foldkit 0.114.0 → 0.115.0

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
@@ -184,7 +184,7 @@ Foldkit is a complete system, not a collection of libraries you stitch together.
184
184
  - **Crash View and Reporting**: Configure `crash.view` to render a custom fallback UI when the update loop throws. A `crash.report` callback fires first with the error, Model, and triggering Message, so you can ship it straight to Sentry or your logger.
185
185
  - **Story Testing**: Exercise the update function directly. Send Messages, resolve Commands inline with `Story.Command.resolve` and `Story.Command.resolveAll`, and assert with focused helpers: `Story.model`, `Story.Command.expectHas`, `Story.Command.expectExact`, `Story.Command.expectNone`, and `Story.expectOutMessage`. No mocking libraries, no fake timers.
186
186
  - **Scene Testing**: Drive your app the way a user does. Scene renders your real view, then clicks buttons, types into inputs, presses keys, and asserts on what's on screen. Accessible locators (`role`, `label`, `placeholder`, `altText`, `title`, `testId`, `displayValue`) with full options (`name`, `level`, `checked`, `selected`, `pressed`, `expanded`, `disabled`), multi-match `Scene.all` with `Scene.filter` and `Scene.nth`, scoped steps via `Scene.inside`, pointer events, event bubbling, and Vitest matchers like `toHaveText`, `toBeVisible`, `toHaveAccessibleName`, and `toHaveCount`. API parity with React Testing Library and Playwright, without a browser.
187
- - **Slow-View Monitoring**: Wire `slowView` on `makeApplication` to catch renders that exceed a threshold you set. The callback fires with the current Model, the triggering Message, and the render duration, so you can log it, sample it, or ship it to your observability tool.
187
+ - **Slow Warnings**: Wire `slow` on `makeApplication` or `makeElement` to catch synchronous phases that exceed budgets: update, view, patch, and Subscription dependency extraction. Configure `measuredPhases`, `thresholdOverrides`, and one `onSlow` sink to state what is measured, which budgets change, and where every slow event goes.
188
188
  - **HMR**: Vite plugin with state-preserving hot module replacement. Change your view, keep your state.
189
189
 
190
190
  ## Correctness You (And Your LLM) Can See
@@ -57,6 +57,7 @@ export type BoundaryRegistry = {
57
57
  readonly boundaryDispatches: WeakMap<DispatchSync, Map<BoundaryId, DispatchSync>>;
58
58
  readonly seenThisRender: Map<BoundaryId, string>;
59
59
  readonly lazyTrackingStack: Array<Map<BoundaryId, string>>;
60
+ readonly dedupeSeen: Set<object>;
60
61
  };
61
62
  export declare const createBoundaryRegistry: () => BoundaryRegistry;
62
63
  export declare const registerBoundaryWrap: (registry: BoundaryRegistry, boundaryId: BoundaryId, descriptor: WrapDescriptor) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../src/html/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;CAC/C,CAAC,CAAA;AAEF;;;;eAIe;AACf,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAI/B,eAAO,MAAM,aAAa,EAAE,UAAe,CAAA;AAE3C,eAAO,MAAM,eAAe,GAC1B,QAAQ,UAAU,EAClB,SAAS,MAAM,KACd,UAUF,CAAA;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAwCa;AACb,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAClC,YAAY,EACZ,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAC9B,CAAA;IACD,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAChD,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;CAC3D,CAAA;AAED,eAAO,MAAM,sBAAsB,QAAO,gBAKxC,CAAA;AAqBF,eAAO,MAAM,oBAAoB,GA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,6 +15,7 @@ export const createBoundaryRegistry = () => ({
15
15
  boundaryDispatches: new WeakMap(),
16
16
  seenThisRender: new Map(),
17
17
  lazyTrackingStack: [],
18
+ dedupeSeen: new Set(),
18
19
  });
