foldkit 0.163.0 → 0.164.0-canary.24f1c43eaaf7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/buildToken.d.ts +6 -0
  2. package/dist/buildToken.d.ts.map +1 -1
  3. package/dist/buildToken.js +11 -6
  4. package/dist/devTools/protocol.d.ts +20 -0
  5. package/dist/devTools/protocol.d.ts.map +1 -1
  6. package/dist/devTools/protocol.js +19 -0
  7. package/dist/devTools/public.d.ts +1 -1
  8. package/dist/devTools/public.d.ts.map +1 -1
  9. package/dist/devTools/public.js +1 -1
  10. package/dist/experimental/server/serialize.d.ts.map +1 -1
  11. package/dist/experimental/server/serialize.js +86 -28
  12. package/dist/experimental/server/server.d.ts +20 -19
  13. package/dist/experimental/server/server.d.ts.map +1 -1
  14. package/dist/experimental/server/server.js +26 -18
  15. package/dist/runtime/hydrationHandoff.js +4 -4
  16. package/dist/runtime/start.d.ts +9 -7
  17. package/dist/runtime/start.d.ts.map +1 -1
  18. package/dist/runtime/start.js +2 -1
  19. package/dist/schema/index.d.ts +15 -9
  20. package/dist/schema/index.d.ts.map +1 -1
  21. package/dist/snabbdom/eventlisteners.d.ts.map +1 -1
  22. package/dist/snabbdom/eventlisteners.js +5 -0
  23. package/dist/subscription/fromMediaQuery.d.ts +57 -0
  24. package/dist/subscription/fromMediaQuery.d.ts.map +1 -0
  25. package/dist/subscription/fromMediaQuery.js +46 -0
  26. package/dist/subscription/public.d.ts +2 -0
  27. package/dist/subscription/public.d.ts.map +1 -1
  28. package/dist/subscription/public.js +1 -0
  29. package/dist/test/query.d.ts +30 -15
  30. package/dist/test/query.d.ts.map +1 -1
  31. package/dist/test/query.js +169 -53
  32. package/dist/vdom.d.ts +3 -3
  33. package/dist/vdom.d.ts.map +1 -1
  34. package/dist/vdom.js +17 -7
  35. package/package.json +9 -9
@@ -1,3 +1,9 @@
1
+ /** The build id compiled into this Foldkit artifact, when one was supplied.
2
+ * @internal */
3
+ export declare const injectedBuildId: string | undefined;
4
+ /** Uses an explicit build id when present and the compiled artifact id otherwise.
5
+ * @internal */
6
+ export declare const buildIdOrInjected: (buildId: string | undefined) => string | undefined;
1
7
  /** The attribute a hydratable render stamps the build id onto. */
2
8
  export declare const HYDRATION_BUILD_ATTRIBUTE = "data-foldkit-build";
3
9
  //# sourceMappingURL=buildToken.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildToken.d.ts","sourceRoot":"","sources":["../src/buildToken.ts"],"names":[],"mappings":"AAoBA,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,uBAAuB,CAAA"}
1
+ {"version":3,"file":"buildToken.d.ts","sourceRoot":"","sources":["../src/buildToken.ts"],"names":[],"mappings":"AAoBA;eACe;AACf,eAAO,MAAM,eAAe,oBAA8B,CAAA;AAE1D;eACe;AACf,eAAO,MAAM,iBAAiB,YACnB,MAAM,GAAG,SAAS,KAC1B,MAAM,GAAG,SAAgE,CAAA;AAE5E,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,uBAAuB,CAAA"}
@@ -11,11 +11,16 @@
11
11
  // DOM state on a stale page could otherwise be carried into a view that now
12
12
  // means something else.
13
13
  //
14
- // Both sides are given the id explicitly rather than reading it from a
15
- // compile-time constant inside this package. Vite externalizes an installed
16
- // dependency from a server build, where a define never reaches it, so a
17
- // framework-internal read is silently absent in exactly the production shape
18
- // that matters. Application code is always transformed, so the entries read
19
- // `import.meta.env.FOLDKIT_BUILD_ID` and pass what they find.
14
+ // The Vite plugin replaces this call while compiling the client and server
15
+ // artifacts. Leaving it as a function keeps direct Node use and builds without
16
+ // the plugin fail-closed: the framework sees no identity and refuses hydratable
17
+ // rendering or hydration instead of sharing a fallback across deployments.
18
+ const foldkitBuildIdPlaceholder = () => undefined;
19
+ /** The build id compiled into this Foldkit artifact, when one was supplied.
20
+ * @internal */
21
+ export const injectedBuildId = foldkitBuildIdPlaceholder();
22
+ /** Uses an explicit build id when present and the compiled artifact id otherwise.
23
+ * @internal */
24
+ export const buildIdOrInjected = (buildId) => (buildId === undefined ? injectedBuildId : buildId);
20
25
  /** The attribute a hydratable render stamps the build id onto. */
