@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.6

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.
Files changed (251) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/browser/chunks/chunk-2RIYH36X.js +3 -0
  3. package/dist/browser/chunks/{chunk-QG6C23IJ.js.map → chunk-2RIYH36X.js.map} +4 -4
  4. package/dist/browser/chunks/chunk-DDJN3QII.js +15 -0
  5. package/dist/browser/chunks/chunk-DDJN3QII.js.map +7 -0
  6. package/dist/browser/chunks/chunk-DHB4COFY.js +2 -0
  7. package/dist/browser/chunks/chunk-DHB4COFY.js.map +7 -0
  8. package/dist/browser/chunks/chunk-EJDPYDQI.js +5 -0
  9. package/dist/browser/chunks/chunk-EJDPYDQI.js.map +7 -0
  10. package/dist/browser/chunks/chunk-XAWE4EAK.js +2 -0
  11. package/dist/browser/chunks/chunk-XAWE4EAK.js.map +7 -0
  12. package/dist/browser/component.js +1 -1
  13. package/dist/browser/component.js.map +4 -4
  14. package/dist/browser/experimental.js +2 -0
  15. package/dist/browser/experimental.js.map +7 -0
  16. package/dist/browser/index.js +1 -1
  17. package/dist/browser/index.js.map +4 -4
  18. package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
  19. package/dist/browser/jsx-jsx-runtime.js +1 -1
  20. package/dist/browser/manifest.json +2 -1
  21. package/dist/browser/sdk.js +1 -1
  22. package/dist/component/api.d.ts +508 -0
  23. package/dist/component/api.d.ts.map +1 -0
  24. package/dist/component/api.js +4 -0
  25. package/dist/component/api.js.map +1 -0
  26. package/dist/component/builtins/audio.d.ts +26 -0
  27. package/dist/component/builtins/audio.d.ts.map +1 -0
  28. package/dist/component/builtins/audio.js +41 -0
  29. package/dist/component/builtins/audio.js.map +1 -0
  30. package/dist/component/builtins/canvas3d.d.ts +98 -0
  31. package/dist/component/builtins/canvas3d.d.ts.map +1 -0
  32. package/dist/component/builtins/canvas3d.js +21 -0
  33. package/dist/component/builtins/canvas3d.js.map +1 -0
  34. package/dist/component/builtins/composite.d.ts +56 -0
  35. package/dist/component/builtins/composite.d.ts.map +1 -0
  36. package/dist/component/builtins/composite.js +25 -0
  37. package/dist/component/builtins/composite.js.map +1 -0
  38. package/dist/component/builtins/geometry.d.ts +505 -0
  39. package/dist/component/builtins/geometry.d.ts.map +1 -0
  40. package/dist/component/builtins/geometry.js +107 -0
  41. package/dist/component/builtins/geometry.js.map +1 -0
  42. package/dist/component/builtins/layout.d.ts +88 -0
  43. package/dist/component/builtins/layout.d.ts.map +1 -0
  44. package/dist/component/builtins/layout.js +84 -0
  45. package/dist/component/builtins/layout.js.map +1 -0
  46. package/dist/component/builtins/media.d.ts +95 -0
  47. package/dist/component/builtins/media.d.ts.map +1 -0
  48. package/dist/component/builtins/media.js +149 -0
  49. package/dist/component/builtins/media.js.map +1 -0
  50. package/dist/component/builtins/providers.d.ts +23 -0
  51. package/dist/component/builtins/providers.d.ts.map +1 -0
  52. package/dist/component/builtins/providers.js +30 -0
  53. package/dist/component/builtins/providers.js.map +1 -0
  54. package/dist/component/builtins/text.d.ts +193 -0
  55. package/dist/component/builtins/text.d.ts.map +1 -0
  56. package/dist/component/builtins/text.js +113 -0
  57. package/dist/component/builtins/text.js.map +1 -0
  58. package/dist/component/builtins/three.d.ts +1085 -0
  59. package/dist/component/builtins/three.d.ts.map +1 -0
  60. package/dist/component/builtins/three.js +265 -0
  61. package/dist/component/builtins/three.js.map +1 -0
  62. package/dist/component/clip-of.d.ts +5 -0
  63. package/dist/component/clip-of.d.ts.map +1 -0
  64. package/dist/component/clip-of.js +33 -0
  65. package/dist/component/clip-of.js.map +1 -0
  66. package/dist/component/commands-for.d.ts +19 -0
  67. package/dist/component/commands-for.d.ts.map +1 -0
  68. package/dist/component/commands-for.js +5 -0
  69. package/dist/component/commands-for.js.map +1 -0
  70. package/dist/component/component-audio.d.ts +9 -0
  71. package/dist/component/component-audio.d.ts.map +1 -0
  72. package/dist/component/component-audio.js +18 -0
  73. package/dist/component/component-audio.js.map +1 -0
  74. package/dist/component/component2d.d.ts +9 -0
  75. package/dist/component/component2d.d.ts.map +1 -0
  76. package/dist/component/component2d.js +239 -0
  77. package/dist/component/component2d.js.map +1 -0
  78. package/dist/component/component3d.d.ts +9 -0
  79. package/dist/component/component3d.d.ts.map +1 -0
  80. package/dist/component/component3d.js +99 -0
  81. package/dist/component/component3d.js.map +1 -0
  82. package/dist/component/factory.d.ts +63 -0
  83. package/dist/component/factory.d.ts.map +1 -0
  84. package/dist/component/factory.js +313 -0
  85. package/dist/component/factory.js.map +1 -0
  86. package/dist/component/modules/aim.d.ts +30 -0
  87. package/dist/component/modules/aim.d.ts.map +1 -0
  88. package/dist/component/modules/aim.js +39 -0
  89. package/dist/component/modules/aim.js.map +1 -0
  90. package/dist/component/modules/corners.d.ts +13 -0
  91. package/dist/component/modules/corners.d.ts.map +1 -0
  92. package/dist/component/modules/corners.js +12 -0
  93. package/dist/component/modules/corners.js.map +1 -0
  94. package/dist/component/modules/flow.d.ts +26 -0
  95. package/dist/component/modules/flow.d.ts.map +1 -0
  96. package/dist/component/modules/flow.js +55 -0
  97. package/dist/component/modules/flow.js.map +1 -0
  98. package/dist/component/modules/material.d.ts +40 -0
  99. package/dist/component/modules/material.d.ts.map +1 -0
  100. package/dist/component/modules/material.js +75 -0
  101. package/dist/component/modules/material.js.map +1 -0
  102. package/dist/component/modules/paint.d.ts +71 -0
  103. package/dist/component/modules/paint.d.ts.map +1 -0
  104. package/dist/component/modules/paint.js +106 -0
  105. package/dist/component/modules/paint.js.map +1 -0
  106. package/dist/component/modules/shapes.d.ts +31 -0
  107. package/dist/component/modules/shapes.d.ts.map +1 -0
  108. package/dist/component/modules/shapes.js +43 -0
  109. package/dist/component/modules/shapes.js.map +1 -0
  110. package/dist/component/modules/text-layout.d.ts +26 -0
  111. package/dist/component/modules/text-layout.d.ts.map +1 -0
  112. package/dist/component/modules/text-layout.js +57 -0
  113. package/dist/component/modules/text-layout.js.map +1 -0
  114. package/dist/component/modules/text-style.d.ts +48 -0
  115. package/dist/component/modules/text-style.d.ts.map +1 -0
  116. package/dist/component/modules/text-style.js +63 -0
  117. package/dist/component/modules/text-style.js.map +1 -0
  118. package/dist/component/modules/three-entries.d.ts +23 -0
  119. package/dist/component/modules/three-entries.d.ts.map +1 -0
  120. package/dist/component/modules/three-entries.js +41 -0
  121. package/dist/component/modules/three-entries.js.map +1 -0
  122. package/dist/component/modules/view3d.d.ts +55 -0
  123. package/dist/component/modules/view3d.d.ts.map +1 -0
  124. package/dist/component/modules/view3d.js +160 -0
  125. package/dist/component/modules/view3d.js.map +1 -0
  126. package/dist/component/timeline.d.ts +22 -0
  127. package/dist/component/timeline.d.ts.map +1 -0
  128. package/dist/component/timeline.js +128 -0
  129. package/dist/component/timeline.js.map +1 -0
  130. package/dist/component/type-def.d.ts +26 -0
  131. package/dist/component/type-def.d.ts.map +1 -0
  132. package/dist/component/type-def.js +16 -0
  133. package/dist/component/type-def.js.map +1 -0
  134. package/dist/component/types.d.ts +91 -0
  135. package/dist/component/types.d.ts.map +1 -0
  136. package/dist/component/types.js +88 -0
  137. package/dist/component/types.js.map +1 -0
  138. package/dist/component/views.d.ts +121 -0
  139. package/dist/component/views.d.ts.map +1 -0
  140. package/dist/component/views.js +413 -0
  141. package/dist/component/views.js.map +1 -0
  142. package/dist/component.d.ts +4 -5
  143. package/dist/component.d.ts.map +1 -1
  144. package/dist/component.js +3 -5
  145. package/dist/component.js.map +1 -1
  146. package/dist/document/audio.d.ts +9 -1
  147. package/dist/document/audio.d.ts.map +1 -1
  148. package/dist/document/audio.js +41 -0
  149. package/dist/document/audio.js.map +1 -1
  150. package/dist/document/builtins.d.ts.map +1 -1
  151. package/dist/document/builtins.js +9 -27
  152. package/dist/document/builtins.js.map +1 -1
  153. package/dist/document/command-traits.js +3 -0
  154. package/dist/document/command-traits.js.map +1 -1
  155. package/dist/document/diff.d.ts.map +1 -1
  156. package/dist/document/diff.js +3 -3
  157. package/dist/document/diff.js.map +1 -1
  158. package/dist/document/doc-index.d.ts.map +1 -1
  159. package/dist/document/doc-index.js +3 -3
  160. package/dist/document/doc-index.js.map +1 -1
  161. package/dist/document/node-descriptor.d.ts +6 -0
  162. package/dist/document/node-descriptor.d.ts.map +1 -1
  163. package/dist/document/node-descriptor.js.map +1 -1
  164. package/dist/document/placement.js +2 -2
  165. package/dist/document/placement.js.map +1 -1
  166. package/dist/document/registry.d.ts +6 -11
  167. package/dist/document/registry.d.ts.map +1 -1
  168. package/dist/document/registry.js +17 -17
  169. package/dist/document/registry.js.map +1 -1
  170. package/dist/document/settled-index.d.ts +49 -0
  171. package/dist/document/settled-index.d.ts.map +1 -0
  172. package/dist/document/settled-index.js +247 -0
  173. package/dist/document/settled-index.js.map +1 -0
  174. package/dist/document/timeline.d.ts +27 -1
  175. package/dist/document/timeline.d.ts.map +1 -1
  176. package/dist/document/timeline.js +98 -2
  177. package/dist/document/timeline.js.map +1 -1
  178. package/dist/experimental.d.ts +22 -0
  179. package/dist/experimental.d.ts.map +1 -0
  180. package/dist/experimental.js +20 -0
  181. package/dist/experimental.js.map +1 -0
  182. package/dist/index.d.ts +9 -0
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +9 -0
  185. package/dist/index.js.map +1 -1
  186. package/dist/nodes/audio/index.d.ts +2 -2
  187. package/dist/nodes/audio/index.d.ts.map +1 -1
  188. package/dist/nodes/audio/index.js +0 -2
  189. package/dist/nodes/audio/index.js.map +1 -1
  190. package/dist/nodes/audio/sound-node.d.ts +2 -1
  191. package/dist/nodes/audio/sound-node.d.ts.map +1 -1
  192. package/dist/nodes/audio/sound-node.js +3 -0
  193. package/dist/nodes/audio/sound-node.js.map +1 -1
  194. package/dist/nodes/index.d.ts +39 -27
  195. package/dist/nodes/index.d.ts.map +1 -1
  196. package/dist/nodes/index.js +16 -30
  197. package/dist/nodes/index.js.map +1 -1
  198. package/dist/nodes/node/node.d.ts +7 -1
  199. package/dist/nodes/node/node.d.ts.map +1 -1
  200. package/dist/nodes/node/node.js +23 -8
  201. package/dist/nodes/node/node.js.map +1 -1
  202. package/dist/nodes/root/canvas2d-node.d.ts +2 -1
  203. package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
  204. package/dist/nodes/root/canvas2d-node.js +3 -0
  205. package/dist/nodes/root/canvas2d-node.js.map +1 -1
  206. package/dist/nodes/text/richtext-node.d.ts +0 -5
  207. package/dist/nodes/text/richtext-node.d.ts.map +1 -1
  208. package/dist/nodes/text/richtext-node.js +5 -71
  209. package/dist/nodes/text/richtext-node.js.map +1 -1
  210. package/dist/nodes/text/text-base.d.ts +5 -22
  211. package/dist/nodes/text/text-base.d.ts.map +1 -1
  212. package/dist/nodes/text/text-base.js +12 -363
  213. package/dist/nodes/text/text-base.js.map +1 -1
  214. package/dist/nodes/text/text-layout.d.ts +87 -0
  215. package/dist/nodes/text/text-layout.d.ts.map +1 -0
  216. package/dist/nodes/text/text-layout.js +368 -0
  217. package/dist/nodes/text/text-layout.js.map +1 -0
  218. package/dist/nodes/three/canvas3d-node.d.ts +3 -1
  219. package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
  220. package/dist/nodes/three/canvas3d-node.js +6 -0
  221. package/dist/nodes/three/canvas3d-node.js.map +1 -1
  222. package/dist/runtime/clip-instance.d.ts +4 -1
  223. package/dist/runtime/clip-instance.d.ts.map +1 -1
  224. package/dist/runtime/clip-instance.js +17 -3
  225. package/dist/runtime/clip-instance.js.map +1 -1
  226. package/dist/runtime/clip-store.d.ts +9 -0
  227. package/dist/runtime/clip-store.d.ts.map +1 -1
  228. package/dist/runtime/clip-store.js +78 -0
  229. package/dist/runtime/clip-store.js.map +1 -1
  230. package/dist/runtime/node-picking.d.ts.map +1 -1
  231. package/dist/runtime/node-picking.js +6 -7
  232. package/dist/runtime/node-picking.js.map +1 -1
  233. package/dist/runtime/node-picking3d.d.ts +11 -4
  234. package/dist/runtime/node-picking3d.d.ts.map +1 -1
  235. package/dist/runtime/node-picking3d.js +5 -0
  236. package/dist/runtime/node-picking3d.js.map +1 -1
  237. package/dist/runtime/text-geometry.d.ts.map +1 -1
  238. package/dist/runtime/text-geometry.js +7 -3
  239. package/dist/runtime/text-geometry.js.map +1 -1
  240. package/dist/sdk/index.d.ts +35 -14
  241. package/dist/sdk/index.d.ts.map +1 -1
  242. package/dist/sdk/index.js +47 -42
  243. package/dist/sdk/index.js.map +1 -1
  244. package/dist/tween/command.d.ts +12 -0
  245. package/dist/tween/command.d.ts.map +1 -1
  246. package/dist/tween/command.js +14 -0
  247. package/dist/tween/command.js.map +1 -1
  248. package/package.json +6 -1
  249. package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
  250. package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
  251. package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
