foldkit 0.148.0 → 0.148.2

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.
package/README.md CHANGED
@@ -18,12 +18,14 @@
18
18
 
19
19
  ---
20
20
 
21
- Foldkit is a TypeScript frontend framework built on [Effect](https://effect.website/) and architected like [Elm](https://guide.elm-lang.org/architecture/). One Model, one update function, one way to do things. No hooks, no local state, no hidden mutations. It's all in on Effect with no escape hatch, though a program doesn't have to own the whole page: [`Runtime.embed`](https://foldkit.dev/core/embedding) runs a Foldkit widget inside any existing app, React included. The same program also [renders on the server](https://foldkit.dev/core/server-rendering), at build time or per request, and hydrates in place.
21
+ Foldkit is a TypeScript frontend framework built on [Effect](https://effect.website/). It gives your entire application one architecture: a [Schema](https://effect.website/docs/schema/introduction/)-defined Model as the single source of truth, fact-named Messages, an exhaustive update function, and explicit Commands for side effects. Routing, server rendering, UI components, Submodels, and browser lifecycles all use that same Model and Message flow.
22
22
 
23
- Your Model is a [Schema](https://effect.website/docs/schema/introduction/) and side effects are values you return, not callbacks you fire. If you know Effect, Foldkit feels natural. If you're new to it, Foldkit is a good way in. Coming from React? [Start here](https://foldkit.dev/react/coming-from-react), or read the [same pixel-art editor built in both frameworks](https://foldkit.dev/react/foldkit-vs-react-side-by-side).
23
+ Foldkit uses [The Elm Architecture](https://guide.elm-lang.org/architecture/) instead of component-owned state and hook lifecycles. That discipline is a real commitment. Foldkit works best when the team wants shared conventions across the application and is ready to build on Effect throughout. If your backend already uses Effect, Foldkit carries the same tools and patterns into the browser: Schema, services, Streams, and scoped resources.
24
+
25
+ A Foldkit program can own the whole page or run as a widget inside an existing application, React included, through [`Runtime.embed`](https://foldkit.dev/core/embedding). The same program can [render on the server](https://foldkit.dev/core/server-rendering) at build time or per request, then hydrate in place. Coming from React? [Start here](https://foldkit.dev/react/coming-from-react), or compare the [same pixel-art editor built in both frameworks](https://foldkit.dev/react/foldkit-vs-react-side-by-side).
24
26
 
25
27
  > [!NOTE]
26
- > Foldkit is pre-1.0. The core API is stable, but breaking changes may occur in minor releases. See the [changelog](./CHANGELOG.md) for details.
28
+ > Foldkit is in beta and under active development. The core API is stable, but breaking changes may occur in minor releases. See the [changelog](./CHANGELOG.md) for details.
27
29
 
28
30
  ## Get Started
29
31
 
@@ -35,7 +37,7 @@ npx create-foldkit-app@latest
35
37
 
36
38
  ## Counter
37
39
 
38
- A complete Foldkit program. State lives in a single Model, events become Messages, and a pure function handles every transition. `main.ts` defines the program and `entry.ts` boots the runtime, so `main.ts` stays importable from tests without booting a runtime as a side effect.
40
+ A complete Foldkit program. State lives in a single Model, events become Messages, and a pure function handles every transition. `main.ts` defines the program and `entry.ts` boots the Runtime, so `main.ts` stays importable from tests without booting a Runtime as a side effect.
39
41
 
40
42
  ```ts
41
43
  // src/main.ts
@@ -124,9 +126,9 @@ Source: [examples/counter](https://github.com/foldkit/foldkit/blob/main/examples
124
126
 
125
127
  ## What Ships With Foldkit
126
128
 
127
- A complete system, not a collection of libraries you stitch together. Each of these is documented in depth at [foldkit.dev](https://foldkit.dev).
129
+ Routing, server rendering, UI components, composition, and browser lifecycles all use the same Model and Message flow. The pieces below ship as one system and are documented in depth at [foldkit.dev](https://foldkit.dev).
128
130
 
129
- - **Commands**: Side effects as named Effects that return Messages and are run by the runtime.
131
+ - **Commands**: Side effects as named Effects that return Messages and are run by the Runtime.
130
132
  - **Routing**: Type-safe bidirectional routing from parser combinators. URLs parse to Routes, Routes build URLs.
131
133
  - **Subscriptions**: External event streams declared as a function of the Model.
132
134
  - **Managed Resources**: Model-driven lifecycle for WebSockets, AudioContext, and other long-lived handles.
@@ -146,9 +148,9 @@ A complete system, not a collection of libraries you stitch together. Each of th
146
148
  - **Slow Warnings**: Development warnings when update, view, patch, or Subscription extraction exceeds its budget.
147
149
  - **HMR**: Vite plugin with state-preserving hot module replacement. Change your view, keep your state.
148
150
 
149
- ## Correctness You (And Your LLM) Can See
151
+ ## AI-Assisted Development
150
152
 
151
- Every state change flows through one update function, and every side effect is declared explicitly. You don't have to hold a mental model of what runs when, you can point at it. That's what makes Foldkit unusually AI-friendly: the property that makes the code easy for humans to reason about makes it easy for an LLM to generate and review.
153
+ Every feature has the same visible structure: a Schema-defined Model, fact-named Messages, exhaustive update, and explicit Commands. AI-generated changes follow code paths a person can inspect and test. Foldkit DevTools and its MCP server expose the same Model and Message history while the application runs.
152
154
 
153
155
  ## Examples
154
156
 
@@ -1 +1 @@
1
- {"version":3,"file":"controlledDomState.d.ts","sourceRoot":"","sources":["../src/controlledDomState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAoBhD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,OAAO,EAChB,cAAc,MAAM,EACpB,OAAO,OAAO,KACb,IAqDF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,cAAc,MAAM,KACnB,IA0CF,CAAA;AAsFD,eAAO,MAAM,0BAA0B,GACrC,SAAS,OAAO,EAChB,OAAO,KAAK,KACX,IAYF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,GACjD,SAAS,OAAO,EAChB,cAAc,MAAM,KACnB,IA0BF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,OAAO,EAChB,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,aAAa,CAAC,MAAM,CAuBtB,CAAA"}
1
+ {"version":3,"file":"controlledDomState.d.ts","sourceRoot":"","sources":["../src/controlledDomState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAoBhD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,OAAO,EAChB,cAAc,MAAM,EACpB,OAAO,OAAO,KACb,IAyDF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,cAAc,MAAM,KACnB,IA0CF,CAAA;AAsFD,eAAO,MAAM,0BAA0B,GACrC,SAAS,OAAO,EAChB,OAAO,KAAK,KACX,IAYF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,GACjD,SAAS,OAAO,EAChB,cAAc,MAAM,KACnB,IA0BF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,OAAO,EAChB,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,aAAa,CAAC,MAAM,CAuBtB,CAAA"}
@@ -58,13 +58,17 @@ export const synchronizeControlledDefault = (element, propertyName, value) => {
58
58
  return;
59
59
  }
60
60
  if (propertyName === 'value' && tagName === 'select') {
61
+ // NOTE: set the live selection before copying it into the defaults. Two
62
+ // options can share one value, so `select.value` may already equal the
63
+ // controlled value while a later child `selected` still owns the live
64
+ // selection. The value setter gives the first matching option ownership.
65
+ Reflect.set(element, 'value', value);
61
66
  for (const option of element.querySelectorAll('option')) {
62
67
  if (option.defaultSelected !== option.selected) {
63
68
  option.defaultSelected = option.selected;
64
69
  }
65
70
  setBooleanDefaultAttribute(option, 'selected', option.selected);
66
71
  }
67
- Reflect.set(element, 'value', value);
68
72
  }
69
73
  };
70
74
  /** Clears default state owned by a controlled property that left a vnode.
@@ -32,10 +32,10 @@ export declare const controlledValueContent: (properties: Readonly<Record<string
32
32
  * tree serializes to an empty comment, mirroring how the runtime patches
33
33
  * `null` as a comment node.
34
34
  *
35
- * A hydratable render also stamps a digest of each vnode's key and identity, so
36
- * hydration can tell one logical entity from another; the raw key and the
37
- * compiler's source identity never appear in the markup. A render that is not
38
- * hydratable emits neither.
35
+ * A hydratable render also stamps a fingerprint of each vnode's key and
36
+ * identity, so hydration can tell one logical entity from another; the raw key
37
+ * and the compiler's source identity never appear in the markup. A render that
38
+ * is not hydratable emits neither.
39
39
  *
40
40
  * @internal Not part of the `foldkit/experimental/server` surface; `renderToString` is the public entry to serialization.
41
41
  */
@@ -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,GAAI,OAAO,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAMpD,CAAA;AA0MD,eAAO,MAAM,sBAAsB,GACjC,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,MAAM,GAAG,SAMX,CAAA;AAugBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,KAAK,GAAG,IAAI,EAClB,UAAU,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,GAAI,OAAO,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAMpD,CAAA;AA0MD,eAAO,MAAM,sBAAsB,GACjC,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,KACxD,MAAM,GAAG,SAMX,CAAA;AA2hBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,KAAK,GAAG,IAAI,EAClB,UAAU,gBAAgB,KACzB,MAUF,CAAA"}
@@ -532,7 +532,17 @@ const selectValueForChildren = (tagName, node, inherited) => {
532
532
  if (tagName !== 'select') {
533
533
  return inherited;
534
534
  }
535
- const value = node.data?.props?.['value'];
535
+ const properties = node.data?.props;
536
+ if (isClientOnlyProperty(properties, 'value')) {
537
+ throw new Error('[foldkit] Cannot server-render a native <select> with a client-only ' +
538
+ 'value property. Foldkit applies that value before options exist in ' +
539
+ 'a fresh client render and after they exist during hydration, so the ' +
540
+ 'two renders can select different options. CustomElement property ' +
541
+ 'factories belong on their declared Custom Element. Use h.Value(...) ' +
542
+ 'to give a native select one controlled selection to serialize and ' +
543
+ 'hydrate.');
544
+ }
545
+ const value = properties?.['value'];
536
546
  if (typeof value === 'string') {
537
547
  return {
538
548
  value,
@@ -611,14 +621,20 @@ const serializeElement = (output, context, node, selector, depth, extraAttribute
611
621
  }
612
622
  }
613
623
  // The server HTML does not otherwise carry a vnode's key or identity, so
614
- // hydration would adopt keyed children positionally. Stamp a digest of each so
615
- // hydration can verify it is adopting the same logical entity without the raw
616
- // key or source identity appearing in public markup; it strips the markers as
617
- // it adopts.
624
+ // hydration would adopt keyed children positionally. Stamp a fingerprint of
625
+ // each so hydration can verify it is adopting the same logical entity without
626
+ // the raw key or source identity appearing in public markup; it strips the
627
+ // markers as it adopts.
618
628
  if (context.emitHydrationMarkers) {
619
629
  if (node.key !== undefined) {
620
630
  const keyMarker = hydrationKeyMarker(node.key);
621
631
  if (keyMarker === undefined) {
632
+ if (typeof node.key === 'number' && Number.isNaN(node.key)) {
633
+ throw new Error('[foldkit] Cannot server-render an element keyed by NaN as ' +
634
+ 'hydratable. NaN is not equal to itself, so hydration cannot ' +
635
+ 'tell whether the server and client mean the same element. ' +
636
+ 'Key hydratable elements by a string or a number other than NaN.');
637
+ }
622
638
  throw new Error('[foldkit] Cannot server-render an element keyed by a symbol. A ' +
623
639
  'symbol key cannot be compared across the server and the client ' +
624
640
  '(a local symbol is a new value in every realm, so hydration ' +
@@ -766,10 +782,10 @@ const serializeNode = (output, context, node, depth, extraAttributes, selectValu
766
782
  * tree serializes to an empty comment, mirroring how the runtime patches
767
783
  * `null` as a comment node.
768
784
  *
769
- * A hydratable render also stamps a digest of each vnode's key and identity, so
770
- * hydration can tell one logical entity from another; the raw key and the
771
- * compiler's source identity never appear in the markup. A render that is not
772
- * hydratable emits neither.
785
+ * A hydratable render also stamps a fingerprint of each vnode's key and
786
+ * identity, so hydration can tell one logical entity from another; the raw key
787
+ * and the compiler's source identity never appear in the markup. A render that
788
+ * is not hydratable emits neither.
773
789
  *
774
790
  * @internal Not part of the `foldkit/experimental/server` surface; `renderToString` is the public entry to serialization.
775
791
  */
@@ -6,9 +6,10 @@ export declare const __assertNoDeclarativeShadowRoot: (html: string) => void;
6
6
  export declare const __assertNoLiveBaseElement: (html: string) => void;
7
7
  export declare const __assertNoDocumentStructureEscape: (html: string) => void;
8
8
  export { FOLDKIT_APP_ATTRIBUTE, FOLDKIT_FLAGS_ATTRIBUTE };
9
- /** The server render of one request: the stamped root markup (plus the Flags
10
- * payload script when the application declares Flags) and the `Document`
11
- * head fields for the host to place into its HTML template.
9
+ /** The server render of one request: the body markup and the `Document` head
10
+ * fields for the host to place into its HTML template. Hydratable output
11
+ * contains a stamped root and, when the application declares Flags, its
12
+ * payload script. Static output carries no handoff markers.
12
13
  *
13
14
  * @experimental Ships from `foldkit/experimental/server`; expect breaking changes while the API settles.
14
15
  */
@@ -171,6 +172,8 @@ export type StaticRenderOptions = CommonRenderOptions & Readonly<{
171
172
  }>;
172
173
  /** Options for {@link renderToString}. `runtimeId` names the application in the
173
174
  * root stamp and Flags payload; it defaults to `'app'` and must be non-empty.
175
+ * A nondefault `runtimeId` changes the root, Flags, and HMR pairing. It does
176
+ * not permit a second hydratable application in one document.
174
177
  *
175
178
  * A hydratable render (the default) requires `buildId`. Pass
176
179
  * `isHydratable: false` for static markup that nothing will hydrate, which
@@ -204,10 +207,10 @@ export type RenderUrlFlagsOptions<Flags> = RenderUrlOptions & RenderFlagsOptions
204
207
  *
205
208
  * Resolves `init` for the request (with the given Flags and URL when the
206
209
  * config declares them), runs the pure `view` under a no-op dispatch frame,
207
- * and serializes the resulting `Document` body. The root element is stamped
208
- * with {@link FOLDKIT_APP_ATTRIBUTE} and, when the config declares `Flags`,
209
- * the Schema-encoded Flags ride along in a JSON script tag so a hydrating
210
- * client boots from the same Model.
210
+ * and serializes the resulting `Document` body. For hydratable output, the
211
+ * root element is stamped with {@link FOLDKIT_APP_ATTRIBUTE} and, when the
212
+ * config declares `Flags`, the Schema-encoded Flags ride along in a JSON script
213
+ * tag so a hydrating client boots from the same Model.
211
214
  *
212
215
  * Commands returned by `init` are not run: the rendered HTML is the
213
216
  * post-`init` state, and the client runs those Commands after hydration.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EAGN,MAAM,EAEP,MAAM,QAAQ,CAAA;AAgBf,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAGjB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,0BAA0B,CAAA;AAQjC,OAAO,EAAE,GAAG,EAAc,MAAM,oBAAoB,CAAA;AAmgBpD,eAAO,MAAM,+BAA+B,GAAI,MAAM,MAAM,KAAG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AC,KAAK,EAAE,OAAO,EAAE,KAAK,EAClD,MAAM,EAAE,iCAAiC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAChE,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,GACpC,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;AAClD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAC3C,MAAM,EAAE,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,EAChD,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;AAClD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAClD,MAAM,EAAE,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EACzD,OAAO,EAAE,kBAAkB,CAAC,KAAK,CAAC,GACjC,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;AAKlD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAC3C,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,EACzC,OAAO,EAAE,aAAa,GACrB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Array as Array_, Context, Data, Effect, Option, Predicate, Schema, pipe, } from 'effect';
1
+ import { Array as Array_, Context, Data, Effect, Option, Predicate, Schema, String, pipe, } from 'effect';
2
2
  import { html as Parse5Html, defaultTreeAdapter, parse, parseFragment, } from 'parse5';
3
3
  import { HYDRATION_BUILD_ATTRIBUTE } from '../../buildToken.js';
4
4
  import { MATHML_NAMESPACE, SVG_NAMESPACE, parsedAttributeName, } from '../../domReflection.js';
@@ -857,11 +857,12 @@ export function renderToString(config, options) {
857
857
  // builds of one deployment or be shared by two that render differently.
858
858
  // Refusing is the only honest answer, and it names what to supply.
859
859
  const configuredBuildId = options?.buildId;
860
- if (isHydratable &&
861
- (configuredBuildId === undefined || configuredBuildId === '')) {
860
+ const isConfiguredBuildId = Predicate.isString(configuredBuildId) &&
861
+ !String.isEmpty(configuredBuildId);
862
+ if (isHydratable && !isConfiguredBuildId) {
862
863
  return yield* Effect.fail(new MissingBuildId());
863
864
  }
864
- const buildId = configuredBuildId ?? '';
865
+ const buildId = isConfiguredBuildId ? configuredBuildId : '';
865
866
  const url = hasRouting ? yield* parseUrl(options?.url ?? '') : undefined;
866
867
  const flagsHandoff = isHydratable && FlagsCodec !== undefined
867
868
  ? yield* encodeFlagsHandoff(FlagsCodec, options?.flags, runtimeId)
@@ -36,7 +36,11 @@ export type InjectIntoTemplateOptions = Readonly<{
36
36
  * top-level JSON Flags script. Static output may contain one element, text, or
37
37
  * comment root, or no body output. The helper rejects additional top-level
38
38
  * content, ambiguous handoff markers, and source that the HTML parser drops,
39
- * splits, moves, or reconstructs before insertion.
39
+ * splits, moves, or reconstructs before insertion. It also refuses to place a
40
+ * hydratable application in a template that already contains one. Static body
41
+ * output may be inserted beside a hydratable application because no runtime
42
+ * adopts it. Each insertion still applies that render's `Document` head
43
+ * fields.
40
44
  *
41
45
  * This helper is pure with no module state, so a host process may import it
42
46
  * directly even when the render itself must stay inside the server entry's
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/template.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,aAAa,CAAA;AA6oBpB;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C;iDAC6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,UAAU,mBAAmB,EAC7B,UAAU,yBAAyB,KAClC,MA0MF,CAAA"}
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/experimental/server/template.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,aAAa,CAAA;AA6oBpB;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C;iDAC6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,UAAU,mBAAmB,EAC7B,UAAU,yBAAyB,KAClC,MAuNF,CAAA"}
@@ -462,7 +462,11 @@ const isContainerPlaceholder = (element, containerId) => element.tagName === 'di
462
462
  * top-level JSON Flags script. Static output may contain one element, text, or
463
463
  * comment root, or no body output. The helper rejects additional top-level
464
464
  * content, ambiguous handoff markers, and source that the HTML parser drops,
465
- * splits, moves, or reconstructs before insertion.
465
+ * splits, moves, or reconstructs before insertion. It also refuses to place a
466
+ * hydratable application in a template that already contains one. Static body
467
+ * output may be inserted beside a hydratable application because no runtime
468
+ * adopts it. Each insertion still applies that render's `Document` head
469
+ * fields.
466
470
  *
467
471
  * This helper is pure with no module state, so a host process may import it
468
472
  * directly even when the render itself must stay inside the server entry's
@@ -485,7 +489,7 @@ export const injectIntoTemplate = (template, rendered, options) => {
485
489
  }
486
490
  if (containers.length > 1) {
487
491
  throw new Error(`[foldkit] injectIntoTemplate found more than one <div id="${containerId}"></div> placeholder in the template. ` +
488
- 'Keep exactly one placeholder for each application root.');
492
+ 'Keep exactly one placeholder with that id.');
489
493
  }
490
494
  // The runtime id names an application across the whole page: it pairs a root
491
495
  // with its Flags payload, and it keys the Model and scroll position HMR
@@ -506,8 +510,16 @@ export const injectIntoTemplate = (template, rendered, options) => {
506
510
  'that id. A runtime id names one application for the whole page: it ' +
507
511
  'pairs a root with its Flags payload and keys the Model and scroll ' +
508
512
  'position hot reloading preserves, so two roots sharing one would ' +
509
- "take each other's state. Give each application its own " +
510
- '`runtimeId` when rendering.');
513
+ "take each other's state. Remove the duplicate root. Foldkit " +
514
+ 'supports one page-owning hydratable application per document.');
515
+ }
516
+ const existingApplications = collectMatching(document, element => attributeValue(element, FOLDKIT_APP_ATTRIBUTE) !== undefined);
517
+ if (existingApplications.length > 0) {
518
+ throw new Error('[foldkit] injectIntoTemplate is placing a hydratable application, ' +
519
+ 'but the page already holds a server-rendered application. Foldkit ' +
520
+ 'supports one page-owning application per document because each ' +
521
+ 'application owns the document metadata and installs document-wide ' +
522
+ 'navigation listeners. Render one application per page.');
511
523
  }
512
524
  const existingFlags = collectMatching(document, element => attributeValue(element, FOLDKIT_FLAGS_ATTRIBUTE) === renderedRuntimeId);
513
525
  if (existingFlags.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAwPhD,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,EAAE,OAAO,KAAK,KAAG,MA4BnE,CAAA;AAmsBD,eAAO,MAAM,cAAc,GACzB,eAAe,OAAO,EACtB,WAAW,KAAK,GAAG,IAAI,EACvB,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,EAC7B,SAAS,MAAM,KACd,KAwDF,CAAA"}
1
+ {"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAmUhD,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,EAAE,OAAO,KAAK,KAAG,MA4BnE,CAAA;AA+rBD,eAAO,MAAM,cAAc,GACzB,eAAe,OAAO,EACtB,WAAW,KAAK,GAAG,IAAI,EACvB,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,EAC7B,SAAS,MAAM,KACd,KA0DF,CAAA"}
package/dist/hydrate.js CHANGED
@@ -161,6 +161,44 @@ const isControlledCurrentState = (element, propertyName) => {
161
161
  (propertyName === 'muted' && (tagName === 'audio' || tagName === 'video')));
162
162
  };
163
163
  const STALE_REFLECTED_PROPERTY = Symbol('foldkit/stale-reflected-property');
164
+ const NO_SELECTED_OPTION = -1;
165
+ // NOTE: a controlled select owns the effective state of every descendant
166
+ // option. The serializer marks the first matching option, and the browser's
167
+ // value setter does the same during a fresh render. Compare hydration against
168
+ // that parent-owned state instead of each option's shadowed `selected` prop.
169
+ const registerControlledSelectState = (element, vnode, status) => {
170
+ const properties = vnode.data?.props;
171
+ const authoredValue = properties?.['value'];
172
+ if (!(element instanceof HTMLSelectElement) ||
173
+ typeof authoredValue !== 'string' ||
174
+ isClientOnlyProperty(properties, 'value')) {
175
+ return;
176
+ }
177
+ const options = Array.from(element.options);
178
+ const selectedOption = options.find(option => option.value === authoredValue);
179
+ for (const option of options) {
180
+ status.controlledOptionSelection.set(option, option === selectedOption);
181
+ }
182
+ status.controlledSelectState.set(element, {
183
+ selectedIndex: selectedOption?.index ?? NO_SELECTED_OPTION,
184
+ value: selectedOption?.value ?? '',
185
+ });
186
+ };
187
+ const detectControlledSelectMismatch = (element, status) => {
188
+ const selectState = status.controlledSelectState.get(element);
189
+ if (selectState !== undefined &&
190
+ (Reflect.get(element, 'value') !== selectState.value ||
191
+ Reflect.get(element, 'selectedIndex') !== selectState.selectedIndex)) {
192
+ detectMismatch(status);
193
+ }
194
+ const isSelected = status.controlledOptionSelection.get(element);
195
+ if (isSelected !== undefined) {
196
+ if (Reflect.get(element, 'selected') !== isSelected ||
197
+ Reflect.get(element, 'defaultSelected') !== isSelected) {
198
+ detectMismatch(status);
199
+ }
200
+ }
201
+ };
164
202
  const seedReflectedProperties = (element, vnode, propertyNames, isCustomElement, status) => {
165
203
  const properties = vnode.data?.props;
166
204
  if (properties === undefined || propertyNames.length === 0) {
@@ -173,6 +211,12 @@ const seedReflectedProperties = (element, vnode, propertyNames, isCustomElement,
173
211
  if (attributeName === undefined) {
174
212
  continue;
175
213
  }
214
+ const isOwnedByControlledSelect = (name === 'value' && status.controlledSelectState.has(element)) ||
215
+ (name === 'selected' && status.controlledOptionSelection.has(element));
216
+ if (isOwnedByControlledSelect) {
217
+ seeded[name] = authored;
218
+ continue;
219
+ }
176
220
  const isEquivalent = !isCustomElement && isControlledCurrentState(element, name)
177
221
  ? Object.is(Reflect.get(element, name), authored)
178
222
  : element.getAttribute(attributeName) ===
@@ -231,6 +275,7 @@ export const __elementSignature = (element, vnode) => {
231
275
  // value is written by one module and then removed as stale state by another.
232
276
  // The hydration stamp is never seeded, so it is never removed.
233
277
  const seedAdoptedState = (element, vnode, clone, status, isCustomElement) => {
278
+ detectControlledSelectMismatch(element, status);
234
279
  const classOwnedByModule = vnode.data?.class !== undefined &&
235
280
  htmlAttributeValue(vnode.data?.attrs, 'class') === undefined;
236
281
  const styleOwnedByModule = vnode.data?.style !== undefined &&
@@ -339,11 +384,11 @@ const matchesNamespace = (element, vnode) => (element.namespaceURI ?? HTML_NAMES
339
384
  // The server DOM does not encode a vnode's key or identity, so a positional
340
385
  // match on tag and namespace alone could adopt a different logical entity: a
341
386
  // reordered or stale keyed list would take over the wrong DOM node, and the user
342
- // state sitting on it. The serializer stamps a digest of key and identity; here
343
- // the same digest is computed for the vnode and compared, so a mismatch rebuilds
344
- // instead of transferring state to the wrong row or branch. A key type the
345
- // digest does not support (a symbol, which a hydratable render refuses) never
346
- // matches, so it rebuilds rather than adopting on a guess.
387
+ // state sitting on it. The serializer stamps a fingerprint of the key and
388
+ // identity; here the same fingerprint is computed for the vnode and compared,
389
+ // so a mismatch rebuilds instead of transferring state to the wrong row or
390
+ // branch. An unsupported key (NaN or a symbol, which a hydratable render
391
+ // refuses) never matches, so it rebuilds rather than adopting on a guess.
347
392
  const matchesAdoptionKey = (element, vnode) => {
348
393
  const serverKey = element.getAttribute(HYDRATION_KEY_ATTRIBUTE);
349
394
  if (vnode.key === undefined) {
@@ -351,9 +396,9 @@ const matchesAdoptionKey = (element, vnode) => {
351
396
  }
352
397
  const clientKey = hydrationKeyMarker(vnode.key);
353
398
  if (clientKey === undefined) {
354
- // A key type the digest cannot represent (a symbol, which a hydratable
355
- // render refuses) cannot be compared, so it never matches: rebuilding beats
356
- // adopting on a guess.
399
+ // An unsupported key (NaN or a symbol, which a hydratable render refuses)
400
+ // cannot be compared, so it never matches: rebuilding beats adopting on a
401
+ // guess.
357
402
  return false;
358
403
  }
359
404
  return serverKey === clientKey;
@@ -510,6 +555,7 @@ const adoptElement = (element, vnode, status) => {
510
555
  return clonePreparedTree(replaceHydrationElement(element, vnode));
511
556
  }
512
557
  const clone = cloneOf(vnode, element);
558
+ registerControlledSelectState(element, vnode, status);
513
559
  // Strip the hydration markers the serializer stamped: they are internal to the
514
560
  // handoff, already verified by the parent's positional walk before this call,
515
561
  // and must not remain on the adopted element.
@@ -804,6 +850,8 @@ export const __hydrateVNode = (hydrationRoot, nextVNode, seen, buildId) => {
804
850
  const status = {
805
851
  isMismatchDetected: false,
806
852
  adoptedSignatures: new Map(),
853
+ controlledOptionSelection: new Map(),
854
+ controlledSelectState: new Map(),
807
855
  };
808
856
  // The build token is checked again here, though the runtime has already
809
857
  // refused a mismatch before reading the handoff. This is the last line of
@@ -1,6 +1,7 @@
1
- /** Attribute stamped on the server-rendered application root. Its presence
2
- * tells a booting runtime to hydrate instead of rendering fresh, and its
3
- * value is the runtime id used for HMR model preservation. */
1
+ /** Attribute stamped on a hydratable server-rendered application root. Its
2
+ * nonempty value is the runtime id used to pair the root with its Flags
3
+ * payload and scope preserved HMR state. `makeApplication` locates the root;
4
+ * `Runtime.hydrate` adopts it. */
4
5
  export declare const FOLDKIT_APP_ATTRIBUTE = "data-foldkit-app";
5
6
  /** Attribute on the JSON script tag carrying the Schema-encoded flags the
6
7
  * server rendered with. A hydrating runtime decodes this payload instead of
@@ -1 +1 @@
1
- {"version":3,"file":"hydrationMarker.d.ts","sourceRoot":"","sources":["../src/hydrationMarker.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAC/D,eAAO,MAAM,qBAAqB,qBAAqB,CAAA;AAEvD;;;kBAGkB;AAClB,eAAO,MAAM,uBAAuB,uBAAuB,CAAA"}
1
+ {"version":3,"file":"hydrationMarker.d.ts","sourceRoot":"","sources":["../src/hydrationMarker.ts"],"names":[],"mappings":"AAAA;;;mCAGmC;AACnC,eAAO,MAAM,qBAAqB,qBAAqB,CAAA;AAEvD;;;kBAGkB;AAClB,eAAO,MAAM,uBAAuB,uBAAuB,CAAA"}
@@ -1,6 +1,7 @@
1
- /** Attribute stamped on the server-rendered application root. Its presence
2
- * tells a booting runtime to hydrate instead of rendering fresh, and its
3
- * value is the runtime id used for HMR model preservation. */
1
+ /** Attribute stamped on a hydratable server-rendered application root. Its
2
+ * nonempty value is the runtime id used to pair the root with its Flags
3
+ * payload and scope preserved HMR state. `makeApplication` locates the root;
4
+ * `Runtime.hydrate` adopts it. */
4
5
  export const FOLDKIT_APP_ATTRIBUTE = 'data-foldkit-app';
5
6
  /** Attribute on the JSON script tag carrying the Schema-encoded flags the
6
7
  * server rendered with. A hydrating runtime decodes this payload instead of
@@ -1,8 +1,8 @@
1
1
  export declare const HYDRATION_KEY_ATTRIBUTE = "data-foldkit-key";
2
2
  export declare const HYDRATION_IDENTITY_ATTRIBUTE = "data-foldkit-identity";
3
- /** The marker value for a vnode key, or `undefined` for a key type the
4
- * hydration handoff does not support (a symbol, which the server refuses to
5
- * render and hydration therefore never adopts).
3
+ /** The marker value for a vnode key, or `undefined` for a key the hydration
4
+ * handoff does not support (`NaN` or a symbol, both of which the server
5
+ * refuses in hydratable output).
6
6
  *
7
7
  * @internal
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"hydrationMarkers.d.ts","sourceRoot":"","sources":["../src/hydrationMarkers.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,uBAAuB,qBAAqB,CAAA;AACzD,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAkCnE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAAM,GAAG,SAQ9D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAU,MAAM,KAAG,MAClC,CAAA"}
1
+ {"version":3,"file":"hydrationMarkers.d.ts","sourceRoot":"","sources":["../src/hydrationMarkers.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,uBAAuB,qBAAqB,CAAA;AACzD,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAmCnE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAAM,GAAG,SAW9D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAU,MAAM,KAAG,MAC7B,CAAA"}
@@ -6,15 +6,13 @@
6
6
  // lets hydration verify it is adopting the same logical entity by key and
7
7
  // identity, not just by tag and position, and rebuild when it is not.
8
8
  //
9
- // A marker carries a digest of the key, never the key itself. Application keys
10
- // are database ids, account identifiers, and email addresses the view otherwise
11
- // never renders, and a compiler identity spells out a source path and function
12
- // name; neither belongs in public HTML. A digest is a one-way comparison token:
13
- // it is enough for hydration, which only ever asks whether two markers are
14
- // equal, and it does not read back to the value it was computed from. It is not
15
- // a secret, since a reader who guesses a candidate key can hash it and compare,
16
- // so it is sized to make an accidental collision between two distinct keys
17
- // vanishingly unlikely rather than to withstand a guessing attack.
9
+ // A marker carries a deterministic, non-cryptographic fingerprint of the key,
10
+ // never the key itself. Application keys are database ids, account identifiers,
11
+ // and email addresses the view otherwise never renders, and a compiler identity
12
+ // spells out a source path and function name; neither belongs directly in public
13
+ // HTML. The fingerprint is public. A reader can fingerprint a guessed value and
14
+ // compare it, and a caller can deliberately construct a collision. Hydration
15
+ // uses it only to detect accidental disagreement between supported inputs.
18
16
  //
19
17
  // Markers are part of the hydration handoff, so they are emitted only for a
20
18
  // hydratable render. Non-hydratable output carries no key or identity channel
@@ -22,13 +20,14 @@
22
20
  export const HYDRATION_KEY_ATTRIBUTE = 'data-foldkit-key';
23
21
  export const HYDRATION_IDENTITY_ATTRIBUTE = 'data-foldkit-identity';
24
22
  // FNV-1a, run as two 32-bit lanes from different offset bases and concatenated
25
- // to 64 bits. The lanes are plain integer arithmetic over the string's code
26
- // units, so the server and the browser compute the same digest for the same
27
- // input with no platform dependency and no async crypto API.
23
+ // into one 16-character value. The lanes are plain integer arithmetic over the
24
+ // string's code units, so the server and the browser compute the same value with
25
+ // no platform dependency or async crypto API. This construction is intended to
26
+ // catch accidental differences. It does not resist deliberate collisions.
28
27
  const FNV_PRIME = 16777619;
29
28
  const FNV_OFFSET_BASIS = 2166136261;
30
29
  const SECOND_LANE_OFFSET_BASIS = 1099511628;
31
- const digest = (value) => {
30
+ const fingerprint = (value) => {
32
31
  let lowLane = FNV_OFFSET_BASIS;
33
32
  let highLane = SECOND_LANE_OFFSET_BASIS;
34
33
  for (let index = 0; index < value.length; index += 1) {
@@ -43,23 +42,26 @@ const digest = (value) => {
43
42
  return ((lowLane >>> 0).toString(16).padStart(8, '0') +
44
43
  (highLane >>> 0).toString(16).padStart(8, '0'));
45
44
  };
46
- // Each digest is taken over a type-tagged string, which keeps the supported key
45
+ // Each fingerprint covers a type-tagged string, which keeps the supported key
47
46
  // types apart. The runtime compares keys with `===`, so the number 1 and the
48
- // string '1' are different keys and must digest differently; untagged, both
49
- // would reach the digest as "1" and a server-rendered numeric key would adopt a
50
- // client string key's node, and the state on it.
51
- /** The marker value for a vnode key, or `undefined` for a key type the
52
- * hydration handoff does not support (a symbol, which the server refuses to
53
- * render and hydration therefore never adopts).
47
+ // string '1' are different keys and must produce different fingerprints;
48
+ // untagged, both would reach the fingerprint as "1" and a server-rendered
49
+ // numeric key would adopt a client string key's node, and the state on it.
50
+ /** The marker value for a vnode key, or `undefined` for a key the hydration
51
+ * handoff does not support (`NaN` or a symbol, both of which the server
52
+ * refuses in hydratable output).
54
53
  *
55
54
  * @internal
56
55
  */
57
56
  export const hydrationKeyMarker = (key) => {
58
57
  if (typeof key === 'string') {
59
- return digest(`s:${key}`);
58
+ return fingerprint(`s:${key}`);
60
59
  }
61
60
  if (typeof key === 'number') {
62
- return digest(`n:${key}`);
61
+ if (Number.isNaN(key)) {
62
+ return undefined;
63
+ }
64
+ return fingerprint(`n:${key}`);
63
65
  }
64
66
  return undefined;
65
67
  };
@@ -67,4 +69,4 @@ export const hydrationKeyMarker = (key) => {
67
69
  *
68
70
  * @internal
69
71
  */
70
- export const hydrationIdentityMarker = (identity) => digest(`i:${identity}`);
72
+ export const hydrationIdentityMarker = (identity) => fingerprint(`i:${identity}`);
@@ -374,8 +374,9 @@ type RuntimeProgram = Readonly<{
374
374
  /** Creates a Foldkit application that owns the page and returns a runtime that
375
375
  * can be passed to `run`. The `view` returns a `Document`, so the runtime
376
376
  * manages `document.title` and the canonical / og:url tags. Add a `routing`
377
- * config for URL routing. To mount an app scoped to a node without touching the
378
- * document `<head>`, use `makeElement`. */
377
+ * config for URL routing. Use one page-owning application per document. To
378
+ * mount an app scoped to a node without touching the document `<head>`, use
379
+ * `makeElement`. */
379
380
  export declare function makeApplication<Model, Message extends {
380
381
  _tag: string;
381
382
  }, Flags, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined>(config: RoutingApplicationConfigWithFlags<Model, Message, Flags, Resources, ManagedResourceServices, P>): MakeRuntimeReturn<P, Flags, Resources, 'Application'>;
@@ -436,17 +437,21 @@ export type HydrateOptions = Readonly<{
436
437
  * of building it fresh. Use this as the client entry for a page served by
437
438
  * `renderToString`: the first render attaches to the stamped root, keeps the
438
439
  * existing nodes, and reconstructs the Model from the Flags the server
439
- * embedded. The handoff is strict: a missing server root, a root stamped more
440
- * than once, more than one root with no container to choose between them, a
441
- * missing Flags payload, an undecodable payload, or a page from another
442
- * deployment terminates startup. Every one of those contains the page first:
440
+ * embedded. The handoff is strict: a missing server root, an empty or
441
+ * duplicated root stamp, more than one stamped root, a requested root outside
442
+ * the document body light DOM, a missing Flags payload, an undecodable
443
+ * payload, or a page from another deployment terminates startup. Every one of
444
+ * those contains the page first:
443
445
  * the document's body is marked `inert` and a nondismissable modal shield is
444
- * opened above existing top-layer content, so native links, forms, controls,
445
- * and focus targets stop responding. Containment leaves author-owned dialogs
446
- * open without calling `close` or dispatching `cancel`. Nothing is moved, so
447
- * no custom element reconnects and no frame reloads. This is not a script or
448
- * event sandbox: existing capture-phase handlers, browser-generated top-layer
449
- * events, timers, and other stale scripts can still run and can open newer
446
+ * opened above existing top-layer content, so pointer and physical keyboard
447
+ * input do not activate same-document native links, forms, or controls.
448
+ * Containment leaves author-owned dialogs open without calling `close` or
449
+ * dispatching `cancel`.
450
+ * Nothing is moved, so no custom element reconnects and no frame reloads.
451
+ * This is not a script, event, or embedded-document sandbox: existing
452
+ * capture-phase handlers, browser-generated top-layer events, timers, and
453
+ * stale scripts can still run. Controls in embedded documents can still
454
+ * receive input if stale code focuses them. Stale code can also open newer
450
455
  * top-layer UI. Use `run` in a separate client-only entry when the page should
451
456
  * boot without server output.
452
457
  *
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,EAEP,MAAM,EACN,IAAI,EAGJ,KAAK,EAEL,MAAM,EAON,MAAM,EACN,KAAK,EAIN,MAAM,QAAQ,CAAA;AAGf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,QAAQ,EACR,IAAI,EACJ,KAAK,WAAW,EASjB,MAAM,kBAAkB,CAAA;AAMzB,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B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AAK,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"}
@@ -206,13 +206,10 @@ const hydrationForRoot = (root, isFlagsRequired) => {
206
206
  // id (a descendant `id="root"`) and `getElementById` returned that inner element
207
207
  // instead of the stamped root above it. That inner element resolves to the app
208
208
  // root only when the page has exactly one stamped root and this container sits
209
- // inside it, so a sibling widget (a stamped root the container is not inside) or
210
- // an outer application's root (when a nested page carries more than one stamped
211
- // root) is never wrongly adopted; those fall through to a fresh boot or a hard
212
- // failure instead. A null container is the replace-parity case, where the server
213
- // root took the placeholder's place and `getElementById` no longer finds it, so
214
- // the stamp is the only handle; more than one stamped root is then ambiguous and
215
- // a hard error rather than a silent wrong-DOM adoption.
209
+ // inside it. A container outside that root is a refused handoff, not a fresh
210
+ // application beside server markup that remains live. A null container is the
211
+ // replace-parity case, where the server root took the placeholder's place and
212
+ // `getElementById` no longer finds it, so the stamp is the only handle.
216
213
  // A runtime id names one application for the whole page: it pairs a root with
217
214
  // its Flags payload, and it keys the Model and scroll position hot reloading
218
215
  // preserves. Two roots sharing one are not two applications but one claimed
@@ -227,18 +224,42 @@ const assertRuntimeIdsAreUnique = (stampedRoots) => {
227
224
  const seen = new Set();
228
225
  for (const root of stampedRoots) {
229
226
  const runtimeId = root.getAttribute(FOLDKIT_APP_ATTRIBUTE) ?? '';
227
+ if (runtimeId === '') {
228
+ containRefusedPage(root.ownerDocument);
229
+ throw new Error('[foldkit] Found a server-rendered root with an empty ' +
230
+ `\`${FOLDKIT_APP_ATTRIBUTE}\` stamp. A hydratable root must carry ` +
231
+ 'a nonempty runtime id so the runtime can pair it with its Flags ' +
232
+ 'payload and preserved HMR state.');
233
+ }
234
+ if (!root.ownerDocument.body?.contains(root)) {
235
+ containRefusedPage(root.ownerDocument);
236
+ throw new Error('[foldkit] Found a server-rendered root outside the document body. ' +
237
+ 'Runtime.hydrate supports one page-owning application in the ' +
238
+ 'document light DOM. Do not hydrate a root in the head, a shadow ' +
239
+ 'tree, or a detached subtree.');
240
+ }
230
241
  if (seen.has(runtimeId)) {
231
242
  containRefusedPage(root.ownerDocument);
232
243
  throw new Error(`[foldkit] Found more than one server-rendered root stamped ` +
233
244
  `"${runtimeId}". A runtime id names one application for the whole ` +
234
245
  'page: it pairs a root with its Flags payload and keys the Model and ' +
235
246
  'scroll position hot reloading preserves, so two roots sharing one ' +
236
- "would take each other's state. Render each application with its " +
237
- 'own `runtimeId`.');
247
+ "would take each other's state. Remove the duplicate root. Foldkit " +
248
+ 'hydrates one page-owning application per document.');
238
249
  }
239
250
  seen.add(runtimeId);
240
251
  }
241
252
  };
