@open-artifact/motion-stage 0.0.0-stage → 0.12.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.
Files changed (173) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +5 -2
  4. package/package.json +69 -4
  5. package/src/build.d.ts +18 -0
  6. package/src/build.js +73 -0
  7. package/src/host.d.ts +37 -0
  8. package/src/host.js +76 -0
  9. package/src/index.d.ts +11 -0
  10. package/src/index.js +6 -0
  11. package/src/layers.d.ts +30 -0
  12. package/src/layers.js +56 -0
  13. package/src/offline/audio.d.ts +19 -0
  14. package/src/offline/audio.js +20 -0
  15. package/src/offline/data.d.ts +26 -0
  16. package/src/offline/data.js +71 -0
  17. package/src/offline/main.d.ts +9 -0
  18. package/src/offline/main.js +52 -0
  19. package/src/offline/player.d.ts +23 -0
  20. package/src/offline/player.js +155 -0
  21. package/src/protocol/guards.d.ts +6 -0
  22. package/src/protocol/guards.js +208 -0
  23. package/src/protocol/layer-guards.d.ts +7 -0
  24. package/src/protocol/layer-guards.js +97 -0
  25. package/src/protocol/layers.d.ts +123 -0
  26. package/src/protocol/layers.js +1 -0
  27. package/src/protocol/types.d.ts +261 -0
  28. package/src/protocol/types.js +7 -0
  29. package/src/protocol.d.ts +2 -0
  30. package/src/protocol.js +2 -0
  31. package/src/raster.d.ts +4 -0
  32. package/src/raster.js +2 -0
  33. package/src/runtime/assets.d.ts +19 -0
  34. package/src/runtime/assets.js +63 -0
  35. package/src/runtime/captions.d.ts +26 -0
  36. package/src/runtime/captions.js +103 -0
  37. package/src/runtime/console.d.ts +13 -0
  38. package/src/runtime/console.js +99 -0
  39. package/src/runtime/cut.d.ts +7 -0
  40. package/src/runtime/cut.js +63 -0
  41. package/src/runtime/determinism.d.ts +12 -0
  42. package/src/runtime/determinism.js +47 -0
  43. package/src/runtime/film.d.ts +40 -0
  44. package/src/runtime/film.js +29 -0
  45. package/src/runtime/focus.d.ts +8 -0
  46. package/src/runtime/focus.js +71 -0
  47. package/src/runtime/fonts.d.ts +22 -0
  48. package/src/runtime/fonts.js +109 -0
  49. package/src/runtime/frame.d.ts +9 -0
  50. package/src/runtime/frame.js +123 -0
  51. package/src/runtime/kit/camera.d.ts +40 -0
  52. package/src/runtime/kit/camera.js +56 -0
  53. package/src/runtime/kit/chip.d.ts +25 -0
  54. package/src/runtime/kit/chip.js +75 -0
  55. package/src/runtime/kit/cursor.d.ts +46 -0
  56. package/src/runtime/kit/cursor.js +108 -0
  57. package/src/runtime/kit/dom.d.ts +14 -0
  58. package/src/runtime/kit/dom.js +46 -0
  59. package/src/runtime/kit/geometry.d.ts +22 -0
  60. package/src/runtime/kit/geometry.js +46 -0
  61. package/src/runtime/kit/index.d.ts +95 -0
  62. package/src/runtime/kit/index.js +149 -0
  63. package/src/runtime/kit/mark-strokes.d.ts +65 -0
  64. package/src/runtime/kit/mark-strokes.js +226 -0
  65. package/src/runtime/kit/marks.d.ts +21 -0
  66. package/src/runtime/kit/marks.js +165 -0
  67. package/src/runtime/kit/math.d.ts +23 -0
  68. package/src/runtime/kit/math.js +35 -0
  69. package/src/runtime/kit/paper.d.ts +7 -0
  70. package/src/runtime/kit/paper.js +27 -0
  71. package/src/runtime/kit/random.d.ts +8 -0
  72. package/src/runtime/kit/random.js +32 -0
  73. package/src/runtime/kit/text-fx.d.ts +18 -0
  74. package/src/runtime/kit/text-fx.js +55 -0
  75. package/src/runtime/kit/typing.d.ts +21 -0
  76. package/src/runtime/kit/typing.js +42 -0
  77. package/src/runtime/layers/describe.d.ts +41 -0
  78. package/src/runtime/layers/describe.js +327 -0
  79. package/src/runtime/layers/item.d.ts +121 -0
  80. package/src/runtime/layers/item.js +149 -0
  81. package/src/runtime/layers/parts.d.ts +50 -0
  82. package/src/runtime/layers/parts.js +155 -0
  83. package/src/runtime/layers/rows.d.ts +4 -0
  84. package/src/runtime/layers/rows.js +233 -0
  85. package/src/runtime/layers/scan.d.ts +24 -0
  86. package/src/runtime/layers/scan.js +202 -0
  87. package/src/runtime/layers/walk.d.ts +16 -0
  88. package/src/runtime/layers/walk.js +333 -0
  89. package/src/runtime/load.d.ts +10 -0
  90. package/src/runtime/load.js +228 -0
  91. package/src/runtime/main.d.ts +1 -0
  92. package/src/runtime/main.js +69 -0
  93. package/src/runtime/modules.d.ts +23 -0
  94. package/src/runtime/modules.js +53 -0
  95. package/src/runtime/port.d.ts +8 -0
  96. package/src/runtime/port.js +46 -0
  97. package/src/runtime/questions.d.ts +24 -0
  98. package/src/runtime/questions.js +162 -0
  99. package/src/runtime/recut.d.ts +35 -0
  100. package/src/runtime/recut.js +158 -0
  101. package/src/runtime/render.d.ts +80 -0
  102. package/src/runtime/render.js +342 -0
  103. package/src/runtime/retouch/ask.d.ts +17 -0
  104. package/src/runtime/retouch/ask.js +156 -0
  105. package/src/runtime/retouch/entry.d.ts +77 -0
  106. package/src/runtime/retouch/entry.js +1 -0
  107. package/src/runtime/retouch/judge.d.ts +25 -0
  108. package/src/runtime/retouch/judge.js +209 -0
  109. package/src/runtime/retouch/look.d.ts +39 -0
  110. package/src/runtime/retouch/look.js +135 -0
  111. package/src/runtime/retouch/parts.d.ts +22 -0
  112. package/src/runtime/retouch/parts.js +166 -0
  113. package/src/runtime/retouch/retouch.d.ts +37 -0
  114. package/src/runtime/retouch/retouch.js +238 -0
  115. package/src/runtime/retouch/seat.d.ts +40 -0
  116. package/src/runtime/retouch/seat.js +228 -0
  117. package/src/runtime/retouch/state.d.ts +37 -0
  118. package/src/runtime/retouch/state.js +153 -0
  119. package/src/runtime/retouch/type-style.d.ts +19 -0
  120. package/src/runtime/retouch/type-style.js +111 -0
  121. package/src/runtime/scan.d.ts +2 -0
  122. package/src/runtime/scan.js +49 -0
  123. package/src/runtime/scenes/card.d.ts +12 -0
  124. package/src/runtime/scenes/card.js +56 -0
  125. package/src/runtime/scenes/install.d.ts +47 -0
  126. package/src/runtime/scenes/install.js +387 -0
  127. package/src/runtime/scenes/read.d.ts +15 -0
  128. package/src/runtime/scenes/read.js +57 -0
  129. package/src/runtime/scenes/scoped.d.ts +13 -0
  130. package/src/runtime/scenes/scoped.js +40 -0
  131. package/src/runtime/score.d.ts +26 -0
  132. package/src/runtime/score.js +221 -0
  133. package/src/runtime/sketch/pen.d.ts +3 -0
  134. package/src/runtime/sketch/pen.js +371 -0
  135. package/src/runtime/sketch/strokes.d.ts +41 -0
  136. package/src/runtime/sketch/strokes.js +187 -0
  137. package/src/runtime/snapshot/draw.d.ts +14 -0
  138. package/src/runtime/snapshot/draw.js +125 -0
  139. package/src/runtime/snapshot/hold-first-draw.d.ts +12 -0
  140. package/src/runtime/snapshot/hold-first-draw.js +128 -0
  141. package/src/runtime/snapshot/plate.d.ts +20 -0
  142. package/src/runtime/snapshot/plate.js +79 -0
  143. package/src/runtime/snapshot/serialize.d.ts +49 -0
  144. package/src/runtime/snapshot/serialize.js +271 -0
  145. package/src/runtime/snapshot/styles.d.ts +8 -0
  146. package/src/runtime/snapshot/styles.js +109 -0
  147. package/src/runtime/snapshot/xml.d.ts +6 -0
  148. package/src/runtime/snapshot/xml.js +110 -0
  149. package/src/runtime/stage-size.d.ts +7 -0
  150. package/src/runtime/stage-size.js +3 -0
  151. package/src/runtime/stage.d.ts +27 -0
  152. package/src/runtime/stage.js +154 -0
  153. package/src/runtime/stretch.d.ts +13 -0
  154. package/src/runtime/stretch.js +16 -0
  155. package/src/runtime/texts.d.ts +24 -0
  156. package/src/runtime/texts.js +210 -0
  157. package/src/runtime/video-sync.d.ts +26 -0
  158. package/src/runtime/video-sync.js +126 -0
  159. package/src/stills.d.ts +41 -0
  160. package/src/stills.js +253 -0
  161. package/src/tools/film.d.ts +13 -0
  162. package/src/tools/film.js +116 -0
  163. package/src/tools/main.d.ts +1 -0
  164. package/src/tools/main.js +216 -0
  165. package/src/tools/score.d.ts +4 -0
  166. package/src/tools/score.js +29 -0
  167. package/src/tools/types.d.ts +69 -0
  168. package/src/tools/types.js +2 -0
  169. package/src/tools.d.ts +5 -0
  170. package/src/tools.js +3 -0
  171. package/src/virtual.d.ts +11 -0
  172. package/src/vite.d.ts +8 -0
  173. package/src/vite.js +43 -0