21
26
  export const HYDRATION_BUILD_ATTRIBUTE = 'data-foldkit-build';
@@ -573,4 +573,24 @@ export declare const EventFrame: Schema.Struct<{
573
573
  }>;
574
574
  /** A wire frame carrying a runtime lifecycle event. */
575
575
  export type EventFrame = typeof EventFrame.Type;
576
+ /** Increment when the relay record's wire format changes. */
577
+ export declare const RELAY_RECORD_VERSION = 1;
578
+ /** Directory name under `XDG_RUNTIME_DIR` or the system temporary directory. */
579
+ export declare const RELAY_REGISTRY_DIRECTORY_NAME = "foldkit-devtools-relays";
580
+ /** Environment variable that sets the relay registry directory. */
581
+ export declare const RELAY_REGISTRY_DIRECTORY_VARIABLE = "FOLDKIT_DEVTOOLS_RELAY_DIRECTORY";
582
+ /**
583
+ * Record published while a Vite relay listens. `root` selects the project;
584
+ * `id` distinguishes a restarted relay from the one it replaced.
585
+ */
586
+ export declare const RelayRecord: Schema.Struct<{
587
+ readonly version: Schema.Literal<1>;
588
+ readonly id: Schema.String;
589
+ readonly root: Schema.String;
590
+ readonly url: Schema.String;
591
+ readonly pid: Schema.Number;
592
+ readonly startedAt: Schema.Number;
593
+ }>;
594
+ /** Decoded record for a running DevTools MCP relay. */
595
+ export type RelayRecord = typeof RelayRecord.Type;
576
596
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/devTools/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAA;AAMvC,yRAAyR;AACzR,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAA;AACF,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAE7D,0MAA0M;AAC1M,eAAO,MAAM,eAAe;;;EAG1B,CAAA;AACF,yFAA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;;YAGd,SAAS;YACT,OAAO;YACP,OAAO;;;;;wBA5DE,KAAK;;;;;;;;;;;;YA8DK,SAAS;;;;;YACV,KAAK;;;;YAEH,eAAe;;;YACV,iBAAiB;;;YACxB,QAAQ;;;;;;;YAE1B,UAAU;YACV,QAAQ;;;;;YACR,WAAW;;;;;;YAGX,YAAY;YACZ,UAAU;YACV,YAAY;YACZ,QAAQ;YACR,kBAAkB;YAClB,YAAY;;;YAGZ,WAAW;;oBAjDe,KAAK;;;;;;;;;oBACF,QAAQ;;;;;YAkDtB,MAAM;;;EA8BvB,CAAA;AACF,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD,0FAA0F;AAC1F,eAAO,MAAM,UAAU;;;;YA1BH,OAAO;;;;;;;YACJ,YAAY;;;EA4BjC,CAAA;AACF,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAI/C,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB,IAAI,CAAA;AAErC,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,4BAA4B,CAAA;AAEtE,mEAAmE;AACnE,eAAO,MAAM,iCAAiC,qCACV,CAAA;AAEpC;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAA;AACF,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA"}
@@ -186,3 +186,22 @@ export const EventFrame = Schema.Struct({
186
186
  maybeConnectionId: Schema.OptionFromNullOr(Schema.String),
187
187
  event: Event,
188
188
  });