19
20
  const captureCallSite = () => {
20
21
  const stack = new Error().stack ?? '';
@@ -181,4 +182,5 @@ export const getOrCreateBoundaryDispatch = (registry, outerDispatch, boundaryId)
181
182
  * resurrect the `dispatchAcrossBoundary missing wrap` crash. */
182
183
  export const beginRender = (registry) => {
183
184
  registry.seenThisRender.clear();
185
+ registry.dedupeSeen.clear();
184
186
  };
@@ -1,4 +1,4 @@
1
- import type { VNode } from '../vdom.js';
1
+ import { type VNode } from '../vdom.js';
2
2
  /** Creates a memoization slot for a view function. On each render, if the
3
3
  * function reference, dispatch, and all arguments are referentially equal
4
4
  * (`===`) to the previous call, the cached VNode is returned without
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/html/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiEvC;;;;;;;;;;;;;;;;;oCAiBoC;AACpC,eAAO,MAAM,UAAU,QAAO,CAAC,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EACjE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,EACnC,IAAI,EAAE,IAAI,KACP,KAAK,GAAG,IAAI,CAUhB,CAAA;AAED;;;;;;;qDAOqD;AACrD,eAAO,MAAM,eAAe,QAAO,CAAC,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EACtE,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,EACnC,IAAI,EAAE,IAAI,KACP,KAAK,GAAG,IAAI,CAWhB,CAAA"}
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/html/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAwC,MAAM,YAAY,CAAA;AA2E7E;;;;;;;;;;;;;;;;;oCAiBoC;AACpC,eAAO,MAAM,UAAU,QAAO,CAAC,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EACjE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,EACnC,IAAI,EAAE,IAAI,KACP,KAAK,GAAG,IAAI,CAUhB,CAAA;AAED;;;;;;;qDAOqD;AACrD,eAAO,MAAM,eAAe,QAAO,CAAC,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EACtE,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,EACnC,IAAI,EAAE,IAAI,KACP,KAAK,GAAG,IAAI,CAWhB,CAAA"}
package/dist/html/lazy.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Predicate } from 'effect';
2
+ import { dedupeMemoizedResult, memoizedVNodes } from '../vdom.js';
2
3
  import { beginLazyTracking, endLazyTracking, markSeenForLazyHit, } from './boundary.js';
3
4
  import { requireBoundary, requireDispatch, } from './runtimeSingleton.js';
4
5
  const argsEqual = (previous, current) => previous.length === current.length &&
@@ -25,8 +26,18 @@ const resolveOrCache = (previousEntry, fn, args, onCache) => {
25
26
  finally {
26
27
  endLazyTracking(registry);
27
28
  }
28
- onCache({ fn, args, dispatch, vnode, trackedBoundaries });
29
- return vnode;
29
+ // NOTE: dedupe the freshly built subtree against the per-render seen set so a
30
+ // const shared inside this view, or across memoized siblings, is cloned even
31
+ // though dedupeSharedVNodes leaves memoized subtrees opaque. Record the result
32
+ // in memoizedVNodes so that top-level pass keeps it opaque on a cache hit.
33
+ const deduped = Predicate.isNotNull(vnode)
34
+ ? dedupeMemoizedResult(vnode, registry.dedupeSeen)
35
+ : null;
36
+ if (Predicate.isNotNull(deduped)) {
37
+ memoizedVNodes.add(deduped);
38
+ }
39
+ onCache({ fn, args, dispatch, vnode: deduped, trackedBoundaries });
40
+ return deduped;
30
41
  };
31
42
  /** Creates a memoization slot for a view function. On each render, if the
32
43
  * function reference, dispatch, and all arguments are referentially equal
@@ -1,4 +1,4 @@
1
- import type { VNode } from '../vdom.js';
1
+ import { type VNode } from '../vdom.js';
2
2
  declare const SUBMODEL_MESSAGE_BRAND = "__submodelMessage";
3
3
  /** A view function branded with the Message type it dispatches. Build
4
4
  * one with {@link defineView}:
@@ -1 +1 @@
1
- {"version":3,"file":"submodel.d.ts","sourceRoot":"","sources":["../../src/html/submodel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAoBvC,QAAA,MAAM,sBAAsB,sBAAsB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;gCAqBgC;AAChC,MAAM,MAAM,YAAY,CACtB,KAAK,EACL,OAAO,EACP,UAAU,GAAG,IAAI,IACf,CAAC,UAAU,SAAS,IAAI,GACxB,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,GAAG,IAAI,GAC9B,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,IAAI,CAAC,GAAG;IAC5D,QAAQ,CAAC,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAC3C,CAAA;AAED;;;;;;;;;yDASyD;AACzD,eAAO,MAAM,UAAU,GAAI,KAAK,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,EAC1D,IAAI,UAAU,SAAS,IAAI,GACvB,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,GAAG,IAAI,GAC9B,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,IAAI,KACzD,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAQM,CAAA;AAEhD,KAAK,eAAe,GAAG,CAAC,CAAC,GAAG,IA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G,OAAO,GACP,KAAK,CAAA;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAyCqC;AACrC,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,eAAe,IAAI,QAAQ,CAAC;IAClE,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,EAAE,IAAI,CAAA;IACV,UAAU,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;IAC/B,eAAe,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,OAAO,CAAA;CAC3D,CAAC,CAAA;AA8JF,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,eAAe,EACnD,QAAQ,cAAc,CAAC,IAAI,CAAC,KAC3B,KAAK,GAAG,IAsDV,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { Predicate } from 'effect';
2
+ import { memoizedVNodes } from '../vdom.js';
2
3
  import { composeBoundary, deregisterBoundaryWrap, registerBoundaryWrap, } from './boundary.js';
3
4
  import { isChildAttribute } from './childAttribute.js';
4
5
  import { clearRuntime, getCurrentFrame, pushBoundary, pushFrame, } from './runtimeSingleton.js';
@@ -145,10 +146,18 @@ const withBoundaryCleanup = (vnode, registry, boundaryId) => {
145
146
  previousDestroy(removed);
146
147
  }
147
148
  };
148
- return {
149
+ const wrapped = {
149
150
  ...vnode,
150
151
  data: { ...data, hook: { ...hook, destroy: compositeDestroy } },
151
152
  };
153
+ // NOTE: a memoized child view returns the same vnode by reference each render;
154
+ // this wrapper is fresh but shares its cached children. Propagate membership
155
+ // so dedupeSharedVNodes keeps the wrapper opaque instead of cloning that
156
+ // cached subtree every render.
157
+ if (memoizedVNodes.has(vnode)) {
158
+ memoizedVNodes.add(wrapped);
159
+ }
160
+ return wrapped;
152
161
  };
153
162
  export const submodel = (config) => {
154
163
  // Snapshot the parent frame BEFORE pushing the child boundary. The
@@ -1,11 +1,11 @@
1
- import { type Effect, Option, type Schema } from 'effect';
1
+ import { type Effect, Option, type Schema, type Scope } from 'effect';
2
2
  import type { ManagedResource } from '../managedResource/index.js';
3
3
  /** Internal configuration for a single Managed Resource, used by the runtime. */
4
4
  export type ManagedResourceConfig<Model, Message> = {
5
5
  readonly schema: Schema.Schema<any>;
6
6
  readonly resource: ManagedResource<any>;
7
7
  readonly modelToMaybeRequirements: (model: Model) => any;
8
- readonly acquire: (params: any) => Effect.Effect<any, unknown>;
8
+ readonly acquire: (params: any) => Effect.Effect<any, unknown, Scope.Scope>;
9
9
  readonly release: (value: any) => Effect.Effect<void>;
10
10
  readonly onAcquired: (value: any) => Message;
11
11
  readonly onReleased: () => Message;
@@ -30,17 +30,21 @@ type AcquireParams<Requirements> = Requirements extends Option.Option<infer Para
30
30
  * `never`, so application code cannot manually construct one: it must go
31
31
  * through a constructor.
32
32
  *
33
+ * The `Value` parameter is the type the resource holds while active: what
34
+ * `acquire` produces, what `release` and `onAcquired` receive, and what the
35
+ * tag's `.get` yields to commands. It is inferred from the `resource` tag.
36
+ *
33
37
  * The `Service` parameter carries the resource tag's identity so `make`,
34
38
  * `lift`, and `aggregate` can union the services a record requires. Read the
35
39
  * union off a finished record with `ManagedResource.ServicesOf`.
36
40
  */
37
- export type Entry<Model, Message, Requirements, Service = unknown> = {
41
+ export type Entry<Model, Message, Requirements, Value, Service = unknown> = {
38
42
  readonly schema: Schema.Schema<Requirements>;
39
- readonly resource: ManagedResource<any, Service>;
43
+ readonly resource: ManagedResource<Value, Service>;
40
44
  readonly modelToMaybeRequirements: (model: Model) => Requirements;
41
- readonly acquire: (params: AcquireParams<Requirements>) => Effect.Effect<any, unknown>;
42
- readonly release: (value: any) => Effect.Effect<void>;
43
- readonly onAcquired: (value: any) => Message;
45
+ readonly acquire: (params: AcquireParams<Requirements>) => Effect.Effect<Value, unknown, Scope.Scope>;
46
+ readonly release: (value: Value) => Effect.Effect<void>;
47
+ readonly onAcquired: (value: Value) => Message;
44
48
  readonly onReleased: () => Message;
45
49
  readonly onAcquireError: (error: unknown) => Message;
46
50
  } & EntryBrand;
@@ -58,15 +62,15 @@ export type ServicesOf<Resources> = {
58
62
  * destructuring patterns are inferred correctly even when the schema uses
59
63
  * transforms like `S.Option`.
60
64
  */
61
- export type EntryBuilder<Model, Message> = <RequirementsSchema extends Schema.Schema<any>, Service>(schema: RequirementsSchema, config: {
62
- readonly resource: ManagedResource<any, Service>;
65
+ export type EntryBuilder<Model, Message> = <RequirementsSchema extends Schema.Schema<any>, Value, Service>(schema: RequirementsSchema, config: {
66
+ readonly resource: ManagedResource<Value, Service>;
63
67
  readonly modelToMaybeRequirements: (model: Model) => Schema.Schema.Type<RequirementsSchema>;
64
- readonly acquire: (params: AcquireParams<Schema.Schema.Type<RequirementsSchema>>) => Effect.Effect<any, unknown>;
65
- readonly release: (value: any) => Effect.Effect<void>;
66
- readonly onAcquired: (value: any) => Message;
68
+ readonly acquire: (params: AcquireParams<Schema.Schema.Type<RequirementsSchema>>) => Effect.Effect<Value, unknown, Scope.Scope>;
69
+ readonly release: (value: Value) => Effect.Effect<void>;
70
+ readonly onAcquired: (value: Value) => Message;
67
71
  readonly onReleased: () => Message;
68
72
  readonly onAcquireError: (error: unknown) => Message;
69
- }) => Entry<Model, Message, Schema.Schema.Type<RequirementsSchema>, Service>;
73
+ }) => Entry<Model, Message, Schema.Schema.Type<RequirementsSchema>, Value, Service>;
70
74
  /**
71
75
  * Declares a Managed Resources record. The Model and Message generics are
72
76
  * provided up front; the entries record follows, built from calls to the
@@ -108,8 +112,17 @@ export type EntryBuilder<Model, Message> = <RequirementsSchema extends Schema.Sc
108
112
  * - `acquire` — Creates the resource from the unwrapped params. The returned
109
113
  * Effect should fail when acquisition fails: errors in the error channel
110
114
  * flow to `onAcquireError` as a message instead of crashing the runtime.
115
+ * `acquire` runs with the resource-lifetime `Scope.Scope` in its context, so
116
+ * it can build an Effect `Layer` with `Layer.build` or register finalizers
117
+ * with `Effect.addFinalizer` whose teardown is tied to the resource. Those
118
+ * finalizers run when the resource is released or re-acquired, after the
119
+ * explicit `release` callback (scope finalizers run in last-in-first-out
120
+ * order, and the runtime registers `release` after `acquire` completes). A
121
+ * `Layer`-built resource therefore needs only `release: () => Effect.void`:
122
+ * the `Layer` finalizers run automatically when the scope closes.
111
123
  * - `release` — Tears down the resource. Errors thrown here are silently
112
- * swallowed: release must not block cleanup.
124
+ * swallowed: release must not block cleanup. Resources that register their
125
+ * teardown as scope finalizers in `acquire` leave this as `() => Effect.void`.
113
126
  * - `onAcquired` — Message dispatched when `acquire` succeeds.
114
127
  * - `onAcquireError` — Message dispatched when `acquire` fails.
115
128
  * - `onReleased` — Message dispatched after `release` completes.
@@ -145,9 +158,9 @@ export type EntryBuilder<Model, Message> = <RequirementsSchema extends Schema.Sc
145
158
  *
146
159
  * @see {@link ManagedResource.tag} for creating the resource identity.
147
160
  */
148
- export declare const make: <Model, Message>() => <Entries extends Record<string, Entry<Model, Message, any, any>>>(build: (entry: EntryBuilder<Model, Message>) => Entries) => Entries;
149
- type ChildModelOf<Resources> = Resources[keyof Resources] extends Entry<infer ChildModel, any, any, any> ? ChildModel : never;
150
- type ChildMessageOf<Resources> = Resources[keyof Resources] extends Entry<any, infer ChildMessage, any, any> ? ChildMessage : never;
161
+ export declare const make: <Model, Message>() => <Entries extends Record<string, Entry<Model, Message, any, any, any>>>(build: (entry: EntryBuilder<Model, Message>) => Entries) => Entries;
162
+ type ChildModelOf<Resources> = Resources[keyof Resources] extends Entry<infer ChildModel, any, any, any, any> ? ChildModel : never;
163
+ type ChildMessageOf<Resources> = Resources[keyof Resources] extends Entry<any, infer ChildMessage, any, any, any> ? ChildMessage : never;
151
164
  /**
152
165
  * Lifts a record of child Managed Resources into a parent's Model and Message
153
166
  * context, applying a Model accessor and a Message wrapper uniformly to every
@@ -160,16 +173,16 @@ type ChildMessageOf<Resources> = Resources[keyof Resources] extends Entry<any, i
160
173
  * just another `None` and flows through the same acquire/release channel, so
161
174
  * each lifted entry's requirements must be `S.Option`-wrapped.
162
175
  */
163
- export declare const lift: <Resources extends Record<string, Entry<any, any, Option.Option<any>, any>>>(resources: Resources) => <ParentModel, ParentMessage>(config: {
176
+ export declare const lift: <Resources extends Record<string, Entry<any, any, Option.Option<any>, any, any>>>(resources: Resources) => <ParentModel, ParentMessage>(config: {
164
177
  readonly toChildModel: (parentModel: ParentModel) => Option.Option<ChildModelOf<Resources>>;
165
178
  readonly toParentMessage: (message: ChildMessageOf<Resources>) => ParentMessage;
166
- }) => { readonly [Key in keyof Resources]: Resources[Key] extends Entry<any, any, infer Requirements, infer Service> ? Entry<ParentModel, ParentMessage, Requirements, Service> : never; };
179
+ }) => { readonly [Key in keyof Resources]: Resources[Key] extends Entry<any, any, infer Requirements, infer Value, infer Service> ? Entry<ParentModel, ParentMessage, Requirements, Value, Service> : never; };
167
180
  type MergeRecords<Records extends ReadonlyArray<unknown>> = Records extends readonly [infer Head, ...infer Rest] ? Head & (Rest extends ReadonlyArray<unknown> ? MergeRecords<Rest> : {}) : {};
168
181
  /**
169
182
  * Combines multiple Managed Resources records into one. Throws on duplicate
170
183
  * keys so a misconfigured aggregate fails loudly at startup rather than
171
184
  * silently overriding.
172
185
  */
173
- export declare const aggregate: <Model, Message>() => <Records extends ReadonlyArray<Record<string, Entry<Model, Message, any, any>>>>(...records: Records) => MergeRecords<Records>;
186
+ export declare const aggregate: <Model, Message>() => <Records extends ReadonlyArray<Record<string, Entry<Model, Message, any, any, any>>>>(...records: Records) => MergeRecords<Records>;
174
187
  export {};
175
188
  //# sourceMappingURL=managedResource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"managedResource.d.ts","sourceRoot":"","sources":["../../src/runtime/managedResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAU,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,iFAAiF;AACjF,MA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EACF,QAAQ,EAAE,GAAG,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,KAAK,CAC7D,GAAG,EACH,GAAG,EACH,MAAM,YAAY,EAClB,MAAM,KAAK,EACX,MAAM,OAAO,CACd,GACG,KAAK,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,GAC/D,KAAK,GAkBC,CAAA;AAEd,KAAK,YAAY,CAAC,OAAO,SAAS,aAAa,CAAC,OAAO,CAAC,IACtD,OAAO,SAAS,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAChD,IAAI,GAAG,CAAC,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GACtE,EAAE,CAAA;AAER;;;;GAIG;AACH,eAAO,MAAM,SAAS,GACnB,KAAK,EAAE,OAAO,QAEb,OAAO,SAAS,aAAa,CAC3B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CACrD,EAED,GAAG,SAAS,OAAO,KAClB,YAAY,CAAC,OAAO,CAetB,CAAA"}
@@ -40,8 +40,17 @@ import { Option, Record } from 'effect';
40
40
  * - `acquire` — Creates the resource from the unwrapped params. The returned
41
41
  * Effect should fail when acquisition fails: errors in the error channel
42
42
  * flow to `onAcquireError` as a message instead of crashing the runtime.
43
+ * `acquire` runs with the resource-lifetime `Scope.Scope` in its context, so
44
+ * it can build an Effect `Layer` with `Layer.build` or register finalizers
45
+ * with `Effect.addFinalizer` whose teardown is tied to the resource. Those
46
+ * finalizers run when the resource is released or re-acquired, after the
47
+ * explicit `release` callback (scope finalizers run in last-in-first-out
48
+ * order, and the runtime registers `release` after `acquire` completes). A
49
+ * `Layer`-built resource therefore needs only `release: () => Effect.void`:
50
+ * the `Layer` finalizers run automatically when the scope closes.
43
51
  * - `release` — Tears down the resource. Errors thrown here are silently
44
- * swallowed: release must not block cleanup.
52
+ * swallowed: release must not block cleanup. Resources that register their
53
+ * teardown as scope finalizers in `acquire` leave this as `() => Effect.void`.
45
54
  * - `onAcquired` — Message dispatched when `acquire` succeeds.
46
55
  * - `onAcquireError` — Message dispatched when `acquire` fails.
47
56
  * - `onReleased` — Message dispatched after `release` completes.
@@ -1,3 +1,3 @@
1
- export { embed, makeApplication, makeElement, run } from './runtime.js';
2
- export type { RoutingConfig, CrashConfig, CrashContext, ElementCrashConfig, RoutingApplicationConfigWithFlags, RoutingApplicationConfig, ApplicationConfigWithFlags, ApplicationConfig, ElementConfigWithFlags, ElementConfig, ApplicationInit, RoutingApplicationInit, ElementInit, EmbedHandle, InboundPortHandle, InboundPortHandles, OutboundPortHandle, OutboundPortHandles, PortHandles, MakeRuntimeReturn, Visibility, SlowViewContext, SlowViewConfig, DevToolsConfig, DevToolsMode, DevToolsModeConfig, DevToolsOverlay, DevToolsPosition, } from './runtime.js';
1
+ export { SlowPhase, defaultSlowCallback, embed, makeApplication, makeElement, run, } from './runtime.js';
2
+ export type { RoutingConfig, CrashConfig, CrashContext, ElementCrashConfig, RoutingApplicationConfigWithFlags, RoutingApplicationConfig, ApplicationConfigWithFlags, ApplicationConfig, ElementConfigWithFlags, ElementConfig, ApplicationInit, RoutingApplicationInit, ElementInit, EmbedHandle, InboundPortHandle, InboundPortHandles, OutboundPortHandle, OutboundPortHandles, PortHandles, MakeRuntimeReturn, Visibility, SlowConfig, SlowContext, SlowPatchContext, SlowSubscriptionDependenciesContext, SlowThresholdOverrides, SlowUpdateContext, SlowViewContext, DevToolsConfig, DevToolsMode, DevToolsModeConfig, DevToolsOverlay, DevToolsPosition, } from './runtime.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvE,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iCAAiC,EACjC,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,eAAe,EACf,WAAW,EACX,GAAG,GACJ,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iCAAiC,EACjC,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,mCAAmC,EACnC,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAA"}
@@ -1 +1 @@
1
- export { embed, makeApplication, makeElement, run } from './runtime.js';
1
+ export { SlowPhase, defaultSlowCallback, embed, makeApplication, makeElement, run, } from './runtime.js';
@@ -71,27 +71,81 @@ export type DevToolsConfig = false | Readonly<{
71
71
  */
72
72
  Message?: Schema.Codec<any, any, unknown, unknown>;
73
73
  }>;
74
- /** Context provided to the slow view callback when a view exceeds the time budget. */
74
+ /** Context provided when view construction exceeds its configured time budget. */
75
75
  export type SlowViewContext<Model, Message> = Readonly<{
76
+ _tag: 'View';
76
77
  model: Model;
77
78
  message: Option.Option<Message>;
78
79
  durationMs: number;
79
80
  thresholdMs: number;
80
81
  }>;
82
+ /** Context provided when update exceeds its configured time budget. */
83
+ export type SlowUpdateContext<Model, Message> = Readonly<{
84
+ _tag: 'Update';
85
+ previousModel: Model;
86
+ nextModel: Model;
87
+ message: Message;
88
+ durationMs: number;
89
+ thresholdMs: number;
90
+ }>;
91
+ /** Context provided when DOM patching exceeds its configured time budget. */
92
+ export type SlowPatchContext<Model, Message> = Readonly<{
93
+ _tag: 'Patch';
94
+ model: Model;
95
+ message: Option.Option<Message>;
96
+ durationMs: number;
97
+ thresholdMs: number;
98
+ }>;
99
+ /** Context provided when subscription dependency extraction exceeds its configured time budget. */
100
+ export type SlowSubscriptionDependenciesContext<Model> = Readonly<{
101
+ _tag: 'SubscriptionDependencies';
102
+ subscriptionKey: string;
103
+ model: Model;
104
+ durationMs: number;
105
+ thresholdMs: number;
106
+ }>;
107
+ /** Tagged union of every slow-phase context passed to `slow.onSlow`. */
108
+ export type SlowContext<Model, Message> = SlowViewContext<Model, Message> | SlowUpdateContext<Model, Message> | SlowPatchContext<Model, Message> | SlowSubscriptionDependenciesContext<Model>;
109
+ /** Phase names measured by the slow warning runtime option. */
110
+ export declare const SlowPhase: Schema.Literals<readonly ["Update", "View", "Patch", "SubscriptionDependencies"]>;
111
+ export type SlowPhase = typeof SlowPhase.Type;
112
+ /** Budget overrides for slow warning phases. Omitted fields use Foldkit defaults. */
113
+ export type SlowThresholdOverrides = Readonly<{
114
+ Update?: number;
115
+ View?: number;
116
+ Patch?: number;
117
+ SubscriptionDependencies?: number;
118
+ }>;
119
+ type ResolvedSlowPhaseConfig<Context> = Readonly<{
120
+ thresholdMs: number;
121
+ onSlow: (context: Context) => void;
122
+ }>;
123
+ type ResolvedSlowConfig<Model, Message> = Readonly<{
124
+ view: Option.Option<ResolvedSlowPhaseConfig<SlowViewContext<Model, Message>>>;
125
+ update: Option.Option<ResolvedSlowPhaseConfig<SlowUpdateContext<Model, Message>>>;
126
+ patch: Option.Option<ResolvedSlowPhaseConfig<SlowPatchContext<Model, Message>>>;
127
+ subscriptionDependencies: Option.Option<ResolvedSlowPhaseConfig<SlowSubscriptionDependenciesContext<Model>>>;
128
+ }>;
81
129
  /**
82
- * Slow view warning configuration.
130
+ * Slow-phase warning configuration.
83
131
  *
84
- * Pass `false` to disable warnings entirely.
132
+ * By default, all phases are enabled in development with Foldkit's default
133
+ * thresholds. Pass `false` to disable warnings entirely. Pass an object to
134
+ * refine those defaults.
85
135
  *
86
- * - `show`: `'Development'` (default) enables in dev mode only, `'Always'` enables in all environments.
87
- * - `thresholdMs`: Duration in ms above which a view is considered slow. Defaults to 16 (one frame at 60fps).
88
- * - `onSlowView`: Custom callback invoked when a slow view is detected. Defaults to `console.warn`.
136
+ * - `show`: `'Development'` (default) enables warnings only when Vite HMR is active. `'Always'` enables them in every environment.
137
+ * - `measuredPhases`: Phases to measure. Defaults to every slow warning phase.
138
+ * - `thresholdOverrides`: Per-phase budget overrides. Omitted fields keep defaults; overrides for unmeasured phases are ignored.
139
+ * - `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.
89
140
  */
90
- export type SlowViewConfig<Model, Message> = false | Readonly<{
141
+ export type SlowConfig<Model, Message> = false | Readonly<{
91
142
  show?: Visibility;
92
- thresholdMs?: number;
93
- onSlowView?: (context: SlowViewContext<Model, Message>) => void;
143
+ measuredPhases?: ReadonlyArray<SlowPhase>;
144
+ thresholdOverrides?: SlowThresholdOverrides;
145
+ onSlow?: (context: SlowContext<Model, Message>) => void;
94
146
  }>;
147
+ export declare const __resolveSlowConfig: <Model, Message>(slow: SlowConfig<Model, Message> | undefined, isSlowVisible: (show: Visibility) => boolean) => Option.Option<ResolvedSlowConfig<Model, Message>>;
148
+ export declare const defaultSlowCallback: (context: SlowContext<unknown, unknown>) => void;
95
149
  declare const Dispatch_base: Context.ServiceClass<Dispatch, "@foldkit/Dispatch", {
96
150
  readonly dispatchAsync: (message: unknown) => Effect.Effect<void>;
97
151
  readonly dispatchSync: (message: unknown) => void;
@@ -130,7 +184,7 @@ type BaseApplicationConfig<Model, Message, Resources = never, ManagedResourceSer
130
184
  container: HTMLElement | null;
131
185
  ports?: P;
132
186
  crash?: CrashConfig<Model, Message>;
133
- slowView?: SlowViewConfig<Model, Message>;
187
+ slow?: SlowConfig<Model, Message>;
134
188
  freezeModel?: boolean;
135
189
  resources?: Layer.Layer<Resources>;
136
190
  managedResources?: ManagedResources<Model, Message, ManagedResourceServices>;
@@ -188,7 +242,7 @@ type BaseElementConfig<Model, Message, Resources = never, ManagedResourceService
188
242
  container: HTMLElement | null;
189
243
  ports?: P;
190
244
  crash?: ElementCrashConfig<Model, Message>;
191
- slowView?: SlowViewConfig<Model, Message>;
245
+ slow?: SlowConfig<Model, Message>;
192
246
  freezeModel?: boolean;
193
247
  resources?: Layer.Layer<Resources>;
194
248
  managedResources?: ManagedResources<Model, Message, ManagedResourceServices>;
@@ -282,7 +336,7 @@ export type EmbedHandle<P extends Ports | undefined = undefined> = Readonly<{
282
336
  ports: PortHandles<P>;
283
337
  dispose: () => void;
284
338
  }>;
285
- export declare const patchVNode: (maybeCurrentVNode: Option.Option<VNode>, nextVNode: VNode | null, container: HTMLElement) => VNode;
339
+ export declare const patchVNode: (maybeCurrentVNode: Option.Option<VNode>, nextVNode: VNode | null, container: HTMLElement, seen?: Set<object>) => VNode;
286
340
  /** Creates a Foldkit application that owns the page and returns a runtime that
287
341
  * can be passed to `run`. The `view` returns a `Document`, so the runtime
288
342
  * manages `document.title` and the canonical / og:url tags. Add a `routing`
@@ -1 +1 @@
1
- {"version":3,"file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WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAC/B,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAEvC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC,CAAC,GAC3E,iBAAiB,CAAC,CAAC,CAAC,CAAA;AA6MvB;;sDAEsD;AACtD,eAAO,MAAM,GAAG,GAAI,SAAS,iBAAiB,CAAC,KAAK,GAAG,SAAS,CAAC,KAAG,IAMnE,CAAA;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAC3D,SAAS,iBAAiB,CAAC,CAAC,CAAC,KAC5B,WAAW,CAAC,CAAC,CAqDf,CAAA"}
@@ -32,19 +32,87 @@ const resolveDevToolsMode = (config) => {
32
32
  const DEV_TOOLS_MAX_ENTRIES_MIN = 20;
33
33
  const DEV_TOOLS_MAX_ENTRIES_MAX = 500;
34
34
  const DEV_TOOLS_KEYFRAME_INTERVAL_MIN = 1;
35
- const DEFAULT_SLOW_VIEW_SHOW = 'Development';
35
+ /** Phase names measured by the slow warning runtime option. */
36
+ export const SlowPhase = Schema.Literals([
37
+ 'Update',
38
+ 'View',
39
+ 'Patch',
40
+ 'SubscriptionDependencies',
41
+ ]);
42
+ const DEFAULT_SLOW_SHOW = 'Development';
36
43
  const DEFAULT_SLOW_VIEW_THRESHOLD_MS = 16;
37
- const defaultSlowViewCallback = (context) => {
38
- const trigger = Option.match(context.message, {
39
- onNone: () => 'init',
40
- onSome: message => {
41
- const tag = Predicate.isObject(message) && '_tag' in message
42
- ? String(message['_tag'])
43
- : 'unknown';
44
- return tag;
45
- },
46
- });
47
- console.warn(`[foldkit] Slow view: ${context.durationMs.toFixed(1)}ms (budget: ${context.thresholdMs}ms), triggered by ${trigger}. Memoize expensive subtrees with createLazy. Cache derived data on the model in update only when memoization cannot cover it, since every update branch then has to keep it in sync.`, ...Option.toArray(context.message));
44
+ const DEFAULT_SLOW_UPDATE_THRESHOLD_MS = 4;
45
+ const DEFAULT_SLOW_PATCH_THRESHOLD_MS = 8;
46
+ const DEFAULT_SLOW_SUBSCRIPTION_DEPENDENCIES_THRESHOLD_MS = 2;
47
+ const ALL_SLOW_PHASES = [
48
+ 'Update',
49
+ 'View',
50
+ 'Patch',
51
+ 'SubscriptionDependencies',
52
+ ];
53
+ const resolveSlowPhase = (isMeasured, thresholdMs, onSlow) => Option.liftPredicate({
54
+ thresholdMs,
55
+ onSlow,
56
+ }, () => isMeasured);
57
+ export const __resolveSlowConfig = (slow, isSlowVisible) => {
58
+ const maybeSlowConfig = Match.value(slow).pipe(Match.withReturnType(), Match.when(false, () => Option.none()), Match.when(Predicate.isUndefined, () => Option.some({})), Match.orElse(config => Option.some(config)));
59
+ return pipe(maybeSlowConfig, Option.filter(config => isSlowVisible(config.show ?? DEFAULT_SLOW_SHOW)), Option.map(config => {
60
+ const onSlow = config.onSlow ?? defaultSlowCallback;
61
+ const measuredPhases = config.measuredPhases ?? ALL_SLOW_PHASES;
62
+ const isPhaseMeasured = (phase) => Array.contains(measuredPhases, phase);
63
+ return {
64
+ view: resolveSlowPhase(isPhaseMeasured('View'), config.thresholdOverrides?.View ?? DEFAULT_SLOW_VIEW_THRESHOLD_MS, onSlow),
65
+ update: resolveSlowPhase(isPhaseMeasured('Update'), config.thresholdOverrides?.Update ?? DEFAULT_SLOW_UPDATE_THRESHOLD_MS, onSlow),
66
+ patch: resolveSlowPhase(isPhaseMeasured('Patch'), config.thresholdOverrides?.Patch ?? DEFAULT_SLOW_PATCH_THRESHOLD_MS, onSlow),
67
+ subscriptionDependencies: resolveSlowPhase(isPhaseMeasured('SubscriptionDependencies'), config.thresholdOverrides?.SubscriptionDependencies ??
68
+ DEFAULT_SLOW_SUBSCRIPTION_DEPENDENCIES_THRESHOLD_MS, onSlow),
69
+ };
70
+ }));
71
+ };
72
+ const measureSlowPhase = (maybeConfig, run) => {
73
+ if (Option.isSome(maybeConfig)) {
74
+ const start = performance.now();
75
+ const result = run();
76
+ return [result, Option.some(performance.now() - start)];
77
+ }
78
+ else {
79
+ return [run(), Option.none()];
80
+ }
81
+ };
82
+ const reportSlowPhase = (maybeConfig, maybeDurationMs, makeContext) => {
83
+ if (Option.isSome(maybeConfig)) {
84
+ const { thresholdMs, onSlow } = maybeConfig.value;
85
+ const maybeExceededDuration = Option.filter(maybeDurationMs, durationMs => durationMs > thresholdMs);
86
+ if (Option.isSome(maybeExceededDuration)) {
87
+ onSlow(makeContext(maybeExceededDuration.value, thresholdMs));
88
+ }
89
+ }
90
+ };
91
+ const messageTag = (rawMessage) => pipe(rawMessage, Option.liftPredicate(Predicate.isObject), Option.flatMap(Record.get('_tag')), Option.match({
92
+ onNone: () => 'unknown',
93
+ onSome: String,
94
+ }));
95
+ const optionMessageTrigger = (maybeMessage) => Option.match(maybeMessage, {
96
+ onNone: () => 'init',
97
+ onSome: messageTag,
98
+ });
99
+ const TUNING_HINT = 'Set slow.thresholdOverrides to change budgets or pass slow: false to disable warnings.';
100
+ export const defaultSlowCallback = (context) => {
101
+ const { durationMs, thresholdMs: budget } = context;
102
+ const duration = durationMs.toFixed(1);
103
+ const summary = Match.value(context).pipe(Match.tagsExhaustive({
104
+ View: ({ message }) => `Slow view: ${duration}ms (budget: ${budget}ms), triggered by ${optionMessageTrigger(message)}. Keep render-only work in the view path and memoize expensive subtrees with createLazy or createKeyedLazy.`,
105
+ Update: ({ message }) => `Slow update: ${duration}ms (budget: ${budget}ms), triggered by ${messageTag(message)}. Inspect the triggering Message branch; move render-only derivations to memoized views and keep update focused on state transitions.`,
106
+ Patch: ({ message }) => `Slow patch: ${duration}ms (budget: ${budget}ms), triggered by ${optionMessageTrigger(message)}. Key mapped lists by stable ids, split large views, or memoize stable subtrees with createLazy.`,
107
+ SubscriptionDependencies: ({ subscriptionKey }) => `Slow subscription dependencies: ${duration}ms (budget: ${budget}ms) for subscription "${subscriptionKey}". Keep modelToDependencies a cheap projection from modeled fields; avoid scans, sorting, serialization, and large dependency objects.`,
108
+ }));
109
+ const maybeRawMessage = Match.value(context).pipe(Match.withReturnType(), Match.tagsExhaustive({
110
+ Update: ({ message }) => Option.some(message),
111
+ View: ({ message }) => message,
112
+ Patch: ({ message }) => message,
113
+ SubscriptionDependencies: () => Option.none(),
114
+ }));
115
+ console.warn(`[foldkit] ${summary} ${TUNING_HINT}`, context, ...Option.toArray(maybeRawMessage));
48
116
  };
49
117
  /** Effect service tag that provides message dispatching to the view layer. */
50
118
  export class Dispatch extends Context.Service()('@foldkit/Dispatch') {
@@ -172,11 +240,13 @@ const validatePorts = (ports) => {
172
240
  });
173
241
  };
174
242
  const runtimeInternals = new WeakMap();
175
- const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, manageDocument, subscriptions, container, routing: routingConfig, crash, slowView, freezeModel, resources, managedResources, devTools, }) => {
176
- const resolvedSlowView = pipe(slowView ?? {}, Option.liftPredicate(config => config !== false), Option.filter(config => Match.value(config.show ?? DEFAULT_SLOW_VIEW_SHOW).pipe(Match.when('Always', () => true), Match.when('Development', () => !!import.meta.hot), Match.exhaustive)), Option.map(config => ({
177
- thresholdMs: config.thresholdMs ?? DEFAULT_SLOW_VIEW_THRESHOLD_MS,
178
- onSlowView: config.onSlowView ?? defaultSlowViewCallback,
179
- })));
243
+ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, manageDocument, subscriptions, container, routing: routingConfig, crash, slow, freezeModel, resources, managedResources, devTools, }) => {
244
+ const isSlowVisible = (show) => Match.value(show).pipe(Match.when('Always', () => true), Match.when('Development', () => !!import.meta.hot), Match.exhaustive);
245
+ const resolvedSlow = __resolveSlowConfig(slow, isSlowVisible);
246
+ const resolvedSlowView = Option.flatMap(resolvedSlow, ({ view }) => view);
247
+ const resolvedSlowUpdate = Option.flatMap(resolvedSlow, ({ update }) => update);
248
+ const resolvedSlowPatch = Option.flatMap(resolvedSlow, ({ patch }) => patch);
249
+ const resolvedSlowSubscriptionDependencies = Option.flatMap(resolvedSlow, ({ subscriptionDependencies }) => subscriptionDependencies);
180
250
  const isFreezeModelActive = freezeModel !== false && !!import.meta.hot;
181
251
  const excludeFromHistoryTags = pipe(devTools ?? {}, Option.liftPredicate(config => config !== false), Option.flatMapNullishOr(config => config.excludeFromHistory), Option.match({
182
252
  onNone: () => new Set(),
@@ -466,8 +536,16 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
466
536
  };
467
537
  const processMessage = (message) => Effect.gen(function* () {
468
538
  const currentModel = yield* Ref.get(modelRef);
469
- const [nextModelRaw, commands] = update(currentModel, message);
539
+ const [[nextModelRaw, commands], maybeUpdateDuration] = measureSlowPhase(resolvedSlowUpdate, () => update(currentModel, message));
470
540
  const nextModel = maybeFreezeModel(nextModelRaw);
541
+ reportSlowPhase(resolvedSlowUpdate, maybeUpdateDuration, (durationMs, thresholdMs) => ({
542
+ _tag: 'Update',
543
+ previousModel: currentModel,
544
+ nextModel,
545
+ message,
546
+ durationMs,
547
+ thresholdMs,
548
+ }));
471
549
  if (currentModel !== nextModel) {
472
550
  yield* Ref.set(modelRef, nextModel);
473
551
  yield* SubscriptionRef.set(isRenderPendingRef, true);
@@ -483,9 +561,9 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
483
561
  }), provideAllResources, Effect.flatMap(enqueueNormal), Effect.catchCause(cause => crashWith(cause, Option.some(message))))));
484
562
  }
485
563
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
486
- const messageTag = message._tag;
564
+ const tag = message._tag;
487
565
  const isModelChanged = currentModel !== nextModel;
488
- const isExcludedFromHistory = excludeFromHistoryTags.has(messageTag);
566
+ const isExcludedFromHistory = excludeFromHistoryTags.has(tag);
489
567
  if (Option.isSome(maybeDevToolsStore)) {
490
568
  const store = maybeDevToolsStore.value;
491
569
  if (!isExcludedFromHistory) {
@@ -508,36 +586,39 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
508
586
  // reach a no-op dispatchSync and never enter the runtime queue.
509
587
  // This prevents mount-derived Messages from polluting history when
510
588
  // the user is just inspecting past state.
511
- const render = (model, message, dispatchService = dispatch) => Effect.gen(function* () {
589
+ const render = (model, message, dispatchService = dispatch, renderMode = 'Live') => Effect.gen(function* () {
512
590
  const runtimeContext = yield* Effect.context();
513
- const viewStart = performance.now();
514
- beginHtmlRender(boundaryRegistry);
515
- setHtmlRuntime(dispatchService.dispatchSync, runtimeContext, boundaryRegistry);
516
- let nextDocument;
517
- try {
518
- nextDocument = view(model);
519
- }
520
- finally {
521
- clearHtmlRuntime();
522
- }
523
- const nextVNode = nextDocument.body;
524
- const viewDuration = performance.now() - viewStart;
525
- Option.match(resolvedSlowView, {
526
- onNone: Function.constVoid,
527
- onSome: ({ thresholdMs, onSlowView }) => {
528
- if (viewDuration > thresholdMs) {
529
- onSlowView({
530
- model,
531
- message,
532
- durationMs: viewDuration,
533
- thresholdMs,
534
- });
535
- }
536
- },
591
+ const maybeLiveRender = Option.liftPredicate(renderMode, mode => mode === 'Live');
592
+ const maybeLiveSlowView = Option.flatMap(maybeLiveRender, () => resolvedSlowView);
593
+ const maybeLiveSlowPatch = Option.flatMap(maybeLiveRender, () => resolvedSlowPatch);
594
+ const [nextDocument, maybeViewDuration] = measureSlowPhase(maybeLiveSlowView, () => {
595
+ beginHtmlRender(boundaryRegistry);
596
+ setHtmlRuntime(dispatchService.dispatchSync, runtimeContext, boundaryRegistry);
597
+ try {
598
+ return view(model);
599
+ }
600
+ finally {
601
+ clearHtmlRuntime();
602
+ }
537
603
  });
604
+ const nextVNode = nextDocument.body;
605
+ reportSlowPhase(maybeLiveSlowView, maybeViewDuration, (durationMs, thresholdMs) => ({
606
+ _tag: 'View',
607
+ model,
608
+ message,
609
+ durationMs,
610
+ thresholdMs,
611
+ }));
538
612
  const maybeCurrentVNode = yield* Ref.get(maybeCurrentVNodeRef);
539
- const patchedVNode = yield* Effect.sync(() => patchVNode(maybeCurrentVNode, nextVNode, container));
613
+ const [patchedVNode, maybePatchDuration] = yield* Effect.sync(() => measureSlowPhase(maybeLiveSlowPatch, () => patchVNode(maybeCurrentVNode, nextVNode, container, boundaryRegistry.dedupeSeen)));
540
614
  yield* Ref.set(maybeCurrentVNodeRef, Option.some(patchedVNode));
615
+ reportSlowPhase(maybeLiveSlowPatch, maybePatchDuration, (durationMs, thresholdMs) => ({
616
+ _tag: 'Patch',
617
+ model,
618
+ message,
619
+ durationMs,
620
+ thresholdMs,
621
+ }));
541
622
  if (manageDocument) {
542
623
  yield* Effect.sync(() => applyDocumentMetadata(nextDocument, patchedVNode.elm));
543
624
  }
@@ -578,8 +659,9 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
578
659
  // attributed to the next user-initiated dispatch.
579
660
  render: model => Effect.gen(function* () {
580
661
  yield* SubscriptionRef.set(isRenderPendingRef, false);
662
+ yield* render(
581
663
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
582
- yield* render(model, Option.none(), noOpDispatch);
664
+ model, Option.none(), noOpDispatch, 'Replay');
583
665
  drainMountEvents();
584
666
  }),
585
667
  // NOTE: `resume` calls this to wake the renderLoop after a
@@ -643,7 +725,7 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
643
725
  onSome: store => store.recordInit(initModel, Array.map(initCommands, toCommandRecord), initMountEvents.starts),
644
726
  });
645
727
  // NOTE: maybeLastDirtyMessageRef holds the most recent dirtying
646
- // Message, so slow-view callbacks during high-rate bursts attribute
728
+ // Message, so slow render-phase callbacks during high-rate bursts attribute
647
729
  // to the last Message in the frame batch, not the specific one that
648
730
  // pushed the view past threshold. Acceptable for a debug callback;
649
731
  // full attribution would require correlating each message with its
@@ -696,12 +778,19 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
696
778
  yield* Effect.sync(() => addBfcacheRestoreListener());
697
779
  }
698
780
  if (subscriptions) {
699
- yield* pipe(subscriptions, Record.toEntries, Effect.forEach(([_key, { dependenciesSchema, modelToDependencies, keepAliveEquivalence, dependenciesToStream, },]) => Effect.gen(function* () {
700
- const latestDependenciesRef = yield* Ref.make(modelToDependencies(initModel));
781
+ yield* pipe(subscriptions, Record.toEntries, Effect.forEach(([key, { dependenciesSchema, modelToDependencies, keepAliveEquivalence, dependenciesToStream, },]) => Effect.gen(function* () {
701
782
  const equivalence = keepAliveEquivalence ??
702
783
  Schema.toEquivalence(dependenciesSchema);
703
- const modelStream = Stream.concat(Stream.make(initModel), Stream.fromPubSub(modelPubSub));
704
- yield* Effect.forkIn(runtimeScope)(modelStream.pipe(
784
+ const [initDependencies, maybeInitDependenciesDuration] = measureSlowPhase(resolvedSlowSubscriptionDependencies, () => modelToDependencies(initModel));
785
+ reportSlowPhase(resolvedSlowSubscriptionDependencies, maybeInitDependenciesDuration, (durationMs, thresholdMs) => ({
786
+ _tag: 'SubscriptionDependencies',
787
+ subscriptionKey: key,
788
+ model: initModel,
789
+ durationMs,
790
+ thresholdMs,
791
+ }));
792
+ const latestDependenciesRef = yield* Ref.make(initDependencies);
793
+ const modelChangesStream = Stream.fromPubSub(modelPubSub).pipe(
705
794
  // NOTE: Ref.set runs upstream of Stream.changesWith on
706
795
  // every model change, so readDependencies() returns
707
796
  // current values even when the equivalence filter
@@ -710,10 +799,18 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
710
799
  // dependencies are equivalence-stable across model
711
800
  // changes.
712
801
  Stream.mapEffect(model => Effect.gen(function* () {
713
- const dependencies = modelToDependencies(model);
802
+ const [dependencies, maybeDependenciesDuration] = measureSlowPhase(resolvedSlowSubscriptionDependencies, () => modelToDependencies(model));
803
+ reportSlowPhase(resolvedSlowSubscriptionDependencies, maybeDependenciesDuration, (durationMs, thresholdMs) => ({
804
+ _tag: 'SubscriptionDependencies',
805
+ subscriptionKey: key,
806
+ model,
807
+ durationMs,
808
+ thresholdMs,
809
+ }));
714
810
  yield* Ref.set(latestDependenciesRef, dependencies);
715
811
  return dependencies;
716
- })), Stream.changesWith(equivalence), Stream.switchMap(dependencies => dependenciesToStream(dependencies, () => Ref.getUnsafe(latestDependenciesRef))), Stream.runForEach(message =>
812
+ })));
813
+ yield* Effect.forkIn(runtimeScope)(Stream.concat(Stream.make(initDependencies), modelChangesStream).pipe(Stream.changesWith(equivalence), Stream.switchMap(dependencies => dependenciesToStream(dependencies, () => Ref.getUnsafe(latestDependenciesRef))), Stream.runForEach(message =>
717
814
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
718
815
  enqueueHigh(message)), provideAllResources, Effect.catchCause(cause => crashWith(cause, Option.none()))));
719
816
  }), {
@@ -823,9 +920,9 @@ const makeRuntime = ({ ports, Model, flags: resolveFlags, init, update, view, ma
823
920
  };
824
921
  // NOTE: exported for `patchVNode.test.ts` to assert the dedupeSharedVNodes
825
922
  // wiring; not part of the public surface (`runtime/public.ts` is curated).
826
- export const patchVNode = (maybeCurrentVNode, nextVNode, container) => {
923
+ export const patchVNode = (maybeCurrentVNode, nextVNode, container, seen) => {
827
924
  const dedupedVNode = Predicate.isNotNull(nextVNode)
828
- ? dedupeSharedVNodes(nextVNode)
925
+ ? dedupeSharedVNodes(nextVNode, seen)
829
926
  : h('!');
830
927
  return Option.match(maybeCurrentVNode, {
831
928
  onNone: () => patch(toVNode(container), dedupedVNode),
@@ -934,8 +1031,8 @@ export function makeApplication(config) {
934
1031
  container,
935
1032
  ...(hasRouting && { routing: config.routing }),
936
1033
  ...(config.crash && { crash: config.crash }),
937
- ...(Predicate.isNotUndefined(config.slowView) && {
938
- slowView: config.slowView,
1034
+ ...(Predicate.isNotUndefined(config.slow) && {
1035
+ slow: config.slow,
939
1036
  }),
940
1037
  ...(Predicate.isNotUndefined(config.freezeModel) && {
941
1038
  freezeModel: config.freezeModel,
@@ -1023,8 +1120,8 @@ export function makeElement(config) {
1023
1120
  ...(config.subscriptions && { subscriptions: config.subscriptions }),
1024
1121
  container,
1025
1122
  ...(Predicate.isNotUndefined(nullableCrash) && { crash: nullableCrash }),
1026
- ...(Predicate.isNotUndefined(config.slowView) && {
1027
- slowView: config.slowView,
1123
+ ...(Predicate.isNotUndefined(config.slow) && {
1124
+ slow: config.slow,
1028
1125
  }),
1029
1126
  ...(Predicate.isNotUndefined(config.freezeModel) && {
1030
1127
  freezeModel: config.freezeModel,
package/dist/vdom.d.ts CHANGED
@@ -2,5 +2,18 @@ import { type VNode, toVNode } from 'snabbdom';
2
2
  export type { VNode } from 'snabbdom';
3
3
  export { toVNode };
4
4
  export declare const patch: (oldVnode: VNode | Element | DocumentFragment, vnode: VNode) => VNode;
5
- export declare const dedupeSharedVNodes: (root: VNode) => VNode;
5
+ export declare const memoizedVNodes: WeakSet<VNode>;
6
+ /** Clones any reused vnode in the tree so snabbdom never sees one object at two
7
+ * positions. Memoized subtrees (createLazy/createKeyedLazy results) are left
8
+ * opaque so their same-vnode short-circuit survives. Pass a shared `seen` set
9
+ * to coordinate with `dedupeMemoizedResult` across a render; omit it for
10
+ * one-off use. */
11
+ export declare const dedupeSharedVNodes: (root: VNode, seen?: Set<object>) => VNode;
12
+ /** Dedupes the freshly built subtree of a memoized view (a
13
+ * createLazy/createKeyedLazy result) so a const shared inside it, or across
14
+ * memoized siblings sharing `seen`, is cloned even though the top-level pass
15
+ * leaves memoized subtrees opaque. The result root itself is left untracked, so
16
+ * the top-level pass still exempts it by membership rather than treating it as
17
+ * a duplicate. */
18
+ export declare const dedupeMemoizedResult: (root: VNode, seen?: Set<object>) => VNode;
6
19
  //# sourceMappingURL=vdom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vdom.d.ts","sourceRoot":"","sources":["../src/vdom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EAOV,OAAO,EACR,MAAM,UAAU,CAAA;AAIjB,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB,eAAO,MAAM,KAAK,uEAOhB,CAAA;AAeF,eAAO,MAAM,kBAAkB,GAAI,MAAM,KAAK,KAAG,KA8BhD,CAAA"}
1
+ {"version":3,"file":"vdom.d.ts","sourceRoot":"","sources":["../src/vdom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EAOV,OAAO,EACR,MAAM,UAAU,CAAA;AAIjB,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB,eAAO,MAAM,KAAK,uEAOhB,CAAA;AAsBF,eAAO,MAAM,cAAc,gBAAuB,CAAA;AA2ClD;;;;mBAImB;AACnB,eAAO,MAAM,kBAAkB,GAC7B,MAAM,KAAK,EACX,OAAM,GAAG,CAAC,MAAM,CAAa,KAC5B,KAA0B,CAAA;AAE7B;;;;;mBAKmB;AACnB,eAAO,MAAM,oBAAoB,GAC/B,MAAM,KAAK,EACX,OAAM,GAAG,CAAC,MAAM,CAAa,KAC5B,KAMF,CAAA"}
package/dist/vdom.js CHANGED
@@ -10,46 +10,77 @@ export const patch = init([
10
10
  styleModule,
11
11
  ]);
12
12
  // NOTE: snabbdom records each element's live DOM node on `vnode.elm` by
13
- // mutating the vnode object during patch. A vnode object placed in more than
14
- // one tree position would share a single `.elm`, so removals and text updates
15
- // land on the wrong DOM node. View code legitimately reuses vnode values, e.g.
16
- // `const checkmark = h.span(...)` dropped into several slots, so before each
17
- // patch we clone any vnode object reached a second time, giving every position
18
- // its own object.
19
- // Detection is keyed off a per-patch Set, so a vnode reused across renders (a
20
- // memoized `createLazy` subtree, the identical object each render) is reached
21
- // only once per patch and passes through untouched, leaving snabbdom's
22
- // same-object subtree short-circuit intact. Allocation happens only along
23
- // paths where a duplicate is actually found; a tree with no reuse returns
24
- // unchanged.
25
- export const dedupeSharedVNodes = (root) => {
26
- const seen = new Set();
27
- const visit = (node) => {
28
- const base = seen.has(node) ? { ...node, elm: undefined } : node;
29
- seen.add(base);
30
- const children = base.children;
31
- if (children === undefined) {
32
- return base;
33
- }
34
- let nextChildren;
35
- for (let index = 0; index < children.length; index++) {
36
- const child = children[index];
37
- const deduped = typeof child === 'string' ? child : visit(child);
38
- if (deduped !== child) {
39
- if (nextChildren === undefined) {
40
- nextChildren = children.slice();
41
- }
42
- nextChildren[index] = deduped;
13
+ // mutating the vnode object during patch, and assumes one vnode object per tree
14
+ // position. A vnode object placed in more than one position would share a single
15
+ // `.elm`, so removals and text updates land on the wrong DOM node.
16
+ // `dedupeSharedVNodes` clones any vnode reached a second time within a render,
17
+ // or arriving with an `.elm` already set from a prior render, so every position
18
+ // gets its own object. Allocation happens only where reuse is actually found; a
19
+ // tree of freshly constructed vnodes returns unchanged.
20
+ //
21
+ // `createLazy`/`createKeyedLazy` results are recorded in `memoizedVNodes` and
22
+ // kept opaque here, so snabbdom's same-vnode short-circuit on a cache hit
23
+ // survives and the cached subtree is not walked. Their own contents are deduped
24
+ // separately by `dedupeMemoizedResult`, which the lazy helpers run on the freshly
25
+ // built subtree on a cache miss. Both passes share one per-render `seen` set
26
+ // (carried on the boundary registry and cleared each render), so a const reused
27
+ // INSIDE a memoized view, or across memoized siblings, is cloned just like a
28
+ // const reused anywhere else. A cache hit rebuilds nothing and is left
29
+ // untouched: a const inside the cached subtree still carries the `.elm` snabbdom
30
+ // set last render, so reuse of it elsewhere this render is cloned by the
31
+ // prior-render `.elm` rule above rather than the per-render set.
32
+ export const memoizedVNodes = new WeakSet();
33
+ const dedupeChildList = (children, seen) => {
34
+ let nextChildren;
35
+ for (let index = 0; index < children.length; index++) {
36
+ const child = children[index];
37
+ const deduped = typeof child === 'string' ? child : visit(child, seen);
38
+ if (deduped !== child) {
39
+ if (nextChildren === undefined) {
40
+ nextChildren = children.slice();
43
41
  }
42
+ nextChildren[index] = deduped;
44
43
  }
45
- if (nextChildren === undefined) {
46
- return base;
47
- }
48
- if (base === node) {
49
- return { ...node, children: nextChildren };
50
- }
51
- base.children = nextChildren;
44
+ }
45
+ return nextChildren;
46
+ };
47
+ const visit = (node, seen) => {
48
+ const isDuplicate = seen.has(node);
49
+ if (!isDuplicate && memoizedVNodes.has(node)) {
50
+ seen.add(node);
51
+ return node;
52
+ }
53
+ const base = isDuplicate || node.elm != null ? { ...node, elm: undefined } : node;
54
+ seen.add(node);
55
+ if (base.children === undefined) {
56
+ return base;
57
+ }
58
+ const nextChildren = dedupeChildList(base.children, seen);
59
+ if (nextChildren === undefined) {
52
60
  return base;
53
- };
54
- return visit(root);
61
+ }
62
+ if (base === node) {
63
+ return { ...node, children: nextChildren };
64
+ }
65
+ base.children = nextChildren;
66
+ return base;
67
+ };
68
+ /** Clones any reused vnode in the tree so snabbdom never sees one object at two
69
+ * positions. Memoized subtrees (createLazy/createKeyedLazy results) are left
70
+ * opaque so their same-vnode short-circuit survives. Pass a shared `seen` set
71
+ * to coordinate with `dedupeMemoizedResult` across a render; omit it for
72
+ * one-off use. */
73
+ export const dedupeSharedVNodes = (root, seen = new Set()) => visit(root, seen);
74
+ /** Dedupes the freshly built subtree of a memoized view (a
75
+ * createLazy/createKeyedLazy result) so a const shared inside it, or across
76
+ * memoized siblings sharing `seen`, is cloned even though the top-level pass
77
+ * leaves memoized subtrees opaque. The result root itself is left untracked, so
78
+ * the top-level pass still exempts it by membership rather than treating it as
79
+ * a duplicate. */
80
+ export const dedupeMemoizedResult = (root, seen = new Set()) => {
81
+ if (root.children === undefined) {
82
+ return root;
83
+ }
84
+ const nextChildren = dedupeChildList(root.children, seen);
85
+ return nextChildren === undefined ? root : { ...root, children: nextChildren };
55
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit",
3
- "version": "0.114.0",
3
+ "version": "0.115.0",
4
4
  "description": "A TypeScript frontend framework, built on Effect and architected like Elm",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -157,7 +157,6 @@
157
157
  "directory": "packages/foldkit"
158
158
  },
159
159
  "dependencies": {
160
- "clsx": "^2.1.1",
161
160
  "snabbdom": "^3.6.3"
162
161
  },
163
162
  "publishConfig": {
@@ -170,7 +169,6 @@
170
169
  "clean": "rimraf dist *.tsbuildinfo",
171
170
  "build": "pnpm run clean && tsc -b tsconfig.build.json",
172
171
  "watch": "tsc -b tsconfig.build.json --watch",
173
- "lint": "eslint src",
174
172
  "typecheck": "tsc -b tsconfig.build.json --noEmit",
175
173
  "test": "vitest run",
176
174
  "docs": "typedoc"