@atom.io/spa 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -138
- package/README.mdx +62 -26
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-client.d.ts +3 -2
- package/dist/astro-client.d.ts.map +1 -1
- package/dist/astro-client.js +11 -10
- package/dist/astro-client.js.map +1 -1
- package/dist/astro-resumability-client.d.ts +10 -0
- package/dist/astro-resumability-client.d.ts.map +1 -0
- package/dist/astro-resumability-client.js +29 -0
- package/dist/astro-resumability-client.js.map +1 -0
- package/dist/astro-resumability-server.d.ts +3 -0
- package/dist/astro-resumability-server.d.ts.map +1 -0
- package/dist/astro-resumability-server.js +7 -0
- package/dist/astro-resumability-server.js.map +1 -0
- package/dist/astro-server.d.ts +3 -2
- package/dist/astro-server.d.ts.map +1 -1
- package/dist/astro-server.js +28 -9
- package/dist/astro-server.js.map +1 -1
- package/dist/{astro-shared-BT45auwR.js → astro-shared-83hxw7-M.js} +4 -2
- package/dist/astro-shared-83hxw7-M.js.map +1 -0
- package/dist/{astro-shared-BkWvVZWZ.d.ts → astro-shared-DHIpjNIG.d.ts} +2 -2
- package/dist/{astro-shared-BkWvVZWZ.d.ts.map → astro-shared-DHIpjNIG.d.ts.map} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +5 -7
- package/dist/astro.js.map +1 -1
- package/dist/{capabilities-CFP-HIuY.d.ts → capabilities-BCtBG-ni.d.ts} +19 -14
- package/dist/capabilities-BCtBG-ni.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/{core-DCmqLZQP.js → core-DjFJ0aIJ.js} +31 -23
- package/dist/core-DjFJ0aIJ.js.map +1 -0
- package/dist/development/astro-client.js +11 -10
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/astro-resumability-client.js +29 -0
- package/dist/development/astro-resumability-client.js.map +1 -0
- package/dist/development/astro-resumability-server.js +7 -0
- package/dist/development/astro-resumability-server.js.map +1 -0
- package/dist/development/astro-server.js +28 -9
- package/dist/development/astro-server.js.map +1 -1
- package/dist/development/{astro-shared-BT45auwR.js → astro-shared-83hxw7-M.js} +4 -2
- package/dist/development/astro-shared-83hxw7-M.js.map +1 -0
- package/dist/development/astro.js +5 -7
- package/dist/development/astro.js.map +1 -1
- package/dist/development/{core-p9vciX9C.js → core-DxPiKryn.js} +31 -23
- package/dist/development/core-DxPiKryn.js.map +1 -0
- package/dist/development/{dom-Ci1XvbVJ.js → dom-BytVV6Rp.js} +44 -12
- package/dist/development/dom-BytVV6Rp.js.map +1 -0
- package/dist/development/index.js +4 -4
- package/dist/development/jsx-runtime.js.map +1 -1
- package/dist/development/konva.js +1 -1
- package/dist/development/konva.js.map +1 -1
- package/dist/development/motion.js +1 -1
- package/dist/development/renderer.js +1 -1
- package/dist/development/renderer.js.map +1 -1
- package/dist/development/server-renderer-CUQXh9oF.js +90 -0
- package/dist/development/server-renderer-CUQXh9oF.js.map +1 -0
- package/dist/development/server.js +2 -83
- package/dist/development/server.js.map +1 -1
- package/dist/{src-DCQa6qxs.js → development/src-WSHJxR9b.js} +4 -4
- package/dist/development/src-WSHJxR9b.js.map +1 -0
- package/dist/development/three.js +1 -1
- package/dist/development/three.js.map +1 -1
- package/dist/{dom-dHQM0O7Q.js → dom-B5OxgHkr.js} +44 -12
- package/dist/dom-B5OxgHkr.js.map +1 -0
- package/dist/{index-CJJXcKaw.d.ts → index-DufwkB6W.d.ts} +5 -5
- package/dist/{index-CJJXcKaw.d.ts.map → index-DufwkB6W.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{jsx-runtime-CREZYKDC.d.ts → jsx-runtime-DMDVr7A5.d.ts} +7 -7
- package/dist/{jsx-runtime-CREZYKDC.d.ts.map → jsx-runtime-DMDVr7A5.d.ts.map} +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/konva.d.ts +16 -16
- package/dist/konva.js +1 -1
- package/dist/konva.js.map +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +1 -1
- package/dist/renderer.d.ts +4 -4
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +1 -1
- package/dist/renderer.js.map +1 -1
- package/dist/server-renderer-DcU55e6s.js +90 -0
- package/dist/server-renderer-DcU55e6s.js.map +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -83
- package/dist/server.js.map +1 -1
- package/dist/size.json +16 -16
- package/dist/{development/src-DG0xjuS5.js → src-DWIqXCiz.js} +4 -4
- package/dist/src-DWIqXCiz.js.map +1 -0
- package/dist/three.d.ts +17 -17
- package/dist/three.js +1 -1
- package/dist/three.js.map +1 -1
- package/package.json +27 -11
- package/src/astro-client.ts +20 -7
- package/src/astro-resumability-client.ts +40 -0
- package/src/astro-resumability-server.ts +7 -0
- package/src/astro-server.ts +58 -19
- package/src/astro-shared.ts +5 -2
- package/src/astro.ts +11 -3
- package/src/core.ts +54 -49
- package/src/dom.ts +73 -39
- package/src/index.ts +4 -4
- package/src/jsx-runtime.ts +7 -6
- package/src/jsx-types.d.ts +2 -2
- package/src/konva.ts +3 -3
- package/src/renderer.ts +24 -18
- package/src/server-renderer.ts +162 -0
- package/src/server.ts +4 -153
- package/src/three.ts +4 -4
- package/src/use-loadable.ts +3 -3
- package/dist/astro-shared-BT45auwR.js.map +0 -1
- package/dist/capabilities-CFP-HIuY.d.ts.map +0 -1
- package/dist/core-DCmqLZQP.js.map +0 -1
- package/dist/development/astro-shared-BT45auwR.js.map +0 -1
- package/dist/development/core-p9vciX9C.js.map +0 -1
- package/dist/development/dom-Ci1XvbVJ.js.map +0 -1
- package/dist/development/src-DG0xjuS5.js.map +0 -1
- package/dist/dom-dHQM0O7Q.js.map +0 -1
- package/dist/src-DCQa6qxs.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMPLICIT, actUponStore, clearTimelineInStore, findInStore, findTimelineInStore, getFromStore, getTimelineTransactionAtHead,
|
|
1
|
+
import { IMPLICIT, actUponStore, clearTimelineInStore, findInStore, findTimelineInStore, getFromStore, getTimelineTransactionAtHead, setIntoStore, subscribeToState, subscribeToTimeline, timeTravel, timeTravelTransactionGroupInStore, withdraw } from "atom.io/internal";
|
|
2
2
|
// src/core.ts
|
|
3
3
|
let owner;
|
|
4
4
|
let tracking;
|
|
@@ -169,12 +169,14 @@ function resolveStateToken(token, key) {
|
|
|
169
169
|
const store = owner._root._store;
|
|
170
170
|
return token.type.endsWith(`_family`) ? findInStore(store, token, key) : token;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function useGetter(token, key) {
|
|
173
173
|
token = resolveStateToken(token, key);
|
|
174
|
-
const
|
|
174
|
+
const root = owner._root;
|
|
175
|
+
const store = root._store;
|
|
175
176
|
const subscribe = (notify) => subscribeToState(store, token, `spa:${serial++}`, notify);
|
|
176
177
|
return () => {
|
|
177
178
|
const value = getFromStore(store, token);
|
|
179
|
+
root._onRead?.(value, token);
|
|
178
180
|
tracking?.(subscribe);
|
|
179
181
|
return value;
|
|
180
182
|
};
|
|
@@ -211,30 +213,36 @@ function useRef(token, key) {
|
|
|
211
213
|
}
|
|
212
214
|
function useTimeline(token, key) {
|
|
213
215
|
const store = owner._root._store;
|
|
214
|
-
|
|
215
|
-
const subscribe = (notify) => subscribeToTimeline(store,
|
|
216
|
-
const
|
|
216
|
+
const selected = token.type === `timeline_family` ? findTimelineInStore(store, token, key) : token;
|
|
217
|
+
const subscribe = (notify) => subscribeToTimeline(store, selected, `spa:${serial++}`, notify);
|
|
218
|
+
const read = () => {
|
|
219
|
+
const timeline = withdraw(store, selected);
|
|
220
|
+
tracking?.(subscribe);
|
|
221
|
+
return timeline;
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
getCursor: () => read().at,
|
|
225
|
+
getLength: () => read().history.length,
|
|
217
226
|
undo: () => {
|
|
218
|
-
timeTravel(store, `undo`,
|
|
227
|
+
timeTravel(store, `undo`, selected);
|
|
219
228
|
},
|
|
220
229
|
redo: () => {
|
|
221
|
-
timeTravel(store, `redo`,
|
|
230
|
+
timeTravel(store, `redo`, selected);
|
|
222
231
|
},
|
|
223
232
|
clear: () => {
|
|
224
|
-
clearTimelineInStore(store,
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
clearTimelineInStore(store, selected);
|
|
234
|
+
},
|
|
235
|
+
getTransaction: () => {
|
|
236
|
+
const timeline = read();
|
|
237
|
+
const controls = {};
|
|
238
|
+
for (const direction of [`undo`, `redo`]) {
|
|
239
|
+
const group = getTimelineTransactionAtHead(timeline, direction);
|
|
240
|
+
if (group) controls[direction] = () => {
|
|
241
|
+
timeTravelTransactionGroupInStore(store, direction, group);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return controls;
|
|
236
245
|
}
|
|
237
|
-
return value;
|
|
238
246
|
};
|
|
239
247
|
}
|
|
240
248
|
function plain(value) {
|
|
@@ -248,6 +256,6 @@ function isPresent(scope) {
|
|
|
248
256
|
for (let at = scope; at; at = at._parent) if (at._dead || at._exiting) return false;
|
|
249
257
|
return true;
|
|
250
258
|
}
|
|
251
|
-
export {
|
|
259
|
+
export { useSetter as _, invalidate as a, useTransaction as b, onCleanup as c, plain as d, resolveStateToken as f, useRef as g, useId as h, fail as i, onMount as l, useGetter as m, createScope as n, isPresent as o, untrack as p, dispose as r, observe as s, createRoot as t, owner as u, useStore as v, within as x, useTimeline as y };
|
|
252
260
|
|
|
253
|
-
//# sourceMappingURL=core-
|
|
261
|
+
//# sourceMappingURL=core-DxPiKryn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-DxPiKryn.js","names":[],"sources":["../../src/core.ts"],"sourcesContent":["import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSetter,\n\tTimelineFamilyToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tViewOf,\n\tWritableFamilyToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/foundations/canonical\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tclearTimelineInStore,\n\tfindInStore,\n\tfindTimelineInStore,\n\tgetFromStore,\n\tgetTimelineTransactionAtHead,\n\tIMPLICIT,\n\tsetIntoStore,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\ttimeTravel,\n\ttimeTravelTransactionGroupInStore,\n\twithdraw,\n} from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\nimport type {\n\tExitParticipant,\n\tPresenceCoordinator,\n\tPresenceTarget,\n} from \"./presence.ts\"\n\nexport type Cleanup = () => void\n// A callable interface permits the recursive Children union. A type alias does not.\n/* oxlint-disable typescript/prefer-function-type -- A callable interface is required for recursive Children. */\nexport interface Accessor<T> {\n\t(): T\n}\n/* oxlint-enable typescript/prefer-function-type */\nexport type Component<P = any> = (props: P) => Children\n/** A JSX descriptor for an intrinsic tag, component, or fragment. */\nexport interface SpaElement {\n\ttype: string | Component | null\n\tprops: Record<string, any>\n}\n/** Renderable content, including nested groups and reactive accessors. */\nexport type Children =\n\t| SpaElement\n\t| string\n\t| number\n\t| bigint\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Children[]\n\t| Accessor<Children>\nexport interface RootOptions {\n\tcapabilities?: readonly Capability[]\n\tstore?: RootStore\n\tidPrefix?: string\n\tonError?: (error: unknown) => void\n}\nexport interface Scope {\n\t_exiting?: boolean\n\t_exits?: Set<ExitParticipant>\n\t_targets?: Set<PresenceTarget>\n\t_root: Root\n\t_parent?: Scope | undefined\n\t_cleanups: Set<Cleanup | Scope>\n\t_updates: Cleanup[]\n\t_dead: boolean\n}\nexport interface Root extends Scope {\n\t_onRead?: ((value: unknown, token: ReadableToken<unknown>) => void) | undefined\n\t_presence?: PresenceCoordinator\n\t_capabilities: Map<string, Capability>\n\t_store: RootStore\n\t_prefix: string\n\t_id: number\n\t_queue: Set<Cleanup>\n\t_mounts: Cleanup[] | undefined\n\tflush: Cleanup\n\terror: (error: unknown) => void\n}\n\nexport let owner: Scope | undefined\ntype Subscribe = (notify: Cleanup) => Cleanup\nlet tracking: ((subscribe: Subscribe) => void) | undefined\nlet serial = 0\n\nexport function within<T>(scope: Scope, run: () => T): T {\n\tconst previous = owner\n\towner = scope\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\towner = previous\n\t}\n}\nexport function untrack<T>(run: () => T): T {\n\tconst previous = tracking\n\ttracking = undefined\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\ttracking = previous\n\t}\n}\nexport function createScope(parent?: Scope): Scope {\n\tconst child: Scope = {\n\t\t_root: parent?._root as Root,\n\t\t_parent: parent,\n\t\t_cleanups: new Set(),\n\t\t_updates: [],\n\t\t_dead: false,\n\t}\n\tparent?._cleanups.add(child)\n\treturn child\n}\nexport function fail(scope: Scope, error: unknown): never {\n\ttry {\n\t\tdispose(scope)\n\t} catch (cleanup) {\n\t\tthrow new AggregateError([error, cleanup])\n\t}\n\tthrow error\n}\nexport function dispose(scope: Scope): void {\n\tif (scope._dead) return\n\tscope._dead = true\n\tconst errors: unknown[] = []\n\ttry {\n\t\tscope._root._presence?.forget(scope)\n\t} catch (error) {\n\t\terrors.push(error)\n\t}\n\tfor (const cleanup of [...scope._cleanups].reverse()) {\n\t\ttry {\n\t\t\ttypeof cleanup === `function` ? cleanup() : dispose(cleanup)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tscope._parent?._cleanups.delete(scope)\n\tscope._cleanups.clear()\n\tscope._updates.length = 0\n\tif (errors.length) throw new AggregateError(errors)\n}\nexport function invalidate(scope: Scope): void {\n\tfor (const run of scope._updates) enqueue(scope, run)\n\tfor (const child of scope._cleanups)\n\t\tif (typeof child !== `function`) invalidate(child)\n}\nfunction enqueue(scope: Scope, run: Cleanup): void {\n\tif (!isPresent(scope)) return\n\tconst root = scope._root\n\tif (!root._queue.size)\n\t\tqueueMicrotask(() => {\n\t\t\ttry {\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\troot.error(error)\n\t\t\t}\n\t\t})\n\troot._queue.add(run)\n}\nexport function createRoot(options: RootOptions = {}, server = false): Root {\n\tconst capabilities = new Map<string, Capability>()\n\tfor (const capability of options.capabilities ?? []) {\n\t\tif (capabilities.has(capability.namespace))\n\t\t\tthrow new Error(`spa: duplicate capability ${capability.namespace}`)\n\t\tcapabilities.set(capability.namespace, capability)\n\t}\n\tconst root = {\n\t\t_capabilities: capabilities,\n\t\t_store: options.store ?? IMPLICIT.STORE,\n\t\t_prefix: options.idPrefix ?? `w${serial++}`,\n\t\t_id: 0,\n\t\t...createScope(),\n\t\t_queue: new Set(),\n\t\t_mounts: server ? undefined : [],\n\t} as unknown as Root\n\troot._root = root\n\troot.error =\n\t\toptions.onError ??\n\t\t((error) => {\n\t\t\tthrow error\n\t\t})\n\tfor (const capability of capabilities.values())\n\t\tif (capability.presence) {\n\t\t\tif (root._presence) throw new Error(`spa: multiple presence coordinators`)\n\t\t\troot._presence = capability.presence(root)\n\t\t}\n\troot.flush = () => {\n\t\ttry {\n\t\t\tlet passes = 0\n\t\t\twhile (root._queue.size || root._mounts!.length) {\n\t\t\t\tif (import.meta.env.DEV && ++passes > 100)\n\t\t\t\t\tthrow new Error(`spa: update loop`)\n\t\t\t\tfor (const run of [...root._queue]) if (root._queue.delete(run)) run()\n\t\t\t\tfor (const run of root._mounts!.splice(0)) run()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(root, error)\n\t\t}\n\t}\n\treturn root\n}\n/** Return the atom.io store selected by the current root. */\nexport function useStore(): RootStore {\n\treturn owner!._root._store\n}\nexport function onCleanup(cleanup: Cleanup): void {\n\towner!._cleanups.add(cleanup)\n}\nexport function onMount(run: Cleanup): void {\n\tconst scope = owner!\n\tscope._root._mounts?.push(() => {\n\t\tif (!scope._dead)\n\t\t\twithin(scope, () => {\n\t\t\t\tuntrack(run)\n\t\t\t})\n\t})\n}\nexport function useId(): string {\n\tconst root = owner!._root\n\treturn `${root._prefix}-${root._id++}`\n}\n\nexport function observe<T>(\n\tscope: Scope,\n\tread: Accessor<T>,\n\tapply: (value: T) => void,\n): void {\n\tconst subscriptions = new Map<Subscribe, Cleanup>()\n\tconst run = () => {\n\t\tif (!isPresent(scope)) return\n\t\tconst used = new Set<Subscribe>()\n\t\tconst previous = tracking\n\t\ttracking = (subscribe) => {\n\t\t\tused.add(subscribe)\n\t\t\tif (!subscriptions.has(subscribe))\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tsubscribe,\n\t\t\t\t\tsubscribe(() => {\n\t\t\t\t\t\tenqueue(scope, run)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t}\n\t\tlet value: T\n\t\ttry {\n\t\t\tvalue = within(scope, read)\n\t\t} finally {\n\t\t\ttracking = previous\n\t\t\tfor (const [subscribe, unsubscribe] of subscriptions)\n\t\t\t\tif (!used.has(subscribe)) {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tsubscriptions.delete(subscribe)\n\t\t\t\t}\n\t\t}\n\t\tuntrack(() => {\n\t\t\tapply(value)\n\t\t})\n\t}\n\tscope._updates.push(run)\n\tscope._cleanups.add(() => {\n\t\tscope._root._queue.delete(run)\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t})\n\trun()\n}\n\n/** Resolve a fixed family key in the current owner's store. */\nexport function resolveStateToken(token: any, key?: Canonical): any {\n\tconst store = owner!._root._store\n\treturn token.type.endsWith(`_family`) ? findInStore(store, token, key!) : token\n}\n\n/** Capture a token for this instance. Change the component key to change its token. */\nexport function useGetter<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): Accessor<ViewOf<T | E>>\nexport function useGetter<T, K extends Canonical, E = never>(\n\tfamily: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): Accessor<ViewOf<T | E>>\nexport function useGetter(token: any, key?: Canonical): Accessor<any> {\n\ttoken = resolveStateToken(token, key)\n\tconst root = owner!._root\n\tconst store = root._store\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToState(store, token, `spa:${serial++}`, notify)\n\treturn () => {\n\t\tconst value = getFromStore(store, token)\n\t\troot._onRead?.(value, token)\n\t\ttracking?.(subscribe)\n\t\treturn value\n\t}\n}\nexport function useSetter<T>(\n\ttoken: WritableToken<T, any, any>,\n): (value: T | Setter<T>) => void\nexport function useSetter<T, K extends Canonical>(\n\tfamily: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n): (value: T | Setter<T>) => void\nexport function useSetter(token: any, key?: Canonical): (value: any) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\treturn (value) => {\n\t\tsetIntoStore(store, token, value)\n\t}\n}\nexport function useTransaction<F extends (...args: any[]) => any>(\n\ttoken: TransactionToken<F>,\n): (...args: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(owner!._root._store, token, `spa:${serial++}`)\n}\n\nconst refs = new WeakMap<RootStore, Map<string, object>>()\nexport function useRef<E extends Element>(\n\ttoken: RegularAtomToken<E | null>,\n): (element: E | null) => void\nexport function useRef<E extends Element, K extends Canonical>(\n\tfamily: RegularAtomFamilyToken<E | null, K>,\n\tkey: NoInfer<K>,\n): (element: E | null) => void\nexport function useRef<E extends Element>(\n\ttoken: any,\n\tkey?: Canonical,\n): (element: E | null) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst owners = refs.get(store) ?? new Map<string, object>()\n\trefs.set(store, owners)\n\tconst identity = {}\n\tlet held: E | null = null\n\treturn (element) => {\n\t\tif (element) {\n\t\t\theld = element\n\t\t\towners.set(token.key, identity)\n\t\t\tsetIntoStore(store, token, element)\n\t\t} else if (owners.get(token.key) === identity) {\n\t\t\towners.delete(token.key)\n\t\t\tif (getFromStore(store, token) === held) setIntoStore(store, token, null)\n\t\t\theld = null\n\t\t}\n\t}\n}\nexport interface TimelineControls {\n\tgetCursor(): number\n\tgetLength(): number\n\tundo(): void\n\tredo(): void\n\tclear(): void\n\tgetTransaction(): { undo?: Cleanup; redo?: Cleanup }\n}\nexport function useTimeline<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n): TimelineControls\nexport function useTimeline<K extends Canonical, M extends TimelineManageable>(\n\tfamily: TimelineFamilyToken<K, M>,\n\tkey: NoInfer<K>,\n): TimelineControls\nexport function useTimeline(token: any, key?: Canonical): TimelineControls {\n\tconst store = owner!._root._store\n\tconst selected: TimelineToken<any> =\n\t\ttoken.type === `timeline_family`\n\t\t\t? findTimelineInStore(store, token, key!)\n\t\t\t: token\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToTimeline(store, selected, `spa:${serial++}`, notify)\n\tconst read = () => {\n\t\tconst timeline = withdraw(store, selected)\n\t\ttracking?.(subscribe)\n\t\treturn timeline\n\t}\n\treturn {\n\t\tgetCursor: () => read().at,\n\t\tgetLength: () => read().history.length,\n\t\tundo: () => {\n\t\t\ttimeTravel(store, `undo`, selected)\n\t\t},\n\t\tredo: () => {\n\t\t\ttimeTravel(store, `redo`, selected)\n\t\t},\n\t\tclear: () => {\n\t\t\tclearTimelineInStore(store, selected)\n\t\t},\n\t\tgetTransaction: () => {\n\t\t\tconst timeline = read()\n\t\t\tconst controls: ReturnType<TimelineControls[`getTransaction`]> = {}\n\t\t\tfor (const direction of [`undo`, `redo`] as const) {\n\t\t\t\tconst group = getTimelineTransactionAtHead(timeline, direction)\n\t\t\t\tif (group)\n\t\t\t\t\tcontrols[direction] = () => {\n\t\t\t\t\t\ttimeTravelTransactionGroupInStore(store, direction, group)\n\t\t\t\t\t}\n\t\t\t}\n\t\t\treturn controls\n\t\t},\n\t}\n}\n\nexport function plain(value: Children): string {\n\tif (typeof value === `function`) return plain(value())\n\tif (Array.isArray(value)) return value.map(plain).join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (import.meta.env.DEV && typeof value === `object`)\n\t\tthrow new Error(`spa: text required`)\n\t// oxlint-disable-next-line typescript/no-base-to-string -- Valid text children are primitives here; development rejects malformed object children.\n\treturn String(value)\n}\n\nexport function isPresent(scope: Scope): boolean {\n\tfor (let at: Scope | undefined = scope; at; at = at._parent)\n\t\tif (at._dead || at._exiting) return false\n\treturn true\n}\n"],"mappings":";;AA4FA,IAAW;AAEX,IAAI;AACJ,IAAI,SAAS;AAEb,SAAgB,OAAU,OAAc,KAAiB;CACxD,MAAM,WAAW;CACjB,QAAQ;CACR,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,QAAQ;CACT;AACD;AACA,SAAgB,QAAW,KAAiB;CAC3C,MAAM,WAAW;CACjB,WAAW,KAAA;CACX,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,WAAW;CACZ;AACD;AACA,SAAgB,YAAY,QAAuB;CAClD,MAAM,QAAe;EACpB,OAAO,QAAQ;EACf,SAAS;EACT,2BAAW,IAAI,IAAI;EACnB,UAAU,CAAC;EACX,OAAO;CACR;CACA,QAAQ,UAAU,IAAI,KAAK;CAC3B,OAAO;AACR;AACA,SAAgB,KAAK,OAAc,OAAuB;CACzD,IAAI;EACH,QAAQ,KAAK;CACd,SAAS,SAAS;EACjB,MAAM,IAAI,eAAe,CAAC,OAAO,OAAO,CAAC;CAC1C;CACA,MAAM;AACP;AACA,SAAgB,QAAQ,OAAoB;CAC3C,IAAI,MAAM,OAAO;CACjB,MAAM,QAAQ;CACd,MAAM,SAAoB,CAAC;CAC3B,IAAI;EACH,MAAM,MAAM,WAAW,OAAO,KAAK;CACpC,SAAS,OAAO;EACf,OAAO,KAAK,KAAK;CAClB;CACA,KAAK,MAAM,WAAW,CAAC,GAAG,MAAM,SAAS,CAAC,CAAC,QAAQ,GAClD,I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rD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;CACzD,IAAI,SAAS,QAAQ,OAAO,UAAU,WAAW,OAAO;CACxD,IAA2B,OAAO,UAAU,UAC3C,MAAM,IAAI,MAAM,oBAAoB;CAErC,OAAO,OAAO,KAAK;AACpB;AAEA,SAAgB,UAAU,OAAuB;CAChD,KAAK,IAAI,KAAwB,OAAO,IAAI,KAAK,GAAG,SACnD,IAAI,GAAG,SAAS,GAAG,UAAU,OAAO;CACrC,OAAO;AACR"}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
|
|
2
|
-
import { a as invalidate, d as plain, i as fail, n as createScope, p as untrack, r as dispose, s as observe, t as createRoot, x as within } from "./core-
|
|
2
|
+
import { a as invalidate, d as plain, i as fail, n as createScope, p as untrack, r as dispose, s as observe, t as createRoot, x as within } from "./core-DxPiKryn.js";
|
|
3
3
|
import { Fragment, merge } from "./jsx-runtime.js";
|
|
4
4
|
// src/dom.ts
|
|
5
5
|
const HTML = `http://www.w3.org/1999/xhtml`;
|
|
6
6
|
const SVG = `http://www.w3.org/2000/svg`;
|
|
7
|
+
function finish(cursor) {
|
|
8
|
+
if (cursor?.node) {
|
|
9
|
+
cursor.report(null, cursor.node);
|
|
10
|
+
while (cursor.node) {
|
|
11
|
+
const node = cursor.node;
|
|
12
|
+
cursor.node = node.nextSibling;
|
|
13
|
+
node.remove();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
7
17
|
function take(node, parent, before, owner, cursor) {
|
|
8
18
|
if (cursor && !(node.nodeType === 3 && !node.nodeValue && cursor.node?.nodeType !== 3)) {
|
|
9
19
|
const found = cursor.node;
|
|
10
|
-
if (!found || found.nodeType !== node.nodeType || found.nodeName !== node.nodeName || found.namespaceURI !== node.namespaceURI || node.nodeType !== 1 && found.nodeValue !== node.nodeValue)
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
if (!found || found.nodeType !== node.nodeType || found.nodeName !== node.nodeName || found.namespaceURI !== node.namespaceURI || node.nodeType !== 1 && found.nodeValue !== node.nodeValue) {
|
|
21
|
+
cursor.report(node, found);
|
|
22
|
+
parent.insertBefore(node, found);
|
|
23
|
+
cursor.node = found?.nextSibling ?? null;
|
|
24
|
+
found?.remove();
|
|
25
|
+
} else {
|
|
26
|
+
node = found;
|
|
27
|
+
cursor.node = found.nextSibling;
|
|
28
|
+
}
|
|
13
29
|
} else parent.insertBefore(node, cursor ? cursor.node : before);
|
|
14
30
|
owner._cleanups.add(() => {
|
|
15
31
|
node.remove();
|
|
@@ -142,9 +158,12 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
|
|
|
142
158
|
if (element.textContent !== text) element.textContent = text;
|
|
143
159
|
});
|
|
144
160
|
else {
|
|
145
|
-
const children = cursor ? {
|
|
161
|
+
const children = cursor ? {
|
|
162
|
+
node: element.firstChild,
|
|
163
|
+
report: cursor.report
|
|
164
|
+
} : void 0;
|
|
146
165
|
if (!/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(vnode.type) || ns !== HTML) mount(() => props[`children`], element, null, owner, vnode.type === `foreignObject` ? HTML : ns, children);
|
|
147
|
-
|
|
166
|
+
finish(children);
|
|
148
167
|
}
|
|
149
168
|
const nativeProps = capabilityProps(owner, {
|
|
150
169
|
kind: `dom`,
|
|
@@ -174,18 +193,31 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
|
|
|
174
193
|
});
|
|
175
194
|
}
|
|
176
195
|
function start(setup, host, options, hydrating) {
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
196
|
+
let reported = false;
|
|
197
|
+
const cursor = hydrating ? {
|
|
198
|
+
node: host.firstChild,
|
|
199
|
+
report(expected, found) {
|
|
200
|
+
if (!reported) {
|
|
201
|
+
reported = true;
|
|
202
|
+
console.warn(`spa: hydration mismatch. Repairing server HTML to match the browser view; replaced nodes may lose focus or unsaved input.`, {
|
|
203
|
+
host,
|
|
204
|
+
expected,
|
|
205
|
+
found
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
} : void 0;
|
|
210
|
+
const marker = cursor?.node;
|
|
211
|
+
const prefix = marker?.nodeType === 8 && marker.nodeValue?.startsWith(`w:`) ? marker.nodeValue.slice(2) : void 0;
|
|
180
212
|
const root = createRoot(options);
|
|
181
|
-
if (prefix !== void 0) root._prefix = prefix;
|
|
213
|
+
if (prefix !== void 0 && options.idPrefix === void 0) root._prefix = prefix;
|
|
182
214
|
try {
|
|
183
215
|
comment(`w:${root._prefix}`, host, null, root, cursor);
|
|
184
216
|
within(root, () => {
|
|
185
217
|
mount(untrack(setup), host, null, root, host.namespaceURI === SVG ? SVG : HTML, cursor);
|
|
186
218
|
});
|
|
187
219
|
comment(`/w`, host, null, root, cursor);
|
|
188
|
-
|
|
220
|
+
finish(cursor);
|
|
189
221
|
root.flush();
|
|
190
222
|
} catch (error) {
|
|
191
223
|
fail(root, error);
|
|
@@ -205,4 +237,4 @@ function hydrate(setup, host, options = {}) {
|
|
|
205
237
|
}
|
|
206
238
|
export { render as n, hydrate as t };
|
|
207
239
|
|
|
208
|
-
//# sourceMappingURL=dom-
|
|
240
|
+
//# sourceMappingURL=dom-BytVV6Rp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-BytVV6Rp.js","names":[],"sources":["../../src/dom.ts"],"sourcesContent":["import { capabilityProps } from \"./capabilities.ts\"\nimport type {\n\tAccessor,\n\tChildren,\n\tRootOptions,\n\tScope,\n\tSpaElement,\n} from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tfail,\n\tinvalidate,\n\tobserve,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment, merge } from \"./jsx-runtime.ts\"\n\nconst HTML = `http://www.w3.org/1999/xhtml`\nconst SVG = `http://www.w3.org/2000/svg`\ntype Cursor = {\n\tnode: Node | null\n\treport(expected: Node | null, found: Node | null): void\n}\ntype RecordNode = { _value: Children; _scope: Scope; _start: Node; _end: Node }\n\nfunction finish(cursor?: Cursor): void {\n\tif (cursor?.node) {\n\t\tcursor.report(null, cursor.node)\n\t\twhile (cursor.node) {\n\t\t\tconst node: Node = cursor.node\n\t\t\tcursor.node = node.nextSibling\n\t\t\t;(node as ChildNode).remove()\n\t\t}\n\t}\n}\n\nfunction take(\n\tnode: Node,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tcursor?: Cursor,\n): Node {\n\tif (\n\t\tcursor &&\n\t\t!(node.nodeType === 3 && !node.nodeValue && cursor.node?.nodeType !== 3)\n\t) {\n\t\tconst found = cursor.node\n\t\tif (\n\t\t\t!found ||\n\t\t\tfound.nodeType !== node.nodeType ||\n\t\t\tfound.nodeName !== node.nodeName ||\n\t\t\t(found as Element).namespaceURI !== (node as Element).namespaceURI ||\n\t\t\t(node.nodeType !== 1 && found.nodeValue !== node.nodeValue)\n\t\t) {\n\t\t\tcursor.report(node, found)\n\t\t\tparent.insertBefore(node, found)\n\t\t\tcursor.node = found?.nextSibling ?? null\n\t\t\t;(found as ChildNode | null)?.remove()\n\t\t} else {\n\t\t\tnode = found\n\t\t\tcursor.node = found.nextSibling\n\t\t}\n\t} else parent.insertBefore(node, cursor ? cursor.node : before)\n\towner._cleanups.add(() => {\n\t\t;(node as ChildNode).remove()\n\t})\n\treturn node\n}\nfunction comment(\n\tvalue: string,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tcursor?: Cursor,\n): Node {\n\treturn take(\n\t\tparent.ownerDocument!.createComment(value),\n\t\tparent,\n\t\tbefore,\n\t\towner,\n\t\tcursor,\n\t)\n}\nfunction property(\n\telement: Element,\n\tkey: string,\n\tvalue: any,\n\tprevious: any,\n): void {\n\tif (/^(key|children|ref)$/.test(key)) return\n\tif (key === `innerHTML` && element.localName === `astro-slot`) return\n\tif (\n\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\tkey,\n\t\t)\n\t)\n\t\tthrow new Error(import.meta.env.DEV ? `spa: owned content` : undefined)\n\tif (key.startsWith(`on`)) {\n\t\tconst capture = /(?<!Pointer)Capture$/.test(key)\n\t\tconst event = key\n\t\t\t.slice(2, capture ? -7 : undefined)\n\t\t\t.toLowerCase()\n\t\t\t.replace(`doubleclick`, `dblclick`)\n\t\tif (previous) element.removeEventListener(event, previous, capture)\n\t\tif (value != null) {\n\t\t\tif (import.meta.env.DEV && typeof value !== `function`)\n\t\t\t\tthrow new Error(`spa: event handler`)\n\t\t\telement.addEventListener(event, value, capture)\n\t\t}\n\t\treturn\n\t}\n\tif (key === `className`) key = `class`\n\tif (key === `htmlFor`) key = `for`\n\tif (\n\t\timport.meta.env.DEV &&\n\t\tkey === `style` &&\n\t\tvalue != null &&\n\t\ttypeof value !== `string`\n\t)\n\t\tthrow new Error(`spa: CSS string required`)\n\tif (\n\t\telement.namespaceURI === HTML &&\n\t\tkey in element &&\n\t\t!/^(style|form|list)$/.test(key)\n\t) {\n\t\tconst target = element as any\n\t\ttarget[key] = value ?? (typeof target[key] === `boolean` ? false : ``)\n\t} else if (value == null || (value === false && !/^(aria-|data-)/.test(key)))\n\t\telement.removeAttribute(key)\n\telse\n\t\telement.setAttribute(\n\t\t\tkey,\n\t\t\tvalue === true && !/^(aria-|data-)/.test(key) ? `` : String(value),\n\t\t)\n}\n\nfunction mount(\n\tvalue: Children,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tnamespace: string,\n\tcursor?: Cursor,\n\tsource = () => value,\n): void {\n\tif (typeof value === `function`) {\n\t\tcomment(`{`, parent, before, owner, cursor)\n\t\tlet end: Node | null = null\n\t\tlet records = new Map<unknown, RecordNode>()\n\t\tconst presence = owner._root._presence?.collection<RecordNode, Children>(\n\t\t\t(record) => record._scope,\n\t\t\t(record, child) =>\n\t\t\t\ttypeof record._value === typeof child &&\n\t\t\t\t(record._value as SpaElement | null)?.type ===\n\t\t\t\t\t(child as SpaElement | null)?.type,\n\t\t)\n\t\tconst retire = (\n\t\t\trecord: RecordNode,\n\t\t\tkey: unknown,\n\t\t\teligible: boolean,\n\t\t\tindex: number,\n\t\t) => {\n\t\t\tif (presence) presence.remove(record, key, eligible, index, () => {})\n\t\t\telse dispose(record._scope)\n\t\t}\n\t\tlet initial = cursor\n\t\tobserve(\n\t\t\towner,\n\t\t\t() => (source() as () => Children)(),\n\t\t\t(next) => {\n\t\t\t\tconst values = ([next] as unknown[]).flat(Infinity) as Children[]\n\t\t\t\tconst kept = new Map<unknown, RecordNode>()\n\t\t\t\tconst focus = parent.ownerDocument!.activeElement as HTMLElement | null\n\t\t\t\tfor (let index = 0; index < values.length; index++) {\n\t\t\t\t\tconst child = values[index]\n\t\t\t\t\tconst vnode = child as SpaElement | null\n\t\t\t\t\tconst explicit = vnode?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (import.meta.env.DEV && kept.has(key))\n\t\t\t\t\t\tthrow new Error(`spa: duplicate key`)\n\t\t\t\t\tlet record = records.get(key)\n\t\t\t\t\tif (\n\t\t\t\t\t\trecord &&\n\t\t\t\t\t\t(typeof record._value !== typeof child ||\n\t\t\t\t\t\t\t(record._value as SpaElement | null)?.type !== vnode?.type)\n\t\t\t\t\t) {\n\t\t\t\t\t\tretire(\n\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tchild == null || typeof child === `boolean`,\n\t\t\t\t\t\t\t[...records.keys()].indexOf(key),\n\t\t\t\t\t\t)\n\t\t\t\t\t\trecord = undefined\n\t\t\t\t\t}\n\t\t\t\t\trecord ??= presence?.take(key, child)\n\t\t\t\t\tif (!record) {\n\t\t\t\t\t\tconst childOwner = createScope(owner)\n\t\t\t\t\t\trecord = {\n\t\t\t\t\t\t\t_value: child,\n\t\t\t\t\t\t\t_scope: childOwner,\n\t\t\t\t\t\t\t_start: comment(`[`, parent, end ?? before, childOwner, initial),\n\t\t\t\t\t\t\t_end: null!,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst held = record\n\t\t\t\t\t\tmount(\n\t\t\t\t\t\t\tchild,\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tend ?? before,\n\t\t\t\t\t\t\tchildOwner,\n\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\tinitial,\n\t\t\t\t\t\t\t() => held._value,\n\t\t\t\t\t\t)\n\t\t\t\t\t\trecord._end = comment(\n\t\t\t\t\t\t\t`]`,\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tend ?? before,\n\t\t\t\t\t\t\tchildOwner,\n\t\t\t\t\t\t\tinitial,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\trecord._value = child\n\t\t\t\t\t\towner._root._presence?.resume(record._scope)\n\t\t\t\t\t\tinvalidate(record._scope)\n\t\t\t\t\t}\n\t\t\t\t\tkept.set(key, record)\n\t\t\t\t}\n\t\t\t\tfor (const [key, record] of records)\n\t\t\t\t\tif (!kept.has(key))\n\t\t\t\t\t\tretire(record, key, true, [...records.keys()].indexOf(key))\n\t\t\t\tif (!initial) {\n\t\t\t\t\tlet at = end ?? before\n\t\t\t\t\tconst rendered = presence?.merge([...kept.values()]) ?? [\n\t\t\t\t\t\t...kept.values(),\n\t\t\t\t\t]\n\t\t\t\t\tfor (const record of rendered.reverse()) {\n\t\t\t\t\t\tif (record._end.nextSibling !== at) {\n\t\t\t\t\t\t\tconst range = parent.ownerDocument!.createRange()\n\t\t\t\t\t\t\trange.setStartBefore(record._start)\n\t\t\t\t\t\t\trange.setEndAfter(record._end)\n\t\t\t\t\t\t\tparent.insertBefore(range.extractContents(), at)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tat = record._start\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocus?.isConnected &&\n\t\t\t\t\t\t!focus.closest(`[inert]`) &&\n\t\t\t\t\t\tfocus !== parent.ownerDocument!.activeElement\n\t\t\t\t\t)\n\t\t\t\t\t\tfocus.focus({ preventScroll: true })\n\t\t\t\t}\n\t\t\t\tinitial = undefined\n\t\t\t\trecords = kept\n\t\t\t},\n\t\t)\n\t\tend = comment(`}`, parent, before, owner, cursor)\n\t\treturn\n\t}\n\tif (Array.isArray(value)) {\n\t\tfor (const child of value)\n\t\t\tmount(child, parent, before, owner, namespace, cursor)\n\t\treturn\n\t}\n\tif (value == null || typeof value === `boolean`) return\n\tif (typeof value !== `object`) {\n\t\tcomment(`t`, parent, before, owner, cursor)\n\t\tconst text = take(\n\t\t\tparent.ownerDocument!.createTextNode(String(value)),\n\t\t\tparent,\n\t\t\tbefore,\n\t\t\towner,\n\t\t\tcursor,\n\t\t)\n\t\tobserve(owner, source as Accessor<string | number | bigint>, (next) => {\n\t\t\tconst data = String(next)\n\t\t\tif (text.nodeValue !== data) text.nodeValue = data\n\t\t})\n\t\treturn\n\t}\n\tif (import.meta.env.DEV && (!(`type` in value) || !(`props` in value)))\n\t\tthrow new Error(`spa: invalid child`)\n\tconst vnode = value as SpaElement\n\tconst props = merge(() => (source() as SpaElement).props)\n\tif (!vnode.type || vnode.type === Fragment) {\n\t\tmount(() => props[`children`], parent, before, owner, namespace, cursor)\n\t\treturn\n\t}\n\tif (typeof vnode.type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\tconst output = within(childOwner, () =>\n\t\t\tuntrack(() => (vnode.type as Function)(props)),\n\t\t)\n\t\tmount(output, parent, before, childOwner, namespace, cursor)\n\t\treturn\n\t}\n\tconst ns = vnode.type === `svg` ? SVG : namespace\n\tconst element = take(\n\t\tparent.ownerDocument!.createElementNS(ns, vnode.type),\n\t\tparent,\n\t\tbefore,\n\t\towner,\n\t\tcursor,\n\t) as Element\n\tif (vnode.type === `astro-slot`) {\n\t\tif (!cursor) element.innerHTML = props[`innerHTML`] ?? ``\n\t} else if (ns === HTML && /^(textarea|title|style|script)$/.test(vnode.type)) {\n\t\tobserve(\n\t\t\towner,\n\t\t\t() =>\n\t\t\t\tplain(\n\t\t\t\t\tvnode.type === `textarea`\n\t\t\t\t\t\t? (props[`value`] ?? props[`children`])\n\t\t\t\t\t\t: props[`children`],\n\t\t\t\t),\n\t\t\t(text) => {\n\t\t\t\tif (element.textContent !== text) element.textContent = text\n\t\t\t},\n\t\t)\n\t} else {\n\t\tconst children = cursor\n\t\t\t? { node: element.firstChild, report: cursor.report }\n\t\t\t: undefined\n\t\tif (\n\t\t\t!/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(\n\t\t\t\tvnode.type,\n\t\t\t) ||\n\t\t\tns !== HTML\n\t\t)\n\t\t\tmount(\n\t\t\t\t() => props[`children`],\n\t\t\t\telement,\n\t\t\t\tnull,\n\t\t\t\towner,\n\t\t\t\tvnode.type === `foreignObject` ? HTML : ns,\n\t\t\t\tchildren,\n\t\t\t)\n\t\tfinish(children)\n\t}\n\tconst nativeProps = capabilityProps(\n\t\towner,\n\t\t{ kind: `dom`, node: element },\n\t\t() => ({ ...props }),\n\t)\n\tlet previous: Record<string, any> = {}\n\towner._cleanups.add(() => {\n\t\tfor (const key in previous)\n\t\t\tif (key.startsWith(`on`)) property(element, key, null, previous[key])\n\t})\n\tobserve(\n\t\towner,\n\t\t() => ({ ...props }),\n\t\t(all) => {\n\t\t\tconst next = nativeProps(all)\n\t\t\tfor (const key in { ...previous, ...next })\n\t\t\t\tif (\n\t\t\t\t\t!Object.is(previous[key], next[key]) ||\n\t\t\t\t\ttypeof next[key] === `object`\n\t\t\t\t) {\n\t\t\t\t\tproperty(element, key, next[key], previous[key])\n\t\t\t\t\tprevious[key] = next[key]\n\t\t\t\t}\n\t\t\tprevious = next\n\t\t},\n\t)\n\tconst ref = untrack(() => props[`ref`])\n\tif (ref) {\n\t\towner._root._mounts!.unshift(() => {\n\t\t\tif (!owner._dead) {\n\t\t\t\towner._cleanups.add(() => ref(null))\n\t\t\t\tref(element)\n\t\t\t}\n\t\t})\n\t}\n}\n\nexport interface SpaRoot {\n\tdispose(): void\n\tflush(): void\n}\nfunction start(\n\tsetup: () => Children,\n\thost: Element,\n\toptions: RootOptions,\n\thydrating: boolean,\n): SpaRoot {\n\tlet reported = false\n\tconst cursor: Cursor | undefined = hydrating\n\t\t? {\n\t\t\t\tnode: host.firstChild,\n\t\t\t\treport(expected, found) {\n\t\t\t\t\tif (!reported) {\n\t\t\t\t\t\treported = true\n\t\t\t\t\t\t// eslint-disable-next-line no-console -- Recoverable degradation must remain human-readable in production.\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`spa: hydration mismatch. Repairing server HTML to match the browser view; replaced nodes may lose focus or unsaved input.`,\n\t\t\t\t\t\t\t{ host, expected, found },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t: undefined\n\tconst marker = cursor?.node\n\tconst prefix =\n\t\tmarker?.nodeType === 8 && marker.nodeValue?.startsWith(`w:`)\n\t\t\t? marker.nodeValue.slice(2)\n\t\t\t: undefined\n\tconst root = createRoot(options)\n\tif (prefix !== undefined && options.idPrefix === undefined)\n\t\troot._prefix = prefix\n\ttry {\n\t\tcomment(`w:${root._prefix}`, host, null, root, cursor)\n\t\twithin(root, () => {\n\t\t\tmount(\n\t\t\t\tuntrack(setup),\n\t\t\t\thost,\n\t\t\t\tnull,\n\t\t\t\troot,\n\t\t\t\thost.namespaceURI === SVG ? SVG : HTML,\n\t\t\t\tcursor,\n\t\t\t)\n\t\t})\n\t\tcomment(`/w`, host, null, root, cursor)\n\t\tfinish(cursor)\n\t\troot.flush()\n\t} catch (error) {\n\t\tfail(root, error)\n\t}\n\treturn {\n\t\tdispose: () => {\n\t\t\tdispose(root)\n\t\t},\n\t\tflush: root.flush,\n\t}\n}\nexport function render(\n\tsetup: () => Children,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\treturn start(setup, host, options, false)\n}\nexport function hydrate(\n\tsetup: () => Children,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\treturn start(setup, host, options, true)\n}\n"],"mappings":";;;;AAqBA,MAAM,OAAO;AACb,MAAM,MAAM;AAOZ,SAAS,OAAO,QAAuB;CACtC,IAAI,QAAQ,MAAM;EACjB,OAAO,OAAO,MAAM,OAAO,IAAI;EAC/B,OAAO,OAAO,MAAM;GACnB,MAAM,OAAa,OAAO;GAC1B,OAAO,OAAO,KAAK;GAClB,KAAoB,OAAO;EAC7B;CACD;AACD;AAEA,SAAS,KACR,MACA,QACA,QACA,OACA,QACO;CACP,IACC,UACA,EAAE,KAAK,aAAa,KAAK,CAAC,KAAK,aAAa,OAAO,MAAM,aAAa,IACrE;EACD,MAAM,QAAQ,OAAO;EACrB,IACC,CAAC,SACD,MAAM,aAAa,KAAK,YACxB,MAAM,aAAa,KAAK,YACvB,MAAkB,iBAAkB,KAAiB,gBACrD,KAAK,aAAa,KAAK,MAAM,cAAc,KAAK,WAChD;GACD,OAAO,OAAO,MAAM,KAAK;GACzB,OAAO,aAAa,MAAM,KAAK;GAC/B,OAAO,OAAO,OAAO,eAAe;GACnC,OAA6B,OAAO;EACtC,OAAO;GACN,OAAO;GACP,OAAO,OAAO,MAAM;EACrB;CACD,OAAO,OAAO,aAAa,MAAM,SAAS,OAAO,OAAO,MAAM;CAC9D,MAAM,UAAU,UAAU;EACxB,KAAoB,OAAO;CAC7B,CAAC;CACD,OAAO;AACR;AACA,SAAS,QACR,OACA,QACA,QACA,OACA,QACO;CACP,OAAO,KACN,OAAO,cAAe,cAAc,KAAK,GACzC,QACA,QACA,OACA,MACD;AACD;AACA,SAAS,SACR,SACA,KACA,OACA,UACO;CACP,IAAI,uBAAuB,KAAK,GAAG,GAAG;CACtC,IAAI,QAAQ,eAAe,QAAQ,cAAc,cAAc;CAC/D,IACC,wEAAwE,KACvE,GACD,GAEA,MAAM,IAAI,MAA4B,oBAAgC;CACvE,IAAI,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AQ,MAAM,MAAM,MAAM,MAAM,MAAM;EACtC,OAAO,MAAM;EACb,KAAK,MAAM;CACZ,SAAS,OAAO;EACf,KAAK,MAAM,KAAK;CACjB;CACA,OAAO;EACN,eAAe;GACd,QAAQ,IAAI;EACb;EACA,OAAO,KAAK;CACb;AACD;AACA,SAAgB,OACf,OACA,MACA,UAAuB,CAAC,GACd;CACV,OAAO,MAAM,OAAO,MAAM,SAAS,KAAK;AACzC;AACA,SAAgB,QACf,OACA,MACA,UAAuB,CAAC,GACd;CACV,OAAO,MAAM,OAAO,MAAM,SAAS,IAAI;AACxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as useSetter, b as useTransaction, c as onCleanup, g as useRef, h as useId, l as onMount, m as useGetter, v as useStore, y as useTimeline } from "./core-DxPiKryn.js";
|
|
2
2
|
import { Fragment } from "./jsx-runtime.js";
|
|
3
|
-
import { n as render, t as hydrate } from "./dom-
|
|
4
|
-
import { t as useLoadable } from "./src-
|
|
5
|
-
export { Fragment, hydrate, onCleanup, onMount, render, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction
|
|
3
|
+
import { n as render, t as hydrate } from "./dom-BytVV6Rp.js";
|
|
4
|
+
import { t as useLoadable } from "./src-WSHJxR9b.js";
|
|
5
|
+
export { Fragment, hydrate, onCleanup, onMount, render, useGetter, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["import type { Children, Component, SpaElement } from \"./core.ts\"\nimport type { HTMLAttributes, NativeElements } from \"./jsx-types.d.ts\"\n\nexport type {\n\tAriaAttributes,\n\tDOMAttributes,\n\tEventAttributes,\n\tEventHandler,\n\tHTMLAttributes,\n\tRef,\n\tSVGAttributes,\n\tTargetedEvent,\n} from \"./jsx-types.d.ts\"\n\n/** Optional integrations augment attributes without changing element identity. */\n// oxlint-disable-next-line typescript/no-empty-interface -- Optional integrations augment this declaration.\nexport interface CapabilityAttributes<Kind extends string = string> {}\n\nexport const Fragment = (props: { children?: Children }): Children =>\n\tprops.children\nexport function jsx(\n\ttype: SpaElement[`type`],\n\tprops: SpaElement[`props`] | null,\n\tkey?: unknown,\n): SpaElement {\n\treturn {\n\t\ttype,\n\t\tprops: key === undefined ? (props ?? {}) : merge(props ?? {}, { key }),\n\t}\n}\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n/** Preserve lazy props and spread precedence, including keys added by later updates. */\nexport function merge(\n\t...sources: (Record<string, any> | (() => Record<string, any>))[]\n): Record<string, any> {\n\tconst values = () =>\n\t\tsources.map(\n\t\t\t(source) => (typeof source === `function` ? source() : source) ?? {},\n\t\t)\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_, key) =>\n\t\t\t\tvalues()\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((source) => Object.hasOwn(source, key))?.[key],\n\t\t\townKeys: () => [...new Set(values().flatMap(Object.keys))],\n\t\t\tgetOwnPropertyDescriptor: () => ({ enumerable: true, configurable: true }),\n\t\t},\n\t)\n}\n\nexport namespace JSX {\n\texport type Element = SpaElement\n\texport type ElementType = keyof IntrinsicElements | Component\n\texport interface ElementChildrenAttribute {\n\t\tchildren: {}\n\t}\n\texport interface IntrinsicAttributes {\n\t\tkey?: string | number\n\t}\n\t/** Augment this interface to declare attributes for registered custom elements. */\n\texport interface IntrinsicElements extends NativeElements {\n\t\t[tag: `${string}-${string}`]: HTMLAttributes<HTMLElement>\n\t}\n}\n"],"mappings":";AAkBA,MAAa,YAAY,UACxB,MAAM;AACP,SAAgB,IACf,MACA,OACA,KACa;CACb,OAAO;EACN;EACA,OAAO,QAAQ,KAAA,IAAa,SAAS,CAAC,IAAK,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;CACtE;AACD;AACA,MAAa,OAAO;AACpB,MAAa,SAAS;;AAGtB,SAAgB,MACf,GAAG,SACmB;CACtB,MAAM,eACL,QAAQ,KACN,YAAY,OAAO,WAAW,aAAa,OAAO,IAAI,WAAW,CAAC,CACpE;CACD,OAAO,IAAI,MACV,CAAC,GACD;EACC,MAAM,GAAG,QACR,OAAO,CAAC,CACN,QAAQ,CAAC,CACT,MAAM,WAAW,OAAO,OAAO,QAAQ,GAAG,CAAC,CAAC,GAAG;EAClD,eAAe,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,IAAI,CAAC,CAAC;EACzD,iCAAiC;GAAE,YAAY;GAAM,cAAc;EAAK;CACzE,CACD;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
|
|
2
|
-
import { c as onCleanup, l as onMount, u as owner } from "./core-
|
|
2
|
+
import { c as onCleanup, l as onMount, u as owner } from "./core-DxPiKryn.js";
|
|
3
3
|
import { jsx } from "./jsx-runtime.js";
|
|
4
4
|
import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.js";
|
|
5
5
|
import Konva from "konva";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"konva.js","names":[],"sources":["../../src/konva.ts"],"sourcesContent":["import Konva from \"konva\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport { owner } from \"./core.ts\"\nimport type {
|
|
1
|
+
{"version":3,"file":"konva.js","names":[],"sources":["../../src/konva.ts"],"sourcesContent":["import Konva from \"konva\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport { owner } from \"./core.ts\"\nimport type { Children, SpaElement } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport { bindScene, createSceneRenderer, sceneComponent } from \"./renderer.ts\"\n\ntype Props<C, N> = C &\n\tCapabilityAttributes<`konva`> & {\n\t\tchildren?: Children\n\t\tref?: (node: N | null) => void\n\t\tonClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void\n\t\tonPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void\n\t\tonDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t\tonDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t}\nconst constructors = {\n\tLayer: Konva.Layer,\n\tGroup: Konva.Group,\n\tRect: Konva.Rect,\n\tCircle: Konva.Circle,\n\tEllipse: Konva.Ellipse,\n\tLine: Konva.Line,\n\tText: Konva.Text,\n\tImage: Konva.Image,\n\tPath: Konva.Path,\n\tStar: Konva.Star,\n\tTransformer: Konva.Transformer,\n}\nfunction suspendNode(node: Konva.Node): () => void {\n\tconst listening = node.listening()\n\tconst draggable = node.draggable()\n\tnode.listening(false)\n\t// The public setter clears both pending and active native drag records.\n\tnode.draggable(false)\n\treturn () => {\n\t\tnode.listening(listening)\n\t\tnode.draggable(draggable)\n\t}\n}\nfunction updateNode(\n\tnode: Konva.Node,\n\tprops: Record<string, any>,\n\tprevious: Record<string, any>,\n): void {\n\tfor (const key of new Set([...Object.keys(previous), ...Object.keys(props)])) {\n\t\tif (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key]))\n\t\t\tcontinue\n\t\tif (key.startsWith(`on`)) {\n\t\t\tconst event = key.slice(2).toLowerCase()\n\t\t\tif (previous[key]) node.off(event, previous[key])\n\t\t\tif (props[key]) node.on(event, props[key])\n\t\t} else node.setAttr(key, props[key])\n\t}\n}\nconst renderer = createSceneRenderer<Konva.Node>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `konva`,\n\t\t\tnode,\n\t\t\tsuspend() {\n\t\t\t\treturn suspendNode(node)\n\t\t\t},\n\t\t\tread: (key) => node.getAttr(key),\n\t\t\twrite: (key, value) => {\n\t\t\t\tnode.setAttr(key, value)\n\t\t\t},\n\t\t\tlisten(event, listener) {\n\t\t\t\tnode.on(event, listener)\n\t\t\t\treturn () => {\n\t\t\t\t\tnode.off(event, listener)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/konva: unknown node ${type}`)\n\t\treturn new Constructor({} as any)\n\t},\n\tupdate: updateNode,\n\tchildren(parent, children) {\n\t\tif (children.length && !(parent instanceof Konva.Container))\n\t\t\tthrow new Error(`spa/konva: shapes cannot contain children`)\n\t\tif (parent instanceof Konva.Container) {\n\t\t\tfor (const child of [...parent.getChildren()])\n\t\t\t\tif (!children.includes(child)) child.remove()\n\t\t\tchildren.forEach((child, index) => {\n\t\t\t\tif (child.getParent() !== parent) parent.add(child as any)\n\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t}\n\t},\n\tdestroy(node) {\n\t\tnode.off()\n\t\tnode.destroy()\n\t},\n})\n\n/** A DOM boundary owning a Konva stage and its scene subtree. */\nexport function Stage(\n\tprops: Props<Omit<Konva.StageConfig, `container`>, Konva.Stage> & {\n\t\twidth?: number\n\t\theight?: number\n\t},\n): SpaElement {\n\tlet container: HTMLDivElement | null = null\n\tonMount(() => {\n\t\t// Konva clears its container; preserve SPA's markers in the outer element.\n\t\tconst surface = container!.ownerDocument.createElement(`div`)\n\t\tcontainer!.append(surface)\n\t\tonCleanup(() => {\n\t\t\tsurface.remove()\n\t\t})\n\t\tconst stage = new Konva.Stage({\n\t\t\tcontainer: surface,\n\t\t\twidth: props.width ?? 300,\n\t\t\theight: props.height ?? 150,\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tstage.off()\n\t\t\tstage.destroy()\n\t\t})\n\t\tconst nativeProps = capabilityProps(\n\t\t\towner!,\n\t\t\t{\n\t\t\t\tkind: `konva`,\n\t\t\t\tnode: stage,\n\t\t\t\tsuspend() {\n\t\t\t\t\treturn suspendNode(stage)\n\t\t\t\t},\n\t\t\t\tlisten(event, listener) {\n\t\t\t\t\tstage.on(event, listener)\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tstage.off(event, listener)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tread: (key) => stage.getAttr(key),\n\t\t\t\twrite: (key, value) => {\n\t\t\t\t\tstage.setAttr(key, value)\n\t\t\t\t},\n\t\t\t},\n\t\t\t() => ({ ...props }),\n\t\t)\n\t\tlet previous: Record<string, any> = {}\n\t\tbindScene(\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\tupdateNode(stage, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tprops.ref?.(stage)\n\t\tonCleanup(() => props.ref?.(null))\n\t\trenderer.mount(() => props.children, stage)\n\t})\n\treturn jsx(`div`, {\n\t\tref: (element: HTMLDivElement | null) => {\n\t\t\tcontainer = element\n\t\t},\n\t})\n}\nexport const Layer =\n\tsceneComponent<Props<Konva.LayerConfig, Konva.Layer>>(`Layer`)\nexport const Group =\n\tsceneComponent<Props<Konva.ContainerConfig, Konva.Group>>(`Group`)\nexport const Rect = sceneComponent<Props<Konva.RectConfig, Konva.Rect>>(`Rect`)\nexport const Circle =\n\tsceneComponent<Props<Konva.CircleConfig, Konva.Circle>>(`Circle`)\nexport const Ellipse =\n\tsceneComponent<Props<Konva.EllipseConfig, Konva.Ellipse>>(`Ellipse`)\nexport const Line = sceneComponent<Props<Konva.LineConfig, Konva.Line>>(`Line`)\nexport const Text = sceneComponent<Props<Konva.TextConfig, Konva.Text>>(`Text`)\nexport const Image =\n\tsceneComponent<Props<Konva.ImageConfig, Konva.Image>>(`Image`)\nexport const Path = sceneComponent<Props<Konva.PathConfig, Konva.Path>>(`Path`)\nexport const Star = sceneComponent<Props<Konva.StarConfig, Konva.Star>>(`Star`)\nexport const Transformer =\n\tsceneComponent<Props<Konva.TransformerConfig, Konva.Transformer>>(\n\t\t`Transformer`,\n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AAK,UAAU;IACtB,MAAM,QAAQ,KAAK,KAAK;GACzB;EACD,UACO,EAAE,GAAG,MAAM,EACnB;EACA,IAAI,WAAgC,CAAC;EACrC,iBACQ,EAAE,GAAG,MAAM,KACjB,QAAQ;GACR,MAAM,OAAO,YAAY,GAAG;GAC5B,WAAW,OAAO,MAAM,QAAQ;GAChC,WAAW;EACZ,CACD;EACA,MAAM,MAAM,KAAK;EACjB,gBAAgB,MAAM,MAAM,IAAI,CAAC;EACjC,SAAS,YAAY,MAAM,UAAU,KAAK;CAC3C,CAAC;CACD,OAAO,IAAI,OAAO,EACjB,MAAM,YAAmC;EACxC,YAAY;CACb,EACD,CAAC;AACF;AACA,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,QACZ,eAA0D,OAAO;AAClE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,SACZ,eAAwD,QAAQ;AACjE,MAAa,UACZ,eAA0D,SAAS;AACpE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,cACZ,eACC,aACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as invalidate, i as fail, o as isPresent, p as untrack, r as dispose } from "./core-
|
|
1
|
+
import { a as invalidate, i as fail, o as isPresent, p as untrack, r as dispose } from "./core-DxPiKryn.js";
|
|
2
2
|
import { animate, cancelFrame, frame, hover, keyframes, motionValue, press, readStyleValue, styleEffect } from "motion";
|
|
3
3
|
// src/motion-tween.ts
|
|
4
4
|
const trajectories = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
|
|
2
|
-
import { a as invalidate, i as fail, n as createScope, o as isPresent, p as untrack, r as dispose, s as observe, t as createRoot, u as owner, x as within } from "./core-
|
|
2
|
+
import { a as invalidate, i as fail, n as createScope, o as isPresent, p as untrack, r as dispose, s as observe, t as createRoot, u as owner, x as within } from "./core-DxPiKryn.js";
|
|
3
3
|
import { Fragment, merge } from "./jsx-runtime.js";
|
|
4
4
|
// src/renderer.ts
|
|
5
5
|
/** A scene renderer shares SPA's owner, store, scheduler, and component lifecycle. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","names":[],"sources":["../../src/renderer.ts"],"sourcesContent":["import type { CapabilityTarget } from \"./capabilities.ts\"\nimport { capabilityProps } from \"./capabilities.ts\"\nimport type { Child, Component, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tfail,\n\tinvalidate,\n\tisPresent,\n\tobserve,\n\towner,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment, merge } from \"./jsx-runtime.ts\"\n\nexport interface SceneHost<N> {\n\ttarget?(node: N): CapabilityTarget\n\tcreate(type: string, props: Record<string, any>): N\n\tupdate(\n\t\tnode: N,\n\t\tprops: Record<string, any>,\n\t\tprevious: Record<string, any>,\n\t): void\n\tchildren(parent: N, children: N[], activeChildren: N[]): void\n\tdestroy(node: N): void\n}\ntype SceneNodes<N> = (activeOnly?: boolean) => N[]\n\ninterface Entry<N> {\n\tscope: Scope\n\tvalue: Child\n\tnodes: SceneNodes<N>\n}\n\nexport interface SceneRenderer<N> {\n\tmount(setup: () => Child, parent: N): void\n\trender(\n\t\tsetup: () => Child,\n\t\tparent: N,\n\t\toptions?: RootOptions,\n\t): { flush(): void; dispose(): void }\n}\n\n/** A scene renderer shares SPA's owner, store, scheduler, and component lifecycle. */\nexport function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {\n\tfunction mount(\n\t\tsource: () => Child,\n\t\tscope: Scope,\n\t\tchanged: () => void,\n\t): SceneNodes<N> {\n\t\tlet entries: Entry<N>[] = []\n\t\tconst presence = scope._root._presence?.collection<Entry<N>, Child>(\n\t\t\t(entry) => entry.scope,\n\t\t\t(entry, value) => same(entry.value, value),\n\t\t)\n\t\tconst retire = (\n\t\t\tentry: Entry<N>,\n\t\t\tid: string,\n\t\t\teligible: boolean,\n\t\t\tindex: number,\n\t\t) => {\n\t\t\tif (presence)\n\t\t\t\tpresence.remove(entry, id, eligible, index, () => {\n\t\t\t\t\tif (!scope._dead) changed()\n\t\t\t\t})\n\t\t\telse dispose(entry.scope)\n\t\t}\n\t\tobserve(scope, source, (next) => {\n\t\t\tconst values = (\n\t\t\t\tArray.isArray(next) ? next.flat(Infinity) : [next]\n\t\t\t) as Child[]\n\t\t\tconst previous = entries\n\t\t\tconst old = new Map(\n\t\t\t\tentries.map((entry, i) => [key(entry.value, i), entry]),\n\t\t\t)\n\t\t\tconst seen = new Set<string>()\n\t\t\tentries = values.map((value, i) => {\n\t\t\t\tconst id = key(value, i)\n\t\t\t\tif (seen.has(id)) throw new Error(`spa: duplicate scene key`)\n\t\t\t\tseen.add(id)\n\t\t\t\tlet entry = old.get(id)\n\t\t\t\told.delete(id)\n\t\t\t\tif (entry && !same(entry.value, value)) {\n\t\t\t\t\tretire(\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tvalue == null || typeof value === `boolean`,\n\t\t\t\t\t\tprevious.indexOf(entry),\n\t\t\t\t\t)\n\t\t\t\t\tentry = undefined\n\t\t\t\t}\n\t\t\t\tentry ??= presence?.take(id, value)\n\t\t\t\tif (entry) {\n\t\t\t\t\tentry.value = value\n\t\t\t\t\tscope._root._presence?.resume(entry.scope)\n\t\t\t\t\tinvalidate(entry.scope)\n\t\t\t\t\treturn entry\n\t\t\t\t}\n\t\t\t\tconst childScope = createScope(scope)\n\t\t\t\tconst created: Entry<N> = { scope: childScope, value, nodes: null! }\n\t\t\t\tcreated.nodes = build(() => created.value, childScope, changed)\n\t\t\t\treturn created\n\t\t\t})\n\t\t\tfor (const [id, entry] of old)\n\t\t\t\tretire(entry, id, true, previous.indexOf(entry))\n\t\t\tchanged()\n\t\t})\n\t\treturn (activeOnly = false) => {\n\t\t\tconst rendered = activeOnly\n\t\t\t\t? entries\n\t\t\t\t: (presence?.merge(entries) ?? entries)\n\t\t\treturn rendered.flatMap((entry) => entry.nodes(activeOnly))\n\t\t}\n\t}\n\tfunction key(value: Child, i: number): string {\n\t\tconst explicit = (value as VNode | null)?.props?.[`key`]\n\t\treturn explicit == null ? `index:${i}` : `key:${explicit}`\n\t}\n\tfunction same(a: Child, b: Child): boolean {\n\t\treturn (\n\t\t\ttypeof a === typeof b &&\n\t\t\t(a as VNode | null)?.type === (b as VNode | null)?.type\n\t\t)\n\t}\n\tfunction build(\n\t\tsource: () => Child,\n\t\tscope: Scope,\n\t\tchanged: () => void,\n\t): SceneNodes<N> {\n\t\tconst value = untrack(source)\n\t\tif (typeof value === `function`)\n\t\t\treturn mount(() => (source() as () => Child)(), scope, changed)\n\t\tif (value == null || typeof value === `boolean`) return () => []\n\t\tif (typeof value !== `object`)\n\t\t\tthrow new Error(`spa: scene children must be nodes`)\n\t\tif (!(`type` in value) || !(`props` in value))\n\t\t\tthrow new Error(`spa: invalid scene child`)\n\t\tconst vnode = value\n\t\tconst props = merge(() => (source() as VNode).props)\n\t\tif (!vnode.type || vnode.type === Fragment)\n\t\t\treturn mount(() => props[`children`], scope, changed)\n\t\tif (typeof vnode.type === `function`) {\n\t\t\tconst output = within(scope, () =>\n\t\t\t\tuntrack(() => (vnode.type as Component)(props)),\n\t\t\t)\n\t\t\treturn mount(() => output, scope, changed)\n\t\t}\n\t\tconst node = host.create(\n\t\t\tvnode.type,\n\t\t\tuntrack(() => props),\n\t\t)\n\t\tscope._cleanups.add(() => {\n\t\t\thost.destroy(node)\n\t\t})\n\t\tconst nativeProps = capabilityProps(\n\t\t\tscope,\n\t\t\thost.target?.(node) ?? { kind: `scene`, node },\n\t\t\t() => ({ ...props }),\n\t\t)\n\t\tlet previous: Record<string, any> = {}\n\t\tobserve(\n\t\t\tscope,\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\thost.update(node, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tlet children: SceneNodes<N> = () => []\n\t\tconst sync = () => {\n\t\t\thost.children(node, children(), children(true))\n\t\t}\n\t\tchildren = mount(() => props[`children`], scope, sync)\n\t\tsync()\n\t\tconst ref = untrack(() => props[`ref`])\n\t\tif (ref)\n\t\t\tscope._root._mounts!.unshift(() => {\n\t\t\t\tif (!scope._dead) {\n\t\t\t\t\tscope._cleanups.add(() => ref(null))\n\t\t\t\t\tref(node)\n\t\t\t\t}\n\t\t\t})\n\t\treturn () => [node]\n\t}\n\tfunction attach(setup: () => Child, parent: N, scope: Scope) {\n\t\tlet nodes: SceneNodes<N> = () => []\n\t\tconst sync = () => {\n\t\t\thost.children(parent, nodes(), nodes(true))\n\t\t}\n\t\tnodes = mount(() => untrack(setup), scope, sync)\n\t\tsync()\n\t\tscope._cleanups.add(() => {\n\t\t\thost.children(parent, [], [])\n\t\t})\n\t}\n\treturn {\n\t\t/** Attach beneath the current component; disposal follows its lifetime. */\n\t\tmount(setup: () => Child, parent: N): void {\n\t\t\tif (!owner) throw new Error(`spa: scene mount requires an owner`)\n\t\t\tconst scope = createScope(owner)\n\t\t\ttry {\n\t\t\t\tattach(setup, parent, scope)\n\t\t\t} catch (error) {\n\t\t\t\tfail(scope, error)\n\t\t\t}\n\t\t},\n\t\trender(setup: () => Child, parent: N, options: RootOptions = {}) {\n\t\t\tconst root = createRoot(options)\n\t\t\ttry {\n\t\t\t\twithin(root, () => {\n\t\t\t\t\tattach(setup, parent, root)\n\t\t\t\t})\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\tfail(root, error)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tflush: root.flush,\n\t\t\t\tdispose: () => {\n\t\t\t\t\tdispose(root)\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t}\n}\n\n/** Define a typed scene component without introducing another JSX runtime. */\nexport function sceneComponent<P>(type: string): (props: P) => VNode {\n\treturn (props) => ({ type, props: props as Record<string, any> })\n}\n\n/** Bind imperative scene work to the current owner and its reactive dependencies. */\nexport function bindScene<T>(read: () => T, apply: (value: T) => void): void {\n\tobserve(owner!, read, apply)\n}\n\n/** Scene drawing follows an installed capability clock, or the browser clock. */\nexport function onSceneFrame(\n\tcallback: (time: number) => void,\n\tinfrastructure = false,\n): void {\n\tconst scope = owner!\n\tconst clocks = [...scope._root._capabilities.values()].filter(\n\t\t(capability) => capability.scheduleFrame,\n\t)\n\tif (clocks.length > 1)\n\t\tthrow new Error(`spa: multiple frame clock capabilities`)\n\tconst draw = (time: number) => {\n\t\tif (scope._dead || (!infrastructure && !isPresent(scope))) return\n\t\ttry {\n\t\t\tcallback(time)\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tfail(scope._root, error)\n\t\t\t} catch (failure) {\n\t\t\t\tscope._root.error(failure)\n\t\t\t}\n\t\t}\n\t}\n\tlet stop: () => void\n\tif (clocks[0]) stop = clocks[0].scheduleFrame!(draw)\n\telse {\n\t\tlet frame = 0\n\t\tconst tick = (time: number) => {\n\t\t\tif (scope._dead) return\n\t\t\tdraw(time)\n\t\t\tif (!scope._dead) frame = requestAnimationFrame(tick)\n\t\t}\n\t\tframe = requestAnimationFrame(tick)\n\t\tstop = () => {\n\t\t\tcancelAnimationFrame(frame)\n\t\t}\n\t}\n\tscope._cleanups.add(stop)\n}\n"],"mappings":";;;;;AA8CA,SAAgB,oBAAuB,MAAsC;CAC5E,SAAS,MACR,QACA,OACA,SACgB;EAChB,IAAI,UAAsB,CAAC;EAC3B,MAAM,WAAW,MAAM,MAAM,WAAW,YACtC,UAAU,MAAM,QAChB,OAAO,UAAU,KAAK,MAAM,OAAO,KAAK,CAC1C;EACA,MAAM,UACL,OACA,IACA,UACA,UACI;GACJ,IAAI,UACH,SAAS,OAAO,OAAO,IAAI,UAAU,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AAgB,eAAkB,MAAmC;CACpE,QAAQ,WAAW;EAAE;EAAa;CAA6B;AAChE;;AAGA,SAAgB,UAAa,MAAe,OAAiC;CAC5E,QAAQ,OAAQ,MAAM,KAAK;AAC5B;;AAGA,SAAgB,aACf,UACA,iBAAiB,OACV;CACP,MAAM,QAAQ;CACd,MAAM,SAAS,CAAC,GAAG,MAAM,MAAM,cAAc,OAAO,CAAC,CAAC,CAAC,QACrD,eAAe,WAAW,aAC5B;CACA,IAAI,OAAO,SAAS,GACnB,MAAM,IAAI,MAAM,wCAAwC;CACzD,MAAM,QAAQ,SAAiB;EAC9B,IAAI,MAAM,SAAU,CAAC,kBAAkB,CAAC,UAAU,KAAK,GAAI;EAC3D,IAAI;GACH,SAAS,IAAI;EACd,SAAS,OAAO;GACf,IAAI;IACH,KAAK,MAAM,OAAO,KAAK;GACxB,SAAS,SAAS;IACjB,MAAM,MAAM,MAAM,OAAO;GAC1B;EACD;CACD;CACA,IAAI;CACJ,IAAI,OAAO,IAAI,OAAO,OAAO,EAAE,CAAC,cAAe,IAAI;MAC9C;EACJ,IAAI,QAAQ;EACZ,MAAM,QAAQ,SAAiB;GAC9B,IAAI,MAAM,OAAO;GACjB,KAAK,IAAI;GACT,IAAI,CAAC,MAAM,OAAO,QAAQ,sBAAsB,IAAI;EACrD;EACA,QAAQ,sBAAsB,IAAI;EAClC,aAAa;GACZ,qBAAqB,KAAK;EAC3B;CACD;CACA,MAAM,UAAU,IAAI,IAAI;AACzB"}
|
|
1
|
+
{"version":3,"file":"renderer.js","names":[],"sources":["../../src/renderer.ts"],"sourcesContent":["import type { CapabilityTarget } from \"./capabilities.ts\"\nimport { capabilityProps } from \"./capabilities.ts\"\nimport type {\n\tChildren,\n\tComponent,\n\tRootOptions,\n\tScope,\n\tSpaElement,\n} from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tfail,\n\tinvalidate,\n\tisPresent,\n\tobserve,\n\towner,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment, merge } from \"./jsx-runtime.ts\"\n\nexport interface SceneHost<N> {\n\ttarget?(node: N): CapabilityTarget\n\tcreate(type: string, props: Record<string, any>): N\n\tupdate(\n\t\tnode: N,\n\t\tprops: Record<string, any>,\n\t\tprevious: Record<string, any>,\n\t): void\n\tchildren(parent: N, children: N[], activeChildren: N[]): void\n\tdestroy(node: N): void\n}\ntype SceneNodes<N> = (activeOnly?: boolean) => N[]\n\ninterface Entry<N> {\n\tscope: Scope\n\tvalue: Children\n\tnodes: SceneNodes<N>\n}\n\nexport interface SceneRenderer<N> {\n\tmount(setup: () => Children, parent: N): void\n\trender(\n\t\tsetup: () => Children,\n\t\tparent: N,\n\t\toptions?: RootOptions,\n\t): { flush(): void; dispose(): void }\n}\n\n/** A scene renderer shares SPA's owner, store, scheduler, and component lifecycle. */\nexport function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {\n\tfunction mount(\n\t\tsource: () => Children,\n\t\tscope: Scope,\n\t\tchanged: () => void,\n\t): SceneNodes<N> {\n\t\tlet entries: Entry<N>[] = []\n\t\tconst presence = scope._root._presence?.collection<Entry<N>, Children>(\n\t\t\t(entry) => entry.scope,\n\t\t\t(entry, value) => same(entry.value, value),\n\t\t)\n\t\tconst retire = (\n\t\t\tentry: Entry<N>,\n\t\t\tid: string,\n\t\t\teligible: boolean,\n\t\t\tindex: number,\n\t\t) => {\n\t\t\tif (presence)\n\t\t\t\tpresence.remove(entry, id, eligible, index, () => {\n\t\t\t\t\tif (!scope._dead) changed()\n\t\t\t\t})\n\t\t\telse dispose(entry.scope)\n\t\t}\n\t\tobserve(scope, source, (next) => {\n\t\t\tconst values = (\n\t\t\t\tArray.isArray(next) ? next.flat(Infinity) : [next]\n\t\t\t) as Children[]\n\t\t\tconst previous = entries\n\t\t\tconst old = new Map(\n\t\t\t\tentries.map((entry, i) => [key(entry.value, i), entry]),\n\t\t\t)\n\t\t\tconst seen = new Set<string>()\n\t\t\tentries = values.map((value, i) => {\n\t\t\t\tconst id = key(value, i)\n\t\t\t\tif (seen.has(id)) throw new Error(`spa: duplicate scene key`)\n\t\t\t\tseen.add(id)\n\t\t\t\tlet entry = old.get(id)\n\t\t\t\told.delete(id)\n\t\t\t\tif (entry && !same(entry.value, value)) {\n\t\t\t\t\tretire(\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tvalue == null || typeof value === `boolean`,\n\t\t\t\t\t\tprevious.indexOf(entry),\n\t\t\t\t\t)\n\t\t\t\t\tentry = undefined\n\t\t\t\t}\n\t\t\t\tentry ??= presence?.take(id, value)\n\t\t\t\tif (entry) {\n\t\t\t\t\tentry.value = value\n\t\t\t\t\tscope._root._presence?.resume(entry.scope)\n\t\t\t\t\tinvalidate(entry.scope)\n\t\t\t\t\treturn entry\n\t\t\t\t}\n\t\t\t\tconst childScope = createScope(scope)\n\t\t\t\tconst created: Entry<N> = { scope: childScope, value, nodes: null! }\n\t\t\t\tcreated.nodes = build(() => created.value, childScope, changed)\n\t\t\t\treturn created\n\t\t\t})\n\t\t\tfor (const [id, entry] of old)\n\t\t\t\tretire(entry, id, true, previous.indexOf(entry))\n\t\t\tchanged()\n\t\t})\n\t\treturn (activeOnly = false) => {\n\t\t\tconst rendered = activeOnly\n\t\t\t\t? entries\n\t\t\t\t: (presence?.merge(entries) ?? entries)\n\t\t\treturn rendered.flatMap((entry) => entry.nodes(activeOnly))\n\t\t}\n\t}\n\tfunction key(value: Children, i: number): string {\n\t\tconst explicit = (value as SpaElement | null)?.props?.[`key`]\n\t\treturn explicit == null ? `index:${i}` : `key:${explicit}`\n\t}\n\tfunction same(a: Children, b: Children): boolean {\n\t\treturn (\n\t\t\ttypeof a === typeof b &&\n\t\t\t(a as SpaElement | null)?.type === (b as SpaElement | null)?.type\n\t\t)\n\t}\n\tfunction build(\n\t\tsource: () => Children,\n\t\tscope: Scope,\n\t\tchanged: () => void,\n\t): SceneNodes<N> {\n\t\tconst value = untrack(source)\n\t\tif (typeof value === `function`)\n\t\t\treturn mount(() => (source() as () => Children)(), scope, changed)\n\t\tif (value == null || typeof value === `boolean`) return () => []\n\t\tif (typeof value !== `object`)\n\t\t\tthrow new Error(`spa: scene children must be nodes`)\n\t\tif (!(`type` in value) || !(`props` in value))\n\t\t\tthrow new Error(`spa: invalid scene child`)\n\t\tconst vnode = value\n\t\tconst props = merge(() => (source() as SpaElement).props)\n\t\tif (!vnode.type || vnode.type === Fragment)\n\t\t\treturn mount(() => props[`children`], scope, changed)\n\t\tif (typeof vnode.type === `function`) {\n\t\t\tconst output = within(scope, () =>\n\t\t\t\tuntrack(() => (vnode.type as Component)(props)),\n\t\t\t)\n\t\t\treturn mount(() => output, scope, changed)\n\t\t}\n\t\tconst node = host.create(\n\t\t\tvnode.type,\n\t\t\tuntrack(() => props),\n\t\t)\n\t\tscope._cleanups.add(() => {\n\t\t\thost.destroy(node)\n\t\t})\n\t\tconst nativeProps = capabilityProps(\n\t\t\tscope,\n\t\t\thost.target?.(node) ?? { kind: `scene`, node },\n\t\t\t() => ({ ...props }),\n\t\t)\n\t\tlet previous: Record<string, any> = {}\n\t\tobserve(\n\t\t\tscope,\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\thost.update(node, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tlet children: SceneNodes<N> = () => []\n\t\tconst sync = () => {\n\t\t\thost.children(node, children(), children(true))\n\t\t}\n\t\tchildren = mount(() => props[`children`], scope, sync)\n\t\tsync()\n\t\tconst ref = untrack(() => props[`ref`])\n\t\tif (ref)\n\t\t\tscope._root._mounts!.unshift(() => {\n\t\t\t\tif (!scope._dead) {\n\t\t\t\t\tscope._cleanups.add(() => ref(null))\n\t\t\t\t\tref(node)\n\t\t\t\t}\n\t\t\t})\n\t\treturn () => [node]\n\t}\n\tfunction attach(setup: () => Children, parent: N, scope: Scope) {\n\t\tlet nodes: SceneNodes<N> = () => []\n\t\tconst sync = () => {\n\t\t\thost.children(parent, nodes(), nodes(true))\n\t\t}\n\t\tnodes = mount(() => untrack(setup), scope, sync)\n\t\tsync()\n\t\tscope._cleanups.add(() => {\n\t\t\thost.children(parent, [], [])\n\t\t})\n\t}\n\treturn {\n\t\t/** Attach beneath the current component; disposal follows its lifetime. */\n\t\tmount(setup: () => Children, parent: N): void {\n\t\t\tif (!owner) throw new Error(`spa: scene mount requires an owner`)\n\t\t\tconst scope = createScope(owner)\n\t\t\ttry {\n\t\t\t\tattach(setup, parent, scope)\n\t\t\t} catch (error) {\n\t\t\t\tfail(scope, error)\n\t\t\t}\n\t\t},\n\t\trender(setup: () => Children, parent: N, options: RootOptions = {}) {\n\t\t\tconst root = createRoot(options)\n\t\t\ttry {\n\t\t\t\twithin(root, () => {\n\t\t\t\t\tattach(setup, parent, root)\n\t\t\t\t})\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\tfail(root, error)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tflush: root.flush,\n\t\t\t\tdispose: () => {\n\t\t\t\t\tdispose(root)\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t}\n}\n\n/** Define a typed scene component without introducing another JSX runtime. */\nexport function sceneComponent<P>(type: string): (props: P) => SpaElement {\n\treturn (props) => ({ type, props: props as Record<string, any> })\n}\n\n/** Bind imperative scene work to the current owner and its reactive dependencies. */\nexport function bindScene<T>(read: () => T, apply: (value: T) => void): void {\n\tobserve(owner!, read, apply)\n}\n\n/** Scene drawing follows an installed capability clock, or the browser clock. */\nexport function onSceneFrame(\n\tcallback: (time: number) => void,\n\tinfrastructure = false,\n): void {\n\tconst scope = owner!\n\tconst clocks = [...scope._root._capabilities.values()].filter(\n\t\t(capability) => capability.scheduleFrame,\n\t)\n\tif (clocks.length > 1)\n\t\tthrow new Error(`spa: multiple frame clock capabilities`)\n\tconst draw = (time: number) => {\n\t\tif (scope._dead || (!infrastructure && !isPresent(scope))) return\n\t\ttry {\n\t\t\tcallback(time)\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tfail(scope._root, error)\n\t\t\t} catch (failure) {\n\t\t\t\tscope._root.error(failure)\n\t\t\t}\n\t\t}\n\t}\n\tlet stop: () => void\n\tif (clocks[0]) stop = clocks[0].scheduleFrame!(draw)\n\telse {\n\t\tlet frame = 0\n\t\tconst tick = (time: number) => {\n\t\t\tif (scope._dead) return\n\t\t\tdraw(time)\n\t\t\tif (!scope._dead) frame = requestAnimationFrame(tick)\n\t\t}\n\t\tframe = requestAnimationFrame(tick)\n\t\tstop = () => {\n\t\t\tcancelAnimationFrame(frame)\n\t\t}\n\t}\n\tscope._cleanups.add(stop)\n}\n"],"mappings":";;;;;AAoDA,SAAgB,oBAAuB,MAAsC;CAC5E,SAAS,MACR,QACA,OACA,SACgB;EAChB,IAAI,UAAsB,CAAC;EAC3B,MAAM,WAAW,MAAM,MAAM,WAAW,YACtC,UAAU,MAAM,QAChB,OAAO,UAAU,KAAK,MAAM,OAAO,KAAK,CAC1C;EACA,MAAM,UACL,OACA,IACA,UACA,UACI;GACJ,IAAI,UACH,SAAS,OAAO,OAAO,IAAI,UAAU,aAAa;IACjD,IAAI,CAAC,MAAM,OAAO,QAAQ;GAC3B,CAAC;QACG,QAAQ,MAAM,KAAK;EACzB;EACA,QAAQ,OAAO,SAAS,SAAS;GAChC,MAAM,SACL,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI;GAElD,MAAM,WAAW;GACjB,MAAM,MAAM,IAAI,IACf,QAAQ,KAAK,OAAO,MAAM,CAAC,IAAI,MAAM,OAAO,CAAC,GAAG,KAAK,CAAC,CACvD;GACA,MAAM,uBAAO,IAAI,IAAY;GAC7B,UAAU,OAAO,KAAK,OAAO,MAAM;IAClC,MAAM,KAAK,IAAI,OAAO,CAAC;IACvB,IAAI,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,MAAM,0BAA0B;IAC5D,KAAK,IAAI,EAAE;I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O,KAAK;GACxB,SAAS,SAAS;IACjB,MAAM,MAAM,MAAM,OAAO;GAC1B;EACD;CACD;CACA,IAAI;CACJ,IAAI,OAAO,IAAI,OAAO,OAAO,EAAE,CAAC,cAAe,IAAI;MAC9C;EACJ,IAAI,QAAQ;EACZ,MAAM,QAAQ,SAAiB;GAC9B,IAAI,MAAM,OAAO;GACjB,KAAK,IAAI;GACT,IAAI,CAAC,MAAM,OAAO,QAAQ,sBAAsB,IAAI;EACrD;EACA,QAAQ,sBAAsB,IAAI;EAClC,aAAa;GACZ,qBAAqB,KAAK;EAC3B;CACD;CACA,MAAM,UAAU,IAAI,IAAI;AACzB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { r as validateCapabilities, t as capabilityNamespace } from "./capabilities-BkQ2i0vV.js";
|
|
2
|
+
import { d as plain, n as createScope, p as untrack, r as dispose, t as createRoot, x as within } from "./core-DxPiKryn.js";
|
|
3
|
+
import { Fragment } from "./jsx-runtime.js";
|
|
4
|
+
// src/server-renderer.ts
|
|
5
|
+
const escape = (value) => String(value).replace(/[&<>"']/g, (char) => ({
|
|
6
|
+
"&": `&`,
|
|
7
|
+
"<": `<`,
|
|
8
|
+
">": `>`,
|
|
9
|
+
"\"": `"`,
|
|
10
|
+
"'": `'`
|
|
11
|
+
})[char]);
|
|
12
|
+
const voidTags = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
|
|
13
|
+
const booleans = new Set(`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(` `));
|
|
14
|
+
function stringify(value, owner, namespace = `html`, selectValue) {
|
|
15
|
+
if (typeof value === `function`) {
|
|
16
|
+
const values = [untrack(value)].flat(Infinity);
|
|
17
|
+
const keys = /* @__PURE__ */ new Set();
|
|
18
|
+
return `<!--{-->` + values.map((child, index) => {
|
|
19
|
+
const explicit = child?.props?.[`key`];
|
|
20
|
+
const key = explicit == null ? index : String(explicit);
|
|
21
|
+
if (keys.has(key)) throw new Error(`spa: duplicate key`);
|
|
22
|
+
keys.add(key);
|
|
23
|
+
return `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`;
|
|
24
|
+
}).join(``) + `<!--}-->`;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value)) return value.map((child) => stringify(child, owner, namespace, selectValue)).join(``);
|
|
27
|
+
if (value == null || typeof value === `boolean`) return ``;
|
|
28
|
+
if (typeof value !== `object`) return `<!--t-->${escape(value)}`;
|
|
29
|
+
if (!(`type` in value) || !(`props` in value)) throw new TypeError(`spa: invalid child`);
|
|
30
|
+
const { type, props } = value;
|
|
31
|
+
if (!type || type === Fragment) return stringify(() => props[`children`], owner, namespace, selectValue);
|
|
32
|
+
if (typeof type === `function`) {
|
|
33
|
+
const childOwner = createScope(owner);
|
|
34
|
+
return within(childOwner, () => stringify(untrack(() => type(props)), childOwner, namespace, selectValue));
|
|
35
|
+
}
|
|
36
|
+
if (!/^[A-Za-z][\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`);
|
|
37
|
+
if (type === `astro-slot`) return `<astro-slot${props[`name`] ? ` name="${escape(props[`name`])}"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`;
|
|
38
|
+
const ns = type === `svg` ? `svg` : namespace;
|
|
39
|
+
validateCapabilities(owner, props);
|
|
40
|
+
let attrs = ``;
|
|
41
|
+
let textValue;
|
|
42
|
+
for (let key of Object.keys(props)) {
|
|
43
|
+
if (capabilityNamespace(key) !== void 0 || key === `children` || key === `ref` || key === `key` || key.startsWith(`on`)) continue;
|
|
44
|
+
if (/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(key)) throw new Error(`spa: owned content`);
|
|
45
|
+
let attribute = props[key];
|
|
46
|
+
if (ns === `html`) {
|
|
47
|
+
if (key === `defaultValue` && (type === `input` || type === `textarea`)) {
|
|
48
|
+
if (props[`value`] != null) continue;
|
|
49
|
+
key = `value`;
|
|
50
|
+
} else if (key === `defaultChecked` && type === `input`) {
|
|
51
|
+
if (props[`checked`] != null) continue;
|
|
52
|
+
key = `checked`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (key === `className`) key = `class`;
|
|
56
|
+
if (key === `htmlFor`) key = `for`;
|
|
57
|
+
if (!/^[^\s"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`);
|
|
58
|
+
if (key === `value` && (type === `select` || type === `textarea`)) {
|
|
59
|
+
textValue = attribute ?? textValue;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (key === `style` && attribute != null && typeof attribute !== `string`) throw new TypeError(`spa: CSS string required`);
|
|
63
|
+
const boolean = ns === `html` && (booleans.has(key.toLowerCase()) || /^(capture|download|hidden)$/.test(key) && typeof attribute === `boolean`);
|
|
64
|
+
if (attribute == null || boolean && !attribute) continue;
|
|
65
|
+
attrs += boolean ? ` ${key}=""` : ` ${key}="${escape(attribute)}"`;
|
|
66
|
+
}
|
|
67
|
+
if (type === `option` && selectValue !== void 0 && String(props[`value`]) === String(selectValue)) attrs += ` selected=""`;
|
|
68
|
+
if (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`;
|
|
69
|
+
if (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {
|
|
70
|
+
let text = plain(type === `textarea` ? textValue ?? props[`children`] : props[`children`]);
|
|
71
|
+
if (type === `textarea` && text.startsWith(`\n`)) text = `\n${text}`;
|
|
72
|
+
if (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text)) throw new Error(`spa: unsafe raw text`);
|
|
73
|
+
return `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`;
|
|
74
|
+
}
|
|
75
|
+
const children = stringify(() => props[`children`], owner, type === `foreignObject` ? `html` : ns, type === `select` ? textValue : selectValue);
|
|
76
|
+
return `<${type}${attrs}>${children}</${type}>`;
|
|
77
|
+
}
|
|
78
|
+
function renderToStringWithReads(setup, options = {}, onRead) {
|
|
79
|
+
const root = createRoot(options, true);
|
|
80
|
+
root._onRead = onRead;
|
|
81
|
+
if (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`);
|
|
82
|
+
try {
|
|
83
|
+
return `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`;
|
|
84
|
+
} finally {
|
|
85
|
+
dispose(root);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export { renderToStringWithReads as t };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=server-renderer-CUQXh9oF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-renderer-CUQXh9oF.js","names":[],"sources":["../../src/server-renderer.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\n\nimport { capabilityNamespace, validateCapabilities } from \"./capabilities.ts\"\nimport type { Children, RootOptions, Scope, SpaElement } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&`, \"<\": `<`, \">\": `>`, '\"': `"`, \"'\": `'` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(\n\t\t` `,\n\t),\n)\nfunction stringify(\n\tvalue: Children,\n\towner: Scope,\n\tnamespace = `html`,\n\tselectValue?: string | number,\n): string {\n\tif (typeof value === `function`) {\n\t\tconst values = ([untrack(value)] as unknown[]).flat(Infinity) as Children[]\n\t\tconst keys = new Set<unknown>()\n\t\treturn (\n\t\t\t`<!--{-->` +\n\t\t\tvalues\n\t\t\t\t.map((child, index) => {\n\t\t\t\t\tconst explicit = (child as SpaElement | null)?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (keys.has(key)) throw new Error(`spa: duplicate key`)\n\t\t\t\t\tkeys.add(key)\n\t\t\t\t\treturn `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`\n\t\t\t\t})\n\t\t\t\t.join(``) +\n\t\t\t`<!--}-->`\n\t\t)\n\t}\n\tif (Array.isArray(value))\n\t\treturn value\n\t\t\t.map((child) => stringify(child, owner, namespace, selectValue))\n\t\t\t.join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (typeof value !== `object`) return `<!--t-->${escape(value)}`\n\tif (!(`type` in value) || !(`props` in value))\n\t\tthrow new TypeError(`spa: invalid child`)\n\tconst { type, props } = value\n\tif (!type || type === Fragment)\n\t\treturn stringify(() => props[`children`], owner, namespace, selectValue)\n\tif (typeof type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\treturn within(childOwner, () =>\n\t\t\tstringify(\n\t\t\t\tuntrack(() => type(props)),\n\t\t\t\tchildOwner,\n\t\t\t\tnamespace,\n\t\t\t\tselectValue,\n\t\t\t),\n\t\t)\n\t}\n\tif (!/^[A-Za-z][\\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`)\n\tif (type === `astro-slot`)\n\t\treturn `<astro-slot${props[`name`] ? ` name=\"${escape(props[`name`])}\"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`\n\tconst ns = type === `svg` ? `svg` : namespace\n\tvalidateCapabilities(owner, props)\n\tlet attrs = ``\n\tlet textValue: string | number | undefined\n\tfor (let key of Object.keys(props)) {\n\t\tif (\n\t\t\tcapabilityNamespace(key) !== undefined ||\n\t\t\tkey === `children` ||\n\t\t\tkey === `ref` ||\n\t\t\tkey === `key` ||\n\t\t\tkey.startsWith(`on`)\n\t\t)\n\t\t\tcontinue\n\t\tif (\n\t\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`spa: owned content`)\n\t\tlet attribute = props[key]\n\t\tif (ns === `html`) {\n\t\t\tif (key === `defaultValue` && (type === `input` || type === `textarea`)) {\n\t\t\t\tif (props[`value`] != null) continue\n\t\t\t\tkey = `value`\n\t\t\t} else if (key === `defaultChecked` && type === `input`) {\n\t\t\t\tif (props[`checked`] != null) continue\n\t\t\t\tkey = `checked`\n\t\t\t}\n\t\t}\n\t\tif (key === `className`) key = `class`\n\t\tif (key === `htmlFor`) key = `for`\n\t\tif (!/^[^\\s\"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)\n\t\tif (key === `value` && (type === `select` || type === `textarea`)) {\n\t\t\ttextValue = attribute ?? textValue\n\t\t\tcontinue\n\t\t}\n\t\tif (key === `style` && attribute != null && typeof attribute !== `string`)\n\t\t\tthrow new TypeError(`spa: CSS string required`)\n\t\tconst boolean =\n\t\t\tns === `html` &&\n\t\t\t(booleans.has(key.toLowerCase()) ||\n\t\t\t\t(/^(capture|download|hidden)$/.test(key) &&\n\t\t\t\t\ttypeof attribute === `boolean`))\n\t\tif (attribute == null || (boolean && !attribute)) continue\n\t\tattrs += boolean ? ` ${key}=\"\"` : ` ${key}=\"${escape(attribute)}\"`\n\t}\n\tif (\n\t\ttype === `option` &&\n\t\tselectValue !== undefined &&\n\t\tString(props[`value`]) === String(selectValue)\n\t)\n\t\tattrs += ` selected=\"\"`\n\tif (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`\n\tif (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {\n\t\tlet text = plain(\n\t\t\ttype === `textarea` ? (textValue ?? props[`children`]) : props[`children`],\n\t\t)\n\t\tif (type === `textarea` && text.startsWith(`\\n`)) text = `\\n${text}`\n\t\tif (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text))\n\t\t\tthrow new Error(`spa: unsafe raw text`)\n\t\treturn `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`\n\t}\n\tconst children = stringify(\n\t\t() => props[`children`],\n\t\towner,\n\t\ttype === `foreignObject` ? `html` : ns,\n\t\ttype === `select` ? textValue : selectValue,\n\t)\n\treturn `<${type}${attrs}>${children}</${type}>`\n}\n\nexport function renderToStringWithReads(\n\tsetup: () => Children,\n\toptions: RootOptions = {},\n\tonRead?: (value: unknown, token: ReadableToken<unknown>) => void,\n): string {\n\tconst root = createRoot(options, true)\n\troot._onRead = onRead\n\tif (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`)\n\ttry {\n\t\treturn `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`\n\t} finally {\n\t\tdispose(root)\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,UAAU,UACf,OAAO,KAAK,CAAC,CAAC,QACb,aACC,UACC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,EAAA,CACtE,KAEH;AACD,MAAM,WACL;AACD,MAAM,WAAW,IAAI,IACpB,qVAAqV,MACpV,GACD,CACD;AACA,SAAS,UACR,OACA,OACA,YAAY,QACZ,aACS;CACT,IAAI,OAAO,UAAU,YAAY;EAChC,MAAM,SAAU,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAe,KAAK,QAAQ;EAC5D,MAAM,uBAAO,IAAI,IAAa;EAC9B,OACC,aACA,OACE,KAAK,OAAO,UAAU;GACtB,MAAM,WAAY,OAA6B,QAAQ;GACvD,MAAM,MAAM,YAAY,OAAO,QAAQ,OAAO,QAAQ;GACtD,IAAI,KAAK,IA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