@open-artifact/motion-stage 0.0.0-stage → 0.12.0-rc.0
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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +5 -2
- package/package.json +71 -4
- package/src/build.d.ts +18 -0
- package/src/build.js +73 -0
- package/src/host.d.ts +37 -0
- package/src/host.js +76 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +6 -0
- package/src/layers.d.ts +30 -0
- package/src/layers.js +56 -0
- package/src/offline/audio.d.ts +19 -0
- package/src/offline/audio.js +20 -0
- package/src/offline/data.d.ts +26 -0
- package/src/offline/data.js +71 -0
- package/src/offline/main.d.ts +9 -0
- package/src/offline/main.js +52 -0
- package/src/offline/player.d.ts +23 -0
- package/src/offline/player.js +155 -0
- package/src/protocol/guards.d.ts +6 -0
- package/src/protocol/guards.js +208 -0
- package/src/protocol/layer-guards.d.ts +7 -0
- package/src/protocol/layer-guards.js +97 -0
- package/src/protocol/layers.d.ts +123 -0
- package/src/protocol/layers.js +1 -0
- package/src/protocol/types.d.ts +261 -0
- package/src/protocol/types.js +7 -0
- package/src/protocol.d.ts +2 -0
- package/src/protocol.js +2 -0
- package/src/raster.d.ts +4 -0
- package/src/raster.js +2 -0
- package/src/runtime/assets.d.ts +19 -0
- package/src/runtime/assets.js +63 -0
- package/src/runtime/captions.d.ts +26 -0
- package/src/runtime/captions.js +103 -0
- package/src/runtime/console.d.ts +13 -0
- package/src/runtime/console.js +99 -0
- package/src/runtime/cut.d.ts +7 -0
- package/src/runtime/cut.js +63 -0
- package/src/runtime/determinism.d.ts +12 -0
- package/src/runtime/determinism.js +47 -0
- package/src/runtime/film.d.ts +40 -0
- package/src/runtime/film.js +29 -0
- package/src/runtime/focus.d.ts +8 -0
- package/src/runtime/focus.js +71 -0
- package/src/runtime/fonts.d.ts +22 -0
- package/src/runtime/fonts.js +109 -0
- package/src/runtime/frame.d.ts +9 -0
- package/src/runtime/frame.js +123 -0
- package/src/runtime/kit/camera.d.ts +40 -0
- package/src/runtime/kit/camera.js +56 -0
- package/src/runtime/kit/chip.d.ts +25 -0
- package/src/runtime/kit/chip.js +75 -0
- package/src/runtime/kit/cursor.d.ts +46 -0
- package/src/runtime/kit/cursor.js +108 -0
- package/src/runtime/kit/dom.d.ts +14 -0
- package/src/runtime/kit/dom.js +46 -0
- package/src/runtime/kit/geometry.d.ts +22 -0
- package/src/runtime/kit/geometry.js +46 -0
- package/src/runtime/kit/index.d.ts +95 -0
- package/src/runtime/kit/index.js +149 -0
- package/src/runtime/kit/mark-strokes.d.ts +65 -0
- package/src/runtime/kit/mark-strokes.js +226 -0
- package/src/runtime/kit/marks.d.ts +21 -0
- package/src/runtime/kit/marks.js +165 -0
- package/src/runtime/kit/math.d.ts +23 -0
- package/src/runtime/kit/math.js +35 -0
- package/src/runtime/kit/paper.d.ts +7 -0
- package/src/runtime/kit/paper.js +27 -0
- package/src/runtime/kit/random.d.ts +8 -0
- package/src/runtime/kit/random.js +32 -0
- package/src/runtime/kit/text-fx.d.ts +18 -0
- package/src/runtime/kit/text-fx.js +55 -0
- package/src/runtime/kit/typing.d.ts +21 -0
- package/src/runtime/kit/typing.js +42 -0
- package/src/runtime/layers/describe.d.ts +41 -0
- package/src/runtime/layers/describe.js +327 -0
- package/src/runtime/layers/item.d.ts +121 -0
- package/src/runtime/layers/item.js +149 -0
- package/src/runtime/layers/parts.d.ts +50 -0
- package/src/runtime/layers/parts.js +155 -0
- package/src/runtime/layers/rows.d.ts +4 -0
- package/src/runtime/layers/rows.js +233 -0
- package/src/runtime/layers/scan.d.ts +24 -0
- package/src/runtime/layers/scan.js +202 -0
- package/src/runtime/layers/walk.d.ts +16 -0
- package/src/runtime/layers/walk.js +333 -0
- package/src/runtime/load.d.ts +10 -0
- package/src/runtime/load.js +228 -0
- package/src/runtime/main.d.ts +1 -0
- package/src/runtime/main.js +69 -0
- package/src/runtime/modules.d.ts +23 -0
- package/src/runtime/modules.js +53 -0
- package/src/runtime/port.d.ts +8 -0
- package/src/runtime/port.js +46 -0
- package/src/runtime/questions.d.ts +24 -0
- package/src/runtime/questions.js +162 -0
- package/src/runtime/recut.d.ts +35 -0
- package/src/runtime/recut.js +158 -0
- package/src/runtime/render.d.ts +80 -0
- package/src/runtime/render.js +342 -0
- package/src/runtime/retouch/ask.d.ts +17 -0
- package/src/runtime/retouch/ask.js +156 -0
- package/src/runtime/retouch/entry.d.ts +77 -0
- package/src/runtime/retouch/entry.js +1 -0
- package/src/runtime/retouch/judge.d.ts +25 -0
- package/src/runtime/retouch/judge.js +209 -0
- package/src/runtime/retouch/look.d.ts +39 -0
- package/src/runtime/retouch/look.js +135 -0
- package/src/runtime/retouch/parts.d.ts +22 -0
- package/src/runtime/retouch/parts.js +166 -0
- package/src/runtime/retouch/retouch.d.ts +37 -0
- package/src/runtime/retouch/retouch.js +238 -0
- package/src/runtime/retouch/seat.d.ts +40 -0
- package/src/runtime/retouch/seat.js +228 -0
- package/src/runtime/retouch/state.d.ts +37 -0
- package/src/runtime/retouch/state.js +153 -0
- package/src/runtime/retouch/type-style.d.ts +19 -0
- package/src/runtime/retouch/type-style.js +111 -0
- package/src/runtime/scan.d.ts +2 -0
- package/src/runtime/scan.js +49 -0
- package/src/runtime/scenes/card.d.ts +12 -0
- package/src/runtime/scenes/card.js +56 -0
- package/src/runtime/scenes/install.d.ts +47 -0
- package/src/runtime/scenes/install.js +387 -0
- package/src/runtime/scenes/read.d.ts +15 -0
- package/src/runtime/scenes/read.js +57 -0
- package/src/runtime/scenes/scoped.d.ts +13 -0
- package/src/runtime/scenes/scoped.js +40 -0
- package/src/runtime/score.d.ts +26 -0
- package/src/runtime/score.js +221 -0
- package/src/runtime/sketch/pen.d.ts +3 -0
- package/src/runtime/sketch/pen.js +371 -0
- package/src/runtime/sketch/strokes.d.ts +41 -0
- package/src/runtime/sketch/strokes.js +187 -0
- package/src/runtime/snapshot/draw.d.ts +14 -0
- package/src/runtime/snapshot/draw.js +125 -0
- package/src/runtime/snapshot/hold-first-draw.d.ts +12 -0
- package/src/runtime/snapshot/hold-first-draw.js +128 -0
- package/src/runtime/snapshot/plate.d.ts +20 -0
- package/src/runtime/snapshot/plate.js +79 -0
- package/src/runtime/snapshot/serialize.d.ts +49 -0
- package/src/runtime/snapshot/serialize.js +271 -0
- package/src/runtime/snapshot/styles.d.ts +8 -0
- package/src/runtime/snapshot/styles.js +109 -0
- package/src/runtime/snapshot/xml.d.ts +6 -0
- package/src/runtime/snapshot/xml.js +110 -0
- package/src/runtime/stage-size.d.ts +7 -0
- package/src/runtime/stage-size.js +3 -0
- package/src/runtime/stage.d.ts +27 -0
- package/src/runtime/stage.js +154 -0
- package/src/runtime/stretch.d.ts +13 -0
- package/src/runtime/stretch.js +16 -0
- package/src/runtime/texts.d.ts +24 -0
- package/src/runtime/texts.js +210 -0
- package/src/runtime/video-sync.d.ts +26 -0
- package/src/runtime/video-sync.js +126 -0
- package/src/stills.d.ts +41 -0
- package/src/stills.js +253 -0
- package/src/tools/film.d.ts +13 -0
- package/src/tools/film.js +116 -0
- package/src/tools/main.d.ts +1 -0
- package/src/tools/main.js +216 -0
- package/src/tools/score.d.ts +4 -0
- package/src/tools/score.js +29 -0
- package/src/tools/types.d.ts +69 -0
- package/src/tools/types.js +2 -0
- package/src/tools.d.ts +5 -0
- package/src/tools.js +3 -0
- package/src/virtual.d.ts +11 -0
- package/src/vite.d.ts +8 -0
- package/src/vite.js +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @open-artifact/motion-stage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Motion stage runtime: the sandboxed in-frame player that runs a film's code (kit, scenes, score recorder, captions, snapshots, text scan), built into one classic script, with its message protocol, a Vite plugin that gives the page the script, and a standalone player.
|
|
4
|
+
|
|
5
|
+
Part of [Open Artifact](https://github.com/JimLiu/open-artifact): slide decks, design canvases and whiteboards an agent makes
|
|
6
|
+
and you view, edit and comment on in one local page. Source: [`packages/motion-stage`](https://github.com/JimLiu/open-artifact/tree/main/packages/motion-stage).
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifact/motion-stage",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.12.0-rc.0",
|
|
4
|
+
"description": "The Motion stage runtime: the sandboxed in-frame player that runs a film's code (kit, scenes, score recorder, captions, snapshots, text scan), built into one classic script, with its message protocol, a Vite plugin that gives the page the script, and a standalone player.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"default": "./src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./protocol": {
|
|
12
|
+
"types": "./src/protocol.d.ts",
|
|
13
|
+
"default": "./src/protocol.js"
|
|
14
|
+
},
|
|
15
|
+
"./layers": {
|
|
16
|
+
"types": "./src/layers.d.ts",
|
|
17
|
+
"default": "./src/layers.js"
|
|
18
|
+
},
|
|
19
|
+
"./tools": {
|
|
20
|
+
"types": "./src/tools.d.ts",
|
|
21
|
+
"default": "./src/tools.js"
|
|
22
|
+
},
|
|
23
|
+
"./raster": {
|
|
24
|
+
"types": "./src/raster.d.ts",
|
|
25
|
+
"default": "./src/raster.js"
|
|
26
|
+
},
|
|
27
|
+
"./stills": {
|
|
28
|
+
"types": "./src/stills.d.ts",
|
|
29
|
+
"default": "./src/stills.js"
|
|
30
|
+
},
|
|
31
|
+
"./build": {
|
|
32
|
+
"types": "./src/build.d.ts",
|
|
33
|
+
"default": "./src/build.js"
|
|
34
|
+
},
|
|
35
|
+
"./vite": {
|
|
36
|
+
"types": "./src/vite.d.ts",
|
|
37
|
+
"default": "./src/vite.js"
|
|
38
|
+
},
|
|
39
|
+
"./virtual": {
|
|
40
|
+
"types": "./src/virtual.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"src",
|
|
46
|
+
"LICENSE",
|
|
47
|
+
"NOTICE"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@open-artifact/motion-core": "0.12.0-rc.0",
|
|
51
|
+
"esbuild": "^0.25.12",
|
|
52
|
+
"vite": "^7.3.6"
|
|
53
|
+
},
|
|
54
|
+
"license": "Apache-2.0",
|
|
55
|
+
"author": {
|
|
56
|
+
"name": "Jim Liu 宝玉",
|
|
57
|
+
"url": "https://github.com/JimLiu"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/JimLiu/open-artifact#readme",
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/JimLiu/open-artifact.git",
|
|
63
|
+
"directory": "packages/motion-stage"
|
|
64
|
+
},
|
|
65
|
+
"bugs": {
|
|
66
|
+
"url": "https://github.com/JimLiu/open-artifact/issues"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public",
|
|
70
|
+
"tag": "next"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "ac158a48a1e61fbbdd71f0f6e33ee9bdb24fd35f"
|
|
73
|
+
}
|
package/src/build.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface BuiltScript {
|
|
2
|
+
script: string;
|
|
3
|
+
/** Absolute paths of the source files that went into it, for a dev server to watch. */
|
|
4
|
+
inputs: string[];
|
|
5
|
+
}
|
|
6
|
+
/** The stage runtime built afresh, with its inputs: for a dev server, which builds it again when one changes. */
|
|
7
|
+
export declare const buildStageRuntimeFresh: () => Promise<BuiltScript>;
|
|
8
|
+
/** The stage runtime, the script the frame runs before any film code: built once per process. */
|
|
9
|
+
export declare function buildStageRuntime(): Promise<string>;
|
|
10
|
+
/** The standalone player, which mounts the stage runtime from the page's `#stage-runtime` element. */
|
|
11
|
+
export declare function buildOfflinePlayer(): Promise<string>;
|
|
12
|
+
/** Film code reaches nothing outside the page, and the page nothing outside itself. */
|
|
13
|
+
export declare const TOOLS_CONTENT_SECURITY_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:";
|
|
14
|
+
/**
|
|
15
|
+
* The tools page: one self-contained HTML file, the stage runtime and its driver inside it, that shows no UI and
|
|
16
|
+
* sets `window.filmTools` (see `./tools`) for a headless browser to load a film into and take stills from.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildToolsPage(): Promise<string>;
|
package/src/build.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { extname, resolve } from 'node:path';
|
|
3
|
+
import { build } from 'esbuild';
|
|
4
|
+
import { inScript } from "./host.js";
|
|
5
|
+
import { OFFLINE_RUNTIME_ID } from "./offline/data.js";
|
|
6
|
+
const here = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
const entryExtension = extname(fileURLToPath(import.meta.url));
|
|
8
|
+
/** Both scripts run as classic scripts: the stage in a srcdoc frame, the player in a page saved to disk. */
|
|
9
|
+
async function bundle(entry) {
|
|
10
|
+
const result = await build({
|
|
11
|
+
entryPoints: [resolve(here, entry.replace(/\.ts$/, entryExtension))],
|
|
12
|
+
bundle: true,
|
|
13
|
+
format: 'iife',
|
|
14
|
+
platform: 'browser',
|
|
15
|
+
target: 'es2022',
|
|
16
|
+
minify: true,
|
|
17
|
+
legalComments: 'none',
|
|
18
|
+
charset: 'utf8',
|
|
19
|
+
write: false,
|
|
20
|
+
logLevel: 'silent',
|
|
21
|
+
absWorkingDir: here,
|
|
22
|
+
metafile: true,
|
|
23
|
+
// A classic script has no import.meta: the model's font file URLs, which the stage never reads, are made against a base that parses.
|
|
24
|
+
define: { 'import.meta.url': '"file:///"' },
|
|
25
|
+
});
|
|
26
|
+
const output = result.outputFiles[0];
|
|
27
|
+
if (!output)
|
|
28
|
+
throw new Error('esbuild gave no output for ' + entry);
|
|
29
|
+
const inputs = Object.keys(result.metafile.inputs).map((input) => resolve(here, input));
|
|
30
|
+
return { script: output.text, inputs };
|
|
31
|
+
}
|
|
32
|
+
/** The stage runtime built afresh, with its inputs: for a dev server, which builds it again when one changes. */
|
|
33
|
+
export const buildStageRuntimeFresh = () => bundle('./runtime/main.ts');
|
|
34
|
+
let runtime = null;
|
|
35
|
+
let player = null;
|
|
36
|
+
/** The stage runtime, the script the frame runs before any film code: built once per process. */
|
|
37
|
+
export function buildStageRuntime() {
|
|
38
|
+
runtime ??= bundle('./runtime/main.ts').then((built) => built.script, (error) => {
|
|
39
|
+
runtime = null;
|
|
40
|
+
throw error;
|
|
41
|
+
});
|
|
42
|
+
return runtime;
|
|
43
|
+
}
|
|
44
|
+
/** The standalone player, which mounts the stage runtime from the page's `#stage-runtime` element. */
|
|
45
|
+
export function buildOfflinePlayer() {
|
|
46
|
+
player ??= bundle('./offline/main.ts').then((built) => built.script, (error) => {
|
|
47
|
+
player = null;
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
return player;
|
|
51
|
+
}
|
|
52
|
+
let driver = null;
|
|
53
|
+
function buildToolsDriver() {
|
|
54
|
+
driver ??= bundle('./tools/main.ts').then((built) => built.script, (error) => {
|
|
55
|
+
driver = null;
|
|
56
|
+
throw error;
|
|
57
|
+
});
|
|
58
|
+
return driver;
|
|
59
|
+
}
|
|
60
|
+
/** Film code reaches nothing outside the page, and the page nothing outside itself. */
|
|
61
|
+
export const TOOLS_CONTENT_SECURITY_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:";
|
|
62
|
+
/**
|
|
63
|
+
* The tools page: one self-contained HTML file, the stage runtime and its driver inside it, that shows no UI and
|
|
64
|
+
* sets `window.filmTools` (see `./tools`) for a headless browser to load a film into and take stills from.
|
|
65
|
+
*/
|
|
66
|
+
export async function buildToolsPage() {
|
|
67
|
+
const [runtime, tools] = await Promise.all([buildStageRuntime(), buildToolsDriver()]);
|
|
68
|
+
return ('<!doctype html>\n<html lang="en"><head><meta charset="utf-8">' +
|
|
69
|
+
`<meta http-equiv="Content-Security-Policy" content="${TOOLS_CONTENT_SECURITY_POLICY}">` +
|
|
70
|
+
'<title>Film tools</title><style>html,body{margin:0;height:100%;overflow:hidden;background:#111}</style></head><body>' +
|
|
71
|
+
`<script type="text/plain" id="${OFFLINE_RUNTIME_ID}">${inScript(runtime)}</script>` +
|
|
72
|
+
`<script>${inScript(tools)}</script></body></html>`);
|
|
73
|
+
}
|
package/src/host.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HostToStage, StageToHost } from './protocol.ts';
|
|
2
|
+
/** The frame runs scripts and nothing else: no same origin, no forms, no popups, no top navigation. */
|
|
3
|
+
export declare const STAGE_SANDBOX = "allow-scripts";
|
|
4
|
+
/**
|
|
5
|
+
* A stage on the page's own origin: a clip streams from the page's server and its frames can be read back into a
|
|
6
|
+
* snapshot. The film's code can then reach the page that holds the frame.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SAME_ORIGIN_STAGE_SANDBOX = "allow-scripts allow-same-origin";
|
|
9
|
+
/** No camera, microphone, location or screen for the film, whatever origin the frame has. */
|
|
10
|
+
export declare const STAGE_PERMISSIONS = "camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'";
|
|
11
|
+
/**
|
|
12
|
+
* A same-origin stage loads nothing but what it is given and the page's own server's files: no other host, no
|
|
13
|
+
* workers, frames, plugins, forms or base URL.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SAME_ORIGIN_STAGE_POLICY: string;
|
|
16
|
+
/** Where the stage runs: an opaque origin of its own, or the page's. */
|
|
17
|
+
export type StageOrigin = 'opaque' | 'same';
|
|
18
|
+
export declare const stageSandbox: (origin: StageOrigin) => string;
|
|
19
|
+
/**
|
|
20
|
+
* A script's text inside a <script> element: a closing tag would end the element early, and a comment opener puts
|
|
21
|
+
* the parser where a later "<script" changes how it ends. Both escapes mean the same in a string, a regular
|
|
22
|
+
* expression or a comment. The patterns are written so that this file's own bundled text holds neither sequence.
|
|
23
|
+
*/
|
|
24
|
+
export declare const inScript: (code: string) => string;
|
|
25
|
+
/** The frame's whole document: the runtime, run once, before anything else; a same-origin stage under its policy. */
|
|
26
|
+
export declare function stageDocument(runtime: string, origin?: StageOrigin): string;
|
|
27
|
+
/** The origin the port is posted to: the page's own for a same-origin stage, unless the page's is opaque too. */
|
|
28
|
+
export declare function stageTargetOrigin(origin: StageOrigin, page?: string): string;
|
|
29
|
+
export interface StagePort {
|
|
30
|
+
send(message: HostToStage): void;
|
|
31
|
+
close(): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hands the loaded frame its port and listens on it. Call on the frame's load event, once per load: a frame that
|
|
35
|
+
* navigates has lost the film, and the stage takes only the first port it is given.
|
|
36
|
+
*/
|
|
37
|
+
export declare function openStagePort(frame: HTMLIFrameElement, onMessage: (message: StageToHost) => void, onRefused?: (data: unknown) => void, origin?: StageOrigin): StagePort | null;
|
package/src/host.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { STAGE_CONNECT, STAGE_PROTOCOL_VERSION, isStageToHost } from "./protocol.js";
|
|
2
|
+
/** The frame runs scripts and nothing else: no same origin, no forms, no popups, no top navigation. */
|
|
3
|
+
export const STAGE_SANDBOX = 'allow-scripts';
|
|
4
|
+
/**
|
|
5
|
+
* A stage on the page's own origin: a clip streams from the page's server and its frames can be read back into a
|
|
6
|
+
* snapshot. The film's code can then reach the page that holds the frame.
|
|
7
|
+
*/
|
|
8
|
+
export const SAME_ORIGIN_STAGE_SANDBOX = 'allow-scripts allow-same-origin';
|
|
9
|
+
/** No camera, microphone, location or screen for the film, whatever origin the frame has. */
|
|
10
|
+
export const STAGE_PERMISSIONS = "camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'";
|
|
11
|
+
/**
|
|
12
|
+
* A same-origin stage loads nothing but what it is given and the page's own server's files: no other host, no
|
|
13
|
+
* workers, frames, plugins, forms or base URL.
|
|
14
|
+
*/
|
|
15
|
+
export const SAME_ORIGIN_STAGE_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; " +
|
|
16
|
+
"media-src 'self' data: blob:; connect-src 'self' data: blob:; worker-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'";
|
|
17
|
+
export const stageSandbox = (origin) => (origin === 'same' ? SAME_ORIGIN_STAGE_SANDBOX : STAGE_SANDBOX);
|
|
18
|
+
/**
|
|
19
|
+
* A script's text inside a <script> element: a closing tag would end the element early, and a comment opener puts
|
|
20
|
+
* the parser where a later "<script" changes how it ends. Both escapes mean the same in a string, a regular
|
|
21
|
+
* expression or a comment. The patterns are written so that this file's own bundled text holds neither sequence.
|
|
22
|
+
*/
|
|
23
|
+
export const inScript = (code) => code.replace(/<\/(script)/gi, '<\\/$1').replace(/<!-{2}/g, '<\\x21--');
|
|
24
|
+
/**
|
|
25
|
+
* The stage's own rules. Under forced colors (a Windows contrast theme) the film keeps its colors: the root and body
|
|
26
|
+
* opt out, and the root's default text takes plain black or white by the theme's scheme, in the film-reset layer that
|
|
27
|
+
* this style names first, so any rule of the film's wins.
|
|
28
|
+
*/
|
|
29
|
+
const STAGE_CSS = 'html,body{margin:0;width:100%;height:100%;overflow:hidden;background:transparent;forced-color-adjust:none}' +
|
|
30
|
+
'@media (forced-colors:active){@layer film-reset{html{color:light-dark(#000,#fff)}}}';
|
|
31
|
+
/** The frame's whole document: the runtime, run once, before anything else; a same-origin stage under its policy. */
|
|
32
|
+
export function stageDocument(runtime, origin = 'opaque') {
|
|
33
|
+
const guard = origin === 'same' ? `<meta http-equiv="Content-Security-Policy" content="${SAME_ORIGIN_STAGE_POLICY}"><meta name="referrer" content="no-referrer">` : '';
|
|
34
|
+
return ('<!doctype html><html><head><meta charset="utf-8">' +
|
|
35
|
+
guard +
|
|
36
|
+
'<style>' +
|
|
37
|
+
STAGE_CSS +
|
|
38
|
+
'</style>' +
|
|
39
|
+
'</head><body><script>' +
|
|
40
|
+
inScript(runtime) +
|
|
41
|
+
'</script></body></html>');
|
|
42
|
+
}
|
|
43
|
+
/** The origin the port is posted to: the page's own for a same-origin stage, unless the page's is opaque too. */
|
|
44
|
+
export function stageTargetOrigin(origin, page = globalThis.location?.origin ?? 'null') {
|
|
45
|
+
return origin === 'same' && page !== 'null' ? page : '*';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Hands the loaded frame its port and listens on it. Call on the frame's load event, once per load: a frame that
|
|
49
|
+
* navigates has lost the film, and the stage takes only the first port it is given.
|
|
50
|
+
*/
|
|
51
|
+
export function openStagePort(frame, onMessage, onRefused, origin = 'opaque') {
|
|
52
|
+
const target = frame.contentWindow;
|
|
53
|
+
if (!target)
|
|
54
|
+
return null;
|
|
55
|
+
const channel = new MessageChannel();
|
|
56
|
+
const port = channel.port1;
|
|
57
|
+
port.onmessage = (event) => {
|
|
58
|
+
const data = event.data;
|
|
59
|
+
if (isStageToHost(data))
|
|
60
|
+
onMessage(data);
|
|
61
|
+
else
|
|
62
|
+
onRefused?.(data);
|
|
63
|
+
};
|
|
64
|
+
const connect = { type: STAGE_CONNECT, version: STAGE_PROTOCOL_VERSION };
|
|
65
|
+
// An opaque frame is reached by '*' alone; the port is what is private. A same-origin frame is held to the page's.
|
|
66
|
+
target.postMessage(connect, stageTargetOrigin(origin), [channel.port2]);
|
|
67
|
+
return {
|
|
68
|
+
send(message) {
|
|
69
|
+
port.postMessage(message);
|
|
70
|
+
},
|
|
71
|
+
close() {
|
|
72
|
+
port.onmessage = null;
|
|
73
|
+
port.close();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './protocol.ts';
|
|
2
|
+
export { SAME_ORIGIN_STAGE_POLICY, SAME_ORIGIN_STAGE_SANDBOX, STAGE_PERMISSIONS, STAGE_SANDBOX, openStagePort, stageDocument, stageSandbox, stageTargetOrigin, } from './host.ts';
|
|
3
|
+
export type { StageOrigin, StagePort } from './host.ts';
|
|
4
|
+
export { OFFLINE_DATA_ID, OFFLINE_RUNTIME_ID, fromBase64, offlineDataText, readOfflineData, toBase64 } from './offline/data.ts';
|
|
5
|
+
export type { OfflineAsset, OfflineData, OfflineFilm } from './offline/data.ts';
|
|
6
|
+
export { OFFLINE_AUDIO_GLOBAL } from './offline/audio.ts';
|
|
7
|
+
export type { ScorePlayer, ScorePlayerFactory } from './offline/audio.ts';
|
|
8
|
+
export { mountPlayer } from './offline/player.ts';
|
|
9
|
+
export type { OfflinePlayer, PlayerOptions } from './offline/player.ts';
|
|
10
|
+
export { findLayer, flattenLayers, hitTestLayers, isLayerOnAt, layerTree } from './layers.ts';
|
|
11
|
+
export type { LayerHitTest, PlacedLayer } from './layers.ts';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./protocol.js";
|
|
2
|
+
export { SAME_ORIGIN_STAGE_POLICY, SAME_ORIGIN_STAGE_SANDBOX, STAGE_PERMISSIONS, STAGE_SANDBOX, openStagePort, stageDocument, stageSandbox, stageTargetOrigin, } from "./host.js";
|
|
3
|
+
export { OFFLINE_DATA_ID, OFFLINE_RUNTIME_ID, fromBase64, offlineDataText, readOfflineData, toBase64 } from "./offline/data.js";
|
|
4
|
+
export { OFFLINE_AUDIO_GLOBAL } from "./offline/audio.js";
|
|
5
|
+
export { mountPlayer } from "./offline/player.js";
|
|
6
|
+
export { findLayer, flattenLayers, hitTestLayers, isLayerOnAt, layerTree } from "./layers.js";
|
package/src/layers.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LayerRow } from './protocol.ts';
|
|
2
|
+
/** A row with the rows that hold it, outermost first. */
|
|
3
|
+
export interface PlacedLayer {
|
|
4
|
+
row: LayerRow;
|
|
5
|
+
ups: LayerRow[];
|
|
6
|
+
}
|
|
7
|
+
/** Every row of a report, each before what it holds, with the rows that hold it. */
|
|
8
|
+
export declare function layerTree(rows: readonly LayerRow[] | null, ups?: LayerRow[]): PlacedLayer[];
|
|
9
|
+
/** Every row of a report, each before what it holds. */
|
|
10
|
+
export declare const flattenLayers: (rows: readonly LayerRow[] | null) => LayerRow[];
|
|
11
|
+
export declare const findLayer: (rows: readonly LayerRow[] | null, id: string | null) => LayerRow | null;
|
|
12
|
+
/** Whether a row is on the picture at a played moment. */
|
|
13
|
+
export declare const isLayerOnAt: (row: LayerRow, t: number) => boolean;
|
|
14
|
+
export interface LayerHitTest {
|
|
15
|
+
/** A point on the picture, in film pixels. */
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
/** The innermost row under the point, at once, as a press with a modifier picks. */
|
|
19
|
+
deep: boolean;
|
|
20
|
+
/** How far outside a row's box, in film pixels, a press still finds it when none is found inside one. */
|
|
21
|
+
slack: number;
|
|
22
|
+
/** A row of things alike whose box is this area or less is picked whole, not passed over to what it holds. */
|
|
23
|
+
small: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The row a press at a point picks. A row that only holds others (a pack, a group) is passed over to what it holds.
|
|
27
|
+
* A first press picks the outermost row under the point; pressing again where the selected row, or one it holds,
|
|
28
|
+
* lies goes one level further in. Of rows that overlap, the smallest wins.
|
|
29
|
+
*/
|
|
30
|
+
export declare function hitTestLayers(rows: readonly LayerRow[] | null, selected: string | null, at: LayerHitTest): LayerRow | null;
|
package/src/layers.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Every row of a report, each before what it holds, with the rows that hold it. */
|
|
2
|
+
export function layerTree(rows, ups = []) {
|
|
3
|
+
return (rows ?? []).flatMap((row) => [{ row, ups }, ...layerTree(row.kids, [...ups, row])]);
|
|
4
|
+
}
|
|
5
|
+
/** Every row of a report, each before what it holds. */
|
|
6
|
+
export const flattenLayers = (rows) => layerTree(rows).map((placed) => placed.row);
|
|
7
|
+
export const findLayer = (rows, id) => (id === null ? null : (flattenLayers(rows).find((row) => row.id === id) ?? null));
|
|
8
|
+
/** Whether a row is on the picture at a played moment. */
|
|
9
|
+
export const isLayerOnAt = (row, t) => row.spans.some(([from, to]) => t >= from - 0.001 && t < to + 0.001);
|
|
10
|
+
const area = (row) => (row.box ? row.box[2] * row.box[3] : Infinity);
|
|
11
|
+
/**
|
|
12
|
+
* The row a press at a point picks. A row that only holds others (a pack, a group) is passed over to what it holds.
|
|
13
|
+
* A first press picks the outermost row under the point; pressing again where the selected row, or one it holds,
|
|
14
|
+
* lies goes one level further in. Of rows that overlap, the smallest wins.
|
|
15
|
+
*/
|
|
16
|
+
export function hitTestLayers(rows, selected, at) {
|
|
17
|
+
const { x, y, deep, slack, small } = at;
|
|
18
|
+
const smallest = (some) => some.sort((a, b) => area(a) - area(b))[0] ?? null;
|
|
19
|
+
const holder = (row, whole) => row.kids.length > 0 && (row.many > 0 ? row.kids.length >= row.many : row.drawn === 'group') && !(whole && row.box !== null && row.box[2] * row.box[3] <= small);
|
|
20
|
+
const under = (row, give, whole) => {
|
|
21
|
+
const box = row.box;
|
|
22
|
+
return (row.kind !== 'ground' &&
|
|
23
|
+
!row.full &&
|
|
24
|
+
row.hidden === false &&
|
|
25
|
+
box !== null &&
|
|
26
|
+
x >= box[0] - give &&
|
|
27
|
+
x < box[0] + box[2] + give &&
|
|
28
|
+
y >= box[1] - give &&
|
|
29
|
+
y < box[1] + box[3] + give &&
|
|
30
|
+
(!holder(row, whole) || row.kids.some((kid) => under(kid, give, whole))));
|
|
31
|
+
};
|
|
32
|
+
const open = (some, whole) => some.flatMap((row) => row.kids.length === 0
|
|
33
|
+
? [row]
|
|
34
|
+
: row.full || row.drawn === 'drawing' || (holder(row, whole) && (whole || row.many > 0))
|
|
35
|
+
? open(row.kids, whole)
|
|
36
|
+
: row.many > 0
|
|
37
|
+
? [row, ...open(row.kids, whole)]
|
|
38
|
+
: [row]);
|
|
39
|
+
const tries = [
|
|
40
|
+
[0, false],
|
|
41
|
+
[slack, false],
|
|
42
|
+
[0, true],
|
|
43
|
+
];
|
|
44
|
+
const hits = (some) => tries.reduce((found, [give, whole]) => (found.length ? found : open(some, whole).filter((row) => under(row, give, whole))), []);
|
|
45
|
+
const inmost = (some) => hits(some).flatMap((row) => {
|
|
46
|
+
const inner = inmost(row.kids);
|
|
47
|
+
return inner.length ? inner : [row];
|
|
48
|
+
});
|
|
49
|
+
if (deep)
|
|
50
|
+
return smallest(inmost(rows ?? []));
|
|
51
|
+
const path = [];
|
|
52
|
+
for (let row = smallest(hits(rows ?? [])); row; row = smallest(hits(row.kids)))
|
|
53
|
+
path.push(row);
|
|
54
|
+
const last = path.map((row) => row.id === selected || flattenLayers(row.kids).some((kid) => kid.id === selected)).lastIndexOf(true);
|
|
55
|
+
return path[Math.min(last + 1, path.length - 1)] ?? null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PlaySeconds } from '@open-artifact/motion-core';
|
|
2
|
+
import type { NarrationReport, PlayedScore } from '../protocol.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The sound of a standalone film, given to the player from outside: the stage records the score and reads the
|
|
5
|
+
* narration, and the player plays neither itself. With none, the film plays silent.
|
|
6
|
+
*/
|
|
7
|
+
export interface ScorePlayer {
|
|
8
|
+
/** Once the film is ready, with its sound as played. */
|
|
9
|
+
prepare(score: PlayedScore | null, narration: NarrationReport | null, duration: PlaySeconds): Promise<void>;
|
|
10
|
+
/** Called from a click, which a browser asks for before it makes a sound. */
|
|
11
|
+
start(t: PlaySeconds): void;
|
|
12
|
+
stop(): void;
|
|
13
|
+
/** Played time by the sound's own clock while it plays, which the picture follows; null while silent. */
|
|
14
|
+
now(): PlaySeconds | null;
|
|
15
|
+
}
|
|
16
|
+
export type ScorePlayerFactory = () => ScorePlayer;
|
|
17
|
+
/** The global a standalone page's audio script sets, before the player's script runs. */
|
|
18
|
+
export declare const OFFLINE_AUDIO_GLOBAL = "filmAudio";
|
|
19
|
+
export declare function injectedAudio(): ScorePlayer | null;
|