189
+ // RELAY REGISTRY
190
+ /** Increment when the relay record's wire format changes. */
191
+ export const RELAY_RECORD_VERSION = 1;
192
+ /** Directory name under `XDG_RUNTIME_DIR` or the system temporary directory. */
193
+ export const RELAY_REGISTRY_DIRECTORY_NAME = 'foldkit-devtools-relays';
194
+ /** Environment variable that sets the relay registry directory. */
195
+ export const RELAY_REGISTRY_DIRECTORY_VARIABLE = 'FOLDKIT_DEVTOOLS_RELAY_DIRECTORY';
196
+ /**
197
+ * Record published while a Vite relay listens. `root` selects the project;
198
+ * `id` distinguishes a restarted relay from the one it replaced.
199
+ */
200
+ export const RelayRecord = Schema.Struct({
201
+ version: Schema.Literal(RELAY_RECORD_VERSION),
202
+ id: Schema.String,
203
+ root: Schema.String,
204
+ url: Schema.String,
205
+ pid: Schema.Number,
206
+ startedAt: Schema.Number,
207
+ });
@@ -1,2 +1,2 @@
1
- export { DiffValue, Event, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaResult, MessageTagCount, ModelDiffChange, Request, RequestFrame, Response, ResponseFrame, RuntimeInfo, SerializedEntry, } from './protocol.js';
1
+ export { DiffValue, Event, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaResult, MessageTagCount, ModelDiffChange, RELAY_RECORD_VERSION, RELAY_REGISTRY_DIRECTORY_NAME, RELAY_REGISTRY_DIRECTORY_VARIABLE, RelayRecord, Request, RequestFrame, Response, ResponseFrame, RuntimeInfo, SerializedEntry, } from './protocol.js';
2
2
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/devTools/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/devTools/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,6BAA6B,EAC7B,iCAAiC,EACjC,WAAW,EACX,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAA"}
@@ -1 +1 @@
1
- export { DiffValue, Event, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaResult, MessageTagCount, ModelDiffChange, Request, RequestFrame, Response, ResponseFrame, RuntimeInfo, SerializedEntry, } from './protocol.js';
1
+ export { DiffValue, Event, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaResult, MessageTagCount, ModelDiffChange, RELAY_RECORD_VERSION, RELAY_REGISTRY_DIRECTORY_NAME, RELAY_REGISTRY_DIRECTORY_VARIABLE, RelayRecord, Request, RequestFrame, Response, ResponseFrame, RuntimeInfo, SerializedEntry, } from './protocol.js';
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/serialize.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAC,CAAA;AAsNF;;;GAGG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAW,MAAM,KAAG,MAMpD,CAAA;AA0MD,eAAO,MAAM,sBAAsB,eACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,MAAM,GAAG,SAMX,CAAA;AA2hBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,SAClB,KAAK,GAAG,IAAI,YACR,gBAAgB,KACzB,MAUF,CAAA"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/serialize.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAC,CAAA;AAsNF;;;GAGG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAW,MAAM,KAAG,MAMpD,CAAA;AA0MD,eAAO,MAAM,sBAAsB,eACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,MAAM,GAAG,SAMX,CAAA;AAsmBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,SAClB,KAAK,GAAG,IAAI,YACR,gBAAgB,KACzB,MA2BF,CAAA"}
@@ -406,21 +406,58 @@ const leadingTextOf = (node) => {
406
406
  }
407
407
  return undefined;
408
408
  };
409
- // NOTE: the serializer recurses per element, so a tree nested thousands of
410
- // elements deep, typically from mapping untrusted hierarchical data straight
411
- // to markup, would exhaust the call stack. The depth is bounded well above any
412
- // real view and refused past the limit, so a hostile input becomes a typed
413
- // SerializationError rather than a stack overflow.
409
+ // NOTE: a view nested thousands of elements deep, typically from mapping
410
+ // untrusted hierarchical data straight to markup, is refused. The depth limit
411
+ // sits well above any real view, so a hostile input becomes a typed
412
+ // SerializationError. The limit is enforced by a pass that does not recurse,
413
+ // before the serializer walks the tree, so the refusal does not depend on how
414
+ // much call stack the runtime has or the caller has already used. Walks that
415
+ // still recurse, such as `hasOptionDescendant` and the parse5 checks in
416
+ // `server.ts`, are bounded by it for elements the view builds. Content inside a
417
+ // trusted `h.InnerHTML` is not counted.
414
418
  const MAX_RENDER_DEPTH = 1000;
