foldkit 0.158.2 → 0.159.0-canary.4e90e99d9ad3
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 +2 -2
- package/dist/customElement/index.d.ts +15 -8
- package/dist/customElement/index.d.ts.map +1 -1
- package/dist/customElement/index.js +28 -5
- package/dist/customElement/public.d.ts +1 -1
- package/dist/customElement/public.d.ts.map +1 -1
- package/dist/dom/dom.d.ts +7 -4
- package/dist/dom/dom.d.ts.map +1 -1
- package/dist/dom/dom.js +8 -5
- package/dist/experimental/server/fetch.d.ts +42 -0
- package/dist/experimental/server/fetch.d.ts.map +1 -0
- package/dist/experimental/server/fetch.js +75 -0
- package/dist/experimental/server/index.d.ts +1 -0
- package/dist/experimental/server/index.d.ts.map +1 -1
- package/dist/experimental/server/index.js +1 -0
- package/dist/experimental/server/public.d.ts +2 -2
- package/dist/experimental/server/public.d.ts.map +1 -1
- package/dist/experimental/server/public.js +1 -1
- package/dist/experimental/server/server.d.ts +3 -2
- package/dist/experimental/server/server.d.ts.map +1 -1
- package/dist/experimental/server/template.js +4 -4
- package/dist/html/index.d.ts +42 -3
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +147 -10
- package/dist/hydrationMarker.d.ts +2 -2
- package/dist/hydrationMarker.d.ts.map +1 -1
- package/dist/hydrationMarker.js +2 -2
- package/dist/runtime/devToolsConfig.d.ts +3 -3
- package/dist/runtime/devToolsConfig.d.ts.map +1 -1
- package/dist/runtime/devToolsConfig.js +3 -3
- package/dist/runtime/hydrationHandoff.d.ts +5 -4
- package/dist/runtime/hydrationHandoff.d.ts.map +1 -1
- package/dist/runtime/hydrationHandoff.js +14 -13
- package/dist/runtime/{hmrProtocol.d.ts → modelPreservation.d.ts} +3 -3
- package/dist/runtime/modelPreservation.d.ts.map +1 -0
- package/dist/runtime/{hmrProtocol.js → modelPreservation.js} +2 -2
- package/dist/runtime/modelPreservationBridge.d.ts +4 -0
- package/dist/runtime/modelPreservationBridge.d.ts.map +1 -0
- package/dist/runtime/{hmrModelBridge.js → modelPreservationBridge.js} +7 -7
- package/dist/runtime/modelPreservationPublic.d.ts +2 -0
- package/dist/runtime/modelPreservationPublic.d.ts.map +1 -0
- package/dist/runtime/{hmrProtocolPublic.js → modelPreservationPublic.js} +1 -1
- package/dist/runtime/preserveScheduler.d.ts +1 -1
- package/dist/runtime/runtime.d.ts +8 -7
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +16 -16
- package/dist/runtime/{hmrScroll.d.ts → scrollPreservation.d.ts} +1 -1
- package/dist/runtime/scrollPreservation.d.ts.map +1 -0
- package/dist/runtime/{hmrScroll.js → scrollPreservation.js} +3 -3
- package/dist/runtime/slowPhase.d.ts +2 -1
- package/dist/runtime/slowPhase.d.ts.map +1 -1
- package/dist/runtime/start.d.ts +10 -7
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +21 -9
- package/dist/runtime/visibility.d.ts +2 -2
- package/dist/runtime/visibility.d.ts.map +1 -1
- package/dist/runtime/visibility.js +2 -2
- package/dist/schema/index.d.ts +42 -12
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +12 -10
- package/dist/test/apps/contentEditableEditor.d.ts +32 -0
- package/dist/test/apps/contentEditableEditor.d.ts.map +1 -0
- package/dist/test/apps/contentEditableEditor.js +39 -0
- package/dist/test/apps/fileUpload.d.ts.map +1 -1
- package/dist/test/apps/fileUpload.js +2 -1
- package/dist/test/apps/formChild.js +1 -1
- package/dist/test/apps/keypressSelf.d.ts +26 -0
- package/dist/test/apps/keypressSelf.d.ts.map +1 -0
- package/dist/test/apps/keypressSelf.js +30 -0
- package/dist/test/apps/pointer.d.ts.map +1 -1
- package/dist/test/apps/pointer.js +10 -11
- package/dist/test/scene.d.ts +28 -6
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +38 -13
- package/dist/vdom.js +5 -5
- package/package.json +4 -4
- package/dist/runtime/hmrModelBridge.d.ts +0 -4
- package/dist/runtime/hmrModelBridge.d.ts.map +0 -1
- package/dist/runtime/hmrProtocol.d.ts.map +0 -1
- package/dist/runtime/hmrProtocolPublic.d.ts +0 -2
- package/dist/runtime/hmrProtocolPublic.d.ts.map +0 -1
- package/dist/runtime/hmrScroll.d.ts.map +0 -1
package/dist/hydrationMarker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Attribute stamped on a hydratable server-rendered application root. Its
|
|
2
2
|
* nonempty value is the runtime id used to pair the root with its Flags
|
|
3
|
-
* payload and scope
|
|
4
|
-
* `Runtime.hydrate` adopts it. */
|
|
3
|
+
* payload and scope Model and scroll preservation. `makeApplication` locates
|
|
4
|
+
* the root; `Runtime.hydrate` adopts it. */
|
|
5
5
|
export const FOLDKIT_APP_ATTRIBUTE = 'data-foldkit-app';
|
|
6
6
|
/** Attribute on the JSON script tag carrying the Schema-encoded flags the
|
|
7
7
|
* server rendered with. A hydrating runtime decodes this payload instead of
|
|
@@ -72,9 +72,9 @@ export type ResolvedDevToolsConfig = Readonly<{
|
|
|
72
72
|
maybeOverlay: Option.Option<DevToolsOverlay>;
|
|
73
73
|
}>;
|
|
74
74
|
/** Resolves the DevTools config for this boot, or `Option.none()` when
|
|
75
|
-
* DevTools is disabled or hidden. `'Development'` visibility requires Vite
|
|
76
|
-
*
|
|
77
|
-
* stack a second panel over its host's. */
|
|
75
|
+
* DevTools is disabled or hidden. `'Development'` visibility requires Vite's
|
|
76
|
+
* dev server and a top-level window, so an app previewed inside an iframe does
|
|
77
|
+
* not stack a second panel over its host's. */
|
|
78
78
|
export declare const resolveDevToolsConfig: (devTools: DevToolsConfig | undefined) => Option.Option<ResolvedDevToolsConfig>;
|
|
79
79
|
/** The Message tags `excludeFromHistory` keeps out of the DevTools history. */
|
|
80
80
|
export declare const resolveExcludeFromHistoryTags: (devTools: DevToolsConfig | undefined) => ReadonlySet<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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AACnE,eAAO,MAAM,yBAAyB,aAC1B,cAAc,GAAG,SAAS,KACnC,MAAM,GAAG,SAaT,CAAA;AAEH,6EAA6E;AAC7E,eAAO,MAAM,+BAA+B,aAChC,cAAc,GAAG,SAAS,KACnC,MAAM,GAAG,SAUT,CAAA"}
|
|
@@ -20,9 +20,9 @@ const DEV_TOOLS_MAX_ENTRIES_MIN = 20;
|
|
|
20
20
|
const DEV_TOOLS_MAX_ENTRIES_MAX = 500;
|
|
21
21
|
const DEV_TOOLS_KEYFRAME_INTERVAL_MIN = 1;
|
|
22
22
|
/** Resolves the DevTools config for this boot, or `Option.none()` when
|
|
23
|
-
* DevTools is disabled or hidden. `'Development'` visibility requires Vite
|
|
24
|
-
*
|
|
25
|
-
* stack a second panel over its host's. */
|
|
23
|
+
* DevTools is disabled or hidden. `'Development'` visibility requires Vite's
|
|
24
|
+
* dev server and a top-level window, so an app previewed inside an iframe does
|
|
25
|
+
* not stack a second panel over its host's. */
|
|
26
26
|
export const resolveDevToolsConfig = (devTools) => {
|
|
27
27
|
const isInIframe = window.self !== window.top;
|
|
28
28
|
return pipe(devTools ?? {}, Option.liftPredicate(config => config !== false), Option.filter(config => isVisible(config.show ?? DEFAULT_DEV_TOOLS_SHOW, !!import.meta.hot && !isInIframe)), Option.map(config => ({
|
|
@@ -26,17 +26,18 @@ export type ResolvedHydrationHandoff<Flags> = Readonly<{
|
|
|
26
26
|
* another deployment, or a missing, duplicated, or undecodable Flags
|
|
27
27
|
* payload contains the served page and stops startup. The build id is
|
|
28
28
|
* compared before the payload text is read and before `init` runs, so
|
|
29
|
-
* nothing acts on another deployment's data.
|
|
30
|
-
* adoption and gets a fresh patch against the
|
|
29
|
+
* nothing acts on another deployment's data. A Model restored after a
|
|
30
|
+
* development reload skips adoption and gets a fresh patch against the
|
|
31
|
+
* stamped root.
|
|
31
32
|
*/
|
|
32
|
-
export declare const resolveHydrationHandoff: <Flags, Resources>({ bootMode, hydration, bootFlags, configuredFlags, isFlagsRequired, FlagsCodec,
|
|
33
|
+
export declare const resolveHydrationHandoff: <Flags, Resources>({ bootMode, hydration, bootFlags, configuredFlags, isFlagsRequired, FlagsCodec, preservedModel, container, buildId, provideResources, }: Readonly<{
|
|
33
34
|
bootMode: BootMode;
|
|
34
35
|
hydration: HydrationConfig | undefined;
|
|
35
36
|
bootFlags: Effect.Effect<Flags, never, Resources> | undefined;
|
|
36
37
|
configuredFlags: Option.Option<Effect.Effect<Flags, never, Resources>>;
|
|
37
38
|
isFlagsRequired: boolean;
|
|
38
39
|
FlagsCodec: Schema.Codec<Flags, any, unknown, unknown>;
|
|
39
|
-
|
|
40
|
+
preservedModel: unknown;
|
|
40
41
|
container: HTMLElement;
|
|
41
42
|
buildId: string | undefined;
|
|
42
43
|
provideResources: <A>(effect: Effect.Effect<A, never, Resources>) => Effect.Effect<A>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrationHandoff.d.ts","sourceRoot":"","sources":["../../src/runtime/hydrationHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,EAAa,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAQvE;wCACwC;AACxC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAK1C,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;IAC9C,eAAe,EAAE,OAAO,CAAA;CACzB,CAAC,CAAA;AAsGF,eAAO,MAAM,SAAS,SACd,WAAW,WACR,OAAO,aACL,MAAM,KAChB,KAAK,GAAG,SAwBV,CAAA;AAmJD,eAAO,MAAM,kBAAkB,kBAAmB,QAAQ,KAAG,IAO5D,CAAA;AAOD,eAAO,MAAM,uBAAuB,kBAAmB,QAAQ,KAAG,OAItD,CAAA;AAEZ,eAAO,MAAM,qBAAqB,cACrB,W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A;CACnC,CAAC,CAAA;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,EAAE,SAAS,2IAWrD,QAAQ,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,EAAE,eAAe,GAAG,SAAS,CAAA;IACtC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,SAAS,CAAA;IAC7D,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAA;IACtE,eAAe,EAAE,OAAO,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACtD,cAAc,EAAE,OAAO,CAAA;IACvB,SAAS,EAAE,WAAW,CAAA;IACtB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gBAAgB,EAAE,CAAC,CAAC,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KACvC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;CACtB,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAuK9C,CAAA"}
|
|
@@ -18,8 +18,8 @@ const hydrationForRoot = (root, isFlagsRequired) => {
|
|
|
18
18
|
// replace-parity case, where the server root took the placeholder's place and
|
|
19
19
|
// `getElementById` no longer finds it, so the stamp is the only handle.
|
|
20
20
|
// A runtime id names one application for the whole page: it pairs a root with
|
|
21
|
-
// its Flags payload, and it keys the Model and scroll position
|
|
22
|
-
//
|
|
21
|
+
// its Flags payload, and it keys the preserved Model and scroll position. Two
|
|
22
|
+
// roots sharing one are not two applications but one claimed
|
|
23
23
|
// twice, so whichever boots second would read the other's handoff and restore
|
|
24
24
|
// the other's Model. `injectIntoTemplate` refuses to build such a page; this is
|
|
25
25
|
// the check for a page assembled some other way.
|
|
@@ -35,8 +35,8 @@ const assertRuntimeIdsAreUnique = (stampedRoots) => {
|
|
|
35
35
|
containRefusedPage(root.ownerDocument);
|
|
36
36
|
throw new Error('[foldkit] Found a server-rendered root with an empty ' +
|
|
37
37
|
`\`${FOLDKIT_APP_ATTRIBUTE}\` stamp. A hydratable root must carry ` +
|
|
38
|
-
'a nonempty runtime id so the runtime can
|
|
39
|
-
'
|
|
38
|
+
'a nonempty runtime id so the runtime can scope its Flags, Model, ' +
|
|
39
|
+
'and scroll preservation.');
|
|
40
40
|
}
|
|
41
41
|
if (!root.ownerDocument.body?.contains(root)) {
|
|
42
42
|
containRefusedPage(root.ownerDocument);
|
|
@@ -49,8 +49,8 @@ const assertRuntimeIdsAreUnique = (stampedRoots) => {
|
|
|
49
49
|
containRefusedPage(root.ownerDocument);
|
|
50
50
|
throw new Error(`[foldkit] Found more than one server-rendered root stamped ` +
|
|
51
51
|
`"${runtimeId}". A runtime id names one application for the whole ` +
|
|
52
|
-
'page: it pairs a root with its Flags payload and keys the
|
|
53
|
-
'scroll position
|
|
52
|
+
'page: it pairs a root with its Flags payload and keys the preserved ' +
|
|
53
|
+
'Model and scroll position, so two roots sharing one ' +
|
|
54
54
|
"would take each other's state. Remove the duplicate root. Foldkit " +
|
|
55
55
|
'hydrates one page-owning application per document.');
|
|
56
56
|
}
|
|
@@ -303,10 +303,11 @@ export const findDocumentHydration = (container, isFlagsRequired) => {
|
|
|
303
303
|
* another deployment, or a missing, duplicated, or undecodable Flags
|
|
304
304
|
* payload contains the served page and stops startup. The build id is
|
|
305
305
|
* compared before the payload text is read and before `init` runs, so
|
|
306
|
-
* nothing acts on another deployment's data.
|
|
307
|
-
* adoption and gets a fresh patch against the
|
|
306
|
+
* nothing acts on another deployment's data. A Model restored after a
|
|
307
|
+
* development reload skips adoption and gets a fresh patch against the
|
|
308
|
+
* stamped root.
|
|
308
309
|
*/
|
|
309
|
-
export const resolveHydrationHandoff = ({ bootMode, hydration, bootFlags, configuredFlags, isFlagsRequired, FlagsCodec,
|
|
310
|
+
export const resolveHydrationHandoff = ({ bootMode, hydration, bootFlags, configuredFlags, isFlagsRequired, FlagsCodec, preservedModel, container, buildId, provideResources, }) => Effect.gen(function* () {
|
|
310
311
|
const maybeResolveFreshFlags = Option.orElse(Option.fromNullishOr(bootFlags), () => configuredFlags);
|
|
311
312
|
const resolveFreshFlags = Option.match(maybeResolveFreshFlags, {
|
|
312
313
|
onNone: () => isFlagsRequired
|
|
@@ -364,11 +365,11 @@ export const resolveHydrationHandoff = ({ bootMode, hydration, bootFlags, config
|
|
|
364
365
|
return yield* Effect.die(skew);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
|
-
// NOTE:
|
|
368
|
-
// server DOM reflects older code. The hydration handoff is
|
|
369
|
-
// required, but the restored Model gets a fresh patch against its
|
|
368
|
+
// NOTE: a Model restored after a development reload wins over DOM adoption
|
|
369
|
+
// because the server DOM reflects older code. The hydration handoff is
|
|
370
|
+
// still required, but the restored Model gets a fresh patch against its
|
|
370
371
|
// stamped root.
|
|
371
|
-
const maybeHydrationRoot = Predicate.isUndefined(
|
|
372
|
+
const maybeHydrationRoot = Predicate.isUndefined(preservedModel)
|
|
372
373
|
? Option.map(maybeRequestedHydration, requestedHydration => requestedHydration.root)
|
|
373
374
|
: Option.none();
|
|
374
375
|
const maybeHydrationFlags = yield* Option.match(maybeRequestedHydration, {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
/** Browser → plugin: the runtime preserves its current Model under a stable id so it can be restored after a full reload. `
|
|
2
|
+
/** Browser → plugin: the runtime preserves its current Model under a stable id so it can be restored after a full reload. `isReloadFlush` is set by the runtime when flushing on `vite:beforeFullReload` to mark the entry as eligible for restoration; absent or `false` for ordinary debounced preserves. */
|
|
3
3
|
export declare const PreserveModelMessage: Schema.Struct<{
|
|
4
4
|
readonly id: Schema.String;
|
|
5
5
|
readonly model: Schema.Unknown;
|
|
6
|
-
readonly
|
|
6
|
+
readonly isReloadFlush: Schema.optional<Schema.Boolean>;
|
|
7
7
|
}>;
|
|
8
8
|
/** Browser → plugin: the runtime preserves its current Model under a stable id. */
|
|
9
9
|
export type PreserveModelMessage = typeof PreserveModelMessage.Type;
|
|
@@ -20,4 +20,4 @@ export declare const RestoreModelMessage: Schema.Struct<{
|
|
|
20
20
|
}>;
|
|
21
21
|
/** Plugin → browser: the plugin returns the preserved Model for a given runtime id. */
|
|
22
22
|
export type RestoreModelMessage = typeof RestoreModelMessage.Type;
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=modelPreservation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelPreservation.d.ts","sourceRoot":"","sources":["../../src/runtime/modelPreservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,+SAA+S;AAC/S,eAAO,MAAM,oBAAoB;;;;EAI/B,CAAA;AACF,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,sGAAsG;AACtG,eAAO,MAAM,mBAAmB;;EAE9B,CAAA;AACF,wFAAwF;AACxF,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAEjE,kKAAkK;AAClK,eAAO,MAAM,mBAAmB;;;EAG9B,CAAA;AACF,uFAAuF;AACvF,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
/** Browser → plugin: the runtime preserves its current Model under a stable id so it can be restored after a full reload. `
|
|
2
|
+
/** Browser → plugin: the runtime preserves its current Model under a stable id so it can be restored after a full reload. `isReloadFlush` is set by the runtime when flushing on `vite:beforeFullReload` to mark the entry as eligible for restoration; absent or `false` for ordinary debounced preserves. */
|
|
3
3
|
export const PreserveModelMessage = Schema.Struct({
|
|
4
4
|
id: Schema.String,
|
|
5
5
|
model: Schema.Unknown,
|
|
6
|
-
|
|
6
|
+
isReloadFlush: Schema.optional(Schema.Boolean),
|
|
7
7
|
});
|
|
8
8
|
/** Browser → plugin: the runtime requests its previously-preserved Model on startup, scoped by id. */
|
|
9
9
|
export const RequestModelMessage = Schema.Struct({
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
export declare const preserveModel: (id: string, encodedModel: unknown, isReloadFlush: boolean) => void;
|
|
3
|
+
export declare const resolvePreservedModel: (runtimeId: string) => Effect.Effect<unknown>;
|
|
4
|
+
//# sourceMappingURL=modelPreservationBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelPreservationBridge.d.ts","sourceRoot":"","sources":["../../src/runtime/modelPreservationBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgC,MAAM,QAAQ,CAAA;AAa7D,eAAO,MAAM,aAAa,OACpB,MAAM,gBACI,OAAO,iBACN,OAAO,KACrB,IASF,CAAA;AAQD,eAAO,MAAM,qBAAqB,cACrB,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,OAAO,CAqCvB,CAAA"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Effect, Exit, Function, Schema, pipe } from 'effect';
|
|
2
|
-
import { PreserveModelMessage, RequestModelMessage, RestoreModelMessage, } from './
|
|
2
|
+
import { PreserveModelMessage, RequestModelMessage, RestoreModelMessage, } from './modelPreservation.js';
|
|
3
3
|
const encodePreserveModelMessage = Schema.encodeUnknownSync(PreserveModelMessage);
|
|
4
4
|
const encodeRequestModelMessage = Schema.encodeUnknownSync(RequestModelMessage);
|
|
5
5
|
const decodeRestoreModelMessage = Schema.decodeUnknownExit(RestoreModelMessage);
|
|
6
|
-
export const preserveModel = (id, encodedModel,
|
|
6
|
+
export const preserveModel = (id, encodedModel, isReloadFlush) => {
|
|
7
7
|
if (import.meta.hot) {
|
|
8
|
-
import.meta.hot.send('foldkit:preserve-model', encodePreserveModelMessage(PreserveModelMessage.make({ id, model: encodedModel,
|
|
8
|
+
import.meta.hot.send('foldkit:preserve-model', encodePreserveModelMessage(PreserveModelMessage.make({ id, model: encodedModel, isReloadFlush })));
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
const PLUGIN_RESPONSE_TIMEOUT_MS = 500;
|
|
12
|
-
// NOTE: asks @foldkit/vite-plugin for a model preserved across the last
|
|
12
|
+
// NOTE: asks @foldkit/vite-plugin for a model preserved across the last
|
|
13
13
|
// reload. The plugin only serves a model whose preservation was flushed by a
|
|
14
14
|
// reload, so a host-driven dispose-then-embed remount initializes fresh while
|
|
15
15
|
// a code reload restores state.
|
|
16
|
-
export const
|
|
16
|
+
export const resolvePreservedModel = (runtimeId) => {
|
|
17
17
|
const hot = import.meta.hot;
|
|
18
18
|
if (!hot) {
|
|
19
19
|
return Effect.succeed(undefined);
|
|
@@ -34,10 +34,10 @@ export const resolveHmrModel = (runtimeId) => {
|
|
|
34
34
|
hot.send('foldkit:request-model', encodeRequestModelMessage(RequestModelMessage.make({ id: runtimeId })));
|
|
35
35
|
return Effect.sync(() => hot.off('foldkit:restore-model', handler));
|
|
36
36
|
}), Effect.timeout(PLUGIN_RESPONSE_TIMEOUT_MS), Effect.catchTag('TimeoutError', () => {
|
|
37
|
-
console.warn('[foldkit] No response from @foldkit/vite-plugin. Add it to your vite.config.ts for
|
|
37
|
+
console.warn('[foldkit] No response from @foldkit/vite-plugin. Add it to your vite.config.ts for Model preservation across reloads:\n\n' +
|
|
38
38
|
" import { foldkit } from '@foldkit/vite-plugin'\n\n" +
|
|
39
39
|
' export default defineConfig({ plugins: [foldkit()] })\n\n' +
|
|
40
|
-
'Starting without
|
|
40
|
+
'Starting without Model preservation.');
|
|
41
41
|
return Effect.succeed(undefined);
|
|
42
42
|
}));
|
|
43
43
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelPreservationPublic.d.ts","sourceRoot":"","sources":["../../src/runtime/modelPreservationPublic.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,wBAAwB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PreserveModelMessage, RequestModelMessage, RestoreModelMessage, } from './
|
|
1
|
+
export { PreserveModelMessage, RequestModelMessage, RestoreModelMessage, } from './modelPreservation.js';
|
|
@@ -10,7 +10,7 @@ import { type Duration, Effect, type Scope } from 'effect';
|
|
|
10
10
|
* as a no-op. Synchronous semantics let the runtime call this from
|
|
11
11
|
* `vite:beforeFullReload` via `Effect.runSync`, with no race against Vite's
|
|
12
12
|
* `location.reload()`. The two-callback split lets the flush path send
|
|
13
|
-
* `
|
|
13
|
+
* `isReloadFlush: true` while debounced calls send `false`.
|
|
14
14
|
*
|
|
15
15
|
* `cancel` drops the pending model and interrupts the in-flight fiber.
|
|
16
16
|
* Forked fibers are tied to the construction scope via `forkIn`, so scope
|
|
@@ -40,8 +40,9 @@ export type RuntimeConfig<Model, Message, Flags, Resources = never, ManagedResou
|
|
|
40
40
|
* instead of replacing it, and when the config declares Flags, `init` is
|
|
41
41
|
* fed the Schema-decoded Flags payload the server embedded, so both sides
|
|
42
42
|
* compute the same Model. Missing or undecodable handoff data is fatal.
|
|
43
|
-
*
|
|
44
|
-
* because the restored code may no longer match the
|
|
43
|
+
* A Model restored after a development reload gets a fresh replace boot
|
|
44
|
+
* against the stamped root because the restored code may no longer match the
|
|
45
|
+
* served DOM.
|
|
45
46
|
*/
|
|
46
47
|
hydration?: HydrationConfig;
|
|
47
48
|
routing?: RoutingConfig<Message>;
|
|
@@ -73,7 +74,7 @@ export type RuntimeConfig<Model, Message, Flags, Resources = never, ManagedResou
|
|
|
73
74
|
* write site with a stack trace, rather than silently corrupting state or
|
|
74
75
|
* breaking reference-equality change detection.
|
|
75
76
|
*
|
|
76
|
-
* Defaults to `true`. Activates only
|
|
77
|
+
* Defaults to `true`. Activates only under Vite's dev server, so production
|
|
77
78
|
* builds pay nothing. Pass `false` to disable.
|
|
78
79
|
*
|
|
79
80
|
* Scope: only the Model is frozen. Messages are short-lived and are not
|
|
@@ -81,13 +82,13 @@ export type RuntimeConfig<Model, Message, Flags, Resources = never, ManagedResou
|
|
|
81
82
|
*/
|
|
82
83
|
freezeModel?: boolean;
|
|
83
84
|
/**
|
|
84
|
-
* Restores the window scroll position across Vite
|
|
85
|
+
* Restores the window scroll position across Vite dev reloads. Every edit
|
|
85
86
|
* triggers a full page reload, which resets scroll to the top; this captures
|
|
86
87
|
* `window.scrollX`/`scrollY` just before the reload and reapplies it once the
|
|
87
88
|
* restored view has rendered, so editing a page you've scrolled deep into
|
|
88
89
|
* doesn't bounce you back to the top on every save.
|
|
89
90
|
*
|
|
90
|
-
* Defaults to `true`. Activates only
|
|
91
|
+
* Defaults to `true`. Activates only under Vite's dev server and the
|
|
91
92
|
* runtime owns the document, so production builds and embedded `makeElement`
|
|
92
93
|
* apps (which do not own the page's scroll) pay nothing. Pass `false` to
|
|
93
94
|
* disable, for an app that drives its own scroll restoration.
|
|
@@ -152,7 +153,7 @@ export type FlagsSchemaConfig<Flags> = Readonly<{
|
|
|
152
153
|
*/
|
|
153
154
|
export type MakeRuntimeReturn<P extends Ports | undefined = undefined, Flags = void, Resources = never, Kind extends 'Application' | 'Element' = 'Application' | 'Element'> = Readonly<{
|
|
154
155
|
runtimeId: string;
|
|
155
|
-
start: (
|
|
156
|
+
start: (preservedModel?: unknown) => Effect.Effect<void>;
|
|
156
157
|
ports: P;
|
|
157
158
|
'~foldkit/RuntimeBoot'?: Readonly<{
|
|
158
159
|
Flags: (flags: Flags) => Flags;
|
|
@@ -161,7 +162,7 @@ export type MakeRuntimeReturn<P extends Ports | undefined = undefined, Flags = v
|
|
|
161
162
|
}>;
|
|
162
163
|
}>;
|
|
163
164
|
type RuntimeInternals = {
|
|
164
|
-
startWith: (maybeConnector: Option.Option<HostConnector>,
|
|
165
|
+
startWith: (maybeConnector: Option.Option<HostConnector>, preservedModel?: unknown, bootMode?: BootMode, flags?: Effect.Effect<any, never, any>, buildId?: string) => Effect.Effect<void>;
|
|
165
166
|
kind: 'Application' | 'Element';
|
|
166
167
|
isEmbedActive: boolean;
|
|
167
168
|
maybeActiveFiber: Option.Option<Fiber.Fiber<void>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEN,KAAK,EACL,KAAK,EACL,MAAM,EAGN,MAAM,EAEP,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,QAAQ,EACR,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,GAAG,EAA+B,MAAM,iBAAiB,CAAA;AAClE,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEN,KAAK,EACL,KAAK,EACL,MAAM,EAGN,MAAM,EAEP,MAAM,QAAQ,CA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C,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,EACtC,OAAO,CAAC,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAA;IAC/B,aAAa,EAAE,OAAO,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;CACnD,CAAA;AAED,eAAO,MAAM,gBAAgB,mCAA0C,CAAA;AAEvE,eAAO,MAAM,WAAW,GACtB,KAAK,EACL,OAAO,EACP,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,CAAC,SAAS,KAAK,GAAG,SAAS,EAC3B,IAAI,SAAS,aAAa,GAAG,SAAS,kRAwBrC,aAAa,CACd,KAAK,EACL,OAAO,EACP,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,CAAC,EACD,IAAI,CACL,KAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAygB9C,CAAA"}
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -6,16 +6,16 @@ import { addNavigationEventListeners, } from './browserListeners.js';
|
|
|
6
6
|
import { deepFreeze } from './deepFreeze.js';
|
|
7
7
|
import { makeDevToolsIntegration } from './devToolsIntegration.js';
|
|
8
8
|
import { createDuplicateIdScanner } from './duplicateIdScanner.js';
|
|
9
|
-
import { preserveModel } from './hmrModelBridge.js';
|
|
10
|
-
import { preserveScrollPosition, restorePreservedScrollPosition, } from './hmrScroll.js';
|
|
11
9
|
import { makePortChannels, validatePorts, } from './hostConnector.js';
|
|
12
10
|
import { resolveHydrationHandoff, } from './hydrationHandoff.js';
|
|
13
11
|
import { forkManagedResourceFibers } from './managedResourceFibers.js';
|
|
14
12
|
import { makeMessageQueue } from './messageQueue.js';
|
|
13
|
+
import { preserveModel } from './modelPreservationBridge.js';
|
|
15
14
|
import { makePreserveScheduler } from './preserveScheduler.js';
|
|
16
15
|
import { makeRenderer } from './renderer.js';
|
|
17
16
|
import { makeResourceProvider } from './resourceProvider.js';
|
|
18
17
|
import { makeRuntimeStatus } from './runtimeStatus.js';
|
|
18
|
+
import { preserveScrollPosition, restorePreservedScrollPosition, } from './scrollPreservation.js';
|
|
19
19
|
import { __resolveSlowConfig, measureSlowPhase, reportSlowPhase, } from './slowPhase.js';
|
|
20
20
|
import { forkSubscriptionFibers } from './subscriptionFibers.js';
|
|
21
21
|
import { __resolveStartViewTransition, } from './viewTransition.js';
|
|
@@ -50,7 +50,7 @@ export const makeRuntime = ({ ports, kind, Model, Flags: FlagsCodec, configuredF
|
|
|
50
50
|
const runtimeId = hydration !== undefined && hydration.runtimeId !== ''
|
|
51
51
|
? hydration.runtimeId
|
|
52
52
|
: (container?.id ?? '');
|
|
53
|
-
const startWith = (maybeConnector,
|
|
53
|
+
const startWith = (maybeConnector, preservedModel, bootMode = 'Fresh', bootFlags, buildId) => {
|
|
54
54
|
// NOTE: one notifier per runtime, provided across the whole runtime
|
|
55
55
|
// Effect so Commands, Subscriptions, and Mount-forked Effects all resolve
|
|
56
56
|
// the same signal. A commit in one embedded application must never wake a
|
|
@@ -58,7 +58,7 @@ export const makeRuntime = ({ ports, kind, Model, Flags: FlagsCodec, configuredF
|
|
|
58
58
|
const commitNotifier = createCommitNotifier();
|
|
59
59
|
return Effect.scoped(Effect.gen(function* () {
|
|
60
60
|
if (runtimeId === '') {
|
|
61
|
-
return yield* Effect.die(new Error('[foldkit] Runtime container must have an `id` for
|
|
61
|
+
return yield* Effect.die(new Error('[foldkit] Runtime container must have an `id` for Model preservation across reloads. ' +
|
|
62
62
|
'Set `container.id = "app"` (or any unique string) before passing it to makeApplication or makeElement. ' +
|
|
63
63
|
'On a server-rendered page the id comes from the `data-foldkit-app` root stamp instead.'));
|
|
64
64
|
}
|
|
@@ -89,7 +89,7 @@ export const makeRuntime = ({ ports, kind, Model, Flags: FlagsCodec, configuredF
|
|
|
89
89
|
configuredFlags,
|
|
90
90
|
isFlagsRequired,
|
|
91
91
|
FlagsCodec,
|
|
92
|
-
|
|
92
|
+
preservedModel,
|
|
93
93
|
container,
|
|
94
94
|
buildId,
|
|
95
95
|
provideResources,
|
|
@@ -97,33 +97,33 @@ export const makeRuntime = ({ ports, kind, Model, Flags: FlagsCodec, configuredF
|
|
|
97
97
|
const ModelJsonCodec = Schema.toCodecJson(
|
|
98
98
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
99
99
|
Model);
|
|
100
|
-
const
|
|
101
|
-
const
|
|
100
|
+
const decodePreservedModel = Schema.decodeUnknownExit(ModelJsonCodec);
|
|
101
|
+
const encodePreservedModel = Schema.encodeUnknownSync(ModelJsonCodec);
|
|
102
102
|
const currentUrl = Option.fromNullishOr(routingConfig).pipe(Option.flatMap(() => urlFromString(window.location.href)));
|
|
103
103
|
// NOTE: a restored Model skips `init`, so resolving Flags on that
|
|
104
104
|
// path would build the `resources` Layer only to discard what it
|
|
105
105
|
// produced. Gating the resolution on the restore decision is what
|
|
106
106
|
// stops a reload from reconnecting whatever the Layer holds. It has
|
|
107
|
-
// to stay ahead of the preserve-scheduler and
|
|
107
|
+
// to stay ahead of the preserve-scheduler and preservation finalizers: a
|
|
108
108
|
// Flags Effect that fails after those are registered tears down more
|
|
109
109
|
// than it used to, and their release defects would bury its cause.
|
|
110
110
|
const runInit = Effect.map(resolveFlags, flags => init(flags, Option.getOrUndefined(currentUrl)));
|
|
111
|
-
const init_ = yield*
|
|
112
|
-
? Exit.match(
|
|
111
|
+
const init_ = yield* preservedModel !== undefined
|
|
112
|
+
? Exit.match(decodePreservedModel(preservedModel), {
|
|
113
113
|
onFailure: () => runInit,
|
|
114
114
|
onSuccess: restoredModel => Effect.succeed({ model: restoredModel }),
|
|
115
115
|
})
|
|
116
116
|
: runInit;
|
|
117
117
|
const initModelRaw = init_.model;
|
|
118
118
|
const initCommands = init_.commands ?? [];
|
|
119
|
-
// NOTE: keep `
|
|
119
|
+
// NOTE: keep `encodePreservedModel` off the dispatch hot path. It walks
|
|
120
120
|
// the entire Model graph (O(modelSize) per call) and blocks input
|
|
121
121
|
// on large Models. The scheduler defers encoding to a quiet window
|
|
122
|
-
// and the `vite:beforeFullReload` flush covers the
|
|
122
|
+
// and the `vite:beforeFullReload` flush covers the reload boundary.
|
|
123
123
|
const PRESERVE_DEBOUNCE = Duration.millis(200);
|
|
124
124
|
const preserveScheduler = yield* makePreserveScheduler({
|
|
125
|
-
onDebounce: model => Effect.sync(() => preserveModel(runtimeId,
|
|
126
|
-
onFlush: model => Effect.sync(() => preserveModel(runtimeId,
|
|
125
|
+
onDebounce: model => Effect.sync(() => preserveModel(runtimeId, encodePreservedModel(model), false)),
|
|
126
|
+
onFlush: model => Effect.sync(() => preserveModel(runtimeId, encodePreservedModel(model), true)),
|
|
127
127
|
}, PRESERVE_DEBOUNCE);
|
|
128
128
|
const hot = import.meta.hot;
|
|
129
129
|
if (hot) {
|
|
@@ -342,14 +342,14 @@ export const makeRuntime = ({ ports, kind, Model, Flags: FlagsCodec, configuredF
|
|
|
342
342
|
yield* Effect.never;
|
|
343
343
|
})).pipe(Effect.provideService(RenderCommit, commitNotifier.service));
|
|
344
344
|
};
|
|
345
|
-
const start = (
|
|
345
|
+
const start = (preservedModel) => startWith(Option.none(), preservedModel, 'Fresh');
|
|
346
346
|
const program = {
|
|
347
347
|
runtimeId,
|
|
348
348
|
start,
|
|
349
349
|
ports,
|
|
350
350
|
};
|
|
351
351
|
runtimeInternals.set(program, {
|
|
352
|
-
startWith: (maybeConnector,
|
|
352
|
+
startWith: (maybeConnector, preservedModel, bootMode, flags, buildId) => startWith(maybeConnector, preservedModel, bootMode, flags, buildId),
|
|
353
353
|
kind,
|
|
354
354
|
isEmbedActive: false,
|
|
355
355
|
maybeActiveFiber: Option.none(),
|
|
@@ -18,4 +18,4 @@ export declare const takePreservedScrollPosition: (runtimeId: string) => Option.
|
|
|
18
18
|
* defeating any CSS `scroll-behavior: smooth`. A no-op when nothing was
|
|
19
19
|
* preserved. Consumes the stored offset, so a second call restores nothing. */
|
|
20
20
|
export declare const restorePreservedScrollPosition: (runtimeId: string) => Effect.Effect<void>;
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=scrollPreservation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollPreservation.d.ts","sourceRoot":"","sources":["../../src/runtime/scrollPreservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AAiB/C;+EAC+E;AAC/E,eAAO,MAAM,yBAAyB,cAAe,MAAM,KAAG,MAC/B,CAAA;AAE/B;;oCAEoC;AACpC,eAAO,MAAM,sBAAsB,cAAe,MAAM,KAAG,IAW1D,CAAA;AAED;;;0BAG0B;AAC1B,eAAO,MAAM,2BAA2B,cAC3B,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAS1D,CAAA;AAED;;gFAEgF;AAChF,eAAO,MAAM,8BAA8B,cAC9B,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAOjB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Option, Schema } from 'effect';
|
|
2
2
|
/**
|
|
3
|
-
* Window scroll offset persisted across a Vite
|
|
3
|
+
* Window scroll offset persisted across a Vite dev full reload. Held in
|
|
4
4
|
* `sessionStorage` as a JSON string so it survives the reload and can be
|
|
5
5
|
* reapplied synchronously at the next init render, before the browser paints.
|
|
6
6
|
*/
|
|
@@ -9,7 +9,7 @@ const encodePreservedScrollPosition = Schema.encodeUnknownSync(PreservedScrollPo
|
|
|
9
9
|
const decodePreservedScrollPosition = Schema.decodeUnknownOption(PreservedScrollPosition);
|
|
10
10
|
/** The `sessionStorage` key a runtime uses for its preserved scroll offset,
|
|
11
11
|
* scoped by runtime id so multiple runtimes never read each other's value. */
|
|
12
|
-
export const preservedScrollStorageKey = (runtimeId) => `foldkit:
|
|
12
|
+
export const preservedScrollStorageKey = (runtimeId) => `foldkit:scroll:${runtimeId}`;
|
|
13
13
|
/** Captures the current window scroll offset under the runtime's key. Called
|
|
14
14
|
* from the `vite:beforeFullReload` handler so the offset is stored just
|
|
15
15
|
* before Vite reloads the page. */
|
|
@@ -20,7 +20,7 @@ export const preserveScrollPosition = (runtimeId) => {
|
|
|
20
20
|
catch {
|
|
21
21
|
// NOTE: sessionStorage throws when storage is disabled or blocked by a
|
|
22
22
|
// privacy mode. Scroll restoration is a dev-only convenience, so a failure
|
|
23
|
-
// here must never break the
|
|
23
|
+
// here must never break the dev reload this runs inside.
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
/** Reads and clears the preserved scroll offset for a runtime. Returns
|
|
@@ -63,7 +63,8 @@ type ResolvedSlowConfig<Model, Message> = Readonly<{
|
|
|
63
63
|
* thresholds. Pass `false` to disable warnings entirely. Pass an object to
|
|
64
64
|
* refine those defaults.
|
|
65
65
|
*
|
|
66
|
-
* - `show`: `'Development'` (default) enables warnings only
|
|
66
|
+
* - `show`: `'Development'` (default) enables warnings only under Vite's dev
|
|
67
|
+
* server. `'Always'` enables them in every environment.
|
|
67
68
|
* - `measuredPhases`: Phases to measure. Defaults to every slow warning phase.
|
|
68
69
|
* - `thresholdOverrides`: Per-phase budget overrides. Omitted fields keep defaults; overrides for unmeasured phases are ignored.
|
|
69
70
|
* - `onSlow`: Callback for every measured phase that exceeds its budget. Replaces Foldkit's default `console.warn`; Foldkit will not also warn for tags your callback ignores.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slowPhase.d.ts","sourceRoot":"","sources":["../../src/runtime/slowPhase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAqB,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAE9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@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
1
|
+
import { Cause, Effect } from 'effect';
|
|
2
2
|
import type { Ports } from '../port/index.js';
|
|
3
3
|
import { type EmbedHandle } from './hostConnector.js';
|
|
4
4
|
import type { BootMode } from './hydrationHandoff.js';
|
|
@@ -12,17 +12,20 @@ export type RunOptions<Flags, Resources = never> = Readonly<{
|
|
|
12
12
|
}>;
|
|
13
13
|
type RuntimeProgram = Readonly<{
|
|
14
14
|
runtimeId: string;
|
|
15
|
-
start: (
|
|
15
|
+
start: (preservedModel?: unknown) => Effect.Effect<void>;
|
|
16
16
|
ports: Ports | undefined;
|
|
17
17
|
}>;
|
|
18
18
|
/** Starts a program Effect with explicit boot inputs for runtime tests.
|
|
19
19
|
* @internal */
|
|
20
|
-
export declare const __startProgram: (program: RuntimeProgram,
|
|
20
|
+
export declare const __startProgram: (program: RuntimeProgram, preservedModel: unknown, bootMode: BootMode, flags?: Effect.Effect<unknown, never, any>, buildId?: string) => Effect.Effect<void>;
|
|
21
|
+
/** Reports unhandled non-interrupt Causes using Effect's runtime policy.
|
|
22
|
+
* @internal */
|
|
23
|
+
export declare const __reportUnhandledCause: <E>(cause: Cause.Cause<E>) => Effect.Effect<void>;
|
|
21
24
|
/** Starts a Foldkit runtime that owns the page for the page's whole lifetime,
|
|
22
|
-
* with
|
|
23
|
-
* the container, replacing whatever is there. On a
|
|
24
|
-
* `hydrate` instead, which adopts the existing DOM.
|
|
25
|
-
* host-controlled lifecycle, use `embed`. */
|
|
25
|
+
* with state-preserving live reload for development. The first render builds
|
|
26
|
+
* the DOM fresh in the container, replacing whatever is there. On a
|
|
27
|
+
* server-rendered page use `hydrate` instead, which adopts the existing DOM.
|
|
28
|
+
* To start a runtime under a host-controlled lifecycle, use `embed`. */
|
|
26
29
|
export declare function run<P extends Ports | undefined, Resources, Kind extends 'Application' | 'Element'>(program: MakeRuntimeReturn<P, void, Resources, Kind>): void;
|
|
27
30
|
export declare function run<P extends Ports | undefined, Flags, Resources, Kind extends 'Application' | 'Element'>(program: MakeRuntimeReturn<P, Flags, Resources, Kind>, options: RunOptions<Flags, Resources>): void;
|
|
28
31
|
/** Options for {@link hydrate}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAOP,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAOP,MAAM,QAAQ,CAAA;AAEf,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,SAAS,CAAA;CACzB,CAAC,CAAA;AAEF;eACe;AACf,eAAO,MAAM,cAAc,YAChB,cAAc,kBACP,OAAO,YACb,QAAQ,UACV,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EA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