@expressive/react 0.92.0 → 0.93.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/adapter.d.ts +1 -1
- package/dist/adapter.js +1 -1
- package/dist/{chunk-runtime-DNnZ2rnk.d.ts → chunk-runtime-BPVaN7sv.d.ts} +4 -42
- package/dist/{chunk-state.get-CwOD24xe.js → chunk-state.get-rQCeG3MQ.js} +57 -74
- package/dist/chunk-state.get-rQCeG3MQ.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-state.get-CwOD24xe.js.map +0 -1
package/dist/adapter.d.ts
CHANGED
package/dist/adapter.js
CHANGED
|
@@ -1,43 +1,5 @@
|
|
|
1
|
-
import { Component, Context
|
|
1
|
+
import { Component, Context } from "@expressive/mvc";
|
|
2
2
|
|
|
3
|
-
//#region src/state.get.d.ts
|
|
4
|
-
/** Type may not be undefined - instead will be null. */
|
|
5
|
-
type NoVoid<T> = T extends undefined | void ? null : T;
|
|
6
|
-
declare module '@expressive/mvc' {
|
|
7
|
-
namespace Model {
|
|
8
|
-
type ForceRefresh = {
|
|
9
|
-
/** Request a refresh for current component. */(): void;
|
|
10
|
-
/**
|
|
11
|
-
* Request a refresh and again after promise either resolves or rejects.
|
|
12
|
-
*
|
|
13
|
-
* @param waitFor Promise to wait for.
|
|
14
|
-
* @returns Promise which resolves, after refresh, to same value as `waitFor`.
|
|
15
|
-
*/
|
|
16
|
-
<T = void>(waitFor: Promise<T>): Promise<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Request refresh before and after async function.
|
|
19
|
-
* A refresh will occur both before and after the given function.
|
|
20
|
-
*
|
|
21
|
-
* **Note:** Any actions performed before first `await` will occur prior to refresh.
|
|
22
|
-
*
|
|
23
|
-
* @param invoke Async function to invoke.
|
|
24
|
-
* @returns Promise which resolves returned value after refresh.
|
|
25
|
-
*/
|
|
26
|
-
<T = void>(invoke: () => Promise<T>): Promise<T>;
|
|
27
|
-
};
|
|
28
|
-
type GetFactory<T extends Model, R> = (this: T, current: T, refresh: ForceRefresh) => R;
|
|
29
|
-
type GetEffect<T extends Model> = (this: T, current: T, refresh: ForceRefresh) => null;
|
|
30
|
-
/** Fetch instance of this class from context. */
|
|
31
|
-
function get<T extends Model>(this: Model.Extends<T>): T;
|
|
32
|
-
/** Fetch instance of this class optionally. */
|
|
33
|
-
function get<T extends Model>(this: Model.Extends<T>, required: false): T | undefined;
|
|
34
|
-
/** Fetch instance of this class from context. */
|
|
35
|
-
function get<T extends Model>(this: Model.Extends<T>, requireValues: true): Required<T>;
|
|
36
|
-
function get<T extends Model, R>(this: Model.Extends<T>, factory: GetFactory<T, Promise<R> | R>): NoVoid<R>;
|
|
37
|
-
function get<T extends Model>(this: Model.Extends<T>, factory: GetEffect<T>): null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
3
|
//#region src/component.d.ts
|
|
42
4
|
declare module '@expressive/mvc' {
|
|
43
5
|
interface Component {
|
|
@@ -52,7 +14,7 @@ declare module '@expressive/mvc' {
|
|
|
52
14
|
*/
|
|
53
15
|
mount?(): (() => void) | void;
|
|
54
16
|
/** @deprecated Only to satisfy host JSX. Use `this.get(Model)` instead. */
|
|
55
|
-
readonly context: Context
|
|
17
|
+
readonly context: Context;
|
|
56
18
|
/** @deprecated Only to satisfy host JSX. Use `this.get()` instead. */
|
|
57
19
|
readonly state: {};
|
|
58
20
|
/** @deprecated Only to satisfy host JSX. Use `this.set({})` instead. */
|
|
@@ -83,7 +45,7 @@ declare const Runtime: {
|
|
|
83
45
|
/** Consumed for pre-commit revision validation; absent where commits
|
|
84
46
|
* cannot interleave with writes. */
|
|
85
47
|
useSyncExternalStore?(subscribe: (notify: () => void) => () => void, getSnapshot: () => number, getServerSnapshot?: () => number): number; /** Per-render-attempt lifecycle; absent where render attempts do not stack. */
|
|
86
|
-
dedupe?(from: Component, context: Context
|
|
48
|
+
dedupe?(from: Component, context: Context): {
|
|
87
49
|
commit(): void;
|
|
88
50
|
remove(): void;
|
|
89
51
|
}; /** Whether the host is certainly not rendering, so a hook probe would only throw - and may log. `undefined` when the host cannot tell. */
|
|
@@ -93,4 +55,4 @@ declare const Runtime: {
|
|
|
93
55
|
};
|
|
94
56
|
//#endregion
|
|
95
57
|
export { Runtime as t };
|
|
96
|
-
//# sourceMappingURL=chunk-runtime-
|
|
58
|
+
//# sourceMappingURL=chunk-runtime-BPVaN7sv.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Component, Context,
|
|
1
|
+
import { Component, Context, Model, pending, unbind } from "@expressive/mvc";
|
|
2
|
+
import { resolver } from "@expressive/mvc/jsx-runtime";
|
|
2
3
|
import { observer, watch } from "@expressive/mvc/observable";
|
|
3
4
|
|
|
4
5
|
//#region src/runtime.ts
|
|
@@ -161,7 +162,7 @@ let shared;
|
|
|
161
162
|
* which an adapter's entry populates at load - after this module evaluates.
|
|
162
163
|
*/
|
|
163
164
|
function Layers() {
|
|
164
|
-
return shared || (shared = Runtime.createContext(Context
|
|
165
|
+
return shared || (shared = Runtime.createContext(Context.root));
|
|
165
166
|
}
|
|
166
167
|
/** Read the ambient {@link Context} from the nearest Layers provider. */
|
|
167
168
|
function useAmbient() {
|
|
@@ -178,13 +179,6 @@ Object.defineProperty(Component, "contextType", {
|
|
|
178
179
|
configurable: true,
|
|
179
180
|
get: Layers
|
|
180
181
|
});
|
|
181
|
-
const _get = Context$1.get;
|
|
182
|
-
Context$1.get = (state) => {
|
|
183
|
-
if (!state && !Runtime.idle()) try {
|
|
184
|
-
return useAmbient();
|
|
185
|
-
} catch {}
|
|
186
|
-
return _get(state);
|
|
187
|
-
};
|
|
188
182
|
|
|
189
183
|
//#endregion
|
|
190
184
|
//#region src/component.ts
|
|
@@ -312,18 +306,31 @@ function subcomponents(target) {
|
|
|
312
306
|
|
|
313
307
|
//#endregion
|
|
314
308
|
//#region src/state.get.ts
|
|
315
|
-
|
|
316
|
-
const
|
|
309
|
+
const normal = resolver((Type, compute) => {
|
|
310
|
+
const idle = Runtime.idle();
|
|
311
|
+
if (idle) return normal(Type, compute);
|
|
312
|
+
let ambient;
|
|
313
|
+
if (idle === void 0) try {
|
|
314
|
+
ambient = useAmbient();
|
|
315
|
+
} catch {
|
|
316
|
+
return normal(Type, compute);
|
|
317
|
+
}
|
|
318
|
+
else ambient = useAmbient();
|
|
319
|
+
return Type ? use(ambient, compute) : compute(ambient);
|
|
320
|
+
});
|
|
321
|
+
function use(local, compute) {
|
|
317
322
|
const [tick, next] = Runtime.useState(0);
|
|
318
323
|
const claim = useSettle(tick);
|
|
319
|
-
const local = Context.get();
|
|
320
324
|
const dispatch = useWeak(next);
|
|
321
325
|
return useFactory(() => {
|
|
322
|
-
let
|
|
326
|
+
let latest = compute;
|
|
323
327
|
let mounted = false;
|
|
324
328
|
let pending = false;
|
|
325
|
-
let value;
|
|
326
329
|
let force;
|
|
330
|
+
let target;
|
|
331
|
+
let value;
|
|
332
|
+
let unwatch;
|
|
333
|
+
let thrown;
|
|
327
334
|
function update() {
|
|
328
335
|
pending = false;
|
|
329
336
|
dispatch.deref()((x) => x + 1);
|
|
@@ -334,70 +341,45 @@ Model.get = function get(argument) {
|
|
|
334
341
|
update();
|
|
335
342
|
} else pending = true;
|
|
336
343
|
}
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
339
|
-
update();
|
|
340
|
-
if (action instanceof Promise) return action.finally(update);
|
|
341
|
-
}
|
|
342
|
-
function release() {
|
|
343
|
-
unfollow();
|
|
344
|
+
function follow(found) {
|
|
345
|
+
if (found === target) return;
|
|
344
346
|
unwatch?.();
|
|
345
347
|
unwatch = void 0;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
348
|
+
target = value = found;
|
|
349
|
+
if (found instanceof Model && observer(found) !== null) {
|
|
350
|
+
let first = true;
|
|
351
|
+
unwatch = watch(found, (current) => {
|
|
352
|
+
value = current;
|
|
353
|
+
if (!first) observed();
|
|
354
|
+
first = false;
|
|
355
|
+
return (update) => {
|
|
356
|
+
if (update === true) force();
|
|
357
|
+
};
|
|
358
|
+
}, false, Runtime.startTransition);
|
|
353
359
|
}
|
|
354
|
-
|
|
355
|
-
unwatch = watch(next, (current) => {
|
|
356
|
-
if (typeof argument === "function") {
|
|
357
|
-
const next = argument.call(current, current, refresh);
|
|
358
|
-
if (next === value) return;
|
|
359
|
-
value = next;
|
|
360
|
-
} else value = current;
|
|
361
|
-
if (!first) observed();
|
|
362
|
-
first = false;
|
|
363
|
-
return (update) => {
|
|
364
|
-
if (update === true) force();
|
|
365
|
-
};
|
|
366
|
-
}, argument === true, Runtime.startTransition);
|
|
360
|
+
return true;
|
|
367
361
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (next === found) return;
|
|
371
|
-
found = next;
|
|
362
|
+
function release() {
|
|
363
|
+
unfollow();
|
|
372
364
|
unwatch?.();
|
|
373
|
-
unwatch = void 0;
|
|
374
|
-
value = void 0;
|
|
375
|
-
if (next) attach(next);
|
|
376
|
-
return true;
|
|
365
|
+
unwatch = target = void 0;
|
|
377
366
|
}
|
|
367
|
+
let first = true;
|
|
378
368
|
const unfollow = watch(local, (ctx) => {
|
|
379
|
-
|
|
369
|
+
try {
|
|
370
|
+
if (follow(latest(ctx)) && !first) observed();
|
|
371
|
+
} catch (error) {
|
|
372
|
+
thrown = [error];
|
|
373
|
+
if (!first) observed();
|
|
374
|
+
}
|
|
380
375
|
}, false);
|
|
381
|
-
|
|
376
|
+
first = false;
|
|
377
|
+
if (thrown) {
|
|
382
378
|
unfollow();
|
|
383
|
-
throw
|
|
379
|
+
throw thrown[0];
|
|
384
380
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return () => null;
|
|
388
|
-
}
|
|
389
|
-
if (value instanceof Promise) {
|
|
390
|
-
let error;
|
|
391
|
-
release();
|
|
392
|
-
value.then((x) => value = x, (e) => error = e).finally(update);
|
|
393
|
-
value = null;
|
|
394
|
-
return () => {
|
|
395
|
-
if (error) throw error;
|
|
396
|
-
return value === void 0 ? null : value;
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
return () => {
|
|
400
|
-
follow(local.get(Type, false));
|
|
381
|
+
let fresh = true;
|
|
382
|
+
return (next) => {
|
|
401
383
|
pending = false;
|
|
402
384
|
useSetup((_self, reset) => {
|
|
403
385
|
force = reset;
|
|
@@ -407,12 +389,13 @@ Model.get = function get(argument) {
|
|
|
407
389
|
return release;
|
|
408
390
|
};
|
|
409
391
|
});
|
|
410
|
-
if (
|
|
411
|
-
|
|
392
|
+
if (!fresh) follow((latest = next)(local));
|
|
393
|
+
fresh = false;
|
|
394
|
+
return value;
|
|
412
395
|
};
|
|
413
|
-
})();
|
|
414
|
-
}
|
|
396
|
+
})(compute);
|
|
397
|
+
}
|
|
415
398
|
|
|
416
399
|
//#endregion
|
|
417
|
-
export { useWatch as a, useFactory as i,
|
|
418
|
-
//# sourceMappingURL=chunk-state.get-
|
|
400
|
+
export { useWatch as a, useFactory as i, useAmbient as n, weak as o, Runtime as r, createFrame as t };
|
|
401
|
+
//# sourceMappingURL=chunk-state.get-rQCeG3MQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-state.get-rQCeG3MQ.js","names":[],"sources":["../src/runtime.ts","../src/context.ts","../src/component.ts","../src/state.get.ts"],"sourcesContent":["import type { Component } from '@expressive/mvc';\nimport { watch } from '@expressive/mvc/observable';\nimport { pending } from '@expressive/mvc';\nimport type { Context } from './context';\n\ninterface Settle {\n waiting?: (() => void)[];\n claim(): void;\n release(): void;\n}\n\ninterface Setup {\n rendered: number;\n revision: number;\n mounted?: boolean;\n fresh?: boolean;\n getRevision?: () => number;\n lapsed?: boolean;\n commit?: () => (() => void) | void;\n release?: (() => void) | void;\n teardown?: () => void;\n}\n\ninterface Hook<T> extends Setup {\n queued?: boolean;\n update?: Weak<(next: (previous: number) => number) => void>;\n output: T;\n}\n\ninterface Weak<T> {\n deref(): T | undefined;\n}\n\nexport const Runtime = {} as {\n /** Host own-property keys to trap out of observed state; assigned by each adapter. */\n ignore: string[];\n createElement(type: any, props?: any, ...children: any[]): any;\n createContext<T>(value: T): any;\n useContext(context: any): any;\n useState<S>(initial: S | (() => S)): [S, (next: (previous: S) => S) => void];\n useEffect(effect: () => (() => void) | void, deps?: any[]): void;\n useRef<T>(initial: T): { current: T };\n /** Non-urgent bracket a subscriber replays through; absent where the host\n * cannot defer, which keeps normal timing. */\n startTransition?(work: () => void): void;\n /** Consumed for pre-commit revision validation; absent where commits\n * cannot interleave with writes. */\n useSyncExternalStore?(\n subscribe: (notify: () => void) => () => void,\n getSnapshot: () => number,\n getServerSnapshot?: () => number\n ): number;\n /** Per-render-attempt lifecycle; absent where render attempts do not stack. */\n dedupe?(from: Component, context: Context): { commit(): void; remove(): void };\n /** Whether the host is certainly not rendering, so a hook probe would only throw - and may log. `undefined` when the host cannot tell. */\n idle(): boolean | undefined;\n /** Host error-boundary component, wrapping a Component whose `catch` is set. */\n ErrorBoundary: unknown;\n Suspense: any;\n};\n\nconst noop = () => () => {};\n\nexport function useFactory<T extends object>(factory: () => T) {\n const ref = Runtime.useRef<T | null>(null);\n return ref.current || (ref.current = factory());\n}\n\n/**\n * Returns a claim on the update being replayed, held until this hook commits\n * carrying it - or until unmount, where it never will. Keyed on `tick` so an\n * urgent commit in the meantime, which leaves the deferred update queued, does\n * not release it.\n */\nexport function useSettle(tick: number) {\n const ref = Runtime.useRef<Settle | null>(null);\n const settle = ref.current || (ref.current = {\n claim() {\n const held = pending();\n\n if (held) (settle.waiting ||= []).push(held);\n },\n release() {\n const { waiting } = settle;\n\n if (!waiting) return;\n settle.waiting = undefined;\n\n for (const held of waiting) held();\n }\n });\n\n Runtime.useEffect(() => {\n settle.release();\n return settle.release;\n }, [tick]);\n\n return settle.claim;\n}\n\n/**\n * Run `init` once for the life of a hook and clean up when it unmounts, safe\n * under React StrictMode - a remount shares the render counter, so neither the\n * setup nor its cleanup repeats. A cleanup following a render not yet committed\n * - Fast Refresh re-running effects - defers a microtask, and is dropped if the\n * effect runs again. `reset` invalidates the rendered value so in-flight render\n * attempts revalidate.\n *\n * @returns The hook's own record, plus the render counter and its setter.\n */\nexport function useSetup<T extends Setup>(\n init: (self: T, reset: () => void) => () => (() => void) | void,\n teardown?: () => void\n) {\n const { current } = Runtime.useRef({ rendered: 0, revision: 0 } as T);\n\n const [tick, update] = Runtime.useState(() => {\n if (!current.rendered)\n current.commit = init(current, () => {\n current.revision++;\n });\n\n return current.rendered++;\n });\n\n useReap(current, teardown);\n\n const getRevision = (current.getRevision ||= () => current.revision);\n\n current.fresh = true;\n\n Runtime.useSyncExternalStore?.(noop, getRevision, getRevision);\n\n Runtime.useEffect(() => {\n current.fresh = false;\n });\n\n Runtime.useEffect(() => {\n current.mounted = true;\n current.lapsed = false;\n\n if (current.commit) {\n current.release = current.commit();\n current.commit = undefined;\n }\n\n return () => {\n if (!current.fresh) {\n if (--current.rendered <= 0) release(current);\n return;\n }\n\n current.lapsed = true;\n\n queueMicrotask(() => {\n if (current.lapsed) release(current);\n });\n }\n }, []);\n\n return [current, tick, update] as const;\n}\n\nfunction release(setup: Setup) {\n setup.release?.();\n setup.teardown?.();\n}\n\nlet reaper: FinalizationRegistry<Setup> | null | undefined;\n\nfunction useReap(setup: Setup, teardown?: () => void) {\n const token = Runtime.useRef<object | null>(null);\n\n if (!teardown || setup.teardown) return;\n\n setup.teardown = teardown;\n\n if (reaper === undefined)\n reaper = typeof FinalizationRegistry == 'function'\n ? new FinalizationRegistry((setup) => setup.mounted || setup.teardown!())\n : null;\n\n reaper?.register((token.current = {}), setup);\n}\n\nexport function weak<T extends object>(value: T): Weak<T> {\n return typeof WeakRef == 'function' ? new WeakRef(value) : { deref: () => value };\n}\n\nexport function useWeak<T extends object>(value: T) {\n const ref = Runtime.useRef<Weak<T> | null>(null);\n return (ref.current ||= weak(value));\n}\n\n/**\n * Mount-effect with a refreshable return value. Publishing a value before mount\n * defers the update to it, and one published after claims the update being\n * replayed until this hook commits carrying it.\n *\n * @returns Latest value published via the setter (`undefined` until set).\n */\nexport function useHook<T = void>(\n callback: (\n refresh: (next: T) => void,\n reset: () => void\n ) => () => (() => void) | void,\n teardown?: () => void\n) {\n const [current, tick, update] = useSetup<Hook<T>>((self, reset) => {\n const mount = callback((next) => {\n self.output = next;\n\n if (self.mounted) {\n claim();\n self.update?.deref()!((x) => x + 1);\n }\n else if (self.update) self.queued = true;\n }, reset);\n\n return () => {\n const cleanup = mount();\n\n if (self.queued) {\n self.queued = false;\n self.update!.deref()!((x) => x + 1);\n }\n\n return cleanup;\n };\n }, teardown);\n\n const claim = useSettle(tick);\n\n current.update ||= weak(update);\n\n return current.output;\n}\n\nexport function useWatch<T extends object>(\n from: T,\n mount?: () => (() => void) | void,\n teardown?: () => void\n) {\n return useHook<T>((refresh, reset) => {\n const release = watch(from, (current) => {\n refresh(current);\n\n return (update) => {\n if (update === true) reset();\n };\n }, undefined, Runtime.startTransition);\n\n return () => {\n const cleanup = mount?.();\n\n return () => {\n release();\n if (typeof cleanup == 'function') cleanup();\n };\n };\n }, teardown) ?? from;\n}\n","import { Context, Component } from '@expressive/mvc';\nimport { Runtime } from './runtime';\n\nlet shared: any;\n\n/**\n * Lazily-created context carrying the active {@link Context} down the tree.\n * Lazy because the framework's `createContext` arrives via {@link Runtime},\n * which an adapter's entry populates at load - after this module evaluates.\n */\nfunction Layers() {\n return shared || (shared = Runtime.createContext(Context.root));\n}\n\n/** Read the ambient {@link Context} from the nearest Layers provider. */\nfunction useAmbient() {\n return Runtime.useContext(Layers());\n}\n\n/** Wrap `children` in a {@link Layers} provider carrying `context` down the tree. */\nfunction createProvider(context: Context, children: any) {\n return Runtime.createElement(Layers().Provider, { value: context, children });\n}\n\n// Class components consume the active Context through the host's `contextType`\nObject.defineProperty(Component, 'contextType', { configurable: true, get: Layers });\n\nexport { Context, createProvider, useAmbient };\n","import { Component, unbind } from '@expressive/mvc';\nimport { createProvider, type Context } from './context';\nimport { Runtime, useWatch } from './runtime';\n\ndeclare module '@expressive/mvc' {\n interface Component {\n /**\n * Optional hook called once this Component commits. Return a function to\n * run when it unmounts.\n *\n * Not called during server render, nor for an instance placed as\n * `{component}` - a placement does not own what it renders. Client-only\n * effects belong here; setup which must accompany the instance itself\n * belongs in `new()`.\n */\n mount?(): (() => void) | void;\n\n /** @deprecated Only to satisfy host JSX. Use `this.get(Model)` instead. */\n readonly context: Context;\n /** @deprecated Only to satisfy host JSX. Use `this.get()` instead. */\n readonly state: {};\n /** @deprecated Only to satisfy host JSX. Use `this.set({})` instead. */\n setState: (state: any, callback?: () => void) => void;\n /** @deprecated Only to satisfy host JSX. Use `this.set(key)` instead. */\n forceUpdate: (callback?: () => void) => void;\n }\n}\n\n// Host-agnostic seams: `state` is a read-only values bag; `context`'s setter\n// pushes a child context, registers the instance for teardown, and installs its\n// per-instance render host. Host-specific descriptors stay in each adapter.\nObject.defineProperties(Component.prototype, {\n state: {\n set() {},\n get: Component.prototype.get\n },\n context: {\n set: bootstrap\n }\n});\n\n/**\n * On the root Component, host own-property keys are trapped so each lands as a\n * plain own property (out of observed state); each adapter assigns its own set.\n */\nComponent.on({\n type(type) {\n const render = Object.getOwnPropertyDescriptor(type.prototype, 'render');\n\n if (typeof render?.value == 'function')\n Object.defineProperty(type.prototype, 'render', { ...render, configurable: false });\n\n if (type === Component)\n for (const key of Runtime.ignore)\n Object.defineProperty(Component.prototype, key, {\n set(value) {\n Object.defineProperty(this, key, { value, writable: true });\n }\n });\n\n subcomponents(type.prototype);\n },\n setup(self) {\n subcomponents(self);\n }\n});\n\nfunction bootstrap(this: Component, parent: Context){\n const context = parent.push(this, () => this.set(null));\n\n Object.defineProperties(this, {\n context: {\n get: () => context,\n set() {}\n },\n render: {\n value: render(this, context)\n }\n });\n\n this.set(null, () => {\n Object.defineProperty(this, 'props', {\n value: this.props,\n writable: true\n });\n })\n}\n\n/**\n * Wrap a content element in its context provider, a Suspense boundary (unless\n * `fallback` is `false`) and, when `catch` is set, the host error boundary.\n */\nfunction createFrame(from: Component, context: Context, children: unknown) {\n const { createElement } = Runtime;\n\n if(from.fallback !== false)\n children = createElement(\n Runtime.Suspense,\n { fallback: from.fallback, name: String(from) },\n children\n )\n\n children = createProvider(context, children);\n\n return from.props.catch || from.catch\n ? createElement(Runtime.ErrorBoundary, { self: from, children })\n : children;\n}\n\n/**\n * Ownership host for `<Component/>`: React owns the instance, so its render\n * threads the bootstrap-pushed context through `Runtime.dedupe` (React stacks\n * render attempts) and tears that context down - destroying the instance - on\n * unmount.\n */\nfunction render(from: Component, context: Context) {\n const { createElement, dedupe } = Runtime;\n const attempt = dedupe?.(from, context);\n const { is: owner } = from;\n // Read before bootstrap shadows an instance `render` with this host.\n const own = Object.prototype.hasOwnProperty.call(owner, 'render') && owner.render;\n const teardown = () => {\n attempt?.remove();\n context.pop();\n };\n\n const Render = () => (own || Object.getPrototypeOf(owner).render).call(from, from.props);\n const Component = () => {\n from = useWatch(from, () => {\n const release = owner.mount?.();\n\n attempt?.commit();\n\n return release;\n }, teardown);\n\n return createFrame(from, context, createElement(Render));\n };\n\n return () => createElement(Component);\n}\n\n/** Rewrite each own capitalized function on `target` into a subcomponent. */\nfunction subcomponents(target: object) {\n for (const key of Object.getOwnPropertyNames(target)) {\n if (!/^[A-Z]/.test(key)) continue;\n const { value } = Object.getOwnPropertyDescriptor(target, key)!;\n if (typeof value != 'function') continue;\n Object.defineProperty(target, key, {\n configurable: true,\n get(this: Component) {\n const owner = this.is;\n let render = unbind(value);\n const Component = (props: unknown) =>\n render.call(useWatch(owner), props);\n\n Object.defineProperty(owner, key, {\n configurable: true,\n get: () => Component,\n set(fn: Function) {\n render = fn;\n }\n });\n\n return Component;\n },\n set(this: Component, value: unknown) {\n Object.defineProperty(this, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true\n });\n\n subcomponents(this);\n }\n });\n }\n}\n\nexport { createFrame };\n","import { Model, Context } from '@expressive/mvc';\nimport { observer, watch } from '@expressive/mvc/observable';\nimport { resolver } from '@expressive/mvc/jsx-runtime';\nimport { useAmbient } from './context';\nimport { Runtime, useFactory, useSettle, useSetup, useWeak } from './runtime';\n\nconst normal = resolver((Type, compute) => {\n const idle = Runtime.idle();\n\n if (idle) return normal(Type, compute);\n\n let ambient: Context;\n\n if (idle === undefined)\n try {\n ambient = useAmbient();\n } catch {\n return normal(Type, compute);\n }\n else ambient = useAmbient();\n\n return Type ? use(ambient, compute) : compute(ambient);\n});\n\nfunction use(local: Context, compute: (context: Context) => unknown) {\n const [tick, next] = Runtime.useState(0);\n const claim = useSettle(tick);\n const dispatch = useWeak(next);\n const render = useFactory(() => {\n let latest = compute;\n let mounted = false;\n let pending = false;\n let force!: () => void;\n let target: unknown;\n let value: unknown;\n let unwatch: (() => void) | undefined;\n let thrown: [unknown] | undefined;\n\n function update() {\n pending = false;\n dispatch.deref()!((x) => x + 1);\n }\n\n function observed() {\n if (mounted) {\n claim();\n update();\n }\n else pending = true;\n }\n\n function follow(found: unknown) {\n if (found === target) return;\n\n unwatch?.();\n unwatch = undefined;\n target = value = found;\n\n if (found instanceof Model && observer(found) !== null) {\n let first = true;\n\n unwatch = watch(\n found,\n (current) => {\n value = current;\n\n if (!first) observed();\n first = false;\n\n return (update) => {\n if (update === true) force();\n };\n },\n false,\n Runtime.startTransition\n );\n }\n\n return true;\n }\n\n function release() {\n unfollow();\n unwatch?.();\n unwatch = target = undefined;\n }\n\n let first = true;\n\n const unfollow = watch(local, (ctx) => {\n try {\n if (follow(latest(ctx)) && !first) observed();\n } catch (error) {\n thrown = [error];\n if (!first) observed();\n }\n }, false);\n\n first = false;\n\n if (thrown) {\n unfollow();\n throw thrown[0];\n }\n\n let fresh = true;\n\n return (next: typeof compute) => {\n pending = false;\n useSetup((_self, reset) => {\n force = reset;\n\n return () => {\n mounted = true;\n if (pending) update();\n return release;\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useWatch, i as useFactory, n as useAmbient, o as weak, r as Runtime, t as createFrame } from "./chunk-state.get-rQCeG3MQ.js";
|
|
2
2
|
import "./adapter.js";
|
|
3
3
|
import { Component } from "@expressive/mvc";
|
|
4
4
|
import * as React$1 from "react";
|
|
@@ -41,7 +41,7 @@ elements((Type) => {
|
|
|
41
41
|
} });
|
|
42
42
|
});
|
|
43
43
|
function Element() {
|
|
44
|
-
const outer =
|
|
44
|
+
const outer = useAmbient();
|
|
45
45
|
return useFactory(() => {
|
|
46
46
|
let from = this;
|
|
47
47
|
const context = outer.push(this);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Context","React"],"sources":["../src/element.ts","../src/jsx-runtime.ts","../src/boundary.ts","../src/idle.ts","../src/index.ts"],"sourcesContent":["import { Component } from '@expressive/mvc';\nimport { elements } from '@expressive/mvc/jsx-runtime';\nimport type { Renderable } from '@expressive/mvc/jsx-runtime';\nimport { Context } from './context';\nimport { Runtime, useFactory, useWatch } from './runtime';\nimport { createFrame } from './component';\n\ndeclare module '@expressive/mvc' {\n interface Component {\n /** @deprecated Only to satisfy host JSX. */\n readonly type: typeof Component;\n }\n}\n\nlet template: any;\n\n/**\n * Borrow a host element's descriptors so `self` passes as a React element.\n * `props` false keeps the target's own `props` (Component supplies its own);\n * an object installs it as the element's props (collections have none).\n */\nexport function seam(\n self: object,\n props: object | false,\n type: Function,\n key: unknown\n) {\n if (!template) template = Runtime.createElement('template');\n\n const descriptors = Object.getOwnPropertyDescriptors(template);\n const store = descriptors._store?.value;\n\n if (props === false) delete (descriptors as any).props;\n\n if (store)\n descriptors._store.value = Object.create(\n Object.getPrototypeOf(store),\n Object.getOwnPropertyDescriptors(store)\n );\n\n Object.defineProperties(self, {\n ...descriptors,\n $$typeof: { value: template.$$typeof },\n ...(props ? { props: { value: props } } : undefined),\n key: { value: key },\n type: { value: type }\n });\n\n return template.$$typeof;\n}\n\n/**\n * Every class the core declares renderable - `Component`, `has` lists and\n * pools, `map` collections - gets the one getter. `is` resolves a derived view\n * to its instance; a Component renders through its ownership frame, anything\n * else through `render()`.\n */\nelements((Type) => {\n Object.defineProperty(Type.prototype, '$$typeof', {\n get(this: Renderable) {\n const self = this.is;\n\n return self instanceof Component\n ? seam(self, false, Element.bind(self), self.key)\n : seam(self, {}, Members.bind(self), null);\n }\n });\n});\n\nfunction Element(this: Component){\n const outer = Context.get();\n const render = useFactory(() => {\n let from = this;\n const context = outer.push(this);\n const Content = () => from.render(from.props);\n\n return () => {\n from = useWatch(this, () => () => context.pop());\n\n return createFrame(from, context, Runtime.createElement(Content));\n };\n });\n\n return render();\n}\n\nfunction Members(this: Renderable) {\n return useWatch(this).render();\n}\n","import { Children, isValidElement } from 'react';\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime';\nimport { host } from '@expressive/mvc/jsx-runtime';\n\nimport type { Component as ReactComponent, JSX as ReactJSX, ReactNode } from 'react';\n\ndeclare module '@expressive/mvc/jsx-runtime' {\n interface Host {\n node: ReactNode;\n intrinsics: ReactJSX.IntrinsicElements;\n elementClass: ReactComponent<any, any>;\n }\n}\n\nhost({\n jsx,\n jsxs,\n Fragment,\n isElement: isValidElement,\n childrenOf: Children.toArray,\n typeOf(node){\n return isValidElement(node) ? node.type : undefined;\n },\n propsOf(node){\n return isValidElement(node) ? node.props as Record<string, unknown> : {};\n }\n});\n","import { Component } from '@expressive/mvc';\nimport React from 'react';\nimport { Context } from './context';\n\ninterface Entry {\n committed?: boolean;\n context: Context;\n commit: () => void;\n remove: () => void;\n};\n\n/** In-flight render attempts by tree position, per ambient context.\n * When one commits, older uncommitted attempts at its slot are provably dead. */\nconst SLOTS = new WeakMap<Context, Map<string, Set<Entry>>>();\n\n/**\n * React's attempt lifecycle: fiber-keyed stacking so a superseded (uncommitted)\n * render attempt at a tree position is discarded when a later one commits.\n */\nexport function dedupe(on: Component, context: Context) {\n let slots = SLOTS.get(context.parent!);\n if (!slots) SLOTS.set(context.parent!, (slots = new Map()));\n\n // key/index path to root: stable across render attempts of this element\n let slot = '';\n for (let f = (on as any)._reactInternals; f; f = f.return)\n slot += (f.key ?? f.index) + '.';\n\n let list = slots.get(slot);\n if (!list) slots.set(slot, (list = new Set()));\n\n const entry: Entry = {\n context,\n commit() {\n entry.committed = true;\n\n for (const e of list) {\n if (e === entry) break;\n if (e.committed) continue;\n e.context.pop();\n list.delete(e);\n }\n },\n remove() {\n list.delete(entry);\n }\n };\n\n list.add(entry);\n return entry;\n};\n\nexport class ErrorBoundary extends React.Component<{\n self: Component;\n children: React.ReactNode;\n}> {\n state = {} as { error?: Error };\n recovering = false;\n\n constructor(props: ErrorBoundary['props']) {\n super(props);\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n const { self } = this.props;\n const { fallback } = self;\n const reset = (error?: Error) => {\n this.recovering = true;\n this.setState({ error });\n };\n\n Promise.resolve((self.props.catch || self.catch)!.call(self, error, self.is))\n .then(() => reset(), reset)\n .finally(() => self.set({ fallback }, true));\n }\n\n componentDidUpdate() {\n this.recovering = false;\n }\n\n render() {\n if (!this.state.error) return this.props.children;\n if (this.recovering) throw this.state.error;\n return this.props.self.fallback;\n }\n};\n","interface Dispatcher {\n useContext: unknown;\n useState: unknown;\n}\n\nexport function idle(React: any): () => boolean | undefined {\n const modern = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;\n const legacy = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher;\n\n const current: (() => Dispatcher | null) | undefined =\n modern && 'H' in modern ? () => modern.H :\n legacy && 'current' in legacy ? () => legacy.current :\n undefined;\n\n if (!current) return () => undefined;\n\n return () => {\n const dispatcher = current();\n\n return !dispatcher || dispatcher.useContext === dispatcher.useState;\n };\n}\n","import { Component } from '@expressive/mvc';\nimport * as React from 'react';\n\nimport './element';\nimport './jsx-runtime';\n\nimport { Runtime } from './adapter';\nimport { weak } from './runtime';\nimport { ErrorBoundary, dedupe } from './boundary';\nimport { idle } from './idle';\n\n// React detects class components by this brand (preact reads `prototype.render`).\nObject.defineProperty(Component.prototype, 'isReactComponent', {\n value: true\n});\n\nconst FIBER = new WeakMap<Component, { deref(): unknown }>();\n\nObject.defineProperty(Component.prototype, '_reactInternals', {\n get(this: Component) {\n return FIBER.get(this)?.deref();\n },\n set(this: Component, fiber: object) {\n FIBER.set(this, weak(fiber));\n }\n});\n\nObject.assign(Runtime, {\n idle: idle(React),\n dedupe,\n ErrorBoundary,\n createElement: React.createElement,\n createContext: React.createContext,\n useContext: React.useContext,\n useEffect: React.useEffect,\n useState: React.useState,\n useRef: React.useRef,\n useSyncExternalStore: React.useSyncExternalStore,\n startTransition: React.startTransition,\n Suspense: React.Suspense,\n ignore: [\n 'updater',\n 'refs',\n '_reactInternalInstance'\n ]\n});\n\n// Nothing is exported for app code - `Model`, `Component` and the instructions come\n// from `@expressive/mvc`; `has` and `map` collections are adopted in `element.ts`.\n\n// A type-only export, so this entry's .d.ts stays linked to the adapter's\n// `Model`/`Component` augmentations; the bundler drops a bare import.\nexport type { Runtime } from './adapter';\n"],"mappings":";;;;;;;;;AAcA,IAAI;;;;;;AAOJ,SAAgB,KACd,MACA,OACA,MACA,KACA;AACA,KAAI,CAAC,SAAU,YAAW,QAAQ,cAAc,WAAW;CAE3D,MAAM,cAAc,OAAO,0BAA0B,SAAS;CAC9D,MAAM,QAAQ,YAAY,QAAQ;AAElC,KAAI,UAAU,MAAO,QAAQ,YAAoB;AAEjD,KAAI,MACF,aAAY,OAAO,QAAQ,OAAO,OAChC,OAAO,eAAe,MAAM,EAC5B,OAAO,0BAA0B,MAAM,CACxC;AAEH,QAAO,iBAAiB,MAAM;EAC5B,GAAG;EACH,UAAU,EAAE,OAAO,SAAS,UAAU;EACtC,GAAI,QAAQ,EAAE,OAAO,EAAE,OAAO,OAAO,EAAE,GAAG;EAC1C,KAAK,EAAE,OAAO,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,aAAa,SAAS;AAE5B,SAAO,CAAC,cAAc,WAAW,eAAe,WAAW;;;;;;ACP/D,OAAO,eAAe,UAAU,WAAW,oBAAoB,EAC7D,OAAO,MACR,CAAC;AAEF,MAAM,wBAAQ,IAAI,SAA0C;AAE5D,OAAO,eAAe,UAAU,WAAW,mBAAmB;CAC5D,MAAqB;AACnB,SAAO,MAAM,IAAI,KAAK,EAAE,OAAO;;CAEjC,IAAqB,OAAe;AAClC,QAAM,IAAI,MAAM,KAAK,MAAM,CAAC;;CAE/B,CAAC;AAEF,OAAO,OAAO,SAAS;CACrB,MAAM,KAAKC,QAAM;CACjB;CACA;CACA,eAAeA,QAAM;CACrB,eAAeA,QAAM;CACrB,YAAYA,QAAM;CAClB,WAAWA,QAAM;CACjB,UAAUA,QAAM;CAChB,QAAQA,QAAM;CACd,sBAAsBA,QAAM;CAC5B,iBAAiBA,QAAM;CACvB,UAAUA,QAAM;CAChB,QAAQ;EACN;EACA;EACA;EACD;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React"],"sources":["../src/element.ts","../src/jsx-runtime.ts","../src/boundary.ts","../src/idle.ts","../src/index.ts"],"sourcesContent":["import { Component } from '@expressive/mvc';\nimport { elements } from '@expressive/mvc/jsx-runtime';\nimport type { Renderable } from '@expressive/mvc/jsx-runtime';\nimport { useAmbient } from './context';\nimport { Runtime, useFactory, useWatch } from './runtime';\nimport { createFrame } from './component';\n\ndeclare module '@expressive/mvc' {\n interface Component {\n /** @deprecated Only to satisfy host JSX. */\n readonly type: typeof Component;\n }\n}\n\nlet template: any;\n\n/**\n * Borrow a host element's descriptors so `self` passes as a React element.\n * `props` false keeps the target's own `props` (Component supplies its own);\n * an object installs it as the element's props (collections have none).\n */\nexport function seam(\n self: object,\n props: object | false,\n type: Function,\n key: unknown\n) {\n if (!template) template = Runtime.createElement('template');\n\n const descriptors = Object.getOwnPropertyDescriptors(template);\n const store = descriptors._store?.value;\n\n if (props === false) delete (descriptors as any).props;\n\n if (store)\n descriptors._store.value = Object.create(\n Object.getPrototypeOf(store),\n Object.getOwnPropertyDescriptors(store)\n );\n\n Object.defineProperties(self, {\n ...descriptors,\n $$typeof: { value: template.$$typeof },\n ...(props ? { props: { value: props } } : undefined),\n key: { value: key },\n type: { value: type }\n });\n\n return template.$$typeof;\n}\n\n/**\n * Every class the core declares renderable - `Component`, `has` lists and\n * pools, `map` collections - gets the one getter. `is` resolves a derived view\n * to its instance; a Component renders through its ownership frame, anything\n * else through `render()`.\n */\nelements((Type) => {\n Object.defineProperty(Type.prototype, '$$typeof', {\n get(this: Renderable) {\n const self = this.is;\n\n return self instanceof Component\n ? seam(self, false, Element.bind(self), self.key)\n : seam(self, {}, Members.bind(self), null);\n }\n });\n});\n\nfunction Element(this: Component){\n const outer = useAmbient();\n const render = useFactory(() => {\n let from = this;\n const context = outer.push(this);\n const Content = () => from.render(from.props);\n\n return () => {\n from = useWatch(this, () => () => context.pop());\n\n return createFrame(from, context, Runtime.createElement(Content));\n };\n });\n\n return render();\n}\n\nfunction Members(this: Renderable) {\n return useWatch(this).render();\n}\n","import { Children, isValidElement } from 'react';\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime';\nimport { host } from '@expressive/mvc/jsx-runtime';\n\nimport type { Component as ReactComponent, JSX as ReactJSX, ReactNode } from 'react';\n\ndeclare module '@expressive/mvc/jsx-runtime' {\n interface Host {\n node: ReactNode;\n intrinsics: ReactJSX.IntrinsicElements;\n elementClass: ReactComponent<any, any>;\n }\n}\n\nhost({\n jsx,\n jsxs,\n Fragment,\n isElement: isValidElement,\n childrenOf: Children.toArray,\n typeOf(node){\n return isValidElement(node) ? node.type : undefined;\n },\n propsOf(node){\n return isValidElement(node) ? node.props as Record<string, unknown> : {};\n }\n});\n","import { Component } from '@expressive/mvc';\nimport React from 'react';\nimport { Context } from './context';\n\ninterface Entry {\n committed?: boolean;\n context: Context;\n commit: () => void;\n remove: () => void;\n};\n\n/** In-flight render attempts by tree position, per ambient context.\n * When one commits, older uncommitted attempts at its slot are provably dead. */\nconst SLOTS = new WeakMap<Context, Map<string, Set<Entry>>>();\n\n/**\n * React's attempt lifecycle: fiber-keyed stacking so a superseded (uncommitted)\n * render attempt at a tree position is discarded when a later one commits.\n */\nexport function dedupe(on: Component, context: Context) {\n let slots = SLOTS.get(context.parent!);\n if (!slots) SLOTS.set(context.parent!, (slots = new Map()));\n\n // key/index path to root: stable across render attempts of this element\n let slot = '';\n for (let f = (on as any)._reactInternals; f; f = f.return)\n slot += (f.key ?? f.index) + '.';\n\n let list = slots.get(slot);\n if (!list) slots.set(slot, (list = new Set()));\n\n const entry: Entry = {\n context,\n commit() {\n entry.committed = true;\n\n for (const e of list) {\n if (e === entry) break;\n if (e.committed) continue;\n e.context.pop();\n list.delete(e);\n }\n },\n remove() {\n list.delete(entry);\n }\n };\n\n list.add(entry);\n return entry;\n};\n\nexport class ErrorBoundary extends React.Component<{\n self: Component;\n children: React.ReactNode;\n}> {\n state = {} as { error?: Error };\n recovering = false;\n\n constructor(props: ErrorBoundary['props']) {\n super(props);\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error) {\n const { self } = this.props;\n const { fallback } = self;\n const reset = (error?: Error) => {\n this.recovering = true;\n this.setState({ error });\n };\n\n Promise.resolve((self.props.catch || self.catch)!.call(self, error, self.is))\n .then(() => reset(), reset)\n .finally(() => self.set({ fallback }, true));\n }\n\n componentDidUpdate() {\n this.recovering = false;\n }\n\n render() {\n if (!this.state.error) return this.props.children;\n if (this.recovering) throw this.state.error;\n return this.props.self.fallback;\n }\n};\n","interface Dispatcher {\n useContext: unknown;\n useState: unknown;\n}\n\nexport function idle(React: any): () => boolean | undefined {\n const modern = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;\n const legacy = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher;\n\n const current: (() => Dispatcher | null) | undefined =\n modern && 'H' in modern ? () => modern.H :\n legacy && 'current' in legacy ? () => legacy.current :\n undefined;\n\n if (!current) return () => undefined;\n\n return () => {\n const dispatcher = current();\n\n return !dispatcher || dispatcher.useContext === dispatcher.useState;\n };\n}\n","import { Component } from '@expressive/mvc';\nimport * as React from 'react';\n\nimport './element';\nimport './jsx-runtime';\n\nimport { Runtime } from './adapter';\nimport { weak } from './runtime';\nimport { ErrorBoundary, dedupe } from './boundary';\nimport { idle } from './idle';\n\n// React detects class components by this brand (preact reads `prototype.render`).\nObject.defineProperty(Component.prototype, 'isReactComponent', {\n value: true\n});\n\nconst FIBER = new WeakMap<Component, { deref(): unknown }>();\n\nObject.defineProperty(Component.prototype, '_reactInternals', {\n get(this: Component) {\n return FIBER.get(this)?.deref();\n },\n set(this: Component, fiber: object) {\n FIBER.set(this, weak(fiber));\n }\n});\n\nObject.assign(Runtime, {\n idle: idle(React),\n dedupe,\n ErrorBoundary,\n createElement: React.createElement,\n createContext: React.createContext,\n useContext: React.useContext,\n useEffect: React.useEffect,\n useState: React.useState,\n useRef: React.useRef,\n useSyncExternalStore: React.useSyncExternalStore,\n startTransition: React.startTransition,\n Suspense: React.Suspense,\n ignore: [\n 'updater',\n 'refs',\n '_reactInternalInstance'\n ]\n});\n\n// Nothing is exported for app code - `Model`, `Component` and the instructions come\n// from `@expressive/mvc`; `has` and `map` collections are adopted in `element.ts`.\n\n// A type-only export, so this entry's .d.ts stays linked to the adapter's\n// `Model`/`Component` augmentations; the bundler drops a bare import.\nexport type { Runtime } from './adapter';\n"],"mappings":";;;;;;;;;AAcA,IAAI;;;;;;AAOJ,SAAgB,KACd,MACA,OACA,MACA,KACA;AACA,KAAI,CAAC,SAAU,YAAW,QAAQ,cAAc,WAAW;CAE3D,MAAM,cAAc,OAAO,0BAA0B,SAAS;CAC9D,MAAM,QAAQ,YAAY,QAAQ;AAElC,KAAI,UAAU,MAAO,QAAQ,YAAoB;AAEjD,KAAI,MACF,aAAY,OAAO,QAAQ,OAAO,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SAAgB,KAAK,OAAuC;CAC1D,MAAM,SAAS,MAAM;CACrB,MAAM,SAAS,MAAM,oDAAoD;CAEzE,MAAM,UACJ,UAAU,OAAO,eAAe,OAAO,IACvC,UAAU,aAAa,eAAe,OAAO,UAC7C;AAEF,KAAI,CAAC,QAAS,cAAa;AAE3B,cAAa;EACX,MAAM,aAAa,SAAS;AAE5B,SAAO,CAAC,cAAc,WAAW,eAAe,WAAW;;;;;;ACP/D,OAAO,eAAe,UAAU,WAAW,oBAAoB,EAC7D,OAAO,MACR,CAAC;AAEF,MAAM,wBAAQ,IAAI,SAA0C;AAE5D,OAAO,eAAe,UAAU,WAAW,mBAAmB;CAC5D,MAAqB;AACnB,SAAO,MAAM,IAAI,KAAK,EAAE,OAAO;;CAEjC,IAAqB,OAAe;AAClC,QAAM,IAAI,MAAM,KAAK,MAAM,CAAC;;CAE/B,CAAC;AAEF,OAAO,OAAO,SAAS;CACrB,MAAM,KAAKA,QAAM;CACjB;CACA;CACA,eAAeA,QAAM;CACrB,eAAeA,QAAM;CACrB,YAAYA,QAAM;CAClB,WAAWA,QAAM;CACjB,UAAUA,QAAM;CAChB,QAAQA,QAAM;CACd,sBAAsBA,QAAM;CAC5B,iBAAiBA,QAAM;CACvB,UAAUA,QAAM;CAChB,QAAQ;EACN;EACA;EACA;EACD;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressive/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
4
4
|
"description": "Class-based reactive state for React. Define state and logic as plain classes; components update when the values they read change.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expressive",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"test": "bun run typecheck && bun run coverage"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@expressive/mvc": "^0.
|
|
66
|
+
"@expressive/mvc": "^0.92.0",
|
|
67
67
|
"@testing-library/react": "^16.3.0",
|
|
68
68
|
"@types/react": "^19",
|
|
69
69
|
"@types/react-dom": "^19",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vite": "^7.3.1"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@expressive/mvc": "^0.
|
|
78
|
+
"@expressive/mvc": "^0.92.0",
|
|
79
79
|
"react": ">=16.14.0 <20.0.0",
|
|
80
80
|
"vite": ">=5"
|
|
81
81
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-state.get-CwOD24xe.js","names":["Context"],"sources":["../src/runtime.ts","../src/context.ts","../src/component.ts","../src/state.get.ts"],"sourcesContent":["import type { Component } from '@expressive/mvc';\nimport { watch } from '@expressive/mvc/observable';\nimport { pending } from '@expressive/mvc';\nimport type { Context } from './context';\n\ninterface Settle {\n waiting?: (() => void)[];\n claim(): void;\n release(): void;\n}\n\ninterface Setup {\n rendered: number;\n revision: number;\n mounted?: boolean;\n fresh?: boolean;\n getRevision?: () => number;\n lapsed?: boolean;\n commit?: () => (() => void) | void;\n release?: (() => void) | void;\n teardown?: () => void;\n}\n\ninterface Hook<T> extends Setup {\n queued?: boolean;\n update?: Weak<(next: (previous: number) => number) => void>;\n output: T;\n}\n\ninterface Weak<T> {\n deref(): T | undefined;\n}\n\nexport const Runtime = {} as {\n /** Host own-property keys to trap out of observed state; assigned by each adapter. */\n ignore: string[];\n createElement(type: any, props?: any, ...children: any[]): any;\n createContext<T>(value: T): any;\n useContext(context: any): any;\n useState<S>(initial: S | (() => S)): [S, (next: (previous: S) => S) => void];\n useEffect(effect: () => (() => void) | void, deps?: any[]): void;\n useRef<T>(initial: T): { current: T };\n /** Non-urgent bracket a subscriber replays through; absent where the host\n * cannot defer, which keeps normal timing. */\n startTransition?(work: () => void): void;\n /** Consumed for pre-commit revision validation; absent where commits\n * cannot interleave with writes. */\n useSyncExternalStore?(\n subscribe: (notify: () => void) => () => void,\n getSnapshot: () => number,\n getServerSnapshot?: () => number\n ): number;\n /** Per-render-attempt lifecycle; absent where render attempts do not stack. */\n dedupe?(from: Component, context: Context): { commit(): void; remove(): void };\n /** Whether the host is certainly not rendering, so a hook probe would only throw - and may log. `undefined` when the host cannot tell. */\n idle(): boolean | undefined;\n /** Host error-boundary component, wrapping a Component whose `catch` is set. */\n ErrorBoundary: unknown;\n Suspense: any;\n};\n\nconst noop = () => () => {};\n\nexport function useFactory<T extends object>(factory: () => T) {\n const ref = Runtime.useRef<T | null>(null);\n return ref.current || (ref.current = factory());\n}\n\n/**\n * Returns a claim on the update being replayed, held until this hook commits\n * carrying it - or until unmount, where it never will. Keyed on `tick` so an\n * urgent commit in the meantime, which leaves the deferred update queued, does\n * not release it.\n */\nexport function useSettle(tick: number) {\n const ref = Runtime.useRef<Settle | null>(null);\n const settle = ref.current || (ref.current = {\n claim() {\n const held = pending();\n\n if (held) (settle.waiting ||= []).push(held);\n },\n release() {\n const { waiting } = settle;\n\n if (!waiting) return;\n settle.waiting = undefined;\n\n for (const held of waiting) held();\n }\n });\n\n Runtime.useEffect(() => {\n settle.release();\n return settle.release;\n }, [tick]);\n\n return settle.claim;\n}\n\n/**\n * Run `init` once for the life of a hook and clean up when it unmounts, safe\n * under React StrictMode - a remount shares the render counter, so neither the\n * setup nor its cleanup repeats. A cleanup following a render not yet committed\n * - Fast Refresh re-running effects - defers a microtask, and is dropped if the\n * effect runs again. `reset` invalidates the rendered value so in-flight render\n * attempts revalidate.\n *\n * @returns The hook's own record, plus the render counter and its setter.\n */\nexport function useSetup<T extends Setup>(\n init: (self: T, reset: () => void) => () => (() => void) | void,\n teardown?: () => void\n) {\n const { current } = Runtime.useRef({ rendered: 0, revision: 0 } as T);\n\n const [tick, update] = Runtime.useState(() => {\n if (!current.rendered)\n current.commit = init(current, () => {\n current.revision++;\n });\n\n return current.rendered++;\n });\n\n useReap(current, teardown);\n\n const getRevision = (current.getRevision ||= () => current.revision);\n\n current.fresh = true;\n\n Runtime.useSyncExternalStore?.(noop, getRevision, getRevision);\n\n Runtime.useEffect(() => {\n current.fresh = false;\n });\n\n Runtime.useEffect(() => {\n current.mounted = true;\n current.lapsed = false;\n\n if (current.commit) {\n current.release = current.commit();\n current.commit = undefined;\n }\n\n return () => {\n if (!current.fresh) {\n if (--current.rendered <= 0) release(current);\n return;\n }\n\n current.lapsed = true;\n\n queueMicrotask(() => {\n if (current.lapsed) release(current);\n });\n }\n }, []);\n\n return [current, tick, update] as const;\n}\n\nfunction release(setup: Setup) {\n setup.release?.();\n setup.teardown?.();\n}\n\nlet reaper: FinalizationRegistry<Setup> | null | undefined;\n\nfunction useReap(setup: Setup, teardown?: () => void) {\n const token = Runtime.useRef<object | null>(null);\n\n if (!teardown || setup.teardown) return;\n\n setup.teardown = teardown;\n\n if (reaper === undefined)\n reaper = typeof FinalizationRegistry == 'function'\n ? new FinalizationRegistry((setup) => setup.mounted || setup.teardown!())\n : null;\n\n reaper?.register((token.current = {}), setup);\n}\n\nexport function weak<T extends object>(value: T): Weak<T> {\n return typeof WeakRef == 'function' ? new WeakRef(value) : { deref: () => value };\n}\n\nexport function useWeak<T extends object>(value: T) {\n const ref = Runtime.useRef<Weak<T> | null>(null);\n return (ref.current ||= weak(value));\n}\n\n/**\n * Mount-effect with a refreshable return value. Publishing a value before mount\n * defers the update to it, and one published after claims the update being\n * replayed until this hook commits carrying it.\n *\n * @returns Latest value published via the setter (`undefined` until set).\n */\nexport function useHook<T = void>(\n callback: (\n refresh: (next: T) => void,\n reset: () => void\n ) => () => (() => void) | void,\n teardown?: () => void\n) {\n const [current, tick, update] = useSetup<Hook<T>>((self, reset) => {\n const mount = callback((next) => {\n self.output = next;\n\n if (self.mounted) {\n claim();\n self.update?.deref()!((x) => x + 1);\n }\n else if (self.update) self.queued = true;\n }, reset);\n\n return () => {\n const cleanup = mount();\n\n if (self.queued) {\n self.queued = false;\n self.update!.deref()!((x) => x + 1);\n }\n\n return cleanup;\n };\n }, teardown);\n\n const claim = useSettle(tick);\n\n current.update ||= weak(update);\n\n return current.output;\n}\n\nexport function useWatch<T extends object>(\n from: T,\n mount?: () => (() => void) | void,\n teardown?: () => void\n) {\n return useHook<T>((refresh, reset) => {\n const release = watch(from, (current) => {\n refresh(current);\n\n return (update) => {\n if (update === true) reset();\n };\n }, undefined, Runtime.startTransition);\n\n return () => {\n const cleanup = mount?.();\n\n return () => {\n release();\n if (typeof cleanup == 'function') cleanup();\n };\n };\n }, teardown) ?? from;\n}\n","import { Model, Context, Component } from '@expressive/mvc';\nimport { Runtime } from './runtime';\n\nlet shared: any;\n\n/**\n * Lazily-created context carrying the active {@link Context} down the tree.\n * Lazy because the framework's `createContext` arrives via {@link Runtime},\n * which an adapter's entry populates at load - after this module evaluates.\n */\nfunction Layers() {\n return shared || (shared = Runtime.createContext(Context.root));\n}\n\n/** Read the ambient {@link Context} from the nearest Layers provider. */\nfunction useAmbient() {\n return Runtime.useContext(Layers());\n}\n\n/** Wrap `children` in a {@link Layers} provider carrying `context` down the tree. */\nfunction createProvider(context: Context, children: any) {\n return Runtime.createElement(Layers().Provider, { value: context, children });\n}\n\n// Class components consume the active Context through the host's `contextType`\nObject.defineProperty(Component, 'contextType', { configurable: true, get: Layers });\n\nconst _get = Context.get;\n\nContext.get = (state?: Model) => {\n if (!state && !Runtime.idle())\n try {\n return useAmbient();\n } catch { }\n\n return _get(state);\n};\n\nexport { Context, createProvider };\n","import { Component, unbind } from '@expressive/mvc';\nimport { createProvider, type Context } from './context';\nimport { Runtime, useWatch } from './runtime';\n\ndeclare module '@expressive/mvc' {\n interface Component {\n /**\n * Optional hook called once this Component commits. Return a function to\n * run when it unmounts.\n *\n * Not called during server render, nor for an instance placed as\n * `{component}` - a placement does not own what it renders. Client-only\n * effects belong here; setup which must accompany the instance itself\n * belongs in `new()`.\n */\n mount?(): (() => void) | void;\n\n /** @deprecated Only to satisfy host JSX. Use `this.get(Model)` instead. */\n readonly context: Context;\n /** @deprecated Only to satisfy host JSX. Use `this.get()` instead. */\n readonly state: {};\n /** @deprecated Only to satisfy host JSX. Use `this.set({})` instead. */\n setState: (state: any, callback?: () => void) => void;\n /** @deprecated Only to satisfy host JSX. Use `this.set(key)` instead. */\n forceUpdate: (callback?: () => void) => void;\n }\n}\n\n// Host-agnostic seams: `state` is a read-only values bag; `context`'s setter\n// pushes a child context, registers the instance for teardown, and installs its\n// per-instance render host. Host-specific descriptors stay in each adapter.\nObject.defineProperties(Component.prototype, {\n state: {\n set() {},\n get: Component.prototype.get\n },\n context: {\n set: bootstrap\n }\n});\n\n/**\n * On the root Component, host own-property keys are trapped so each lands as a\n * plain own property (out of observed state); each adapter assigns its own set.\n */\nComponent.on({\n type(type) {\n const render = Object.getOwnPropertyDescriptor(type.prototype, 'render');\n\n if (typeof render?.value == 'function')\n Object.defineProperty(type.prototype, 'render', { ...render, configurable: false });\n\n if (type === Component)\n for (const key of Runtime.ignore)\n Object.defineProperty(Component.prototype, key, {\n set(value) {\n Object.defineProperty(this, key, { value, writable: true });\n }\n });\n\n subcomponents(type.prototype);\n },\n setup(self) {\n subcomponents(self);\n }\n});\n\nfunction bootstrap(this: Component, parent: Context){\n const context = parent.push(this, () => this.set(null));\n\n Object.defineProperties(this, {\n context: {\n get: () => context,\n set() {}\n },\n render: {\n value: render(this, context)\n }\n });\n\n this.set(null, () => {\n Object.defineProperty(this, 'props', {\n value: this.props,\n writable: true\n });\n })\n}\n\n/**\n * Wrap a content element in its context provider, a Suspense boundary (unless\n * `fallback` is `false`) and, when `catch` is set, the host error boundary.\n */\nfunction createFrame(from: Component, context: Context, children: unknown) {\n const { createElement } = Runtime;\n\n if(from.fallback !== false)\n children = createElement(\n Runtime.Suspense,\n { fallback: from.fallback, name: String(from) },\n children\n )\n\n children = createProvider(context, children);\n\n return from.props.catch || from.catch\n ? createElement(Runtime.ErrorBoundary, { self: from, children })\n : children;\n}\n\n/**\n * Ownership host for `<Component/>`: React owns the instance, so its render\n * threads the bootstrap-pushed context through `Runtime.dedupe` (React stacks\n * render attempts) and tears that context down - destroying the instance - on\n * unmount.\n */\nfunction render(from: Component, context: Context) {\n const { createElement, dedupe } = Runtime;\n const attempt = dedupe?.(from, context);\n const { is: owner } = from;\n // Read before bootstrap shadows an instance `render` with this host.\n const own = Object.prototype.hasOwnProperty.call(owner, 'render') && owner.render;\n const teardown = () => {\n attempt?.remove();\n context.pop();\n };\n\n const Render = () => (own || Object.getPrototypeOf(owner).render).call(from, from.props);\n const Component = () => {\n from = useWatch(from, () => {\n const release = owner.mount?.();\n\n attempt?.commit();\n\n return release;\n }, teardown);\n\n return createFrame(from, context, createElement(Render));\n };\n\n return () => createElement(Component);\n}\n\n/** Rewrite each own capitalized function on `target` into a subcomponent. */\nfunction subcomponents(target: object) {\n for (const key of Object.getOwnPropertyNames(target)) {\n if (!/^[A-Z]/.test(key)) continue;\n const { value } = Object.getOwnPropertyDescriptor(target, key)!;\n if (typeof value != 'function') continue;\n Object.defineProperty(target, key, {\n configurable: true,\n get(this: Component) {\n const owner = this.is;\n let render = unbind(value);\n const Component = (props: unknown) =>\n render.call(useWatch(owner), props);\n\n Object.defineProperty(owner, key, {\n configurable: true,\n get: () => Component,\n set(fn: Function) {\n render = fn;\n }\n });\n\n return Component;\n },\n set(this: Component, value: unknown) {\n Object.defineProperty(this, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true\n });\n\n subcomponents(this);\n }\n });\n }\n}\n\nexport { createFrame };\n","import { Model, Context } from '@expressive/mvc';\nimport { observer, watch } from '@expressive/mvc/observable';\nimport { Runtime, useFactory, useSettle, useSetup, useWeak } from './runtime';\n\n/** Type may not be undefined - instead will be null. */\ntype NoVoid<T> = T extends undefined | void ? null : T;\n\ndeclare module '@expressive/mvc' {\n namespace Model {\n type ForceRefresh = {\n /** Request a refresh for current component. */\n (): void;\n\n /**\n * Request a refresh and again after promise either resolves or rejects.\n *\n * @param waitFor Promise to wait for.\n * @returns Promise which resolves, after refresh, to same value as `waitFor`.\n */\n <T = void>(waitFor: Promise<T>): Promise<T>;\n\n /**\n * Request refresh before and after async function.\n * A refresh will occur both before and after the given function.\n *\n * **Note:** Any actions performed before first `await` will occur prior to refresh.\n *\n * @param invoke Async function to invoke.\n * @returns Promise which resolves returned value after refresh.\n */\n <T = void>(invoke: () => Promise<T>): Promise<T>;\n };\n\n type GetFactory<T extends Model, R> = (\n this: T,\n current: T,\n refresh: ForceRefresh\n ) => R;\n\n type GetEffect<T extends Model> = (\n this: T,\n current: T,\n refresh: ForceRefresh\n ) => null;\n\n /** Fetch instance of this class from context. */\n function get<T extends Model>(this: Model.Extends<T>): T;\n\n /** Fetch instance of this class optionally. */\n function get<T extends Model>(\n this: Model.Extends<T>,\n required: false\n ): T | undefined;\n\n /** Fetch instance of this class from context. */\n function get<T extends Model>(\n this: Model.Extends<T>,\n requireValues: true\n ): Required<T>;\n\n function get<T extends Model, R>(\n this: Model.Extends<T>,\n factory: GetFactory<T, Promise<R> | R>\n ): NoVoid<R>;\n\n function get<T extends Model>(\n this: Model.Extends<T>,\n factory: GetEffect<T>\n ): null;\n }\n}\n\nModel.get = function get<T extends Model>(\n this: Model.Extends<T>,\n argument?: boolean | Model.GetFactory<T, unknown>\n) {\n const Type = this;\n const [tick, next] = Runtime.useState(0);\n const claim = useSettle(tick);\n const local = Context.get();\n const dispatch = useWeak(next);\n const render = useFactory(() => {\n let unwatch: (() => void) | undefined;\n let mounted = false;\n let pending = false;\n let value: any;\n let force!: () => void;\n\n function update() {\n pending = false;\n dispatch.deref()!((x) => x + 1);\n }\n\n function observed() {\n if (mounted) {\n claim();\n update();\n }\n else pending = true;\n }\n\n function refresh<T>(action?: Promise<T> | (() => Promise<T>)): any {\n if (typeof action == 'function') action = action();\n update();\n if (action instanceof Promise) return action.finally(update);\n }\n\n function release() {\n unfollow();\n unwatch?.();\n unwatch = undefined;\n }\n\n function attach(next: T) {\n unwatch?.();\n\n if (observer(next) === null) {\n value = typeof argument === 'function'\n ? argument.call(next, next, refresh)\n : next;\n unwatch = () => {};\n return;\n }\n\n let first = true;\n\n unwatch = watch(\n next,\n (current) => {\n if (typeof argument === 'function') {\n const next = argument.call(current, current, refresh);\n if (next === value) return;\n value = next;\n } else {\n value = current;\n }\n\n if (!first) observed();\n first = false;\n\n return (update) => {\n if (update === true) force();\n };\n },\n argument === true,\n Runtime.startTransition\n );\n }\n\n let found: T | undefined;\n\n function follow(next: T | undefined) {\n if (next === found) return;\n\n found = next;\n unwatch?.();\n unwatch = undefined;\n value = undefined;\n\n if (next) attach(next);\n\n return true;\n }\n\n const unfollow = watch(local, (ctx) => {\n if (follow(ctx.get(Type, false)) && mounted) observed();\n }, false);\n\n if (!found && argument !== false) {\n unfollow();\n throw new Error(`Could not find ${Type} in context.`);\n }\n\n if (value === null) {\n release();\n return () => null;\n }\n\n if (value instanceof Promise) {\n let error: Error | undefined;\n\n release();\n\n value\n .then(\n (x) => (value = x),\n (e) => (error = e)\n )\n .finally(update);\n\n value = null;\n\n return () => {\n if (error) throw error;\n return value === undefined ? null : value;\n };\n }\n\n return () => {\n follow(local.get(Type, false));\n pending = false;\n useSetup((_self, reset) => {\n force = reset;\n\n return () => {\n mounted = true;\n if (pending) update();\n return release;\n };\n });\n if (found) return value === undefined ? null : value;\n if (argument !== false) throw new Error(`Could not find ${Type} in context.`);\n };\n });\n\n return render();\n};\n"],"mappings":";;;;AAiCA,MAAa,UAAU,EAAE;AA4BzB,MAAM,mBAAmB;AAEzB,SAAgB,WAA6B,SAAkB;CAC7D,MAAM,MAAM,QAAQ,OAAiB,KAAK;AAC1C,QAAO,IAAI,YAAY,IAAI,UAAU,SAAS;;;;;;;;AAShD,SAAgB,UAAU,MAAc;CACtC,MAAM,MAAM,QAAQ,OAAsB,KAAK;CAC/C,MAAM,SAAS,IAAI,YAAY,IAAI,UAAU;EAC3C,QAAQ;GACN,MAAM,OAAO,SAAS;AAEtB,OAAI,KAAM,EAAC,OAAO,YAAY,EAAE,EAAE,KAAK,KAAK;;EAE9C,UAAU;GACR,MAAM,EAAE,YAAY;AAEpB,OAAI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