415
- const serializeChildren = (output, context, node, depth, selectValue) => {
416
- const children = node.children;
419
+ const assertWithinRenderDepth = (root) => {
420
+ const pendingEntries = [
421
+ { node: root, depth: 0 },
422
+ ];
423
+ for (let entry = pendingEntries.pop(); entry !== undefined; entry = pendingEntries.pop()) {
424
+ const { depth, node } = entry;
425
+ if (depth > MAX_RENDER_DEPTH) {
426
+ throw new Error(`[foldkit] renderToString exceeded the maximum render depth of ${MAX_RENDER_DEPTH}. ` +
427
+ 'A view nesting elements this deeply, often from mapping untrusted ' +
428
+ 'hierarchical data straight to markup, is refused to protect the ' +
429
+ 'render stack.');
430
+ }
431
+ if (typeof node === 'string') {
432
+ continue;
433
+ }
434
+ const { children } = node;
435
+ if (children !== undefined) {
436
+ const childDepth = depth + 1;
437
+ for (const child of children) {
438
+ pendingEntries.push({ node: child, depth: childDepth });
439
+ }
440
+ }
441
+ }
442
+ };
443
+ const scheduleContent = (output, workStack, node, closeElementStep) => {
444
+ const { childSelectValue } = closeElementStep;
445
+ const { children } = node;
417
446
  if (children !== undefined) {
418
- for (const child of children) {
419
- serializeNode(output, context, child, depth + 1, undefined, selectValue);
447
+ workStack.push(closeElementStep);
448
+ for (let index = children.length - 1; index >= 0; index--) {
449
+ workStack.push({
450
+ _tag: 'VisitNode',
451
+ node: Array.getUnsafe(children, index),
452
+ selectValue: childSelectValue,
453
+ });
420
454
  }
421
455
  }
422
- else if (node.text !== undefined) {
423
- output.push(escapeText(node.text));
456
+ else {
457
+ if (node.text !== undefined) {
458
+ output.push(escapeText(node.text));
459
+ }
460
+ workStack.push(closeElementStep);
424
461
  }
425
462
  };
426
463
  // NOTE: an option without a value prop falls back to its label the way the
@@ -552,7 +589,7 @@ const selectValueForChildren = (tagName, node, inherited) => {
552
589
  }
553
590
  return undefined;
554
591
  };
555
- const serializeElement = (output, context, node, selector, depth, extraAttributes, selectValue) => {
592
+ const openElement = (output, context, workStack, node, selector, extraAttributes, selectValue) => {
556
593
  const authoredTagName = tagNameFromSelector(selector);
557
594
  if (!TAG_NAME_PATTERN.test(authoredTagName)) {
558
595
  throw new Error(`[foldkit] Cannot serialize the invalid tag name "${authoredTagName}". Tag ` +
@@ -663,6 +700,12 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
663
700
  const childSelectValue = isForeignNamespace
664
701
  ? undefined
665
702
  : selectValueForChildren(tagName, node, selectValue);
703
+ const closeElementStep = {
704
+ _tag: 'CloseElement',
705
+ tagName,
706
+ childSelectValue,
707
+ selectValue,
708
+ };
666
709
  const isHtmlRawText = !isForeignNamespace && RAW_TEXT_ELEMENTS.has(tagName);
667
710
  const isHtmlRcdata = !isForeignNamespace && RCDATA_ELEMENTS.has(tagName);
668
711
  const innerHtml = data?.props?.['innerHTML'];
@@ -689,6 +732,7 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
689
732
  output.push('\n');
690
733
  }
691
734
  output.push(innerHtml);
735
+ workStack.push(closeElementStep);
692
736
  }
693
737
  else if (!isForeignNamespace && tagName === 'textarea') {
694
738
  const content = controlledValueContent(data?.props);
@@ -697,12 +741,13 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
697
741
  output.push('\n');
698
742
  }
699
743
  output.push(escapeText(content));
744
+ workStack.push(closeElementStep);
700
745
  }
701
746
  else {
702
747
  if (leadingTextOf(node)?.startsWith('\n')) {
703
748
  output.push('\n');
704
749
  }
705
- serializeChildren(output, context, node, depth, childSelectValue);
750
+ scheduleContent(output, workStack, node, closeElementStep);
706
751
  }
707
752
  }
708
753
  else if (!isForeignNamespace && tagName === 'output') {
@@ -712,16 +757,17 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
712
757
  const content = controlledValueContent(data?.props);
713
758
  if (content !== undefined) {
714
759
  output.push(escapeText(content));
760
+ workStack.push(closeElementStep);
715
761
  }
716
762
  else {
717
- serializeChildren(output, context, node, depth, childSelectValue);
763
+ scheduleContent(output, workStack, node, closeElementStep);
718
764
  }
719
765
  }
720
766
  else if (!isForeignNamespace && NEWLINE_DROPPING_ELEMENTS.has(tagName)) {
721
767
  if (leadingTextOf(node)?.startsWith('\n')) {
722
768
  output.push('\n');
723
769
  }
724
- serializeChildren(output, context, node, depth, childSelectValue);
770
+ scheduleContent(output, workStack, node, closeElementStep);
725
771
  }
726
772
  else if (isHtmlRawText) {
727
773
  const rawText = collectRawText(node);
@@ -730,10 +776,14 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
730
776
  assertNoscriptTextIsSafe(rawText);
731
777
  }
732
778
  output.push(rawText);
779
+ workStack.push(closeElementStep);
733
780
  }
734
781
  else {
735
- serializeChildren(output, context, node, depth, childSelectValue);
782
+ scheduleContent(output, workStack, node, closeElementStep);
736
783
  }
784
+ };
785
+ const closeElement = (output, closeElementStep) => {
786
+ const { childSelectValue, selectValue, tagName } = closeElementStep;
737
787
  if (childSelectValue !== undefined &&
738
788
  childSelectValue !== selectValue &&
739
789
  !childSelectValue.consumed &&
@@ -747,16 +797,7 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
747
797
  }
748
798
  output.push(`</${tagName}>`);
749
799
  };
