MCPcopy
hub / github.com/QwikDev/qwik / processData

Function processData

packages/qwik/src/core/render/ssr/render-ssr.ts:879–930  ·  view source on GitHub ↗
(
  node: any,
  rCtx: RenderContext,
  ssrCtx: SSRContext,
  stream: StreamWriter,
  flags: number,
  beforeClose?: (stream: StreamWriter) => ValueOrPromise<void>
)

Source from the content-addressed store, hash-verified

877
878/** Embed metadata while rendering the tree, to be used when resuming */
879const processData = (
880 node: any,
881 rCtx: RenderContext,
882 ssrCtx: SSRContext,
883 stream: StreamWriter,
884 flags: number,
885 beforeClose?: (stream: StreamWriter) => ValueOrPromise<void>
886): ValueOrPromise<void> => {
887 if (node == null || typeof node === 'boolean') {
888 return;
889 }
890 if (isString(node) || typeof node === 'number') {
891 stream.write(escapeHtml(String(node)));
892 } else if (isJSXNode(node)) {
893 return renderNode(node, rCtx, ssrCtx, stream, flags, beforeClose);
894 } else if (isArray(node)) {
895 return walkChildren(node, rCtx, ssrCtx, stream, flags);
896 } else if (isSignal(node)) {
897 const insideText = flags & IS_TEXT;
898 const hostEl = rCtx.$cmpCtx$?.$element$ as QwikElement;
899 let value;
900 if (hostEl) {
901 if (!insideText) {
902 const id = getNextIndex(rCtx);
903 const subs =
904 flags & IS_IMMUTABLE
905 ? ([3, ('#' + id) as any, node, ('#' + id) as any] as const)
906 : ([4, hostEl, node, ('#' + id) as any] as const);
907
908 value = trackSignal(node, subs);
909 if (isString(value)) {
910 const str = jsxToString(value);
911 ssrCtx.$static$.$textNodes$.set(str, id);
912 }
913 stream.write(`<!--t=${id}-->`);
914 processData(value, rCtx, ssrCtx, stream, flags, beforeClose);
915 stream.write(`<!---->`);
916 return;
917 } else {
918 value = invoke(ssrCtx.$invocationContext$, () => node.value);
919 }
920 }
921 stream.write(escapeHtml(jsxToString(value)));
922 return;
923 } else if (isPromise(node)) {
924 stream.write(FLUSH_COMMENT);
925 return node.then((node) => processData(node, rCtx, ssrCtx, stream, flags, beforeClose));
926 } else {
927 logWarn('A unsupported value was passed to the JSX, skipping render. Value:', node);
928 return;
929 }
930};
931
932const walkChildren = (
933 children: unknown,

Callers 6

renderRootFunction · 0.70
renderGeneratorFunction · 0.70
renderNodeVirtualFunction · 0.70
renderSSRComponentFunction · 0.70
renderNodeFunction · 0.70
walkChildrenFunction · 0.70

Calls 14

isStringFunction · 0.90
isJSXNodeFunction · 0.90
isArrayFunction · 0.90
isSignalFunction · 0.90
getNextIndexFunction · 0.90
trackSignalFunction · 0.90
jsxToStringFunction · 0.90
invokeFunction · 0.90
isPromiseFunction · 0.90
logWarnFunction · 0.90
renderNodeFunction · 0.85
walkChildrenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…