@motionscript/grids 0.0.0-stage → 0.1.0-alpha.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.
Files changed (133) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +117 -2
  5. package/dist/browser/chunks/chunk-TYNFMZ3D.js +2 -0
  6. package/dist/browser/chunks/chunk-TYNFMZ3D.js.map +7 -0
  7. package/dist/browser/index.js +2 -0
  8. package/dist/browser/index.js.map +7 -0
  9. package/dist/browser/kit.js +2 -0
  10. package/dist/browser/kit.js.map +7 -0
  11. package/dist/browser/manifest.json +13 -0
  12. package/dist/engine.d.ts +13 -0
  13. package/dist/engine.d.ts.map +1 -0
  14. package/dist/engine.js +13 -0
  15. package/dist/engine.js.map +1 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +7 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/kit/index.d.ts +9 -0
  21. package/dist/kit/index.d.ts.map +1 -0
  22. package/dist/kit/index.js +10 -0
  23. package/dist/kit/index.js.map +1 -0
  24. package/dist/kit/item-effects.d.ts +37 -0
  25. package/dist/kit/item-effects.d.ts.map +1 -0
  26. package/dist/kit/item-effects.js +76 -0
  27. package/dist/kit/item-effects.js.map +1 -0
  28. package/dist/kit/item-grid.d.ts +240 -0
  29. package/dist/kit/item-grid.d.ts.map +1 -0
  30. package/dist/kit/item-grid.js +492 -0
  31. package/dist/kit/item-grid.js.map +1 -0
  32. package/dist/kit/order.d.ts +13 -0
  33. package/dist/kit/order.d.ts.map +1 -0
  34. package/dist/kit/order.js +43 -0
  35. package/dist/kit/order.js.map +1 -0
  36. package/dist/kit/random.d.ts +7 -0
  37. package/dist/kit/random.d.ts.map +1 -0
  38. package/dist/kit/random.js +29 -0
  39. package/dist/kit/random.js.map +1 -0
  40. package/dist/kit/slots/index.d.ts +22 -0
  41. package/dist/kit/slots/index.d.ts.map +1 -0
  42. package/dist/kit/slots/index.js +28 -0
  43. package/dist/kit/slots/index.js.map +1 -0
  44. package/dist/kit/slots/path-templates.d.ts +15 -0
  45. package/dist/kit/slots/path-templates.d.ts.map +1 -0
  46. package/dist/kit/slots/path-templates.js +113 -0
  47. package/dist/kit/slots/path-templates.js.map +1 -0
  48. package/dist/kit/slots/path.d.ts +45 -0
  49. package/dist/kit/slots/path.d.ts.map +1 -0
  50. package/dist/kit/slots/path.js +87 -0
  51. package/dist/kit/slots/path.js.map +1 -0
  52. package/dist/kit/slots/radial.d.ts +30 -0
  53. package/dist/kit/slots/radial.d.ts.map +1 -0
  54. package/dist/kit/slots/radial.js +45 -0
  55. package/dist/kit/slots/radial.js.map +1 -0
  56. package/dist/kit/slots/rectangular.d.ts +42 -0
  57. package/dist/kit/slots/rectangular.d.ts.map +1 -0
  58. package/dist/kit/slots/rectangular.js +79 -0
  59. package/dist/kit/slots/rectangular.js.map +1 -0
  60. package/dist/kit/slots/slot.d.ts +62 -0
  61. package/dist/kit/slots/slot.d.ts.map +1 -0
  62. package/dist/kit/slots/slot.js +41 -0
  63. package/dist/kit/slots/slot.js.map +1 -0
  64. package/dist/kit/slots/sphere.d.ts +36 -0
  65. package/dist/kit/slots/sphere.d.ts.map +1 -0
  66. package/dist/kit/slots/sphere.js +68 -0
  67. package/dist/kit/slots/sphere.js.map +1 -0
  68. package/dist/kit/stagger.d.ts +24 -0
  69. package/dist/kit/stagger.d.ts.map +1 -0
  70. package/dist/kit/stagger.js +90 -0
  71. package/dist/kit/stagger.js.map +1 -0
  72. package/dist/nodes.d.ts +20 -0
  73. package/dist/nodes.d.ts.map +1 -0
  74. package/dist/nodes.js +11 -0
  75. package/dist/nodes.js.map +1 -0
  76. package/dist/path-grid/index.d.ts +2 -0
  77. package/dist/path-grid/index.d.ts.map +1 -0
  78. package/dist/path-grid/index.js +2 -0
  79. package/dist/path-grid/index.js.map +1 -0
  80. package/dist/path-grid/path-grid.d.ts +196 -0
  81. package/dist/path-grid/path-grid.d.ts.map +1 -0
  82. package/dist/path-grid/path-grid.js +149 -0
  83. package/dist/path-grid/path-grid.js.map +1 -0
  84. package/dist/radial-grid/index.d.ts +2 -0
  85. package/dist/radial-grid/index.d.ts.map +1 -0
  86. package/dist/radial-grid/index.js +2 -0
  87. package/dist/radial-grid/index.js.map +1 -0
  88. package/dist/radial-grid/radial-grid.d.ts +177 -0
  89. package/dist/radial-grid/radial-grid.d.ts.map +1 -0
  90. package/dist/radial-grid/radial-grid.js +63 -0
  91. package/dist/radial-grid/radial-grid.js.map +1 -0
  92. package/dist/rectangular-grid/index.d.ts +2 -0
  93. package/dist/rectangular-grid/index.d.ts.map +1 -0
  94. package/dist/rectangular-grid/index.js +2 -0
  95. package/dist/rectangular-grid/index.js.map +1 -0
  96. package/dist/rectangular-grid/rectangular-grid.d.ts +212 -0
  97. package/dist/rectangular-grid/rectangular-grid.d.ts.map +1 -0
  98. package/dist/rectangular-grid/rectangular-grid.js +118 -0
  99. package/dist/rectangular-grid/rectangular-grid.js.map +1 -0
  100. package/dist/sphere-grid/index.d.ts +2 -0
  101. package/dist/sphere-grid/index.d.ts.map +1 -0
  102. package/dist/sphere-grid/index.js +2 -0
  103. package/dist/sphere-grid/index.js.map +1 -0
  104. package/dist/sphere-grid/sphere-grid.d.ts +200 -0
  105. package/dist/sphere-grid/sphere-grid.d.ts.map +1 -0
  106. package/dist/sphere-grid/sphere-grid.js +102 -0
  107. package/dist/sphere-grid/sphere-grid.js.map +1 -0
  108. package/package.json +72 -3
  109. package/registry.json +32 -0
  110. package/src/engine.ts +12 -0
  111. package/src/index.ts +6 -0
  112. package/src/kit/index.ts +18 -0
  113. package/src/kit/item-effects.ts +114 -0
  114. package/src/kit/item-grid.ts +648 -0
  115. package/src/kit/order.ts +41 -0
  116. package/src/kit/random.ts +29 -0
  117. package/src/kit/slots/index.ts +39 -0
  118. package/src/kit/slots/path-templates.ts +120 -0
  119. package/src/kit/slots/path.ts +120 -0
  120. package/src/kit/slots/radial.ts +62 -0
  121. package/src/kit/slots/rectangular.ts +108 -0
  122. package/src/kit/slots/slot.ts +82 -0
  123. package/src/kit/slots/sphere.ts +94 -0
  124. package/src/kit/stagger.ts +96 -0
  125. package/src/nodes.ts +30 -0
  126. package/src/path-grid/index.ts +1 -0
  127. package/src/path-grid/path-grid.ts +186 -0
  128. package/src/radial-grid/index.ts +1 -0
  129. package/src/radial-grid/radial-grid.ts +81 -0
  130. package/src/rectangular-grid/index.ts +1 -0
  131. package/src/rectangular-grid/rectangular-grid.ts +145 -0
  132. package/src/sphere-grid/index.ts +1 -0
  133. package/src/sphere-grid/sphere-grid.ts +129 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,87 @@
