@openartifactsai/motion-stage 0.0.0-stage → 0.23.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 +70 -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 +157 -0
- package/src/protocol/clip-guards.d.ts +5 -0
- package/src/protocol/clip-guards.js +22 -0
- package/src/protocol/guards.d.ts +6 -0
- package/src/protocol/guards.js +257 -0
- package/src/protocol/layer-guards.d.ts +7 -0
- package/src/protocol/layer-guards.js +100 -0
- package/src/protocol/layers.d.ts +135 -0
- package/src/protocol/layers.js +1 -0
- package/src/protocol/types.d.ts +340 -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/caption-box.d.ts +3 -0
- package/src/runtime/caption-box.js +16 -0
- package/src/runtime/captions.d.ts +31 -0
- package/src/runtime/captions.js +115 -0
- package/src/runtime/clip-captions.d.ts +9 -0
- package/src/runtime/clip-captions.js +27 -0
- package/src/runtime/clips.d.ts +83 -0
- package/src/runtime/clips.js +259 -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 +43 -0
- package/src/runtime/film.js +31 -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 +140 -0
- package/src/runtime/fx/backdrop.d.ts +60 -0
- package/src/runtime/fx/backdrop.js +264 -0
- package/src/runtime/fx/color.d.ts +19 -0
- package/src/runtime/fx/color.js +84 -0
- package/src/runtime/fx/css-color.d.ts +6 -0
- package/src/runtime/fx/css-color.js +44 -0
- package/src/runtime/fx/curve.d.ts +12 -0
- package/src/runtime/fx/curve.js +34 -0
- package/src/runtime/fx/gl.d.ts +29 -0
- package/src/runtime/fx/gl.js +207 -0
- package/src/runtime/fx/glsl.d.ts +35 -0
- package/src/runtime/fx/glsl.js +113 -0
- package/src/runtime/fx/index.d.ts +23 -0
- package/src/runtime/fx/index.js +151 -0
- package/src/runtime/fx/key.d.ts +11 -0
- package/src/runtime/fx/key.js +21 -0
- package/src/runtime/fx/numbers.d.ts +14 -0
- package/src/runtime/fx/numbers.js +57 -0
- package/src/runtime/fx/pace.d.ts +17 -0
- package/src/runtime/fx/pace.js +26 -0
- package/src/runtime/fx/paint.d.ts +28 -0
- package/src/runtime/fx/paint.js +150 -0
- package/src/runtime/guard.d.ts +4 -0
- package/src/runtime/guard.js +141 -0
- package/src/runtime/hand-titles/index.d.ts +9 -0
- package/src/runtime/hand-titles/index.js +73 -0
- package/src/runtime/hand-titles/layer.d.ts +20 -0
- package/src/runtime/hand-titles/layer.js +118 -0
- package/src/runtime/hand-titles/place.d.ts +27 -0
- package/src/runtime/hand-titles/place.js +45 -0
- package/src/runtime/held-store.d.ts +35 -0
- package/src/runtime/held-store.js +63 -0
- package/src/runtime/held.d.ts +19 -0
- package/src/runtime/held.js +225 -0
- package/src/runtime/kit/camera.d.ts +59 -0
- package/src/runtime/kit/camera.js +81 -0
- package/src/runtime/kit/chip.d.ts +25 -0
- package/src/runtime/kit/chip.js +75 -0
- package/src/runtime/kit/count.d.ts +37 -0
- package/src/runtime/kit/count.js +100 -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 +24 -0
- package/src/runtime/kit/geometry.js +56 -0
- package/src/runtime/kit/index.d.ts +113 -0
- package/src/runtime/kit/index.js +157 -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/laid/layer.d.ts +44 -0
- package/src/runtime/laid/layer.js +370 -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 +123 -0
- package/src/runtime/layers/item.js +150 -0
- package/src/runtime/layers/parts.d.ts +53 -0
- package/src/runtime/layers/parts.js +158 -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 +204 -0
- package/src/runtime/layers/walk.d.ts +16 -0
- package/src/runtime/layers/walk.js +337 -0
- package/src/runtime/load.d.ts +10 -0
- package/src/runtime/load.js +267 -0
- package/src/runtime/main.d.ts +1 -0
- package/src/runtime/main.js +90 -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 +81 -0
- package/src/runtime/recut.js +325 -0
- package/src/runtime/render.d.ts +80 -0
- package/src/runtime/render.js +358 -0
- package/src/runtime/retouch/ask.d.ts +17 -0
- package/src/runtime/retouch/ask.js +171 -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/own-styles.d.ts +19 -0
- package/src/runtime/retouch/own-styles.js +141 -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 +69 -0
- package/src/runtime/scenes/install.js +528 -0
- package/src/runtime/scenes/read.d.ts +27 -0
- package/src/runtime/scenes/read.js +73 -0
- package/src/runtime/scenes/scoped.d.ts +13 -0
- package/src/runtime/scenes/scoped.js +46 -0
- package/src/runtime/score.d.ts +32 -0
- package/src/runtime/score.js +262 -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/lift.d.ts +41 -0
- package/src/runtime/snapshot/lift.js +161 -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 +51 -0
- package/src/runtime/snapshot/serialize.js +286 -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 +211 -0
- package/src/runtime/video-sync.d.ts +51 -0
- package/src/runtime/video-sync.js +218 -0
- package/src/stills.d.ts +90 -0
- package/src/stills.js +329 -0
- package/src/tools/film.d.ts +13 -0
- package/src/tools/film.js +116 -0
- package/src/tools/levels.d.ts +8 -0
- package/src/tools/levels.js +28 -0
- package/src/tools/main.d.ts +1 -0
- package/src/tools/main.js +223 -0
- package/src/tools/score.d.ts +4 -0
- package/src/tools/score.js +35 -0
- package/src/tools/types.d.ts +84 -0
- package/src/tools/types.js +2 -0
- package/src/tools.d.ts +6 -0
- package/src/tools.js +4 -0
- package/src/virtual.d.ts +11 -0
- package/src/vite.d.ts +8 -0
- package/src/vite.js +43 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { MAX_RETOUCHED_LAYERS, RETOUCH_PROPERTIES, TEXT_ALIGNS, isRetouchParts, parseRetouchLayer } from '@openartifactsai/motion-core';
|
|
2
|
+
const isFields = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
3
|
+
const isNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
4
|
+
const isString = (value) => typeof value === 'string';
|
|
5
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
6
|
+
const isNullable = (value, is) => value === null || is(value);
|
|
7
|
+
const isListOf = (value, is) => Array.isArray(value) && value.every(is);
|
|
8
|
+
const isNumberPair = (value) => Array.isArray(value) && value.length === 2 && value.every(isNumber);
|
|
9
|
+
const isBox = (value) => Array.isArray(value) && value.length === 4 && value.every(isNumber);
|
|
10
|
+
const COLOR = /^#[0-9a-f]{6}([0-9a-f]{2})?$/;
|
|
11
|
+
const isColor = (value) => isString(value) && COLOR.test(value);
|
|
12
|
+
const isOneOf = (all) => (value) => isString(value) && all.includes(value);
|
|
13
|
+
const LAYER_KINDS = ['ground', 'group', 'shape', 'image', 'text'];
|
|
14
|
+
const LAYER_DRAWN = ['', 'graphic', 'drawing', 'group', 'line', 'path', 'polygon'];
|
|
15
|
+
const LAYER_EFFECTS = ['fade', 'grow', 'left', 'right', 'top', 'bottom'];
|
|
16
|
+
const PROPERTIES = RETOUCH_PROPERTIES;
|
|
17
|
+
const ALIGNS = TEXT_ALIGNS;
|
|
18
|
+
const OWN_TEXT_STYLES = ['weight', 'italic', 'px', 'tracking', 'ink'];
|
|
19
|
+
function isMotion(value) {
|
|
20
|
+
return isFields(value) && isNullable(value['how'], (how) => isListOf(how, isOneOf(LAYER_EFFECTS))) && isNumber(value['from']) && isNumber(value['to']);
|
|
21
|
+
}
|
|
22
|
+
function isLayerLook(value) {
|
|
23
|
+
return (isFields(value) &&
|
|
24
|
+
isString(value['cls']) &&
|
|
25
|
+
isNullable(value['kin'], isString) &&
|
|
26
|
+
(value['parts'] === undefined || isRetouchParts(value['parts'])) &&
|
|
27
|
+
isNumber(value['at']) &&
|
|
28
|
+
['fill', 'ink', 'svgfill', 'svgstroke'].every((key) => isNullable(value[key], isColor)) &&
|
|
29
|
+
isNullable(value['radius'], isNumber) &&
|
|
30
|
+
isNumber(value['most']) &&
|
|
31
|
+
isNullable(value['size'], isNumber) &&
|
|
32
|
+
(value['hidden'] === 0 || value['hidden'] === null) &&
|
|
33
|
+
(value['filled'] === undefined || value['filled'] === true) &&
|
|
34
|
+
isNullable(value['entry'], isString) &&
|
|
35
|
+
isBoolean(value['loose']) &&
|
|
36
|
+
isBoolean(value['home']) &&
|
|
37
|
+
isListOf(value['lapsed'], isOneOf(PROPERTIES)));
|
|
38
|
+
}
|
|
39
|
+
export function isLayerRow(value) {
|
|
40
|
+
return (isFields(value) &&
|
|
41
|
+
isString(value['id']) &&
|
|
42
|
+
isOneOf(LAYER_KINDS)(value['kind']) &&
|
|
43
|
+
isBoolean(value['round']) &&
|
|
44
|
+
isString(value['name']) &&
|
|
45
|
+
(value['hidden'] === 'held' || value['hidden'] === 'own' || value['hidden'] === false) &&
|
|
46
|
+
isNullable(value['under'], isString) &&
|
|
47
|
+
isBoolean(value['own']) &&
|
|
48
|
+
isNumber(value['many']) &&
|
|
49
|
+
isListOf(value['texts'], isString) &&
|
|
50
|
+
isListOf(value['spans'], isNumberPair) &&
|
|
51
|
+
isNumber(value['at']) &&
|
|
52
|
+
isMotion(value['enter']) &&
|
|
53
|
+
isMotion(value['leave']) &&
|
|
54
|
+
isNullable(value['box'], isBox) &&
|
|
55
|
+
isNullable(value['wordsBox'], isBox) &&
|
|
56
|
+
isNullable(value['look'], isLayerLook) &&
|
|
57
|
+
isListOf(value['kids'], isLayerRow) &&
|
|
58
|
+
isNullable(value['sole'], isLayerRow) &&
|
|
59
|
+
isBoolean(value['whole']) &&
|
|
60
|
+
isOneOf(LAYER_DRAWN)(value['drawn']) &&
|
|
61
|
+
isBoolean(value['full']));
|
|
62
|
+
}
|
|
63
|
+
export function isLayersReport(value) {
|
|
64
|
+
return (isFields(value) &&
|
|
65
|
+
isNumber(value['seq']) &&
|
|
66
|
+
isNumber(value['from']) &&
|
|
67
|
+
isNumber(value['to']) &&
|
|
68
|
+
isNumber(value['at']) &&
|
|
69
|
+
isListOf(value['lost'], isString) &&
|
|
70
|
+
isListOf(value['underHide'], isString) &&
|
|
71
|
+
isNullable(value['rows'], (rows) => isListOf(rows, isLayerRow)));
|
|
72
|
+
}
|
|
73
|
+
export function isAskedLook(value) {
|
|
74
|
+
return (isFields(value) &&
|
|
75
|
+
isNullable(value['weight'], isNumber) &&
|
|
76
|
+
(value['italic'] === 0 || value['italic'] === 1 || value['italic'] === null) &&
|
|
77
|
+
isNullable(value['px'], isNumber) &&
|
|
78
|
+
(value['leading'] === 'normal' || isNullable(value['leading'], isNumber)) &&
|
|
79
|
+
isNullable(value['tracking'], isNumber) &&
|
|
80
|
+
isNullable(value['align'], isOneOf(ALIGNS)) &&
|
|
81
|
+
isString(value['cls']) &&
|
|
82
|
+
isNullable(value['kin'], isString) &&
|
|
83
|
+
isNumber(value['at']) &&
|
|
84
|
+
isNullable(value['fill'], isColor) &&
|
|
85
|
+
isNullable(value['ink'], isColor) &&
|
|
86
|
+
isNullable(value['radius'], isNumber) &&
|
|
87
|
+
isNumber(value['most']) &&
|
|
88
|
+
isNullable(value['size'], isNumber) &&
|
|
89
|
+
(value['hidden'] === 0 || value['hidden'] === null) &&
|
|
90
|
+
isNullable(value['entry'], isString) &&
|
|
91
|
+
isBoolean(value['home']) &&
|
|
92
|
+
isListOf(value['lapsed'], isOneOf(PROPERTIES)) &&
|
|
93
|
+
isString(value['family']) &&
|
|
94
|
+
(value['own'] === undefined || isListOf(value['own'], isOneOf(OWN_TEXT_STYLES))) &&
|
|
95
|
+
(value['linePx'] === undefined || (isNumber(value['linePx']) && value['linePx'] > 0)));
|
|
96
|
+
}
|
|
97
|
+
/** A record as `parseRetouchedRecord` gives it: each entry one the player would keep. The frame parses it again. */
|
|
98
|
+
export function isRetouchedRecord(value) {
|
|
99
|
+
return isFields(value) && Array.isArray(value['layers']) && value['layers'].length <= MAX_RETOUCHED_LAYERS && value['layers'].every((layer) => parseRetouchLayer(layer) !== null);
|
|
100
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { FilmSeconds, PlaySeconds, RetouchProperty, TextAlign } from '@openartifactsai/motion-core';
|
|
2
|
+
export type LayerKind = 'ground' | 'group' | 'shape' | 'image' | 'text';
|
|
3
|
+
/** What the list calls a drawing that has no name of its own; '' where its kind says enough. */
|
|
4
|
+
export type LayerDrawn = '' | 'graphic' | 'drawing' | 'group' | 'line' | 'path' | 'polygon';
|
|
5
|
+
export type LayerEffect = 'fade' | 'grow' | 'left' | 'right' | 'top' | 'bottom';
|
|
6
|
+
/**
|
|
7
|
+
* How a layer comes on or goes, as far as its opacity and its box tell: `how` is null where they cannot (better no
|
|
8
|
+
* word than a wrong one), and empty where it just appears.
|
|
9
|
+
*/
|
|
10
|
+
export interface LayerMotion {
|
|
11
|
+
how: LayerEffect[] | null;
|
|
12
|
+
from: PlaySeconds;
|
|
13
|
+
to: PlaySeconds;
|
|
14
|
+
}
|
|
15
|
+
/** x, y, width and height in film pixels. */
|
|
16
|
+
export type LayerBox = [number, number, number, number];
|
|
17
|
+
/**
|
|
18
|
+
* How the film itself draws a layer at the moment on show, for the controls that change it by hand. A value is null
|
|
19
|
+
* where nothing a person sets would show, or where the film changes it in the course of the stretch.
|
|
20
|
+
*/
|
|
21
|
+
export interface LayerLook {
|
|
22
|
+
/** The classes it has at every moment read, as many as the record can hold. */
|
|
23
|
+
cls: string;
|
|
24
|
+
/** Which it is of how many like elements, and maybe a print of its words (a `RetouchLayer` kin); null: none. */
|
|
25
|
+
kin: string | null;
|
|
26
|
+
/** For a g inside an svg that a hide would hold on: what the hide is also found by (a `RetouchLayer` parts). */
|
|
27
|
+
parts?: string;
|
|
28
|
+
/** The moment of the stretch on show, in the stretch's own seconds (a scene's from its start). */
|
|
29
|
+
at: FilmSeconds;
|
|
30
|
+
fill: string | null;
|
|
31
|
+
ink: string | null;
|
|
32
|
+
radius: number | null;
|
|
33
|
+
/** The largest radius that would still show: half its shorter side. */
|
|
34
|
+
most: number;
|
|
35
|
+
size: number | null;
|
|
36
|
+
hidden: 0 | null;
|
|
37
|
+
svgfill: string | null;
|
|
38
|
+
svgstroke: string | null;
|
|
39
|
+
/** A shape whose fill shows even where no colour is offered for it (a gradient): its stroke is a Stroke, not a Color. */
|
|
40
|
+
filled?: true;
|
|
41
|
+
/** The id of the entry of the record that marks it. */
|
|
42
|
+
entry: string | null;
|
|
43
|
+
/** That entry was found by its turn, not its print, on a thing with words: it may be another thing. */
|
|
44
|
+
loose: boolean;
|
|
45
|
+
/** The entry's own moment lies in the stretch on show. */
|
|
46
|
+
home: boolean;
|
|
47
|
+
/** What of the entry no longer counts here: the film's own style now says otherwise. */
|
|
48
|
+
lapsed: RetouchProperty[];
|
|
49
|
+
}
|
|
50
|
+
export interface LayerRow {
|
|
51
|
+
/** `<stretch>:<place>/<tag>`, with `+` for a node made anew at the same place and `*` for a pack of alike things. */
|
|
52
|
+
id: string;
|
|
53
|
+
kind: LayerKind;
|
|
54
|
+
/** A shape that is round (a dot, a circle). */
|
|
55
|
+
round: boolean;
|
|
56
|
+
name: string;
|
|
57
|
+
/** held: something that holds it was hidden by hand; own: it was. */
|
|
58
|
+
hidden: 'held' | 'own' | false;
|
|
59
|
+
/** The id of what was hidden, where `hidden` is 'held'. */
|
|
60
|
+
under: string | null;
|
|
61
|
+
own: boolean;
|
|
62
|
+
/** How many alike things a pack holds; 0: no pack. */
|
|
63
|
+
many: number;
|
|
64
|
+
texts: string[];
|
|
65
|
+
/** When it is on in the stretch read, as played. Six at most. */
|
|
66
|
+
spans: Array<[PlaySeconds, PlaySeconds]>;
|
|
67
|
+
/** Where to look at it: the first moment it is as solid as it gets and at rest. */
|
|
68
|
+
at: PlaySeconds;
|
|
69
|
+
enter: LayerMotion;
|
|
70
|
+
leave: LayerMotion;
|
|
71
|
+
/** Its box at the moment on show; null: not on the picture then. */
|
|
72
|
+
box: LayerBox | null;
|
|
73
|
+
/** The box round its words alone, for a line of words. */
|
|
74
|
+
wordsBox: LayerBox | null;
|
|
75
|
+
look: LayerLook | null;
|
|
76
|
+
kids: LayerRow[];
|
|
77
|
+
/** The one shape that is all a drawing's row holds: the row's colours are that shape's. */
|
|
78
|
+
sole: LayerRow | null;
|
|
79
|
+
/** Everything the svg draws is listed under the row, so a colour set on the row leaves nothing behind. */
|
|
80
|
+
whole: boolean;
|
|
81
|
+
drawn: LayerDrawn;
|
|
82
|
+
/** As large as the picture, but no Background: only the list picks it. */
|
|
83
|
+
full: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface LayersReport {
|
|
86
|
+
seq: number;
|
|
87
|
+
from: PlaySeconds;
|
|
88
|
+
to: PlaySeconds;
|
|
89
|
+
/** The moment on show, which the boxes and looks are of. */
|
|
90
|
+
at: PlaySeconds;
|
|
91
|
+
/** The record's entries for the stretch on show that find nothing, or another entry's thing. */
|
|
92
|
+
lost: string[];
|
|
93
|
+
/** Of those, the hides whose thing another entry's hide hides all the same. */
|
|
94
|
+
underHide: string[];
|
|
95
|
+
/** null: no reading (the film is not loaded, a newer question came, or the film's render gives promises). */
|
|
96
|
+
rows: LayerRow[] | null;
|
|
97
|
+
}
|
|
98
|
+
/** How the film itself sets one line of words, as the text style controls read it. null: nothing a person sets would show. */
|
|
99
|
+
export interface TypeLook {
|
|
100
|
+
weight: number | null;
|
|
101
|
+
italic: 0 | 1 | null;
|
|
102
|
+
px: number | null;
|
|
103
|
+
leading: number | 'normal' | null;
|
|
104
|
+
tracking: number | null;
|
|
105
|
+
align: TextAlign | null;
|
|
106
|
+
}
|
|
107
|
+
/** A style of a line of words that its words may each set for themselves. */
|
|
108
|
+
export type OwnTextStyle = 'weight' | 'italic' | 'px' | 'tracking' | 'ink';
|
|
109
|
+
/** How the film itself draws the thing an id names, read with no change by hand on the stage. */
|
|
110
|
+
export interface AskedLook extends TypeLook {
|
|
111
|
+
cls: string;
|
|
112
|
+
kin: string | null;
|
|
113
|
+
at: FilmSeconds;
|
|
114
|
+
fill: string | null;
|
|
115
|
+
ink: string | null;
|
|
116
|
+
radius: number | null;
|
|
117
|
+
most: number;
|
|
118
|
+
size: number | null;
|
|
119
|
+
hidden: 0 | null;
|
|
120
|
+
entry: string | null;
|
|
121
|
+
home: boolean;
|
|
122
|
+
lapsed: RetouchProperty[];
|
|
123
|
+
/** The head of its font stack; '': none that is a plain name. */
|
|
124
|
+
family: string;
|
|
125
|
+
/**
|
|
126
|
+
* The styles every word of the line sets for itself, so a change laid on the line would show on none of them. Each
|
|
127
|
+
* is null above. Absent: none.
|
|
128
|
+
*/
|
|
129
|
+
own?: OwnTextStyle[];
|
|
130
|
+
/**
|
|
131
|
+
* The line's font size where its words set their own size but not their own letter spacing: letter spacing is laid
|
|
132
|
+
* in ems of the line's size, and shown in pixels by it. Absent: `px` says it, or there is none to tell.
|
|
133
|
+
*/
|
|
134
|
+
linePx?: number;
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import type { ClipSoundUse, FilmSeconds, LaidRecord, PlaySeconds, RetouchedRecord, ScoreData, ScoreEvent } from '@openartifactsai/motion-core';
|
|
2
|
+
import type { AskedLook, LayersReport } from './layers.js';
|
|
3
|
+
export type * from './layers.js';
|
|
4
|
+
/** Bumped when a message changes shape; the host refuses a stage that says another. */
|
|
5
|
+
export declare const STAGE_PROTOCOL_VERSION = 2;
|
|
6
|
+
/**
|
|
7
|
+
* The one message the host posts to the frame's window, on the frame's load, carrying the port every later message
|
|
8
|
+
* goes through. The frame takes the first one that comes from its parent and ignores the rest.
|
|
9
|
+
*/
|
|
10
|
+
export declare const STAGE_CONNECT = "video-stage:connect";
|
|
11
|
+
export interface StageConnect {
|
|
12
|
+
type: typeof STAGE_CONNECT;
|
|
13
|
+
version: number;
|
|
14
|
+
}
|
|
15
|
+
export type StageModuleKind = 'js' | 'css' | 'html' | 'json' | 'text';
|
|
16
|
+
export interface StageModule {
|
|
17
|
+
name: string;
|
|
18
|
+
kind: StageModuleKind;
|
|
19
|
+
text: string;
|
|
20
|
+
}
|
|
21
|
+
/** Pictures and fonts arrive as bytes and become data: URLs, which a snapshot can see; a clip arrives as its URL and streams. */
|
|
22
|
+
export interface StageAsset {
|
|
23
|
+
name: string;
|
|
24
|
+
mime: string;
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
bytes?: ArrayBuffer;
|
|
28
|
+
url?: string;
|
|
29
|
+
}
|
|
30
|
+
export type StackName = 'sans' | 'serif' | 'mono' | 'display';
|
|
31
|
+
/** A face from the page (shipped with the type, or fetched): woff2 as a data: URL. */
|
|
32
|
+
export interface StageFace {
|
|
33
|
+
family: string;
|
|
34
|
+
url: string;
|
|
35
|
+
weight: string;
|
|
36
|
+
style: string;
|
|
37
|
+
range?: string;
|
|
38
|
+
/** ascent and descent overrides, in percent. */
|
|
39
|
+
box?: [number, number];
|
|
40
|
+
/** One or two characters the face draws, to load a face whose unicode-range leaves out a space. */
|
|
41
|
+
sample?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface StageFaces {
|
|
44
|
+
fonts: StageFace[];
|
|
45
|
+
/** The family that heads each stack, from the film's scenes.json fonts or a person's choice. */
|
|
46
|
+
slots: Partial<Record<StackName, string>>;
|
|
47
|
+
}
|
|
48
|
+
export interface NarrationLimits {
|
|
49
|
+
maxLines: number;
|
|
50
|
+
maxLineSeconds: number;
|
|
51
|
+
}
|
|
52
|
+
export interface StageFilm {
|
|
53
|
+
script: string;
|
|
54
|
+
modules: StageModule[];
|
|
55
|
+
assets: StageAsset[];
|
|
56
|
+
faces: StageFaces | null;
|
|
57
|
+
/** null: this viewer gets no narration, so narration.js is not read. */
|
|
58
|
+
narration: NarrationLimits | null;
|
|
59
|
+
/** How long a snapshot waits for words clipped at its first draw (Firefox). */
|
|
60
|
+
clippedTextWaitMs: number;
|
|
61
|
+
mode: RenderMode;
|
|
62
|
+
}
|
|
63
|
+
/** rough: a scene that says it is rough draws as a grey sketch. final: every written scene draws as it is. */
|
|
64
|
+
export type RenderMode = 'rough' | 'final';
|
|
65
|
+
export interface Chapter<Time extends number> {
|
|
66
|
+
t: Time;
|
|
67
|
+
label: string;
|
|
68
|
+
}
|
|
69
|
+
/** A part of the film (a scene, or a stretch between chapters) on both clocks. */
|
|
70
|
+
export interface FilmPart {
|
|
71
|
+
key: string | null;
|
|
72
|
+
/** The person's name for it, or the film's. */
|
|
73
|
+
label: string;
|
|
74
|
+
/** The film's own name for it. */
|
|
75
|
+
own: string;
|
|
76
|
+
a0: FilmSeconds;
|
|
77
|
+
nat: number;
|
|
78
|
+
p0: PlaySeconds;
|
|
79
|
+
dur: number;
|
|
80
|
+
/** Trimmed by hand: `nat` is the stretch shown, from second `from` of its whole scene, which is `was` long. */
|
|
81
|
+
trim?: {
|
|
82
|
+
from: number;
|
|
83
|
+
was: number;
|
|
84
|
+
};
|
|
85
|
+
/** A piece of a scene split by hand: the scene `of`, where the piece starts in it, and the scene's length. */
|
|
86
|
+
split?: {
|
|
87
|
+
of: string;
|
|
88
|
+
from: number;
|
|
89
|
+
was: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export type SceneState = 'todo' | 'failed' | 'rough' | 'final';
|
|
93
|
+
export interface SceneReport {
|
|
94
|
+
id: string;
|
|
95
|
+
state: SceneState;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A scene that comes on over a picture of the scene before it, held at that scene's last moment (`"enter"` in
|
|
99
|
+
* scenes.json). `at` is when it starts, in the film's own seconds; `held` says the picture was made: without one the
|
|
100
|
+
* scene cuts in.
|
|
101
|
+
*/
|
|
102
|
+
export interface SceneEntrance {
|
|
103
|
+
from: string;
|
|
104
|
+
to: string;
|
|
105
|
+
at: number;
|
|
106
|
+
kind: 'fade' | 'push' | 'wipe' | 'iris';
|
|
107
|
+
dur: number;
|
|
108
|
+
held: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface StageMeta {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
fps: 24 | 30 | 60;
|
|
114
|
+
duration: PlaySeconds;
|
|
115
|
+
filmDuration: FilmSeconds;
|
|
116
|
+
chapters: Chapter<PlaySeconds>[];
|
|
117
|
+
/** null: not a film made of scenes. */
|
|
118
|
+
scenes: SceneReport[] | null;
|
|
119
|
+
/** The stage's computed background colour and image. */
|
|
120
|
+
background: [string, string];
|
|
121
|
+
parts: FilmPart[];
|
|
122
|
+
/** The film's entrances, in order; missing or empty: every scene cuts in. */
|
|
123
|
+
entrances?: SceneEntrance[];
|
|
124
|
+
}
|
|
125
|
+
export interface PlayedScoreEvent extends Omit<ScoreEvent, 't'> {
|
|
126
|
+
t: PlaySeconds;
|
|
127
|
+
}
|
|
128
|
+
/** The score as played: recorded on the film's clock, moved with a person's scene lengths. */
|
|
129
|
+
export interface PlayedScore extends Omit<ScoreData, 'events'> {
|
|
130
|
+
events: PlayedScoreEvent[];
|
|
131
|
+
}
|
|
132
|
+
export interface PlayedNarrationLine {
|
|
133
|
+
at: PlaySeconds;
|
|
134
|
+
dur: number;
|
|
135
|
+
text: string;
|
|
136
|
+
audio: string;
|
|
137
|
+
/** The second of the asset this line's cut starts at, when it plays a cut of it (a clip's own sound). */
|
|
138
|
+
from?: number;
|
|
139
|
+
}
|
|
140
|
+
export interface NarrationReport {
|
|
141
|
+
lines: PlayedNarrationLine[];
|
|
142
|
+
duck: number | null;
|
|
143
|
+
}
|
|
144
|
+
/** One text node on the stage, in document order. A hidden node is told too, without a box. */
|
|
145
|
+
export interface StageText {
|
|
146
|
+
text: string;
|
|
147
|
+
x?: number;
|
|
148
|
+
y?: number;
|
|
149
|
+
w?: number;
|
|
150
|
+
h?: number;
|
|
151
|
+
/** The height of its first line, in film pixels. */
|
|
152
|
+
line?: number;
|
|
153
|
+
/** `<stretch>:<place>`: the line of words it is part of, where the page asked for places. */
|
|
154
|
+
id?: string;
|
|
155
|
+
seen?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** A hand title on show: its id and its size in film pixels. */
|
|
158
|
+
export interface TitleBox {
|
|
159
|
+
id: string;
|
|
160
|
+
w: number;
|
|
161
|
+
h: number;
|
|
162
|
+
}
|
|
163
|
+
/** The caption on show, in film pixels: its words and the box around them. */
|
|
164
|
+
export interface StageCaption {
|
|
165
|
+
text: string;
|
|
166
|
+
x: number;
|
|
167
|
+
y: number;
|
|
168
|
+
w: number;
|
|
169
|
+
h: number;
|
|
170
|
+
}
|
|
171
|
+
export type ConsoleLevel = 'log' | 'info' | 'warn' | 'error';
|
|
172
|
+
export type ErrorPhase = 'load' | 'render';
|
|
173
|
+
export type HostToStage = {
|
|
174
|
+
type: 'load';
|
|
175
|
+
film: StageFilm;
|
|
176
|
+
}
|
|
177
|
+
/** Seek, play and pause: the moment to show and whether the film is playing on from it. */
|
|
178
|
+
| {
|
|
179
|
+
type: 'render';
|
|
180
|
+
seq: number;
|
|
181
|
+
t: PlaySeconds;
|
|
182
|
+
playing: boolean;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'mode';
|
|
185
|
+
mode: RenderMode;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A snapshot of the stage at `t`, `scale` times its size. `lift`: an export's frame, which may take the backdrop out
|
|
189
|
+
* of the snapshot and answer with it as `under`.
|
|
190
|
+
*/
|
|
191
|
+
| {
|
|
192
|
+
type: 'frame';
|
|
193
|
+
seq: number;
|
|
194
|
+
t: PlaySeconds;
|
|
195
|
+
scale: number;
|
|
196
|
+
smallMedia: boolean;
|
|
197
|
+
readFx: boolean;
|
|
198
|
+
smooth: boolean;
|
|
199
|
+
lift?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Read the stage's text nodes now and after each paused frame (`watch` on), with their places if asked. */
|
|
202
|
+
| {
|
|
203
|
+
type: 'watch';
|
|
204
|
+
on: boolean;
|
|
205
|
+
places: boolean;
|
|
206
|
+
}
|
|
207
|
+
/** Check the stage for what a snapshot cannot show; findings come as console errors. */
|
|
208
|
+
| {
|
|
209
|
+
type: 'scan';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Read the layers of the stretch `from`–`to`, drawing it many times over, and their boxes and looks at `at`.
|
|
213
|
+
* `scene`: the scene the stretch is, whose class prefix names things; null in a film not made of scenes.
|
|
214
|
+
* `stop`: no reading is wanted any more, so one under way ends unanswered.
|
|
215
|
+
*/
|
|
216
|
+
| {
|
|
217
|
+
type: 'layers';
|
|
218
|
+
seq: number;
|
|
219
|
+
from: PlaySeconds;
|
|
220
|
+
to: PlaySeconds;
|
|
221
|
+
at: PlaySeconds;
|
|
222
|
+
scene: string | null;
|
|
223
|
+
stop: boolean;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A person's changes by hand to how things look (modules/retouched.json, parsed), laid over the film from the next
|
|
227
|
+
* frame on and drawn at once on the moment on show. null: none.
|
|
228
|
+
*/
|
|
229
|
+
| {
|
|
230
|
+
type: 'retouch';
|
|
231
|
+
record: RetouchedRecord | null;
|
|
232
|
+
}
|
|
233
|
+
/** A record of what is laid over the film (modules/laid.json, parsed), tried at once on the moment on show; null: the one it loaded with. */
|
|
234
|
+
| {
|
|
235
|
+
type: 'laid';
|
|
236
|
+
record: LaidRecord | null;
|
|
237
|
+
}
|
|
238
|
+
/** How the film itself draws the thing `id` names in the stretch on show; `t`: the moment on show, if not the last asked. */
|
|
239
|
+
| {
|
|
240
|
+
type: 'look';
|
|
241
|
+
seq: number;
|
|
242
|
+
id: string;
|
|
243
|
+
t: PlaySeconds | null;
|
|
244
|
+
}
|
|
245
|
+
/** A person's titles (modules/hand-titles.json, its text), drawn over the film from now on. null: none. */
|
|
246
|
+
| {
|
|
247
|
+
type: 'titles';
|
|
248
|
+
text: string | null;
|
|
249
|
+
};
|
|
250
|
+
export type StageToHost = {
|
|
251
|
+
type: 'hello';
|
|
252
|
+
version: number;
|
|
253
|
+
}
|
|
254
|
+
/** `clips`: the clips whose own sound plays (kit.video's `sound`), on the play clock; absent when none does. */
|
|
255
|
+
| {
|
|
256
|
+
type: 'ready';
|
|
257
|
+
meta: StageMeta;
|
|
258
|
+
score: PlayedScore | null;
|
|
259
|
+
narration: NarrationReport | null;
|
|
260
|
+
loadMs: number;
|
|
261
|
+
clips?: ClipSoundUse[];
|
|
262
|
+
}
|
|
263
|
+
/** The frame asked for with `seq` (and every one before it) is on show. */
|
|
264
|
+
| {
|
|
265
|
+
type: 'presented';
|
|
266
|
+
seq: number;
|
|
267
|
+
t: PlaySeconds;
|
|
268
|
+
ok: boolean;
|
|
269
|
+
ms: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* `under`: the backdrop taken out of the snapshot, `pw` × `ph`, to be drawn under it. `clipLate`: a small frame drawn
|
|
273
|
+
* before a video clip reached its frame, which may show a stale picture of the clip.
|
|
274
|
+
*/
|
|
275
|
+
| {
|
|
276
|
+
type: 'frame';
|
|
277
|
+
seq: number;
|
|
278
|
+
t: FilmSeconds;
|
|
279
|
+
svg: string;
|
|
280
|
+
pw: number;
|
|
281
|
+
ph: number;
|
|
282
|
+
ms: number;
|
|
283
|
+
under?: ImageBitmap;
|
|
284
|
+
clipLate?: boolean;
|
|
285
|
+
}
|
|
286
|
+
/** hold: this frame failed but the next may not. env: the browser's doing (a tab in the background), not the film's. */
|
|
287
|
+
| {
|
|
288
|
+
type: 'frame-error';
|
|
289
|
+
seq: number;
|
|
290
|
+
hold: boolean;
|
|
291
|
+
env: boolean;
|
|
292
|
+
message: string;
|
|
293
|
+
} | {
|
|
294
|
+
type: 'console';
|
|
295
|
+
level: ConsoleLevel;
|
|
296
|
+
text: string;
|
|
297
|
+
} | {
|
|
298
|
+
type: 'error';
|
|
299
|
+
phase: ErrorPhase;
|
|
300
|
+
message: string;
|
|
301
|
+
stack: string;
|
|
302
|
+
}
|
|
303
|
+
/** The frame is about to navigate away: the film is gone. */
|
|
304
|
+
| {
|
|
305
|
+
type: 'navigating';
|
|
306
|
+
}
|
|
307
|
+
/** `caption`: the caption on show with the words, `null` for none; absent from a stage that does not tell it. */
|
|
308
|
+
| {
|
|
309
|
+
type: 'texts';
|
|
310
|
+
nodes: StageText[];
|
|
311
|
+
caption?: StageCaption | null;
|
|
312
|
+
} | {
|
|
313
|
+
type: 'layers';
|
|
314
|
+
report: LayersReport;
|
|
315
|
+
}
|
|
316
|
+
/** null: nothing could be told of it (it is not there, the stage is not displayed, or the film's render gives promises). */
|
|
317
|
+
| {
|
|
318
|
+
type: 'looked';
|
|
319
|
+
seq: number;
|
|
320
|
+
id: string;
|
|
321
|
+
look: AskedLook | null;
|
|
322
|
+
lost: string[];
|
|
323
|
+
}
|
|
324
|
+
/** A person clicked a link on the stage; the frame never follows it, the host decides. */
|
|
325
|
+
| {
|
|
326
|
+
type: 'link';
|
|
327
|
+
href: string;
|
|
328
|
+
}
|
|
329
|
+
/** Sent after 'ready': the clips whose own sound plays, before what is laid over the film turns any off. */
|
|
330
|
+
| {
|
|
331
|
+
type: 'clip-sound';
|
|
332
|
+
own: ClipSoundUse[];
|
|
333
|
+
}
|
|
334
|
+
/** The size of each hand title on show, in film pixels; null while a scene comes on over a held picture. */
|
|
335
|
+
| {
|
|
336
|
+
type: 'titles';
|
|
337
|
+
boxes: TitleBox[] | null;
|
|
338
|
+
};
|
|
339
|
+
export type HostToStageType = HostToStage['type'];
|
|
340
|
+
export type StageToHostType = StageToHost['type'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Bumped when a message changes shape; the host refuses a stage that says another. */
|
|
2
|
+
export const STAGE_PROTOCOL_VERSION = 2;
|
|
3
|
+
/**
|
|
4
|
+
* The one message the host posts to the frame's window, on the frame's load, carrying the port every later message
|
|
5
|
+
* goes through. The frame takes the first one that comes from its parent and ignores the rest.
|
|
6
|
+
*/
|
|
7
|
+
export const STAGE_CONNECT = 'video-stage:connect';
|
package/src/protocol.js
ADDED
package/src/raster.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { drawSnapshot, whyNoDecode } from './runtime/snapshot/draw.js';
|
|
2
|
+
export type { SnapshotSource, SnapshotSurface } from './runtime/snapshot/draw.js';
|
|
3
|
+
export { makeHoldFirstDraw } from './runtime/snapshot/hold-first-draw.js';
|
|
4
|
+
export type { HoldFirstDraw } from './runtime/snapshot/hold-first-draw.js';
|
package/src/raster.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StageAsset } from '../protocol.js';
|
|
2
|
+
export declare function dataUrl(mime: string, bytes: ArrayBuffer): string;
|
|
3
|
+
/** Pictures and fonts become data: URLs, which a snapshot can see; a clip keeps its URL and streams. */
|
|
4
|
+
export declare function addAssets(list: readonly StageAsset[]): void;
|
|
5
|
+
export declare const assetUrl: (name: string) => string | null;
|
|
6
|
+
export interface AssetStore {
|
|
7
|
+
has(name: string): boolean;
|
|
8
|
+
list(): string[];
|
|
9
|
+
url(name: string): string;
|
|
10
|
+
mime(name: string): string;
|
|
11
|
+
bytes(name: string): Uint8Array | null;
|
|
12
|
+
text(name: string): string | null;
|
|
13
|
+
image(name: string): Promise<HTMLImageElement>;
|
|
14
|
+
size(name: string): {
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export declare const assetStore: AssetStore;
|