@tschk/moonshine-dom 0.0.0-stage → 0.4.49
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/LICENSE +15 -0
- package/README.md +467 -2
- package/package.json +62 -4
- package/src/attributes.ts +56 -0
- package/src/binding.ts +430 -0
- package/src/cleanup-order.ts +16 -0
- package/src/component-instance.ts +291 -0
- package/src/component.ts +187 -0
- package/src/control.ts +469 -0
- package/src/custom-element.ts +54 -0
- package/src/dom.ts +870 -0
- package/src/error.ts +59 -0
- package/src/framework-lazy.ts +20 -0
- package/src/framework-native.ts +141 -0
- package/src/framework-source.ts +28 -0
- package/src/head-ssr.ts +108 -0
- package/src/head.ts +34 -0
- package/src/html.ts +54 -0
- package/src/jsx-types.d.ts +19 -0
- package/src/platform.d.ts +4 -0
- package/src/platform.js +4 -0
- package/src/reactive.ts +693 -0
- package/src/render-scheduler.ts +17 -0
- package/src/resource-ssr.ts +73 -0
- package/src/resource.ts +195 -0
- package/src/rotating-text.ts +38 -0
- package/src/ssr-attempt.ts +64 -0
- package/src/ssr-owner.ts +38 -0
- package/src/ssr.ts +874 -0
- package/src/store.ts +527 -0
- package/src/style.ts +30 -0
- package/src/template-retention.ts +4 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/** Native exported-instance references; not a Svelte class/component ABI. */
|
|
2
|
+
import {
|
|
3
|
+
getComponentContext,
|
|
4
|
+
peekComponentContext,
|
|
5
|
+
type ComponentContext,
|
|
6
|
+
} from "./component";
|
|
7
|
+
import {
|
|
8
|
+
batch,
|
|
9
|
+
getRenderScheduler,
|
|
10
|
+
createComputed,
|
|
11
|
+
onCleanup,
|
|
12
|
+
queuePostCommit,
|
|
13
|
+
runWithOwner,
|
|
14
|
+
untrack,
|
|
15
|
+
type Owner,
|
|
16
|
+
} from "./reactive";
|
|
17
|
+
|
|
18
|
+
export const componentRef = /* @__PURE__ */ Symbol("moonshine.component.ref");
|
|
19
|
+
/** Optional compiler-supplied paths retain tuple types; fixed cells keep zero arguments. */
|
|
20
|
+
export type ComponentReference<
|
|
21
|
+
T extends object,
|
|
22
|
+
Parts extends readonly unknown[] = [],
|
|
23
|
+
Current = T,
|
|
24
|
+
> = {
|
|
25
|
+
/** Opt into clearing after the enclosing DOM commit; default is a microtask. */
|
|
26
|
+
cleanup?: "commit";
|
|
27
|
+
/** Compiler opt-in: publish after child lifecycle posts, before ancestor posts.
|
|
28
|
+
* Requires a render scheduler; default references publish before mounts. */
|
|
29
|
+
publication?: "post";
|
|
30
|
+
get: (...parts: Parts) => Current | null | undefined;
|
|
31
|
+
set: (value: T | null, ...parts: Parts) => void;
|
|
32
|
+
} & (Parts extends readonly []
|
|
33
|
+
? { parts?: () => Parts }
|
|
34
|
+
: { parts: () => Parts });
|
|
35
|
+
const exposed = new WeakSet<ComponentContext>();
|
|
36
|
+
const instancePrototype = /* @__PURE__ */ Object.freeze(
|
|
37
|
+
/* @__PURE__ */ Object.create(null),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const publications = new Set<() => void>();
|
|
41
|
+
let scheduled = false;
|
|
42
|
+
let flushing = false;
|
|
43
|
+
|
|
44
|
+
/** Commit all pending instance references before post-DOM lifecycle callbacks. */
|
|
45
|
+
export function flushComponentReferences(): void {
|
|
46
|
+
if (flushing || !publications.size || peekComponentContext()?.active) return;
|
|
47
|
+
flushing = true;
|
|
48
|
+
let failed = false;
|
|
49
|
+
let failure: unknown;
|
|
50
|
+
let waves = 0;
|
|
51
|
+
try {
|
|
52
|
+
while (publications.size) {
|
|
53
|
+
// Fresh publishers can perpetuate feedback without repeating a callback.
|
|
54
|
+
if (++waves > 1000) {
|
|
55
|
+
if (!failed)
|
|
56
|
+
failure = new Error("Component reference update limit exceeded");
|
|
57
|
+
failed = true;
|
|
58
|
+
publications.clear();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
// oxlint-disable-next-line unicorn/no-useless-spread -- Freeze the wave so newly queued callbacks count toward the limit.
|
|
62
|
+
for (const publish of [...publications]) {
|
|
63
|
+
if (!publications.delete(publish)) continue;
|
|
64
|
+
try {
|
|
65
|
+
publish();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (!failed) failure = error;
|
|
68
|
+
failed = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} finally {
|
|
73
|
+
flushing = false;
|
|
74
|
+
}
|
|
75
|
+
if (failed) throw failure;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Preserve export descriptors in an opaque instance; publish and clear in microtasks. */
|
|
79
|
+
export function exposeComponent<T extends object>(exports: T): T {
|
|
80
|
+
const frame = getComponentContext();
|
|
81
|
+
if (
|
|
82
|
+
exports === null ||
|
|
83
|
+
typeof exports !== "object" ||
|
|
84
|
+
(Object.getPrototypeOf(exports) !== Object.prototype &&
|
|
85
|
+
Object.getPrototypeOf(exports) !== null)
|
|
86
|
+
)
|
|
87
|
+
throw new TypeError(
|
|
88
|
+
"Component exports must be a plain object of named exports",
|
|
89
|
+
);
|
|
90
|
+
if (exposed.has(frame))
|
|
91
|
+
throw new Error("Component exports may be exposed only once per instance");
|
|
92
|
+
const instance = Object.create(
|
|
93
|
+
instancePrototype,
|
|
94
|
+
Object.getOwnPropertyDescriptors(exports),
|
|
95
|
+
) as T;
|
|
96
|
+
if (frame.mode === "ssr") {
|
|
97
|
+
exposed.add(frame);
|
|
98
|
+
return instance;
|
|
99
|
+
}
|
|
100
|
+
const props = frame.props;
|
|
101
|
+
const reference =
|
|
102
|
+
props && (typeof props === "object" || typeof props === "function")
|
|
103
|
+
? Reflect.get(props, componentRef)
|
|
104
|
+
: undefined;
|
|
105
|
+
if (
|
|
106
|
+
reference !== undefined &&
|
|
107
|
+
(!reference ||
|
|
108
|
+
typeof reference.get !== "function" ||
|
|
109
|
+
typeof reference.set !== "function")
|
|
110
|
+
)
|
|
111
|
+
throw new TypeError("Component reference requires get and set functions");
|
|
112
|
+
if (reference?.cleanup !== undefined && reference.cleanup !== "commit")
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
"Component reference cleanup must be commit when provided",
|
|
115
|
+
);
|
|
116
|
+
const publication = reference?.publication;
|
|
117
|
+
if (publication !== undefined && publication !== "post")
|
|
118
|
+
throw new TypeError(
|
|
119
|
+
"Component reference publication must be post when provided",
|
|
120
|
+
);
|
|
121
|
+
const enqueue = publisher(publication);
|
|
122
|
+
exposed.add(frame);
|
|
123
|
+
frame.capture?.(instance);
|
|
124
|
+
if (!reference) return instance;
|
|
125
|
+
if ("parts" in reference) {
|
|
126
|
+
enqueue(bindOwnedReference(frame.owner, instance, reference, enqueue));
|
|
127
|
+
return instance;
|
|
128
|
+
}
|
|
129
|
+
const binding = reference as ComponentReference<T>;
|
|
130
|
+
let published = false;
|
|
131
|
+
const clear = () =>
|
|
132
|
+
untrack(() => {
|
|
133
|
+
if (binding.get() === instance) binding.set(null);
|
|
134
|
+
});
|
|
135
|
+
const publish = () => {
|
|
136
|
+
if (frame.owner.disposed) return;
|
|
137
|
+
const commit = () =>
|
|
138
|
+
untrack(() => {
|
|
139
|
+
published = true;
|
|
140
|
+
try {
|
|
141
|
+
binding.set(instance);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
try {
|
|
144
|
+
clear();
|
|
145
|
+
} catch {
|
|
146
|
+
/* Preserve the publishing failure. */
|
|
147
|
+
}
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
runPublication(binding, commit);
|
|
152
|
+
};
|
|
153
|
+
onCleanup(() => {
|
|
154
|
+
publications.delete(publish);
|
|
155
|
+
if (published) scheduleClear(binding, clear);
|
|
156
|
+
});
|
|
157
|
+
enqueue(publish);
|
|
158
|
+
return instance;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Schedule an owned reference publisher for the next microtask or explicit flush. */
|
|
162
|
+
export function enqueueComponentReference(publish: () => void): void {
|
|
163
|
+
publications.add(publish);
|
|
164
|
+
if (!scheduled && !flushing) {
|
|
165
|
+
scheduled = true;
|
|
166
|
+
queueMicrotask(() => {
|
|
167
|
+
scheduled = false;
|
|
168
|
+
flushComponentReferences();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function runPublication(
|
|
174
|
+
binding: { cleanup?: "commit" },
|
|
175
|
+
publish: () => void,
|
|
176
|
+
): void {
|
|
177
|
+
if (binding.cleanup === "commit") batch(publish);
|
|
178
|
+
else publish();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function scheduleClear(
|
|
182
|
+
binding: { cleanup?: "commit" },
|
|
183
|
+
clear: () => void,
|
|
184
|
+
enqueueClear?: (clear: () => void) => void,
|
|
185
|
+
): void {
|
|
186
|
+
if (enqueueClear) enqueueClear(clear);
|
|
187
|
+
else if (binding.cleanup === "commit") queuePostCommit(clear);
|
|
188
|
+
else queueMicrotask(clear);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export type OwnedReference<T extends object> = {
|
|
192
|
+
cleanup?: "commit";
|
|
193
|
+
publication?: "post";
|
|
194
|
+
parts?: () => readonly unknown[];
|
|
195
|
+
get: (...parts: unknown[]) => T | null | undefined;
|
|
196
|
+
set: (value: T | null, ...parts: unknown[]) => void;
|
|
197
|
+
};
|
|
198
|
+
/** Internal shared target protocol; the caller chooses when parts initialize. */
|
|
199
|
+
export function bindOwnedReference<T extends object>(
|
|
200
|
+
owner: Owner,
|
|
201
|
+
instance: T,
|
|
202
|
+
binding: OwnedReference<T>,
|
|
203
|
+
enqueue: (fn: () => void) => void,
|
|
204
|
+
policy?: {
|
|
205
|
+
cleanup?: "commit";
|
|
206
|
+
previousCheck?: "after-set";
|
|
207
|
+
enqueueClear?: (clear: () => void) => void;
|
|
208
|
+
},
|
|
209
|
+
): () => void {
|
|
210
|
+
const cleanupPolicy = policy ?? binding;
|
|
211
|
+
let current: readonly unknown[] | undefined;
|
|
212
|
+
let next: readonly unknown[] | undefined;
|
|
213
|
+
const clear = (parts: readonly unknown[]) =>
|
|
214
|
+
untrack(() => {
|
|
215
|
+
if (binding.get(...parts) === instance) binding.set(null, ...parts);
|
|
216
|
+
});
|
|
217
|
+
const publish = () => {
|
|
218
|
+
if (owner.disposed || !next) return;
|
|
219
|
+
const target = next;
|
|
220
|
+
next = undefined;
|
|
221
|
+
const commit = () =>
|
|
222
|
+
untrack(() => {
|
|
223
|
+
// Distinct path tuples can address the same actual cell.
|
|
224
|
+
if (binding.get(...target) === instance) {
|
|
225
|
+
current = target;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const previous = current;
|
|
229
|
+
const ownedPrevious =
|
|
230
|
+
previous &&
|
|
231
|
+
(policy?.previousCheck === "after-set" ||
|
|
232
|
+
binding.get(...previous) === instance);
|
|
233
|
+
try {
|
|
234
|
+
binding.set(instance, ...target);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
try {
|
|
237
|
+
clear(target);
|
|
238
|
+
} catch {
|
|
239
|
+
/* Preserve the publishing failure. */
|
|
240
|
+
}
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
current = target;
|
|
244
|
+
// The setter can dispose its component before the new path is recorded.
|
|
245
|
+
if (owner.disposed)
|
|
246
|
+
scheduleClear(
|
|
247
|
+
cleanupPolicy,
|
|
248
|
+
() => clear(target),
|
|
249
|
+
policy?.enqueueClear,
|
|
250
|
+
);
|
|
251
|
+
if (ownedPrevious) clear(previous);
|
|
252
|
+
});
|
|
253
|
+
// A setter can synchronously dispose the component. Keep its final target
|
|
254
|
+
// cleanup inside the same native commit, after ancestor teardown callbacks.
|
|
255
|
+
runPublication(cleanupPolicy, commit);
|
|
256
|
+
};
|
|
257
|
+
const initialize = () => {
|
|
258
|
+
if (owner.disposed) return;
|
|
259
|
+
runWithOwner(owner, () =>
|
|
260
|
+
createComputed(() => {
|
|
261
|
+
const parts = binding.parts;
|
|
262
|
+
if (parts !== undefined && typeof parts !== "function")
|
|
263
|
+
throw new TypeError("Component reference parts must be a function");
|
|
264
|
+
const values = parts ? parts.call(binding) : [];
|
|
265
|
+
if (!Array.isArray(values))
|
|
266
|
+
throw new TypeError("Component reference parts must return an array");
|
|
267
|
+
next = Array.from(values);
|
|
268
|
+
enqueue(publish);
|
|
269
|
+
}),
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
onCleanup(() => {
|
|
273
|
+
publications.delete(initialize);
|
|
274
|
+
publications.delete(publish);
|
|
275
|
+
next = undefined;
|
|
276
|
+
const last = current;
|
|
277
|
+
if (last)
|
|
278
|
+
scheduleClear(cleanupPolicy, () => clear(last), policy?.enqueueClear);
|
|
279
|
+
});
|
|
280
|
+
return initialize;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function publisher(publication?: "post"): (fn: () => void) => void {
|
|
284
|
+
if (publication !== "post") return enqueueComponentReference;
|
|
285
|
+
const scheduler = getRenderScheduler();
|
|
286
|
+
if (!scheduler)
|
|
287
|
+
throw new Error(
|
|
288
|
+
"Post component reference publication requires an opt-in render scheduler",
|
|
289
|
+
);
|
|
290
|
+
return (fn) => scheduler.post(fn, true);
|
|
291
|
+
}
|
package/src/component.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { cleanupOrderKey } from "./cleanup-order";
|
|
2
|
+
/** Native component ownership/context ABI; no source-language compiler runtime. */
|
|
3
|
+
import {
|
|
4
|
+
cleanupComputationKey,
|
|
5
|
+
createComponentScope,
|
|
6
|
+
getOwner,
|
|
7
|
+
getRenderScheduler,
|
|
8
|
+
type Owner,
|
|
9
|
+
} from "./reactive";
|
|
10
|
+
|
|
11
|
+
const componentKey = /* @__PURE__ */ Symbol("moonshine.component");
|
|
12
|
+
const contextSourceKey = /* @__PURE__ */ Symbol(
|
|
13
|
+
"moonshine.component.contextSource",
|
|
14
|
+
);
|
|
15
|
+
type ComponentContextSource = ComponentContext & {
|
|
16
|
+
readonly [contextSourceKey]?: ReadonlyMap<unknown, unknown>;
|
|
17
|
+
};
|
|
18
|
+
/** Explicit per-instance event listener map; interpreted by compiler adapters. */
|
|
19
|
+
export const componentEvents = /* @__PURE__ */ Symbol(
|
|
20
|
+
"moonshine.component.events",
|
|
21
|
+
);
|
|
22
|
+
export interface ComponentContext<P = unknown> {
|
|
23
|
+
readonly props: P;
|
|
24
|
+
readonly owner: Owner;
|
|
25
|
+
readonly mode: "dom" | "ssr";
|
|
26
|
+
readonly contexts: ReadonlyMap<unknown, unknown>;
|
|
27
|
+
active: boolean;
|
|
28
|
+
ready?: Array<() => void>;
|
|
29
|
+
capture?: (instance: object) => void;
|
|
30
|
+
}
|
|
31
|
+
export function peekComponentContext(): ComponentContext | undefined {
|
|
32
|
+
return getOwner()?.context?.get(componentKey) as ComponentContext | undefined;
|
|
33
|
+
}
|
|
34
|
+
export function getComponentContext(): ComponentContext {
|
|
35
|
+
const frame = peekComponentContext();
|
|
36
|
+
const owner = getOwner();
|
|
37
|
+
if (
|
|
38
|
+
!frame?.active ||
|
|
39
|
+
!owner ||
|
|
40
|
+
(owner.disposed && !owner.context?.has(cleanupComputationKey))
|
|
41
|
+
)
|
|
42
|
+
throw new Error(
|
|
43
|
+
"Component context is available only during native component initialization",
|
|
44
|
+
);
|
|
45
|
+
return frame;
|
|
46
|
+
}
|
|
47
|
+
export interface ComponentInvocation {
|
|
48
|
+
contexts?: ReadonlyMap<unknown, unknown>;
|
|
49
|
+
capture?: (instance: object) => void;
|
|
50
|
+
}
|
|
51
|
+
export function createComponent<P, T>(
|
|
52
|
+
fn: (props: P) => T,
|
|
53
|
+
props: P,
|
|
54
|
+
mode: "dom" | "ssr",
|
|
55
|
+
options?: ComponentInvocation,
|
|
56
|
+
): T {
|
|
57
|
+
const inherited = peekComponentContext() as
|
|
58
|
+
ComponentContextSource | undefined;
|
|
59
|
+
return createComponentScope(() => {
|
|
60
|
+
const owner = getOwner()!;
|
|
61
|
+
let captured = false;
|
|
62
|
+
let contexts: Map<unknown, unknown> | undefined;
|
|
63
|
+
const frame: ComponentContext<P> & ComponentContextSource = {
|
|
64
|
+
props,
|
|
65
|
+
owner,
|
|
66
|
+
mode,
|
|
67
|
+
// Skip untouched ancestors without initializing their context maps.
|
|
68
|
+
get [contextSourceKey]() {
|
|
69
|
+
return (
|
|
70
|
+
contexts ??
|
|
71
|
+
options?.contexts ??
|
|
72
|
+
(inherited &&
|
|
73
|
+
(contextSourceKey in inherited
|
|
74
|
+
? inherited[contextSourceKey]
|
|
75
|
+
: inherited.contexts))
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
get contexts() {
|
|
79
|
+
return (contexts ??= new Map(frame[contextSourceKey]));
|
|
80
|
+
},
|
|
81
|
+
active: true,
|
|
82
|
+
};
|
|
83
|
+
if (options?.capture)
|
|
84
|
+
frame.capture = (instance) => {
|
|
85
|
+
captured = true;
|
|
86
|
+
options.capture!(instance);
|
|
87
|
+
};
|
|
88
|
+
owner.context = new Map(owner.context);
|
|
89
|
+
// Native component frames start their own default cleanup policy.
|
|
90
|
+
owner.context.delete(cleanupOrderKey);
|
|
91
|
+
owner.context.set(componentKey, frame);
|
|
92
|
+
let result: T;
|
|
93
|
+
try {
|
|
94
|
+
const scheduler = getRenderScheduler();
|
|
95
|
+
result = scheduler ? scheduler.component(() => fn(props)) : fn(props);
|
|
96
|
+
} finally {
|
|
97
|
+
frame.active = false;
|
|
98
|
+
}
|
|
99
|
+
if (!captured && !owner.disposed) options?.capture?.(Object.create(null));
|
|
100
|
+
const ready = frame.ready?.splice(0);
|
|
101
|
+
if (ready && !owner.disposed) {
|
|
102
|
+
let failed = false;
|
|
103
|
+
let failure: unknown;
|
|
104
|
+
for (const callback of ready) {
|
|
105
|
+
if (owner.disposed) break;
|
|
106
|
+
try {
|
|
107
|
+
callback();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (!failed) failure = error;
|
|
110
|
+
failed = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (failed) throw failure;
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** Internal setup completion, before the enclosing component scope returns. */
|
|
119
|
+
export function onComponentReady(fn: () => void): void {
|
|
120
|
+
(getComponentContext().ready ??= []).push(fn);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function getContext<T>(key: unknown): T | undefined {
|
|
124
|
+
return getComponentContext().contexts.get(key) as T | undefined;
|
|
125
|
+
}
|
|
126
|
+
export function setContext<T>(key: unknown, value: T): T {
|
|
127
|
+
(getComponentContext().contexts as Map<unknown, unknown>).set(key, value);
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
export function hasContext(key: unknown): boolean {
|
|
131
|
+
return getComponentContext().contexts.has(key);
|
|
132
|
+
}
|
|
133
|
+
/** Snapshot: callers cannot mutate an inactive component's context through it. */
|
|
134
|
+
export function getAllContexts(): Map<unknown, unknown> {
|
|
135
|
+
return new Map(getComponentContext().contexts);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Internal compiler adapter boundary: retain the invocation owner/attempt. */
|
|
139
|
+
export function withComponentConsumer<T>(
|
|
140
|
+
frame: ComponentContext,
|
|
141
|
+
fn: () => T,
|
|
142
|
+
): T {
|
|
143
|
+
return withConsumer(frame, fn, false);
|
|
144
|
+
}
|
|
145
|
+
/** Internal historical computation boundary; current owner stays disposed if already stopped. */
|
|
146
|
+
export function withComponentCleanupConsumer<T>(
|
|
147
|
+
frame: ComponentContext,
|
|
148
|
+
fn: () => T,
|
|
149
|
+
): T {
|
|
150
|
+
return withConsumer(frame, fn, true);
|
|
151
|
+
}
|
|
152
|
+
function withConsumer<T>(
|
|
153
|
+
frame: ComponentContext,
|
|
154
|
+
fn: () => T,
|
|
155
|
+
cleanup: boolean,
|
|
156
|
+
): T {
|
|
157
|
+
const owner = getOwner();
|
|
158
|
+
if (!owner || (!cleanup && (owner.disposed || frame.owner.disposed)))
|
|
159
|
+
throw new Error("Live component consumer required");
|
|
160
|
+
const context = owner.context,
|
|
161
|
+
active = frame.active,
|
|
162
|
+
wasDisposed = owner.disposed;
|
|
163
|
+
if (!cleanup && active && context?.get(componentKey) === frame) {
|
|
164
|
+
try {
|
|
165
|
+
return fn();
|
|
166
|
+
} finally {
|
|
167
|
+
frame.active = active;
|
|
168
|
+
owner.context =
|
|
169
|
+
owner.disposed && !wasDisposed && !context.has(cleanupComputationKey)
|
|
170
|
+
? undefined
|
|
171
|
+
: context;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
owner.context = new Map(context);
|
|
175
|
+
owner.context.set(componentKey, frame);
|
|
176
|
+
if (cleanup) owner.context.set(cleanupComputationKey, true);
|
|
177
|
+
frame.active = true;
|
|
178
|
+
try {
|
|
179
|
+
return fn();
|
|
180
|
+
} finally {
|
|
181
|
+
frame.active = active;
|
|
182
|
+
owner.context =
|
|
183
|
+
owner.disposed && !wasDisposed && !context?.has(cleanupComputationKey)
|
|
184
|
+
? undefined
|
|
185
|
+
: context;
|
|
186
|
+
}
|
|
187
|
+
}
|