@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,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.js';
|
|
2
|
+
import type { TypeKey } from './type-style.js';
|
|
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,19 @@
|
|
|
1
|
+
import type { OwnTextStyle } from '../../protocol.js';
|
|
2
|
+
export declare const OWN_TEXT_STYLES: readonly OwnTextStyle[];
|
|
3
|
+
/** What one word showed of the style tried, before the trial and during it. */
|
|
4
|
+
export interface WordTrial {
|
|
5
|
+
before: string;
|
|
6
|
+
during: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Whether the style tried is the words' own: the line took the trial, and no word that showed the line's value
|
|
10
|
+
* followed it. A trial the line did not take tells nothing, so the control stays. Pure.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ownByTrial(line: WordTrial, words: readonly WordTrial[]): boolean;
|
|
13
|
+
/** A value for the trial that differs from the line's own. Pure. */
|
|
14
|
+
export declare function trialValue(key: OwnTextStyle, now: number | string): number | string;
|
|
15
|
+
/**
|
|
16
|
+
* The styles of the line `el` that its words all set for themselves, of those `now` offers (a null is not offered).
|
|
17
|
+
* Reads layout; run with no mark of the record's on the stage. A trial that throws tells nothing: none.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ownStyles(stage: HTMLElement, el: Element, now: Partial<Record<OwnTextStyle, number | string | null>>): OwnTextStyle[];
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { SKIP, isArtWords, isPen } from "../layers/parts.js";
|
|
2
|
+
import { typeRule } from "./type-style.js";
|
|
3
|
+
/*
|
|
4
|
+
* Which of a line's styles its words all set for themselves. A change by hand is laid on the line's element; a word
|
|
5
|
+
* that sets its own weight (a span, a <b>) keeps it whatever the line says. Where no word would show a change, the
|
|
6
|
+
* panel offers no control for it but says why.
|
|
7
|
+
*
|
|
8
|
+
* Each style is tried in turn: a made-up value is laid on the line the way a saved change is (in its own sheet in the
|
|
9
|
+
* stage, by an attribute on the element), every word is read before and after, and everything is put back.
|
|
10
|
+
*/
|
|
11
|
+
export const OWN_TEXT_STYLES = ['weight', 'italic', 'px', 'tracking', 'ink'];
|
|
12
|
+
/** The attribute the trial's rules go by; on the line only while one style is tried. */
|
|
13
|
+
const TRYING = 'data-film-trying';
|
|
14
|
+
/** What a word shows of one style, as computed. Letter spacing in px: a word has the line's spacing where it is the same width. */
|
|
15
|
+
function shownOf(cs, key, art) {
|
|
16
|
+
switch (key) {
|
|
17
|
+
case 'weight':
|
|
18
|
+
return cs.fontWeight;
|
|
19
|
+
case 'italic':
|
|
20
|
+
return cs.fontStyle;
|
|
21
|
+
case 'px':
|
|
22
|
+
return cs.fontSize;
|
|
23
|
+
case 'tracking':
|
|
24
|
+
return cs.letterSpacing;
|
|
25
|
+
case 'ink':
|
|
26
|
+
return art ? cs.fill : cs.color;
|
|
27
|
+
default: {
|
|
28
|
+
const never = key;
|
|
29
|
+
return never;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether the style tried is the words' own: the line took the trial, and no word that showed the line's value
|
|
35
|
+
* followed it. A trial the line did not take tells nothing, so the control stays. Pure.
|
|
36
|
+
*/
|
|
37
|
+
export function ownByTrial(line, words) {
|
|
38
|
+
if (line.during === line.before || words.length === 0)
|
|
39
|
+
return false;
|
|
40
|
+
const follows = (word) => word.before === line.before && word.during !== word.before;
|
|
41
|
+
return !words.some(follows);
|
|
42
|
+
}
|
|
43
|
+
/** A value for the trial that differs from the line's own. Pure. */
|
|
44
|
+
export function trialValue(key, now) {
|
|
45
|
+
const n = typeof now === 'number' ? now : NaN;
|
|
46
|
+
switch (key) {
|
|
47
|
+
case 'weight':
|
|
48
|
+
return n >= 550 ? 200 : 800;
|
|
49
|
+
case 'italic':
|
|
50
|
+
return n === 1 ? 0 : 1;
|
|
51
|
+
case 'px':
|
|
52
|
+
return Math.max(1, Math.round((Number.isFinite(n) ? n : 16) * 1.5));
|
|
53
|
+
case 'tracking':
|
|
54
|
+
return (Number.isFinite(n) ? n : 0) + 0.25;
|
|
55
|
+
case 'ink':
|
|
56
|
+
return String(now).toLowerCase() === '#123456' ? '#654321' : '#123456';
|
|
57
|
+
default: {
|
|
58
|
+
const never = key;
|
|
59
|
+
return never;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The trial's rules, laid the way a saved change is: with !important, and again in the layer that beats the film's own !important. */
|
|
64
|
+
function trialRules(key, value, art) {
|
|
65
|
+
const declaration = key === 'ink' ? (art ? 'fill:' : 'color:') + String(value) + '!important' : typeRule(key, value);
|
|
66
|
+
const rule = '[' + TRYING + '="' + key + '"]{' + declaration + '}';
|
|
67
|
+
return rule + '@layer film-laid{' + rule + '}';
|
|
68
|
+
}
|
|
69
|
+
/** Whether an element shows: displayed, and visible where its nearest box is. */
|
|
70
|
+
function shows(el) {
|
|
71
|
+
if (getComputedStyle(el).display === 'none')
|
|
72
|
+
return false;
|
|
73
|
+
let box = el;
|
|
74
|
+
while (box.parentElement && getComputedStyle(box).display === 'contents')
|
|
75
|
+
box = box.parentElement;
|
|
76
|
+
return typeof box.checkVisibility !== 'function' || box.checkVisibility();
|
|
77
|
+
}
|
|
78
|
+
/** The elements that hold the line's words themselves: those with text of their own, shown, and not a caption, pen or sheet. */
|
|
79
|
+
function wordHolders(el) {
|
|
80
|
+
const out = [];
|
|
81
|
+
const walk = (at) => {
|
|
82
|
+
if (SKIP.test(at.tagName) || isPen(at) || at.hasAttribute('data-film-held') || at.hasAttribute('data-film-title') || at.hasAttribute('data-film-placed') || at.classList.contains('film-caption'))
|
|
83
|
+
return;
|
|
84
|
+
let worded = false;
|
|
85
|
+
for (let n = at.firstChild; n; n = n.nextSibling) {
|
|
86
|
+
if (n instanceof Element)
|
|
87
|
+
walk(n);
|
|
88
|
+
else if (!worded && n instanceof Text && /\S/.test(n.data))
|
|
89
|
+
worded = true;
|
|
90
|
+
}
|
|
91
|
+
if (worded && shows(at))
|
|
92
|
+
out.push(at);
|
|
93
|
+
};
|
|
94
|
+
walk(el);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The styles of the line `el` that its words all set for themselves, of those `now` offers (a null is not offered).
|
|
99
|
+
* Reads layout; run with no mark of the record's on the stage. A trial that throws tells nothing: none.
|
|
100
|
+
*/
|
|
101
|
+
export function ownStyles(stage, el, now) {
|
|
102
|
+
const keys = OWN_TEXT_STYLES.filter((key) => now[key] !== null && now[key] !== undefined);
|
|
103
|
+
if (keys.length === 0)
|
|
104
|
+
return [];
|
|
105
|
+
const words = wordHolders(el);
|
|
106
|
+
if (words.length === 0)
|
|
107
|
+
return [];
|
|
108
|
+
const art = isArtWords(el);
|
|
109
|
+
const sheet = document.createElement('style');
|
|
110
|
+
const had = el.getAttribute(TRYING);
|
|
111
|
+
const out = [];
|
|
112
|
+
try {
|
|
113
|
+
stage.appendChild(sheet);
|
|
114
|
+
for (const key of keys) {
|
|
115
|
+
const value = now[key];
|
|
116
|
+
if (value === null || value === undefined)
|
|
117
|
+
continue;
|
|
118
|
+
const lineBefore = shownOf(getComputedStyle(el), key, art);
|
|
119
|
+
const before = words.map((word) => shownOf(getComputedStyle(word), key, art));
|
|
120
|
+
sheet.textContent = trialRules(key, trialValue(key, value), art);
|
|
121
|
+
el.setAttribute(TRYING, key);
|
|
122
|
+
const lineDuring = shownOf(getComputedStyle(el), key, art);
|
|
123
|
+
const during = words.map((word) => shownOf(getComputedStyle(word), key, art));
|
|
124
|
+
el.removeAttribute(TRYING);
|
|
125
|
+
const trials = before.map((was, i) => ({ before: was, during: during[i] ?? was }));
|
|
126
|
+
if (ownByTrial({ before: lineBefore, during: lineDuring }, trials))
|
|
127
|
+
out.push(key);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
sheet.remove();
|
|
135
|
+
if (had === null)
|
|
136
|
+
el.removeAttribute(TRYING);
|
|
137
|
+
else
|
|
138
|
+
el.setAttribute(TRYING, had);
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReadMemo } from './entry.js';
|
|
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;
|