1
+ # @motionscript/grids
2
+
3
+ ## 0.1.0-alpha.10
4
+
5
+ ## 0.1.0-alpha.9
6
+
7
+ ## 0.1.0-alpha.8
8
+
9
+ ## 0.1.0-alpha.7
10
+
11
+ ## 0.1.0-alpha.6
12
+
13
+ ### Minor Changes
14
+
15
+ - 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
16
+
17
+ - **Writing a node type.** A component is one object literal: `key`, `state` (literals and `Types`), `defaults`, `commands`, `children`, `allowedChildren`/`allowedParents`, `provide`, `load`, and its tree's own fields (`measure`, `layout`, `render` for 2D). Behaviour comes from modules you spread in and call: `Paint`, `Flow`, `Shapes`, `Typeface`, `TextLayout`, `Aim`, `Material`, `View3D`. ADR 0007 and the custom-node docs cover it.
18
+ - **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
19
+ - **Every built-in and every kit node is a component**, under the same document key. Code that tested `instanceof` a class now uses the component's `.is`, or `instanceof X.node`. Changed members:
20
+ - `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
21
+ - A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
22
+ - `PieChart.isSelected` is replaced by `isSliceSelected`.
23
+ - `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
24
+ - **The sdk no longer exports the class surface:**
25
+ - the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
26
+ - the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
27
+ - `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
28
+ - the `jsx-runtime` and `jsx-dev-runtime` subpaths.
29
+ - `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
30
+ - **Editor metadata leaves the engine.** The kits no longer declare `parentKey`, `forkable`, `layout`, `seed`, `within`, `beside` or `closed`; a host keeps those in its own configs. `describe()` now reports `holds`, the trees a type takes children from, and the placement checks use it, so a 2D viewport of your own that takes 3D children places them.
31
+ - A command called from code with no argument runs, and a refused child is told what its parent takes (`allowedChildren`) or where it goes (`allowedParents`).
32
+
33
+ ## 0.1.0-alpha.5
34
+
35
+ ### Patch Changes
36
+
37
+ - da6f97a: Every package ships a `NOTICE`, and a browser build lists what it bundles.
38
+
39
+ - Each tarball carries the repository `NOTICE`: the copyright line and the MIT attributions for the noise functions in `skia-render`'s fractal-noise fill (David Hoskins' "Hash without Sine", Inigo Quilez's 2D simplex noise).
40
+ - `@motionscript/canvaskit` ships `THIRD_PARTY_NOTICES.txt` with the licences of the libraries compiled into the binary: FreeType, HarfBuzz, ICU 74, zlib, libpng, Brotli, WOFF2, Emscripten and musl.
41
+ - `dist/browser/manifest.json` gains `thirdParty`, the packages the browser build bundled (`name`, `version`, `license`), and their licence and NOTICE files are written to `dist/browser/THIRD_PARTY_LICENSES.txt`. `@motionscript/browser` bundles mediabunny (MPL-2.0, unmodified; source at https://github.com/Vanilagy/mediabunny), esbuild-wasm and three; `@motionscript/math` bundles MathJax.
42
+
43
+ - 1778355: The published packages carry what a user needs and say what they are.
44
+
45
+ - `@motionscript/code` no longer ships `dist/tests/diff.bench.*`, and `@motionscript/math` no longer ships `dist/tests/harness.*` or `mathjax.setup.*`: test helpers under a `tests` folder are left out of every package's build.
46
+ - `@motionscript/sdk`'s description no longer repeats core's, and `@motionscript/math`'s names the coordinate systems, plots, 3D graphs and network graphs it has as well as formulas.
47
+ - The READMEs of `@motionscript/canvaskit`, `@motionscript/charts`, `@motionscript/geo`, `@motionscript/grids`, `@motionscript/skia-render` and `@motionscript/geography` say what to install, and `@motionscript/sdk`'s example now opens the document in an engine and plays it. Links between packages point at the repository, so they work on npm.
48
+
49
+ ## 0.1.0-alpha.4
50
+
51
+ ### Minor Changes
52
+
53
+ - 3eefc7e: Package reshuffle.
54
+
55
+ - `@motionscript/layout-grid` is now `@motionscript/grids` (`@motionscript/grids/kit`, and `packages/components/grids`), and its `LayoutGrid` base class is `ItemGrid` (`ItemGridProps`, `ITEM_GRID_TYPES`). `RectangularGrid`, `RadialGrid`, `PathGrid` and `SphereGrid` keep their names and document keys. Update the dependency, the imports, and any `@motionscript/layout-grid/kit` specifier a copied component carries.
56
+ - `@motionscript/geo-data` is now `@motionscript/geography`. The data format on disk (`data/v1/…`) is unchanged, so `@motionscript/geo` reads it as before and a host that serves `@motionscript/geo-data/data` serves `@motionscript/geography/data` the same way.
57
+ - `@motionscript/ui` is removed: its `Switch`, `Button`, `Window` and `Cursor` nodes, and the `ControlNode` base class, no longer ship. They are plain nodes over `@motionscript/sdk`, so a project that needs one writes its own and shapes it to taste.
58
+ - `@motionscript/patterns` is new. It holds the pattern nodes (`LineGridPattern`, `DotGridPattern`, `GridPattern`, `ViewportPattern`) that `@motionscript/core` and `@motionscript/sdk` no longer ship.
59
+
60
+ ### Patch Changes
61
+
62
+ - 7f8b4d0: A node can give its children coordinates of its own, which is what a coordinate system needs: a child's `x`/`y` are then in the parent's units and the child keeps its size.
63
+
64
+ - A parent answers `_planeOf(child)` with a `ChildPlane` (`toOffset` and `toCoords`, exported). Paint, `global`, the anchor getters, `moveTo({ target })` and `parentPlanePointAt` all read it, and the last two answer in the parent's coordinates. A node whose parent publishes none is unchanged.
65
+ - `childPlanePointAt(root, path, point)`, and `childPlanePoint` on the player, say where a point lands in the coordinates a node positions its children in, for a host placing a node that is not there yet. They answer `null` for a node whose children are in pixels, and `_planeOf(null)` is what they ask.
66
+ - `findNode2D(from, id)` and `frameIn(host, node)` are exported from the SDK, for a node that follows another by id. `@motionscript/grids` now uses them and still exports both names.
67
+
68
+ - e78f716: Kit gaps in waveforms, item grids, graphs and protein node.
69
+
70
+ - `@motionscript/audio`: documents that the host supplies the baked envelope and states its JSON form. `AudioEnvelope.magnitude` and `speaker` are typed `ArrayLike<number>`, which accepts the plain arrays a document stores as well as typed arrays. The package description no longer claims the meter responds to a signal.
71
+ - `@motionscript/grids`: the grids' descriptors name `children: "freeform"`, the one answer that is true of slot-placed children, in place of `flow` and `grid`.
72
+ - `@motionscript/molecule`: `Protein` refuses children, as its descriptor says, and declares `quality` non-animatable.
73
+ - `@motionscript/plot`: new `curveEquationIssues`, `surfaceEquationIssues` and `equationIssues` return a `ValidationIssue` for each equation whose expression does not compile and so is not drawn, which `validateDocument` cannot see. The `Canvas3D` scene props that `Graph3D` inherits and ignores are documented in its docs and a README.
74
+
75
+ ## 0.1.0-alpha.3
76
+
77
+ ## 0.1.0-alpha.2
78
+
79
+ ## 0.1.0-alpha.1
80
+
81
+ ### Minor Changes
82
+
83
+ - 59cecba: Build on `@motionscript/sdk` instead of `@motionscript/core`. The peer dependency is now `@motionscript/sdk`, every import goes through it (and `@motionscript/sdk/component` for the component machinery), and the browser build leaves `@motionscript/sdk` an import, so an import map names it once. A component copied with `ms add` imports the SDK too, and its registry item depends on `@motionscript/sdk` rather than `@motionscript/core`. `@motionscript/charts/kit` re-exports `@motionscript/sdk/component` where it re-exported `@motionscript/core/component`.
84
+
85
+ ## 0.1.0-alpha.0
86
+
87
+ Initial release.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,49 @@
1
+ Motionscript
2
+ Copyright 2026 Motionscript LLC
3
+
4
+ This product includes the third-party code below, each part under the MIT
5
+ License reproduced at the end of this file.
6
+
7
+ - packages/renderer/crates/renderer/src/shaders/prim.wgsl (`fn_hash2`):
8
+ "Hash without Sine" by David Hoskins (https://www.shadertoy.com/view/4djSRW).
9
+ Copyright (c) 2014 David Hoskins.
10
+
11
+ - packages/renderer/crates/renderer/src/shaders/prim.wgsl (`simplex_noise`): "Noise - simplex - 2D" by Inigo Quilez
12
+ (https://www.shadertoy.com/view/Msf3WH). Copyright (c) 2013 Inigo Quilez.
13
+
14
+ - packages/renderer/crates/render3d (in @motionscript/renderer's WebAssembly):
15
+ its shaders (src/shaders/mesh.wgsl) port three.js r185's mesh programs and
16
+ src/geometry.rs its primitive generators (https://threejs.org).
17
+ Copyright (c) 2010-2026 three.js authors.
18
+
19
+ @motionscript/renderer's WebAssembly (dist/ms_renderer_bg.wasm) compiles in
20
+ Rust crates under MIT, Apache-2.0, Zlib and Unicode-3.0 terms (wgpu, naga,
21
+ harfrust, read-fonts, kurbo, wasm-bindgen and others); their notices are in
22
+ packages/renderer/THIRD_PARTY_NOTICES.txt.
23
+
24
+ MP3 export loads @mediabunny/mp3-encoder (MPL-2.0), a WebAssembly build of
25
+ the LAME MP3 encoder (LGPL, https://lame.sourceforge.io), on first use.
26
+
27
+ The browser builds under dist/browser/ bundle each package's npm dependencies;
28
+ dist/browser/THIRD_PARTY_LICENSES.txt in each package lists them with their
29
+ licences.
30
+
31
+ MIT License
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy
34
+ of this software and associated documentation files (the "Software"), to deal
35
+ in the Software without restriction, including without limitation the rights
36
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
+ copies of the Software, and to permit persons to whom the Software is
38
+ furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in all
41
+ copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # Temporary Holding Version
1
+ # @motionscript/grids
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Grid layouts for [Motion Script](https://motionscript.dev): a node that places
4
+ its children in a rectangular, radial, path or spherical arrangement, with
5
+ staggered reveals, waves, focus, reordering and morphs between arrangements.
6
+ Written against [`@motionscript/sdk`](https://github.com/motionscript-dev/motionscript/tree/main/packages/sdk), a peer dependency.
7
+
8
+ ```ts
9
+ import { NODES } from '@motionscript/grids';
10
+
11
+ export const nodes = NODES; // [RectangularGrid, RadialGrid, PathGrid, SphereGrid]
12
+ ```
13
+
14
+ Importing registers nothing (see [`packages/components/CLAUDE.md`](https://github.com/motionscript-dev/motionscript/blob/main/packages/components/CLAUDE.md)). Each grid
15
+ is a component (`component2d`); `ItemGrid`, the module the four are built from,
16
+ is no node type and is not in `NODES`.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @motionscript/grids @motionscript/sdk
22
+ ```
23
+
24
+ ## Exports
25
+
26
+ | Path | Source | What |
27
+ |---|---|---|
28
+ | `@motionscript/grids` | `src/index.ts` | the four grids, `PATH_GRID_SHAPES`, `NODES`, and `src/engine.ts` |
29
+ | `@motionscript/grids/kit` | `src/engine.ts` | the `ItemGrid` module and what it uses (`src/kit/`): slot functions per arrangement, stagger, reveal and wave styles, order helpers, seeded random |
30
+
31
+ ## Nodes
32
+
33
+ The items are the grid's children, in layer order; a group is one item. A grid is
34
+ `hug` by default, except `pathGrid` (640 x 400, fixed).
35
+
36
+ | Key | Arrangement props | Own commands |
37
+ |---|---|---|
38
+ | `rectangularGrid` | `columns`, `fillDirection`, `cellMode` (`fit`/`fixed`/`fill`), `cellWidth/Height`, `columnGap`, `rowGap`, `lastLineAlign`, `rowOffset`, `columnOffset` | `columnsTo`, `gapTo`, `cellSizeTo`, `focusRow`, `focusColumn` |
39
+ | `radialGrid` | `radius`, `startAngle`, `sweep`, `direction`, `rotateItems`, `spinSpeed` | `spin`, `turnTo`, `radiusTo`, `sweepTo` |
40
+ | `pathGrid` | `shape` (a template or `custom`), `path`, `pathNode`, `spacing`, `spacingDistance`, `offset`, `flowSpeed`, `trimStart/End`, `alignToPath` | `flow`, `trimTo`, `setPath` |
41
+ | `sphereGrid` | `radius`, `yaw`, `pitch`, `roll`, `facing`, `focalLength`, `depthFade`, `cullBackfaces`, `spinSpeed` | `spin`, `orientTo`, `turnTo`, `radiusTo`, `focalLengthTo` |
42
+
43
+ Every grid also has `order`, `spread` and `arrangeLike`, and these commands from
44
+ the `ItemGrid` module: `reveal`, `conceal`, `wave`, `focus`, `unfocus`, `spreadTo`, `shuffle`,
45
+ `swap`, `reorder`, `morphInto`. Per-item commands take `staggerOrder` (`index`,
46
+ `reverse`, `random`, `centerOut`, `edgesIn`, `row`, `column`, `angle`, `path`,
47
+ `depth`) and `stagger` (0 to 0.95); `shuffle`, `swap`, `reorder`, `morphInto`,
48
+ `columnsTo` and `setPath` are *transitions*.
49
+
50
+ ## Rules worth knowing
51
+
52
+ - **A slot is a parent transform.** Each item is laid out where its slot is, and the
53
+ rest of the slot (turn, scale, tilt, depth, fade) rides on its layout placement,
54
+ applied about the item's centre before its own transform, so an item's own `x`,
55
+ `y`, `rotation` and its commands keep working relative to the slot. A grid whose
56
+ arrangement has depth (the sphere) opens a camera of its own with its render's
57
+ `ctx.space`, unless it already sits in a space (`ctx.inSpace`).
58
+ - **`flowOps` sizes; it never places.** The grid's size is what its slots come to
59
+ (`extentOf`), seen through the camera it has that frame, so a grid of grids is a
60
+ grid of items.
61
+ - **`revealState`, `waveState`, `focusState` and `transition` are written by
62
+ commands, not authored.** They are rewritten every frame as a pure function of
63
+ time and set to `null` at the command's end, so a seek reproduces them. `reveal`
64
+ hides every item at its start (place it where the grid enters); `conceal` leaves
65
+ them hidden until a later `reveal`.
66
+ - **The stagger lives inside the duration**: a command lasts its row's `duration`.
67
+ - **An arrangement is data.** A transition keeps the arrangement it leaves as a
68
+ `GridSnapshot` and re-evaluates it each frame, so a morph can start from any
69
+ arrangement, including another grid's. `morphInto` writes `arrangeLike` (a node
70
+ reference: the grid reads a view of the one it names, and where it stands) and keeps
71
+ following that grid; a grid that cannot find `arrangeLike` or `pathNode` draws its
72
+ own arrangement. Another grid's arrangement is worked out from its state by the
73
+ `Arranger` it was defined with, so a grid is borrowable once `ItemGrid.define` has
74
+ seen it.
75
+ - **A command reads the grid as its predecessors leave it.** Ranks for a stagger, the
76
+ rows `focusRow` picks and the cell `cellSizeTo` starts from are worked out afresh from
77
+ the command's state, its children's sizes and the grid's box, against the clock the
78
+ timeline builds commands at (time 0).
79
+ - **`order[k]` is the child in slot `k`**, and `normalizeOrder` repairs any order
80
+ (missing, repeated or out-of-range entries), so a stale order never throws.
81
+ - **The kit stays an import.** A copy of `rectangular-grid` (or `radial-grid`,
82
+ `path-grid`, `sphere-grid`) takes one grid's two files and rewrites their kit
83
+ imports to `@motionscript/grids/kit` (`registry.json`): a second copy of
84
+ `ItemGrid` would keep a second register of grids, and a morph would not find the
85
+ grids it should.
86
+
87
+ ## A grid of your own
88
+
89
+ ```ts
90
+ import { component2d, Types, type Values } from '@motionscript/sdk';
91
+ import { ItemGrid, type Arrangement } from '@motionscript/grids/kit';
92
+
93
+ const own = { radius: Types.number(120) };
94
+ const arranger: ItemGrid.Arranger<Values<typeof own>> = {
95
+ arrangement: (s): Arrangement => ({ kind: 'radial', radius: s.radius, startAngle: 0, sweep: 180, direction: 'clockwise', rotateItems: false, spinSpeed: 0 }),
96
+ };
97
+
98
+ export const ArcGrid = ItemGrid.define(component2d({
99
+ key: 'arcGrid',
100
+ state: { ...ItemGrid.state, ...own },
101
+ defaults: ItemGrid.defaults,
102
+ commands: { ...ItemGrid.commands },
103
+ ...ItemGrid.fields(arranger),
104
+ }), arranger);
105
+ ```
106
+
107
+ `define` registers the arranger, which is what another grid and a host know it by:
108
+ `ItemGrid.isGrid(node)` tells a grid from any other node.
109
+
110
+ ## Development
111
+
112
+ ```bash
113
+ pnpm --filter @motionscript/grids build
114
+ pnpm --filter @motionscript/grids test
115
+ ```
116
+
117
+ Tests are in `src/tests/` (`grid.test.ts`, `slots.test.ts`, `descriptors.test.ts`);
118
+ `harness.ts` builds, seeks and renders a document.
@@ -0,0 +1,2 @@
1
+ var Dt=Object.defineProperty;var Yt=(t,e)=>{for(var n in e)Dt(t,n,{get:e[n],enumerable:!0})};import{pathOps as st}from"@motionscript/sdk";function y(t,e,n){return{x:t,y:e,depth:0,rotation:0,rotationX:0,rotationY:0,scale:1,opacity:1,meta:n}}function rt(t,e,n){if(n<=0)return t;if(n>=1)return e;let o=(r,a)=>r+(a-r)*n;return{x:o(t.x,e.x),y:o(t.y,e.y),depth:o(t.depth,e.depth),rotation:o(t.rotation,e.rotation),rotationX:o(t.rotationX,e.rotationX),rotationY:o(t.rotationY,e.rotationY),scale:o(t.scale,e.scale),opacity:o(t.opacity,e.opacity),meta:n<.5?t.meta:e.meta}}function Z(t,e){return e===1?t:{...t,x:t.x*e,y:t.y*e,depth:t.depth*e}}function at(t){let e=0,n=0;for(let o of t)o.width>e&&(e=o.width),o.height>n&&(n=o.height);return{width:e,height:n}}var be=["distribute","fixed"],P=new Map,Bt=32;function Xt(t){let e=P.get(t);if(e)return e;let n=st.contours(t),o={sampler:st.sampler(t),closed:n.length===1&&n[0].closed};return P.size>=Bt&&P.delete(P.keys().next().value),P.set(t,o),o}function ct(t,e){let{count:n}=e;if(n===0)return[];let{sampler:o,closed:r}=Xt(t.path),a=o.length,s=_(Math.min(t.trimStart,t.trimEnd)),c=_(Math.max(t.trimStart,t.trimEnd)),i=s*a,u=(c-s)*a,h=r&&s===0&&c===1,f=t.offset+t.flowSpeed*e.time,l=t.placement,m=l.rotation*Math.PI/180,k=Math.cos(m),A=Math.sin(m),g=[];for(let x=0;x<n;x++){let d;t.spacing==="fixed"&&u>0?d=f+x*t.spacingDistance/u:h?d=f+x/n:d=f+(n===1?.5:x/(n-1));let E=!0;h?d=d-Math.floor(d):(d<-1e-9||d>1+1e-9)&&(E=!1);let M=o.frameAt(i+_(d)*u);if(!M){let X=y(0,0,{kind:"path",t:_(d)});X.opacity=0,g.push(X);continue}let T=l.flipY?-1:1,R=(M.x-l.originX)*l.scale,G=(M.y-l.originY)*l.scale*T,O=y(l.x+R*k+G*A,l.y-R*A+G*k,{kind:"path",t:_(d)});t.alignToPath&&(O.rotation=-Math.atan2(M.ty*T,M.tx)*180/Math.PI+l.rotation),E||(O.opacity=0),g.push(O)}return g}function _(t){return t<0?0:t>1?1:t}var Re=["clockwise","counterclockwise"];function it(t,e,n){let o=t.sweep,r=Math.min(1,Math.abs(o)/360)**8,a=e<=1?0:o/(e-1+r),s=t.direction==="counterclockwise"?-1:1,c=t.startAngle+t.spinSpeed*n,i=[];for(let u=0;u<e;u++)i.push(c+s*u*a);return i}function ut(t,e){let n=it(t,e.count,e.time),o=n[0]??0;return n.map(r=>{let a=r*Math.PI/180,s=y(t.radius*Math.sin(a),t.radius*Math.cos(a),{kind:"radial",angle:Math.abs(r-o)});return t.rotateItems&&(s.rotation=r),s})}function Ge(t,e,n){let o=it({...t,spinSpeed:0},e,0)[n]??t.startAngle;return-Ft(o)}function Ft(t){let e=(t%360+360)%360;return e>180?e-360:e}var ve=["row","column"],Ce=["fit","fixed","fill"],Ne=["start","center","end"];function ft(t,e){let n=Math.max(1,Math.round(t.columns)),o=Math.max(1,Math.ceil(e/n));return t.fillDirection==="column"?{rows:o,columns:Math.max(1,Math.ceil(e/o))}:{rows:o,columns:n}}function Ht(t,e,n,o){let{rows:r,columns:a}=ft(t,e);switch(t.cellMode){case"fixed":return{width:Math.max(0,t.cellWidth),height:Math.max(0,t.cellHeight)};case"fill":return{width:Math.max(0,(o.width-t.columnGap*(a-1))/a),height:Math.max(0,(o.height-t.rowGap*(r-1))/r)};default:return at(n)}}function lt(t,e){let{count:n}=e;if(n===0)return[];let{rows:o,columns:r}=ft(t,n),a=t.fillDirection==="column",s=a?r:o,c=a?o:r,i=Ht(t,n,e.sizes,e.box),u=i.width+t.columnGap,h=i.height+t.rowGap,f=s-1,l=n-f*c,m=c-l,k=t.lastLineAlign==="center"?m/2:t.lastLineAlign==="end"?m:0,A=t.rowOffset*u,g=t.columnOffset*h,x=[];for(let d=0;d<n;d++){let E=Math.floor(d/c),M=d%c;E===f&&(M+=k);let T=a?M:E,R=a?E:M,G=Math.round(T),O=Math.round(R),X=(R-(r-1)/2)*u+(G%2===1?A:0)-(o>1?A/2:0),zt=((o-1)/2-T)*h-(O%2===1?g:0)+(r>1?g/2:0);x.push(y(X,zt,{kind:"rectangular",row:G,column:O}))}return x}var Ye=["outward","billboard"],Be=["x","y","z"],Wt=Math.PI*(3-Math.sqrt(5)),w=180/Math.PI;function ht(t,e){if(e<=1)return[0,0,1];let n=1-2*(t+.5)/e,o=Math.sqrt(Math.max(0,1-n*n)),r=t*Wt;return[Math.cos(r)*o,n,Math.sin(r)*o]}function qt(t,e,n,o){let[r,a,s]=t,c=e/w,i=n/w,u=o/w,h=r*Math.cos(c)+s*Math.sin(c),f=-r*Math.sin(c)+s*Math.cos(c),l=a*Math.cos(i)-f*Math.sin(i),m=a*Math.sin(i)+f*Math.cos(i);return[h*Math.cos(u)+l*Math.sin(u),-h*Math.sin(u)+l*Math.cos(u),m]}function pt(t,e){let{count:n}=e,o=t.radius,r=t.yaw+t.spinSpeed*e.time,a=t.facing==="outward",s=[];for(let c=0;c<n;c++){let i=ht(c,n),[u,h,f]=qt(i,r,t.pitch,t.roll),l=y(u*o,h*o,{kind:"sphere",lat:Math.asin(Math.max(-1,Math.min(1,i[1])))*w,lon:Math.atan2(i[2],i[0])*w,depth:f});l.depth=f*o,a&&(l.rotationY=Math.asin(Math.max(-1,Math.min(1,u)))*w,l.rotationX=Math.atan2(h,f)*w),l.opacity=1-t.depthFade*(1-(f+1)/2),a&&t.cullBackfaces&&Vt(l,[u,h,f],t.focalLength)&&(l.opacity=0),s.push(l)}return s}function Vt(t,e,n){return n<=0?e[2]<0:e[0]*-t.x+e[1]*-t.y+e[2]*(n-t.depth)<0}function Xe(t,e){let[n,o,r]=ht(e,t);return{yaw:-Math.atan2(n,r)*w,pitch:Math.atan2(o,Math.hypot(n,r))*w}}var He=["circle","square","star","heart","infinity","wave","spiral","arc","line"];var v=new Map,$t=64;function We(t,e){let n=`${t}:${Math.round(e.width*100)}:${Math.round(e.height*100)}`,o=v.get(n);if(o)return o;let r=Kt(t,e);return v.size>=$t&&v.delete(v.keys().next().value),v.set(n,r),r}function Kt(t,e){let n=e.width>0?e.width:400,o=e.height>0?e.height:400,r=n/2,a=o/2;switch(t){case"square":return F([[-r,a],[r,a],[r,-a],[-r,-a]]);case"star":{let s=[];for(let c=0;c<10;c++){let i=c*Math.PI/5,u=c%2===0?1:.45;s.push([Math.sin(i)*r*u,Math.cos(i)*a*u])}return F(s)}case"heart":return F(C(96,s=>{let c=s*2*Math.PI,i=16*Math.sin(c)**3,u=13*Math.cos(c)-5*Math.cos(2*c)-2*Math.cos(3*c)-Math.cos(4*c);return[i/17*r,(u+2.5)/15.5*a]}).slice(0,-1));case"infinity":return F(C(96,s=>{let c=s*2*Math.PI,i=1+Math.sin(c)**2;return[Math.cos(c)/i*r,Math.sin(c)*Math.cos(c)/i*a*2]}).slice(0,-1));case"wave":return H(C(96,s=>[(-1+2*s)*r,Math.sin(s*4*Math.PI)*a*.6]));case"spiral":return H(C(160,s=>{let c=s*3*2*Math.PI,i=.08+.92*s;return[Math.sin(c)*r*i,Math.cos(c)*a*i]}));case"arc":return H(C(64,s=>{let c=-Math.PI/2+s*Math.PI;return[Math.sin(c)*r,-a+Math.cos(c)*o]}));case"line":return[{type:"M",x:-r,y:0},{type:"L",x:r,y:0}];default:return Zt(r,a)}}function Zt(t,e){let n=.5522847498;return[{type:"M",x:0,y:e},{type:"C",x1:n*t,y1:e,x2:t,y2:n*e,x:t,y:0},{type:"C",x1:t,y1:-n*e,x2:n*t,y2:-e,x:0,y:-e},{type:"C",x1:-n*t,y1:-e,x2:-t,y2:-n*e,x:-t,y:0},{type:"C",x1:-t,y1:n*e,x2:-n*t,y2:e,x:0,y:e},{type:"Z"}]}function C(t,e){let n=[];for(let o=0;o<=t;o++)n.push(e(o/t));return n}function H(t){return t.map(([e,n],o)=>o===0?{type:"M",x:e,y:n}:{type:"L",x:e,y:n})}function F(t){return[...H(t),{type:"Z"}]}function j(t,e){switch(t.kind){case"rectangular":return lt(t,e);case"radial":return ut(t,e);case"path":return ct(t,e);case"sphere":return pt(t,e)}}function J(t){return t.kind==="sphere"?Math.max(1,t.focalLength):0}function jt(t){let e=Math.floor(t)>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function W(t,e){let n=[...t],o=jt(e);for(let r=n.length-1;r>0;r--){let a=Math.floor(o()*(r+1));[n[r],n[a]]=[n[a],n[r]]}return n}function dt(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return e>>>0}var mt=["index","reverse","random","centerOut","edgesIn","row","column","angle","path","depth"],Jt=.95;function gt(t,e,n){let o=e.length,r=Qt(t,e,n),a=1/0,s=-1/0;for(let i of r)i<a&&(a=i),i>s&&(s=i);let c=s-a;return c>1e-9?r.map(i=>(i-a)/c):new Array(o).fill(0)}function N(t,e,n){let o=Math.max(0,Math.min(Jt,n)),r=o===0?e:(e-t*o)/(1-o);return r<0?0:r>1?1:r}function Qt(t,e,n){switch(t){case"reverse":return e.map((o,r)=>-r);case"random":{let o=W(e.map((a,s)=>s),n),r=new Array(e.length);return o.forEach((a,s)=>{r[a]=s}),r}case"centerOut":return e.map(o=>Math.round(Math.hypot(o.x,o.y,o.depth)*1e3)/1e3);case"edgesIn":return e.map(o=>-Math.round(Math.hypot(o.x,o.y,o.depth)*1e3)/1e3);case"row":return e.map(o=>o.meta.kind==="rectangular"?o.meta.row:-Math.round(o.y));case"column":return e.map(o=>o.meta.kind==="rectangular"?o.meta.column:Math.round(o.x));case"angle":return e.map((o,r)=>o.meta.kind==="radial"?o.meta.angle:o.meta.kind==="rectangular"||o.meta.kind==="sphere"?Ut(o):r);case"path":return e.map((o,r)=>o.meta.kind==="path"?o.meta.t:r);case"depth":return e.map((o,r)=>o.meta.kind==="sphere"?-o.meta.depth:r);default:return e.map((o,r)=>r)}}function Ut(t){let e=Math.atan2(t.x,t.y)*180/Math.PI;return e<0?e+360:e}var Q=["scale","fade","center","rise","flip","spin"],xt=["scale","lift","fade","spin"];function Mt(t,e,n,o,r,a){o&&te(t,o.style,o.values[e]??1,n),r&&ee(t,r,r.values[e]??0,n),a&&ne(t,a,a.values[e]??0)}function te(t,e,n,o){if(n===1)return;let r=q(n);switch(e){case"fade":t.opacity*=r;break;case"center":t.x*=n,t.y*=n,t.depth*=n,t.opacity*=q(n*4);break;case"rise":t.y-=(1-n)*Math.max(40,o.height),t.opacity*=r;break;case"flip":t.rotationX+=(1-n)*90;break;case"spin":t.rotation-=(1-n)*180,t.scale*=Math.max(0,n);break;default:t.scale*=Math.max(0,n)}}function ee(t,e,n,o){if(n!==0)switch(e.style){case"lift":t.y+=e.amount*n*Math.max(40,o.height);break;case"fade":t.opacity*=q(1-e.amount*n);break;case"spin":t.rotation+=e.amount*n*360;break;default:t.scale*=1+e.amount*n}}function ne(t,e,n){if(n!==0){if(n>0){t.scale*=1+e.grow*n;return}t.opacity*=q(1-e.dim*-n),t.scale*=Math.max(0,1+e.grow*.5*n)}}function q(t){return t<0?0:t>1?1:t}function I(t,e){let n=[],o=new Array(e).fill(!1);for(let r of t??[]){let a=Math.round(r);a>=0&&a<e&&!o[a]&&(o[a]=!0,n.push(a))}for(let r=0;r<e;r++)o[r]||n.push(r);return n}function U(t){let e=new Array(t.length);return t.forEach((n,o)=>{e[n]=o}),e}function yt(t){return Array.isArray(t)?t.map(Number).filter(Number.isFinite):typeof t!="string"?[]:t.split(/[\s,]+/).filter(e=>e!=="").map(Number).filter(Number.isFinite)}var Nt={};Yt(Nt,{ITEM_GRID_TYPES:()=>$,TRANSITION_STAGGER:()=>b,commands:()=>pe,contentBox:()=>L,contentBoxOf:()=>Lt,defaults:()=>se,define:()=>ce,fields:()=>ue,focusOn:()=>Rt,hinted:()=>ae,isGrid:()=>ie,itemSlots:()=>Tt,layout:()=>Ot,measure:()=>Et,nodeRef:()=>kt,nodeRefArg:()=>At,ranks:()=>Y,render:()=>bt,staggerArgs:()=>S,state:()=>It,transitionTo:()=>z});import{commandsFor as oe,easeIn as re,easeInOut as D,easeOut as wt,flowOps as tt,insetsOps as St,Types as p}from"@motionscript/sdk";var $=["rectangularGrid","radialGrid","pathGrid","sphereGrid"],b=.3;function kt(t){let e={kind:"nodeRef",nodeTypes:t,animatable:!1};return p.custom("",e)}function S(t){return{staggerOrder:p.oneOf(mt,{default:"index"}),stagger:p.number(t,{min:0,max:.95,step:.05})}}function ae(t,e={}){let n={...e,default:t};return p.custom(void 0,n)}function At(t){let e={kind:"nodeRef",nodeTypes:t};return p.custom(void 0,e)}var It={order:p.custom([],{kind:"order",animatable:!1}),spread:p.number(1,{min:0,max:3,step:.05}),arrangeLike:kt($),revealState:p.custom(void 0,{kind:"state",animatable:!1}),waveState:p.custom(void 0,{kind:"state",animatable:!1}),focusState:p.custom(void 0,{kind:"state",animatable:!1}),transition:p.custom(void 0,{kind:"state",animatable:!1}),transitionSource:p.custom("",{kind:"nodeRef",private:!0})},se={width:"hug",height:"hug"},B=new Map;function ce(t,e){return B.set(t.key,{component:t,arranger:e}),t}function ie(t){for(let{component:e}of B.values())if(t instanceof e.node)return!0;return!1}function ue(t){return{measure:(e,n,o)=>Et(e,n,o,t),layout:(e,n,o)=>Ot(e,n,o,t),render:(e,n)=>bt(e,n,t)}}var fe={width:0,height:0},le={x:0,y:0},V=new WeakMap;function Et(t,e,n,o){let r={maxWidth:t.max.width,maxHeight:t.max.height},a=e.padding;if(n.length===0)return V.delete(e),tt.size(e,r,a,fe);let s=tt.contentBox(e,r,a),c=_t(n,s,e,o);V.set(e,{space:s,sizes:c});let i={state:e,arranger:o,children:n,isSelf:Gt(n)},u=ot(i,c.length,c,s,t.time.total);return tt.size(e,r,a,we(u.slots,c,vt(e,u.arrangement)))}function Ot(t,e,n,o){let r=V.get(e);if(V.delete(e),n.length===0)return[];let a=St.insetBounds(t.width,t.height,e.padding),s=r&&r.sizes.length===n.length&&ke(r.space,a)?r.sizes:_t(n,a,e,o);return xe({state:e,arranger:o,children:n,isSelf:Gt(n)},s,a,t.time.total).map((i,u)=>ye(a,i,s[u]))}function bt(t,e,n){let o=e.children.length===0?0:vt(e,ge({state:e,arranger:n,children:[],isSelf:()=>!1},L(t.size,e.padding)));o>0&&!t.inSpace?t.space(Me(o)):t.children()}function Lt(t){let e=t.layoutBounds;return L({width:e.width,height:e.height},t.effectivePadding())}function Tt(t,e,n){let o=Pt(t,e,n),r=n.map(a=>a.size);return ot(o,n.length,r,L(t.node.size,e.padding),0).slots}function Y(t,e,n,o){return gt(o??"index",Tt(t,e,n),dt(t.node.id))}function z(t,e,n,o,r=b){let a=me(t,e,n),s=t.easing??D("cubic"),c=Y(t,e,n,t.args.staggerOrder),i=t.args.stagger??r;return t.animate(u=>{if(u>=1)return{...o,transition:null,transitionSource:""};let h=c.map(f=>s(N(f,u,i)));return{...o,transition:{from:a,mix:h},transitionSource:a.source}},{eased:!1})}function Rt(t,e,n,o,r,a){let s=e.focusState,c=Array.from({length:o},(u,h)=>n(h)?1:-1),i=t.easing??D("cubic");return t.animate(u=>{let h=i(u);return{focusState:{dim:et(s?.dim??r,r,h),grow:et(s?.grow??a,a,h),values:c.map((f,l)=>et(s?.values[l]??0,f,h))}}},{eased:!1})}var he={...It,padding:p.insets},pe=oe(he,{reveal:{args:{style:p.oneOf(Q,{default:"scale"}),...S(.5)},run:(t,e,n)=>{let o=t.args.style??"scale",r=t.easing??(o==="scale"||o==="flip"?wt("back"):wt("cubic")),a=Y(t,e,n,t.args.staggerOrder),s=t.args.stagger??.5;return t.animate(c=>c>=1?{revealState:null}:{revealState:{style:o,values:a.map(i=>r(N(i,c,s)))}},{eased:!1})}},conceal:{args:{style:p.oneOf(Q,{default:"scale"}),...S(.5)},run:(t,e,n)=>{let o=t.args.style??"scale",r=t.easing??(o==="scale"||o==="flip"?re("back"):D("cubic")),a=Y(t,e,n,t.args.staggerOrder),s=t.args.stagger??.5,c=e.revealState?.values;return t.animate(i=>({revealState:{style:o,values:a.map((u,h)=>(c?.[h]??1)*(1-r(N(u,i,s))))}}),{eased:!1})}},wave:{args:{style:p.oneOf(xt,{default:"scale"}),amount:p.number(.3,{min:0,max:2,step:.05}),...S(.7)},run:(t,e,n)=>{let o=t.args.style??"scale",r=t.args.amount??.3,a=t.easing??D("sine"),s=Y(t,e,n,t.args.staggerOrder),c=t.args.stagger??.7;return t.animate(i=>i>=1?{waveState:null}:{waveState:{style:o,amount:r,values:s.map(u=>Math.sin(Math.PI*a(N(u,i,c))))}},{eased:!1})}},focus:{args:{item:p.number(0,{min:0,step:1}),dim:p.number(.7,{min:0,max:1,step:.05}),grow:p.number(.15,{min:0,max:1,step:.05})},run:(t,e,n)=>{let o=Math.round(t.args.item??0);return Rt(t,e,r=>r===o,n.length,t.args.dim??.7,t.args.grow??.15)}},unfocus:(t,e)=>{let n=e.focusState,o=t.easing??D("cubic");return t.animate(r=>{if(r>=1||!n)return{focusState:null};let a=1-o(r);return{focusState:{...n,values:n.values.map(s=>s*a)}}},{eased:!1})},spreadTo:{args:{spread:p.number(1,{min:0,max:3,step:.05})},run:t=>t.tween({spread:t.args.spread??1})},shuffle:{args:{seed:p.number(1,{min:0,step:1}),...S(b)},run:(t,e,n)=>{let o=I(e.order,n.length),r=W(o,t.args.seed??1);return r.length>1&&r.every((a,s)=>a===o[s])&&(r=[...r.slice(1),r[0]]),z(t,e,n,{order:r})}},swap:{args:{first:p.number(0,{min:0,step:1}),second:p.number(1,{min:0,step:1}),...S(0)},run:(t,e,n)=>{let o=I(e.order,n.length),r=o.indexOf(Math.round(t.args.first??0)),a=o.indexOf(Math.round(t.args.second??1));return r>=0&&a>=0&&([o[r],o[a]]=[o[a],o[r]]),z(t,e,n,{order:o},0)}},reorder:{args:{order:p.text(""),...S(b)},run:(t,e,n)=>{let o=I(yt(t.args.order),n.length);return z(t,e,n,{order:o})}},morphInto:{args:{target:At($),...S(b)},run:(t,e,n)=>z(t,e,n,{arrangeLike:t.args.target??""})}});function de(t){let e=B.get(t);if(!e)throw new Error(`"${t}" is no grid: pass its component through ItemGrid.define.`);return e.arranger}function nt(t,e){if(!t)return null;let n=B.get(t.key);return!n||e.isSelf(t)?null:{view:t,arranger:n.arranger}}function Gt(t){return e=>t.length===0?!1:e.state.children?.[0]===t[0]}function Pt(t,e,n){return{state:e,arranger:de(t.node.key),children:n,isSelf:o=>o.id===t.node.id}}function me(t,e,n){let o=Pt(t,e,n),r=nt(e.arrangeLike,o);return{arrangement:r?r.arranger.arrangement(r.view.state,K(r.view)):o.arranger.arrangement(e,L(t.node.size,e.padding)),source:r?.view.id??"",order:I(e.order,n.length),spread:e.spread}}function _t(t,e,n,o){let r=t.map(s=>s.measure(e)),a=o.itemSpace?o.itemSpace(n,t.length,e):e;return a===e?r:t.map(s=>s.measure(a))}function ge(t,e){let n=nt(t.state.arrangeLike,t);return n?n.arranger.arrangement(n.view.state,K(n.view)):t.arranger.arrangement(t.state,e)}function ot(t,e,n,o,r){let a=t.state,s=nt(a.arrangeLike,t),c=s?K(s.view):o,i=s?s.arranger.arrangement(s.view.state,c):t.arranger.arrangement(a,o),u=j(i,{count:e,sizes:n,box:c,time:r});return s&&(u=Ct(s.view.frame,u)),{slots:U(I(a.order,e)).map(f=>Z(u[f],a.spread)),arrangement:i}}function xe(t,e,n,o){let r=t.state,a=e.length,s=ot(t,a,e,n,o).slots,c=r.transition;if(c){let{from:f}=c,l=f.source?r.transitionSource:null,m=l&&l.id===f.source&&B.has(l.key)?l:null,k=m!==null&&t.isSelf(m),A=m&&!k?K(m):n,g=j(f.arrangement,{count:a,sizes:e,box:A,time:o});m&&!k&&(g=Ct(m.frame,g));let x=U(I(f.order,a));for(let d=0;d<a;d++)s[d]=rt(Z(g[x[d]],f.spread),s[d],c.mix[d]??1)}let i=r.revealState,u=r.waveState,h=r.focusState;if(i||u||h)for(let f=0;f<a;f++)Mt(s[f],f,e[f],i,u,h);return s}function vt(t,e){return J(e)||(t.transition?J(t.transition.from.arrangement):0)}function Me(t){return{perspective:t,orbit:0,elevation:0,dolly:0,lookAt:le,zoom:1,heading:0,viewportX:0,viewportY:0}}function ye(t,e,n){let o={x:t.x+e.x,y:e.y-t.y,width:n.width,height:n.height};return e.rotation===0&&e.scale===1&&e.rotationX===0&&e.rotationY===0&&e.depth===0&&e.opacity===1?o:{...o,rotation:e.rotation,scale:e.scale,rotationX:e.rotationX,rotationY:e.rotationY,depth:e.depth,opacity:e.opacity}}function Ct(t,e){return e.map(n=>{let o=Se(n.x*t.scale,n.y*t.scale,t.rotation);return{...n,x:t.x+o.x,y:t.y+o.y,depth:n.depth*t.scale,rotation:n.rotation+t.rotation,scale:n.scale*t.scale}})}function K(t){return L(t.size,t.state.padding)}function L(t,e){let n=St.insetBounds(t.width,t.height,e);return{width:n.width,height:n.height}}function we(t,e,n){let o=0,r=0;for(let a=0;a<t.length;a++){let s=t[a],c=e[a],i=s.rotation*Math.PI/180,u=Math.abs(Math.cos(i)),h=Math.abs(Math.sin(i)),f=n>0&&n-s.depth>1?n/(n-s.depth):1,l=(c.width*u+c.height*h)/2*s.scale*f,m=(c.width*h+c.height*u)/2*s.scale*f;o=Math.max(o,Math.abs(s.x)*f+l),r=Math.max(r,Math.abs(s.y)*f+m)}return{width:o*2,height:r*2}}function Se(t,e,n){if(n===0)return{x:t,y:e};let o=n*Math.PI/180,r=Math.cos(o),a=Math.sin(o);return{x:t*r+e*a,y:-t*a+e*r}}function ke(t,e){return Math.abs(t.width-e.width)<1e-6&&Math.abs(t.height-e.height)<1e-6}function et(t,e,n){return t+(e-t)*n}import{findNode2D as An,frameIn as In}from"@motionscript/sdk";export{y as a,rt as b,Z as c,at as d,be as e,ct as f,Re as g,it as h,ut as i,Ge as j,Ft as k,ve as l,Ce as m,Ne as n,ft as o,Ht as p,lt as q,Ye as r,Be as s,ht as t,qt as u,pt as v,Xe as w,He as x,We as y,j as z,J as A,jt as B,W as C,dt as D,mt as E,gt as F,N as G,Q as H,xt as I,Mt as J,I as K,U as L,yt as M,$ as N,b as O,S as P,Lt as Q,Nt as R,An as S,In as T};
2
+ //# sourceMappingURL=chunk-TYNFMZ3D.js.map