253
+ const assertSinglePageApplication = (stampedRoots) => {
254
+ if (stampedRoots.length > 1) {
255
+ containRefusedPage(document);
256
+ throw new Error('[foldkit] Found more than one page-owning application stamped with ' +
257
+ `\`${FOLDKIT_APP_ATTRIBUTE}\`. Hydrating multiple applications in ` +
258
+ 'one document is not supported: each application owns the document ' +
259
+ 'metadata and installs document-wide navigation listeners. Render ' +
260
+ 'one application per page.');
261
+ }
262
+ };
242
263
  // The reason this page cannot be adopted by this client, or `undefined` when
243
264
  // the two name the same deployment.
244
265
  //
@@ -247,7 +268,7 @@ const assertRuntimeIdsAreUnique = (stampedRoots) => {
247
268
  // which reads a page from an unknown deployment as one of this build's own: the
248
269
  // exact case the id exists to refuse.
249
270
  const buildSkew = (root, buildId, runtimeId) => {
250
- if (buildId === undefined || buildId === '') {
271
+ if (!Predicate.isString(buildId) || buildId === '') {
251
272
  return new Error('[foldkit] Runtime.hydrate was given no build id. Hydration compares ' +
252
273
  'the id the server stamped on the root with this client’s own before ' +
253
274
  'it adopts any DOM, and without one a page from any deployment would ' +
@@ -285,20 +306,33 @@ const REFUSAL_SHIELD_INPUT_EVENTS = [
285
306
  'touchend',
286
307
  'touchstart',
287
308
  ];
309
+ const REFUSAL_DOCUMENT_INPUT_EVENTS = ['keydown', 'keypress', 'keyup'];
288
310
  const preventRefusalShieldInteraction = (event) => {
289
311
  event.preventDefault();
290
312
  event.stopImmediatePropagation();
291
313
  };
314
+ // NOTE: `showModal` throws when the owning document is not fully active. A
315
+ // foreign or detached document still needs the original Foldkit refusal rather
316
+ // than a browser exception from its containment UI.
317
+ const tryOpenRefusalShieldAsModal = (shield) => {
318
+ if (typeof shield.showModal !== 'function') {
319
+ return false;
320
+ }
321
+ try {
322
+ shield.showModal();
323
+ return true;
324
+ }
325
+ catch {
326
+ return false;
327
+ }
328
+ };
292
329
  const openRefusalShield = (shield) => {
293
330
  shield.inert = true;
294
331
  shield.setAttribute('inert', '');
295
332
  if (shield.open && typeof shield.close === 'function') {
296
333
  shield.close();
297
334
  }
298
- if (typeof shield.showModal === 'function') {
299
- shield.showModal();
300
- }
301
- else {
335
+ if (!tryOpenRefusalShieldAsModal(shield)) {
302
336
  shield.setAttribute('open', '');
303
337
  }
304
338
  shield.inert = false;
@@ -344,6 +378,12 @@ const installRefusalShield = (ownerDocument) => {
344
378
  passive: false,
345
379
  });
346
380
  }
381
+ for (const eventName of REFUSAL_DOCUMENT_INPUT_EVENTS) {
382
+ ownerDocument.addEventListener(eventName, preventRefusalShieldInteraction, {
383
+ capture: true,
384
+ passive: false,
385
+ });
386
+ }
347
387
  ownerDocument.documentElement.appendChild(shield);
348
388
  refusalShields.set(ownerDocument, shield);
349
389
  openRefusalShield(shield);
@@ -366,28 +406,46 @@ const hasServerRenderedMarkup = (ownerDocument) => ownerDocument.querySelector(`
366
406
  const findDocumentHydration = (container, isFlagsRequired) => {
367
407
  const stampedRoots = Array.fromIterable(document.querySelectorAll(`[${FOLDKIT_APP_ATTRIBUTE}]`));
368
408
  assertRuntimeIdsAreUnique(stampedRoots);
409
+ assertSinglePageApplication(stampedRoots);
369
410
  if (container !== null) {
411
+ const stampedAncestor = container.closest(`[${FOLDKIT_APP_ATTRIBUTE}]`);
370
412
  if (container.hasAttribute(FOLDKIT_APP_ATTRIBUTE)) {
413
+ const isDocumentRoot = Option.match(Array.head(stampedRoots), {
414
+ onNone: () => false,
415
+ onSome: root => root === container,
416
+ });
417
+ if (!isDocumentRoot) {
418
+ containRefusedPage(container.ownerDocument);
419
+ throw new Error('[foldkit] Runtime.hydrate received a stamped container that is ' +
420
+ 'not the single server root in the document light DOM. Hydration ' +
421
+ 'supports one page-owning application under the document body. ' +
422
+ 'Do not hydrate a root in a shadow tree or detached subtree.');
423
+ }
371
424
  return hydrationForRoot(container, isFlagsRequired);
372
425
  }
373
426
  return Array.match(stampedRoots, {
374
- onEmpty: () => undefined,
427
+ onEmpty: () => {
428
+ if (stampedAncestor === null) {
429
+ return undefined;
430
+ }
431
+ containRefusedPage(container.ownerDocument);
432
+ throw new Error('[foldkit] Runtime.hydrate received a container under a stamped ' +
433
+ 'root outside the document body light DOM. Do not hydrate a root ' +
434
+ 'in a shadow tree, detached subtree, or another document.');
435
+ },
375
436
  onNonEmpty: roots => {
376
437
  const onlyRoot = Array.headNonEmpty(roots);
377
- return roots.length === 1 &&
378
- container.closest(`[${FOLDKIT_APP_ATTRIBUTE}]`) === onlyRoot
379
- ? hydrationForRoot(onlyRoot, isFlagsRequired)
380
- : undefined;
438
+ if (stampedAncestor === onlyRoot) {
439
+ return hydrationForRoot(onlyRoot, isFlagsRequired);
440
+ }
441
+ containRefusedPage(container.ownerDocument);
442
+ throw new Error('[foldkit] Runtime.hydrate received a container outside the ' +
443
+ "document's server-rendered application root. A page-owning " +
444
+ 'application must adopt that single root rather than boot beside ' +
445
+ 'server markup it does not own.');
381
446
  },
382
447
  });
383
448
  }
384
- if (stampedRoots.length > 1) {
385
- containRefusedPage(document);
386
- throw new Error('[foldkit] Found multiple server-rendered roots stamped with ' +
387
- `\`${FOLDKIT_APP_ATTRIBUTE}\` but no container to disambiguate them. ` +
388
- 'Give each app its own container element so the runtime can tell ' +
389
- 'which root to hydrate.');
390
- }
391
449
  return Option.match(Array.head(stampedRoots), {
392
450
  onNone: () => undefined,
393
451
  onSome: root => hydrationForRoot(root, isFlagsRequired),
@@ -2080,24 +2138,28 @@ export function run(program, options) {
2080
2138
  * of building it fresh. Use this as the client entry for a page served by
2081
2139
  * `renderToString`: the first render attaches to the stamped root, keeps the
2082
2140
  * existing nodes, and reconstructs the Model from the Flags the server
2083
- * embedded. The handoff is strict: a missing server root, a root stamped more
2084
- * than once, more than one root with no container to choose between them, a
2085
- * missing Flags payload, an undecodable payload, or a page from another
2086
- * deployment terminates startup. Every one of those contains the page first:
2141
+ * embedded. The handoff is strict: a missing server root, an empty or
2142
+ * duplicated root stamp, more than one stamped root, a requested root outside
2143
+ * the document body light DOM, a missing Flags payload, an undecodable
2144
+ * payload, or a page from another deployment terminates startup. Every one of
2145
+ * those contains the page first:
2087
2146
  * the document's body is marked `inert` and a nondismissable modal shield is
2088
- * opened above existing top-layer content, so native links, forms, controls,
2089
- * and focus targets stop responding. Containment leaves author-owned dialogs
2090
- * open without calling `close` or dispatching `cancel`. Nothing is moved, so
2091
- * no custom element reconnects and no frame reloads. This is not a script or
2092
- * event sandbox: existing capture-phase handlers, browser-generated top-layer
2093
- * events, timers, and other stale scripts can still run and can open newer
2147
+ * opened above existing top-layer content, so pointer and physical keyboard
2148
+ * input do not activate same-document native links, forms, or controls.
2149
+ * Containment leaves author-owned dialogs open without calling `close` or
2150
+ * dispatching `cancel`.
2151
+ * Nothing is moved, so no custom element reconnects and no frame reloads.
2152
+ * This is not a script, event, or embedded-document sandbox: existing
2153
+ * capture-phase handlers, browser-generated top-layer events, timers, and
2154
+ * stale scripts can still run. Controls in embedded documents can still
2155
+ * receive input if stale code focuses them. Stale code can also open newer
2094
2156
  * top-layer UI. Use `run` in a separate client-only entry when the page should
2095
2157
  * boot without server output.
2096
2158
  *
2097
2159
  * @experimental Server rendering and hydration are experimental while their
2098
2160
  * contracts settle. */
2099
2161
  export const hydrate = (program, options) => {
2100
- startProgram(program, 'Hydrate', undefined, options.buildId);
2162
+ startProgram(program, 'Hydrate', undefined, options?.buildId);
2101
2163
  };
2102
2164
  const buildPortHandles = (ports, connector) => {
2103
2165
  const handles = {};
@@ -1 +1 @@
1
- {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/snabbdom/class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AA4B7C,eAAO,MAAM,WAAW,EAAE,MAIzB,CAAA"}
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/snabbdom/class.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAwG7C,eAAO,MAAM,WAAW,EAAE,MAIzB,CAAA"}
@@ -1,26 +1,82 @@
1
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
2
+ import { parsedAttributeName } from '../domReflection.js';
1
3
  import { VNodeDataMask } from './vnode.js';
4
+ const absentRawClassAttribute = { _tag: 'Absent' };
5
+ const ASCII_WHITESPACE = /[\t\n\f\r ]+/;
6
+ const rawClassAttributeFor = (vnode, namespace) => {
7
+ const attrs = vnode.data.attrs;
8
+ if (attrs === undefined) {
9
+ return absentRawClassAttribute;
10
+ }
11
+ let attribute = absentRawClassAttribute;
12
+ for (const name of Object.keys(attrs)) {
13
+ if (parsedAttributeName(namespace, name) === 'class') {
14
+ attribute = { _tag: 'Present', value: attrs[name] };
15
+ }
16
+ }
17
+ return attribute;
18
+ };
19
+ const rawClassAttributesAgree = (previous, next) => {
20
+ if (previous._tag === 'Absent') {
21
+ return next._tag === 'Absent';
22
+ }
23
+ return next._tag === 'Present' && previous.value === next.value;
24
+ };
25
+ const rawClassNamesFor = (attribute) => {
26
+ const names = new Set();
27
+ if (attribute._tag === 'Absent' || typeof attribute.value === 'boolean') {
28
+ return names;
29
+ }
30
+ for (const name of String(attribute.value).split(ASCII_WHITESPACE)) {
31
+ if (name !== '') {
32
+ names.add(name);
33
+ }
34
+ }
35
+ return names;
36
+ };
2
37
  function updateClass(oldVnode, vnode) {
3
38
  let cur;
4
39
  let name;
5
40
  const elm = vnode.elm;
6
41
  let oldClass = oldVnode.data.class;
7
42
  let klass = vnode.data.class;
43
+ const oldAttrs = oldVnode.data.attrs;
44
+ const attrs = vnode.data.attrs;
8
45
  if (!oldClass && !klass)
9
46
  return;
10
- if (oldClass === klass)
47
+ if (oldClass === klass && oldAttrs === attrs)
48
+ return;
49
+ const previousRawClass = rawClassAttributeFor(oldVnode, elm.namespaceURI);
50
+ const nextRawClass = rawClassAttributeFor(vnode, elm.namespaceURI);
51
+ if (oldClass === klass &&
52
+ rawClassAttributesAgree(previousRawClass, nextRawClass)) {
11
53
  return;
54
+ }
12
55
  oldClass = oldClass || {};
13
56
  klass = klass || {};
57
+ if (oldClass === klass) {
58
+ for (name in klass) {
59
+ if (klass[name] && !elm.classList.contains(name)) {
60
+ elm.classList.add(name);
61
+ }
62
+ }
63
+ return;
64
+ }
65
+ const nextRawClassNames = rawClassNamesFor(nextRawClass);
14
66
  for (name in oldClass) {
15
- if (oldClass[name] && !Object.prototype.hasOwnProperty.call(klass, name)) {
16
- // was `true` and now not provided
67
+ if (oldClass[name] &&
68
+ klass[name] !== true &&
69
+ !nextRawClassNames.has(name)) {
17
70
  elm.classList.remove(name);
18
71
  }
19
72
  }
20
73
  for (name in klass) {
21
74
  cur = klass[name];
22
- if (cur !== oldClass[name]) {
23
- elm.classList[cur ? 'add' : 'remove'](name);
75
+ if (cur && !elm.classList.contains(name)) {
76
+ elm.classList.add(name);
77
+ }
78
+ else if (cur !== oldClass[name] && !nextRawClassNames.has(name)) {
79
+ elm.classList.remove(name);
24
80
  }
25
81
  }
26
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/snabbdom/style.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEvD,MAAM,MAAM,UAAU,GAAG,YAAY,GACnC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IACvB,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChD,CAAA;AAyJH,eAAO,MAAM,WAAW,EAAE,MAOzB,CAAA"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/snabbdom/style.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEvD,MAAM,MAAM,UAAU,GAAG,YAAY,GACnC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IACvB,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChD,CAAA;AA+JH,eAAO,MAAM,WAAW,EAAE,MAOzB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/consistent-type-assertions */
2
- import { serializedStylePropertyName } from '../domReflection.js';
2
+ import { htmlAttributeValue, serializedStylePropertyName, } from '../domReflection.js';
3
3
  import { VNodeDataMask } from './vnode.js';
4
4
  // Binding `requestAnimationFrame` like this fixes a bug in IE/Edge. See #360 and #409.
5
5
  const raf = typeof window !== 'undefined' &&
@@ -51,6 +51,10 @@ function updateStyle(oldVnode, vnode) {
51
51
  return;
52
52
  if (oldStyle === style)
53
53
  return;
54
+ if (style === undefined &&
55
+ htmlAttributeValue(vnode.data.attrs, 'style') !== undefined) {
56
+ return;
57
+ }
54
58
  oldStyle = oldStyle || {};
55
59
  style = style || {};
56
60
  const oldHasDel = Object.hasOwn(oldStyle, 'delayed');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
4
4
  "description": "A TypeScript frontend framework, built on Effect and architected like Elm",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",