@@ -0,0 +1,313 @@
1
+ import { getPropertyMeta, property } from "../attributes/properties/decorator.js";
2
+ import { node } from "../document/node-decorator.js";
3
+ import { settling } from "../tween/command.js";
4
+ import { command } from "../tween/command-decorator.js";
5
+ import { commandOf, makeTimeline } from "../component/timeline.js";
6
+ import { defOf, isTypeLike } from "../component/type-def.js";
7
+ import { nodeOfView, nodeView, snapshot, stateView, stateViewPrototype } from "../component/views.js";
8
+ export function lowering(spec, Base, ownsDefault = new Set()) {
9
+ const builtIn = new Map(getPropertyMeta(Object.create(Base.prototype)).map((m) => [m.key, m]));
10
+ const entries = new Map(Object.entries(spec.state ?? {}).map(([k, e]) => [k, defOf(e)]));
11
+ const defaults = (spec.defaults ?? {});
12
+ // A default for an own entry is that entry's default; for a built-in one, a redeclaration.
13
+ for (const [key, value] of Object.entries(defaults)) {
14
+ if (typeof value === "function")
15
+ continue;
16
+ const own = entries.get(key);
17
+ if (own)
18
+ entries.set(key, { ...own, default: value });
19
+ else if (!builtIn.has(key))
20
+ throw new TypeError(`${spec.key}: "defaults.${key}" names no entry.`);
21
+ }
22
+ // A reference entry holds an id; its fields read a view of the node it names.
23
+ const references = new Set([...entries].filter(([, def]) => def.editor.kind === "nodeRef").map(([key]) => key));
24
+ return { spec, entries, defaults, builtIn, view: stateViewPrototype([...builtIn.keys(), ...entries.keys()], references), ownsDefault };
25
+ }
26
+ export function factoryDefault(def) {
27
+ return typeof def.default === "function" ? def.default() : def.default;
28
+ }
29
+ /** The base every tree's generated class extends: `Base` with the spec's state, context, assets and children. */
30
+ export function componentBase(Base, l) {
31
+ const { spec: s, entries, defaults } = l;
32
+ class Componentized extends Base {
33
+ constructor(...args) {
34
+ const props = args[0];
35
+ const given = s.children ? props?.children : undefined;
36
+ super(s.children && props ? { ...props, children: undefined } : props);
37
+ this._view = stateView(l.view, this);
38
+ this._built = 0;
39
+ for (const [key, def] of entries) {
40
+ if (def.private)
41
+ this.applyProp(key, factoryDefault(def), { mapper: def.mapper, tween: def.tween });
42
+ else if (typeof def.default === "function" && props?.[key] === undefined)
43
+ this._writeProp(key, factoryDefault(def));
44
+ }
45
+ let built;
46
+ for (const [key, value] of Object.entries(defaults)) {
47
+ if (typeof value === "function" && props?.[key] === undefined) {
48
+ const asBuilt = (built ??= Object.freeze({ ...props }));
49
+ this._writeProp(key, () => value(this._view, asBuilt));
50
+ }
51
+ }
52
+ if (s.children) {
53
+ // Live, like the field state, so a binding the builder writes reads the node as it changes.
54
+ const builderState = stateView(l.view, this);
55
+ Object.defineProperty(builderState, "children", { value: [given ?? []].flat(Infinity).filter(Boolean) });
56
+ const built = [s.children(builderState)].flat(Infinity).filter(Boolean);
57
+ for (const part of built)
58
+ this.add(part);
59
+ this._built = built.length;
60
+ }
61
+ }
62
+ /** Each entry the author left unset that inherits takes what its ancestors provide, once, on first attach. */
63
+ resolveContext(ctx) {
64
+ super.resolveContext(ctx);
65
+ const given = (this._props ?? {});
66
+ const self = this;
67
+ for (const [key, def] of entries) {
68
+ if (!def.inherit || given[key] !== undefined)
69
+ continue;
70
+ const value = def.inherit((context) => ctx.get(context), given);
71
+ if (value !== undefined)
72
+ self[key] = value;
73
+ }
74
+ }
75
+ provideContext(parent) {
76
+ if (!s.provide)
77
+ return super.provideContext(parent);
78
+ const provided = s.provide(this._view, (context) => parent.get(context));
79
+ // The same map while nothing changed, so the subtree isn't re-bound every attach.
80
+ const memo = this._provided;
81
+ if (memo && memo.parent === parent && memo.values.length === provided.length
82
+ && memo.values.every((p, i) => p.context === provided[i].context && p.value === provided[i].value))
83
+ return memo.map;
84
+ let map = parent;
85
+ for (const { context, value } of provided)
86
+ if (map.get(context) !== value)
87
+ map = map.with(context, value);
88
+ this._provided = { parent, values: provided, map };
89
+ return map;
90
+ }
91
+ declareAssets(assets) {
92
+ super.declareAssets(assets);
93
+ const self = this;
94
+ for (const [key, def] of entries)
95
+ declareEntry(assets, def.editor.kind ?? "", self[key]);
96
+ if (s.load)
97
+ s.load(loaderOf(assets), this._view);
98
+ }
99
+ acceptsChild(child) {
100
+ const allowed = s.allowedChildren;
101
+ if (allowed === undefined || allowed === null)
102
+ return super.acceptsChild(child);
103
+ return allowed.some((rule) => matches(child, rule));
104
+ }
105
+ _childRule() {
106
+ const allowed = s.allowedChildren;
107
+ if (!allowed)
108
+ return super._childRule();
109
+ return allowed.length === 0 ? "It takes no children." : `It takes only ${namesOf(allowed)}.`;
110
+ }
111
+ _parentRefusal(parent) {
112
+ const allowed = s.allowedParents;
113
+ if (!allowed || allowed.some((rule) => matches(parent, rule)))
114
+ return null;
115
+ return `${this.className} goes only inside ${namesOf(allowed)}, not ${parent.className}.`;
116
+ }
117
+ /** The children a command's builders see: none, unless the tree says which. */
118
+ _commandChildren() {
119
+ return [];
120
+ }
121
+ _animate(frame, duration, easing) {
122
+ return this.command(frame, duration, easing);
123
+ }
124
+ }
125
+ return Componentized;
126
+ }
127
+ /**
128
+ * Declare the state and commands on the generated class, register its key, and
129
+ * hand back the component value.
130
+ */
131
+ export function finishComponent(Generated, l) {
132
+ const { spec: s, entries, defaults, builtIn } = l;
133
+ Object.defineProperty(Generated, "name", { value: pascal(s.key) });
134
+ const proto = Generated.prototype;
135
+ // A node is a context provider by overriding these: only one that provides, or inherits, keeps them.
136
+ if (!s.provide)
137
+ deleteUpTo(proto, "provideContext");
138
+ if (![...entries.values()].some((def) => def.inherit))
139
+ deleteUpTo(proto, "resolveContext");
140
+ if (s.allowedChildren === undefined || s.allowedChildren === null) {
141
+ deleteUpTo(proto, "acceptsChild");
142
+ deleteUpTo(proto, "_childRule");
143
+ }
144
+ if (!s.allowedParents)
145
+ deleteUpTo(proto, "_parentRefusal");
146
+ const allowed = s.allowedChildren;
147
+ if (allowed) {
148
+ const trees = [...new Set(allowed.map((rule) => (typeof rule === "string"
149
+ ? rule
150
+ : Object.create(rule.node.prototype).dimension)))];
151
+ Object.defineProperty(proto, "_childTrees", { get: () => trees, configurable: true });
152
+ }
153
+ for (const [key, def] of entries) {
154
+ if (def.private)
155
+ continue;
156
+ property({ default: typeof def.default === "function" ? undefined : def.default, mapper: def.mapper, tween: def.tween, ...def.editor })(proto, key);
157
+ }
158
+ for (const [key, value] of Object.entries(defaults)) {
159
+ if (entries.has(key) || l.ownsDefault.has(key) || typeof value === "function")
160
+ continue;
161
+ const inherited = builtIn.get(key);
162
+ property({ default: value, mapper: inherited.options?.mapper, tween: inherited.options?.tween, ...inherited.editor })(proto, key);
163
+ }
164
+ const base = Object.getPrototypeOf(Object.getPrototypeOf(proto));
165
+ for (const [key, entry] of Object.entries(s.commands ?? {})) {
166
+ // Commands have their own namespace: a key a node already uses (`remove`, `to`) publishes through another method name.
167
+ const method = key in base ? `_command_${key}` : key;
168
+ let args;
169
+ if (typeof entry === "function") {
170
+ proto[method] = function (cmd = {}) {
171
+ const duration = cmd.duration ?? 0;
172
+ const timeline = makeTimeline({}, duration, cmd.easing, nodeView(this, this));
173
+ const piece = entry(timeline, snapshot(this._view), this._commandChildren());
174
+ return commandOf(this, piece, duration, cmd.easing);
175
+ };
176
+ }
177
+ else {
178
+ const { args: declared, run, easing: ownEasing } = entry;
179
+ if (Array.isArray(declared)) {
180
+ const names = declared;
181
+ for (const name of names) {
182
+ if (!entries.has(name) && !builtIn.has(name))
183
+ throw new TypeError(`${s.key}.${key}: args names "${name}", which is no entry.`);
184
+ }
185
+ // Each arg is its entry: what a host shows for it is what the entry means.
186
+ args = names.map((name) => ({ key: name, ...(entries.get(name)?.editor ?? builtIn.get(name)?.editor ?? {}) }));
187
+ proto[method] = function (cmd = {}) {
188
+ const data = argsRecord(cmd.data, names);
189
+ const stated = {};
190
+ for (const name of names)
191
+ if (data[name] !== undefined)
192
+ stated[name] = data[name];
193
+ return settling(this.to({ data: stated, duration: cmd.duration ?? 0, easing: cmd.easing ?? ownEasing }));
194
+ };
195
+ }
196
+ else {
197
+ const own = declared;
198
+ args = Object.entries(own).map(([k, e]) => {
199
+ const def = defOf(e);
200
+ return { key: k, default: isTypeLike(e) ? factoryDefault(def) : e, ...def.editor };
201
+ });
202
+ proto[method] = function (cmd = {}) {
203
+ const duration = cmd.duration ?? 0;
204
+ const easing = cmd.easing ?? ownEasing;
205
+ const timeline = makeTimeline(resolveArgs(own, cmd.data), duration, easing, nodeView(this, this));
206
+ const piece = run(timeline, snapshot(this._view), this._commandChildren());
207
+ return commandOf(this, piece, duration, easing);
208
+ };
209
+ }
210
+ }
211
+ command({ key, ...(args ? { args } : {}) })(proto, method);
212
+ }
213
+ node({ key: s.key })(Generated);
214
+ return componentValue(s.key, Generated);
215
+ }
216
+ /** Remove the generated override of `name`, wherever between the class and its base it sits. */
217
+ function deleteUpTo(proto, name) {
218
+ for (let at = proto; at; at = Object.getPrototypeOf(at)) {
219
+ if (Object.prototype.hasOwnProperty.call(at, name)) {
220
+ delete at[name];
221
+ return;
222
+ }
223
+ }
224
+ }
225
+ /**
226
+ * What a factory hands back: call it (`Rect({...})`) or `new` it, either way a
227
+ * node of the generated class, which is also what `instanceof` tests.
228
+ */
229
+ export function componentValue(key, Generated) {
230
+ const make = function (props) {
231
+ return new Generated(props);
232
+ };
233
+ make.prototype = Generated.prototype;
234
+ Object.defineProperty(make, "name", { value: Generated.name });
235
+ return Object.assign(make, {
236
+ key,
237
+ node: Generated,
238
+ is: (child) => nodeOfView(child) instanceof Generated,
239
+ });
240
+ }
241
+ function pascal(key) {
242
+ return key.replace(/(^|[-_ ])(\w)/g, (_, _sep, c) => c.toUpperCase());
243
+ }
244
+ /** Whether `node` is of `rule`: a component, or a whole tree by name. */
245
+ function matches(node, rule) {
246
+ return typeof rule === "string"
247
+ ? node.dimension === rule
248
+ : node instanceof rule.node;
249
+ }
250
+ function namesOf(rules) {
251
+ const names = rules.map((rule) => (typeof rule === "string" ? `any ${rule.toUpperCase()} node` : rule.node.name));
252
+ return names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} or ${names.at(-1)}`;
253
+ }
254
+ /** One document arg: the bare value from a paint command, or the args record from the registry. */
255
+ function argsRecord(data, names) {
256
+ if (names.length === 1) {
257
+ const plain = typeof data === "object" && data !== null && !Array.isArray(data) && Object.getPrototypeOf(data) === Object.prototype;
258
+ if (!(plain && names[0] in data))
259
+ return { [names[0]]: data };
260
+ }
261
+ return (data ?? {});
262
+ }
263
+ function resolveArgs(spec, data) {
264
+ const given = (data ?? {});
265
+ const out = {};
266
+ for (const key in spec) {
267
+ const def = defOf(spec[key]);
268
+ const value = given[key] === undefined ? factoryDefault(def) : given[key];
269
+ out[key] = def.mapper ? def.mapper(value) : value;
270
+ }
271
+ return out;
272
+ }
273
+ function declareEntry(assets, kind, value) {
274
+ if (value === undefined || value === null || value === "")
275
+ return;
276
+ switch (kind) {
277
+ case "fills": return assets.fill(value);
278
+ case "strokes":
279
+ for (const stroke of value)
280
+ assets.fill(stroke.fill);
281
+ return;
282
+ case "shadows":
283
+ for (const shadow of value)
284
+ assets.fill(shadow.fill);
285
+ return;
286
+ case "image": return assets.image(value);
287
+ case "video": return assets.video(value);
288
+ case "font": return assets.font(value);
289
+ }
290
+ }
291
+ /** One wrapper per load function: the scope warns when a key's second declaration hands it a different one. */
292
+ const tasks = new WeakMap();
293
+ function taskOf(load) {
294
+ let task = tasks.get(load);
295
+ if (!task) {
296
+ task = async () => {
297
+ const loaded = await load();
298
+ return typeof loaded === "function" ? loaded : undefined;
299
+ };
300
+ tasks.set(load, task);
301
+ }
302
+ return task;
303
+ }
304
+ function loaderOf(assets) {
305
+ return {
306
+ font: (family, weight) => assets.font(family, weight),
307
+ image: (src) => assets.image(src),
308
+ video: (src, trim) => assets.video(src, trim),
309
+ task: (key, load, options) => assets.loader(key, taskOf(load), { gate: options?.before === "layout" ? "layout" : "render" }),
310
+ fill: (fills) => assets.fill(fills),
311
+ };
312
+ }
313
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/component/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAqB,MAAM,mCAAmC,CAAC;AAIjG,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAkC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAmB,MAAM,2BAA2B,CAAC;AAIrE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAgB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAkB,MAAM,mBAAmB,CAAC;AAqClH,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,IAAc,EAAE,cAAmC,IAAI,GAAG,EAAE;IACjG,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACzG,MAAM,OAAO,GAAG,IAAI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AQ,CAAC,MAAkB;IAChC,OAAO;QACH,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;QACrD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjC,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC;QAC7C,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC5H,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;KACtC,CAAC;AACN,CAAC","sourcesContent":["import type { Disposer } from \"@/assets/record\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\nimport { getPropertyMeta, property, type PropertyMeta } from \"@/attributes/properties/decorator\";\r\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\r\nimport type { ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\r\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\r\nimport { node } from \"@/document/node-decorator\";\r\nimport type { Node } from \"@/nodes/node/node\";\r\nimport { settling, type Command, type CommandArgs } from \"@/tween/command\";\r\nimport { command, type CommandArg } from \"@/tween/command-decorator\";\r\nimport type { EasingFunction } from \"@/tween/ease/type\";\r\nimport type { ContextMap } from \"@/util/context\";\r\nimport type { ChildView, Loader, Provided, StateSpec } from \"@/component/api\";\r\nimport { commandOf, makeTimeline } from \"@/component/timeline\";\r\nimport { defOf, isTypeLike, type TypeDef } from \"@/component/type-def\";\r\nimport { nodeOfView, nodeView, snapshot, stateView, stateViewPrototype, type ViewShape } from \"@/component/views\";\r\n\r\n/**\r\n * What every factory does, whatever tree it builds for: declare the state on a\r\n * generated subclass of the tree's base, publish the commands, run the\r\n * `children` builder, provide and inherit context, and declare assets. Each\r\n * factory adds only its own tree's hooks on top.\r\n */\r\n\r\n/** The fields every factory takes. */\r\nexport interface CoreSpec {\r\n readonly key: string;\r\n readonly state?: StateSpec;\r\n readonly defaults?: Record<string, unknown>;\r\n readonly commands?: Record<string, unknown>;\r\n readonly children?: (state: never) => unknown;\r\n readonly provide?: (state: never, inherited: <T>(context: { readonly id: symbol; readonly defaultValue: T }) => T) => readonly Provided[];\r\n readonly load?: (loader: Loader, state: never) => void;\r\n /** `[]` takes none; `null` (the default) anything of its tree; components, or `\"2d\"`/`\"3d\"`/`\"audio\"`, only those. */\r\n readonly allowedChildren?: readonly unknown[] | null;\r\n /** The components it goes only inside; unsaid, wherever its tree allows. */\r\n readonly allowedParents?: readonly unknown[];\r\n}\r\n\r\n/** A spec, resolved against the base it lowers onto. */\r\nexport interface Lowering {\r\n readonly spec: CoreSpec;\r\n readonly entries: Map<string, TypeDef>;\r\n readonly defaults: Record<string, unknown>;\r\n readonly builtIn: ReadonlyMap<string, PropertyMeta>;\r\n readonly view: ViewShape;\r\n /** Built-in entries whose default a factory applies itself (a 2D size), not by redeclaring the property. */\r\n readonly ownsDefault: ReadonlySet<string>;\r\n}\r\n\r\ntype NodeBase = abstract new (...args: any[]) => Node;\r\n\r\nexport function lowering(spec: CoreSpec, Base: NodeBase, ownsDefault: ReadonlySet<string> = new Set()): Lowering {\r\n const builtIn = new Map(getPropertyMeta(Object.create(Base.prototype as object)).map((m) => [m.key, m]));\r\n const entries = new Map<string, TypeDef>(Object.entries(spec.state ?? {}).map(([k, e]) => [k, defOf(e)]));\r\n const defaults = (spec.defaults ?? {}) as Record<string, unknown>;\r\n // A default for an own entry is that entry's default; for a built-in one, a redeclaration.\r\n for (const [key, value] of Object.entries(defaults)) {\r\n if (typeof value === \"function\") continue;\r\n const own = entries.get(key);\r\n if (own) entries.set(key, { ...own, default: value });\r\n else if (!builtIn.has(key)) throw new TypeError(`${spec.key}: \"defaults.${key}\" names no entry.`);\r\n }\r\n // A reference entry holds an id; its fields read a view of the node it names.\r\n const references = new Set([...entries].filter(([, def]) => def.editor.kind === \"nodeRef\").map(([key]) => key));\r\n return { spec, entries, defaults, builtIn, view: stateViewPrototype([...builtIn.keys(), ...entries.keys()], references), ownsDefault };\r\n}\r\n\r\nexport function factoryDefault(def: TypeDef): unknown {\r\n return typeof def.default === \"function\" ? (def.default as () => unknown)() : def.default;\r\n}\r\n\r\n/** The members every generated node has, whatever its tree. */\r\nexport interface ComponentNode extends Node {\r\n _view: object;\r\n /** How many nodes the `children` builder made. */\r\n _built: number;\r\n _commandChildren(): readonly ChildView[];\r\n _animate(frame: (t: number) => Record<string, unknown>, duration: number, easing: unknown): unknown;\r\n}\r\n\r\n/** The base every tree's generated class extends: `Base` with the spec's state, context, assets and children. */\r\nexport function componentBase<T extends NodeBase>(Base: T, l: Lowering): T & (abstract new (...args: any[]) => ComponentNode) {\r\n const { spec: s, entries, defaults } = l;\r\n\r\n abstract class Componentized extends (Base as unknown as abstract new (...args: any[]) => Node) implements Partial<ComponentNode> {\r\n declare _view: object;\r\n declare _built: number;\r\n declare _provided: { parent: ContextMap; values: readonly Provided[]; map: ContextMap } | undefined;\r\n\r\n constructor(...args: any[]) {\r\n const props = args[0] as Record<string, unknown> | undefined;\r\n const given = s.children ? props?.children : undefined;\r\n super(s.children && props ? { ...props, children: undefined } : props);\r\n this._view = stateView(l.view, this);\r\n this._built = 0;\r\n\r\n for (const [key, def] of entries) {\r\n if (def.private) this.applyProp(key, factoryDefault(def), { mapper: def.mapper, tween: def.tween });\r\n else if (typeof def.default === \"function\" && props?.[key] === undefined) this._writeProp(key, factoryDefault(def));\r\n }\r\n let built: Readonly<Record<string, unknown>> | undefined;\r\n for (const [key, value] of Object.entries(defaults)) {\r\n if (typeof value === \"function\" && props?.[key] === undefined) {\r\n const asBuilt = (built ??= Object.freeze({ ...props }));\r\n this._writeProp(key, () => (value as (state: object, given: object) => unknown)(this._view, asBuilt));\r\n }\r\n }\r\n\r\n if (s.children) {\r\n // Live, like the field state, so a binding the builder writes reads the node as it changes.\r\n const builderState = stateView(l.view, this);\r\n Object.defineProperty(builderState, \"children\", { value: [given ?? []].flat(Infinity).filter(Boolean) });\r\n const built = [s.children(builderState as never)].flat(Infinity).filter(Boolean) as Node[];\r\n for (const part of built) this.add(part);\r\n this._built = built.length;\r\n }\r\n }\r\n\r\n /** Each entry the author left unset that inherits takes what its ancestors provide, once, on first attach. */\r\n protected override resolveContext(ctx: ContextMap): void {\r\n super.resolveContext(ctx);\r\n const given = (this._props ?? {}) as Record<string, unknown>;\r\n const self = this as unknown as Record<string, unknown>;\r\n for (const [key, def] of entries) {\r\n if (!def.inherit || given[key] !== undefined) continue;\r\n const value = def.inherit((context) => ctx.get(context), given);\r\n if (value !== undefined) self[key] = value;\r\n }\r\n }\r\n\r\n protected override provideContext(parent: ContextMap): ContextMap {\r\n if (!s.provide) return super.provideContext(parent);\r\n const provided = s.provide(this._view as never, (context) => parent.get(context as never));\r\n // The same map while nothing changed, so the subtree isn't re-bound every attach.\r\n const memo = this._provided;\r\n if (memo && memo.parent === parent && memo.values.length === provided.length\r\n && memo.values.every((p, i) => p.context === provided[i].context && p.value === provided[i].value)) return memo.map;\r\n let map = parent;\r\n for (const { context, value } of provided) if (map.get(context) !== value) map = map.with(context, value);\r\n this._provided = { parent, values: provided, map };\r\n return map;\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n const self = this as unknown as Record<string, unknown>;\r\n for (const [key, def] of entries) declareEntry(assets, def.editor.kind ?? \"\", self[key]);\r\n if (s.load) s.load(loaderOf(assets), this._view as never);\r\n }\r\n\r\n protected override acceptsChild(child: Node): boolean {\r\n const allowed = s.allowedChildren;\r\n if (allowed === undefined || allowed === null) return super.acceptsChild(child);\r\n return allowed.some((rule) => matches(child, rule));\r\n }\r\n\r\n protected override _childRule(): string {\r\n const allowed = s.allowedChildren;\r\n if (!allowed) return super._childRule();\r\n return allowed.length === 0 ? \"It takes no children.\" : `It takes only ${namesOf(allowed)}.`;\r\n }\r\n\r\n override _parentRefusal(parent: Node): string | null {\r\n const allowed = s.allowedParents;\r\n if (!allowed || allowed.some((rule) => matches(parent, rule))) return null;\r\n return `${this.className} goes only inside ${namesOf(allowed)}, not ${parent.className}.`;\r\n }\r\n\r\n /** The children a command's builders see: none, unless the tree says which. */\r\n _commandChildren(): readonly ChildView[] {\r\n return [];\r\n }\r\n\r\n _animate(frame: (t: number) => Record<string, unknown>, duration: number, easing: unknown) {\r\n return this.command(frame, duration, easing as EasingFunction | undefined);\r\n }\r\n }\r\n return Componentized as unknown as T & (abstract new (...args: any[]) => ComponentNode);\r\n}\r\n\r\ntype CommandFn = (timeline: unknown, state: unknown, children: unknown) => never;\r\n\r\n/**\r\n * Declare the state and commands on the generated class, register its key, and\r\n * hand back the component value.\r\n */\r\nexport function finishComponent(Generated: abstract new (...args: any[]) => Node, l: Lowering): object {\r\n const { spec: s, entries, defaults, builtIn } = l;\r\n Object.defineProperty(Generated, \"name\", { value: pascal(s.key) });\r\n const proto = Generated.prototype as unknown as Record<string, unknown>;\r\n // A node is a context provider by overriding these: only one that provides, or inherits, keeps them.\r\n if (!s.provide) deleteUpTo(proto, \"provideContext\");\r\n if (![...entries.values()].some((def) => def.inherit)) deleteUpTo(proto, \"resolveContext\");\r\n if (s.allowedChildren === undefined || s.allowedChildren === null) {\r\n deleteUpTo(proto, \"acceptsChild\");\r\n deleteUpTo(proto, \"_childRule\");\r\n }\r\n if (!s.allowedParents) deleteUpTo(proto, \"_parentRefusal\");\r\n const allowed = s.allowedChildren;\r\n if (allowed) {\r\n const trees = [...new Set(allowed.map((rule) => (typeof rule === \"string\"\r\n ? rule\r\n : (Object.create((rule as { node: { prototype: object } }).node.prototype) as Node).dimension)))];\r\n Object.defineProperty(proto, \"_childTrees\", { get: () => trees, configurable: true });\r\n }\r\n\r\n for (const [key, def] of entries) {\r\n if (def.private) continue;\r\n property({ default: typeof def.default === \"function\" ? undefined : def.default, mapper: def.mapper, tween: def.tween, ...def.editor })(proto, key);\r\n }\r\n for (const [key, value] of Object.entries(defaults)) {\r\n if (entries.has(key) || l.ownsDefault.has(key) || typeof value === \"function\") continue;\r\n const inherited = builtIn.get(key)!;\r\n property({ default: value, mapper: inherited.options?.mapper, tween: inherited.options?.tween, ...inherited.editor })(proto, key);\r\n }\r\n\r\n const base = Object.getPrototypeOf(Object.getPrototypeOf(proto)) as object;\r\n for (const [key, entry] of Object.entries(s.commands ?? {})) {\r\n // Commands have their own namespace: a key a node already uses (`remove`, `to`) publishes through another method name.\r\n const method = key in base ? `_command_${key}` : key;\r\n let args: CommandArg[] | undefined;\r\n if (typeof entry === \"function\") {\r\n proto[method] = function (this: ComponentNode, cmd: CommandArgs & { duration?: number } = {}): Command<Record<string, unknown>> {\r\n const duration = cmd.duration ?? 0;\r\n const timeline = makeTimeline({}, duration, cmd.easing, nodeView(this, this));\r\n const piece = (entry as CommandFn)(timeline, snapshot(this._view), this._commandChildren());\r\n return commandOf(this as never, piece, duration, cmd.easing);\r\n };\r\n } else {\r\n const { args: declared, run, easing: ownEasing } = entry as { args: readonly string[] | StateSpec; run?: CommandFn; easing?: EasingFunction };\r\n if (Array.isArray(declared)) {\r\n const names = declared as readonly string[];\r\n for (const name of names) {\r\n if (!entries.has(name) && !builtIn.has(name)) throw new TypeError(`${s.key}.${key}: args names \"${name}\", which is no entry.`);\r\n }\r\n // Each arg is its entry: what a host shows for it is what the entry means.\r\n args = names.map((name) => ({ key: name, ...(entries.get(name)?.editor ?? builtIn.get(name)?.editor ?? {}) }));\r\n proto[method] = function (this: Node, cmd: CommandArgs & { duration?: number } = {}) {\r\n const data = argsRecord(cmd.data, names);\r\n const stated: Record<string, unknown> = {};\r\n for (const name of names) if (data[name] !== undefined) stated[name] = data[name];\r\n return settling(this.to({ data: stated as never, duration: cmd.duration ?? 0, easing: cmd.easing ?? ownEasing }));\r\n };\r\n } else {\r\n const own = declared as StateSpec;\r\n args = Object.entries(own).map(([k, e]) => {\r\n const def = defOf(e);\r\n return { key: k, default: isTypeLike(e) ? factoryDefault(def) : e, ...def.editor };\r\n });\r\n proto[method] = function (this: ComponentNode, cmd: CommandArgs & { duration?: number } = {}) {\r\n const duration = cmd.duration ?? 0;\r\n const easing = cmd.easing ?? ownEasing;\r\n const timeline = makeTimeline(resolveArgs(own, cmd.data), duration, easing, nodeView(this, this));\r\n const piece = run!(timeline, snapshot(this._view), this._commandChildren());\r\n return commandOf(this as never, piece, duration, easing);\r\n };\r\n }\r\n }\r\n command({ key, ...(args ? { args } : {}) })(proto, method);\r\n }\r\n\r\n node({ key: s.key })(Generated as never);\r\n return componentValue(s.key, Generated as unknown as new (props?: Record<string, unknown>) => object);\r\n}\r\n\r\n/** Remove the generated override of `name`, wherever between the class and its base it sits. */\r\nfunction deleteUpTo(proto: Record<string, unknown>, name: string): void {\r\n for (let at: Record<string, unknown> | null = proto; at; at = Object.getPrototypeOf(at) as Record<string, unknown> | null) {\r\n if (Object.prototype.hasOwnProperty.call(at, name)) {\r\n delete at[name];\r\n return;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * What a factory hands back: call it (`Rect({...})`) or `new` it, either way a\r\n * node of the generated class, which is also what `instanceof` tests.\r\n */\r\nexport function componentValue(key: string, Generated: new (props?: Record<string, unknown>) => object): object {\r\n const make = function (props?: object) {\r\n return new Generated(props as Record<string, unknown>);\r\n };\r\n make.prototype = Generated.prototype;\r\n Object.defineProperty(make, \"name\", { value: Generated.name });\r\n return Object.assign(make, {\r\n key,\r\n node: Generated,\r\n is: (child: unknown) => nodeOfView(child as never) instanceof Generated,\r\n });\r\n}\r\n\r\nfunction pascal(key: string): string {\r\n return key.replace(/(^|[-_ ])(\\w)/g, (_, _sep, c: string) => c.toUpperCase());\r\n}\r\n\r\n/** Whether `node` is of `rule`: a component, or a whole tree by name. */\r\nfunction matches(node: Node, rule: unknown): boolean {\r\n return typeof rule === \"string\"\r\n ? node.dimension === rule\r\n : node instanceof (rule as { node: abstract new (...args: never[]) => unknown }).node;\r\n}\r\n\r\nfunction namesOf(rules: readonly unknown[]): string {\r\n const names = rules.map((rule) => (typeof rule === \"string\" ? `any ${rule.toUpperCase()} node` : (rule as { node: { name: string } }).node.name));\r\n return names.length === 1 ? names[0] : `${names.slice(0, -1).join(\", \")} or ${names.at(-1)}`;\r\n}\r\n\r\n/** One document arg: the bare value from a paint command, or the args record from the registry. */\r\nfunction argsRecord(data: unknown, names: readonly string[]): Record<string, unknown> {\r\n if (names.length === 1) {\r\n const plain = typeof data === \"object\" && data !== null && !Array.isArray(data) && Object.getPrototypeOf(data) === Object.prototype;\r\n if (!(plain && names[0] in (data as object))) return { [names[0]]: data };\r\n }\r\n return (data ?? {}) as Record<string, unknown>;\r\n}\r\n\r\nfunction resolveArgs(spec: StateSpec, data: unknown): Record<string, unknown> {\r\n const given = (data ?? {}) as Record<string, unknown>;\r\n const out: Record<string, unknown> = {};\r\n for (const key in spec) {\r\n const def = defOf(spec[key]);\r\n const value = given[key] === undefined ? factoryDefault(def) : given[key];\r\n out[key] = def.mapper ? def.mapper(value) : value;\r\n }\r\n return out;\r\n}\r\n\r\nfunction declareEntry(assets: AssetScope, kind: string, value: unknown): void {\r\n if (value === undefined || value === null || value === \"\") return;\r\n switch (kind) {\r\n case \"fills\": return assets.fill(value as FillResolved[]);\r\n case \"strokes\": for (const stroke of value as StrokeResolved[]) assets.fill(stroke.fill); return;\r\n case \"shadows\": for (const shadow of value as ShadowResolved[]) assets.fill(shadow.fill); return;\r\n case \"image\": return assets.image(value as string);\r\n case \"video\": return assets.video(value as string);\r\n case \"font\": return assets.font(value as string);\r\n }\r\n}\r\n\r\n/** One wrapper per load function: the scope warns when a key's second declaration hands it a different one. */\r\nconst tasks = new WeakMap<() => Promise<unknown>, () => Promise<void | Disposer>>();\r\n\r\nfunction taskOf(load: () => Promise<unknown>): () => Promise<void | Disposer> {\r\n let task = tasks.get(load);\r\n if (!task) {\r\n task = async () => {\r\n const loaded = await load();\r\n return typeof loaded === \"function\" ? (loaded as Disposer) : undefined;\r\n };\r\n tasks.set(load, task);\r\n }\r\n return task;\r\n}\r\n\r\nfunction loaderOf(assets: AssetScope): Loader {\r\n return {\r\n font: (family, weight) => assets.font(family, weight),\r\n image: (src) => assets.image(src),\r\n video: (src, trim) => assets.video(src, trim),\r\n task: (key, load, options) => assets.loader(key, taskOf(load), { gate: options?.before === \"layout\" ? \"layout\" : \"render\" }),\r\n fill: (fills) => assets.fill(fills),\r\n };\r\n}\r\n"]}
@@ -0,0 +1,30 @@
1
+ import { type Vector2 } from "../../attributes/layout/vector2.js";
2
+ import type { RenderContext2D, Values } from "../../component/api.js";
3
+ /** Where a 2D camera looks: a point, a zoom and a heading, or a node below it to follow. */
4
+ export declare const state: {
5
+ zoom: import("../../component/api.js").Type<number, number, false>;
6
+ lookAt: import("../../component/api.js").Type<Vector2, Vector2, false>;
7
+ heading: import("../../component/api.js").Type<number, number, false>;
8
+ follow: import("../../component/api.js").Type<string, import("../../component/api.js").NodeView<import("../../component/api.js").Element<string, unknown, unknown>> | null, false>;
9
+ };
10
+ export declare const commands: {
11
+ readonly zoomTo: {
12
+ readonly args: readonly ["zoom"];
13
+ readonly run?: undefined;
14
+ };
15
+ readonly panTo: {
16
+ readonly args: readonly ["lookAt"];
17
+ readonly run?: undefined;
18
+ };
19
+ readonly headingTo: {
20
+ readonly args: readonly ["heading"];
21
+ readonly run?: undefined;
22
+ };
23
+ };
24
+ type AimState = Values<typeof state>;
25
+ /** The point the camera centres on: `lookAt`, offset from the followed node when there is one below it. */
26
+ export declare function aim(ctx: RenderContext2D, s: AimState): Vector2;
27
+ /** The children, through this camera. */
28
+ export declare function camera(ctx: RenderContext2D, s: AimState): void;
29
+ export {};
30
+ //# sourceMappingURL=aim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aim.d.ts","sourceRoot":"","sources":["../../../src/component/modules/aim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAK/D,4FAA4F;AAC5F,eAAO,MAAM,KAAK;;;;;CAKjB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;CAInB,CAAC;AAEH,KAAK,QAAQ,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC;AAErC,2GAA2G;AAC3G,wBAAgB,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAO9D;AAED,yCAAyC;AACzC,wBAAgB,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAE9D"}
@@ -0,0 +1,39 @@
1
+ import { lerpVector2 } from "../../attributes/layout/vector2.js";
2
+ import { Node2D } from "../../nodes/2d/node2d.js";
3
+ import { commandsFor } from "../../component/commands-for.js";
4
+ import { Types } from "../../component/types.js";
5
+ import { internalsOf, nodeOfNodeView } from "../../component/views.js";
6
+ /** Where a 2D camera looks: a point, a zoom and a heading, or a node below it to follow. */
7
+ export const state = {
8
+ zoom: Types.number(1, { min: 0.01, step: 0.1, unit: "×" }),
9
+ lookAt: Types.custom({ x: 0, y: 0 }, { lerp: lerpVector2, kind: "vector2", properties: { x: { kind: "number" }, y: { kind: "number" } } }),
10
+ heading: Types.number(0, { step: 1, unit: "°" }),
11
+ follow: Types.nodeRef(),
12
+ };
13
+ export const commands = commandsFor(state, {
14
+ zoomTo: { args: ["zoom"] },
15
+ panTo: { args: ["lookAt"] },
16
+ headingTo: { args: ["heading"] },
17
+ });
18
+ /** The point the camera centres on: `lookAt`, offset from the followed node when there is one below it. */
19
+ export function aim(ctx, s) {
20
+ const target = s.follow;
21
+ if (!target)
22
+ return s.lookAt;
23
+ const node = nodeOfNodeView(target);
24
+ if (!(node instanceof Node2D) || !within(node, internalsOf(ctx).host))
25
+ return s.lookAt;
26
+ const at = target.frame;
27
+ return { x: at.x + s.lookAt.x, y: at.y + s.lookAt.y };
28
+ }
29
+ /** The children, through this camera. */
30
+ export function camera(ctx, s) {
31
+ ctx.camera({ lookAt: aim(ctx, s), zoom: s.zoom, heading: s.heading });
32
+ }
33
+ function within(node, ancestor) {
34
+ for (let at = node.parent; at; at = at.parent)
35
+ if (at === ancestor)
36
+ return true;
37
+ return false;
38
+ }
39
+ //# sourceMappingURL=aim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aim.js","sourceRoot":"","sources":["../../../src/component/modules/aim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE,4FAA4F;AAC5F,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC1D,MAAM,EAAE,KAAK,CAAC,MAAM,CAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,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,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,MAAM,CAAC,IAAU,EAAE,QAAc;IACtC,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM;QAAE,IAAI,EAAE,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;IAChF,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { lerpVector2, type Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { Node2D } from \"@/nodes/2d/node2d\";\r\nimport type { Node } from \"@/nodes/node/node\";\r\nimport type { RenderContext2D, Values } from \"@/component/api\";\r\nimport { commandsFor } from \"@/component/commands-for\";\r\nimport { Types } from \"@/component/types\";\r\nimport { internalsOf, nodeOfNodeView } from \"@/component/views\";\r\n\r\n/** Where a 2D camera looks: a point, a zoom and a heading, or a node below it to follow. */\r\nexport const state = {\r\n zoom: Types.number(1, { min: 0.01, step: 0.1, unit: \"×\" }),\r\n lookAt: Types.custom<Vector2>({ x: 0, y: 0 }, { lerp: lerpVector2, kind: \"vector2\", properties: { x: { kind: \"number\" }, y: { kind: \"number\" } } }),\r\n heading: Types.number(0, { step: 1, unit: \"°\" }),\r\n follow: Types.nodeRef(),\r\n};\r\n\r\nexport const commands = commandsFor(state, {\r\n zoomTo: { args: [\"zoom\"] },\r\n panTo: { args: [\"lookAt\"] },\r\n headingTo: { args: [\"heading\"] },\r\n});\r\n\r\ntype AimState = Values<typeof state>;\r\n\r\n/** The point the camera centres on: `lookAt`, offset from the followed node when there is one below it. */\r\nexport function aim(ctx: RenderContext2D, s: AimState): Vector2 {\r\n const target = s.follow;\r\n if (!target) return s.lookAt;\r\n const node = nodeOfNodeView(target);\r\n if (!(node instanceof Node2D) || !within(node, internalsOf(ctx).host)) return s.lookAt;\r\n const at = target.frame;\r\n return { x: at.x + s.lookAt.x, y: at.y + s.lookAt.y };\r\n}\r\n\r\n/** The children, through this camera. */\r\nexport function camera(ctx: RenderContext2D, s: AimState): void {\r\n ctx.camera({ lookAt: aim(ctx, s), zoom: s.zoom, heading: s.heading });\r\n}\r\n\r\nfunction within(node: Node, ancestor: Node): boolean {\r\n for (let at = node.parent; at; at = at.parent) if (at === ancestor) return true;\r\n return false;\r\n}\r\n"]}
@@ -0,0 +1,13 @@
1
+ import type { Size2D } from "../../attributes/layout/size.js";
2
+ import type { CornerRadiusResolved, RectCornerRadius } from "../../attributes/shape/corners/corner-radius.js";
3
+ import type { CornerStyleResolved, RectCornerStyle } from "../../attributes/shape/corners/corner-style.js";
4
+ import { Graphics2D } from "../../render/graphics2d.js";
5
+ import type { Values } from "../../component/api.js";
6
+ import { type Attribute } from "../../component/types.js";
7
+ export declare const state: {
8
+ cornerRadius: Attribute<RectCornerRadius, CornerRadiusResolved>;
9
+ cornerStyle: Attribute<RectCornerStyle, CornerStyleResolved>;
10
+ };
11
+ /** A rectangle the size of the box, with these corners. */
12
+ export declare function rect(size: Size2D, s: Values<typeof state>): Graphics2D;
13
+ //# sourceMappingURL=corners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corners.d.ts","sourceRoot":"","sources":["../../../src/component/modules/corners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACvG,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,KAAK,EAAE;IAAE,YAAY,EAAE,SAAS,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;CAGlJ,CAAC;AAEF,2DAA2D;AAC3D,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,KAAK,CAAC,GAAG,UAAU,CAEtE"}
@@ -0,0 +1,12 @@
1
+ import { Graphics2D } from "../../render/graphics2d.js";
2
+ import { Types } from "../../component/types.js";
3
+ // Typed out so the declarations name what the corners take by their own modules: a kit's emit reaches those through the sdk.
4
+ export const state = {
5
+ cornerRadius: Types.cornerRadius,
6
+ cornerStyle: Types.cornerStyle,
7
+ };
8
+ /** A rectangle the size of the box, with these corners. */
9
+ export function rect(size, s) {
10
+ return new Graphics2D().rect({ width: size.width, height: size.height, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle });
11
+ }
12
+ //# sourceMappingURL=corners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corners.js","sourceRoot":"","sources":["../../../src/component/modules/corners.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAkB,MAAM,mBAAmB,CAAC;AAE1D,6HAA6H;AAC7H,MAAM,CAAC,MAAM,KAAK,GAAsI;IACpJ,YAAY,EAAE,KAAK,CAAC,YAAY;IAChC,WAAW,EAAE,KAAK,CAAC,WAAW;CACjC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,CAAuB;IACtD,OAAO,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACvI,CAAC","sourcesContent":["import type { Size2D } from \"@/attributes/layout/size\";\r\nimport type { CornerRadiusResolved, RectCornerRadius } from \"@/attributes/shape/corners/corner-radius\";\r\nimport type { CornerStyleResolved, RectCornerStyle } from \"@/attributes/shape/corners/corner-style\";\r\nimport { Graphics2D } from \"@/render/graphics2d\";\r\nimport type { Values } from \"@/component/api\";\r\nimport { Types, type Attribute } from \"@/component/types\";\r\n\r\n// Typed out so the declarations name what the corners take by their own modules: a kit's emit reaches those through the sdk.\r\nexport const state: { cornerRadius: Attribute<RectCornerRadius, CornerRadiusResolved>; cornerStyle: Attribute<RectCornerStyle, CornerStyleResolved> } = {\r\n cornerRadius: Types.cornerRadius,\r\n cornerStyle: Types.cornerStyle,\r\n};\r\n\r\n/** A rectangle the size of the box, with these corners. */\r\nexport function rect(size: Size2D, s: Values<typeof state>): Graphics2D {\r\n return new Graphics2D().rect({ width: size.width, height: size.height, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle });\r\n}\r\n"]}
@@ -0,0 +1,26 @@
1
+ import type { Alignment } from "../../attributes/layout/alignment.js";
2
+ import type { InsetsResolved } from "../../attributes/layout/insets.js";
3
+ import type { Size2D } from "../../attributes/layout/size.js";
4
+ import type { Vector2 } from "../../attributes/layout/vector2.js";
5
+ import type { BoxBounds } from "../../layout/bounds.js";
6
+ import type { FlowMode, FlowResolved, GapSize } from "../../layout/types.js";
7
+ import type { ChildView, Measurer, Placement2D, Values } from "../../component/api.js";
8
+ import { type Attribute } from "../../component/types.js";
9
+ /** The Rect layout engine: freeform, runs, wrapped runs and grids. */
10
+ export declare const state: {
11
+ flow: import("../../component/api.js").Type<FlowMode, FlowResolved, false>;
12
+ gap: import("../../component/api.js").Type<GapSize, GapSize, false>;
13
+ wrap: boolean;
14
+ crossGap: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
15
+ columns: import("../../component/api.js").Type<number, number, false>;
16
+ align: Attribute<Alignment, Vector2>;
17
+ };
18
+ export type FlowState = Values<typeof state> & {
19
+ readonly padding: InsetsResolved;
20
+ readonly width: import("../../attributes/layout/size.js").SizeInput;
21
+ readonly height: import("../../attributes/layout/size.js").SizeInput;
22
+ };
23
+ /** `inset` is room the children must clear beyond `padding`: a stroke, say. */
24
+ export declare function measure(measurer: Measurer, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): Size2D;
25
+ export declare function layout(box: BoxBounds, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): readonly Placement2D[];
26
+ //# sourceMappingURL=flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/component/modules/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAe,QAAQ,EAAE,YAAY,EAAgB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG1D,sEAAsE;AACtE,eAAO,MAAM,KAAK;;;;;;WAOY,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,GAAG;IAC3C,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,OAAO,0BAA0B,EAAE,SAAS,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,OAAO,0BAA0B,EAAE,SAAS,CAAC;CACjE,CAAC;AAaF,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,MAAM,CAY7H;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,WAAW,EAAE,CAexI"}
@@ -0,0 +1,55 @@
1
+ import { insetsOps } from "../../attributes/layout/insets.js";
2
+ import { flowOps } from "../../layout/ops.js";
3
+ import { Types } from "../../component/types.js";
4
+ import { currentPass, nodeOfView } from "../../component/views.js";
5
+ /** The Rect layout engine: freeform, runs, wrapped runs and grids. */
6
+ export const state = {
7
+ flow: Types.custom("freeform", { lerp: flowOps.lerp }),
8
+ gap: Types.custom(0),
9
+ wrap: false,
10
+ crossGap: Types.custom(undefined),
11
+ columns: Types.number(1),
12
+ // Typed out so the declarations name Alignment by its own module: a kit's emit reaches it through the sdk.
13
+ align: Types.alignment,
14
+ };
15
+ const NO_CONTENT = { width: 0, height: 0 };
16
+ /** The measure a container took, kept for its layout in the same pass (as `Node2D` keeps its own). */
17
+ const pending = new WeakMap();
18
+ function padded(s, inset) {
19
+ const p = s.padding;
20
+ if (!inset)
21
+ return p;
22
+ return { left: p.left + inset.left, right: p.right + inset.right, top: p.top + inset.top, bottom: p.bottom + inset.bottom };
23
+ }
24
+ /** `inset` is room the children must clear beyond `padding`: a stroke, say. */
25
+ export function measure(measurer, s, children, inset) {
26
+ const { node, scope } = currentPass();
27
+ const padding = padded(s, inset);
28
+ const constraints = { maxWidth: measurer.max.width, maxHeight: measurer.max.height };
29
+ if (children.length === 0) {
30
+ pending.delete(node);
31
+ return flowOps.size(s, constraints, padding, NO_CONTENT);
32
+ }
33
+ const space = flowOps.contentBox(s, constraints, padding);
34
+ const measured = flowOps.measure(s, children.map(nodeOfView), space, scope);
35
+ pending.set(node, measured);
36
+ return flowOps.size(s, constraints, padding, measured.hug);
37
+ }
38
+ export function layout(box, s, children, inset) {
39
+ const { node, scope } = currentPass();
40
+ const kept = pending.get(node);
41
+ pending.delete(node);
42
+ if (children.length === 0)
43
+ return [];
44
+ const inner = insetsOps.insetBounds(box.width, box.height, padded(s, inset));
45
+ const measured = kept && flowOps.reusable(kept, inner)
46
+ ? kept
47
+ : flowOps.measure(s, children.map(nodeOfView), {
48
+ width: inner.width, height: inner.height, hugWidth: s.width === "hug", hugHeight: s.height === "hug",
49
+ }, scope);
50
+ // `place` answers y-up from the content box's centre; a placement is y-up from the component's.
51
+ return flowOps.place(measured, s, inner).map((b) => ({
52
+ x: inner.x + b.x, y: b.y - inner.y, width: b.width, height: b.height,
53
+ }));
54
+ }
55
+ //# sourceMappingURL=flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.js","sourceRoot":"","sources":["../../../src/component/modules/flow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EAAE,KAAK,EAAkB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5D,sEAAsE;AACtE,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAyB,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAC9E,GAAG,EAAE,KAAK,CAAC,MAAM,CAAU,CAAC,CAAC;IAC7B,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,KAAK,CAAC,MAAM,CA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,KAAK,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,KAAK,KAAK;SACvG,EAAE,KAAK,CAAC,CAAC;IACd,gGAAgG;IAChG,OAAO,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAiB,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM;KACvE,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import type { Alignment } from \"@/attributes/layout/alignment\";\r\nimport type { InsetsResolved } from \"@/attributes/layout/insets\";\r\nimport { insetsOps } from \"@/attributes/layout/insets\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { BoxBounds } from \"@/layout/bounds\";\r\nimport { flowOps } from \"@/layout/ops\";\r\nimport type { FlowMeasure, FlowMode, FlowResolved, FlowSettings, GapSize } from \"@/layout/types\";\r\nimport type { Node2D } from \"@/nodes/2d/node2d\";\r\nimport type { ChildView, Measurer, Placement2D, Values } from \"@/component/api\";\r\nimport { Types, type Attribute } from \"@/component/types\";\r\nimport { currentPass, nodeOfView } from \"@/component/views\";\r\n\r\n/** The Rect layout engine: freeform, runs, wrapped runs and grids. */\r\nexport const state = {\r\n flow: Types.custom<FlowMode, FlowResolved>(\"freeform\", { lerp: flowOps.lerp }),\r\n gap: Types.custom<GapSize>(0),\r\n wrap: false,\r\n crossGap: Types.custom<number | undefined>(undefined),\r\n columns: Types.number(1),\r\n // Typed out so the declarations name Alignment by its own module: a kit's emit reaches it through the sdk.\r\n align: Types.alignment as Attribute<Alignment, Vector2>,\r\n};\r\n\r\nexport type FlowState = Values<typeof state> & {\r\n readonly padding: InsetsResolved;\r\n readonly width: import(\"@/attributes/layout/size\").SizeInput;\r\n readonly height: import(\"@/attributes/layout/size\").SizeInput;\r\n};\r\n\r\nconst NO_CONTENT: Size2D = { width: 0, height: 0 };\r\n\r\n/** The measure a container took, kept for its layout in the same pass (as `Node2D` keeps its own). */\r\nconst pending = new WeakMap<Node2D, FlowMeasure<Node2D>>();\r\n\r\nfunction padded(s: FlowState, inset: InsetsResolved | undefined): InsetsResolved {\r\n const p = s.padding;\r\n if (!inset) return p;\r\n return { left: p.left + inset.left, right: p.right + inset.right, top: p.top + inset.top, bottom: p.bottom + inset.bottom };\r\n}\r\n\r\n/** `inset` is room the children must clear beyond `padding`: a stroke, say. */\r\nexport function measure(measurer: Measurer, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): Size2D {\r\n const { node, scope } = currentPass();\r\n const padding = padded(s, inset);\r\n const constraints = { maxWidth: measurer.max.width, maxHeight: measurer.max.height };\r\n if (children.length === 0) {\r\n pending.delete(node);\r\n return flowOps.size(s, constraints, padding, NO_CONTENT);\r\n }\r\n const space = flowOps.contentBox(s, constraints, padding);\r\n const measured = flowOps.measure(s as FlowSettings, children.map(nodeOfView), space, scope);\r\n pending.set(node, measured);\r\n return flowOps.size(s, constraints, padding, measured.hug);\r\n}\r\n\r\nexport function layout(box: BoxBounds, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): readonly Placement2D[] {\r\n const { node, scope } = currentPass();\r\n const kept = pending.get(node);\r\n pending.delete(node);\r\n if (children.length === 0) return [];\r\n const inner = insetsOps.insetBounds(box.width, box.height, padded(s, inset));\r\n const measured = kept && flowOps.reusable(kept, inner)\r\n ? kept\r\n : flowOps.measure(s as FlowSettings, children.map(nodeOfView), {\r\n width: inner.width, height: inner.height, hugWidth: s.width === \"hug\", hugHeight: s.height === \"hug\",\r\n }, scope);\r\n // `place` answers y-up from the content box's centre; a placement is y-up from the component's.\r\n return flowOps.place(measured, s as FlowSettings, inner).map((b) => ({\r\n x: inner.x + b.x, y: b.y - inner.y, width: b.width, height: b.height,\r\n }));\r\n}\r\n"]}