foldkit 0.91.0 → 0.92.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/dist/devTools/overlay.d.ts +1 -0
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/store.d.ts +12 -1
- package/dist/devTools/store.d.ts.map +1 -1
- package/dist/devTools/store.js +23 -7
- package/dist/runtime/runtime.d.ts +4 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +41 -6
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ declare const StoreService_base: Context.ServiceClass<StoreService, "foldkit/Dev
|
|
|
7
7
|
recordMessage: (message: Readonly<{
|
|
8
8
|
_tag: string;
|
|
9
9
|
}>, modelBeforeUpdate: unknown, modelAfterUpdate: unknown, commands: ReadonlyArray<CommandRecord>, isModelChanged: boolean) => Effect.Effect<void>;
|
|
10
|
+
updateLatestModel: (model: unknown) => Effect.Effect<void>;
|
|
10
11
|
attachRenderedMounts: (mountStarts: ReadonlyArray<MountRecord>, mountEnds: ReadonlyArray<MountRecord>) => Effect.Effect<void>;
|
|
11
12
|
getModelAtIndex: (index: number) => Effect.Effect<unknown>;
|
|
12
13
|
getMessageAtIndex: (index: number) => Effect.Effect<Option.Option<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devTools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,MAAM,EAGN,OAAO,EAGP,MAAM,EAKN,MAAM,IAAI,CAAC,EAGX,eAAe,EAEhB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAa9C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAO3E,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAA;;
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devTools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,MAAM,EAGN,OAAO,EAGP,MAAM,EAKN,MAAM,IAAI,CAAC,EAGX,eAAe,EAEhB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAa9C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAO3E,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAA;;oFA8aQ,CAAC;;;;;;;;;;;;;;AAnL5B,cAAM,YAAa,SAAQ,iBAE1B;CAAG;;AAEJ,cAAM,iBAAkB,SAAQ,sBAGC;CAAG;AAEpC,eAAO,MAAM,UAAU;;iBAGsB,CAAA;AAE7C,eAAO,MAAM,YAAY;;iBAGwB,CAAA;AAWjD,eAAO,MAAM,MAAM;;;;wBAUlB,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;;;wBAIqB,CAAA;AAE9C,eAAO,MAAM,aAAa;;;;;;wBAYzB,CAAA;AAED,eAAO,MAAM,MAAM;;wBASlB,CAAA;AAED,eAAO,MAAM,KAAK;;wBASjB,CAAA;AAED,eAAO,MAAM,WAAW;;6BAYvB,CAAA;AA2/CD,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCAoDhC,CAAA"}
|
package/dist/devTools/store.d.ts
CHANGED
|
@@ -40,12 +40,23 @@ export type Bridge = Readonly<{
|
|
|
40
40
|
render: (model: unknown) => Effect.Effect<void>;
|
|
41
41
|
markRenderPending: Effect.Effect<void>;
|
|
42
42
|
}>;
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Options for `createDevToolsStore`.
|
|
45
|
+
*
|
|
46
|
+
* - `maxEntries`: Maximum number of history entries to retain before evicting the oldest segment. Defaults to 100.
|
|
47
|
+
* - `keyframeInterval`: Number of recorded entries between full model snapshots. Smaller values use more memory but make time-travel a constant-time lookup instead of a replay. Set to `1` to snapshot every entry, which keeps time-travel correct under exclusion-from-history (since excluded Messages are never replayed). Defaults to 31.
|
|
48
|
+
*/
|
|
49
|
+
export type CreateDevToolsStoreOptions = Readonly<{
|
|
50
|
+
maxEntries?: number;
|
|
51
|
+
keyframeInterval?: number;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const createDevToolsStore: (bridge: Bridge, options?: CreateDevToolsStoreOptions) => Effect.Effect<DevToolsStore>;
|
|
44
54
|
export type DevToolsStore = Readonly<{
|
|
45
55
|
recordInit: (model: unknown, commands: ReadonlyArray<CommandRecord>, mountStarts?: ReadonlyArray<MountRecord>) => Effect.Effect<void>;
|
|
46
56
|
recordMessage: (message: Readonly<{
|
|
47
57
|
_tag: string;
|
|
48
58
|
}>, modelBeforeUpdate: unknown, modelAfterUpdate: unknown, commands: ReadonlyArray<CommandRecord>, isModelChanged: boolean) => Effect.Effect<void>;
|
|
59
|
+
updateLatestModel: (model: unknown) => Effect.Effect<void>;
|
|
49
60
|
attachRenderedMounts: (mountStarts: ReadonlyArray<MountRecord>, mountEnds: ReadonlyArray<MountRecord>) => Effect.Effect<void>;
|
|
50
61
|
getModelAtIndex: (index: number) => Effect.Effect<unknown>;
|
|
51
62
|
getMessageAtIndex: (index: number) => Effect.Effect<Option.Option<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/devTools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,OAAO,EACP,OAAO,EAEP,MAAM,EAIN,eAAe,EAEhB,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"store.d.ts","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CACb,OAAO,EAAE,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EACnC,iBAAiB,EAAE,OAAO,EAC1B,gBAAgB,EAAE,OAAO,EACzB,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,EACtC,cAAc,EAAE,OAAO,KACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxB,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,CACpB,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,EACvC,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,KAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC1D,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3E,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAC5D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1B,QAAQ,EAAE,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;CACtD,CAAC,CAAA"}
|
package/dist/devTools/store.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Array, Effect, HashMap, HashSet, Match, Option, Predicate, Record, String as String_, SubscriptionRef, pipe, } from 'effect';
|
|
2
|
+
import { evo } from '../struct/index.js';
|
|
2
3
|
export const INIT_INDEX = -1;
|
|
3
|
-
const
|
|
4
|
-
const DEFAULT_MAX_ENTRIES =
|
|
4
|
+
const DEFAULT_KEYFRAME_INTERVAL = 31;
|
|
5
|
+
const DEFAULT_MAX_ENTRIES = 100;
|
|
5
6
|
export const emptyDiff = {
|
|
6
7
|
changedPaths: HashSet.empty(),
|
|
7
8
|
affectedPaths: HashSet.empty(),
|
|
@@ -74,25 +75,38 @@ const emptyState = {
|
|
|
74
75
|
pausedAtIndex: 0,
|
|
75
76
|
maybeLatestModel: Option.none(),
|
|
76
77
|
};
|
|
77
|
-
export const createDevToolsStore = (bridge,
|
|
78
|
+
export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function* () {
|
|
79
|
+
const maxEntries = options.maxEntries ?? DEFAULT_MAX_ENTRIES;
|
|
80
|
+
const keyframeInterval = options.keyframeInterval ?? DEFAULT_KEYFRAME_INTERVAL;
|
|
78
81
|
const stateRef = yield* SubscriptionRef.make(emptyState);
|
|
79
82
|
const replayToIndex = (state, index) => {
|
|
80
|
-
|
|
83
|
+
// NOTE: the keyframe stored at `index + 1` represents the model
|
|
84
|
+
// state immediately after entry `index` was processed, per the
|
|
85
|
+
// convention `recordMessage` uses. Looking it up first short-circuits
|
|
86
|
+
// replay entirely; this hits on every index when keyframeInterval is
|
|
87
|
+
// 1 and at segment boundaries otherwise. Don't "simplify" to
|
|
88
|
+
// `keyframes[index]` — that's the model BEFORE entry `index`, which
|
|
89
|
+
// would require replaying the entry to land at the right state.
|
|
90
|
+
const directSnapshot = HashMap.get(state.keyframes, index + 1);
|
|
91
|
+
if (Option.isSome(directSnapshot)) {
|
|
92
|
+
return directSnapshot.value;
|
|
93
|
+
}
|
|
94
|
+
const segmentStart = Math.floor(index / keyframeInterval) * keyframeInterval;
|
|
81
95
|
const keyframeIndex = HashMap.has(state.keyframes, segmentStart)
|
|
82
96
|
? segmentStart
|
|
83
97
|
: state.startIndex;
|
|
84
98
|
return pipe(state.keyframes, HashMap.get(keyframeIndex), Option.map(keyframeModel => pipe(state.entries, Array.drop(keyframeIndex - state.startIndex), Array.take(index - keyframeIndex + 1), Array.reduce(keyframeModel, (model, entry) => bridge.replay(model, entry.message)))), Option.getOrThrow);
|
|
85
99
|
};
|
|
86
|
-
const addKeyframeIfNeeded = (keyframes, nextAbsoluteIndex, modelAfterUpdate) => nextAbsoluteIndex %
|
|
100
|
+
const addKeyframeIfNeeded = (keyframes, nextAbsoluteIndex, modelAfterUpdate) => nextAbsoluteIndex % keyframeInterval === 0
|
|
87
101
|
? HashMap.set(keyframes, nextAbsoluteIndex, modelAfterUpdate)
|
|
88
102
|
: keyframes;
|
|
89
103
|
const evictOldestSegment = (state) => {
|
|
90
|
-
const nextStartIndex = state.startIndex +
|
|
104
|
+
const nextStartIndex = state.startIndex + keyframeInterval;
|
|
91
105
|
const isPausedAtRetainedIndex = state.pausedAtIndex >= nextStartIndex ||
|
|
92
106
|
state.pausedAtIndex === INIT_INDEX;
|
|
93
107
|
return {
|
|
94
108
|
...state,
|
|
95
|
-
entries: Array.drop(state.entries,
|
|
109
|
+
entries: Array.drop(state.entries, keyframeInterval),
|
|
96
110
|
keyframes: HashMap.remove(state.keyframes, state.startIndex),
|
|
97
111
|
startIndex: nextStartIndex,
|
|
98
112
|
isPaused: state.isPaused && isPausedAtRetainedIndex,
|
|
@@ -214,9 +228,11 @@ export const createDevToolsStore = (bridge, maxEntries = DEFAULT_MAX_ENTRIES) =>
|
|
|
214
228
|
onSome: ({ diff }) => diff,
|
|
215
229
|
}));
|
|
216
230
|
});
|
|
231
|
+
const updateLatestModel = (model) => SubscriptionRef.update(stateRef, evo({ maybeLatestModel: () => Option.some(model) }));
|
|
217
232
|
return {
|
|
218
233
|
recordInit,
|
|
219
234
|
recordMessage,
|
|
235
|
+
updateLatestModel,
|
|
220
236
|
attachRenderedMounts,
|
|
221
237
|
getModelAtIndex,
|
|
222
238
|
getMessageAtIndex,
|
|
@@ -24,12 +24,16 @@ export type DevToolsMode = 'Inspect' | 'TimeTravel';
|
|
|
24
24
|
* - `position`: Where the badge and panel appear. Defaults to `'BottomRight'`.
|
|
25
25
|
* - `mode`: `'TimeTravel'` (default) enables full time-travel debugging. `'Inspect'` allows browsing state snapshots without pausing the app.
|
|
26
26
|
* - `banner`: Optional text shown as a banner at the top of the panel.
|
|
27
|
+
* - `excludeFromHistory`: Message `_tag` values whose dispatches should not be recorded in DevTools history. The Messages still drive `update` and the runtime as usual; they just don't appear in the history panel and don't pay the per-Message diff cost. Use for high-frequency Messages (animation frames, pointer moves, scroll events) that would flood history without adding insight.
|
|
28
|
+
* - `maxEntries`: Maximum number of recorded Messages retained in history before the oldest is evicted. Defaults to 100. Clamped to the range 20-500: smaller values keep the panel snappy under high message rates, larger values give you more scroll-back. Each retained entry stores a full Model snapshot, so memory cost scales linearly with both `maxEntries` and your Model size.
|
|
27
29
|
*/
|
|
28
30
|
export type DevToolsConfig = false | Readonly<{
|
|
29
31
|
show?: Visibility;
|
|
30
32
|
position?: DevToolsPosition;
|
|
31
33
|
mode?: DevToolsMode;
|
|
32
34
|
banner?: string;
|
|
35
|
+
excludeFromHistory?: ReadonlyArray<string>;
|
|
36
|
+
maxEntries?: number;
|
|
33
37
|
/**
|
|
34
38
|
* The application's `Message` Schema. When provided and the running app
|
|
35
39
|
* is connected to the Foldkit DevTools MCP server, AI agents can dispatch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,OAAO,EAEP,MAAM,EAGN,KAAK,EAEL,MAAM,EAON,MAAM,EAIP,MAAM,QAAQ,CAAA;AAGf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AASlD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,GAAG,EAA+B,MAAM,iBAAiB,CAAA;AAalE,O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,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACzD,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAE/B,MAAM,EAAE,aAAa,CACnB,KAAK,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AA2NpB,kEAAkE;AAClE,eAAO,MAAM,GAAG,GAAI,SAAS,iBAAiB,KAAG,IA4ChD,CAAA"}
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -20,6 +20,8 @@ const toCommandRecord = (command) => command.args !== undefined
|
|
|
20
20
|
const DEFAULT_DEV_TOOLS_SHOW = 'Development';
|
|
21
21
|
const DEFAULT_DEV_TOOLS_POSITION = 'BottomRight';
|
|
22
22
|
const DEFAULT_DEV_TOOLS_MODE = 'TimeTravel';
|
|
23
|
+
const DEV_TOOLS_MAX_ENTRIES_MIN = 20;
|
|
24
|
+
const DEV_TOOLS_MAX_ENTRIES_MAX = 500;
|
|
23
25
|
const DEFAULT_SLOW_VIEW_SHOW = 'Development';
|
|
24
26
|
const DEFAULT_SLOW_VIEW_THRESHOLD_MS = 16;
|
|
25
27
|
const defaultSlowViewCallback = (context) => {
|
|
@@ -43,6 +45,11 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
43
45
|
onSlowView: config.onSlowView ?? defaultSlowViewCallback,
|
|
44
46
|
})));
|
|
45
47
|
const isFreezeModelActive = freezeModel !== false && !!import.meta.hot;
|
|
48
|
+
const excludeFromHistoryTags = pipe(devTools ?? {}, Option.liftPredicate(config => config !== false), Option.flatMapNullishOr(config => config.excludeFromHistory), Option.match({
|
|
49
|
+
onNone: () => new Set(),
|
|
50
|
+
onSome: tags => new Set(tags),
|
|
51
|
+
}));
|
|
52
|
+
const devToolsMaxEntries = pipe(devTools ?? {}, Option.liftPredicate(config => config !== false), Option.flatMapNullishOr(config => config.maxEntries), Option.map(value => Math.max(DEV_TOOLS_MAX_ENTRIES_MIN, Math.min(DEV_TOOLS_MAX_ENTRIES_MAX, value))), Option.getOrUndefined);
|
|
46
53
|
const maybeFreezeModel = (model) => isFreezeModelActive ? deepFreeze(model) : model;
|
|
47
54
|
const runtimeId = container?.id ?? '';
|
|
48
55
|
// NOTE: When the message queue drains a chain of dispatches (e.g. recursive
|
|
@@ -221,13 +228,25 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
221
228
|
attributes: command.args ?? {},
|
|
222
229
|
}), provideAllResources, Effect.flatMap(enqueueNormal))));
|
|
223
230
|
const maybeDevToolsStore = yield* Ref.get(maybeDevToolsStoreRef);
|
|
231
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
232
|
+
const messageTag = message._tag;
|
|
233
|
+
const isModelChanged = currentModel !== nextModel;
|
|
234
|
+
const isExcludedFromHistory = excludeFromHistoryTags.has(messageTag);
|
|
224
235
|
yield* Option.match(maybeDevToolsStore, {
|
|
225
236
|
onNone: () => Effect.void,
|
|
226
|
-
onSome: store =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
237
|
+
onSome: store => {
|
|
238
|
+
if (!isExcludedFromHistory) {
|
|
239
|
+
return store.recordMessage(
|
|
240
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
241
|
+
message, currentModel, nextModel, Array.map(
|
|
242
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
243
|
+
commands, toCommandRecord), isModelChanged);
|
|
244
|
+
}
|
|
245
|
+
if (isModelChanged) {
|
|
246
|
+
return store.updateLatestModel(nextModel);
|
|
247
|
+
}
|
|
248
|
+
return Effect.void;
|
|
249
|
+
},
|
|
231
250
|
});
|
|
232
251
|
});
|
|
233
252
|
// NOTE: `dispatchService` defaults to the live dispatch but is
|
|
@@ -269,12 +288,23 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
269
288
|
})));
|
|
270
289
|
if (Option.isSome(resolvedDevTools)) {
|
|
271
290
|
const { position, mode, maybeBanner } = resolvedDevTools.value;
|
|
291
|
+
// NOTE: when excludeFromHistory is active, the runtime drops
|
|
292
|
+
// excluded Messages from the recorded history. Replay walks the
|
|
293
|
+
// recorded entries forward from the nearest keyframe — but with
|
|
294
|
+
// exclusion, the dropped Messages aren't in that walk, so any
|
|
295
|
+
// cumulative state they would have produced is missing from the
|
|
296
|
+
// replayed model. Setting keyframeInterval to 1 stores a full
|
|
297
|
+
// snapshot on every recorded entry, so time-travel becomes a
|
|
298
|
+
// direct lookup that reflects the real live state at the moment
|
|
299
|
+
// the entry was recorded.
|
|
300
|
+
const isExcludingMessages = excludeFromHistoryTags.size > 0;
|
|
272
301
|
const devToolsStore = yield* createDevToolsStore({
|
|
302
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
273
303
|
replay: (model, message) => {
|
|
274
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
275
304
|
const [updatedModel] = update(model, message);
|
|
276
305
|
return maybeFreezeModel(updatedModel);
|
|
277
306
|
},
|
|
307
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
278
308
|
// NOTE: clears the dirty bit on the jumpTo render so the
|
|
279
309
|
// renderLoop's Stream.changes sees the next dispatch as a real
|
|
280
310
|
// false-to-true transition rather than a deduped no-op. Passes
|
|
@@ -295,6 +325,11 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
295
325
|
// animation frame, which renders the live model with live
|
|
296
326
|
// dispatch and rebinds listeners.
|
|
297
327
|
markRenderPending: SubscriptionRef.set(isRenderPendingRef, true),
|
|
328
|
+
}, {
|
|
329
|
+
...(isExcludingMessages && { keyframeInterval: 1 }),
|
|
330
|
+
...(devToolsMaxEntries !== undefined && {
|
|
331
|
+
maxEntries: devToolsMaxEntries,
|
|
332
|
+
}),
|
|
298
333
|
});
|
|
299
334
|
yield* Ref.set(maybeDevToolsStoreRef, Option.some(devToolsStore));
|
|
300
335
|
// The init render runs below; capture the events it produces. We
|