750
- const serializeNode = (output, context, node, depth, extraAttributes, selectValue) => {
751
- if (depth > MAX_RENDER_DEPTH) {
752
- throw new Error(`[foldkit] renderToString exceeded the maximum render depth of ${MAX_RENDER_DEPTH}. ` +
753
- 'A view nesting elements this deeply, often from mapping untrusted ' +
754
- 'hierarchical data straight to markup, is refused to protect the ' +
755
- 'render stack.');
756
- }
757
- if (node === null) {
758
- return;
759
- }
800
+ const visitNode = (output, context, workStack, node, extraAttributes, selectValue) => {
760
801
  if (typeof node === 'string') {
761
802
  output.push(escapeText(node));
762
803
  return;
@@ -774,7 +815,7 @@ const serializeNode = (output, context, node, depth, extraAttributes, selectValu
774
815
  output.push(`<!--${commentText}-->`);
775
816
  return;
776
817
  }
777
- serializeElement(output, context, node, selector, depth, extraAttributes, selectValue);
818
+ openElement(output, context, workStack, node, selector, extraAttributes, selectValue);
778
819
  };
779
820
  /** Serializes a view-produced vnode tree to an HTML string. Event handlers and
780
821
  * hooks are behavior, not markup, and are skipped; attrs, class, dataset,
@@ -793,10 +834,27 @@ export const serializeHtml = (root, options) => {
793
834
  if (root === null) {
794
835
  return '<!---->';
795
836
  }
837
+ assertWithinRenderDepth(root);
796
838
  const context = {
797
839
  emitHydrationMarkers: options?.emitHydrationMarkers ?? false,
798
840
  };
799
841
  const output = [];
800
- serializeNode(output, context, root, 0, options?.rootAttributes);
842
+ const workStack = [
843
+ {
844
+ _tag: 'VisitNode',
845
+ node: root,
846
+ selectValue: undefined,
847
+ extraAttributes: options?.rootAttributes,
848
+ },
849
+ ];
850
+ for (let step = workStack.pop(); step !== undefined; step = workStack.pop()) {
851
+ if (step._tag === 'VisitNode') {
852
+ const { node, extraAttributes, selectValue } = step;
853
+ visitNode(output, context, workStack, node, extraAttributes, selectValue);
854
+ }
855
+ else {
856
+ closeElement(output, step);
857
+ }
858
+ }
801
859
  return output.join('');
802
860
  };
@@ -85,14 +85,13 @@ export declare class InvalidHydrationRoot extends InvalidHydrationRoot_base<{
85
85
  declare const MissingBuildId_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
86
86
  readonly _tag: "MissingBuildId";
87
87
  } & Readonly<A>;
88
- /** Failure of a hydratable render that was given no build id. Hydration
88
+ /** Failure of a hydratable render that has no build id. Hydration
89
89
  * compares the id on the served root with the client's own to refuse a page
90
90
  * from another deployment, so a render that carries none has no such
91
- * protection. Supply one from a value the deployment already has, such as a
92
- * commit or a release tag, through `@foldkit/vite-plugin`'s `buildId` option or
93
- * the `FOLDKIT_BUILD_ID` environment variable, and pass
94
- * `import.meta.env.FOLDKIT_BUILD_ID` to `renderToString` and `Runtime.hydrate`.
95
- * A render that nothing will hydrate (`isHydratable: false`) needs none.
91
+ * protection. Build both artifacts together with `@foldkit/vite-plugin`, or
92
+ * supply the same nonempty `buildId` explicitly when client and server builds
93
+ * are orchestrated separately. A render that nothing will hydrate
94
+ * (`isHydratable: false`) needs none.
96
95
  *
97
96
  * @experimental Ships from `foldkit/experimental/server`; expect breaking changes while the API settles.
98
97
  */
@@ -145,9 +144,9 @@ export type ApplicationConfig<Model, Message> = Readonly<{
145
144
  type CommonRenderOptions = Readonly<{
146
145
  runtimeId?: string;
147
146
  }>;
148
- /** Render options for output a client will hydrate, which is the default. The
149
- * build id is required here: hydration compares it against the client's own
150
- * before adopting any DOM, and a page carrying none has no such protection.
147
+ /** Render options for output a client will hydrate, which is the default.
148
+ * Hydration compares the render's build id against the client's own before
149
+ * adopting any DOM, and a page carrying none has no such protection.
151
150
  *
152
151
  * @experimental Ships from `foldkit/experimental/server`; expect breaking changes while the API settles.
153
152
  */
@@ -155,12 +154,13 @@ export type HydratableRenderOptions = CommonRenderOptions & Readonly<{
155
154
  isHydratable?: true;
156
155
  /**
157
156
  * The deployment this render belongs to, stamped on the root so hydration
158
- * can refuse a page from a different one before adopting its DOM. Pass
159
- * `import.meta.env.FOLDKIT_BUILD_ID`, which `@foldkit/vite-plugin` fills
160
- * from its `buildId` option or the `FOLDKIT_BUILD_ID` environment variable,
161
- * and give the client entry the same value.
157
+ * can refuse a page from a different one before adopting its DOM. Foldkit
158
+ * normally reads the identity compiled into the server artifact by
159
+ * `@foldkit/vite-plugin`. This explicit option is for integrations that
160
+ * cannot compile the shared identity into the artifact. Give the client
161
+ * the same public value.
162
162
  */
163
- buildId: string;
163
+ buildId?: string;
164
164
  }>;
165
165
  /** Render options for static markup nothing will hydrate. No build id applies,
166
166
  * because no client will compare one.
@@ -177,9 +177,11 @@ export type StaticRenderOptions = CommonRenderOptions & Readonly<{
177
177
  * Model, and scroll preservation. It does not permit a second hydratable
178
178
  * application in one document.
179
179
  *
180
- * A hydratable render (the default) requires `buildId`. Pass
181
- * `isHydratable: false` for static markup that nothing will hydrate, which
182
- * takes no build id.
180
+ * A hydratable render (the default) uses the build identity compiled by
181
+ * `@foldkit/vite-plugin`. Pass `isHydratable: false` for static markup that
182
+ * nothing will hydrate, which takes no build id. The explicit `buildId`
183
+ * option supports integrations that cannot compile the shared identity into
184
+ * their artifacts.
183
185
  *
184
186
  * @experimental Ships from `foldkit/experimental/server`; expect breaking changes while the API settles.
185
187
  */
@@ -237,7 +239,6 @@ export type RenderUrlFlagsOptions<Flags> = RenderUrlOptions & RenderFlagsOptions
237
239
  * const renderedApplication = yield* Server.renderToString(config, {
238
240
  * url: request.url,
239
241
  * flags: { theme },
240
- * buildId: import.meta.env.FOLDKIT_BUILD_ID,
241
242
  * })
242
243
  * ```
243
244
  *
@@ -246,5 +247,5 @@ export type RenderUrlFlagsOptions<Flags> = RenderUrlOptions & RenderFlagsOptions
246
247
  export declare function renderToString<Model, Message, Flags>(config: RoutingApplicationConfigWithFlags<Model, Message, Flags>, options: RenderUrlFlagsOptions<Flags>): Effect.Effect<RenderedApplication, RenderError>;
247
248
  export declare function renderToString<Model, Message>(config: RoutingApplicationConfig<Model, Message>, options: RenderUrlOptions): Effect.Effect<RenderedApplication, RenderError>;
248
249
  export declare function renderToString<Model, Message, Flags>(config: ApplicationConfigWithFlags<Model, Message, Flags>, options: RenderFlagsOptions<Flags>): Effect.Effect<RenderedApplication, RenderError>;
249
- export declare function renderToString<Model, Message>(config: ApplicationConfig<Model, Message>, options: RenderOptions): Effect.Effect<RenderedApplication, RenderError>;
250
+ export declare function renderToString<Model, Message>(config: ApplicationConfig<Model, Message>, options?: RenderOptions): Effect.Effect<RenderedApplication, RenderError>;
250
251
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EAGN,MAAM,EAGP,MAAM,QAAQ,CAAA;AAgBf,OAAO,EACL,KAAK,QA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AC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Array, Context, Data, Effect, Option, Predicate, Schema, String, pipe, } from 'effect';
2
2
  import { html as Parse5Html, defaultTreeAdapter, parse, parseFragment, } from 'parse5';
3
- import { HYDRATION_BUILD_ATTRIBUTE } from '../../buildToken.js';
3
+ import { HYDRATION_BUILD_ATTRIBUTE, buildIdOrInjected, } from '../../buildToken.js';
4
4
  import { MATHML_NAMESPACE, SVG_NAMESPACE, parsedAttributeName, } from '../../domReflection.js';
5
5
  import { beginRender, createBoundaryRegistry } from '../../html/boundary.js';
6
6
  import { __htmlBuilder as htmlBuilderFor, textDirectionToAttribute, } from '../../html/index.js';
@@ -555,7 +555,7 @@ const reservedHandoffAttributeIn = (node) => {
555
555
  const hasScriptElement = (node) => node.childNodes.some(child => isParse5Element(child) &&
556
556
  (child.tagName.toLowerCase() === 'script' ||
557
557
  hasScriptElement(traversableContent(child))));
558
- const assertViewDoesNotAuthorReservedContent = (node) => {
558
+ const assertNodeDoesNotAuthorReservedContent = (node) => {
559
559
  const attrs = node.data?.attrs;
560
560
  if (attrs !== undefined) {
561
561
  for (const name of Object.keys(attrs)) {
@@ -598,9 +598,19 @@ const assertViewDoesNotAuthorReservedContent = (node) => {
598
598
  'ordinary view element or move it to the HTML template instead.');
599
599
  }
600
600
  }
601
- for (const child of node.children ?? []) {
602
- if (typeof child !== 'string') {
603
- assertViewDoesNotAuthorReservedContent(child);
601
+ };
602
+ const assertViewDoesNotAuthorReservedContent = (root) => {
603
+ const pendingNodes = [root];
604
+ for (let node = pendingNodes.pop(); node !== undefined; node = pendingNodes.pop()) {
605
+ assertNodeDoesNotAuthorReservedContent(node);
606
+ const { children } = node;
607
+ if (children !== undefined) {
608
+ for (let index = children.length - 1; index >= 0; index--) {
609
+ const child = Array.getUnsafe(children, index);
610
+ if (typeof child !== 'string') {
611
+ pendingNodes.push(child);
612
+ }
613
+ }
604
614
  }
605
615
  }
606
616
  };
@@ -735,14 +745,13 @@ export class InvalidRuntimeId extends Data.TaggedError('InvalidRuntimeId') {
735
745
  */
736
746
  export class InvalidHydrationRoot extends Data.TaggedError('InvalidHydrationRoot') {
737
747
  }
738
- /** Failure of a hydratable render that was given no build id. Hydration
748
+ /** Failure of a hydratable render that has no build id. Hydration
739
749
  * compares the id on the served root with the client's own to refuse a page
740
750
  * from another deployment, so a render that carries none has no such
741
- * protection. Supply one from a value the deployment already has, such as a
742
- * commit or a release tag, through `@foldkit/vite-plugin`'s `buildId` option or
743
- * the `FOLDKIT_BUILD_ID` environment variable, and pass
744
- * `import.meta.env.FOLDKIT_BUILD_ID` to `renderToString` and `Runtime.hydrate`.
745
- * A render that nothing will hydrate (`isHydratable: false`) needs none.
751
+ * protection. Build both artifacts together with `@foldkit/vite-plugin`, or
752
+ * supply the same nonempty `buildId` explicitly when client and server builds
753
+ * are orchestrated separately. A render that nothing will hydrate
754
+ * (`isHydratable: false`) needs none.
746
755
  *
747
756
  * @experimental Ships from `foldkit/experimental/server`; expect breaking changes while the API settles.
748
757
  */
@@ -833,13 +842,12 @@ export function renderToString(config, options) {
833
842
  const hasRouting = config.routing !== undefined;
834
843
  const FlagsCodec = config.Flags;
835
844
  const isHydratable = options?.isHydratable ?? true;
836
- // A hydratable render must say which deployment it came from. Deriving it
837
- // here is not possible: the render cannot see the sources, the
838
- // configuration, or the dependencies that decide what the view produced, so
839
- // an id it invented would either differ between the client and server
840
- // builds of one deployment or be shared by two that render differently.
841
- // Refusing is the only honest answer, and it names what to supply.
842
- const configuredBuildId = options?.buildId;
845
+ // A hydratable render must say which deployment it came from. The Vite
846
+ // plugin compiles that identity into Foldkit when it coordinates the client
847
+ // and server artifacts. Separately built artifacts must receive the same
848
+ // explicit value. With neither source, refusing keeps an unstamped page
849
+ // from being mistaken for this deployment.
850
+ const configuredBuildId = buildIdOrInjected(options?.buildId);
843
851
  const isConfiguredBuildId = Predicate.isString(configuredBuildId) &&
844
852
  !String.isEmpty(configuredBuildId);
845
853
  if (isHydratable && !isConfiguredBuildId) {
@@ -76,12 +76,12 @@ const assertSinglePageApplication = (stampedRoots) => {
76
76
  // exact case the id exists to refuse.
77
77
  export const buildSkew = (root, buildId, runtimeId) => {
78
78
  if (!Predicate.isString(buildId) || buildId === '') {
79
- return new Error('[foldkit] Runtime.hydrate was given no build id. Hydration compares ' +
79
+ return new Error('[foldkit] Runtime.hydrate has no build id. Hydration compares ' +
80
80
  'the id the server stamped on the root with this client’s own before ' +
81
81
  'it adopts any DOM, and without one a page from any deployment would ' +
82
- 'be adopted as this one. Pass ' +
83
- '`buildId: import.meta.env.FOLDKIT_BUILD_ID`, the same value the ' +
84
- 'server entry passes to `renderToString`.');
82
+ 'be adopted as this one. Build the client with @foldkit/vite-plugin, ' +
83
+ 'or pass the same nonempty `buildId` explicitly to `Runtime.hydrate` ' +
84
+ 'and `renderToString`.');
85
85
  }
86
86
  const servedBuild = root.getAttribute(HYDRATION_BUILD_ATTRIBUTE);
87
87
  if (servedBuild === buildId) {
@@ -34,14 +34,16 @@ export type HydrateOptions = Readonly<{
34
34
  * The deployment this client belongs to, compared against the id the server
35
35
  * stamped on the root before the Flags payload text is accessed or decoded,
36
36
  * so a page from a different deployment stops startup rather than handing its
37
- * Flags to this build. Required, and must be non-empty: an absent id would
38
- * equal the absent marker on a page served before build ids existed.
37
+ * Flags to this build. When omitted, Foldkit uses the identity compiled into
38
+ * this artifact by `@foldkit/vite-plugin`. An explicit id overrides that
39
+ * value and must be non-empty: an absent id would equal the absent marker on
40
+ * a page served before build ids existed.
39
41
  *
40
- * Pass `import.meta.env.FOLDKIT_BUILD_ID`, which `@foldkit/vite-plugin` fills
41
- * from its `buildId` option or the `FOLDKIT_BUILD_ID` environment variable,
42
- * the same value the server entry passes to `renderToString`.
42
+ * This explicit option is for integrations that cannot compile the shared
43
+ * identity into the artifact. Give the server the same public,
44
+ * deployment-specific value.
43
45
  */
44
- buildId: string;
46
+ buildId?: string;
45
47
  }>;
46
48
  /** Starts a Foldkit runtime by adopting a server-rendered DOM in place instead
47
49
  * of building it fresh. Use this as the client entry for a page served by
@@ -67,7 +69,7 @@ export type HydrateOptions = Readonly<{
67
69
  *
68
70
  * @experimental Server rendering and hydration are experimental while their
69
71
  * contracts settle. */
70
- export declare const hydrate: <P extends Ports | undefined, Flags, Resources>(program: MakeRuntimeReturn<P, Flags, Resources, 'Application'>, options: HydrateOptions) => void;
72
+ export declare const hydrate: <P extends Ports | undefined, Flags, Resources>(program: MakeRuntimeReturn<P, Flags, Resources, 'Application'>, options?: HydrateOptions) => void;
71
73
  /**
72
74
  * Starts a Foldkit runtime under a host-controlled lifecycle and returns an
73
75
  * `EmbedHandle`. This is the entry point for embedding a Foldkit app inside
@@ -1 +1 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAA2C,MAAM,QAAQ,CAAA;AAI/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,cAAc,CAAA;AAEvE;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,QAAQ,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;CAC9C,CAAC,CAAA;AAEF,KAAK,cAAc,GAAG,QAAQ,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxD,KAAK,EAAE,KAAK,GAAG,SAA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BAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,YACpD,cAAc,KACvB,IAOF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CACnB,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EACvC,SAAS,GAAG,KAAK,EACjB,IAAI,SAAS,aAAa,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,EAClE,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AACvE,wBAAgB,KAAK,CACnB,CAAC,SAAS,KAAK,GAAG,SAAS,EAC3B,KAAK,EACL,SAAS,EACT,IAAI,SAAS,aAAa,GAAG,SAAS,EAEtC,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,EACrD,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,GACpC,WAAW,CAAC,CAAC,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { Cause, Effect, Fiber, Option, Predicate, Runtime, pipe } from 'effect';
2
2
  import { BrowserRuntime } from '@effect/platform-browser';
3
+ import { buildIdOrInjected } from '../buildToken.js';
3
4
  import { provideBrowserScheduler } from './browserScheduler.js';
4
5
  import { buildPortHandles, makeHostConnector, } from './hostConnector.js';
5
6
  import { resolvePreservedModel } from './modelPreservationBridge.js';
@@ -60,7 +61,7 @@ export function run(program, options) {
60
61
  * @experimental Server rendering and hydration are experimental while their
61
62
  * contracts settle. */
62
63
  export const hydrate = (program, options) => {
63
- startProgram(program, 'Hydrate', undefined, options?.buildId);
64
+ startProgram(program, 'Hydrate', undefined, buildIdOrInjected(options?.buildId));
64
65
  };
65
66
  export function embed(program, options) {
66
67
  const internals = runtimeInternals.get(program);