@atom.io/spa 0.0.8 → 0.0.10
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 +194 -30
- package/README.mdx +78 -20
- package/dist/BrandMarkScene-CBYk-RJ2.js +140 -0
- package/dist/BrandMarkScene-CBYk-RJ2.js.map +1 -0
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.d.ts.map +1 -1
- package/dist/astro-client.js +5 -4
- package/dist/astro-client.js.map +1 -1
- package/dist/astro-resumability-client.d.ts +1 -1
- package/dist/astro-server.js +4 -4
- package/dist/astro-server.js.map +1 -1
- package/dist/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
- package/dist/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
- package/dist/{astro-shared-DZp1x8RQ.d.ts → astro-shared-KxK9OUSj.d.ts} +2 -2
- package/dist/{astro-shared-DZp1x8RQ.d.ts.map → astro-shared-KxK9OUSj.d.ts.map} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/brand-css.d.ts +2 -0
- package/dist/brand-model.d.ts +32 -0
- package/dist/brand-model.d.ts.map +1 -0
- package/dist/brand-model.js +120 -0
- package/dist/brand-model.js.map +1 -0
- package/dist/brand.css +37 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +94 -0
- package/dist/brand.js.map +1 -0
- package/dist/{capabilities-DNcnGRv_.d.ts → capabilities-ChgSs6bp.d.ts} +34 -6
- package/dist/capabilities-ChgSs6bp.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/core-DD2giR6E.js +451 -0
- package/dist/core-DD2giR6E.js.map +1 -0
- package/dist/development/BrandMarkScene-BDdC7K5M.js +140 -0
- package/dist/development/BrandMarkScene-BDdC7K5M.js.map +1 -0
- package/dist/development/astro-client.js +5 -4
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/astro-server.js +4 -4
- package/dist/development/astro-server.js.map +1 -1
- package/dist/development/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
- package/dist/development/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
- package/dist/development/astro.js +1 -1
- package/dist/development/brand-model.js +120 -0
- package/dist/development/brand-model.js.map +1 -0
- package/dist/development/brand.css +37 -0
- package/dist/development/brand.js +94 -0
- package/dist/development/brand.js.map +1 -0
- package/dist/development/core-DrUd8x25.js +465 -0
- package/dist/development/core-DrUd8x25.js.map +1 -0
- package/dist/development/{dom-DQ0M3rLL.js → dom-CEVtlaav.js} +152 -36
- package/dist/development/dom-CEVtlaav.js.map +1 -0
- package/dist/development/floating.js +2 -6
- package/dist/development/floating.js.map +1 -1
- package/dist/development/hot.js +164 -0
- package/dist/development/hot.js.map +1 -0
- package/dist/development/identity-B8wTFkyW.js +121 -0
- package/dist/development/identity-B8wTFkyW.js.map +1 -0
- package/dist/development/index.js +5 -5
- package/dist/development/jsx-runtime-BGDPK50B.js +49 -0
- package/dist/development/jsx-runtime-BGDPK50B.js.map +1 -0
- package/dist/development/jsx-runtime.js +1 -25
- package/dist/development/konva.js +12 -5
- package/dist/development/konva.js.map +1 -1
- package/dist/development/motion.js +41 -39
- package/dist/development/motion.js.map +1 -1
- package/dist/development/renderer.js +41 -40
- package/dist/development/renderer.js.map +1 -1
- package/dist/development/{server-renderer-DCLoMdOX.js → server-renderer-zAqEL1g1.js} +8 -18
- package/dist/development/server-renderer-zAqEL1g1.js.map +1 -0
- package/dist/development/server.js +1 -1
- package/dist/{src-Bme1kz2b.js → development/src-CB7ruwRs.js} +3 -3
- package/dist/development/src-CB7ruwRs.js.map +1 -0
- package/dist/development/three-CsZ6Od1C.js +527 -0
- package/dist/development/three-CsZ6Od1C.js.map +1 -0
- package/dist/development/three.js +1 -508
- package/dist/development/vite-WUiz1ju6.js +545 -0
- package/dist/development/vite-WUiz1ju6.js.map +1 -0
- package/dist/development/vite.js +1 -1
- package/dist/{dom-D8g3roX9.js → dom-DUpa3Sj2.js} +141 -33
- package/dist/dom-DUpa3Sj2.js.map +1 -0
- package/dist/floating.d.ts +1 -1
- package/dist/floating.d.ts.map +1 -1
- package/dist/floating.js +2 -6
- package/dist/floating.js.map +1 -1
- package/dist/hot.d.ts +15 -0
- package/dist/hot.d.ts.map +1 -0
- package/dist/hot.js +19 -0
- package/dist/hot.js.map +1 -0
- package/dist/identity-ByJswZtF.js +121 -0
- package/dist/identity-ByJswZtF.js.map +1 -0
- package/dist/{index-BFnXIfOj.d.ts → index-DdA39aMv.d.ts} +4 -4
- package/dist/{index-BFnXIfOj.d.ts.map → index-DdA39aMv.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/jsx-runtime-BGDPK50B.js +49 -0
- package/dist/jsx-runtime-BGDPK50B.js.map +1 -0
- package/dist/{jsx-runtime-DQnpyT_g.d.ts → jsx-runtime-CCvcEosg.d.ts} +14 -9
- package/dist/jsx-runtime-CCvcEosg.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -25
- package/dist/konva.d.ts +46 -9
- package/dist/konva.d.ts.map +1 -1
- package/dist/konva.js +12 -5
- package/dist/konva.js.map +1 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +41 -39
- package/dist/motion.js.map +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +39 -40
- package/dist/renderer.js.map +1 -1
- package/dist/{server-renderer-D0rsFL_-.js → server-renderer-D7CdyOMo.js} +8 -18
- package/dist/server-renderer-D7CdyOMo.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/size.json +12 -12
- package/dist/{development/src-DoQgCX-O.js → src-B2W_TA_X.js} +3 -3
- package/dist/src-B2W_TA_X.js.map +1 -0
- package/dist/three-DcYxRXPW.js +527 -0
- package/dist/three-DcYxRXPW.js.map +1 -0
- package/dist/three.d.ts +24 -3
- package/dist/three.d.ts.map +1 -1
- package/dist/three.js +1 -508
- package/dist/vite-WUiz1ju6.js +545 -0
- package/dist/vite-WUiz1ju6.js.map +1 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +1 -1
- package/package.json +45 -18
- package/src/BrandMark.module.css +25 -0
- package/src/BrandMark.tsx +106 -0
- package/src/BrandMarkScene.module.css +10 -0
- package/src/BrandMarkScene.tsx +116 -0
- package/src/astro-client.ts +3 -2
- package/src/astro-server.ts +2 -2
- package/src/brand-css.d.ts +2 -0
- package/src/brand-model.ts +177 -0
- package/src/brand.ts +3 -0
- package/src/capabilities.ts +48 -21
- package/src/compiler-hmr.ts +297 -0
- package/src/compiler.ts +127 -25
- package/src/core.ts +282 -33
- package/src/dom-forms.ts +127 -0
- package/src/dom.ts +124 -53
- package/src/floating.ts +2 -6
- package/src/hot.ts +191 -0
- package/src/identity.ts +39 -0
- package/src/index.ts +2 -0
- package/src/jsx-runtime.ts +6 -26
- package/src/jsx-types.d.ts +8 -3
- package/src/konva.ts +66 -10
- package/src/lasertag.d.ts +1 -0
- package/src/motion-layout.ts +55 -26
- package/src/motion.ts +3 -0
- package/src/presence.ts +11 -23
- package/src/props.ts +55 -0
- package/src/renderer.ts +91 -71
- package/src/server-renderer.ts +18 -13
- package/src/three.ts +92 -46
- package/src/use-loadable.ts +2 -2
- package/src/vite.ts +44 -4
- package/dist/capabilities-DNcnGRv_.d.ts.map +0 -1
- package/dist/capabilities-nOIitQ-_.js +0 -65
- package/dist/capabilities-nOIitQ-_.js.map +0 -1
- package/dist/core-B4rJ0xdc.js +0 -268
- package/dist/core-B4rJ0xdc.js.map +0 -1
- package/dist/development/capabilities-nOIitQ-_.js +0 -65
- package/dist/development/capabilities-nOIitQ-_.js.map +0 -1
- package/dist/development/core-BHA7I1nf.js +0 -271
- package/dist/development/core-BHA7I1nf.js.map +0 -1
- package/dist/development/dom-DQ0M3rLL.js.map +0 -1
- package/dist/development/jsx-runtime.js.map +0 -1
- package/dist/development/server-renderer-DCLoMdOX.js.map +0 -1
- package/dist/development/src-DoQgCX-O.js.map +0 -1
- package/dist/development/three.js.map +0 -1
- package/dist/development/vite-Bmyb6P5w.js +0 -265
- package/dist/development/vite-Bmyb6P5w.js.map +0 -1
- package/dist/dom-D8g3roX9.js.map +0 -1
- package/dist/jsx-runtime-DQnpyT_g.d.ts.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/server-renderer-D0rsFL_-.js.map +0 -1
- package/dist/src-Bme1kz2b.js.map +0 -1
- package/dist/three.js.map +0 -1
- package/dist/vite-Bmyb6P5w.js +0 -265
- package/dist/vite-Bmyb6P5w.js.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { _ as scopeCapabilities, c as isPresent } from "./core-DrUd8x25.js";
|
|
2
|
+
import { packCanonical } from "atom.io/foundations/canonical";
|
|
3
|
+
// src/capabilities.ts
|
|
4
|
+
function capabilityNamespace(key) {
|
|
5
|
+
const colon = key.indexOf(`:`);
|
|
6
|
+
if (colon < 0) return void 0;
|
|
7
|
+
const namespace = key.slice(0, colon);
|
|
8
|
+
return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
|
|
9
|
+
}
|
|
10
|
+
function requireCapability(capabilities, namespace) {
|
|
11
|
+
const capability = capabilities.get(namespace);
|
|
12
|
+
if (!capability) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
|
|
13
|
+
return capability;
|
|
14
|
+
}
|
|
15
|
+
function validateCapabilities(scope, props) {
|
|
16
|
+
const capabilities = scopeCapabilities(scope);
|
|
17
|
+
for (const key of Object.keys(props)) {
|
|
18
|
+
const namespace = capabilityNamespace(key);
|
|
19
|
+
if (namespace) requireCapability(capabilities, namespace);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Separate framework properties from native attributes and own their bindings. */
|
|
23
|
+
function capabilityProps(scope, target, read, applyNative) {
|
|
24
|
+
const root = scope._root;
|
|
25
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
26
|
+
let handlers;
|
|
27
|
+
const event = (handler) => {
|
|
28
|
+
const cache = handlers ??= /* @__PURE__ */ new WeakMap();
|
|
29
|
+
let wrapped = cache.get(handler);
|
|
30
|
+
if (!wrapped) {
|
|
31
|
+
wrapped = function(...args) {
|
|
32
|
+
if (!root._presence || isPresent(scope)) return handler.apply(this, args);
|
|
33
|
+
};
|
|
34
|
+
cache.set(handler, wrapped);
|
|
35
|
+
}
|
|
36
|
+
return wrapped;
|
|
37
|
+
};
|
|
38
|
+
if (root._presence) root._presence.target(scope, target);
|
|
39
|
+
else (scope._targets ??= /* @__PURE__ */ new Set()).add(target);
|
|
40
|
+
const cleanup = () => {
|
|
41
|
+
const errors = [];
|
|
42
|
+
for (const binding of [...bindings.values()].reverse()) try {
|
|
43
|
+
binding.dispose();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
errors.push(error);
|
|
46
|
+
}
|
|
47
|
+
bindings.clear();
|
|
48
|
+
if (errors.length) throw new AggregateError(errors);
|
|
49
|
+
};
|
|
50
|
+
scope._cleanups.add(cleanup);
|
|
51
|
+
return (props) => {
|
|
52
|
+
const capabilities = scopeCapabilities(scope);
|
|
53
|
+
const native = {};
|
|
54
|
+
const groups = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const key of Object.keys(props)) {
|
|
56
|
+
const namespace = capabilityNamespace(key);
|
|
57
|
+
if (!namespace) {
|
|
58
|
+
const value = props[key];
|
|
59
|
+
native[key] = key.startsWith(`on`) && typeof value === `function` ? event(value) : value;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const capability = requireCapability(capabilities, namespace);
|
|
63
|
+
const group = groups.get(capability) ?? {};
|
|
64
|
+
group[key.slice(namespace.length + 1)] = props[key];
|
|
65
|
+
groups.set(capability, group);
|
|
66
|
+
}
|
|
67
|
+
const previousStyle = applyNative?.(native);
|
|
68
|
+
for (const [capability, values] of groups) {
|
|
69
|
+
let binding = bindings.get(capability);
|
|
70
|
+
if (!binding) {
|
|
71
|
+
binding = capability.attach(target, scope);
|
|
72
|
+
bindings.set(capability, binding);
|
|
73
|
+
root._presence?.bind(scope, binding, read ?? (() => props), capability.namespace);
|
|
74
|
+
}
|
|
75
|
+
if (previousStyle !== void 0) binding.update(values, previousStyle);
|
|
76
|
+
else binding.update(values);
|
|
77
|
+
}
|
|
78
|
+
for (const [capability, binding] of bindings) if (!groups.has(capability)) {
|
|
79
|
+
bindings.delete(capability);
|
|
80
|
+
root._presence?.unbind(binding);
|
|
81
|
+
binding.dispose();
|
|
82
|
+
}
|
|
83
|
+
return native;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// src/identity.ts
|
|
87
|
+
function childProps(value) {
|
|
88
|
+
return value?.props;
|
|
89
|
+
}
|
|
90
|
+
function hasKey(value) {
|
|
91
|
+
if (Array.isArray(value)) return value.some(hasKey);
|
|
92
|
+
const props = childProps(value);
|
|
93
|
+
return props !== void 0 && Object.hasOwn(props, `key`);
|
|
94
|
+
}
|
|
95
|
+
/** Direct output opts into key tracking when it first mounts. */
|
|
96
|
+
function trackKeys(value) {
|
|
97
|
+
return hasKey(value) ? () => value : value;
|
|
98
|
+
}
|
|
99
|
+
function identifyChildren(output, duplicate = `spa: duplicate key`) {
|
|
100
|
+
const values = [output].flat(1e400);
|
|
101
|
+
const seen = /* @__PURE__ */ new Set();
|
|
102
|
+
return values.map((value, index) => {
|
|
103
|
+
const key = childProps(value)?.[`key`];
|
|
104
|
+
if (key === void 0) return {
|
|
105
|
+
value,
|
|
106
|
+
key,
|
|
107
|
+
id: index
|
|
108
|
+
};
|
|
109
|
+
const id = packCanonical(key);
|
|
110
|
+
if (seen.has(id)) throw new Error(duplicate);
|
|
111
|
+
seen.add(id);
|
|
112
|
+
return {
|
|
113
|
+
value,
|
|
114
|
+
key,
|
|
115
|
+
id
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export { validateCapabilities as a, capabilityProps as i, trackKeys as n, capabilityNamespace as r, identifyChildren as t };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=identity-B8wTFkyW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-B8wTFkyW.js","names":[],"sources":["../../src/capabilities.ts","../../src/identity.ts"],"sourcesContent":["import type { Cleanup, Root, Scope } from \"./core.ts\"\nimport { isPresent, scopeCapabilities } from \"./core.ts\"\nimport type { ExitHandle, PresenceCoordinator } from \"./presence.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tsuspend?(): Cleanup\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\texit?(props: Record<string, unknown>): ExitHandle | undefined\n\tresume?(): void\n\t/** Inline CSS before native style replacement, for restoring capability-owned values. */\n\tupdate(props: Record<string, unknown>, previousStyle?: string): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\t/** Prepare a synchronous update batch and return its commit callback. */\n\tbeforeUpdate?(root: Root): Cleanup\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\t/** SPA supplies ownership for integrations that measure after mount or report async errors. */\n\tattach(target: CapabilityTarget, scope?: Scope): CapabilityBinding\n}\ntype EventHandler = (this: unknown, ...args: unknown[]) => unknown\n\nexport function capabilityNamespace(key: string): string | undefined {\n\tconst colon = key.indexOf(`:`)\n\tif (colon < 0) return undefined\n\tconst namespace = key.slice(0, colon)\n\treturn /^(xml|xmlns|xlink)$/.test(namespace) ? undefined : namespace\n}\nfunction requireCapability(\n\tcapabilities: Map<string, Capability>,\n\tnamespace: string,\n) {\n\tconst capability = capabilities.get(namespace)\n\tif (!capability)\n\t\tthrow new Error(\n\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t)\n\treturn capability\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tconst capabilities = scopeCapabilities(scope)\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace) requireCapability(capabilities, namespace)\n\t}\n}\n\n/** Separate framework properties from native attributes and own their bindings. */\nexport function capabilityProps(\n\tscope: Scope,\n\ttarget: CapabilityTarget,\n\tread?: () => Record<string, any>,\n\tapplyNative?: (props: Record<string, any>) => string | undefined,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst root = scope._root\n\tconst bindings = new Map<Capability, CapabilityBinding>()\n\tlet handlers: WeakMap<EventHandler, EventHandler> | undefined\n\tconst event = (handler: EventHandler) => {\n\t\tconst cache = (handlers ??= new WeakMap())\n\t\tlet wrapped = cache.get(handler)\n\t\tif (!wrapped) {\n\t\t\twrapped = function (this: unknown, ...args: unknown[]) {\n\t\t\t\t// Presence may activate after this listener mounts.\n\t\t\t\tif (!root._presence || isPresent(scope)) return handler.apply(this, args)\n\t\t\t}\n\t\t\tcache.set(handler, wrapped)\n\t\t}\n\t\treturn wrapped\n\t}\n\n\tif (root._presence) root._presence.target(scope, target)\n\telse (scope._targets ??= new Set()).add(target)\n\tconst cleanup: Cleanup = () => {\n\t\tconst errors: unknown[] = []\n\t\tfor (const binding of [...bindings.values()].reverse()) {\n\t\t\ttry {\n\t\t\t\tbinding.dispose()\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error)\n\t\t\t}\n\t\t}\n\t\tbindings.clear()\n\t\tif (errors.length) throw new AggregateError(errors)\n\t}\n\tscope._cleanups.add(cleanup)\n\treturn (props) => {\n\t\tconst capabilities = scopeCapabilities(scope)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<Capability, Record<string, unknown>>()\n\t\tfor (const key of Object.keys(props)) {\n\t\t\tconst namespace = capabilityNamespace(key)\n\t\t\tif (!namespace) {\n\t\t\t\tconst value = props[key]\n\t\t\t\tnative[key] =\n\t\t\t\t\tkey.startsWith(`on`) && typeof value === `function`\n\t\t\t\t\t\t? event(value)\n\t\t\t\t\t\t: value\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst capability = requireCapability(capabilities, namespace)\n\t\t\tconst group = groups.get(capability) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(capability, group)\n\t\t}\n\t\tconst previousStyle = applyNative?.(native)\n\t\tfor (const [capability, values] of groups) {\n\t\t\tlet binding = bindings.get(capability)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = capability.attach(target, scope)\n\t\t\t\tbindings.set(capability, binding)\n\t\t\t\troot._presence?.bind(\n\t\t\t\t\tscope,\n\t\t\t\t\tbinding,\n\t\t\t\t\tread ?? (() => props),\n\t\t\t\t\tcapability.namespace,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (previousStyle !== undefined) binding.update(values, previousStyle)\n\t\t\telse binding.update(values)\n\t\t}\n\t\tfor (const [capability, binding] of bindings)\n\t\t\tif (!groups.has(capability)) {\n\t\t\t\tbindings.delete(capability)\n\t\t\t\troot._presence?.unbind(binding)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n","import type { Canonical } from \"atom.io/foundations/canonical\"\nimport { packCanonical } from \"atom.io/foundations/canonical\"\n\nimport type { Children, SpaElement } from \"./core.ts\"\n\ntype Props = SpaElement[`props`]\ntype Key = Canonical | undefined\ntype Identity = string | number\n\nfunction childProps(value: Children): Props | undefined {\n\treturn (value as SpaElement | null)?.props\n}\n\nfunction hasKey(value: Children): boolean {\n\tif (Array.isArray(value)) return value.some(hasKey)\n\tconst props = childProps(value)\n\treturn props !== undefined && Object.hasOwn(props, `key`)\n}\n\n/** Direct output opts into key tracking when it first mounts. */\nexport function trackKeys(value: Children): Children {\n\treturn hasKey(value) ? () => value : value\n}\n\nexport function identifyChildren(\n\toutput: Children,\n\tduplicate = `spa: duplicate key`,\n): { value: Children; key: Key; id: Identity }[] {\n\tconst values = ([output] as unknown[]).flat(Infinity) as Children[]\n\tconst seen = new Set<string>()\n\treturn values.map((value, index) => {\n\t\tconst key: Key = childProps(value)?.[`key`]\n\t\tif (key === undefined) return { value, key, id: index }\n\t\tconst id = packCanonical(key)\n\t\tif (seen.has(id)) throw new Error(duplicate)\n\t\tseen.add(id)\n\t\treturn { value, key, id }\n\t})\n}\n"],"mappings":";;;AA+BA,SAAgB,oBAAoB,KAAiC;CACpE,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,QAAQ,GAAG,OAAO,KAAA;CACtB,MAAM,YAAY,IAAI,MAAM,GAAG,KAAK;CACpC,OAAO,sBAAsB,KAAK,SAAS,IAAI,KAAA,IAAY;AAC5D;AACA,SAAS,kBACR,cACA,WACC;CACD,MAAM,aAAa,aAAa,IAAI,SAAS;CAC7C,IAAI,CAAC,YACJ,MAAM,IAAI,MACT,oBAAoB,UAAU,kCAC/B;CACD,OAAO;AACR;AACA,SAAgB,qBACf,OACA,OACO;CACP,MAAM,eAAe,kBAAkB,KAAK;CAC5C,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,MAAM,YAAY,oBAAoB,GAAG;EACzC,IAAI,WAAW,kBAAkB,cAAc,SAAS;CACzD;AACD;;AAGA,SAAgB,gBACf,OACA,QACA,MACA,aACsD;CACtD,MAAM,OAAO,MAAM;CACnB,MAAM,2BAAW,IAAI,IAAmC;CACxD,IAAI;CACJ,MAAM,SAAS,YAA0B;EACxC,MAAM,QAAS,6BAAa,IAAI,QAAQ;EACxC,IAAI,UAAU,MAAM,IAAI,OAAO;EAC/B,IAAI,CAAC,SAAS;GACb,UAAU,SAAyB,GAAG,MAAiB;IAEtD,IAAI,CAAC,KAAK,aAAa,UAAU,KAAK,GAAG,OAAO,QAAQ,MAAM,MAAM,IAAI;GACzE;GACA,MAAM,IAAI,SAAS,OAAO;E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AA,GAAW,QAAQ,OAAO,QAAQ,aAAa;QAChE,QAAQ,OAAO,MAAM;EAC3B;EACA,KAAK,MAAM,CAAC,YAAY,YAAY,UACnC,IAAI,CAAC,OAAO,IAAI,UAAU,GAAG;GAC5B,SAAS,OAAO,UAAU;GAC1B,KAAK,WAAW,OAAO,OAAO;GAC9B,QAAQ,QAAQ;EACjB;EACD,OAAO;CACR;AACD;;ACnIA,SAAS,WAAW,OAAoC;CACvD,OAAQ,OAA6B;AACtC;AAEA,SAAS,OAAO,OAA0B;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,MAAM;CAClD,MAAM,QAAQ,WAAW,KAAK;CAC9B,OAAO,UAAU,KAAA,KAAa,OAAO,OAAO,OAAO,KAAK;AACzD;;AAGA,SAAgB,UAAU,OAA2B;CACpD,OAAO,OAAO,KAAK,UAAU,QAAQ;AACtC;AAEA,SAAgB,iBACf,QACA,YAAY,sBACoC;CAChD,MAAM,SAAU,CAAC,MAAM,CAAC,CAAe,KAAK,KAAQ;CACpD,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,OAAO,KAAK,OAAO,UAAU;EACnC,MAAM,MAAW,WAAW,KAAK,CAAC,GAAG;EACrC,IAAI,QAAQ,KAAA,GAAW,OAAO;GAAE;GAAO;GAAK,IAAI;EAAM;EACtD,MAAM,KAAK,cAAc,GAAG;EAC5B,IAAI,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,MAAM,SAAS;EAC3C,KAAK,IAAI,EAAE;EACX,OAAO;GAAE;GAAO;GAAK;EAAG;CACzB,CAAC;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as useLoadable } from "./src-
|
|
5
|
-
export { Fragment, hydrate, onCleanup, onMount, render, useDisposal, useGetter, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction };
|
|
1
|
+
import { C as useSetter, E as useTransaction, S as useRef, T as useTimeline, b as useGetter, d as onCommit, f as onMount, t as RootBoundary, u as onCleanup, w as useStore, x as useId, y as useDisposal } from "./core-DrUd8x25.js";
|
|
2
|
+
import { n as render, t as hydrate } from "./dom-CEVtlaav.js";
|
|
3
|
+
import { t as Fragment } from "./jsx-runtime-BGDPK50B.js";
|
|
4
|
+
import { t as useLoadable } from "./src-CB7ruwRs.js";
|
|
5
|
+
export { Fragment, RootBoundary as Root, hydrate, onCleanup, onCommit, onMount, render, useDisposal, useGetter, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/props.ts
|
|
2
|
+
function liveProps(values, fixedKey) {
|
|
3
|
+
const source = (name) => values().reverse().find((props) => Object.hasOwn(props, name));
|
|
4
|
+
const has = (_, name) => fixedKey && name === `key` ? fixedKey.present : source(name) !== void 0;
|
|
5
|
+
return new Proxy({}, {
|
|
6
|
+
has,
|
|
7
|
+
get(_, name) {
|
|
8
|
+
if (fixedKey && name === `key`) return fixedKey.value;
|
|
9
|
+
const props = source(name);
|
|
10
|
+
return props && Reflect.get(props, name);
|
|
11
|
+
},
|
|
12
|
+
ownKeys() {
|
|
13
|
+
const keys = new Set(values().flatMap(Object.keys));
|
|
14
|
+
if (fixedKey?.present) keys.add(`key`);
|
|
15
|
+
else if (fixedKey) keys.delete(`key`);
|
|
16
|
+
return [...keys];
|
|
17
|
+
},
|
|
18
|
+
getOwnPropertyDescriptor(_, name) {
|
|
19
|
+
if (has(_, name)) return {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Preserve lazy props and spread precedence, including keys added by later updates. */
|
|
27
|
+
function merge(...sources) {
|
|
28
|
+
return liveProps(() => sources.map((source) => (typeof source === `function` ? source() : source) ?? {}));
|
|
29
|
+
}
|
|
30
|
+
/** Expose the first key while leaving data props live, including through spreads. */
|
|
31
|
+
function instanceProps(read, key) {
|
|
32
|
+
return liveProps(() => [read()], {
|
|
33
|
+
value: key,
|
|
34
|
+
present: key !== void 0 || Object.hasOwn(read(), `key`)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// src/jsx-runtime.ts
|
|
38
|
+
const Fragment = (props) => props.children;
|
|
39
|
+
function jsx(type, props, key) {
|
|
40
|
+
return {
|
|
41
|
+
type,
|
|
42
|
+
props: key === void 0 ? props ?? {} : merge(props ?? {}, { key })
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const jsxs = jsx;
|
|
46
|
+
const jsxDEV = jsx;
|
|
47
|
+
export { instanceProps as a, jsxs as i, jsx as n, merge as o, jsxDEV as r, Fragment as t };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=jsx-runtime-BGDPK50B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime-BGDPK50B.js","names":[],"sources":["../../src/props.ts","../../src/jsx-runtime.ts"],"sourcesContent":["import type { Canonical } from \"atom.io/foundations/canonical\"\n\nimport type { SpaElement } from \"./core.ts\"\n\ntype Props = SpaElement[`props`]\ntype FixedKey = { value: Canonical | undefined; present: boolean }\n\nfunction liveProps(values: () => Props[], fixedKey?: FixedKey): Props {\n\tconst source = (name: PropertyKey) =>\n\t\tvalues()\n\t\t\t.reverse()\n\t\t\t.find((props) => Object.hasOwn(props, name))\n\tconst has = (_: Props, name: PropertyKey): boolean =>\n\t\tfixedKey && name === `key` ? fixedKey.present : source(name) !== undefined\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\thas,\n\t\t\tget(_, name) {\n\t\t\t\tif (fixedKey && name === `key`) return fixedKey.value\n\t\t\t\tconst props = source(name)\n\t\t\t\treturn props && Reflect.get(props, name)\n\t\t\t},\n\t\t\townKeys() {\n\t\t\t\tconst keys = new Set(values().flatMap(Object.keys))\n\t\t\t\tif (fixedKey?.present) keys.add(`key`)\n\t\t\t\telse if (fixedKey) keys.delete(`key`)\n\t\t\t\treturn [...keys]\n\t\t\t},\n\t\t\tgetOwnPropertyDescriptor(_, name) {\n\t\t\t\tif (has(_, name)) return { enumerable: true, configurable: true }\n\t\t\t},\n\t\t},\n\t)\n}\n\n/** Preserve lazy props and spread precedence, including keys added by later updates. */\nexport function merge(...sources: (Props | (() => Props))[]): Props {\n\treturn liveProps(() =>\n\t\tsources.map(\n\t\t\t(source) => (typeof source === `function` ? source() : source) ?? {},\n\t\t),\n\t)\n}\n\n/** Expose the first key while leaving data props live, including through spreads. */\nexport function instanceProps(\n\tread: () => Props,\n\tkey: Canonical | undefined,\n): Props {\n\treturn liveProps(() => [read()], {\n\t\tvalue: key,\n\t\tpresent: key !== undefined || Object.hasOwn(read(), `key`),\n\t})\n}\n","import type { Canonical } from \"atom.io/foundations/canonical\"\n\nimport type { Children, Component, SpaElement } from \"./core.ts\"\nimport type { HTMLAttributes, NativeElements } from \"./jsx-types.d.ts\"\nimport { merge } from \"./props.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\"\nexport { merge } from \"./props.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?: Canonical,\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\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?: Canonical | undefined\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":";AAOA,SAAS,UAAU,QAAuB,UAA4B;CACrE,MAAM,UAAU,SACf,OAAO,CAAC,CACN,QAAQ,CAAC,CACT,MAAM,UAAU,OAAO,OAAO,OAAO,IAAI,CAAC;CAC7C,MAAM,OAAO,GAAU,SACtB,YAAY,SAAS,QAAQ,SAAS,UAAU,OAAO,IAAI,MAAM,KAAA;CAClE,OAAO,IAAI,MACV,CAAC,GACD;EACC;EACA,IAAI,GAAG,MAAM;GACZ,IAAI,YAAY,SAAS,OAAO,OAAO,SAAS;GAChD,MAAM,QAAQ,OAAO,IAAI;GACzB,OAAO,SAAS,QAAQ,IAAI,OAAO,IAAI;EACxC;EACA,UAAU;GACT,MAAM,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,IAAI,CAAC;GAClD,IAAI,UAAU,SAAS,KAAK,IAAI,KAAK;QAChC,IAAI,UAAU,KAAK,OAAO,KAAK;GACpC,OAAO,CAAC,GAAG,IAAI;EAChB;EACA,yBAAyB,GAAG,MAAM;GACjC,IAAI,IAAI,GAAG,IAAI,GAAG,OAAO;IAAE,YAAY;IAAM,cAAc;GAAK;EACjE;CACD,CACD;AACD;;AAGA,SAAgB,MAAM,GAAG,SAA2C;CACnE,OAAO,gBACN,QAAQ,KACN,YAAY,OAAO,WAAW,aAAa,OAAO,IAAI,WAAW,CAAC,CACpE,CACD;AACD;;AAGA,SAAgB,cACf,MACA,KACQ;CACR,OAAO,gBAAgB,CAAC,KAAK,CAAC,GAAG;EAChC,OAAO;EACP,SAAS,QAAQ,KAAA,KAAa,OAAO,OAAO,KAAK,GAAG,KAAK;CAC1D,CAAC;AACF;;AChCA,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"}
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const Fragment = (props) => props.children;
|
|
3
|
-
function jsx(type, props, key) {
|
|
4
|
-
return {
|
|
5
|
-
type,
|
|
6
|
-
props: key === void 0 ? props ?? {} : merge(props ?? {}, { key })
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
const jsxs = jsx;
|
|
10
|
-
const jsxDEV = jsx;
|
|
11
|
-
/** Preserve lazy props and spread precedence, including keys added by later updates. */
|
|
12
|
-
function merge(...sources) {
|
|
13
|
-
const values = () => sources.map((source) => (typeof source === `function` ? source() : source) ?? {});
|
|
14
|
-
return new Proxy({}, {
|
|
15
|
-
get: (_, key) => values().reverse().find((source) => Object.hasOwn(source, key))?.[key],
|
|
16
|
-
ownKeys: () => [...new Set(values().flatMap(Object.keys))],
|
|
17
|
-
getOwnPropertyDescriptor: (_, key) => values().some((source) => Object.hasOwn(source, key)) ? {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true
|
|
20
|
-
} : void 0
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export { Fragment, jsx, jsxDEV, jsxs, merge };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=jsx-runtime.js.map
|
|
1
|
+
export { t as Fragment, n as jsx, r as jsxDEV, i as jsxs, o as merge } from "./jsx-runtime-BGDPK50B.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsx } from "./jsx-runtime.js";
|
|
1
|
+
import { i as capabilityProps } from "./identity-B8wTFkyW.js";
|
|
2
|
+
import { f as onMount, p as owner, u as onCleanup } from "./core-DrUd8x25.js";
|
|
3
|
+
import { n as jsx } from "./jsx-runtime-BGDPK50B.js";
|
|
4
4
|
import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.js";
|
|
5
5
|
import Konva from "konva";
|
|
6
6
|
// src/konva.ts
|
|
@@ -66,11 +66,18 @@ const renderer = createSceneRenderer({
|
|
|
66
66
|
children(parent, children) {
|
|
67
67
|
if (children.length && !(parent instanceof Konva.Container)) throw new Error(`spa/konva: shapes cannot contain children`);
|
|
68
68
|
if (parent instanceof Konva.Container) {
|
|
69
|
-
|
|
69
|
+
const current = parent.getChildren();
|
|
70
|
+
if (current.length === children.length && children.every((child, index) => child === current[index])) return;
|
|
71
|
+
const wanted = new Set(children);
|
|
72
|
+
for (const child of [...current]) if (!wanted.has(child)) child.remove();
|
|
70
73
|
children.forEach((child, index) => {
|
|
71
74
|
if (child.getParent() !== parent) parent.add(child);
|
|
72
|
-
child.zIndex(index);
|
|
75
|
+
if (parent instanceof Konva.Stage && child.zIndex() !== index) child.zIndex(index);
|
|
73
76
|
});
|
|
77
|
+
if (!(parent instanceof Konva.Stage)) {
|
|
78
|
+
parent.children = [...children];
|
|
79
|
+
parent._setChildrenIndices();
|
|
80
|
+
}
|
|
74
81
|
}
|
|
75
82
|
},
|
|
76
83
|
destroy(node) {
|
|
@@ -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 { 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\t)\nexport { renderer as konvaRenderer }\n"],"mappings":";;;;;;AAmBA,MAAM,eAAe;CACpB,OAAO,MAAM;CACb,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,QAAQ,MAAM;CACd,SAAS,M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AAQ;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
|
+
{"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 InteractionEvent = MouseEvent | TouchEvent | PointerEvent\ninterface Events {\n\tonClick: MouseEvent\n\tonDblClick: MouseEvent\n\tonMouseDown: MouseEvent\n\tonMouseUp: MouseEvent\n\tonMouseMove: MouseEvent\n\tonMouseEnter: MouseEvent\n\tonMouseLeave: MouseEvent\n\tonMouseOver: MouseEvent\n\tonMouseOut: MouseEvent\n\tonContextMenu: PointerEvent\n\tonWheel: WheelEvent\n\tonPointerDown: PointerEvent\n\tonPointerUp: PointerEvent\n\tonPointerMove: PointerEvent\n\tonPointerEnter: PointerEvent\n\tonPointerLeave: PointerEvent\n\tonPointerOver: PointerEvent\n\tonPointerOut: PointerEvent\n\tonPointerCancel: PointerEvent\n\tonPointerClick: PointerEvent\n\tonPointerDblClick: PointerEvent\n\tonGotPointerCapture: PointerEvent\n\tonLostPointerCapture: PointerEvent\n\tonTouchStart: TouchEvent\n\tonTouchMove: TouchEvent\n\tonTouchEnd: TouchEvent\n\tonTouchCancel: TouchEvent\n\tonTap: TouchEvent\n\tonDblTap: TouchEvent\n\tonDragStart: InteractionEvent\n\tonDragMove: InteractionEvent\n\tonDragEnd: InteractionEvent\n\tonTransformStart: InteractionEvent\n\tonTransform: InteractionEvent\n\tonTransformEnd: InteractionEvent | undefined\n}\ntype Config<C> = {\n\t[K in keyof C as string extends K ? never : number extends K ? never : K]: C[K]\n}\ntype Props<C, N extends Konva.Node> = Config<C> & {\n\t[K in keyof Events]?:\n\t\t| ((\n\t\t\t\tevent: Omit<Konva.KonvaEventObject<Events[K]>, `currentTarget`> & {\n\t\t\t\t\treadonly currentTarget: N\n\t\t\t\t},\n\t\t ) => void)\n\t\t| undefined\n} & CapabilityAttributes<`konva`> & {\n\t\tchildren?: Children\n\t\tref?: (node: N | null) => 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\tconst current = parent.getChildren()\n\t\t\tif (\n\t\t\t\tcurrent.length === children.length &&\n\t\t\t\tchildren.every((child, index) => child === current[index])\n\t\t\t)\n\t\t\t\treturn\n\t\t\tconst wanted = new Set(children)\n\t\t\tfor (const child of [...current]) if (!wanted.has(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\t// Layer zIndex also updates the Stage's canvas order.\n\t\t\t\tif (parent instanceof Konva.Stage && child.zIndex() !== index)\n\t\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t\tif (!(parent instanceof Konva.Stage)) {\n\t\t\t\tparent.children = [...children]\n\t\t\t\tparent._setChildrenIndices()\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<Config<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\t)\nexport { renderer as konvaRenderer }\n"],"mappings":";;;;;;AA+DA,MAAM,eAAe;CACpB,OAAO,MAAM;CACb,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,QAAQ,MAAM;CACd,SAAS,MAAM;CACf,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,aAAa,MAAM;AACpB;AACA,SAAS,YAAY,MAA8B;CAClD,MAAM,YAAY,KAAK,UAAU;CACjC,MAAM,YAAY,KAAK,UAAU;CACjC,KAAK,UAAU,KAAK;CAEpB,KAAK,UAAU,KAAK;CACpB,aAAa;E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,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 {
|
|
1
|
+
import { D as within, c as isPresent, f as onMount, h as reportScopeError, i as dispose, o as fail, s as invalidate, v as untrack } from "./core-DrUd8x25.js";
|
|
2
2
|
import { acquireProjectionNode, animate, cancelFrame, frame, handOffElementState, hover, keyframes, motionValue, press, readStyleValue, styleEffect, visualElementStore } from "motion";
|
|
3
3
|
// src/motion-layout.ts
|
|
4
4
|
let serial = 0;
|
|
@@ -21,7 +21,7 @@ function createLayoutController(root, options) {
|
|
|
21
21
|
const detach = entry.release;
|
|
22
22
|
entry.release = void 0;
|
|
23
23
|
entry.node = void 0;
|
|
24
|
-
entry.
|
|
24
|
+
entry.beginStyles = entry.measureStyles = entry.endStyles = entry.captureStyles = void 0;
|
|
25
25
|
detach?.();
|
|
26
26
|
};
|
|
27
27
|
const configure = (entry) => {
|
|
@@ -42,6 +42,7 @@ function createLayoutController(root, options) {
|
|
|
42
42
|
}
|
|
43
43
|
entry.node.setOptions({
|
|
44
44
|
layoutScroll: entry.props.scroll ?? false,
|
|
45
|
+
layoutRoot: entry.props.root ?? false,
|
|
45
46
|
animationType: typeof entry.props.animate === `string` ? entry.props.animate : `both`,
|
|
46
47
|
animate: entry.props.animate !== false && !reduced(),
|
|
47
48
|
transition: reduced() ? { duration: 0 } : transition
|
|
@@ -91,25 +92,26 @@ function createLayoutController(root, options) {
|
|
|
91
92
|
let visibility = ``;
|
|
92
93
|
let pointerEvents = ``;
|
|
93
94
|
let transform = ``;
|
|
95
|
+
let rendered = ``;
|
|
94
96
|
const transformTemplate = (_, projected) => `${projected === `none` ? `` : projected} ${transform}`.trim();
|
|
95
97
|
entry.captureStyles = () => {
|
|
96
98
|
style.cssText = element.style.cssText;
|
|
97
99
|
};
|
|
98
|
-
entry.
|
|
99
|
-
|
|
100
|
+
entry.beginStyles = () => {
|
|
101
|
+
rendered = element.style.cssText;
|
|
100
102
|
for (const name of styleNames) restore(name);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
};
|
|
104
|
+
entry.measureStyles = () => {
|
|
105
|
+
const authored = getComputedStyle(element);
|
|
106
|
+
opacity = authored.opacity || `1`;
|
|
107
|
+
visibility = authored.visibility;
|
|
108
|
+
pointerEvents = authored.pointerEvents;
|
|
109
|
+
transform = authored.transform;
|
|
110
|
+
if (!visual.values.has(`opacity`)) node.latestValues[`opacity`] = Number(opacity);
|
|
111
|
+
const origin = authored.transformOrigin.split(` `);
|
|
112
|
+
const width = element.offsetWidth, height = element.offsetHeight;
|
|
113
|
+
entry.size = `${width}:${height}`;
|
|
114
|
+
for (const [key, value] of [[`originX`, parseFloat(origin[0]) / (width || 1)], [`originY`, parseFloat(origin[1]) / (height || 1)]]) if (!visual.values.has(key) && Number.isFinite(value)) node.latestValues[key] = value;
|
|
113
115
|
const template = transform && transform !== `none` && !Object.keys(visual.latestValues).some((key) => /^(x|y|scale|rotate|skew)/.test(key)) ? transformTemplate : originalProps.transformTemplate;
|
|
114
116
|
if (visual.getProps().transformTemplate !== template) {
|
|
115
117
|
const next = { ...visual.getProps() };
|
|
@@ -118,6 +120,9 @@ function createLayoutController(root, options) {
|
|
|
118
120
|
visual.update(next, null);
|
|
119
121
|
}
|
|
120
122
|
};
|
|
123
|
+
entry.endStyles = () => {
|
|
124
|
+
element.style.cssText = rendered;
|
|
125
|
+
};
|
|
121
126
|
const applyProjectionStyles = node.applyProjectionStyles;
|
|
122
127
|
node.applyProjectionStyles = (targetStyle, styleProp) => {
|
|
123
128
|
applyProjectionStyles.call(node, targetStyle, {
|
|
@@ -155,14 +160,27 @@ function createLayoutController(root, options) {
|
|
|
155
160
|
};
|
|
156
161
|
observer?.observe(element);
|
|
157
162
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
};
|
|
164
|
+
const prepareAll = () => {
|
|
165
|
+
const active = ordered();
|
|
166
|
+
for (const entry of active) prepare(entry);
|
|
167
|
+
const begun = [];
|
|
168
|
+
try {
|
|
169
|
+
for (const entry of active) {
|
|
170
|
+
begun.push(entry);
|
|
171
|
+
entry.beginStyles();
|
|
172
|
+
}
|
|
173
|
+
for (const entry of active) entry.measureStyles();
|
|
174
|
+
} finally {
|
|
175
|
+
for (const entry of begun) entry.endStyles();
|
|
176
|
+
}
|
|
177
|
+
for (const entry of active) configure(entry);
|
|
178
|
+
return active;
|
|
161
179
|
};
|
|
162
180
|
const commit = () => {
|
|
163
181
|
try {
|
|
164
182
|
if (dead) return;
|
|
165
|
-
|
|
183
|
+
prepareAll();
|
|
166
184
|
const roots = new Set([...entries].flatMap((entry) => entry.node ? [entry.node.root ?? entry.node] : []));
|
|
167
185
|
for (const projection of roots) projection.didUpdate();
|
|
168
186
|
for (const entry of entries) if (entry.dead) {
|
|
@@ -397,7 +415,6 @@ function animateTween(value, goal, transition, interrupted) {
|
|
|
397
415
|
/** Optional coordinator: only imported by integrations that support retention. */
|
|
398
416
|
function createPresence(root) {
|
|
399
417
|
const releases = /* @__PURE__ */ new Map();
|
|
400
|
-
const handlers = /* @__PURE__ */ new WeakMap();
|
|
401
418
|
const groups = /* @__PURE__ */ new Map();
|
|
402
419
|
const sessions = /* @__PURE__ */ new Set();
|
|
403
420
|
const active = /* @__PURE__ */ new Map();
|
|
@@ -430,14 +447,6 @@ function createPresence(root) {
|
|
|
430
447
|
for (let at = scope; at; at = at._parent) if (at === parent) return true;
|
|
431
448
|
return false;
|
|
432
449
|
};
|
|
433
|
-
const report = (error) => {
|
|
434
|
-
if (root._dead) return;
|
|
435
|
-
try {
|
|
436
|
-
fail(root, error);
|
|
437
|
-
} catch (failure) {
|
|
438
|
-
root.error(failure);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
450
|
const finish = () => {
|
|
442
451
|
for (const group of [...groups.values()]) {
|
|
443
452
|
if (group.scope._dead || group.sessions.some((session) => !session.done)) continue;
|
|
@@ -446,7 +455,7 @@ function createPresence(root) {
|
|
|
446
455
|
try {
|
|
447
456
|
group.done();
|
|
448
457
|
} catch (error) {
|
|
449
|
-
|
|
458
|
+
if (!root._dead) reportScopeError(group.scope, error);
|
|
450
459
|
}
|
|
451
460
|
}
|
|
452
461
|
};
|
|
@@ -485,14 +494,6 @@ function createPresence(root) {
|
|
|
485
494
|
unbind(binding) {
|
|
486
495
|
releases.get(binding)?.();
|
|
487
496
|
},
|
|
488
|
-
event(scope, handler) {
|
|
489
|
-
const cached = handlers.get(scope) ?? /* @__PURE__ */ new WeakMap();
|
|
490
|
-
handlers.set(scope, cached);
|
|
491
|
-
if (!cached.has(handler)) cached.set(handler, function(...args) {
|
|
492
|
-
if (isPresent(scope)) return handler.apply(this, args);
|
|
493
|
-
});
|
|
494
|
-
return cached.get(handler);
|
|
495
|
-
},
|
|
496
497
|
collection(scopeOf, compatible) {
|
|
497
498
|
let order = [];
|
|
498
499
|
const exiting = /* @__PURE__ */ new Map();
|
|
@@ -561,7 +562,7 @@ function createPresence(root) {
|
|
|
561
562
|
held.done = true;
|
|
562
563
|
finish();
|
|
563
564
|
}, (error) => {
|
|
564
|
-
if (!held.cancelled)
|
|
565
|
+
if (!held.cancelled && !root._dead) reportScopeError(held.scope, error);
|
|
565
566
|
});
|
|
566
567
|
}
|
|
567
568
|
collected.push(session);
|
|
@@ -632,6 +633,7 @@ const layoutKeys = {
|
|
|
632
633
|
layoutId: `id`,
|
|
633
634
|
layoutGroup: `group`,
|
|
634
635
|
layoutScroll: `scroll`,
|
|
636
|
+
layoutRoot: `root`,
|
|
635
637
|
layoutTransition: `transition`
|
|
636
638
|
};
|
|
637
639
|
function equal(a, b) {
|