@@ -0,0 +1,69 @@
1
+ import type { PlaySeconds, ScoreTempo } from '@open-artifact/motion-core';
2
+ import type { ConsoleLevel, ErrorPhase, RenderMode, StageMeta } from '../protocol.ts';
3
+ /** The global the tools page sets: `window.filmTools`. */
4
+ export declare const TOOLS_GLOBAL = "filmTools";
5
+ /**
6
+ * A video artifact's film as it lies on disk: the documents under `db/` and the uploads under `_blobs/`.
7
+ * `documents` is keyed by path under `db/` without `.json` (`film/meta`, `film/script`, `modules/scenes.json`,
8
+ * `assets/logo.png`); each value is the file's JSON text or the value it parses to. `blobs` is keyed by upload id
9
+ * (the 32 hex digits of `_blob/<id>`), each the file's bytes as base64.
10
+ */
11
+ export interface ToolsFiles {
12
+ documents: Record<string, unknown>;
13
+ blobs?: Record<string, string>;
14
+ /** final (the default): every written scene draws as it is, as in an export. rough: rough scenes draw as sketches. */
15
+ mode?: RenderMode;
16
+ }
17
+ export interface ToolsLoaded {
18
+ meta: StageMeta;
19
+ /** What of the film the player drops or cannot have (unreadable documents, missing uploads, records not applied). */
20
+ problems: string[];
21
+ }
22
+ export interface ToolsFailed {
23
+ error: {
24
+ message: string;
25
+ };
26
+ problems: string[];
27
+ }
28
+ export type ToolsLoad = ToolsLoaded | ToolsFailed;
29
+ export interface ToolsFrameOptions {
30
+ /** Times the film's own size: 0.5 makes a 960 × 540 PNG of a 1080p film. 1 by default. */
31
+ scale?: number;
32
+ }
33
+ /** The stage's console and the film's errors since the last load, in order. */
34
+ export interface ToolsLogLine {
35
+ level: ConsoleLevel;
36
+ text: string;
37
+ /** Set on the film's own errors: whether loading or a render threw. */
38
+ phase?: ErrorPhase;
39
+ }
40
+ /** The score `kit.score` recorded, counted, and the narration's lines. */
41
+ export interface ScoreReport {
42
+ events: number;
43
+ notes: number;
44
+ drums: number;
45
+ fx: number;
46
+ /** `kind:patch` of events whose patch the player has no voice for: they play as silence. */
47
+ unknown: string[];
48
+ /** When the first sound starts and the last ends, played seconds. */
49
+ first: PlaySeconds;
50
+ last: PlaySeconds;
51
+ tempo: ScoreTempo | null;
52
+ /** null: the film has no narration (or this page reads none). */
53
+ narration: {
54
+ lines: number;
55
+ seconds: number;
56
+ } | null;
57
+ }
58
+ /** What the tools page sets as `window.filmTools`. Every call that waits returns a promise. */
59
+ export interface FilmTools {
60
+ version: 1;
61
+ load(files: ToolsFiles): Promise<ToolsLoad>;
62
+ /** Shows the film at `t` (played seconds) and resolves once it is on show. */
63
+ seek(t: number): Promise<void>;
64
+ /** The frame at `t` as an export draws it (the stage's snapshot, rastered), as a PNG data URL. */
65
+ frame(t: number, options?: ToolsFrameOptions): Promise<string>;
66
+ /** null before a load succeeds. */
67
+ scoreReport(): ScoreReport | null;
68
+ consoleLog(): ToolsLogLine[];
69
+ }
@@ -0,0 +1,2 @@
1
+ /** The global the tools page sets: `window.filmTools`. */
2
+ export const TOOLS_GLOBAL = 'filmTools';
package/src/tools.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { TOOLS_GLOBAL } from './tools/types.ts';
2
+ export type { FilmTools, ScoreReport, ToolsFailed, ToolsFiles, ToolsFrameOptions, ToolsLoad, ToolsLoaded, ToolsLogLine } from './tools/types.ts';
3
+ export { toolsFilm } from './tools/film.ts';
4
+ export type { ToolsFilm } from './tools/film.ts';
5
+ export { scoreReport } from './tools/score.ts';
package/src/tools.js ADDED
@@ -0,0 +1,3 @@
1
+ export { TOOLS_GLOBAL } from "./tools/types.js";
2
+ export { toolsFilm } from "./tools/film.js";
3
+ export { scoreReport } from "./tools/score.js";
@@ -0,0 +1,11 @@
1
+ /** The stage runtime's script text, from the `motionStageRuntime()` Vite plugin. */
2
+ declare module 'virtual:motion-stage-runtime' {
3
+ const runtime: string;
4
+ export default runtime;
5
+ }
6
+
7
+ /** The standalone player's script text (it mounts the runtime the page keeps), from the `motionStageRuntime()` Vite plugin. */
8
+ declare module 'virtual:motion-stage-player' {
9
+ const player: string;
10
+ export default player;
11
+ }
package/src/vite.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare const STAGE_RUNTIME_MODULE = "virtual:motion-stage-runtime";
3
+ export declare const STAGE_PLAYER_MODULE = "virtual:motion-stage-player";
4
+ /**
5
+ * Gives the page the stage runtime as a string, `import runtime from 'virtual:motion-stage-runtime'`, and the
6
+ * standalone player a saved page runs, `import player from 'virtual:motion-stage-player'`.
7
+ */
8
+ export declare function motionStageRuntime(): Plugin;
package/src/vite.js ADDED
@@ -0,0 +1,43 @@
1
+ import { buildOfflinePlayer, buildStageRuntimeFresh } from "./build.js";
2
+ export const STAGE_RUNTIME_MODULE = 'virtual:motion-stage-runtime';
3
+ export const STAGE_PLAYER_MODULE = 'virtual:motion-stage-player';
4
+ const RESOLVED = '\0' + STAGE_RUNTIME_MODULE;
5
+ const RESOLVED_PLAYER = '\0' + STAGE_PLAYER_MODULE;
6
+ /**
7
+ * Gives the page the stage runtime as a string, `import runtime from 'virtual:motion-stage-runtime'`, and the
8
+ * standalone player a saved page runs, `import player from 'virtual:motion-stage-player'`.
9
+ */
10
+ export function motionStageRuntime() {
11
+ let watched = new Set();
12
+ return {
13
+ name: 'motion-stage-runtime',
14
+ resolveId(id) {
15
+ if (id === STAGE_RUNTIME_MODULE)
16
+ return RESOLVED;
17
+ if (id === STAGE_PLAYER_MODULE)
18
+ return RESOLVED_PLAYER;
19
+ return null;
20
+ },
21
+ async load(id) {
22
+ if (id === RESOLVED_PLAYER)
23
+ return 'export default ' + JSON.stringify(await buildOfflinePlayer()) + ';\n';
24
+ if (id !== RESOLVED)
25
+ return null;
26
+ const built = await buildStageRuntimeFresh();
27
+ watched = new Set(built.inputs);
28
+ for (const input of built.inputs)
29
+ this.addWatchFile(input);
30
+ return 'export default ' + JSON.stringify(built.script) + ';\n';
31
+ },
32
+ // A runtime source is not in the page's module graph: its change makes the virtual module stale by hand.
33
+ handleHotUpdate({ file, server }) {
34
+ if (!watched.has(file))
35
+ return;
36
+ const module = server.moduleGraph.getModuleById(RESOLVED);
37
+ if (!module)
38
+ return;
39
+ server.moduleGraph.invalidateModule(module);
40
+ return [module];
41
+ },
42
+ };
43
+ }