@expressive/react 0.79.0 → 0.79.1
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 +4 -4
- package/dist/adapter.js +231 -5
- package/dist/adapter.js.map +1 -1
- package/package.json +5 -2
package/dist/adapter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Context, State as State$1, State as State$2 } from "@expressive/mvc";
|
|
1
|
+
import { Component, Context as Context$1, State as State$1, State as State$2 } from "@expressive/mvc";
|
|
2
2
|
import * as react from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/state.get.d.ts
|
|
@@ -101,7 +101,7 @@ declare namespace Provider {
|
|
|
101
101
|
is: (instance: T) => void;
|
|
102
102
|
} & { [K in State$2.Field<T>]?: T[K] };
|
|
103
103
|
type ForMultipleProps<T extends State$2> = SharedProps & {
|
|
104
|
-
for: Context.Accept<T>;
|
|
104
|
+
for: Context$1.Accept<T>;
|
|
105
105
|
is?: ForEach<T>;
|
|
106
106
|
};
|
|
107
107
|
type Props<T extends State$2 = State$2> = ForSingleProps<T> | ForMultipleProps<T>;
|
|
@@ -112,7 +112,7 @@ declare function Provider<T extends State$2>(props: Provider.Props<T>): any;
|
|
|
112
112
|
declare module '@expressive/mvc' {
|
|
113
113
|
interface Component {
|
|
114
114
|
/** @deprecated Only to satisfy host JSX. Use `this.get(State)` instead. */
|
|
115
|
-
readonly context: Context;
|
|
115
|
+
readonly context: Context$1;
|
|
116
116
|
/** @deprecated Only to satisfy host JSX. Use `this.get()` instead. */
|
|
117
117
|
readonly state: State.Values<this>;
|
|
118
118
|
/** @deprecated Only to satisfy host JSX. Use `this.set({})` instead. */
|
|
@@ -133,7 +133,7 @@ declare const Runtime: {
|
|
|
133
133
|
useRef<T>(initial: T): {
|
|
134
134
|
current: T;
|
|
135
135
|
}; /** Per-render-attempt lifecycle, set by each adapter (React stacks attempts; others no-op). */
|
|
136
|
-
dedupe(from: Component, context: Context): {
|
|
136
|
+
dedupe(from: Component, context: Context$1): {
|
|
137
137
|
commit(): void;
|
|
138
138
|
remove(): void;
|
|
139
139
|
}; /** Host error-boundary component, wrapping a Component whose `catch` is set. */
|
package/dist/adapter.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Component, Context, State, State as State$1, event, observer, watch } from "@expressive/mvc";
|
|
1
|
+
import { Component, Context, Context as Context$1, State, State as State$1, event, observer, unbind, watch } from "@expressive/mvc";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime.ts
|
|
4
4
|
const Runtime = {};
|
|
5
|
+
function useFactory(factory) {
|
|
6
|
+
const ref = Runtime.useRef(null);
|
|
7
|
+
return ref.current || (ref.current = factory());
|
|
8
|
+
}
|
|
9
|
+
function useReady(callback) {
|
|
10
|
+
return Runtime.useEffect(() => void callback(), []);
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Mount-effect with a refreshable return value, safe under React StrictMode.
|
|
7
14
|
*
|
|
@@ -61,6 +68,114 @@ function use(subject) {
|
|
|
61
68
|
return current.proxy;
|
|
62
69
|
}
|
|
63
70
|
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/state.get.ts
|
|
73
|
+
State$1.get = function get(argument) {
|
|
74
|
+
const next = Runtime.useState(0)[1];
|
|
75
|
+
const local = Context.get();
|
|
76
|
+
return useFactory(() => {
|
|
77
|
+
let unwatch;
|
|
78
|
+
let mounted = false;
|
|
79
|
+
let pending = false;
|
|
80
|
+
let value;
|
|
81
|
+
function update() {
|
|
82
|
+
pending = false;
|
|
83
|
+
next((x) => x + 1);
|
|
84
|
+
}
|
|
85
|
+
function refresh(action) {
|
|
86
|
+
if (typeof action == "function") action = action();
|
|
87
|
+
update();
|
|
88
|
+
if (action instanceof Promise) return action.finally(update);
|
|
89
|
+
}
|
|
90
|
+
function release() {
|
|
91
|
+
unsubscribe();
|
|
92
|
+
unwatch?.();
|
|
93
|
+
unwatch = void 0;
|
|
94
|
+
}
|
|
95
|
+
function attach(next) {
|
|
96
|
+
unwatch?.();
|
|
97
|
+
if (observer(next) === null) {
|
|
98
|
+
value = typeof argument === "function" ? argument.call(next, next, refresh) : next;
|
|
99
|
+
unwatch = () => {};
|
|
100
|
+
return release;
|
|
101
|
+
}
|
|
102
|
+
unwatch = watch(next, (current, changed) => {
|
|
103
|
+
if (typeof argument === "function") {
|
|
104
|
+
const next = argument.call(current, current, refresh);
|
|
105
|
+
if (next === value) return;
|
|
106
|
+
value = next;
|
|
107
|
+
} else value = current;
|
|
108
|
+
if (changed.length) update();
|
|
109
|
+
}, argument === true);
|
|
110
|
+
if (mounted) {
|
|
111
|
+
pending = true;
|
|
112
|
+
queueMicrotask(() => pending && update());
|
|
113
|
+
}
|
|
114
|
+
return release;
|
|
115
|
+
}
|
|
116
|
+
const unsubscribe = local.get(this, attach);
|
|
117
|
+
if (!unwatch) {
|
|
118
|
+
unsubscribe();
|
|
119
|
+
if (argument === false) return () => void 0;
|
|
120
|
+
throw new Error(`Could not find ${this} in context.`);
|
|
121
|
+
}
|
|
122
|
+
if (value === null) {
|
|
123
|
+
release();
|
|
124
|
+
return () => null;
|
|
125
|
+
}
|
|
126
|
+
if (value instanceof Promise) {
|
|
127
|
+
let error;
|
|
128
|
+
release();
|
|
129
|
+
value.then((x) => value = x, (e) => error = e).finally(update);
|
|
130
|
+
value = null;
|
|
131
|
+
return () => {
|
|
132
|
+
if (error) throw error;
|
|
133
|
+
return value === void 0 ? null : value;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return () => {
|
|
137
|
+
pending = false;
|
|
138
|
+
useReady(() => mounted = true);
|
|
139
|
+
useHook(() => release);
|
|
140
|
+
return value === void 0 ? null : value;
|
|
141
|
+
};
|
|
142
|
+
})();
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/state.use.ts
|
|
147
|
+
State$1.use = function use(...args) {
|
|
148
|
+
const outer = Context.get();
|
|
149
|
+
return useFactory(() => {
|
|
150
|
+
const add = (arg) => typeof arg == "object" && instance.set(arg);
|
|
151
|
+
let use = (...args) => Promise.all(args.flat().map(add));
|
|
152
|
+
const instance = new this((x) => {
|
|
153
|
+
if ("use" in x && typeof x.use == "function") {
|
|
154
|
+
use = x.use.bind(x);
|
|
155
|
+
use(...args);
|
|
156
|
+
} else return args;
|
|
157
|
+
});
|
|
158
|
+
const context = outer.push(instance);
|
|
159
|
+
let ready = false;
|
|
160
|
+
return (args) => {
|
|
161
|
+
if (ready) {
|
|
162
|
+
ready = false;
|
|
163
|
+
Promise.resolve(use(...args)).finally(() => {
|
|
164
|
+
ready = true;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
useReady(() => ready = true);
|
|
168
|
+
return useHook((update) => {
|
|
169
|
+
watch(instance, update);
|
|
170
|
+
return () => {
|
|
171
|
+
context.pop();
|
|
172
|
+
instance.set(null);
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
})(args);
|
|
177
|
+
};
|
|
178
|
+
|
|
64
179
|
//#endregion
|
|
65
180
|
//#region src/context.ts
|
|
66
181
|
let shared;
|
|
@@ -70,7 +185,7 @@ let shared;
|
|
|
70
185
|
* which an adapter's entry populates at load - after this module evaluates.
|
|
71
186
|
*/
|
|
72
187
|
function Layers() {
|
|
73
|
-
return shared || (shared = Runtime.createContext(Context.root));
|
|
188
|
+
return shared || (shared = Runtime.createContext(Context$1.root));
|
|
74
189
|
}
|
|
75
190
|
/** Read the ambient {@link Context} from the nearest Layers provider. */
|
|
76
191
|
function useAmbient() {
|
|
@@ -87,8 +202,8 @@ Object.defineProperty(Component, "contextType", {
|
|
|
87
202
|
configurable: true,
|
|
88
203
|
get: Layers
|
|
89
204
|
});
|
|
90
|
-
const _get = Context.get;
|
|
91
|
-
Context.get = (state) => {
|
|
205
|
+
const _get = Context$1.get;
|
|
206
|
+
Context$1.get = (state) => {
|
|
92
207
|
if (!state) try {
|
|
93
208
|
return useAmbient();
|
|
94
209
|
} catch {}
|
|
@@ -101,7 +216,7 @@ function Provider(props) {
|
|
|
101
216
|
const { for: input, children, fallback, name, is, ...rest } = props;
|
|
102
217
|
const ambient = useAmbient();
|
|
103
218
|
const context = useHook((set) => {
|
|
104
|
-
set(new Context(ambient));
|
|
219
|
+
set(new Context$1(ambient));
|
|
105
220
|
return () => context.pop();
|
|
106
221
|
});
|
|
107
222
|
context.set(input, is);
|
|
@@ -115,6 +230,117 @@ function Provider(props) {
|
|
|
115
230
|
}, children) : children);
|
|
116
231
|
}
|
|
117
232
|
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/component.ts
|
|
235
|
+
Object.defineProperties(Component.prototype, {
|
|
236
|
+
state: {
|
|
237
|
+
set() {},
|
|
238
|
+
get: Component.prototype.get
|
|
239
|
+
},
|
|
240
|
+
context: { set: bootstrap }
|
|
241
|
+
});
|
|
242
|
+
/**
|
|
243
|
+
* `State.on` handler that prepares a Component's prototype at bootstrap, before
|
|
244
|
+
* mvc classifies its members:
|
|
245
|
+
*
|
|
246
|
+
* - On the root Component, host own-property keys are trapped so each lands as a
|
|
247
|
+
* plain own property (out of observed state); each adapter assigns its own set.
|
|
248
|
+
* - capitalized methods are rewritten into subcomponents as non-configurable
|
|
249
|
+
* getters, so bootstrap skips them too.
|
|
250
|
+
*
|
|
251
|
+
* (Sealing `render` as the content-render seam is handled by core itself.)
|
|
252
|
+
*
|
|
253
|
+
* `before` covers the per-instance case: a capitalized function assigned as an
|
|
254
|
+
* instance field (e.g. `Sidebar = Sidebar` to inject or override one), promoted
|
|
255
|
+
* before `observe` so it is not mistaken for reactive state.
|
|
256
|
+
*/
|
|
257
|
+
Component.on({
|
|
258
|
+
type(type) {
|
|
259
|
+
if (type === Component) for (const key of Runtime.ignore) Object.defineProperty(Component.prototype, key, { set(value) {
|
|
260
|
+
Object.defineProperty(this, key, {
|
|
261
|
+
value,
|
|
262
|
+
writable: true
|
|
263
|
+
});
|
|
264
|
+
} });
|
|
265
|
+
subcomponents(type.prototype);
|
|
266
|
+
},
|
|
267
|
+
before(self) {
|
|
268
|
+
subcomponents(self, true);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
function bootstrap(context) {
|
|
272
|
+
context = context.push();
|
|
273
|
+
context.set(this, () => () => this.set(null));
|
|
274
|
+
Object.defineProperties(this, {
|
|
275
|
+
context: {
|
|
276
|
+
get: () => context,
|
|
277
|
+
set() {}
|
|
278
|
+
},
|
|
279
|
+
render: { value: render(this, context) }
|
|
280
|
+
});
|
|
281
|
+
this.set(null, () => {
|
|
282
|
+
Object.defineProperty(this, "props", {
|
|
283
|
+
value: this.props,
|
|
284
|
+
writable: true
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Per-instance render host: subscribe the instance, render inside its context
|
|
290
|
+
* provider, wrap pending in Suspense and (when `catch` is set) the host error
|
|
291
|
+
* boundary. Host differences live behind `Runtime.dedupe`/`Runtime.ErrorBoundary`.
|
|
292
|
+
*/
|
|
293
|
+
function render(from, context) {
|
|
294
|
+
const { createElement: create } = Runtime;
|
|
295
|
+
const { commit, remove } = Runtime.dedupe(from, context);
|
|
296
|
+
const content = from.render;
|
|
297
|
+
const Render = () => content.call(from, from.props);
|
|
298
|
+
const Component = () => {
|
|
299
|
+
from = useHook((refresh) => {
|
|
300
|
+
if (observer(from) !== null) watch(from, refresh);
|
|
301
|
+
return () => {
|
|
302
|
+
remove();
|
|
303
|
+
context.pop();
|
|
304
|
+
};
|
|
305
|
+
}) || from;
|
|
306
|
+
useReady(commit);
|
|
307
|
+
const rendered = create(Render);
|
|
308
|
+
const children = provide(context, from.fallback === false ? rendered : create(Runtime.Suspense, {
|
|
309
|
+
fallback: from.fallback,
|
|
310
|
+
name: String(from)
|
|
311
|
+
}, rendered));
|
|
312
|
+
return from.catch ? create(Runtime.ErrorBoundary, {
|
|
313
|
+
self: from,
|
|
314
|
+
children
|
|
315
|
+
}) : children;
|
|
316
|
+
};
|
|
317
|
+
return () => create(Component);
|
|
318
|
+
}
|
|
319
|
+
/** Rewrite each own capitalized function on `target` into a subcomponent. */
|
|
320
|
+
function subcomponents(target, configurable) {
|
|
321
|
+
for (const key of Object.getOwnPropertyNames(target)) {
|
|
322
|
+
if (!/^[A-Z]/.test(key)) continue;
|
|
323
|
+
const { value } = Object.getOwnPropertyDescriptor(target, key);
|
|
324
|
+
if (typeof value != "function") continue;
|
|
325
|
+
Object.defineProperty(target, key, {
|
|
326
|
+
configurable,
|
|
327
|
+
get() {
|
|
328
|
+
const owner = this.is;
|
|
329
|
+
let render = unbind(value);
|
|
330
|
+
const Component = (props) => render.call(useHook((set) => watch(owner, set)) || owner, props);
|
|
331
|
+
Object.defineProperty(owner, key, {
|
|
332
|
+
configurable: true,
|
|
333
|
+
get: () => Component,
|
|
334
|
+
set(fn) {
|
|
335
|
+
render = fn;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return Component;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
118
344
|
//#endregion
|
|
119
345
|
export { Consumer, Provider, Runtime, State, use };
|
|
120
346
|
//# sourceMappingURL=adapter.js.map
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","names":["State"],"sources":["../src/runtime.ts","../src/context.ts"],"sourcesContent":["import { event, watch, observer } from '@expressive/mvc';\nimport type { Component } from '@expressive/mvc';\nimport type { Context } from './context';\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 /** Per-render-attempt lifecycle, set by each adapter (React stacks attempts; others no-op). */\n dedupe(from: Component, context: Context): { commit(): void; remove(): void };\n /** Host error-boundary component, wrapping a Component whose `catch` is set. */\n ErrorBoundary: unknown;\n Suspense: any;\n};\n\nexport function useFactory<T extends Function>(factory: () => T) {\n const ref = Runtime.useRef<T | null>(null);\n return ref.current || (ref.current = factory());\n}\n\nexport function useReady<T>(callback: () => void) {\n return Runtime.useEffect(() => void callback(), []);\n}\n\n/**\n * Mount-effect with a refreshable return value, safe under React StrictMode.\n *\n * @param callback Setup handler; receives a setter, must return a cleanup.\n * @returns Latest value published via the setter (`undefined` until set).\n */\nexport function useHook<T = void>(\n callback: (refresh: (next: T) => void) => () => void\n) {\n const { current } = Runtime.useRef(\n { rendered: 0 } as {\n rendered: number;\n mounted?: boolean;\n pending?: boolean;\n unmount: () => void;\n update?: (next: (previous: number) => number) => void;\n output: T;\n }\n );\n\n current.update = Runtime.useState(() => {\n if (!current.rendered)\n current.unmount = callback((next) => {\n current.output = next;\n if (current.mounted) current.update?.((x) => x + 1);\n else if (current.update) current.pending = true;\n });\n\n return current.rendered++;\n })[1];\n\n Runtime.useEffect(() => {\n current.mounted = true;\n if (current.pending) {\n current.pending = false;\n current.update!((x) => x + 1);\n }\n return () => {\n if (--current.rendered < 1) current.unmount();\n }\n }, []);\n\n return current.output;\n}\n\n/** Subscribe to an existing observable instance within a component. */\nexport function use<T extends object>(subject: T) {\n const { current } = Runtime.useRef<{\n proxy: T;\n source?: T;\n mounted: number;\n unwatch?: () => void;\n }>({ mounted: 0, proxy: subject });\n\n const update = Runtime.useState(() => current.mounted++)[1];\n\n if (current.source !== subject) {\n const status = observer(subject);\n\n if (status === undefined)\n throw new Error('Provided object is not observable.');\n\n current.unwatch?.();\n current.source = subject;\n\n if (status === null) {\n current.unwatch = undefined;\n current.proxy = subject;\n } else {\n if (!status.ready) event(subject);\n\n let init = true;\n\n current.unwatch = watch(subject, (next, changed) => {\n current.proxy = next;\n if (changed.length && !init)\n update((x) => x + 1);\n });\n\n init = false;\n }\n }\n\n Runtime.useEffect(() => () => {\n if (--current.mounted < 1) current.unwatch?.();\n }, []);\n\n return current.proxy;\n}\n","import { State, Context, Component } from '@expressive/mvc';\nimport { Runtime, useHook } 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 provide(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?: State) => {\n if (!state)\n try {\n return useAmbient();\n } catch { }\n\n return _get(state);\n};\n\ndeclare namespace Consumer {\n type Props<T extends State> = {\n /** Type of controller to fetch from context. */\n for: State.Extends<T>;\n\n /**\n * Render function, will receive instance of desired controller.\n *\n * Called every render of parent component.\n * Similar to `State.get()`, updates to properties accessed in\n * this function will cause a refresh when they change.\n */\n children: (value: T) => Component.Node | void;\n };\n}\n\nfunction Consumer<T extends State>(props: Consumer.Props<T>) {\n return props.for.get((i) => props.children(i));\n}\n\ndeclare namespace Provider {\n type ForEach<T> = (state: T) => void | (() => void);\n\n interface SharedProps {\n /**\n * Children to render within this Provider.\n */\n children?: Component.Node;\n\n /** A fallback tree to show when suspended. */\n fallback?: Component.Node;\n\n /**\n * A name for this Suspense boundary for instrumentation purposes.\n * The name will help identify this boundary in React DevTools.\n */\n name?: string | undefined;\n }\n\n type ForSingleProps<T extends State> = SharedProps & {\n for: T | State.Type<T>;\n is: (instance: T) => void;\n } & { [K in State.Field<T>]?: T[K] };\n\n type ForMultipleProps<T extends State> = SharedProps & {\n for: Context.Accept<T>;\n is?: ForEach<T>;\n };\n\n type Props<T extends State = State> = ForSingleProps<T> | ForMultipleProps<T>;\n}\n\nfunction Provider<T extends State>(props: Provider.Props<T>) {\n const {\n for: input,\n children,\n fallback,\n name,\n is,\n ...rest\n } = props as Provider.ForSingleProps<T> & Provider.ForMultipleProps<T>;\n\n const ambient = useAmbient();\n const context = useHook<Context>((set) => {\n set(new Context(ambient));\n return () => context.pop();\n });\n\n context.set(input, is);\n\n if (Object.keys(rest).length) {\n const i = State.is(input) ? context.get(input) : input;\n if (i instanceof State) i.set(rest);\n }\n\n return provide(context,\n fallback !== undefined\n ? Runtime.createElement(Runtime.Suspense, { fallback, name }, children)\n : children\n );\n}\n\nexport { Consumer, Provider, Context, provide };\n"],"mappings":";;;AAIA,MAAa,UAAU,EAAE;;;;;;;AA+BzB,SAAgB,QACd,UACA;CACA,MAAM,EAAE,YAAY,QAAQ,OAC1B,EAAE,UAAU,GAAG,CAQhB;AAED,SAAQ,SAAS,QAAQ,eAAe;AACtC,MAAI,CAAC,QAAQ,SACX,SAAQ,UAAU,UAAU,SAAS;AACnC,WAAQ,SAAS;AACjB,OAAI,QAAQ,QAAS,SAAQ,UAAU,MAAM,IAAI,EAAE;YAC1C,QAAQ,OAAQ,SAAQ,UAAU;IAC3C;AAEJ,SAAO,QAAQ;GACf,CAAC;AAEH,SAAQ,gBAAgB;AACtB,UAAQ,UAAU;AAClB,MAAI,QAAQ,SAAS;AACnB,WAAQ,UAAU;AAClB,WAAQ,QAAS,MAAM,IAAI,EAAE;;AAE/B,eAAa;AACX,OAAI,EAAE,QAAQ,WAAW,EAAG,SAAQ,SAAS;;IAE9C,EAAE,CAAC;AAEN,QAAO,QAAQ;;;AAIjB,SAAgB,IAAsB,SAAY;CAChD,MAAM,EAAE,YAAY,QAAQ,OAKzB;EAAE,SAAS;EAAG,OAAO;EAAS,CAAC;CAElC,MAAM,SAAS,QAAQ,eAAe,QAAQ,UAAU,CAAC;AAEzD,KAAI,QAAQ,WAAW,SAAS;EAC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AAQ,QAAQ,CAAC;AACzB,eAAa,QAAQ,KAAK;GAC1B;AAEF,SAAQ,IAAI,OAAO,GAAG;AAEtB,KAAI,OAAO,KAAK,KAAK,CAAC,QAAQ;EAC5B,MAAM,IAAIA,QAAM,GAAG,MAAM,GAAG,QAAQ,IAAI,MAAM,GAAG;AACjD,MAAI,aAAaA,QAAO,GAAE,IAAI,KAAK;;AAGrC,QAAO,QAAQ,SACb,aAAa,SACT,QAAQ,cAAc,QAAQ,UAAU;EAAE;EAAU;EAAM,EAAE,SAAS,GACrE,SACL"}
|
|
1
|
+
{"version":3,"file":"adapter.js","names":["Context","State"],"sources":["../src/runtime.ts","../src/state.get.ts","../src/state.use.ts","../src/context.ts","../src/component.ts"],"sourcesContent":["import { event, watch, observer } from '@expressive/mvc';\nimport type { Component } from '@expressive/mvc';\nimport type { Context } from './context';\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 /** Per-render-attempt lifecycle, set by each adapter (React stacks attempts; others no-op). */\n dedupe(from: Component, context: Context): { commit(): void; remove(): void };\n /** Host error-boundary component, wrapping a Component whose `catch` is set. */\n ErrorBoundary: unknown;\n Suspense: any;\n};\n\nexport function useFactory<T extends Function>(factory: () => T) {\n const ref = Runtime.useRef<T | null>(null);\n return ref.current || (ref.current = factory());\n}\n\nexport function useReady<T>(callback: () => void) {\n return Runtime.useEffect(() => void callback(), []);\n}\n\n/**\n * Mount-effect with a refreshable return value, safe under React StrictMode.\n *\n * @param callback Setup handler; receives a setter, must return a cleanup.\n * @returns Latest value published via the setter (`undefined` until set).\n */\nexport function useHook<T = void>(\n callback: (refresh: (next: T) => void) => () => void\n) {\n const { current } = Runtime.useRef(\n { rendered: 0 } as {\n rendered: number;\n mounted?: boolean;\n pending?: boolean;\n unmount: () => void;\n update?: (next: (previous: number) => number) => void;\n output: T;\n }\n );\n\n current.update = Runtime.useState(() => {\n if (!current.rendered)\n current.unmount = callback((next) => {\n current.output = next;\n if (current.mounted) current.update?.((x) => x + 1);\n else if (current.update) current.pending = true;\n });\n\n return current.rendered++;\n })[1];\n\n Runtime.useEffect(() => {\n current.mounted = true;\n if (current.pending) {\n current.pending = false;\n current.update!((x) => x + 1);\n }\n return () => {\n if (--current.rendered < 1) current.unmount();\n }\n }, []);\n\n return current.output;\n}\n\n/** Subscribe to an existing observable instance within a component. */\nexport function use<T extends object>(subject: T) {\n const { current } = Runtime.useRef<{\n proxy: T;\n source?: T;\n mounted: number;\n unwatch?: () => void;\n }>({ mounted: 0, proxy: subject });\n\n const update = Runtime.useState(() => current.mounted++)[1];\n\n if (current.source !== subject) {\n const status = observer(subject);\n\n if (status === undefined)\n throw new Error('Provided object is not observable.');\n\n current.unwatch?.();\n current.source = subject;\n\n if (status === null) {\n current.unwatch = undefined;\n current.proxy = subject;\n } else {\n if (!status.ready) event(subject);\n\n let init = true;\n\n current.unwatch = watch(subject, (next, changed) => {\n current.proxy = next;\n if (changed.length && !init)\n update((x) => x + 1);\n });\n\n init = false;\n }\n }\n\n Runtime.useEffect(() => () => {\n if (--current.mounted < 1) current.unwatch?.();\n }, []);\n\n return current.proxy;\n}\n","import { State, Context, observer, watch } from '@expressive/mvc';\nimport { Runtime, useFactory, useHook, useReady } 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 State {\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 State, R> = (\n this: T,\n current: T,\n refresh: ForceRefresh\n ) => R;\n\n type GetEffect<T extends State> = (\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 State>(this: State.Extends<T>): T;\n\n /** Fetch instance of this class optionally. */\n function get<T extends State>(\n this: State.Extends<T>,\n required: false\n ): T | undefined;\n\n /** Fetch instance of this class from context. */\n function get<T extends State>(\n this: State.Extends<T>,\n requireValues: true\n ): Required<T>;\n\n function get<T extends State, R>(\n this: State.Extends<T>,\n factory: GetFactory<T, Promise<R> | R>\n ): NoVoid<R>;\n\n function get<T extends State>(\n this: State.Extends<T>,\n factory: GetEffect<T>\n ): null;\n }\n}\n\nState.get = function get<T extends State>(\n this: State.Extends<T>,\n argument?: boolean | State.GetFactory<T, unknown>\n) {\n const next = Runtime.useState(0)[1];\n const local = Context.get();\n const render = useFactory(() => {\n let unwatch: (() => void) | undefined;\n let mounted = false;\n let pending = false;\n let value: any;\n\n function update() {\n pending = false;\n next((x) => x + 1);\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 unsubscribe();\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 release;\n }\n\n unwatch = watch(\n next,\n (current, changed) => {\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 (changed.length) update();\n },\n argument === true\n );\n\n if (mounted) {\n pending = true;\n queueMicrotask(() => pending && update());\n }\n\n return release;\n }\n\n const unsubscribe = local.get(this, attach);\n\n if (!unwatch) {\n unsubscribe();\n if (argument === false) return () => undefined;\n throw new Error(`Could not find ${this} 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 pending = false;\n useReady(() => mounted = true);\n useHook(() => release);\n return value === undefined ? null : value;\n };\n });\n\n return render();\n};\n","import { State, Context, watch } from '@expressive/mvc';\nimport { useFactory, useHook, useReady } from './runtime';\n\ndeclare module '@expressive/mvc' {\n interface UseState extends State {\n /**\n * Optional hook called when State.use() is invoked within a React component.\n *\n * This is called *every render* of the component, and will intercept\n * arguments which would otherwise be passed into the State constructor.\n *\n * @param props Arguments passed to State.use().\n */\n use?(...props: any[]): Promise<void> | void;\n }\n\n namespace State {\n type UseArgs<T extends State> = T extends {\n use(...props: infer P): any;\n }\n ? P\n : State.Args<T>;\n\n /**\n * Create and manage instance of this State within React component.\n *\n * @param args Arguments to pass to constructor or `use` method (if defined).\n * @returns Managed instance of this State.\n */\n function use<T extends UseState>(\n this: State.Type<T>,\n ...args: UseArgs<T>\n ): T;\n }\n}\n\nState.use = function use<T extends State>(\n this: State.Type<T>,\n ...args: State.UseArgs<T>\n) {\n const outer = Context.get();\n const render = useFactory(() => {\n const add = (arg: unknown) =>\n typeof arg == 'object' && instance.set(arg as State.Assign<T>);\n\n let use = (...args: State.Args<T>) => Promise.all(args.flat().map(add));\n\n const instance = new this((x) => {\n if ('use' in x && typeof x.use == 'function') {\n use = x.use.bind(x);\n use(...args);\n }\n else return args;\n });\n\n const context = outer.push(instance);\n\n let ready = false;\n\n return (args: State.Args<T>) => {\n if (ready) {\n ready = false;\n Promise.resolve(use(...args)).finally(() => {\n ready = true;\n });\n }\n\n useReady(() => ready = true);\n\n return useHook<T>((update) => {\n watch(instance, update);\n return () => {\n context.pop();\n instance.set(null);\n };\n });\n };\n });\n\n return render(args);\n};\n","import { State, Context, Component } from '@expressive/mvc';\nimport { Runtime, useHook } 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 provide(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?: State) => {\n if (!state)\n try {\n return useAmbient();\n } catch { }\n\n return _get(state);\n};\n\ndeclare namespace Consumer {\n type Props<T extends State> = {\n /** Type of controller to fetch from context. */\n for: State.Extends<T>;\n\n /**\n * Render function, will receive instance of desired controller.\n *\n * Called every render of parent component.\n * Similar to `State.get()`, updates to properties accessed in\n * this function will cause a refresh when they change.\n */\n children: (value: T) => Component.Node | void;\n };\n}\n\nfunction Consumer<T extends State>(props: Consumer.Props<T>) {\n return props.for.get((i) => props.children(i));\n}\n\ndeclare namespace Provider {\n type ForEach<T> = (state: T) => void | (() => void);\n\n interface SharedProps {\n /**\n * Children to render within this Provider.\n */\n children?: Component.Node;\n\n /** A fallback tree to show when suspended. */\n fallback?: Component.Node;\n\n /**\n * A name for this Suspense boundary for instrumentation purposes.\n * The name will help identify this boundary in React DevTools.\n */\n name?: string | undefined;\n }\n\n type ForSingleProps<T extends State> = SharedProps & {\n for: T | State.Type<T>;\n is: (instance: T) => void;\n } & { [K in State.Field<T>]?: T[K] };\n\n type ForMultipleProps<T extends State> = SharedProps & {\n for: Context.Accept<T>;\n is?: ForEach<T>;\n };\n\n type Props<T extends State = State> = ForSingleProps<T> | ForMultipleProps<T>;\n}\n\nfunction Provider<T extends State>(props: Provider.Props<T>) {\n const {\n for: input,\n children,\n fallback,\n name,\n is,\n ...rest\n } = props as Provider.ForSingleProps<T> & Provider.ForMultipleProps<T>;\n\n const ambient = useAmbient();\n const context = useHook<Context>((set) => {\n set(new Context(ambient));\n return () => context.pop();\n });\n\n context.set(input, is);\n\n if (Object.keys(rest).length) {\n const i = State.is(input) ? context.get(input) : input;\n if (i instanceof State) i.set(rest);\n }\n\n return provide(context,\n fallback !== undefined\n ? Runtime.createElement(Runtime.Suspense, { fallback, name }, children)\n : children\n );\n}\n\nexport { Consumer, Provider, Context, provide };\n","import { Component, watch, unbind, observer } from '@expressive/mvc';\nimport { provide, type Context } from './context';\nimport { Runtime, useHook, useReady } from './runtime';\n\ndeclare module '@expressive/mvc' {\n interface Component {\n /** @deprecated Only to satisfy host JSX. Use `this.get(State)` instead. */\n readonly context: Context;\n /** @deprecated Only to satisfy host JSX. Use `this.get()` instead. */\n readonly state: State.Values<this>;\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 * `State.on` handler that prepares a Component's prototype at bootstrap, before\n * mvc classifies its members:\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 * - capitalized methods are rewritten into subcomponents as non-configurable\n * getters, so bootstrap skips them too.\n *\n * (Sealing `render` as the content-render seam is handled by core itself.)\n *\n * `before` covers the per-instance case: a capitalized function assigned as an\n * instance field (e.g. `Sidebar = Sidebar` to inject or override one), promoted\n * before `observe` so it is not mistaken for reactive state.\n */\nComponent.on({\n type(type) {\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 // capitalized methods into subcomponents\n subcomponents(type.prototype);\n },\n before(self){\n // capitalized instance fields into subcomponents\n subcomponents(self, true);\n }\n});\n\nfunction bootstrap(this: Component, context: Context){\n context = context.push();\n context.set(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 * Per-instance render host: subscribe the instance, render inside its context\n * provider, wrap pending in Suspense and (when `catch` is set) the host error\n * boundary. Host differences live behind `Runtime.dedupe`/`Runtime.ErrorBoundary`.\n */\nfunction render(from: Component, context: Context) {\n const { createElement: create } = Runtime;\n const { commit, remove } = Runtime.dedupe(from, context);\n\n const content = from.render;\n const Render = () => content.call(from, from.props);\n const Component = () => {\n from = useHook<Component>((refresh) => {\n if (observer(from) !== null)\n watch(from, refresh);\n return () => {\n remove();\n context.pop();\n };\n }) || from;\n\n useReady(commit);\n\n const rendered = create(Render);\n const children = provide(context,\n from.fallback === false\n ? rendered\n : create(Runtime.Suspense,\n { fallback: from.fallback, name: String(from) },\n rendered)\n );\n\n return from.catch\n ? create(Runtime.ErrorBoundary, { self: from, children })\n : children;\n };\n\n return () => create(Component);\n}\n\n/** Rewrite each own capitalized function on `target` into a subcomponent. */\nfunction subcomponents(target: object, configurable?: boolean) {\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,\n get(this: Component) {\n const owner = this.is;\n let render = unbind(value);\n const Component = (props: unknown) =>\n render.call(\n useHook<Component>((set) => watch(owner, set)) || owner,\n props\n );\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 });\n }\n}\n"],"mappings":";;;AAIA,MAAa,UAAU,EAAE;AAgBzB,SAAgB,WAA+B,SAAkB;CAC/D,MAAM,MAAM,QAAQ,OAAiB,KAAK;AAC1C,QAAO,IAAI,YAAY,IAAI,UAAU,SAAS;;AAGhD,SAAgB,SAAY,UAAsB;AAChD,QAAO,QAAQ,gBAAgB,KAAK,UAAU,EAAE,EAAE,CAAC;;;;;;;;AASrD,SAAgB,QACd,UACA;CACA,MAAM,EAAE,YAAY,QAAQ,OAC1B,EAAE,UAAU,GAAG,CAQhB;AAED,SAAQ,SAAS,QAAQ,eAAe;AACtC,MAAI,CAAC,QAAQ,SACX,SAAQ,UAAU,UAAU,SAAS;AACnC,WAAQ,SAAS;AACjB,OAAI,QAAQ,QAAS,SAAQ,UAAU,MAAM,IAAI,EAAE;YAC1C,QAAQ,OAAQ,SAAQ,UAAU;IAC3C;AAEJ,SAAO,QAAQ;GACf,CAAC;AAEH,SAAQ,gBAAgB;AACtB,UAAQ,UAAU;AAClB,MAAI,QAAQ,SAAS;AACnB,WAAQ,UAAU;AAClB,WAAQ,QAAS,MAAM,IAAI,EAAE;;AAE/B,eAAa;AACX,OAAI,EAAE,QAAQ,WAAW,EAAG,SAAQ,SAAS;;IAE9C,EAAE,CAAC;AAEN,QAAO,QAAQ;;;AAIjB,SAAgB,IAAsB,SAAY;CAChD,MAAM,EAAE,YAAY,QAAQ,OAKzB;EAAE,SAAS;EAAG,OAAO;EAAS,CAAC;CAElC,MAAM,SAAS,QAAQ,eAAe,QAAQ,UAAU,CAAC;AAEzD,KAAI,QAAQ,WAAW,SAAS;EAC9B,MAAM,SAAS,SAAS,QAAQ;AAEhC,MAAI,WAAW,O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W,QAAQ,SACvB,KAAK,aAAa,QACd,WACA,OAAO,QAAQ,UACf;GAAE,UAAU,KAAK;GAAU,MAAM,OAAO,KAAK;GAAE,EAC/C,SAAS,CACd;AAED,SAAO,KAAK,QACR,OAAO,QAAQ,eAAe;GAAE,MAAM;GAAM;GAAU,CAAC,GACvD;;AAGN,cAAa,OAAO,UAAU;;;AAIhC,SAAS,cAAc,QAAgB,cAAwB;AAC7D,MAAK,MAAM,OAAO,OAAO,oBAAoB,OAAO,EAAE;AACpD,MAAI,CAAC,SAAS,KAAK,IAAI,CAAE;EACzB,MAAM,EAAE,UAAU,OAAO,yBAAyB,QAAQ,IAAI;AAC9D,MAAI,OAAO,SAAS,WAAY;AAChC,SAAO,eAAe,QAAQ,KAAK;GACjC;GACA,MAAqB;IACnB,MAAM,QAAQ,KAAK;IACnB,IAAI,SAAS,OAAO,MAAM;IAC1B,MAAM,aAAa,UACjB,OAAO,KACL,SAAoB,QAAQ,MAAM,OAAO,IAAI,CAAC,IAAI,OAClD,MACD;AAEH,WAAO,eAAe,OAAO,KAAK;KAChC,cAAc;KACd,WAAW;KACX,IAAI,IAAc;AAChB,eAAS;;KAEZ,CAAC;AAEF,WAAO;;GAEV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressive/react",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.1",
|
|
4
4
|
"description": "Use classes to define state in React!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expressive",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"sideEffects": [
|
|
25
25
|
"./dist/index.js",
|
|
26
26
|
"./dist/adapter.js",
|
|
27
|
-
"./src/jsx-runtime.ts"
|
|
27
|
+
"./src/jsx-runtime.ts",
|
|
28
|
+
"./src/state.get.ts",
|
|
29
|
+
"./src/state.use.ts",
|
|
30
|
+
"./src/component.ts"
|
|
28
31
|
],
|
|
29
32
|
"main": "dist/index.js",
|
|
30
33
|
"types": "dist/index.d.ts",
|