@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.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +5 -2
- package/package.json +69 -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
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { drawnValue, isArtWords, styleOf } from "../layers/parts.js";
|
|
2
|
+
import { CORNERS, KEYS, propsOf, same, seenLook, trial } from "./look.js";
|
|
3
|
+
/*
|
|
4
|
+
* Whether a pair still holds on its thing: it yields only to a value the film gives this element itself. A value
|
|
5
|
+
* that reaches the element from elsewhere (a variable set higher up, a rule for many) is one it shares, and a change
|
|
6
|
+
* there would show on every element that shares it, so the pair is held to it.
|
|
7
|
+
*/
|
|
8
|
+
/** Each scene's box as it came up, with the classes in it, so a class counts as the element's own alike in every runner. */
|
|
9
|
+
export const boxes = [];
|
|
10
|
+
function alone(stage, name) {
|
|
11
|
+
return stage.getElementsByClassName(name).length < 2 && !boxes.some((box) => box.names.has(name) && !stage.contains(box.node));
|
|
12
|
+
}
|
|
13
|
+
function probe(el) {
|
|
14
|
+
return styleOf(el.ownerDocument.createElementNS(el.namespaceURI, 'i'));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether a style attribute's text, read anew, lists the declarations el.style has, in whatever order. Not once a
|
|
18
|
+
* longhand is set over a shorthand holding a var() and the film has written to el.style: taken off, it could not be
|
|
19
|
+
* put back.
|
|
20
|
+
*/
|
|
21
|
+
export function intact(el, text) {
|
|
22
|
+
const style = styleOf(el);
|
|
23
|
+
const fresh = probe(el);
|
|
24
|
+
if (!style || !fresh)
|
|
25
|
+
return false;
|
|
26
|
+
const all = (s) => s.cssText.replace(/;\s*$/, '').split('; ').sort().join('; ');
|
|
27
|
+
fresh.cssText = text;
|
|
28
|
+
return all(fresh) === all(style);
|
|
29
|
+
}
|
|
30
|
+
/** The attributes of an svg text that set what a person may change. */
|
|
31
|
+
const WORN = ['fill', 'color', 'font-family', 'font-size', 'font-style', 'font-weight', 'letter-spacing'];
|
|
32
|
+
/** An attribute's value as the engine takes it for the property of that name; '': none, or the engine drops it. */
|
|
33
|
+
function taken(el, name) {
|
|
34
|
+
const style = probe(el);
|
|
35
|
+
if (!style)
|
|
36
|
+
return '';
|
|
37
|
+
const said = (el.getAttribute(name) ?? '').trim();
|
|
38
|
+
style.setProperty(name, said);
|
|
39
|
+
// An attribute may leave out a length's unit, which not every engine allows in a declaration.
|
|
40
|
+
if (!style.getPropertyValue(name) && /^[-+]?(\d*\.)?\d+(e[-+]?\d+)?$/i.test(said))
|
|
41
|
+
style.setProperty(name, said + 'px');
|
|
42
|
+
return style.getPropertyValue(name);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reads how the film would draw the element but for what is its own: its style attribute, its id, each class nothing
|
|
46
|
+
* else has, and on an svg text its paint and font attributes. `style` goes in place of its style attribute; null is
|
|
47
|
+
* given back where that cannot be done.
|
|
48
|
+
*/
|
|
49
|
+
export function bare(stage, el, style, read) {
|
|
50
|
+
const own = ['class', 'style', 'id'].concat(isArtWords(el) ? WORN.filter((name) => !/^\s*currentcolor\s*$|var\(/i.test(el.getAttribute(name) ?? '')) : []);
|
|
51
|
+
const had = own.map((name) => el.getAttribute(name));
|
|
52
|
+
const attribute = had[1];
|
|
53
|
+
const torn = attribute !== null && attribute !== undefined && !intact(el, attribute);
|
|
54
|
+
const outer = trial.on;
|
|
55
|
+
if (torn && style)
|
|
56
|
+
return null;
|
|
57
|
+
if (torn) {
|
|
58
|
+
own.splice(1, 1);
|
|
59
|
+
had.splice(1, 1);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
if (!torn) {
|
|
63
|
+
if (style)
|
|
64
|
+
el.setAttribute('style', style);
|
|
65
|
+
else
|
|
66
|
+
el.removeAttribute('style');
|
|
67
|
+
}
|
|
68
|
+
trial.on = !torn;
|
|
69
|
+
for (const name of own.slice(torn ? 1 : 2))
|
|
70
|
+
el.removeAttribute(name);
|
|
71
|
+
if (had[0] !== null)
|
|
72
|
+
el.setAttribute('class', Array.from(el.classList).filter((name) => !alone(stage, name)).join(' '));
|
|
73
|
+
return read();
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
trial.on = outer;
|
|
77
|
+
own.forEach((name, i) => {
|
|
78
|
+
const value = had[i];
|
|
79
|
+
if (value === null || value === undefined)
|
|
80
|
+
el.removeAttribute(name);
|
|
81
|
+
else
|
|
82
|
+
el.setAttribute(name, value);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const bareSeen = (stage, el, style) => bare(stage, el, style, () => seenLook(getComputedStyle(el), el));
|
|
87
|
+
/** The style rules that find the element, nested ones too, none under a media rule that does not apply. A sheet that may not be read is passed over. */
|
|
88
|
+
function rulesOf(el) {
|
|
89
|
+
const out = [];
|
|
90
|
+
const walk = (rules, within) => {
|
|
91
|
+
for (const rule of Array.from(rules)) {
|
|
92
|
+
const own = rule instanceof CSSStyleRule ? rule.selectorText : '';
|
|
93
|
+
const selector = !own || !within ? own || within : own.includes('&') ? own.split('&').join(':is(' + within + ')') : ':is(' + within + ') :is(' + own + ')';
|
|
94
|
+
const style = Reflect.get(rule, 'style');
|
|
95
|
+
try {
|
|
96
|
+
if (style instanceof CSSStyleDeclaration && selector && el.matches(selector))
|
|
97
|
+
out.push(style);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// A selector the engine does not take.
|
|
101
|
+
}
|
|
102
|
+
const kids = Reflect.get(rule, 'cssRules');
|
|
103
|
+
if (kids instanceof CSSRuleList && !(rule instanceof CSSMediaRule && !window.matchMedia(rule.media.mediaText).matches))
|
|
104
|
+
walk(kids, selector);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
for (const sheet of Array.from(el.ownerDocument.styleSheets)) {
|
|
108
|
+
try {
|
|
109
|
+
walk(sheet.cssRules, '');
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// A sheet from elsewhere.
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function declarations(key, text, el) {
|
|
118
|
+
const props = propsOf(key, el);
|
|
119
|
+
return text
|
|
120
|
+
.split(';')
|
|
121
|
+
.map((d) => {
|
|
122
|
+
const i = d.indexOf(':');
|
|
123
|
+
return { name: d.slice(0, i).trim().toLowerCase(), value: drawnValue(d.slice(i + 1).replace(/!\s*important\s*$/i, '').trim()), important: /!\s*important\s*$/i.test(d) };
|
|
124
|
+
})
|
|
125
|
+
.filter(({ name }) => props.some((p) => p === name || ((name === 'background' || name === 'font') && p.startsWith(name + '-')) || (name === 'border-radius' && /-radius$/.test(p)) || (name === 'font' && p === 'line-height')));
|
|
126
|
+
}
|
|
127
|
+
/** Leading and tracking are read as multiples of the font size, and corners may be given in em: a trial keeps the size. */
|
|
128
|
+
function pin(el, key) {
|
|
129
|
+
return key === 'leading' || key === 'tracking' || key === 'radius' ? ['font-size: ' + getComputedStyle(el).fontSize + ' !important'] : [];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether the film's value `v` only reaches the element from elsewhere: in one of the blocks every declaration of the
|
|
133
|
+
* property uses a var(), and those, put on the element in place of all that is its own, give `v`. Tried with each
|
|
134
|
+
* made !important; unless `force`, also as important as each is.
|
|
135
|
+
*/
|
|
136
|
+
function handed(stage, el, key, v, texts, force) {
|
|
137
|
+
return texts.some((text) => {
|
|
138
|
+
const mine = declarations(key, text, el);
|
|
139
|
+
const gives = (all) => {
|
|
140
|
+
const seen = bareSeen(stage, el, mine
|
|
141
|
+
.map((d) => d.name + ': ' + d.value + (all || d.important ? ' !important' : ''))
|
|
142
|
+
.concat(pin(el, key))
|
|
143
|
+
.join('; '));
|
|
144
|
+
return !seen || same(key, seen.values[key], v);
|
|
145
|
+
};
|
|
146
|
+
return mine.length > 0 && mine.every((d) => d.value !== null) && (gives(true) || (!force && gives(false)));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Judges the pairs of entry `e` on `el`. `so`: the verdict so far; a later look only turns a yes into a no. `must`:
|
|
151
|
+
* at the entry's own moment; at others an element that is not displayed is passed over.
|
|
152
|
+
*/
|
|
153
|
+
export function judge(stage, el, e, so, must) {
|
|
154
|
+
const cs = getComputedStyle(el);
|
|
155
|
+
if (!must && cs.display === 'none')
|
|
156
|
+
return so;
|
|
157
|
+
const now = seenLook(cs, el);
|
|
158
|
+
let without = null;
|
|
159
|
+
const shared = (key, v) => {
|
|
160
|
+
const set = Array.from(styleOf(el) ?? []);
|
|
161
|
+
// Where the style attribute sets the property, only it is tried, less its comments.
|
|
162
|
+
if (propsOf(key, el).some((p) => set.includes(p)))
|
|
163
|
+
return handed(stage, el, key, v, [(el.getAttribute('style') ?? '').replace(/\/\*[\s\S]*?(?:\*\/|$)/g, ' ')], false);
|
|
164
|
+
// Else an svg text's attribute for the property, where what it says is what shows.
|
|
165
|
+
const attribute = isArtWords(el) ? propsOf(key, el)[0] : undefined;
|
|
166
|
+
const says = attribute !== undefined && WORN.includes(attribute) ? taken(el, attribute) : '';
|
|
167
|
+
const tried = says && !/^(currentcolor|inherit|unset|revert|revert-layer)$/i.test(says) ? bareSeen(stage, el, [attribute + ': ' + says + ' !important', ...pin(el, key)].join('; ')) : null;
|
|
168
|
+
if (tried && same(key, tried.values[key], v))
|
|
169
|
+
return handed(stage, el, key, v, [attribute + ': ' + says], false);
|
|
170
|
+
// Else the rules.
|
|
171
|
+
const pinned = pin(el, key)[0];
|
|
172
|
+
const kept = pinned ? bareSeen(stage, el, pinned) : null;
|
|
173
|
+
const b = kept ?? (without ??= bareSeen(stage, el, null));
|
|
174
|
+
if (!b)
|
|
175
|
+
return false;
|
|
176
|
+
// Where the style attribute is left on, not being intact, only the rules that find the element by its id or a class of its own count.
|
|
177
|
+
const ownRules = () => {
|
|
178
|
+
let all = rulesOf(el);
|
|
179
|
+
const text = el.getAttribute('style');
|
|
180
|
+
if (text !== null && !intact(el, text))
|
|
181
|
+
bare(stage, el, '', () => {
|
|
182
|
+
const still = rulesOf(el);
|
|
183
|
+
all = all.filter((rule) => !still.includes(rule));
|
|
184
|
+
});
|
|
185
|
+
return all.map((rule) => rule.cssText);
|
|
186
|
+
};
|
|
187
|
+
// Nor can the font size be kept there: a reading at another size tells nothing.
|
|
188
|
+
if (pinned && b === without && b.values.px !== now.values.px)
|
|
189
|
+
return !ownRules().some((rule) => declarations(key, rule, el).some((d) => d.value === null));
|
|
190
|
+
return same(key, b.values[key], v) || handed(stage, el, key, v, ownRules(), true);
|
|
191
|
+
};
|
|
192
|
+
const verdict = so ?? { round: now.round, art: isArtWords(el), own: {}, holds: {} };
|
|
193
|
+
for (const key of KEYS) {
|
|
194
|
+
const pair = e.pairs[key];
|
|
195
|
+
if (!pair || verdict.holds[key] === false)
|
|
196
|
+
continue;
|
|
197
|
+
const value = now.values[key];
|
|
198
|
+
if (!so)
|
|
199
|
+
verdict.own[key] = !same(key, value, pair.was) && value !== null && shared(key, value) ? value : pair.was;
|
|
200
|
+
verdict.holds[key] = same(key, value, verdict.own[key] ?? pair.was);
|
|
201
|
+
}
|
|
202
|
+
return verdict;
|
|
203
|
+
}
|
|
204
|
+
/** What of an entry holds (`good`) or has lapsed, as the marks say it. The film's own choice of round corners takes the new radius; if none is round, all four do. */
|
|
205
|
+
export function marksOf(e, verdict, good) {
|
|
206
|
+
return KEYS.filter((key) => e.pairs[key] && verdict.holds[key] === good)
|
|
207
|
+
.map((key) => (good && key === 'radius' ? (verdict.round.length ? verdict.round : CORNERS).join(' ') : good && key === 'ink' && verdict.art ? 'paint' : key))
|
|
208
|
+
.join(' ');
|
|
209
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PaintKey } from '../layers/parts.ts';
|
|
2
|
+
import type { TypeKey } from './type-style.ts';
|
|
3
|
+
/** What a person may set by hand that this stage lays. A picked typeface is not among them. */
|
|
4
|
+
export type Key = 'fill' | 'ink' | 'size' | 'radius' | 'hidden' | TypeKey | PaintKey;
|
|
5
|
+
export declare const KEYS: readonly Key[];
|
|
6
|
+
/** What only a box that paints has, and what only a line of words has. */
|
|
7
|
+
export declare const OF_BOX: readonly Key[];
|
|
8
|
+
export declare const OF_WORDS: readonly Key[];
|
|
9
|
+
export declare const CORNERS: readonly ["top-left", "top-right", "bottom-right", "bottom-left"];
|
|
10
|
+
export type Corner = (typeof CORNERS)[number];
|
|
11
|
+
export type Value = string | number;
|
|
12
|
+
/** Each value as computed now; null: nothing the record can hold, or that a change would show on. */
|
|
13
|
+
export type Values = Record<Key, Value | null>;
|
|
14
|
+
export interface Seen {
|
|
15
|
+
values: Values;
|
|
16
|
+
/** The corners the film rounds. */
|
|
17
|
+
round: Corner[];
|
|
18
|
+
}
|
|
19
|
+
export declare const isPaintKey: (key: Key) => key is PaintKey;
|
|
20
|
+
export declare const isTypeKey: (key: Key) => key is TypeKey;
|
|
21
|
+
/**
|
|
22
|
+
* Set while the style attribute on the element is a trial's, or a trial took the film's off: an !important there
|
|
23
|
+
* is then not the film's.
|
|
24
|
+
*/
|
|
25
|
+
export declare const trial: {
|
|
26
|
+
on: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** A computed colour as #rrggbb or #rrggbbaa; null: none a picker can show. What is not spelled rgb() is painted on one pixel and read back. */
|
|
29
|
+
export declare function hex(colour: string): string | null;
|
|
30
|
+
export declare const inkOf: (cs: CSSStyleDeclaration, el: Element) => string;
|
|
31
|
+
/** How the film draws the element now, under its own colours. */
|
|
32
|
+
export declare const seenLook: (cs: CSSStyleDeclaration, el: Element) => Seen;
|
|
33
|
+
/** Compared look to look for the film's own changes; called inside `inOwnColors`. */
|
|
34
|
+
export declare function hues(cs: CSSStyleDeclaration, el: Element): Partial<Record<Key, string>>;
|
|
35
|
+
/** Engines round a mixed colour differently. */
|
|
36
|
+
export declare function alike(a: string | null, b: string | null): boolean;
|
|
37
|
+
export declare function same(key: Key, now: Value | null, was: Value): boolean;
|
|
38
|
+
/** The CSS properties a key is read off; the ink of an svg text is its fill. */
|
|
39
|
+
export declare function propsOf(key: Key, el: Element): readonly string[];
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { inOwnColors } from "../snapshot/serialize.js";
|
|
2
|
+
import { PAINT, PAINT_KEYS, SHAPE, isArtWords, isPart, styleOf } from "../layers/parts.js";
|
|
3
|
+
import { TYPE_KEYS, TYPE_PROPS, sameType, typeHues, typeSeen } from "./type-style.js";
|
|
4
|
+
export const KEYS = ['fill', 'ink', 'size', 'radius', 'hidden', ...TYPE_KEYS, ...PAINT_KEYS];
|
|
5
|
+
/** What only a box that paints has, and what only a line of words has. */
|
|
6
|
+
export const OF_BOX = ['fill', 'radius'];
|
|
7
|
+
export const OF_WORDS = ['ink', ...TYPE_KEYS];
|
|
8
|
+
export const CORNERS = ['top-left', 'top-right', 'bottom-right', 'bottom-left'];
|
|
9
|
+
export const isPaintKey = (key) => key === 'svgfill' || key === 'svgstroke';
|
|
10
|
+
export const isTypeKey = (key) => TYPE_KEYS.some((each) => each === key);
|
|
11
|
+
/**
|
|
12
|
+
* Set while the style attribute on the element is a trial's, or a trial took the film's off: an !important there
|
|
13
|
+
* is then not the film's.
|
|
14
|
+
*/
|
|
15
|
+
export const trial = { on: false };
|
|
16
|
+
let dot = null;
|
|
17
|
+
/** A computed colour as #rrggbb or #rrggbbaa; null: none a picker can show. What is not spelled rgb() is painted on one pixel and read back. */
|
|
18
|
+
export function hex(colour) {
|
|
19
|
+
const m = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,/\s]+([\d.]+))?\s*\)$/.exec(colour || '');
|
|
20
|
+
let p = m ? [+m[1], +m[2], +m[3], m[4] === undefined ? 255 : +m[4] * 255] : null;
|
|
21
|
+
if (!p && colour) {
|
|
22
|
+
try {
|
|
23
|
+
dot = dot ?? document.createElement('canvas').getContext('2d', { willReadFrequently: true });
|
|
24
|
+
if (!dot)
|
|
25
|
+
return null;
|
|
26
|
+
dot.canvas.width = dot.canvas.height = 1;
|
|
27
|
+
dot.fillStyle = '#000';
|
|
28
|
+
dot.fillStyle = colour;
|
|
29
|
+
dot.fillRect(0, 0, 1, 1);
|
|
30
|
+
p = dot.getImageData(0, 0, 1, 1).data;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!p)
|
|
37
|
+
return null;
|
|
38
|
+
let out = '#';
|
|
39
|
+
for (let i = 0; i < ((p[3] ?? 255) >= 254.5 ? 3 : 4); i++)
|
|
40
|
+
out += ('0' + Math.round(Math.max(0, Math.min(255, p[i] ?? 0))).toString(16)).slice(-2);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
export const inkOf = (cs, el) => (!isArtWords(el) ? cs.color : /^(none|url|context)/i.test(cs.fill) ? '' : cs.fill);
|
|
44
|
+
function cornersOf(cs) {
|
|
45
|
+
return CORNERS.map((corner) => cs.getPropertyValue('border-' + corner + '-radius'));
|
|
46
|
+
}
|
|
47
|
+
/** A shape's fill and stroke, each as one plain colour; null where hex() would read black or the film's own !important wins. */
|
|
48
|
+
function painted(cs, el, values) {
|
|
49
|
+
const shape = isPart(el) && SHAPE.test(el.tagName);
|
|
50
|
+
const style = styleOf(el);
|
|
51
|
+
for (const key of PAINT_KEYS) {
|
|
52
|
+
const property = PAINT[key];
|
|
53
|
+
const paint = cs.getPropertyValue(property) || 'none';
|
|
54
|
+
const pinned = !trial.on && !!style && !!style.getPropertyPriority(property);
|
|
55
|
+
values[key] = !shape || (property === 'fill' && /^line$/i.test(el.tagName)) || /^(none|url|context)/i.test(paint) || pinned ? null : hex(paint);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The element's look as computed now. fill: a gradient counts as its first colour; over a picture there is none.
|
|
60
|
+
* size: the scale property, which does nothing to an inline box but a picture's. radius: its roundest corner, not
|
|
61
|
+
* where the film gives it in percent.
|
|
62
|
+
*/
|
|
63
|
+
function readLook(cs, el) {
|
|
64
|
+
const art = cs.backgroundImage === 'none' ? '' : cs.backgroundImage;
|
|
65
|
+
const first = /(rgba?\([^)]*\)|color\([^)]*\))/i.exec(art);
|
|
66
|
+
const radii = cornersOf(cs);
|
|
67
|
+
const scale = isNaN(parseFloat(cs.scale)) ? 1 : parseFloat(cs.scale);
|
|
68
|
+
const style = styleOf(el);
|
|
69
|
+
const type = typeSeen(cs);
|
|
70
|
+
const values = {
|
|
71
|
+
fill: /url\(/i.test(art) ? null : hex(first ? first[1] : cs.backgroundColor),
|
|
72
|
+
ink: hex(inkOf(cs, el)),
|
|
73
|
+
size: (cs.display === 'inline' && !/^(img|svg|canvas|video)$/i.test(el.tagName)) || scale < 0.1 || scale > 4 ? null : scale,
|
|
74
|
+
radius: radii.some((value) => /%/.test(value)) ? null : Math.min(2000, Math.max(...radii.map((value) => parseFloat(value) || 0))),
|
|
75
|
+
hidden: style && (style.visibility === 'visible' || style.getPropertyPriority('visibility')) ? null : 0,
|
|
76
|
+
weight: type.weight,
|
|
77
|
+
italic: type.italic,
|
|
78
|
+
px: type.px,
|
|
79
|
+
leading: type.leading,
|
|
80
|
+
tracking: type.tracking,
|
|
81
|
+
align: type.align,
|
|
82
|
+
svgfill: null,
|
|
83
|
+
svgstroke: null,
|
|
84
|
+
};
|
|
85
|
+
painted(cs, el, values);
|
|
86
|
+
return { values, round: CORNERS.filter((_, i) => parseFloat(radii[i] ?? '0') > 0) };
|
|
87
|
+
}
|
|
88
|
+
/** How the film draws the element now, under its own colours. */
|
|
89
|
+
export const seenLook = (cs, el) => inOwnColors(() => readLook(cs, el));
|
|
90
|
+
/** Compared look to look for the film's own changes; called inside `inOwnColors`. */
|
|
91
|
+
export function hues(cs, el) {
|
|
92
|
+
return {
|
|
93
|
+
fill: cs.backgroundColor + cs.backgroundImage,
|
|
94
|
+
ink: inkOf(cs, el),
|
|
95
|
+
radius: cornersOf(cs).join(''),
|
|
96
|
+
size: cs.scale,
|
|
97
|
+
...typeHues(cs),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Engines round a mixed colour differently. */
|
|
101
|
+
export function alike(a, b) {
|
|
102
|
+
if (a === null || b === null || a.length !== b.length)
|
|
103
|
+
return false;
|
|
104
|
+
for (let i = 1; i < a.length; i += 2)
|
|
105
|
+
if (Math.abs(parseInt(a.substr(i, 2), 16) - parseInt(b.substr(i, 2), 16)) > 2)
|
|
106
|
+
return false;
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
export function same(key, now, was) {
|
|
110
|
+
if (key === 'fill' || key === 'ink' || isPaintKey(key))
|
|
111
|
+
return alike(typeof now === 'string' ? now : null, String(was).toLowerCase());
|
|
112
|
+
if (key === 'size')
|
|
113
|
+
return typeof now === 'number' && typeof was === 'number' && Math.abs(now - was) < 0.005;
|
|
114
|
+
if (key === 'radius')
|
|
115
|
+
return typeof now === 'number' && typeof was === 'number' && Math.abs(now - was) <= 0.5;
|
|
116
|
+
if (key === 'hidden')
|
|
117
|
+
return now === was;
|
|
118
|
+
return sameType(key, now, was);
|
|
119
|
+
}
|
|
120
|
+
const PROPS = {
|
|
121
|
+
fill: ['background-color', 'background-image'],
|
|
122
|
+
ink: ['color'],
|
|
123
|
+
size: ['scale'],
|
|
124
|
+
radius: CORNERS.map((corner) => 'border-' + corner + '-radius'),
|
|
125
|
+
svgfill: ['fill'],
|
|
126
|
+
svgstroke: ['stroke'],
|
|
127
|
+
};
|
|
128
|
+
/** The CSS properties a key is read off; the ink of an svg text is its fill. */
|
|
129
|
+
export function propsOf(key, el) {
|
|
130
|
+
if (key === 'ink' && isArtWords(el))
|
|
131
|
+
return ['fill'];
|
|
132
|
+
if (isTypeKey(key))
|
|
133
|
+
return TYPE_PROPS[key];
|
|
134
|
+
return PROPS[key] ?? [];
|
|
135
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReadMemo } from './entry.ts';
|
|
2
|
+
/** FNV-1a over UTF-16 code units, unsigned. */
|
|
3
|
+
export declare function fnv(s: string): number;
|
|
4
|
+
/**
|
|
5
|
+
* A piece in six hex digits. A g: a hash of its name, led by 0, which tells it from a shape. A shape: a hash from
|
|
6
|
+
* 100000 up of how it is written: what its own attributes say (saidOf), its outline and place, and the paint it may
|
|
7
|
+
* take from what holds it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function written(el: Element, memo: ReadMemo): string;
|
|
10
|
+
/**
|
|
11
|
+
* The `parts` of an entry that hides this g now: the lowest hashes of the named g's in it (NAMES at most), then of its
|
|
12
|
+
* shapes, MOST in all; those kept do not depend on the drawing's order. null: it holds what may draw unread, or at most
|
|
13
|
+
* half of its shapes stand only in it, so a copy of it could pass for it. The caller has seen that it has no words.
|
|
14
|
+
*/
|
|
15
|
+
export declare function partsOf(g: Element, memo: ReadMemo): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Whether a g is still the one that held these pieces: more of the saved shapes are in it than elsewhere on the
|
|
18
|
+
* stage, and over three quarters of them are (or nothing new stands in it); and little was put in, so that not much is
|
|
19
|
+
* hidden that nobody hid: new shapes are at most a third of its shapes, and under a g whose name is new, or on more g's
|
|
20
|
+
* than were saved, stand only saved shapes. Nor may it hold what draws unread, or be drawn again by a use.
|
|
21
|
+
*/
|
|
22
|
+
export declare function holds(g: Element, parts: readonly string[], memo: ReadMemo): boolean;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { RETOUCH_PARTS_MANY as MANY, RETOUCH_PARTS_NAMES as NAMES } from '@open-artifact/motion-core';
|
|
2
|
+
import { isPart, kidsOf, saidOf } from "../layers/parts.js";
|
|
3
|
+
/*
|
|
4
|
+
* What a hide on a g inside an svg is also found by (an entry's "parts"), once a change inside the g ends its print:
|
|
5
|
+
* a hash of each named g in it and of each of its shapes. A g whose shapes are mostly still there, with little put in,
|
|
6
|
+
* is still the g that was hidden. The hashes match the player's that the record is shared with, to the letter.
|
|
7
|
+
*/
|
|
8
|
+
/** The longest a `parts` gets. */
|
|
9
|
+
const MOST = 32;
|
|
10
|
+
/** What a shape's outline and place are written in. A missing one counts as the word "null". */
|
|
11
|
+
const OUTLINE = ['d', 'points', 'x', 'y', 'width', 'height', 'cx', 'cy', 'r', 'rx', 'ry', 'x1', 'y1', 'x2', 'y2', 'transform', 'xlink:href'];
|
|
12
|
+
/** FNV-1a over UTF-16 code units, unsigned. */
|
|
13
|
+
export function fnv(s) {
|
|
14
|
+
let h = 0x811c9dc5;
|
|
15
|
+
for (let i = 0; i < s.length; i++)
|
|
16
|
+
h = Math.imul(h ^ s.charCodeAt(i), 16777619);
|
|
17
|
+
return h >>> 0;
|
|
18
|
+
}
|
|
19
|
+
const isGroup = (el) => /^g$/i.test(el.tagName);
|
|
20
|
+
/** The name a g has of its own: its id, its classes, its data-label and its aria-label. */
|
|
21
|
+
function named(g) {
|
|
22
|
+
return [g.id, g.getAttribute('class') ?? '', g.getAttribute('data-label') ?? '', g.getAttribute('aria-label') ?? ''].join(' ').trim();
|
|
23
|
+
}
|
|
24
|
+
/** What a g is known by: the shapes under it (parts that are no g's) and the g's under it that have a name, however deep. */
|
|
25
|
+
function piecesIn(up, out = []) {
|
|
26
|
+
for (const el of kidsOf(up).filter(isPart)) {
|
|
27
|
+
if (!isGroup(el) || named(el))
|
|
28
|
+
out.push(el);
|
|
29
|
+
if (isGroup(el))
|
|
30
|
+
piecesIn(el, out);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The paint written on the svg and the g's round a part, as one short hash. A holder's tag, id and classes do not
|
|
36
|
+
* count, so a drawing is known again under another name; a holder with no paint adds nothing, so a new wrapper
|
|
37
|
+
* changes nothing.
|
|
38
|
+
*/
|
|
39
|
+
function lent(el, memo) {
|
|
40
|
+
const up = el.parentElement;
|
|
41
|
+
if (!up)
|
|
42
|
+
return '';
|
|
43
|
+
const known = (memo.lent ??= new Map()).get(up);
|
|
44
|
+
if (known !== undefined)
|
|
45
|
+
return known;
|
|
46
|
+
const above = isPart(up) ? lent(up, memo) : '';
|
|
47
|
+
const paint = saidOf(up).slice((up.tagName + ' ' + up.id + ' ' + (up.getAttribute('class') ?? '')).length);
|
|
48
|
+
const out = /\S/.test(paint) ? String(fnv(above + paint)) : above;
|
|
49
|
+
memo.lent.set(up, out);
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A piece in six hex digits. A g: a hash of its name, led by 0, which tells it from a shape. A shape: a hash from
|
|
54
|
+
* 100000 up of how it is written: what its own attributes say (saidOf), its outline and place, and the paint it may
|
|
55
|
+
* take from what holds it.
|
|
56
|
+
*/
|
|
57
|
+
export function written(el, memo) {
|
|
58
|
+
const known = (memo.written ??= new Map()).get(el);
|
|
59
|
+
if (known !== undefined)
|
|
60
|
+
return known;
|
|
61
|
+
const n = isGroup(el)
|
|
62
|
+
? fnv(named(el)) >>> 12
|
|
63
|
+
: ((fnv(lent(el, memo) + saidOf(el) + OUTLINE.map((name) => ' ' + String(el.getAttribute(name))).join('')) >>> 8) % 0xf00000) + 0x100000;
|
|
64
|
+
const out = ('00000' + n.toString(16)).slice(-6);
|
|
65
|
+
memo.written.set(el, out);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** How many of the pieces are written each way. */
|
|
69
|
+
function tally(pieces, memo) {
|
|
70
|
+
const n = new Map();
|
|
71
|
+
for (const el of pieces) {
|
|
72
|
+
const w = written(el, memo);
|
|
73
|
+
n.set(w, (n.get(w) ?? 0) + 1);
|
|
74
|
+
}
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
/** The shapes on the whole stage, tallied. `memo.art` is read: the caller has listed the stage's g's (peers). */
|
|
78
|
+
function onStage(memo) {
|
|
79
|
+
return (memo.pieces ??= tally((memo.art ?? []).filter((el) => isPart(el) && !isGroup(el)), memo));
|
|
80
|
+
}
|
|
81
|
+
/** A g holds something that may draw and is not read: a nested svg, a link, a switch, the kit's marks, what a foreignObject holds. */
|
|
82
|
+
function odd(g) {
|
|
83
|
+
return Array.from(g.getElementsByTagName('*')).some((el) => /^(svg|a|switch)$/i.test(el.tagName) || el.hasAttribute('data-film-mark') || /^foreignObject$/i.test(el.parentElement?.tagName ?? ''));
|
|
84
|
+
}
|
|
85
|
+
/** A use on the stage draws a copy of the g, which would be hidden with it. */
|
|
86
|
+
function copied(g, memo) {
|
|
87
|
+
return !!g.id && (memo.art ?? []).some((el) => /^use$/i.test(el.tagName) && (el.getAttribute('href') || el.getAttribute('xlink:href')) === '#' + g.id);
|
|
88
|
+
}
|
|
89
|
+
/** The lowest of some hashes, none kept more than MANY times, so that many alike do not crowd out the rest. */
|
|
90
|
+
function lowest(hashes, most) {
|
|
91
|
+
return hashes
|
|
92
|
+
.slice()
|
|
93
|
+
.sort()
|
|
94
|
+
.filter((w, i, all) => w !== all[i - MANY])
|
|
95
|
+
.slice(0, most);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The `parts` of an entry that hides this g now: the lowest hashes of the named g's in it (NAMES at most), then of its
|
|
99
|
+
* shapes, MOST in all; those kept do not depend on the drawing's order. null: it holds what may draw unread, or at most
|
|
100
|
+
* half of its shapes stand only in it, so a copy of it could pass for it. The caller has seen that it has no words.
|
|
101
|
+
*/
|
|
102
|
+
export function partsOf(g, memo) {
|
|
103
|
+
const own = piecesIn(g);
|
|
104
|
+
const inside = tally(own, memo);
|
|
105
|
+
const all = onStage(memo);
|
|
106
|
+
const said = own.map((el) => written(el, memo));
|
|
107
|
+
const names = lowest(said.filter((w) => w < '1'), NAMES);
|
|
108
|
+
const shapes = said.filter((w) => w >= '1');
|
|
109
|
+
if (odd(g) || 2 * shapes.filter((w) => all.get(w) === inside.get(w)).length <= shapes.length)
|
|
110
|
+
return null;
|
|
111
|
+
return names.concat(lowest(shapes, MOST - names.length)).join('.');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Whether a g is still the one that held these pieces: more of the saved shapes are in it than elsewhere on the
|
|
115
|
+
* stage, and over three quarters of them are (or nothing new stands in it); and little was put in, so that not much is
|
|
116
|
+
* hidden that nobody hid: new shapes are at most a third of its shapes, and under a g whose name is new, or on more g's
|
|
117
|
+
* than were saved, stand only saved shapes. Nor may it hold what draws unread, or be drawn again by a use.
|
|
118
|
+
*/
|
|
119
|
+
export function holds(g, parts, memo) {
|
|
120
|
+
const inside = tally(piecesIn(g), memo);
|
|
121
|
+
const all = onStage(memo);
|
|
122
|
+
const times = new Map();
|
|
123
|
+
const seen = new Map();
|
|
124
|
+
const shapes = parts.filter((w) => w >= '1');
|
|
125
|
+
// Where all MOST places are used, a shape hashed above the highest saved may be saved or new.
|
|
126
|
+
const top = parts.length < MOST ? 'g' : parts[MOST - 1];
|
|
127
|
+
// More of a piece than were saved; one saved MANY times may have been there any number of times.
|
|
128
|
+
const over = (w, n) => n > (times.get(w) ?? 0) && times.get(w) !== MANY;
|
|
129
|
+
let here = 0;
|
|
130
|
+
let away = 0;
|
|
131
|
+
let old = 0;
|
|
132
|
+
let fresh = 0;
|
|
133
|
+
let dark = 0;
|
|
134
|
+
let alien = false;
|
|
135
|
+
for (const w of parts) {
|
|
136
|
+
const t = (times.get(w) ?? 0) + 1;
|
|
137
|
+
times.set(w, t);
|
|
138
|
+
if (w < '1')
|
|
139
|
+
continue;
|
|
140
|
+
if (t <= (inside.get(w) ?? 0))
|
|
141
|
+
here++;
|
|
142
|
+
if (t <= (all.get(w) ?? 0) - (inside.get(w) ?? 0))
|
|
143
|
+
away++;
|
|
144
|
+
}
|
|
145
|
+
const walk = (up, strange) => {
|
|
146
|
+
for (const el of kidsOf(up).filter(isPart)) {
|
|
147
|
+
const w = written(el, memo);
|
|
148
|
+
if (isGroup(el)) {
|
|
149
|
+
walk(el, strange || over(w, inside.get(w) ?? 0));
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const n = (seen.get(w) ?? 0) + 1;
|
|
153
|
+
seen.set(w, n);
|
|
154
|
+
if (!over(w, n))
|
|
155
|
+
old++;
|
|
156
|
+
else if (w < top)
|
|
157
|
+
fresh++;
|
|
158
|
+
else
|
|
159
|
+
dark++;
|
|
160
|
+
if (strange && over(w, inside.get(w) ?? 0))
|
|
161
|
+
alien = true;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
walk(g, false);
|
|
165
|
+
return here > away && !odd(g) && !copied(g, memo) && !alien && 3 * fresh <= old + fresh && (4 * here > 3 * shapes.length || !(fresh || dark));
|
|
166
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RetouchedRecord } from '@open-artifact/motion-core';
|
|
2
|
+
import type { ReadMemo } from './entry.ts';
|
|
3
|
+
import type { LineMemo } from './seat.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Draws a moment of the stretch, in its own seconds. true: drawn; false: the film threw there; null: nothing more can
|
|
6
|
+
* be drawn this load (a render gave a promise).
|
|
7
|
+
*/
|
|
8
|
+
export type DrawMoment = (s: number) => boolean | null;
|
|
9
|
+
export declare const stageOf: () => HTMLElement | null;
|
|
10
|
+
/** Takes the record; the caller draws the frame again. */
|
|
11
|
+
export declare function setRecord(record: RetouchedRecord | null): void;
|
|
12
|
+
export declare const anyRetouch: () => boolean;
|
|
13
|
+
export declare const isDue: (scene: string, lo: number) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Reaches the verdicts on the entries of a stretch (lo to hi) not told yet, with no mark on the stage: at each
|
|
16
|
+
* entry's own moment, where its thing must stand, then at moments spread over the stretch, since what the film
|
|
17
|
+
* itself changes in its course is the film's. `draw` draws a second of the stretch; `far` one anywhere in the film,
|
|
18
|
+
* for an entry of another stretch.
|
|
19
|
+
*/
|
|
20
|
+
export declare function tell(scene: string, lo: number, hi: number, draw: DrawMoment, far: DrawMoment): void;
|
|
21
|
+
/** Marks what is laid on the stretch just drawn, which starts at lo. scene null: nothing is laid (a rough scene is a sketch). */
|
|
22
|
+
export declare function apply(scene: string | null, lo: number): void;
|
|
23
|
+
/** The entries whose own moment lies in the stretch and whose thing could not be told then, or is another entry's. */
|
|
24
|
+
export declare function lostIn(scene: string, lo: number, hi: number): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Of those, the hides that would count on their thing, where another entry's hide is laid: the thing is hidden all the
|
|
27
|
+
* same, so the page says nothing of them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function underHideIn(scene: string, lo: number, hi: number): string[];
|
|
30
|
+
/** Told of each scene's box as it comes up: notes the classes in it, so a class counts as an element's own alike in every runner. */
|
|
31
|
+
export declare function noteBox(node: HTMLElement): void;
|
|
32
|
+
/** The kin of an element held to the classes `cls`, on the stage as it is now. */
|
|
33
|
+
export declare function kinFor(el: Element, cls: string, memo: ReadMemo): string | null;
|
|
34
|
+
/** The parts a hide on this g inside an svg would also be found by, on the stage as it is now; null: none would hold. */
|
|
35
|
+
export declare function partsFor(el: Element, memo: ReadMemo): string | null;
|
|
36
|
+
/** The line of words a text node of the stage is part of. */
|
|
37
|
+
export declare function lineFor(node: Node, memo: Map<Element, LineMemo>): string | null;
|