@motionscript/grids 0.0.0-stage → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/LICENSE +201 -0
- package/NOTICE +48 -0
- package/README.md +86 -3
- package/dist/browser/chunks/chunk-XDUDKWM7.js +2 -0
- package/dist/browser/chunks/chunk-XDUDKWM7.js.map +7 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/kit.js +2 -0
- package/dist/browser/kit.js.map +7 -0
- package/dist/browser/manifest.json +13 -0
- package/dist/engine.d.ts +13 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +13 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kit/index.d.ts +7 -0
- package/dist/kit/index.d.ts.map +1 -0
- package/dist/kit/index.js +7 -0
- package/dist/kit/index.js.map +1 -0
- package/dist/kit/item-effects.d.ts +37 -0
- package/dist/kit/item-effects.d.ts.map +1 -0
- package/dist/kit/item-effects.js +76 -0
- package/dist/kit/item-effects.js.map +1 -0
- package/dist/kit/item-grid.d.ts +235 -0
- package/dist/kit/item-grid.d.ts.map +1 -0
- package/dist/kit/item-grid.js +519 -0
- package/dist/kit/item-grid.js.map +1 -0
- package/dist/kit/order.d.ts +13 -0
- package/dist/kit/order.d.ts.map +1 -0
- package/dist/kit/order.js +43 -0
- package/dist/kit/order.js.map +1 -0
- package/dist/kit/random.d.ts +7 -0
- package/dist/kit/random.d.ts.map +1 -0
- package/dist/kit/random.js +29 -0
- package/dist/kit/random.js.map +1 -0
- package/dist/kit/slots/index.d.ts +22 -0
- package/dist/kit/slots/index.d.ts.map +1 -0
- package/dist/kit/slots/index.js +28 -0
- package/dist/kit/slots/index.js.map +1 -0
- package/dist/kit/slots/path-templates.d.ts +15 -0
- package/dist/kit/slots/path-templates.d.ts.map +1 -0
- package/dist/kit/slots/path-templates.js +113 -0
- package/dist/kit/slots/path-templates.js.map +1 -0
- package/dist/kit/slots/path.d.ts +45 -0
- package/dist/kit/slots/path.d.ts.map +1 -0
- package/dist/kit/slots/path.js +87 -0
- package/dist/kit/slots/path.js.map +1 -0
- package/dist/kit/slots/radial.d.ts +30 -0
- package/dist/kit/slots/radial.d.ts.map +1 -0
- package/dist/kit/slots/radial.js +45 -0
- package/dist/kit/slots/radial.js.map +1 -0
- package/dist/kit/slots/rectangular.d.ts +42 -0
- package/dist/kit/slots/rectangular.d.ts.map +1 -0
- package/dist/kit/slots/rectangular.js +79 -0
- package/dist/kit/slots/rectangular.js.map +1 -0
- package/dist/kit/slots/slot.d.ts +62 -0
- package/dist/kit/slots/slot.d.ts.map +1 -0
- package/dist/kit/slots/slot.js +41 -0
- package/dist/kit/slots/slot.js.map +1 -0
- package/dist/kit/slots/sphere.d.ts +36 -0
- package/dist/kit/slots/sphere.d.ts.map +1 -0
- package/dist/kit/slots/sphere.js +68 -0
- package/dist/kit/slots/sphere.js.map +1 -0
- package/dist/kit/stagger.d.ts +24 -0
- package/dist/kit/stagger.d.ts.map +1 -0
- package/dist/kit/stagger.js +90 -0
- package/dist/kit/stagger.js.map +1 -0
- package/dist/nodes.d.ts +15 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +15 -0
- package/dist/nodes.js.map +1 -0
- package/dist/path-grid/index.d.ts +2 -0
- package/dist/path-grid/index.d.ts.map +1 -0
- package/dist/path-grid/index.js +2 -0
- package/dist/path-grid/index.js.map +1 -0
- package/dist/path-grid/path-grid.d.ts +82 -0
- package/dist/path-grid/path-grid.d.ts.map +1 -0
- package/dist/path-grid/path-grid.js +192 -0
- package/dist/path-grid/path-grid.js.map +1 -0
- package/dist/radial-grid/index.d.ts +2 -0
- package/dist/radial-grid/index.d.ts.map +1 -0
- package/dist/radial-grid/index.js +2 -0
- package/dist/radial-grid/index.js.map +1 -0
- package/dist/radial-grid/radial-grid.d.ts +51 -0
- package/dist/radial-grid/radial-grid.d.ts.map +1 -0
- package/dist/radial-grid/radial-grid.js +95 -0
- package/dist/radial-grid/radial-grid.js.map +1 -0
- package/dist/rectangular-grid/index.d.ts +2 -0
- package/dist/rectangular-grid/index.d.ts.map +1 -0
- package/dist/rectangular-grid/index.js +2 -0
- package/dist/rectangular-grid/index.js.map +1 -0
- package/dist/rectangular-grid/rectangular-grid.d.ts +79 -0
- package/dist/rectangular-grid/rectangular-grid.d.ts.map +1 -0
- package/dist/rectangular-grid/rectangular-grid.js +156 -0
- package/dist/rectangular-grid/rectangular-grid.js.map +1 -0
- package/dist/sphere-grid/index.d.ts +2 -0
- package/dist/sphere-grid/index.d.ts.map +1 -0
- package/dist/sphere-grid/index.js +2 -0
- package/dist/sphere-grid/index.js.map +1 -0
- package/dist/sphere-grid/sphere-grid.d.ts +68 -0
- package/dist/sphere-grid/sphere-grid.d.ts.map +1 -0
- package/dist/sphere-grid/sphere-grid.js +149 -0
- package/dist/sphere-grid/sphere-grid.js.map +1 -0
- package/package.json +71 -3
- package/registry.json +32 -0
- package/src/engine.ts +12 -0
- package/src/index.ts +6 -0
- package/src/kit/index.ts +6 -0
- package/src/kit/item-effects.ts +114 -0
- package/src/kit/item-grid.ts +585 -0
- package/src/kit/order.ts +41 -0
- package/src/kit/random.ts +29 -0
- package/src/kit/slots/index.ts +39 -0
- package/src/kit/slots/path-templates.ts +120 -0
- package/src/kit/slots/path.ts +120 -0
- package/src/kit/slots/radial.ts +62 -0
- package/src/kit/slots/rectangular.ts +108 -0
- package/src/kit/slots/slot.ts +82 -0
- package/src/kit/slots/sphere.ts +94 -0
- package/src/kit/stagger.ts +96 -0
- package/src/nodes.ts +15 -0
- package/src/path-grid/index.ts +1 -0
- package/src/path-grid/path-grid.ts +213 -0
- package/src/radial-grid/index.ts +1 -0
- package/src/radial-grid/radial-grid.ts +90 -0
- package/src/rectangular-grid/index.ts +1 -0
- package/src/rectangular-grid/rectangular-grid.ts +160 -0
- package/src/sphere-grid/index.ts +1 -0
- package/src/sphere-grid/sphere-grid.ts +143 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @motionscript/grids
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- da6f97a: Every package ships a `NOTICE`, and a browser build lists what it bundles.
|
|
8
|
+
|
|
9
|
+
- 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).
|
|
10
|
+
- `@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.
|
|
11
|
+
- `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.
|
|
12
|
+
|
|
13
|
+
- 1778355: The published packages carry what a user needs and say what they are.
|
|
14
|
+
|
|
15
|
+
- `@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.
|
|
16
|
+
- `@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.
|
|
17
|
+
- 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.
|
|
18
|
+
|
|
19
|
+
## 0.1.0-alpha.4
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- 3eefc7e: Package reshuffle.
|
|
24
|
+
|
|
25
|
+
- `@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.
|
|
26
|
+
- `@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.
|
|
27
|
+
- `@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.
|
|
28
|
+
- `@motionscript/patterns` is new. It holds the pattern nodes (`LineGridPattern`, `DotGridPattern`, `GridPattern`, `ViewportPattern`) that `@motionscript/core` and `@motionscript/sdk` no longer ship.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 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.
|
|
33
|
+
|
|
34
|
+
- 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.
|
|
35
|
+
- `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.
|
|
36
|
+
- `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.
|
|
37
|
+
|
|
38
|
+
- e78f716: Kit gaps in waveforms, item grids, graphs and protein node.
|
|
39
|
+
|
|
40
|
+
- `@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.
|
|
41
|
+
- `@motionscript/grids`: the grids' descriptors name `children: "freeform"`, the one answer that is true of slot-placed children, in place of `flow` and `grid`.
|
|
42
|
+
- `@motionscript/molecule`: `Protein` refuses children, as its descriptor says, and declares `quality` non-animatable.
|
|
43
|
+
- `@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.
|
|
44
|
+
|
|
45
|
+
## 0.1.0-alpha.3
|
|
46
|
+
|
|
47
|
+
## 0.1.0-alpha.2
|
|
48
|
+
|
|
49
|
+
## 0.1.0-alpha.1
|
|
50
|
+
|
|
51
|
+
### Minor Changes
|
|
52
|
+
|
|
53
|
+
- 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`.
|
|
54
|
+
|
|
55
|
+
## 0.1.0-alpha.0
|
|
56
|
+
|
|
57
|
+
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,48 @@
|
|
|
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/skia-render/src/fills/fractal-noise.ts: `hash2` is "Hash without
|
|
8
|
+
Sine" by David Hoskins (https://www.shadertoy.com/view/4djSRW).
|
|
9
|
+
Copyright (c) 2014 David Hoskins.
|
|
10
|
+
|
|
11
|
+
- packages/skia-render/src/fills/fractal-noise.ts: `simplexNoise` follows
|
|
12
|
+
"Noise - simplex - 2D" by Inigo Quilez (https://www.shadertoy.com/view/Msf3WH).
|
|
13
|
+
Copyright (c) 2013 Inigo Quilez.
|
|
14
|
+
|
|
15
|
+
The project website, which is in the source repository only and in no npm
|
|
16
|
+
package, also includes MIT code: its landing-page background
|
|
17
|
+
(packages/site/components/landing/GradientBackground.tsx) uses 3D simplex
|
|
18
|
+
noise from webgl-noise by Ian McEwan, Ashima Arts
|
|
19
|
+
(https://github.com/ashima/webgl-noise). Copyright (C) 2011 by Ashima Arts.
|
|
20
|
+
|
|
21
|
+
@motionscript/canvaskit is a build of Skia's CanvasKit (BSD-3-Clause,
|
|
22
|
+
Copyright (c) 2011 Google Inc.) and carries FreeType, HarfBuzz, ICU, zlib,
|
|
23
|
+
libpng, Brotli, WOFF2, Emscripten and musl; their notices are in
|
|
24
|
+
packages/canvaskit/THIRD_PARTY_NOTICES.txt.
|
|
25
|
+
|
|
26
|
+
The browser builds under dist/browser/ bundle each package's npm dependencies;
|
|
27
|
+
dist/browser/THIRD_PARTY_LICENSES.txt in each package lists them with their
|
|
28
|
+
licences.
|
|
29
|
+
|
|
30
|
+
MIT License
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @motionscript/grids
|
|
2
|
+
|
|
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)). `ItemGrid`, the
|
|
15
|
+
abstract base the four share, has no `@node` key and is not in `NODES`.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @motionscript/grids @motionscript/sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Exports
|
|
24
|
+
|
|
25
|
+
| Path | Source | What |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `@motionscript/grids` | `src/index.ts` | the four grids, `PATH_GRID_SHAPES`, `NODES`, and `src/engine.ts` |
|
|
28
|
+
| `@motionscript/grids/kit` | `src/engine.ts` | `ItemGrid` and what it uses (`src/kit/`): slot functions per arrangement, stagger, reveal and wave styles, order helpers, seeded random |
|
|
29
|
+
|
|
30
|
+
## Nodes
|
|
31
|
+
|
|
32
|
+
The items are the grid's children, in layer order; a group is one item. A grid is
|
|
33
|
+
`hug` by default, except `pathGrid` (640 x 400, fixed).
|
|
34
|
+
|
|
35
|
+
| Key | Arrangement props | Own commands |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `rectangularGrid` | `columns`, `fillDirection`, `cellMode` (`fit`/`fixed`/`fill`), `cellWidth/Height`, `columnGap`, `rowGap`, `lastLineAlign`, `rowOffset`, `columnOffset` | `columnsTo`, `gapTo`, `cellSizeTo`, `focusRow`, `focusColumn` |
|
|
38
|
+
| `radialGrid` | `radius`, `startAngle`, `sweep`, `direction`, `rotateItems`, `spinSpeed` | `spin`, `turnTo`, `radiusTo`, `sweepTo` |
|
|
39
|
+
| `pathGrid` | `shape` (a template or `custom`), `path`, `pathNode`, `spacing`, `spacingDistance`, `offset`, `flowSpeed`, `trimStart/End`, `alignToPath` | `flow`, `trimTo`, `setPath` |
|
|
40
|
+
| `sphereGrid` | `radius`, `yaw`, `pitch`, `roll`, `facing`, `focalLength`, `depthFade`, `cullBackfaces`, `spinSpeed` | `spin`, `orientTo`, `turnTo`, `radiusTo`, `focalLengthTo` |
|
|
41
|
+
|
|
42
|
+
Every grid also has `order`, `spread` and `arrangeLike`, and these commands from
|
|
43
|
+
`ItemGrid`: `reveal`, `conceal`, `wave`, `focus`, `unfocus`, `spreadTo`, `shuffle`,
|
|
44
|
+
`swap`, `reorder`, `morphInto`. Per-item commands take `staggerOrder` (`index`,
|
|
45
|
+
`reverse`, `random`, `centerOut`, `edgesIn`, `row`, `column`, `angle`, `path`,
|
|
46
|
+
`depth`) and `stagger` (0 to 0.95); `shuffle`, `swap`, `reorder`, `morphInto`,
|
|
47
|
+
`columnsTo` and `setPath` are *transitions*.
|
|
48
|
+
|
|
49
|
+
## Rules worth knowing
|
|
50
|
+
|
|
51
|
+
- **A slot is a parent transform.** Each item is laid out where its slot is, and the
|
|
52
|
+
rest of the slot (turn, scale, tilt, depth, fade) is answered through
|
|
53
|
+
`_placementOf(child)`, applied about the item's centre before its own transform, so
|
|
54
|
+
an item's own `x`, `y`, `rotation` and its commands keep working relative to the
|
|
55
|
+
slot. A grid whose arrangement has depth (the sphere) opens a camera of its own
|
|
56
|
+
through `_spaceCamera()`, unless it already sits in a space.
|
|
57
|
+
- **`flowOps` measures and sizes; it never places.** The grid's size is what its
|
|
58
|
+
slots come to (`extentOf`), so a grid of grids is a grid of items.
|
|
59
|
+
- **`revealState`, `waveState`, `focusState` and `transition` are written by
|
|
60
|
+
commands, not authored.** They are rewritten every frame as a pure function of
|
|
61
|
+
time and set to `null` at the command's end, so a seek reproduces them. `reveal`
|
|
62
|
+
hides every item at its start (place it where the grid enters); `conceal` leaves
|
|
63
|
+
them hidden until a later `reveal`.
|
|
64
|
+
- **The stagger lives inside the duration**: a command lasts its row's `duration`.
|
|
65
|
+
- **An arrangement is data.** A transition keeps the arrangement it leaves as a
|
|
66
|
+
`GridSnapshot` and re-evaluates it each frame, so a morph can start from any
|
|
67
|
+
arrangement, including another grid's. `morphInto` writes `arrangeLike` and keeps
|
|
68
|
+
following that grid; a grid that cannot find `arrangeLike` or `pathNode` draws its
|
|
69
|
+
own arrangement.
|
|
70
|
+
- **`order[k]` is the child in slot `k`**, and `normalizeOrder` repairs any order
|
|
71
|
+
(missing, repeated or out-of-range entries), so a stale order never throws.
|
|
72
|
+
- **The kit stays an import.** `ms add rectangular-grid` (or `radial-grid`,
|
|
73
|
+
`path-grid`, `sphere-grid`) copies one grid's two files and rewrites their kit
|
|
74
|
+
imports to `@motionscript/grids/kit` (`registry.json`): a second copy of
|
|
75
|
+
`ItemGrid` would be a second class under one name, and a morph would not find the
|
|
76
|
+
grids it should.
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pnpm --filter @motionscript/grids build
|
|
82
|
+
pnpm --filter @motionscript/grids test
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Tests are in `src/tests/` (`grid.test.ts`, `slots.test.ts`, `descriptors.test.ts`);
|
|
86
|
+
`harness.ts` supplies the attach and measure helpers.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{pathOps as et}from"@motionscript/sdk";function _(n,t,e){return{x:n,y:t,depth:0,rotation:0,rotationX:0,rotationY:0,scale:1,opacity:1,meta:e}}function U(n,t,e){if(e<=0)return n;if(e>=1)return t;let o=(s,r)=>s+(r-s)*e;return{x:o(n.x,t.x),y:o(n.y,t.y),depth:o(n.depth,t.depth),rotation:o(n.rotation,t.rotation),rotationX:o(n.rotationX,t.rotationX),rotationY:o(n.rotationY,t.rotationY),scale:o(n.scale,t.scale),opacity:o(n.opacity,t.opacity),meta:e<.5?n.meta:t.meta}}function V(n,t){return t===1?n:{...n,x:n.x*t,y:n.y*t,depth:n.depth*t}}function tt(n){let t=0,e=0;for(let o of n)o.width>t&&(t=o.width),o.height>e&&(e=o.height);return{width:t,height:e}}var $t=["distribute","fixed"],R=new Map,_t=32;function wt(n){let t=R.get(n);if(t)return t;let e=et.contours(n),o={sampler:et.sampler(n),closed:e.length===1&&e[0].closed};return R.size>=_t&&R.delete(R.keys().next().value),R.set(n,o),o}function nt(n,t){let{count:e}=t;if(e===0)return[];let{sampler:o,closed:s}=wt(n.path),r=o.length,a=z(Math.min(n.trimStart,n.trimEnd)),i=z(Math.max(n.trimStart,n.trimEnd)),c=a*r,l=(i-a)*r,d=s&&a===0&&i===1,h=n.offset+n.flowSpeed*t.time,u=n.placement,M=u.rotation*Math.PI/180,S=Math.cos(M),I=Math.sin(M),y=[];for(let k=0;k<e;k++){let m;n.spacing==="fixed"&&l>0?m=h+k*n.spacingDistance/l:d?m=h+k/e:m=h+(e===1?.5:k/(e-1));let C=!0;d?m=m-Math.floor(m):(m<-1e-9||m>1+1e-9)&&(C=!1);let g=o.frameAt(c+z(m)*l);if(!g){let X=_(0,0,{kind:"path",t:z(m)});X.opacity=0,y.push(X);continue}let P=u.flipY?-1:1,T=(g.x-u.originX)*u.scale,v=(g.y-u.originY)*u.scale*P,b=_(u.x+T*S+v*I,u.y-T*I+v*S,{kind:"path",t:z(m)});n.alignToPath&&(b.rotation=-Math.atan2(g.ty*P,g.tx)*180/Math.PI+u.rotation),C||(b.opacity=0),y.push(b)}return y}function z(n){return n<0?0:n>1?1:n}var Qt=["clockwise","counterclockwise"];function ot(n,t,e){let o=n.sweep,s=Math.min(1,Math.abs(o)/360)**8,r=t<=1?0:o/(t-1+s),a=n.direction==="counterclockwise"?-1:1,i=n.startAngle+n.spinSpeed*e,c=[];for(let l=0;l<t;l++)c.push(i+a*l*r);return c}function st(n,t){let e=ot(n,t.count,t.time),o=e[0]??0;return e.map(s=>{let r=s*Math.PI/180,a=_(n.radius*Math.sin(r),n.radius*Math.cos(r),{kind:"radial",angle:Math.abs(s-o)});return n.rotateItems&&(a.rotation=s),a})}function Ut(n,t,e){let o=ot({...n,spinSpeed:0},t,0)[e]??n.startAngle;return-St(o)}function St(n){let t=(n%360+360)%360;return t>180?t-360:t}var ne=["row","column"],oe=["fit","fixed","fill"],se=["start","center","end"];function rt(n,t){let e=Math.max(1,Math.round(n.columns)),o=Math.max(1,Math.ceil(t/e));return n.fillDirection==="column"?{rows:o,columns:Math.max(1,Math.ceil(t/o))}:{rows:o,columns:e}}function kt(n,t,e,o){let{rows:s,columns:r}=rt(n,t);switch(n.cellMode){case"fixed":return{width:Math.max(0,n.cellWidth),height:Math.max(0,n.cellHeight)};case"fill":return{width:Math.max(0,(o.width-n.columnGap*(r-1))/r),height:Math.max(0,(o.height-n.rowGap*(s-1))/s)};default:return tt(e)}}function at(n,t){let{count:e}=t;if(e===0)return[];let{rows:o,columns:s}=rt(n,e),r=n.fillDirection==="column",a=r?s:o,i=r?o:s,c=kt(n,e,t.sizes,t.box),l=c.width+n.columnGap,d=c.height+n.rowGap,h=a-1,u=e-h*i,M=i-u,S=n.lastLineAlign==="center"?M/2:n.lastLineAlign==="end"?M:0,I=n.rowOffset*l,y=n.columnOffset*d,k=[];for(let m=0;m<e;m++){let C=Math.floor(m/i),g=m%i;C===h&&(g+=S);let P=r?g:C,T=r?C:g,v=Math.round(P),b=Math.round(T),X=(T-(s-1)/2)*l+(v%2===1?I:0)-(o>1?I/2:0),gt=((o-1)/2-P)*d-(b%2===1?y:0)+(s>1?y/2:0);k.push(_(X,gt,{kind:"rectangular",row:v,column:b}))}return k}var ie=["outward","billboard"],ce=["x","y","z"],It=Math.PI*(3-Math.sqrt(5)),w=180/Math.PI;function it(n,t){if(t<=1)return[0,0,1];let e=1-2*(n+.5)/t,o=Math.sqrt(Math.max(0,1-e*e)),s=n*It;return[Math.cos(s)*o,e,Math.sin(s)*o]}function At(n,t,e,o){let[s,r,a]=n,i=t/w,c=e/w,l=o/w,d=s*Math.cos(i)+a*Math.sin(i),h=-s*Math.sin(i)+a*Math.cos(i),u=r*Math.cos(c)-h*Math.sin(c),M=r*Math.sin(c)+h*Math.cos(c);return[d*Math.cos(l)+u*Math.sin(l),-d*Math.sin(l)+u*Math.cos(l),M]}function ct(n,t){let{count:e}=t,o=n.radius,s=n.yaw+n.spinSpeed*t.time,r=n.facing==="outward",a=[];for(let i=0;i<e;i++){let c=it(i,e),[l,d,h]=At(c,s,n.pitch,n.roll),u=_(l*o,d*o,{kind:"sphere",lat:Math.asin(Math.max(-1,Math.min(1,c[1])))*w,lon:Math.atan2(c[2],c[0])*w,depth:h});u.depth=h*o,r&&(u.rotationY=Math.asin(Math.max(-1,Math.min(1,l)))*w,u.rotationX=Math.atan2(d,h)*w),u.opacity=1-n.depthFade*(1-(h+1)/2),r&&n.cullBackfaces&&Ot(u,[l,d,h],n.focalLength)&&(u.opacity=0),a.push(u)}return a}function Ot(n,t,e){return e<=0?t[2]<0:t[0]*-n.x+t[1]*-n.y+t[2]*(e-n.depth)<0}function le(n,t){let[e,o,s]=it(t,n);return{yaw:-Math.atan2(e,s)*w,pitch:Math.atan2(o,Math.hypot(e,s))*w}}var ue=["circle","square","star","heart","infinity","wave","spiral","arc","line"];var G=new Map,Et=64;function de(n,t){let e=`${n}:${Math.round(t.width*100)}:${Math.round(t.height*100)}`,o=G.get(e);if(o)return o;let s=Ct(n,t);return G.size>=Et&&G.delete(G.keys().next().value),G.set(e,s),s}function Ct(n,t){let e=t.width>0?t.width:400,o=t.height>0?t.height:400,s=e/2,r=o/2;switch(n){case"square":return B([[-s,r],[s,r],[s,-r],[-s,-r]]);case"star":{let a=[];for(let i=0;i<10;i++){let c=i*Math.PI/5,l=i%2===0?1:.45;a.push([Math.sin(c)*s*l,Math.cos(c)*r*l])}return B(a)}case"heart":return B(N(96,a=>{let i=a*2*Math.PI,c=16*Math.sin(i)**3,l=13*Math.cos(i)-5*Math.cos(2*i)-2*Math.cos(3*i)-Math.cos(4*i);return[c/17*s,(l+2.5)/15.5*r]}).slice(0,-1));case"infinity":return B(N(96,a=>{let i=a*2*Math.PI,c=1+Math.sin(i)**2;return[Math.cos(i)/c*s,Math.sin(i)*Math.cos(i)/c*r*2]}).slice(0,-1));case"wave":return H(N(96,a=>[(-1+2*a)*s,Math.sin(a*4*Math.PI)*r*.6]));case"spiral":return H(N(160,a=>{let i=a*3*2*Math.PI,c=.08+.92*a;return[Math.sin(i)*s*c,Math.cos(i)*r*c]}));case"arc":return H(N(64,a=>{let i=-Math.PI/2+a*Math.PI;return[Math.sin(i)*s,-r+Math.cos(i)*o]}));case"line":return[{type:"M",x:-s,y:0},{type:"L",x:s,y:0}];default:return bt(s,r)}}function bt(n,t){let e=.5522847498;return[{type:"M",x:0,y:t},{type:"C",x1:e*n,y1:t,x2:n,y2:e*t,x:n,y:0},{type:"C",x1:n,y1:-e*t,x2:e*n,y2:-t,x:0,y:-t},{type:"C",x1:-e*n,y1:-t,x2:-n,y2:-e*t,x:-n,y:0},{type:"C",x1:-n,y1:e*t,x2:-e*n,y2:t,x:0,y:t},{type:"Z"}]}function N(n,t){let e=[];for(let o=0;o<=n;o++)e.push(t(o/n));return e}function H(n){return n.map(([t,e],o)=>o===0?{type:"M",x:t,y:e}:{type:"L",x:t,y:e})}function B(n){return[...H(n),{type:"Z"}]}function K(n,t){switch(n.kind){case"rectangular":return at(n,t);case"radial":return st(n,t);case"path":return nt(n,t);case"sphere":return ct(n,t)}}function $(n){return n.kind==="sphere"?Math.max(1,n.focalLength):0}function Lt(n){let t=Math.floor(n)>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function W(n,t){let e=[...n],o=Lt(t);for(let s=e.length-1;s>0;s--){let r=Math.floor(o()*(s+1));[e[s],e[r]]=[e[r],e[s]]}return e}function lt(n){let t=2166136261;for(let e=0;e<n.length;e++)t=Math.imul(t^n.charCodeAt(e),16777619);return t>>>0}var ht=["index","reverse","random","centerOut","edgesIn","row","column","angle","path","depth"],Pt=.95;function ut(n,t,e){let o=t.length,s=Tt(n,t,e),r=1/0,a=-1/0;for(let c of s)c<r&&(r=c),c>a&&(a=c);let i=a-r;return i>1e-9?s.map(c=>(c-r)/i):new Array(o).fill(0)}function D(n,t,e){let o=Math.max(0,Math.min(Pt,e)),s=o===0?t:(t-n*o)/(1-o);return s<0?0:s>1?1:s}function Tt(n,t,e){switch(n){case"reverse":return t.map((o,s)=>-s);case"random":{let o=W(t.map((r,a)=>a),e),s=new Array(t.length);return o.forEach((r,a)=>{s[r]=a}),s}case"centerOut":return t.map(o=>Math.round(Math.hypot(o.x,o.y,o.depth)*1e3)/1e3);case"edgesIn":return t.map(o=>-Math.round(Math.hypot(o.x,o.y,o.depth)*1e3)/1e3);case"row":return t.map(o=>o.meta.kind==="rectangular"?o.meta.row:-Math.round(o.y));case"column":return t.map(o=>o.meta.kind==="rectangular"?o.meta.column:Math.round(o.x));case"angle":return t.map((o,s)=>o.meta.kind==="radial"?o.meta.angle:o.meta.kind==="rectangular"||o.meta.kind==="sphere"?vt(o):s);case"path":return t.map((o,s)=>o.meta.kind==="path"?o.meta.t:s);case"depth":return t.map((o,s)=>o.meta.kind==="sphere"?-o.meta.depth:s);default:return t.map((o,s)=>s)}}function vt(n){let t=Math.atan2(n.x,n.y)*180/Math.PI;return t<0?t+360:t}var Z=["scale","fade","center","rise","flip","spin"],dt=["scale","lift","fade","spin"];function ft(n,t,e,o,s,r){o&&Rt(n,o.style,o.values[t]??1,e),s&&zt(n,s,s.values[t]??0,e),r&&Gt(n,r,r.values[t]??0)}function Rt(n,t,e,o){if(e===1)return;let s=q(e);switch(t){case"fade":n.opacity*=s;break;case"center":n.x*=e,n.y*=e,n.depth*=e,n.opacity*=q(e*4);break;case"rise":n.y-=(1-e)*Math.max(40,o.height),n.opacity*=s;break;case"flip":n.rotationX+=(1-e)*90;break;case"spin":n.rotation-=(1-e)*180,n.scale*=Math.max(0,e);break;default:n.scale*=Math.max(0,e)}}function zt(n,t,e,o){if(e!==0)switch(t.style){case"lift":n.y+=t.amount*e*Math.max(40,o.height);break;case"fade":n.opacity*=q(1-t.amount*e);break;case"spin":n.rotation+=t.amount*e*360;break;default:n.scale*=1+t.amount*e}}function Gt(n,t,e){if(e!==0){if(e>0){n.scale*=1+t.grow*e;return}n.opacity*=q(1-t.dim*-e),n.scale*=Math.max(0,1+t.grow*.5*e)}}function q(n){return n<0?0:n>1?1:n}function A(n,t){let e=[],o=new Array(t).fill(!1);for(let s of n??[]){let r=Math.round(s);r>=0&&r<t&&!o[r]&&(o[r]=!0,e.push(r))}for(let s=0;s<t;s++)o[s]||e.push(s);return e}function J(n){let t=new Array(n.length);return n.forEach((e,o)=>{t[e]=o}),t}function pt(n){return Array.isArray(n)?n.map(Number).filter(Number.isFinite):typeof n!="string"?[]:n.split(/[\s,]+/).filter(t=>t!=="").map(Number).filter(Number.isFinite)}import{command as x,easeIn as Nt,easeInOut as Y,easeOut as mt,findNode2D as Dt,flowOps as F,frameIn as Yt,insetsOps as Mt,Node2D as Ft,property as O,sizeInputOps as yt}from"@motionscript/sdk";import{findNode2D as De,frameIn as Ye}from"@motionscript/sdk";var p=function(n,t,e,o){var s=arguments.length,r=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,e):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,o);else for(var i=n.length-1;i>=0;i--)(a=n[i])&&(r=(s<3?a(r):s>3?a(t,e,r):a(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};function E(n){return[{key:"staggerOrder",kind:"enum",options:ht,default:"index"},{key:"stagger",min:0,max:.95,step:.05,default:n}]}var xt=["rectangularGrid","radialGrid","pathGrid","sphereGrid"],j=.3,Xt={width:0,height:0},Bt={x:0,y:0},f=class n extends Ft{reveal(t){let e=t.data?.style??"scale",o=t.easing??(e==="scale"||e==="flip"?mt("back"):mt("cubic")),s=this._ranks(t.data?.staggerOrder),r=t.data?.stagger??.5;return this.command(a=>a>=1?{revealState:null}:{revealState:{style:e,values:s.map(i=>o(D(i,a,r)))}},t.duration)}conceal(t){let e=t.data?.style??"scale",o=t.easing??(e==="scale"||e==="flip"?Nt("back"):Y("cubic")),s=this._ranks(t.data?.staggerOrder),r=t.data?.stagger??.5,a=this.revealState?.values;return this.command(i=>({revealState:{style:e,values:s.map((c,l)=>(a?.[l]??1)*(1-o(D(c,i,r))))}}),t.duration)}wave(t){let e=t.data?.style??"scale",o=t.data?.amount??.3,s=t.easing??Y("sine"),r=this._ranks(t.data?.staggerOrder),a=t.data?.stagger??.7;return this.command(i=>i>=1?{waveState:null}:{waveState:{style:e,amount:o,values:r.map(c=>Math.sin(Math.PI*s(D(c,i,a))))}},t.duration)}focus(t){let e=this._itemCount(),o=Math.round(t.data?.item??0);return this._focusOn(s=>s===o,e,t)}unfocus(t){let e=this.focusState,o=t.easing??Y("cubic");return this.command(s=>{if(s>=1||!e)return{focusState:null};let r=1-o(s);return{focusState:{...e,values:e.values.map(a=>a*r)}}},t.duration)}spreadTo(t){return this.to({data:{spread:t.data?.spread??1},duration:t.duration,easing:t.easing})}shuffle(t){let e=A(this.order,this._itemCount()),o=W(e,t.data?.seed??1);return o.length>1&&o.every((s,r)=>s===e[r])&&(o=[...o.slice(1),o[0]]),this._transitionTo({order:o},t)}swap(t){let e=A(this.order,this._itemCount()),o=e.indexOf(Math.round(t.data?.first??0)),s=e.indexOf(Math.round(t.data?.second??1));return o>=0&&s>=0&&([e[o],e[s]]=[e[s],e[o]]),this._transitionTo({order:e},t,0)}reorder(t){let e=A(pt(t.data?.order),this._itemCount());return this._transitionTo({order:e},t)}morphInto(t){return this._transitionTo({arrangeLike:t.data?.target??""},t)}applyDefaultSize(t){(!t||t.width===void 0)&&this.applyProp("width","hug",{tween:yt.lerp}),(!t||t.height===void 0)&&this.applyProp("height","hug",{tween:yt.lerp})}itemSpace(t,e,o){return e}measure(t,e){this.lastMeasure={constraints:t,measurer:e};let o=this.effectivePadding(),s=this.flowChildren();if(s.length===0)return this._measured=null,F.size(this,t,o,Xt);let r=F.contentBox(this,t,o),a=this._measureItems(s,r,e);return this._measured={space:r,sizes:a},F.size(this,t,o,Ht(this._targetSlots(s.length,a,r).slots,a,this._focal))}layoutChildren(t,e){this._placements.clear();let o=this.flowChildren();if(o.length===0){this._slots=[],this._sizes=[],this._focal=0;return}let s=Mt.insetBounds(t.width,t.height,this.effectivePadding()),r=this._measured;this._measured=null;let a=r&&r.sizes.length===o.length&&qt(r.space,s)?r.sizes:this._measureItems(o,s,e),i=this._resolve(a,s);this._slots=i,this._sizes=a;for(let c=0;c<o.length;c++){let l=i[c];o[c].layout({x:s.x+l.x,y:s.y-l.y,width:a[c].width,height:a[c].height},e),(l.rotation!==0||l.scale!==1||l.rotationX!==0||l.rotationY!==0||l.depth!==0||l.opacity!==1)&&this._placements.set(o[c],{rotation:l.rotation,scale:l.scale,rotationX:l.rotationX,rotationY:l.rotationY,depth:l.depth,opacity:l.opacity})}}_placementOf(t){return this._placements.get(t)??null}_spaceCamera(){let t=this._focal;return t<=0||this._inSpace()?null:{perspective:t,orbit:0,elevation:0,dolly:0,lookAt:Bt,zoom:1,heading:0,viewportX:0,viewportY:0}}_placements=new Map;_measured=null;_slots=[];_sizes=[];_focal=0;_borrowCache=null;_itemCount(){return this.flowChildren().length}_itemSlots(){let t=this._itemCount();if(this._slots.length===t)return this._slots;let e=new Array(t).fill({width:100,height:100});return this._targetSlots(t,e,L(this)).slots}_itemSizes(){return this._sizes.length===this._itemCount()?this._sizes:[]}_ranks(t){return ut(t??"index",this._itemSlots(),lt(this.id))}_transitionTo(t,e,o=j){let s=this._snapshot(),r=e.easing??Y("cubic"),a=this._ranks(e.data?.staggerOrder),i=e.data?.stagger??o;return this.command(c=>{if(c>=1)return{...t,transition:null};let l=a.map(d=>r(D(d,c,i)));return{...t,transition:{from:s,mix:l}}},e.duration)}_focusOn(t,e,o){let s=this.focusState,r=o.data?.dim??.7,a=o.data?.grow??.15,i=Array.from({length:e},(l,d)=>t(d)?1:-1),c=o.easing??Y("cubic");return this.command(l=>{let d=c(l);return{focusState:{dim:Q(s?.dim??r,r,d),grow:Q(s?.grow??a,a,d),values:i.map((h,u)=>Q(s?.values[u]??0,h,d))}}},o.duration)}_snapshot(){let t=this._borrowed();return{arrangement:t?t.arrangementFor(L(t)):this.arrangementFor(L(this)),source:t?.id??"",order:A(this.order,this._itemCount()),spread:this.spread}}_measureItems(t,e,o){let s=F.measure({},t,e,o).sizes,r=this.itemSpace(t.length,e,s);return r===e?[...s]:[...F.measure({},t,r,o).sizes]}_targetSlots(t,e,o){let s=this._borrowed(),r=s?s.arrangementFor(L(s)):this.arrangementFor(o),a=K(r,{count:t,sizes:e,box:s?L(s):o,time:this.time.total});return s&&(a=this._fromGrid(s,a)),{slots:J(A(this.order,t)).map(c=>V(a[c],this.spread)),arrangement:r}}_resolve(t,e){let o=t.length,s=this._targetSlots(o,t,e),r=s.slots,a=$(s.arrangement),i=this.transition;if(i){let{from:h}=i,u=h.source?this._gridById(h.source):null,M=u?L(u):e,S=K(h.arrangement,{count:o,sizes:t,box:M,time:this.time.total});u&&u!==this&&(S=this._fromGrid(u,S));let I=J(A(h.order,o));for(let y=0;y<o;y++)r[y]=U(V(S[I[y]],h.spread),r[y],i.mix[y]??1);a=a||$(h.arrangement)}this._focal=a;let c=this.revealState,l=this.waveState,d=this.focusState;if(c||l||d)for(let h=0;h<o;h++)ft(r[h],h,t[h],c,l,d);return r}_inSpace(){for(let t=this.parent;t;t=t.parent){if(t._spaceCamera())return!0;if(!t._rendersChildrenInSpace())return!1}return!1}_borrowed(){let t=this.arrangeLike;return!t||t===this.id?null:this._gridById(t)}_gridById(t){if(t===this.id)return this;let e=this._borrowCache;if(e&&e.id===t&&e.grid.mounted)return e.grid;let o=Dt(this,t),s=o instanceof n?o:null;return this._borrowCache=s?{id:t,grid:s}:null,s}_fromGrid(t,e){let o=Yt(this,t);return e.map(s=>{let r=Wt(s.x*o.scale,s.y*o.scale,o.rotation);return{...s,x:o.x+r.x,y:o.y+r.y,depth:s.depth*o.scale,rotation:s.rotation+o.rotation,scale:s.scale*o.scale}})}};p([O({default:[],kind:"order",animatable:!1})],f.prototype,"order",void 0);p([O({default:1,min:0,max:3,step:.05})],f.prototype,"spread",void 0);p([O({default:"",kind:"nodeRef",nodeTypes:xt,animatable:!1})],f.prototype,"arrangeLike",void 0);p([O({default:void 0,kind:"state",animatable:!1})],f.prototype,"revealState",void 0);p([O({default:void 0,kind:"state",animatable:!1})],f.prototype,"waveState",void 0);p([O({default:void 0,kind:"state",animatable:!1})],f.prototype,"focusState",void 0);p([O({default:void 0,kind:"state",animatable:!1})],f.prototype,"transition",void 0);p([x({args:[{key:"style",kind:"enum",options:Z,default:"scale"},...E(.5)]})],f.prototype,"reveal",null);p([x({args:[{key:"style",kind:"enum",options:Z,default:"scale"},...E(.5)]})],f.prototype,"conceal",null);p([x({args:[{key:"style",kind:"enum",options:dt,default:"scale"},{key:"amount",min:0,max:2,step:.05,default:.3},...E(.7)]})],f.prototype,"wave",null);p([x({args:[{key:"item",min:0,step:1,default:0},{key:"dim",min:0,max:1,step:.05,default:.7},{key:"grow",min:0,max:1,step:.05,default:.15}]})],f.prototype,"focus",null);p([x()],f.prototype,"unfocus",null);p([x({args:[{key:"spread",min:0,max:3,step:.05,default:1}]})],f.prototype,"spreadTo",null);p([x({args:[{key:"seed",min:0,step:1,default:1},...E(j)]})],f.prototype,"shuffle",null);p([x({args:[{key:"first",min:0,step:1,default:0},{key:"second",min:0,step:1,default:1},...E(0)]})],f.prototype,"swap",null);p([x({args:[{key:"order",kind:"text",default:""},...E(j)]})],f.prototype,"reorder",null);p([x({args:[{key:"target",kind:"nodeRef",nodeTypes:xt},...E(j)]})],f.prototype,"morphInto",null);function L(n){let t=n.layoutBounds,e=Mt.insetBounds(t.width,t.height,n.effectivePadding());return{width:e.width,height:e.height}}function Ht(n,t,e){let o=0,s=0;for(let r=0;r<n.length;r++){let a=n[r],i=t[r],c=a.rotation*Math.PI/180,l=Math.abs(Math.cos(c)),d=Math.abs(Math.sin(c)),h=e>0&&e-a.depth>1?e/(e-a.depth):1,u=(i.width*l+i.height*d)/2*a.scale*h,M=(i.width*d+i.height*l)/2*a.scale*h;o=Math.max(o,Math.abs(a.x)*h+u),s=Math.max(s,Math.abs(a.y)*h+M)}return{width:o*2,height:s*2}}function Wt(n,t,e){if(e===0)return{x:n,y:t};let o=e*Math.PI/180,s=Math.cos(o),r=Math.sin(o);return{x:n*s+t*r,y:-n*r+t*s}}function qt(n,t){return Math.abs(n.width-t.width)<1e-6&&Math.abs(n.height-t.height)<1e-6}function Q(n,t,e){return n+(t-n)*e}export{_ as a,U as b,V as c,tt as d,$t as e,nt as f,Qt as g,ot as h,st as i,Ut as j,St as k,ne as l,oe as m,se as n,rt as o,kt as p,at as q,ie as r,ce as s,it as t,At as u,ct as v,le as w,ue as x,de as y,K as z,$ as A,Lt as B,W as C,lt as D,ht as E,ut as F,D as G,Z as H,dt as I,ft as J,A as K,J as L,pt as M,E as N,xt as O,j as P,f as Q,L as R,De as S,Ye as T};
|
|
2
|
+
//# sourceMappingURL=chunk-XDUDKWM7.js.map
|