@solidtv/solid 1.7.4 → 1.8.0-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/MIGRATION-1.8.md +270 -0
- package/dist/src/core/dom-renderer/dashedBorderStyle.d.ts +20 -0
- package/dist/src/core/dom-renderer/dashedBorderStyle.js +104 -0
- package/dist/src/core/dom-renderer/dashedBorderStyle.js.map +1 -0
- package/dist/src/core/dom-renderer/domRenderer.d.ts +14 -0
- package/dist/src/core/dom-renderer/domRenderer.js +194 -12
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/dom-renderer/domRendererTypes.d.ts +12 -2
- package/dist/src/core/elementNode.d.ts +176 -9
- package/dist/src/core/elementNode.js +1906 -411
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/flexLayout.d.ts +6 -0
- package/dist/src/core/flexLayout.js +535 -218
- package/dist/src/core/flexLayout.js.map +1 -1
- package/dist/src/core/focusManager.js +70 -23
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/fontLoaded.d.ts +10 -0
- package/dist/src/core/fontLoaded.js +26 -0
- package/dist/src/core/fontLoaded.js.map +1 -0
- package/dist/src/core/intrinsicTypes.d.ts +2 -1
- package/dist/src/core/lightningInit.js +8 -1
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/shaders.d.ts +5 -2
- package/dist/src/core/shaders.js +6 -0
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/core/states.d.ts +2 -0
- package/dist/src/core/states.js +26 -7
- package/dist/src/core/states.js.map +1 -1
- package/dist/src/core/stylePlan.d.ts +39 -0
- package/dist/src/core/stylePlan.js +159 -0
- package/dist/src/core/stylePlan.js.map +1 -0
- package/dist/src/core/utils.js +2 -2
- package/dist/src/primitives/Grid.jsx +22 -3
- package/dist/src/primitives/Grid.jsx.map +1 -1
- package/dist/src/primitives/Virtual.jsx +16 -6
- package/dist/src/primitives/Virtual.jsx.map +1 -1
- package/dist/src/primitives/utils/handleNavigation.js +29 -6
- package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
- package/dist/src/primitives/utils/withScrolling.js +2 -1
- package/dist/src/primitives/utils/withScrolling.js.map +1 -1
- package/dist/src/solidOpts.js +22 -8
- package/dist/src/solidOpts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/AI_CODING_GUIDELINES.md +7 -6
- package/docs/AI_UPGRADE_1.8.md +290 -0
- package/package.json +5 -3
- package/src/core/dom-renderer/dashedBorderStyle.ts +128 -0
- package/src/core/dom-renderer/domRenderer.ts +201 -10
- package/src/core/dom-renderer/domRendererTypes.ts +12 -0
- package/src/core/elementNode.ts +2124 -459
- package/src/core/flexLayout.ts +583 -231
- package/src/core/focusManager.ts +86 -27
- package/src/core/fontLoaded.ts +29 -0
- package/src/core/intrinsicTypes.ts +2 -0
- package/src/core/lightningInit.ts +8 -1
- package/src/core/shaders.ts +12 -0
- package/src/core/states.ts +29 -9
- package/src/core/stylePlan.ts +195 -0
- package/src/core/utils.ts +2 -2
- package/src/primitives/Grid.tsx +35 -9
- package/src/primitives/Virtual.tsx +20 -6
- package/src/primitives/utils/handleNavigation.ts +40 -6
- package/src/primitives/utils/withScrolling.ts +3 -2
- package/src/solidOpts.ts +23 -8
- package/dist/src/core/flex.d.ts +0 -2
- package/dist/src/core/flex.js +0 -285
- package/dist/src/core/flex.js.map +0 -1
- package/src/core/flex.ts +0 -332
package/src/core/elementNode.ts
CHANGED
|
@@ -16,28 +16,26 @@ import {
|
|
|
16
16
|
type DollarString,
|
|
17
17
|
} from './intrinsicTypes.js';
|
|
18
18
|
import States, { type NodeStates } from './states.js';
|
|
19
|
-
import
|
|
20
|
-
import calculateFlexNew from './flexLayout.js';
|
|
21
|
-
|
|
22
|
-
const calculateFlex = import.meta.env?.VITE_USE_NEW_FLEX
|
|
23
|
-
? calculateFlexNew
|
|
24
|
-
: calculateFlexOld;
|
|
19
|
+
import calculateFlex, { getArrayValue } from './flexLayout.js';
|
|
25
20
|
import {
|
|
26
21
|
log,
|
|
27
22
|
isArray,
|
|
28
|
-
|
|
23
|
+
isObject,
|
|
24
|
+
isString,
|
|
29
25
|
isINode,
|
|
30
26
|
isElementNode,
|
|
31
27
|
isElementText,
|
|
32
28
|
logRenderTree,
|
|
33
29
|
isFunction,
|
|
34
30
|
} from './utils.js';
|
|
31
|
+
import { compileBlock, shaderParse, type BlockPlan } from './stylePlan.js';
|
|
35
32
|
import { isDev, SHADERS_ENABLED } from './env.js';
|
|
36
33
|
import { Config, isDomRendererActive } from './config.js';
|
|
37
34
|
import type {
|
|
38
35
|
RendererMain,
|
|
39
36
|
INode,
|
|
40
37
|
AnimateProps,
|
|
38
|
+
DashedBorderProps,
|
|
41
39
|
IAnimationController,
|
|
42
40
|
LinearGradientProps,
|
|
43
41
|
RadialGradientProps,
|
|
@@ -53,6 +51,7 @@ import {
|
|
|
53
51
|
FocusNode,
|
|
54
52
|
} from './focusManager.js';
|
|
55
53
|
import { initClickInspector } from './clickInspector.js';
|
|
54
|
+
import { onFontLoaded } from './fontLoaded.js';
|
|
56
55
|
|
|
57
56
|
import {
|
|
58
57
|
IRendererNode,
|
|
@@ -65,25 +64,68 @@ import {
|
|
|
65
64
|
|
|
66
65
|
// Unified post-mutation scheduler.
|
|
67
66
|
//
|
|
68
|
-
// Three phases run in one microtask (or
|
|
67
|
+
// Three phases run in one microtask (or, for a `loaded` handler, in the
|
|
68
|
+
// renderer frame between its walks: schedulePostMutationInFrame):
|
|
69
69
|
// 1. delete-flush — destroy nodes that were removed and not re-inserted
|
|
70
|
-
// 2. layout —
|
|
70
|
+
// 2. layout — measure the texts written since the last run (and
|
|
71
|
+
// those that waited for a font), then recompute flex
|
|
72
|
+
// layout for any dirty subtree
|
|
71
73
|
// 3. focus — resolve forwardFocus on deferred elements, then apply
|
|
72
74
|
//
|
|
73
75
|
// Order matters: layout reads the rendered tree (so destroyed nodes must be
|
|
74
76
|
// gone), and focus reads the laid-out tree.
|
|
75
77
|
let postMutationQueued = false;
|
|
78
|
+
let postMutationInFrame = false;
|
|
76
79
|
let nextActiveElement: ElementNode | null = null;
|
|
77
80
|
let deferredFocusElement: ElementNode | null = null;
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
// Entries past elementDeleteCount are undefined; the array keeps its
|
|
82
|
+
// capacity between runs.
|
|
83
|
+
const elementDeleteQueue: Array<ElementNode | undefined> = [];
|
|
84
|
+
let elementDeleteCount = 0;
|
|
85
|
+
|
|
86
|
+
// The layout queue: containers bucketed by depth (the root's children are at
|
|
87
|
+
// depth 1), laid out deepest first, so a container runs after every queued
|
|
88
|
+
// container inside it. A node is in at most one bucket entry that counts
|
|
89
|
+
// (`_layoutQueued`); updateLayout() clears it, so a node laid out directly is
|
|
90
|
+
// skipped when its entry comes up. Buckets keep their capacity: no allocation
|
|
91
|
+
// per run once the tree's depth has been seen.
|
|
92
|
+
const layoutBuckets: Array<Array<ElementNode | undefined>> = [];
|
|
93
|
+
const layoutBucketSize: number[] = [];
|
|
94
|
+
let layoutMaxDepth = -1; // deepest bucket that may hold a node
|
|
95
|
+
let layoutSweepDepth = -1; // bucket the layout phase is on, -1 outside it
|
|
96
|
+
// A node was queued since the layout phase last ran to its end (one that
|
|
97
|
+
// threw leaves it set, so the entries it left run next time).
|
|
98
|
+
let layoutPending = false;
|
|
99
|
+
|
|
100
|
+
// Text measurement (design 3.4): a `<text>` whose parent lays out is sized by
|
|
101
|
+
// the renderer's synchronous `measure()` before the parent's flex, not by the
|
|
102
|
+
// walk and its `loaded` event. A write to a prop its layout reads queues it
|
|
103
|
+
// here (`TextMeasure.due`); the layout phase measures the queue and queues
|
|
104
|
+
// the parent of a text whose size, as flex reads it, changed. Entries past
|
|
105
|
+
// textMeasureCount are undefined; the array keeps its capacity.
|
|
106
|
+
const textMeasureQueue: Array<ElementNode | undefined> = [];
|
|
107
|
+
let textMeasureCount = 0;
|
|
108
|
+
// Texts whose font's description was missing when measured (`waiting`):
|
|
109
|
+
// each hears `loaded` once (the walk lays it out when the font arrives), and
|
|
110
|
+
// loadFonts() tells when a font has loaded, for those no walk visits. Both
|
|
111
|
+
// set fontWaitingDue; the layout phase then measures them.
|
|
112
|
+
const fontWaiting: ElementNode[] = [];
|
|
113
|
+
let fontWaitingDue = false;
|
|
114
|
+
// Length at which the list is next swept of texts that no longer wait
|
|
115
|
+
// (destroyed: nothing else takes them off while their font never loads).
|
|
116
|
+
// Never while measureFontWaiting walks it (`measuringFontWaiting`).
|
|
117
|
+
let fontWaitingSweepAt = 64;
|
|
118
|
+
let measuringFontWaiting = false;
|
|
119
|
+
// Re-measures in one layout phase before the rest waits for its next change:
|
|
120
|
+
// a text whose size flex writes (flexGrow, flexShrink, minWidth) settles in
|
|
121
|
+
// one or two, so more means a layout that does not converge.
|
|
122
|
+
const MAX_TEXT_SWEEPS = 16;
|
|
80
123
|
|
|
81
124
|
export function enqueueDelete(node: ElementNode, n: number): void {
|
|
82
125
|
if (node._queueDelete === undefined) {
|
|
83
126
|
node._queueDelete = n;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
127
|
+
elementDeleteQueue[elementDeleteCount++] = node;
|
|
128
|
+
schedulePostMutation();
|
|
87
129
|
} else {
|
|
88
130
|
node._queueDelete += n;
|
|
89
131
|
}
|
|
@@ -92,34 +134,102 @@ export function enqueueDelete(node: ElementNode, n: number): void {
|
|
|
92
134
|
function schedulePostMutation() {
|
|
93
135
|
if (postMutationQueued) return;
|
|
94
136
|
postMutationQueued = true;
|
|
95
|
-
if ('reprocessUpdates' in renderer.stage && renderer.stage.reprocessUpdates) {
|
|
96
|
-
renderer.stage.reprocessUpdates(runPostMutation);
|
|
97
|
-
}
|
|
98
137
|
queueMicrotask(runPostMutation);
|
|
99
138
|
}
|
|
100
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Also runs the post-mutation pass inside the renderer's current or next
|
|
142
|
+
* frame, after its walk and before the draw, so what it writes is drawn in
|
|
143
|
+
* that frame. For handlers the renderer calls between its walks (`loaded`).
|
|
144
|
+
*/
|
|
145
|
+
function schedulePostMutationInFrame(): void {
|
|
146
|
+
schedulePostMutation();
|
|
147
|
+
if (postMutationInFrame) return;
|
|
148
|
+
const stage = renderer.stage;
|
|
149
|
+
if ('reprocessUpdates' in stage && stage.reprocessUpdates) {
|
|
150
|
+
postMutationInFrame = true;
|
|
151
|
+
stage.reprocessUpdates(runPostMutation);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
101
155
|
function runPostMutation() {
|
|
102
156
|
postMutationQueued = false;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
157
|
+
postMutationInFrame = false;
|
|
158
|
+
|
|
159
|
+
// Phase 1: delete-flush (the count is read every time: a destroy can
|
|
160
|
+
// queue more). An entry is cleared before its destroy, so one whose
|
|
161
|
+
// onDestroy threw is not retried and the next run carries on after it.
|
|
162
|
+
if (elementDeleteCount > 0) {
|
|
163
|
+
for (let i = 0; i < elementDeleteCount; i++) {
|
|
164
|
+
const el = elementDeleteQueue[i];
|
|
165
|
+
elementDeleteQueue[i] = undefined;
|
|
166
|
+
if (el === undefined) continue;
|
|
167
|
+
const queued = el._queueDelete ?? 0;
|
|
168
|
+
el._queueDelete = undefined;
|
|
169
|
+
if (queued < 0) {
|
|
108
170
|
el.destroy();
|
|
109
171
|
}
|
|
110
|
-
el._queueDelete = undefined;
|
|
111
172
|
}
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Phase 2: layout
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
173
|
+
elementDeleteCount = 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Phase 2: layout. Inline, not a function of its own: terser's default
|
|
177
|
+
// `reduce_funcs` turns a module function with one call site into a
|
|
178
|
+
// closure per call (as with every helper on this path).
|
|
179
|
+
if (fontWaitingDue === true) {
|
|
180
|
+
TextMeasure.measureFontWaiting();
|
|
181
|
+
}
|
|
182
|
+
if (layoutPending === true || textMeasureCount > 0) {
|
|
183
|
+
measureQueuedTexts();
|
|
184
|
+
// Start from the deepest bucket there is, so entries a run that threw
|
|
185
|
+
// left behind are not stranded.
|
|
186
|
+
layoutMaxDepth = layoutBuckets.length - 1;
|
|
187
|
+
let textSweeps = 0;
|
|
188
|
+
while (layoutMaxDepth >= 0) {
|
|
189
|
+
let depth = layoutMaxDepth;
|
|
190
|
+
layoutMaxDepth = -1;
|
|
191
|
+
for (; depth >= 0; depth--) {
|
|
192
|
+
layoutSweepDepth = depth;
|
|
193
|
+
const bucket = layoutBuckets[depth]!;
|
|
194
|
+
// Read the size every time: a run can queue more at this depth.
|
|
195
|
+
for (let i = 0; i < layoutBucketSize[depth]!; i++) {
|
|
196
|
+
const node = bucket[i];
|
|
197
|
+
bucket[i] = undefined;
|
|
198
|
+
if (node !== undefined && node._layoutQueued === true) {
|
|
199
|
+
node.updateLayout();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
layoutBucketSize[depth] = 0;
|
|
203
|
+
}
|
|
204
|
+
layoutSweepDepth = -1;
|
|
205
|
+
// Texts the sweep wrote (flex sizing a text, an onLayout): measured
|
|
206
|
+
// now, so the container of one that resized runs again in another
|
|
207
|
+
// sweep.
|
|
208
|
+
if (textMeasureCount > 0 && textSweeps < MAX_TEXT_SWEEPS) {
|
|
209
|
+
textSweeps++;
|
|
210
|
+
measureQueuedTexts();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (textMeasureCount > 0) {
|
|
214
|
+
// Not converging: drop the rest (each is measured again at its next
|
|
215
|
+
// change), or the run its writes scheduled would start over.
|
|
216
|
+
for (let i = 0; i < textMeasureCount; i++) {
|
|
217
|
+
const t = textMeasureQueue[i];
|
|
218
|
+
textMeasureQueue[i] = undefined;
|
|
219
|
+
if (t !== undefined) {
|
|
220
|
+
t._text!.due = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
textMeasureCount = 0;
|
|
224
|
+
if (isDev) {
|
|
225
|
+
console.warn(
|
|
226
|
+
'[solid] Text sizes did not settle in ' +
|
|
227
|
+
MAX_TEXT_SWEEPS +
|
|
228
|
+
' layout passes (a layout that changes the size of a text it lays out); the rest waits for its next change.',
|
|
229
|
+
);
|
|
230
|
+
}
|
|
122
231
|
}
|
|
232
|
+
layoutPending = false;
|
|
123
233
|
}
|
|
124
234
|
|
|
125
235
|
// Phase 3: focus. setFocus() may have evaluated forwardFocus pre-render
|
|
@@ -136,28 +246,204 @@ function runPostMutation() {
|
|
|
136
246
|
}
|
|
137
247
|
}
|
|
138
248
|
|
|
139
|
-
function
|
|
140
|
-
|
|
249
|
+
function enqueueLayout(node: ElementNode): void {
|
|
250
|
+
if (node._layoutQueued === true) return;
|
|
251
|
+
node._layoutQueued = true;
|
|
252
|
+
layoutPending = true;
|
|
253
|
+
// The depth in its tree: a removed node's tree ends at it.
|
|
254
|
+
let depth = 0;
|
|
255
|
+
for (
|
|
256
|
+
let n: ElementNode = node, p = n.parent;
|
|
257
|
+
n._detached !== true && p !== undefined && p !== null;
|
|
258
|
+
n = p, p = n.parent
|
|
259
|
+
) {
|
|
260
|
+
depth++;
|
|
261
|
+
}
|
|
262
|
+
while (layoutBuckets.length <= depth) {
|
|
263
|
+
layoutBuckets.push([]);
|
|
264
|
+
layoutBucketSize.push(0);
|
|
265
|
+
}
|
|
266
|
+
const size = layoutBucketSize[depth]!;
|
|
267
|
+
layoutBuckets[depth]![size] = node;
|
|
268
|
+
layoutBucketSize[depth] = size + 1;
|
|
269
|
+
// During a sweep, a node at the bucket being run or shallower is reached
|
|
270
|
+
// by that sweep; a deeper one needs another.
|
|
271
|
+
if (depth > layoutMaxDepth && depth > layoutSweepDepth) {
|
|
272
|
+
layoutMaxDepth = depth;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Queue `node`'s layout (flex and `onLayout`) for the post-mutation pass.
|
|
278
|
+
* Within one pass, containers run deepest first, each at most once unless a
|
|
279
|
+
* child's size changed after its run.
|
|
280
|
+
*/
|
|
281
|
+
function queueLayout(node: ElementNode): void {
|
|
282
|
+
enqueueLayout(node);
|
|
141
283
|
schedulePostMutation();
|
|
142
284
|
}
|
|
143
285
|
|
|
144
286
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
287
|
+
* Measures the texts written since the last call (`_textLayoutDirty`) and
|
|
288
|
+
* queues the parent of each whose size, as flex reads it, changed. A text
|
|
289
|
+
* the parent's updateLayout() measured already is skipped.
|
|
148
290
|
*/
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
291
|
+
function measureQueuedTexts(): void {
|
|
292
|
+
for (let i = 0; i < textMeasureCount; i++) {
|
|
293
|
+
const t = textMeasureQueue[i];
|
|
294
|
+
textMeasureQueue[i] = undefined;
|
|
295
|
+
// Cleared by a run that threw part way (the count was not reset).
|
|
296
|
+
if (t === undefined) {
|
|
297
|
+
continue;
|
|
155
298
|
}
|
|
156
|
-
|
|
299
|
+
const m = t._text!;
|
|
300
|
+
if (m.due !== true) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const parent = t._parent;
|
|
304
|
+
if (parent === undefined || parent._requiresLayout !== true) {
|
|
305
|
+
// Moved out, or the parent stopped laying out: nothing to size.
|
|
306
|
+
m.due = false;
|
|
307
|
+
m.w = NaN;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (t._measureText() === true) {
|
|
311
|
+
enqueueLayout(parent);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
textMeasureCount = 0;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* A text that waited for its font heard `loaded`: the walk laid it out, as
|
|
319
|
+
* the font's description arrived. Shared by every waiting text (no closure
|
|
320
|
+
* per text); the layout phase, in this frame, measures them all.
|
|
321
|
+
*/
|
|
322
|
+
function fontWaitHeard(): void {
|
|
323
|
+
fontWaitingDue = true;
|
|
324
|
+
schedulePostMutationInFrame();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Drops the texts that no longer wait for a font (destroyed ones). */
|
|
328
|
+
function sweepFontWaiting(): void {
|
|
329
|
+
let kept = 0;
|
|
330
|
+
for (let i = 0; i < fontWaiting.length; i++) {
|
|
331
|
+
const t = fontWaiting[i]!;
|
|
332
|
+
if (t._text!.waiting === true && t.destroyed !== true) {
|
|
333
|
+
fontWaiting[kept++] = t;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
fontWaiting.length = kept;
|
|
337
|
+
fontWaitingSweepAt = kept * 2 > 64 ? kept * 2 : 64;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* What Solid knows of a `<text>` it measures (`ElementNode._text`), made the
|
|
342
|
+
* first time: only texts in a container that lays out have one. Its sizes
|
|
343
|
+
* start as doubles, so storing a measured size allocates nothing.
|
|
344
|
+
*/
|
|
345
|
+
class TextMeasure {
|
|
346
|
+
// `declare`d, assigned in the constructor: a class field would be emitted
|
|
347
|
+
// as a native field that starts undefined (design 3.6.5).
|
|
348
|
+
/** A prop its layout reads was written since it was last measured; queued. */
|
|
349
|
+
declare due: boolean;
|
|
350
|
+
/** Its font was missing when measured (`_waitForFont`). */
|
|
351
|
+
declare waiting: boolean;
|
|
352
|
+
/** Width and height, as flex reads them, when last measured; NaN before. */
|
|
353
|
+
declare w: number;
|
|
354
|
+
declare h: number;
|
|
355
|
+
/**
|
|
356
|
+
* Hears every layout (`_listenTextLoaded`): a text Solid animated a layout
|
|
357
|
+
* prop of, and every measured text in DOM builds. For its lifetime.
|
|
358
|
+
*/
|
|
359
|
+
declare listening: boolean;
|
|
360
|
+
|
|
361
|
+
constructor() {
|
|
362
|
+
this.due = false;
|
|
363
|
+
this.waiting = false;
|
|
364
|
+
this.w = NaN;
|
|
365
|
+
this.h = NaN;
|
|
366
|
+
this.listening = false;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Measures the texts that waited for a font (`_waitForFont`): one whose
|
|
371
|
+
* font is there now stops waiting and, if its size changed, queues its
|
|
372
|
+
* parent; one whose font is still missing waits again. A method, not a
|
|
373
|
+
* module function: the post-mutation pass is its one caller, and terser's
|
|
374
|
+
* default `reduce_funcs` turns such a function into a closure per call.
|
|
375
|
+
* (Its own: the try would keep that pass from being optimized.)
|
|
376
|
+
*/
|
|
377
|
+
static measureFontWaiting(): void {
|
|
378
|
+
fontWaitingDue = false;
|
|
379
|
+
const n = fontWaiting.length;
|
|
380
|
+
// A text whose font is still missing is appended again (_waitForFont),
|
|
381
|
+
// which must not sweep the list under this loop.
|
|
382
|
+
measuringFontWaiting = true;
|
|
383
|
+
try {
|
|
384
|
+
for (let i = 0; i < n; i++) {
|
|
385
|
+
const t = fontWaiting[i]!;
|
|
386
|
+
const m = t._text!;
|
|
387
|
+
if (m.waiting !== true) {
|
|
388
|
+
continue; // measured meanwhile
|
|
389
|
+
}
|
|
390
|
+
// Off first, so a measure() now queues no `loaded` for it.
|
|
391
|
+
(t.lng as IRendererTextNode).off('loaded', fontWaitHeard);
|
|
392
|
+
m.waiting = false;
|
|
393
|
+
if (t.destroyed === true) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const parent = t._parent;
|
|
397
|
+
if (
|
|
398
|
+
parent === undefined ||
|
|
399
|
+
t._detached === true ||
|
|
400
|
+
parent._requiresLayout !== true
|
|
401
|
+
) {
|
|
402
|
+
m.w = NaN;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
// Waits again (appended past n) while the font is still missing.
|
|
406
|
+
if (t._measureText() === true) {
|
|
407
|
+
enqueueLayout(parent);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} finally {
|
|
411
|
+
measuringFontWaiting = false;
|
|
412
|
+
}
|
|
413
|
+
// Keep the entries appended meanwhile, without allocating.
|
|
414
|
+
const length = fontWaiting.length;
|
|
415
|
+
for (let i = n; i < length; i++) {
|
|
416
|
+
fontWaiting[i - n] = fontWaiting[i]!;
|
|
417
|
+
}
|
|
418
|
+
fontWaiting.length = length - n;
|
|
157
419
|
}
|
|
158
|
-
return index;
|
|
159
420
|
}
|
|
160
421
|
|
|
422
|
+
/**
|
|
423
|
+
* The settings of an animation that has none (no `animationSettings` on the
|
|
424
|
+
* node or in Config): one object, so renderer v2's animateProp, which reuses
|
|
425
|
+
* its controller for the same settings object, retargets a running one
|
|
426
|
+
* rather than stopping it and making another per write. Nothing writes it.
|
|
427
|
+
*/
|
|
428
|
+
const NO_ANIMATION_SETTINGS: Readonly<AnimationSettings> = Object.freeze({});
|
|
429
|
+
|
|
430
|
+
/** onAnimation.stopped for one write, after its duration and delay. */
|
|
431
|
+
function fireAnimationStopped(
|
|
432
|
+
node: ElementNode,
|
|
433
|
+
stopped: AnimationEventHandler,
|
|
434
|
+
name: string,
|
|
435
|
+
value: number,
|
|
436
|
+
): void {
|
|
437
|
+
stopped.call(node, name, value);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
onFontLoaded(() => {
|
|
441
|
+
if (fontWaiting.length > 0) {
|
|
442
|
+
fontWaitingDue = true;
|
|
443
|
+
schedulePostMutation();
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
161
447
|
// Text-default template, built once on first use. Config.fontSettings is
|
|
162
448
|
// expected to be set at app startup and not change afterwards.
|
|
163
449
|
let _fontTemplate: Array<[string, any]> | undefined;
|
|
@@ -188,55 +474,23 @@ const EFFECT_SHADER_KEYS = [
|
|
|
188
474
|
'shadow',
|
|
189
475
|
] as const satisfies ReadonlyArray<keyof StyleEffects>;
|
|
190
476
|
|
|
191
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
192
|
-
|
|
193
|
-
// Handle individual border sides: transform width/w to bottom/left/right/top
|
|
194
|
-
const borderSideMap: Record<string, string> = {
|
|
195
|
-
borderBottom: 'bottom',
|
|
196
|
-
borderLeft: 'left',
|
|
197
|
-
borderRight: 'right',
|
|
198
|
-
borderTop: 'top',
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// The shader prop each key of a style object writes, per style prefix
|
|
202
|
-
// (`border` + `width` → `border-w`, `borderTop` + `w` → `border-top`): built
|
|
203
|
-
// at a key's first write, so that a write builds no string.
|
|
204
|
-
const shaderPropNames: Record<string, Record<string, string> | undefined> =
|
|
205
|
-
Object.create(null);
|
|
206
|
-
|
|
207
477
|
const parseAndAssignShaderProps = (
|
|
208
478
|
prefix: string,
|
|
209
479
|
obj: Record<string, unknown>,
|
|
210
|
-
props: Record<string, unknown
|
|
480
|
+
props: Record<string, unknown>,
|
|
211
481
|
) => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// The object's own enumerable keys in order, as Object.entries gave them,
|
|
224
|
-
// without its arrays and closure.
|
|
225
|
-
for (const key in obj) {
|
|
226
|
-
if (!hasOwnProperty.call(obj, key)) continue;
|
|
227
|
-
let name = names[key];
|
|
228
|
-
if (name === undefined) {
|
|
229
|
-
let transformedKey = key === 'width' ? 'w' : key;
|
|
230
|
-
|
|
231
|
-
// If border side and key is width/w, transform to side (bottom/left/right/top)
|
|
232
|
-
if (side && transformedKey === 'w') {
|
|
233
|
-
transformedKey = side;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
name = actualPrefix + '-' + transformedKey;
|
|
237
|
-
names[key] = name;
|
|
482
|
+
// Parsed once per object (stylePlan.ts): `border` and `border-w`, ... A
|
|
483
|
+
// sub-prop the props already hold with that value is not written again
|
|
484
|
+
// (a facade write repacks); the result is the merge 1.6's writes gave.
|
|
485
|
+
const parse = shaderParse(prefix, obj);
|
|
486
|
+
const keys = parse.keys;
|
|
487
|
+
const values = parse.values;
|
|
488
|
+
for (let i = 0; i < keys.length; i++) {
|
|
489
|
+
const name = keys[i]!;
|
|
490
|
+
const value = values[i];
|
|
491
|
+
if (props[name] !== value) {
|
|
492
|
+
props[name] = value;
|
|
238
493
|
}
|
|
239
|
-
props[name] = obj[key];
|
|
240
494
|
}
|
|
241
495
|
};
|
|
242
496
|
|
|
@@ -244,19 +498,10 @@ const assignEffects = (v: StyleEffects, props: Record<string, unknown>) => {
|
|
|
244
498
|
if (v.rounded) props.radius = v.rounded.radius;
|
|
245
499
|
if (v.borderRadius) props.radius = v.borderRadius;
|
|
246
500
|
for (const k of EFFECT_SHADER_KEYS) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const assignShaderProp = (
|
|
252
|
-
key: string,
|
|
253
|
-
value: unknown,
|
|
254
|
-
props: Record<string, unknown>,
|
|
255
|
-
) => {
|
|
256
|
-
if (key === 'rounded' || typeof value === 'number') {
|
|
257
|
-
props.radius = value;
|
|
258
|
-
} else {
|
|
259
|
-
parseAndAssignShaderProps(key, value as Record<string, unknown>, props);
|
|
501
|
+
const obj = v[k];
|
|
502
|
+
if (isObject(obj)) {
|
|
503
|
+
parseAndAssignShaderProps(k, obj, props);
|
|
504
|
+
}
|
|
260
505
|
}
|
|
261
506
|
};
|
|
262
507
|
|
|
@@ -295,6 +540,120 @@ const hasBorderWidth = (
|
|
|
295
540
|
return false;
|
|
296
541
|
};
|
|
297
542
|
|
|
543
|
+
const copyOf = (value: unknown): unknown =>
|
|
544
|
+
isArray(value) ? value.slice() : value;
|
|
545
|
+
|
|
546
|
+
/** A renderer `AdvancedProp`, as far as the gradient update reads it. */
|
|
547
|
+
interface AdvancedPropLike {
|
|
548
|
+
default?: unknown;
|
|
549
|
+
resolve?: unknown;
|
|
550
|
+
set?: unknown;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** The gradient shaders the raw accessors made, by accessor key. */
|
|
554
|
+
const gradientShaders = new WeakMap<object, string>();
|
|
555
|
+
|
|
556
|
+
/** Marks a key a state change tracks but has not written yet. */
|
|
557
|
+
const UNWRITTEN = {};
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* The border family: the style keys whose objects write the `border-*`
|
|
561
|
+
* shader props (a `border` write sets all four widths, a side its own).
|
|
562
|
+
*/
|
|
563
|
+
const BORDER_FAMILY: Record<string, boolean | undefined> = {
|
|
564
|
+
border: true,
|
|
565
|
+
borderTop: true,
|
|
566
|
+
borderRight: true,
|
|
567
|
+
borderBottom: true,
|
|
568
|
+
borderLeft: true,
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Append the keys of the `$state` block `block` that `keys` does not hold
|
|
573
|
+
* yet (they are written for the first time). Returns the new count.
|
|
574
|
+
*/
|
|
575
|
+
function trackKeys(
|
|
576
|
+
block: unknown,
|
|
577
|
+
keys: string[],
|
|
578
|
+
count: number,
|
|
579
|
+
applied: Record<string, unknown>,
|
|
580
|
+
): number {
|
|
581
|
+
if (!isObject(block)) {
|
|
582
|
+
return count;
|
|
583
|
+
}
|
|
584
|
+
const blockKeys = compileBlock(block).keys;
|
|
585
|
+
for (let j = 0; j < blockKeys.length; j++) {
|
|
586
|
+
const key = blockKeys[j]!;
|
|
587
|
+
let k = 0;
|
|
588
|
+
while (k < count && keys[k] !== key) {
|
|
589
|
+
k++;
|
|
590
|
+
}
|
|
591
|
+
if (k === count) {
|
|
592
|
+
if (count < keys.length) {
|
|
593
|
+
keys[count] = key;
|
|
594
|
+
} else {
|
|
595
|
+
keys.push(key);
|
|
596
|
+
}
|
|
597
|
+
count++;
|
|
598
|
+
applied[key] = UNWRITTEN;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return count;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** The base value undo restores: theme[key], else style[key] (pinned). */
|
|
605
|
+
function styleFallback(node: ElementNode, key: string): unknown {
|
|
606
|
+
const theme = node._theme as Record<string, unknown> | undefined;
|
|
607
|
+
let value = theme !== undefined ? theme[key] : undefined;
|
|
608
|
+
if (value === undefined) {
|
|
609
|
+
const style = node._style as Record<string, unknown> | undefined;
|
|
610
|
+
if (style !== undefined) {
|
|
611
|
+
value = style[key];
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if (isDev && value === undefined) {
|
|
615
|
+
console.warn('fallback style key not found: ', key);
|
|
616
|
+
}
|
|
617
|
+
return value;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* The value `key` takes with `states` on: from the block of the state of
|
|
622
|
+
* highest precedence that has it (the later in `order`, then the later
|
|
623
|
+
* added; `order` undefined: the later added), else the base value.
|
|
624
|
+
*/
|
|
625
|
+
function resolveStateValue(
|
|
626
|
+
node: ElementNode,
|
|
627
|
+
key: string,
|
|
628
|
+
states: States,
|
|
629
|
+
order: DollarString[] | undefined,
|
|
630
|
+
): unknown {
|
|
631
|
+
let best = -2;
|
|
632
|
+
let plan: BlockPlan | undefined;
|
|
633
|
+
let at = 0;
|
|
634
|
+
for (let i = 0; i < states.length; i++) {
|
|
635
|
+
const state = states[i]!;
|
|
636
|
+
const block = node[state];
|
|
637
|
+
if (isObject(block)) {
|
|
638
|
+
const candidate = compileBlock(block);
|
|
639
|
+
const pos = candidate.index[key];
|
|
640
|
+
if (pos !== undefined) {
|
|
641
|
+
const rank = order === undefined ? -1 : order.indexOf(state);
|
|
642
|
+
if (rank >= best) {
|
|
643
|
+
best = rank;
|
|
644
|
+
plan = candidate;
|
|
645
|
+
at = pos;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (plan === undefined) {
|
|
651
|
+
return styleFallback(node, key);
|
|
652
|
+
}
|
|
653
|
+
// A getter is read now, each time the state is applied (pinned).
|
|
654
|
+
return plan.getters[at] === true ? plan.block[key] : plan.values[at];
|
|
655
|
+
}
|
|
656
|
+
|
|
298
657
|
export function convertToShader(
|
|
299
658
|
node: ElementNode,
|
|
300
659
|
v: StyleEffects,
|
|
@@ -311,89 +670,6 @@ export function convertToShader(
|
|
|
311
670
|
) as IRendererShader;
|
|
312
671
|
}
|
|
313
672
|
|
|
314
|
-
function getPropertyAlias(name: string) {
|
|
315
|
-
if (name === 'w') return 'width';
|
|
316
|
-
if (name === 'h') return 'height';
|
|
317
|
-
return name;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const LightningRendererNumberProps = [
|
|
321
|
-
'alpha',
|
|
322
|
-
'color',
|
|
323
|
-
'colorTop',
|
|
324
|
-
'colorRight',
|
|
325
|
-
'colorLeft',
|
|
326
|
-
'colorBottom',
|
|
327
|
-
'colorTl',
|
|
328
|
-
'colorTr',
|
|
329
|
-
'colorBl',
|
|
330
|
-
'colorBr',
|
|
331
|
-
'h',
|
|
332
|
-
'fontSize',
|
|
333
|
-
'lineHeight',
|
|
334
|
-
'mount',
|
|
335
|
-
'mountX',
|
|
336
|
-
'mountY',
|
|
337
|
-
'pivot',
|
|
338
|
-
'pivotX',
|
|
339
|
-
'pivotY',
|
|
340
|
-
'rotation',
|
|
341
|
-
'scale',
|
|
342
|
-
'scaleX',
|
|
343
|
-
'scaleY',
|
|
344
|
-
'w',
|
|
345
|
-
'worldX',
|
|
346
|
-
'worldY',
|
|
347
|
-
'x',
|
|
348
|
-
'y',
|
|
349
|
-
'zIndex',
|
|
350
|
-
'zIndexLocked',
|
|
351
|
-
];
|
|
352
|
-
|
|
353
|
-
const LightningRendererNonAnimatingProps = [
|
|
354
|
-
'absX',
|
|
355
|
-
'absY',
|
|
356
|
-
'atlasGroup',
|
|
357
|
-
'autosize',
|
|
358
|
-
'clipping',
|
|
359
|
-
'contain',
|
|
360
|
-
'componentName',
|
|
361
|
-
'componentLocation',
|
|
362
|
-
'data',
|
|
363
|
-
'destroyed',
|
|
364
|
-
'forceLoad',
|
|
365
|
-
'fontStretch',
|
|
366
|
-
'fontStyle',
|
|
367
|
-
'group',
|
|
368
|
-
'ignoreParentAlpha',
|
|
369
|
-
'imageType',
|
|
370
|
-
'letterSpacing',
|
|
371
|
-
'maxHeight',
|
|
372
|
-
'maxLines',
|
|
373
|
-
'maxWidth',
|
|
374
|
-
'offsetY',
|
|
375
|
-
'overflowSuffix',
|
|
376
|
-
'placeholderColor',
|
|
377
|
-
'preventCleanup',
|
|
378
|
-
'scrollable',
|
|
379
|
-
'scrollY',
|
|
380
|
-
'srcHeight',
|
|
381
|
-
'srcWidth',
|
|
382
|
-
'srcX',
|
|
383
|
-
'srcY',
|
|
384
|
-
'strictBounds',
|
|
385
|
-
'text',
|
|
386
|
-
'textAlign',
|
|
387
|
-
'textBaseline',
|
|
388
|
-
'textOverflow',
|
|
389
|
-
'texture',
|
|
390
|
-
'textureOptions',
|
|
391
|
-
'textRendererOverride',
|
|
392
|
-
'verticalAlign',
|
|
393
|
-
'wordBreak',
|
|
394
|
-
'wordWrap',
|
|
395
|
-
];
|
|
396
|
-
|
|
397
673
|
declare global {
|
|
398
674
|
interface HTMLElement {
|
|
399
675
|
/** Assigned for development, to quickly get ElementNode from selected HTMLElement */
|
|
@@ -429,6 +705,23 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
429
705
|
_animationSettings?: AnimationSettings;
|
|
430
706
|
_autofocus?: any;
|
|
431
707
|
_containsFlexGrow?: boolean | null;
|
|
708
|
+
/** @internal flexGrow/flexShrink record (B8): the size before the last growth or shrink. */
|
|
709
|
+
_flexBase?: number;
|
|
710
|
+
/** @internal flexGrow/flexShrink record (B8): the size the last growth or shrink wrote. */
|
|
711
|
+
_flexGrown?: number;
|
|
712
|
+
/** @internal the last x, y, width, height flex wrote with a transition */
|
|
713
|
+
_flexX?: number;
|
|
714
|
+
_flexY?: number;
|
|
715
|
+
_flexW?: number;
|
|
716
|
+
_flexH?: number;
|
|
717
|
+
/** @internal in the layout queue (queueLayout) */
|
|
718
|
+
_layoutQueued: boolean;
|
|
719
|
+
/**
|
|
720
|
+
* @internal a `<text>` in a container that lays out: what Solid's text
|
|
721
|
+
* measurement knows of it (`_textLayoutDirty`, `_measureText`); undefined
|
|
722
|
+
* until it is first queued or measured
|
|
723
|
+
*/
|
|
724
|
+
_text: TextMeasure | undefined;
|
|
432
725
|
_hasRenderedChildren?: boolean;
|
|
433
726
|
_effects?: Record<string, any>;
|
|
434
727
|
/** The props of a shader convertToShader made, kept to swap its type. */
|
|
@@ -441,10 +734,23 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
441
734
|
_rendererProps?: any;
|
|
442
735
|
_states?: States;
|
|
443
736
|
_style?: Styles;
|
|
737
|
+
/** @internal text-only props written to an element that is not a `<text>` (B20) */
|
|
738
|
+
_textProps?: Record<string, unknown>;
|
|
739
|
+
/**
|
|
740
|
+
* @internal removed from its parent's children and not inserted since. Its
|
|
741
|
+
* `parent` link stays (1.6: keys and events still bubble through it), but
|
|
742
|
+
* it does not lay out that parent.
|
|
743
|
+
*/
|
|
744
|
+
_detached: boolean;
|
|
444
745
|
_theme?: Styles;
|
|
445
746
|
_lastAnyKeyPressTime?: number;
|
|
446
747
|
_type: 'element' | 'textNode';
|
|
748
|
+
/** @internal The keys state changes wrote, in first-write order: undo walks them. Reused, never shrunk. */
|
|
447
749
|
_undoStyles?: string[];
|
|
750
|
+
/** @internal How many entries of `_undoStyles` are live. */
|
|
751
|
+
_undoCount: number;
|
|
752
|
+
/** @internal Per key in `_undoStyles`, the value the last state change wrote. */
|
|
753
|
+
_applied?: Record<string, unknown>;
|
|
448
754
|
_display?: 'flex' | 'block';
|
|
449
755
|
_onLayout?: (this: ElementNode, target: ElementNode) => void;
|
|
450
756
|
_requiresLayout: boolean;
|
|
@@ -502,12 +808,10 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
502
808
|
/**
|
|
503
809
|
* Defines the ability for a flex item to shrink if necessary.
|
|
504
810
|
* Defaults to 0 since existing legacy implementations did not shrink layout boxes.
|
|
505
|
-
* Only available in NEW flex layout.
|
|
506
811
|
*/
|
|
507
812
|
flexShrink?: number;
|
|
508
813
|
/**
|
|
509
814
|
* Defines the default size of an element before the remaining space is distributed.
|
|
510
|
-
* Only available in NEW flex layout.
|
|
511
815
|
*/
|
|
512
816
|
flexBasis?: number | string;
|
|
513
817
|
/**
|
|
@@ -697,6 +1001,14 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
697
1001
|
* @see https://solid-tv.github.io/solid/#/essentials/effects
|
|
698
1002
|
*/
|
|
699
1003
|
radialGradient?: RadialGradientProps;
|
|
1004
|
+
/**
|
|
1005
|
+
* Clips the element to a rounded rectangle and draws a dashed border
|
|
1006
|
+
* inside its edge. The DOM renderer draws it with CSS gradients: dash and
|
|
1007
|
+
* gap lengths match, and each rounded corner is drawn as one dash.
|
|
1008
|
+
*
|
|
1009
|
+
* @see https://solid-tv.github.io/solid/#/essentials/effects
|
|
1010
|
+
*/
|
|
1011
|
+
dashedBorder?: AddColorString<Partial<DashedBorderProps>>;
|
|
700
1012
|
/**
|
|
701
1013
|
* The margin on the bottom side of the element for a flexItem.
|
|
702
1014
|
*
|
|
@@ -871,7 +1183,6 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
871
1183
|
/**
|
|
872
1184
|
* The individual padding on each side of an element, acting as an override to the `padding` array property.
|
|
873
1185
|
* `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`.
|
|
874
|
-
* Only in the new flex engine.
|
|
875
1186
|
*
|
|
876
1187
|
* @see https://solid-tv.github.io/solid/#/flow/layout?id=flex
|
|
877
1188
|
*/
|
|
@@ -920,6 +1231,16 @@ export class ElementNode {
|
|
|
920
1231
|
this._calcWidth = undefined;
|
|
921
1232
|
this._calcHeight = undefined;
|
|
922
1233
|
this._containsFlexGrow = undefined;
|
|
1234
|
+
this._flexBase = undefined;
|
|
1235
|
+
this._flexGrown = undefined;
|
|
1236
|
+
this._flexX = undefined;
|
|
1237
|
+
this._flexY = undefined;
|
|
1238
|
+
this._flexW = undefined;
|
|
1239
|
+
this._flexH = undefined;
|
|
1240
|
+
// Written by flexLayout when it resizes a container: here, so that
|
|
1241
|
+
// write adds no field.
|
|
1242
|
+
this.preFlexwidth = undefined;
|
|
1243
|
+
this.preFlexheight = undefined;
|
|
923
1244
|
this._hasRenderedChildren = undefined;
|
|
924
1245
|
this._effects = undefined;
|
|
925
1246
|
this._shaderProps = undefined;
|
|
@@ -933,10 +1254,16 @@ export class ElementNode {
|
|
|
933
1254
|
this._theme = undefined;
|
|
934
1255
|
this._lastAnyKeyPressTime = undefined;
|
|
935
1256
|
this._undoStyles = undefined;
|
|
1257
|
+
this._undoCount = 0;
|
|
1258
|
+
this._applied = undefined;
|
|
936
1259
|
this._display = undefined;
|
|
937
1260
|
this._onLayout = undefined;
|
|
938
1261
|
this._requiresLayout = false;
|
|
939
1262
|
this._focusGen = 0;
|
|
1263
|
+
this._layoutQueued = false;
|
|
1264
|
+
this._textProps = undefined;
|
|
1265
|
+
this._detached = false;
|
|
1266
|
+
this._text = undefined;
|
|
940
1267
|
}
|
|
941
1268
|
|
|
942
1269
|
get effects(): StyleEffects | undefined {
|
|
@@ -966,7 +1293,8 @@ export class ElementNode {
|
|
|
966
1293
|
* Swap a shader convertToShader made when its border width moves to or
|
|
967
1294
|
* from 0. For an animated write, `change` holds what animates: a border
|
|
968
1295
|
* it adds is swapped in before the animation reads its start values, one
|
|
969
|
-
* it removes stays until the animation stops.
|
|
1296
|
+
* it removes stays until the animation stops. A type the app did not
|
|
1297
|
+
* register (createShader returns null) keeps the current shader.
|
|
970
1298
|
*/
|
|
971
1299
|
_syncShaderType(change?: Record<string, unknown>) {
|
|
972
1300
|
const props = this._shaderProps;
|
|
@@ -976,24 +1304,24 @@ export class ElementNode {
|
|
|
976
1304
|
if (hasBorderWidth(props, change)) next |= BORDER_FEATURE;
|
|
977
1305
|
else if (change !== undefined) next |= features & BORDER_FEATURE;
|
|
978
1306
|
if (next === features) return;
|
|
1307
|
+
const shader = renderer.createShader(ROUNDED_SHADER_TYPES[next]!, props);
|
|
1308
|
+
if (!shader) return;
|
|
979
1309
|
this._shaderFeatures = next;
|
|
980
|
-
this.lng.shader =
|
|
981
|
-
ROUNDED_SHADER_TYPES[next]!,
|
|
982
|
-
props,
|
|
983
|
-
) as IRendererShader;
|
|
1310
|
+
this.lng.shader = shader as IRendererShader;
|
|
984
1311
|
}
|
|
985
1312
|
|
|
986
1313
|
set effects(v: StyleEffects) {
|
|
987
1314
|
if (!SHADERS_ENABLED) return;
|
|
988
1315
|
let target = this.lng.shader || {};
|
|
989
|
-
|
|
990
|
-
|
|
1316
|
+
const props = this.lng.shader?.props;
|
|
1317
|
+
if (props) {
|
|
1318
|
+
target = props;
|
|
991
1319
|
}
|
|
992
1320
|
assignEffects(v, target);
|
|
993
1321
|
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
if (
|
|
1322
|
+
const kept = this._shaderProps;
|
|
1323
|
+
if (kept !== undefined) {
|
|
1324
|
+
if (kept !== target) assignEffects(v, kept);
|
|
997
1325
|
this._syncShaderType();
|
|
998
1326
|
}
|
|
999
1327
|
|
|
@@ -1062,9 +1390,14 @@ export class ElementNode {
|
|
|
1062
1390
|
|
|
1063
1391
|
/**
|
|
1064
1392
|
* The renderer's family name from `fontFamily` and `fontWeight`, resolved
|
|
1065
|
-
* in one place so either JSX order gives the same name (B17).
|
|
1393
|
+
* in one place so either JSX order gives the same name (B17). Only a
|
|
1394
|
+
* `<text>` has a font: another element keeps both on the ElementNode and
|
|
1395
|
+
* writes nothing to its renderer node (B20).
|
|
1066
1396
|
*/
|
|
1067
1397
|
_writeFontFamily() {
|
|
1398
|
+
if (this._type !== NodeType.TextNode) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1068
1401
|
const weight = this._fontWeight as number | string | undefined;
|
|
1069
1402
|
if (weight === undefined) {
|
|
1070
1403
|
// No family of its own: before render, undefined lets render's font
|
|
@@ -1074,62 +1407,135 @@ export class ElementNode {
|
|
|
1074
1407
|
const family = this._fontFamily;
|
|
1075
1408
|
(this.lng as ElementNode).fontFamily =
|
|
1076
1409
|
family === undefined && this.rendered ? _fontFamilyWithWeight : family;
|
|
1077
|
-
|
|
1410
|
+
} else {
|
|
1411
|
+
const alias = Config.fontWeightAlias;
|
|
1412
|
+
const aliased =
|
|
1413
|
+
alias !== undefined && alias !== null
|
|
1414
|
+
? (alias[weight] as number | string | undefined)
|
|
1415
|
+
: undefined;
|
|
1416
|
+
(this.lng as ElementNode).fontFamily =
|
|
1417
|
+
`${this._fontFamily || Config.fontSettings?.fontFamily}${aliased ?? weight}`;
|
|
1078
1418
|
}
|
|
1079
|
-
|
|
1080
|
-
const aliased =
|
|
1081
|
-
alias !== undefined && alias !== null
|
|
1082
|
-
? (alias[weight] as number | string | undefined)
|
|
1083
|
-
: undefined;
|
|
1084
|
-
(this.lng as ElementNode).fontFamily =
|
|
1085
|
-
`${this._fontFamily || Config.fontSettings?.fontFamily}${aliased ?? weight}`;
|
|
1419
|
+
this._textLayoutDirty();
|
|
1086
1420
|
}
|
|
1087
1421
|
|
|
1088
1422
|
insertChild(
|
|
1089
1423
|
node: ElementNode | ElementText | TextNode,
|
|
1090
1424
|
beforeNode?: ElementNode | ElementText | TextNode | null,
|
|
1091
1425
|
) {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1426
|
+
const children = this.children;
|
|
1427
|
+
const prevParent = node.parent;
|
|
1428
|
+
// Removed earlier (its parent link stays, as in 1.6): it is in no child
|
|
1429
|
+
// list, so there is nothing to take it out of.
|
|
1430
|
+
const detached = isElementNode(node) && node._detached;
|
|
1431
|
+
// The renderer node of a rendered element is placed among its siblings
|
|
1432
|
+
// in `children` order (B19: renderer v2 draws siblings in that order).
|
|
1433
|
+
// The renderer keeps siblings sorted by zIndex: when the anchor's zIndex
|
|
1434
|
+
// is not the child's, it takes the nearest sorted place instead, so
|
|
1435
|
+
// among equal-zIndex siblings its order can then differ from `children`.
|
|
1436
|
+
const drawn = this.rendered && isElementNode(node) && node.rendered;
|
|
1437
|
+
// A move within this node: the renderer sibling it was drawn before, so
|
|
1438
|
+
// a move that leaves it there costs the renderer nothing.
|
|
1439
|
+
let drawnBefore: ElementNode | null = null;
|
|
1440
|
+
// Before itself: it stays where it is (DOM semantics). Solid's swap of
|
|
1441
|
+
// adjacent items asks for this (insertNode(parent, y, nextSibling(x))).
|
|
1442
|
+
if (beforeNode === node) {
|
|
1443
|
+
beforeNode =
|
|
1444
|
+
prevParent === this && !detached
|
|
1445
|
+
? children[lastIndexOf(children, node) + 1]
|
|
1446
|
+
: undefined;
|
|
1447
|
+
}
|
|
1448
|
+
// A node in a parent (this one too) is taken out first, then inserted
|
|
1449
|
+
// before `beforeNode`, or appended.
|
|
1450
|
+
if (prevParent !== undefined && !detached) {
|
|
1451
|
+
if (drawn && prevParent === this) {
|
|
1452
|
+
drawnBefore = nextDrawn(children, lastIndexOf(children, node) + 1);
|
|
1100
1453
|
}
|
|
1454
|
+
prevParent.removeChild(node);
|
|
1455
|
+
}
|
|
1456
|
+
// In a child list again (removeChild above marked it detached).
|
|
1457
|
+
if (isElementNode(node)) {
|
|
1458
|
+
node._detached = false;
|
|
1101
1459
|
}
|
|
1102
1460
|
|
|
1103
|
-
node
|
|
1461
|
+
// We're inserting a node thats been rendered into a node that hasn't been
|
|
1462
|
+
if (!this.rendered && isElementNode(node) && node.rendered) {
|
|
1463
|
+
this._hasRenderedChildren = true;
|
|
1464
|
+
}
|
|
1104
1465
|
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1466
|
+
// DOM insertBefore semantics: an anchor that is not a child appends.
|
|
1467
|
+
let index =
|
|
1468
|
+
beforeNode !== undefined && beforeNode !== null
|
|
1469
|
+
? lastIndexOf(children, beforeNode)
|
|
1470
|
+
: -1;
|
|
1471
|
+
if (index === -1) {
|
|
1472
|
+
index = children.length;
|
|
1473
|
+
children.push(node as ElementNode);
|
|
1474
|
+
} else {
|
|
1475
|
+
// Shifted up by hand: splice allocates, and a module helper with this
|
|
1476
|
+
// one call site would be a closure per call under terser's defaults.
|
|
1477
|
+
let i = children.length;
|
|
1478
|
+
children.push(node as ElementNode);
|
|
1479
|
+
for (; i > index; i--) {
|
|
1480
|
+
children[i] = children[i - 1]!;
|
|
1119
1481
|
}
|
|
1482
|
+
children[index] = node as ElementNode;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
if (!drawn) {
|
|
1486
|
+
node.parent = this;
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
// insertBefore reparents the renderer node too, so the parent setter's
|
|
1490
|
+
// renderer write is skipped.
|
|
1491
|
+
(node as ElementNode)._parent = this;
|
|
1492
|
+
const next = nextDrawn(children, index + 1);
|
|
1493
|
+
if (prevParent !== this || detached || next !== drawnBefore) {
|
|
1494
|
+
(this.lng as INode).insertBefore(
|
|
1495
|
+
(node as ElementNode).lng as INode,
|
|
1496
|
+
next === null ? null : (next.lng as INode),
|
|
1497
|
+
);
|
|
1120
1498
|
}
|
|
1499
|
+
}
|
|
1121
1500
|
|
|
1122
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* After `render()` made `node`'s renderer node (it appends), move it before
|
|
1503
|
+
* the renderer node of its next rendered sibling (B19). solidOpts calls it
|
|
1504
|
+
* for a node inserted before an anchor.
|
|
1505
|
+
*/
|
|
1506
|
+
_drawInOrder(node: ElementNode) {
|
|
1507
|
+
const children = this.children;
|
|
1508
|
+
const next = nextDrawn(children, lastIndexOf(children, node) + 1);
|
|
1509
|
+
if (next !== null) {
|
|
1510
|
+
(this.lng as INode).insertBefore(node.lng as INode, next.lng as INode);
|
|
1511
|
+
}
|
|
1123
1512
|
}
|
|
1124
1513
|
|
|
1125
1514
|
removeChild(node: ElementNode | ElementText | TextNode) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1515
|
+
const children = this.children;
|
|
1516
|
+
const index = lastIndexOf(children, node);
|
|
1517
|
+
if (index > -1) {
|
|
1518
|
+
// Shifted down by hand: splice allocates the array of removed items,
|
|
1519
|
+
// and a module helper with this one call site would be a closure per
|
|
1520
|
+
// call under terser's defaults.
|
|
1521
|
+
if (index === 0) {
|
|
1522
|
+
children.shift();
|
|
1523
|
+
} else {
|
|
1524
|
+
const last = children.length - 1;
|
|
1525
|
+
for (let i = index; i < last; i++) {
|
|
1526
|
+
children[i] = children[i + 1]!;
|
|
1527
|
+
}
|
|
1528
|
+
children.pop();
|
|
1529
|
+
}
|
|
1530
|
+
if (isElementNode(node)) {
|
|
1531
|
+
node._detached = true;
|
|
1532
|
+
if (node.onRemove) {
|
|
1533
|
+
node.onRemove.call(node, node);
|
|
1534
|
+
}
|
|
1129
1535
|
}
|
|
1130
1536
|
|
|
1131
1537
|
if (this.requiresLayout()) {
|
|
1132
|
-
|
|
1538
|
+
queueLayout(this);
|
|
1133
1539
|
}
|
|
1134
1540
|
}
|
|
1135
1541
|
}
|
|
@@ -1157,45 +1563,66 @@ export class ElementNode {
|
|
|
1157
1563
|
: shaderProps;
|
|
1158
1564
|
}
|
|
1159
1565
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
) {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
return
|
|
1566
|
+
/**
|
|
1567
|
+
* The transition path of an animatable prop's setter, which calls it only
|
|
1568
|
+
* when the node has a `transition`. Returns true when the write became an
|
|
1569
|
+
* animation; false when the setter stores the value itself (the common
|
|
1570
|
+
* case is a direct store in the setter, under its own name).
|
|
1571
|
+
*/
|
|
1572
|
+
_sendToLightningAnimatable(name: string, value: number): boolean {
|
|
1573
|
+
const transition = this.transition;
|
|
1574
|
+
if (!this.rendered || !transition || !Config.animationsEnabled) {
|
|
1575
|
+
return false;
|
|
1576
|
+
}
|
|
1577
|
+
let animationSettings: AnimationSettings | undefined;
|
|
1578
|
+
if (transition !== true) {
|
|
1579
|
+
const own = transition[name];
|
|
1580
|
+
// The transition may name w/h as width/height. Written inline: a
|
|
1581
|
+
// single-use helper here is what terser inlines as an IIFE (a closure
|
|
1582
|
+
// per call) under its default compress options.
|
|
1583
|
+
const setting =
|
|
1584
|
+
own ||
|
|
1585
|
+
(name === 'w'
|
|
1586
|
+
? transition.width
|
|
1587
|
+
: name === 'h'
|
|
1588
|
+
? transition.height
|
|
1589
|
+
: undefined);
|
|
1590
|
+
if (!setting) {
|
|
1591
|
+
return false;
|
|
1186
1592
|
}
|
|
1593
|
+
animationSettings =
|
|
1594
|
+
own === true ? undefined : (setting as AnimationSettings | undefined);
|
|
1595
|
+
}
|
|
1187
1596
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1597
|
+
// If the renderer doesn't support animateProp,
|
|
1598
|
+
// keep backwards compatible with LightningRenderer
|
|
1599
|
+
if (!('animateProp' in this.lng)) {
|
|
1600
|
+
const animationController = this.animate(
|
|
1601
|
+
{ [name]: value },
|
|
1602
|
+
animationSettings,
|
|
1192
1603
|
);
|
|
1193
1604
|
this._fireAnimationEvents(name, value, animationSettings);
|
|
1194
|
-
|
|
1605
|
+
animationController.start();
|
|
1606
|
+
return true;
|
|
1195
1607
|
}
|
|
1196
1608
|
|
|
1197
|
-
(this.lng
|
|
1198
|
-
|
|
1609
|
+
(this.lng as INode).animateProp(
|
|
1610
|
+
name,
|
|
1611
|
+
value,
|
|
1612
|
+
animationSettings || this.animationSettings || NO_ANIMATION_SETTINGS,
|
|
1613
|
+
);
|
|
1614
|
+
// A text's layout prop: its container follows the animated sizes.
|
|
1615
|
+
if (
|
|
1616
|
+
this._type === NodeType.TextNode &&
|
|
1617
|
+
(name === 'fontSize' ||
|
|
1618
|
+
name === 'lineHeight' ||
|
|
1619
|
+
name === 'w' ||
|
|
1620
|
+
name === 'h')
|
|
1621
|
+
) {
|
|
1622
|
+
this._textLayoutAnimated();
|
|
1623
|
+
}
|
|
1624
|
+
this._fireAnimationEvents(name, value, animationSettings);
|
|
1625
|
+
return true;
|
|
1199
1626
|
}
|
|
1200
1627
|
|
|
1201
1628
|
_fireAnimationEvents(
|
|
@@ -1211,7 +1638,8 @@ export class ElementNode {
|
|
|
1211
1638
|
}
|
|
1212
1639
|
if (stopped) {
|
|
1213
1640
|
const total = (settings?.duration ?? 0) + (settings?.delay ?? 0);
|
|
1214
|
-
|
|
1641
|
+
// Its arguments through the timer, not a closure per write.
|
|
1642
|
+
setTimeout(fireAnimationStopped, total, this, stopped, name, value);
|
|
1215
1643
|
}
|
|
1216
1644
|
}
|
|
1217
1645
|
|
|
@@ -1223,10 +1651,28 @@ export class ElementNode {
|
|
|
1223
1651
|
if (isDev) console.log('NOT RENDERED! CANNOT ANIMATE');
|
|
1224
1652
|
return { start: () => {} } as IAnimationController;
|
|
1225
1653
|
}
|
|
1226
|
-
|
|
1654
|
+
const controller = (this.lng as IRendererNode).animate(
|
|
1227
1655
|
props,
|
|
1228
|
-
animationSettings || this.animationSettings ||
|
|
1656
|
+
animationSettings || this.animationSettings || NO_ANIMATION_SETTINGS,
|
|
1229
1657
|
);
|
|
1658
|
+
// A prop the text's layout reads (inline: a module function with this
|
|
1659
|
+
// one call site would be a closure per call under terser's defaults).
|
|
1660
|
+
if (
|
|
1661
|
+
this._type === NodeType.TextNode &&
|
|
1662
|
+
('fontSize' in props ||
|
|
1663
|
+
'lineHeight' in props ||
|
|
1664
|
+
'letterSpacing' in props ||
|
|
1665
|
+
'maxWidth' in props ||
|
|
1666
|
+
'maxHeight' in props ||
|
|
1667
|
+
'maxLines' in props ||
|
|
1668
|
+
'w' in props ||
|
|
1669
|
+
'h' in props)
|
|
1670
|
+
) {
|
|
1671
|
+
// Started now or later, again or not at all: the text hears its
|
|
1672
|
+
// layouts from now on (`_listenTextLoaded`).
|
|
1673
|
+
this._textLayoutAnimated();
|
|
1674
|
+
}
|
|
1675
|
+
return controller;
|
|
1230
1676
|
}
|
|
1231
1677
|
|
|
1232
1678
|
chain(props: Partial<AnimateProps>, animationSettings?: AnimationSettings) {
|
|
@@ -1305,12 +1751,229 @@ export class ElementNode {
|
|
|
1305
1751
|
}
|
|
1306
1752
|
|
|
1307
1753
|
_layoutOnLoad() {
|
|
1754
|
+
// An autosize node takes its size from its texture: the size the
|
|
1755
|
+
// parent's last layout saw, so a load that leaves it unchanged needs no
|
|
1756
|
+
// layout; a new one queues the parent and runs the pass in the frame.
|
|
1757
|
+
// (A text in a layout parent is measured instead: _measureText.)
|
|
1758
|
+
let width = this.width;
|
|
1759
|
+
let height = this.height;
|
|
1308
1760
|
(this.lng as IRendererNode).on('loaded', () => {
|
|
1309
|
-
|
|
1310
|
-
this.
|
|
1761
|
+
const w = this.width;
|
|
1762
|
+
const h = this.height;
|
|
1763
|
+
if (w === width && h === height) return;
|
|
1764
|
+
width = w;
|
|
1765
|
+
height = h;
|
|
1766
|
+
const parent = this.parent;
|
|
1767
|
+
if (parent !== undefined && parent !== null && !this._detached) {
|
|
1768
|
+
enqueueLayout(parent);
|
|
1769
|
+
schedulePostMutationInFrame();
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
/**
|
|
1775
|
+
* @internal A prop the text layout reads was written on this element:
|
|
1776
|
+
* `text`, `fontFamily`/`fontWeight`, `fontSize`, `lineHeight`,
|
|
1777
|
+
* `letterSpacing`, `maxWidth`/`width`, `maxHeight`/`height`, `maxLines`,
|
|
1778
|
+
* `wordBreak`, `overflowSuffix`. A rendered `<text>` whose parent lays out
|
|
1779
|
+
* is measured again in the post-mutation pass, and its parent laid out if
|
|
1780
|
+
* its size changed. Anything else returns at once.
|
|
1781
|
+
*/
|
|
1782
|
+
_textLayoutDirty(): void {
|
|
1783
|
+
if (this._type !== NodeType.TextNode || this.rendered !== true) {
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
let m = this._text;
|
|
1787
|
+
if (m !== undefined && m.due === true) {
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
const parent = this._parent;
|
|
1791
|
+
if (parent === undefined || parent._requiresLayout !== true) {
|
|
1792
|
+
// No layout reads it: a parent that lays it out later measures it
|
|
1793
|
+
// first (updateLayout), as one it never measured.
|
|
1794
|
+
if (m !== undefined) {
|
|
1795
|
+
m.w = NaN;
|
|
1796
|
+
}
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (m === undefined) {
|
|
1800
|
+
m = new TextMeasure();
|
|
1801
|
+
this._text = m;
|
|
1802
|
+
}
|
|
1803
|
+
m.due = true;
|
|
1804
|
+
textMeasureQueue[textMeasureCount++] = this;
|
|
1805
|
+
schedulePostMutation();
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* @internal Size this rendered `<text>` for its parent's layout now, with
|
|
1810
|
+
* the renderer's synchronous `measure()` (renderer v2 lays it out into its
|
|
1811
|
+
* layout cache, and the walk reuses that layout). Returns whether its
|
|
1812
|
+
* width or height, as flex reads them (`maxWidth || w`, `maxHeight || h`),
|
|
1813
|
+
* changed since the last call. A text with both max sizes is that large to
|
|
1814
|
+
* flex whatever its layout: the walk lays it out. While its font is
|
|
1815
|
+
* missing it waits (`_waitForFont`).
|
|
1816
|
+
*/
|
|
1817
|
+
_measureText(): boolean {
|
|
1818
|
+
let m = this._text;
|
|
1819
|
+
if (m === undefined) {
|
|
1820
|
+
m = new TextMeasure();
|
|
1821
|
+
this._text = m;
|
|
1822
|
+
}
|
|
1823
|
+
m.due = false;
|
|
1824
|
+
const lng = this.lng as IRendererTextNode;
|
|
1825
|
+
const maxWidth = lng.maxWidth;
|
|
1826
|
+
const maxHeight = lng.maxHeight;
|
|
1827
|
+
if (!(maxWidth > 0 && maxHeight > 0)) {
|
|
1828
|
+
if (lng.measure() === true) {
|
|
1829
|
+
if (m.waiting === true) {
|
|
1830
|
+
// The font arrived: stop listening (the list entry goes at the
|
|
1831
|
+
// next measureFontWaiting).
|
|
1832
|
+
m.waiting = false;
|
|
1833
|
+
lng.off('loaded', fontWaitHeard);
|
|
1834
|
+
fontWaitingDue = true;
|
|
1835
|
+
}
|
|
1836
|
+
} else if (lng.destroyed === true) {
|
|
1837
|
+
return false; // in a subtree destroyed since it was written
|
|
1838
|
+
} else if (m.waiting === false) {
|
|
1839
|
+
this._waitForFont(m);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
const w = maxWidth || lng.w;
|
|
1843
|
+
const h = maxHeight || lng.h;
|
|
1844
|
+
if (w === m.w && h === m.h) {
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
m.w = w;
|
|
1848
|
+
m.h = h;
|
|
1849
|
+
return true;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* @internal Development only, on `loaded`: a layout Solid did not ask for
|
|
1854
|
+
* (the walk's) changed the size of a text Solid measures, so its parent's
|
|
1855
|
+
* flex has the old one. A prop the layout reads was written on the
|
|
1856
|
+
* renderer node (`el.lng`) rather than on the element, or animated there.
|
|
1857
|
+
*/
|
|
1858
|
+
_warnUnmeasuredLayout(): void {
|
|
1859
|
+
const m = this._text;
|
|
1860
|
+
if (
|
|
1861
|
+
m === undefined ||
|
|
1862
|
+
m.due === true ||
|
|
1863
|
+
m.waiting === true ||
|
|
1864
|
+
m.listening === true ||
|
|
1865
|
+
m.w !== m.w ||
|
|
1866
|
+
this._parent === undefined ||
|
|
1867
|
+
this._parent._requiresLayout !== true
|
|
1868
|
+
) {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
const lng = this.lng as IRendererTextNode;
|
|
1872
|
+
if ((lng.maxWidth || lng.w) !== m.w || (lng.maxHeight || lng.h) !== m.h) {
|
|
1873
|
+
console.warn(
|
|
1874
|
+
'[solid] A text in a flex container was laid out at a size Solid did not measure: a prop its layout reads was written, or animated, on its renderer node (el.lng) instead of on the element. Its container keeps the old size.',
|
|
1875
|
+
this,
|
|
1876
|
+
);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* @internal `measure()` found no font description: hear `loaded` once,
|
|
1882
|
+
* when the walk lays the text out (the renderer wakes the nodes it
|
|
1883
|
+
* visited), and wait for loadFonts() to say a font loaded (for one no walk
|
|
1884
|
+
* visits). Either way measureFontWaiting measures it again.
|
|
1885
|
+
*/
|
|
1886
|
+
_waitForFont(m: TextMeasure): void {
|
|
1887
|
+
m.waiting = true;
|
|
1888
|
+
(this.lng as IRendererTextNode).on('loaded', fontWaitHeard);
|
|
1889
|
+
if (
|
|
1890
|
+
measuringFontWaiting === false &&
|
|
1891
|
+
fontWaiting.length >= fontWaitingSweepAt
|
|
1892
|
+
) {
|
|
1893
|
+
sweepFontWaiting();
|
|
1894
|
+
}
|
|
1895
|
+
fontWaiting.push(this);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* @internal Solid animated a prop this text's layout reads
|
|
1900
|
+
* (`_sendToLightningAnimatable`, `animate()`): from now on, for the text's
|
|
1901
|
+
* lifetime, each layout the walk makes of an animated value lays its
|
|
1902
|
+
* container out again in that frame, as 1.6's `loaded` listener did.
|
|
1903
|
+
* Lifetime, not the animation's: Solid does not see a controller started
|
|
1904
|
+
* later, or again (`animate()` returns it to the app).
|
|
1905
|
+
*/
|
|
1906
|
+
_textLayoutAnimated(): void {
|
|
1907
|
+
if (this.rendered !== true) {
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
const parent = this._parent;
|
|
1911
|
+
if (parent === undefined || parent._requiresLayout !== true) {
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
this._listenTextLoaded();
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
/**
|
|
1918
|
+
* @internal Hear every layout of this text: one whose size, as flex reads
|
|
1919
|
+
* it, Solid did not measure lays the container out in that frame. One
|
|
1920
|
+
* closure per text, made once and kept for its lifetime, on its renderer
|
|
1921
|
+
* node only (nothing else holds it, so it goes with the node). A layout
|
|
1922
|
+
* Solid measured changes nothing, and asks for no second walk.
|
|
1923
|
+
*/
|
|
1924
|
+
_listenTextLoaded(): void {
|
|
1925
|
+
let m = this._text;
|
|
1926
|
+
if (m === undefined) {
|
|
1927
|
+
m = new TextMeasure();
|
|
1928
|
+
this._text = m;
|
|
1929
|
+
}
|
|
1930
|
+
if (m.listening === true) {
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
m.listening = true;
|
|
1934
|
+
this._hearTextLayouts();
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* @internal The listener `_listenTextLoaded` adds, once per text. A method
|
|
1939
|
+
* of its own: an arrow's `this` is allocated in a context on every call of
|
|
1940
|
+
* the method that holds it, and that one runs on every animated write.
|
|
1941
|
+
*/
|
|
1942
|
+
_hearTextLayouts(): void {
|
|
1943
|
+
(this.lng as IRendererTextNode).on('loaded', () => {
|
|
1944
|
+
if (this._textSizeChanged() === true) {
|
|
1945
|
+
enqueueLayout(this._parent!);
|
|
1946
|
+
schedulePostMutationInFrame();
|
|
1947
|
+
}
|
|
1311
1948
|
});
|
|
1312
1949
|
}
|
|
1313
1950
|
|
|
1951
|
+
/**
|
|
1952
|
+
* @internal After a layout Solid did not make (the walk's, of an animated
|
|
1953
|
+
* value; the DOM renderer's late re-measure): whether this text's size, as
|
|
1954
|
+
* flex reads it, changed since Solid last saw it. If so, it is recorded
|
|
1955
|
+
* and the caller lays the parent out. False while a measure is due.
|
|
1956
|
+
*/
|
|
1957
|
+
_textSizeChanged(): boolean {
|
|
1958
|
+
const m = this._text;
|
|
1959
|
+
if (m === undefined || m.due === true || m.waiting === true) {
|
|
1960
|
+
return false;
|
|
1961
|
+
}
|
|
1962
|
+
const parent = this._parent;
|
|
1963
|
+
if (parent === undefined || parent._requiresLayout !== true) {
|
|
1964
|
+
return false;
|
|
1965
|
+
}
|
|
1966
|
+
const lng = this.lng as IRendererTextNode;
|
|
1967
|
+
const w = lng.maxWidth || lng.w;
|
|
1968
|
+
const h = lng.maxHeight || lng.h;
|
|
1969
|
+
if (w === m.w && h === m.h) {
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
m.w = w;
|
|
1973
|
+
m.h = h;
|
|
1974
|
+
return true;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1314
1977
|
getText(this: ElementText) {
|
|
1315
1978
|
const len = this.children.length;
|
|
1316
1979
|
if (len === 1) return this.children[0]!.text;
|
|
@@ -1329,7 +1992,9 @@ export class ElementNode {
|
|
|
1329
1992
|
// If onDestroy returns a promise, wait for it to resolve before destroying
|
|
1330
1993
|
// Useful with animations waitUntilStopped method which returns promise
|
|
1331
1994
|
if (destroyPromise instanceof Promise) {
|
|
1332
|
-
|
|
1995
|
+
// Bound here, not an arrow: an arrow's `this` is allocated in a
|
|
1996
|
+
// context on every destroy(), a promise or not.
|
|
1997
|
+
void destroyPromise.then(this._destroy.bind(this));
|
|
1333
1998
|
} else {
|
|
1334
1999
|
this._destroy();
|
|
1335
2000
|
}
|
|
@@ -1395,8 +2060,13 @@ export class ElementNode {
|
|
|
1395
2060
|
}
|
|
1396
2061
|
|
|
1397
2062
|
set src(src) {
|
|
1398
|
-
if (
|
|
1399
|
-
|
|
2063
|
+
if (
|
|
2064
|
+
typeof src === 'string' ||
|
|
2065
|
+
(typeof Blob !== 'undefined' && src instanceof Blob)
|
|
2066
|
+
) {
|
|
2067
|
+
// The renderer types `Node.src` as a string, but loads a Blob src as
|
|
2068
|
+
// ImageTexture does; the DOM renderer shows it through an object URL.
|
|
2069
|
+
this.lng.src = src as string;
|
|
1400
2070
|
if (!this.color && this.rendered) {
|
|
1401
2071
|
this.color = 0xffffffff;
|
|
1402
2072
|
}
|
|
@@ -1405,11 +2075,9 @@ export class ElementNode {
|
|
|
1405
2075
|
}
|
|
1406
2076
|
}
|
|
1407
2077
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
// non-string arms are unreachable through this path.
|
|
1412
|
-
return this.lng.src as string | null | undefined;
|
|
2078
|
+
/** An image URL, or a Blob holding the image (e.g. a fetch() response's). */
|
|
2079
|
+
get src(): string | Blob | null | undefined {
|
|
2080
|
+
return this.lng.src as string | Blob | null | undefined;
|
|
1413
2081
|
}
|
|
1414
2082
|
|
|
1415
2083
|
getChildById(id: string) {
|
|
@@ -1434,19 +2102,59 @@ export class ElementNode {
|
|
|
1434
2102
|
}
|
|
1435
2103
|
|
|
1436
2104
|
set states(states: NodeStates) {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
this.
|
|
2105
|
+
const current = this._states;
|
|
2106
|
+
if (current === undefined) {
|
|
2107
|
+
const created = new States(this._stateChanged.bind(this), states);
|
|
2108
|
+
this._states = created;
|
|
2109
|
+
if (this.rendered && created.length > 0) {
|
|
2110
|
+
this._stateChanged();
|
|
2111
|
+
}
|
|
2112
|
+
return;
|
|
2113
|
+
}
|
|
2114
|
+
// An unchanged list is a no-op (design 3.3.3): nothing to re-apply.
|
|
2115
|
+
// "Unchanged" by the rules of States.merge: an array or a string
|
|
2116
|
+
// replaces the list, an object adds its truthy keys (`has`) and removes
|
|
2117
|
+
// its falsy ones. (Inline on purpose here and in the gradient accessor:
|
|
2118
|
+
// terser's default `reduce_funcs` turns a single-use helper into a
|
|
2119
|
+
// closure per call.)
|
|
2120
|
+
const len = current.length;
|
|
2121
|
+
let changed = false;
|
|
2122
|
+
if (isArray(states)) {
|
|
2123
|
+
changed = states.length !== len;
|
|
2124
|
+
for (let i = 0; !changed && i < len; i++) {
|
|
2125
|
+
changed = states[i] !== current[i];
|
|
2126
|
+
}
|
|
2127
|
+
} else if (isString(states)) {
|
|
2128
|
+
changed = len !== 1 || current[0] !== states;
|
|
2129
|
+
} else {
|
|
2130
|
+
for (const key in states) {
|
|
2131
|
+
const state = key as DollarString;
|
|
2132
|
+
if (states[state]) {
|
|
2133
|
+
changed = !current.has(state);
|
|
2134
|
+
} else {
|
|
2135
|
+
for (let i = 0; !changed && i < len; i++) {
|
|
2136
|
+
changed = current[i] === state;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
if (changed) {
|
|
2140
|
+
break;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
if (!changed) {
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
current.merge(states);
|
|
2148
|
+
if (this.rendered) {
|
|
2149
|
+
this._stateChanged();
|
|
1442
2150
|
}
|
|
1443
2151
|
}
|
|
1444
2152
|
|
|
1445
|
-
get states(): States {
|
|
1446
|
-
this._states = this._states || new States(this._stateChanged.bind(this));
|
|
1447
|
-
return this._states;
|
|
1448
|
-
}
|
|
1449
|
-
|
|
2153
|
+
get states(): States {
|
|
2154
|
+
this._states = this._states || new States(this._stateChanged.bind(this));
|
|
2155
|
+
return this._states;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
1450
2158
|
get animationSettings(): AnimationSettings | undefined {
|
|
1451
2159
|
return this._animationSettings || Config.animationSettings;
|
|
1452
2160
|
}
|
|
@@ -1539,44 +2247,87 @@ export class ElementNode {
|
|
|
1539
2247
|
}
|
|
1540
2248
|
|
|
1541
2249
|
updateLayout() {
|
|
1542
|
-
|
|
1543
|
-
|
|
2250
|
+
this._layoutQueued = false;
|
|
2251
|
+
const children = this.children;
|
|
2252
|
+
const numChildren = children.length;
|
|
2253
|
+
if (numChildren === 0) return;
|
|
2254
|
+
if (isDev) log('Layout: ', this);
|
|
2255
|
+
|
|
2256
|
+
const isFlex = this._display === 'flex';
|
|
2257
|
+
if (isFlex && this.flexGrow && this.width === 0) {
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
1544
2260
|
|
|
1545
|
-
|
|
1546
|
-
|
|
2261
|
+
// Texts written since Solid last measured them (a direct updateLayout()
|
|
2262
|
+
// before the post-mutation pass), or never measured (this container lays
|
|
2263
|
+
// out only now): sized before the pass reads them.
|
|
2264
|
+
for (let i = 0; i < numChildren; i++) {
|
|
2265
|
+
const c = children[i] as ElementNode;
|
|
2266
|
+
if (c._type === NodeType.TextNode && c.rendered === true) {
|
|
2267
|
+
const m = c._text;
|
|
2268
|
+
if (m === undefined || m.due === true || m.w !== m.w) {
|
|
2269
|
+
c._measureText();
|
|
2270
|
+
}
|
|
1547
2271
|
}
|
|
2272
|
+
}
|
|
1548
2273
|
|
|
1549
|
-
|
|
1550
|
-
layoutQueue.delete(this);
|
|
1551
|
-
const onLayoutChanged =
|
|
1552
|
-
isFunction(this.onLayout) && this.onLayout.call(this, this);
|
|
2274
|
+
let flexChanged = isFlex && calculateFlex(this);
|
|
1553
2275
|
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
2276
|
+
if (isFlex && this._containsFlexGrow === true) {
|
|
2277
|
+
// This pass changed its children's sizes: lay out the flex ones again,
|
|
2278
|
+
// directly, so they do not queue this container back through their
|
|
2279
|
+
// own size. If one of them resized, lay this container out once more.
|
|
2280
|
+
let childResized = false;
|
|
2281
|
+
for (let i = 0; i < numChildren; i++) {
|
|
2282
|
+
const c = children[i]!;
|
|
2283
|
+
if (isElementNode(c) && c._display === 'flex') {
|
|
2284
|
+
if (calculateFlex(c)) childResized = true;
|
|
2285
|
+
const childOnLayout = c._onLayout;
|
|
2286
|
+
if (childOnLayout !== undefined && isFunction(childOnLayout)) {
|
|
2287
|
+
childOnLayout.call(c, c);
|
|
1566
2288
|
}
|
|
1567
|
-
}
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
if (childResized && calculateFlex(this)) {
|
|
2292
|
+
flexChanged = true;
|
|
1568
2293
|
}
|
|
2294
|
+
this._containsFlexGrow = null;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
// One onLayout, after the final layout (the children's included).
|
|
2298
|
+
const onLayout = this._onLayout;
|
|
2299
|
+
const onLayoutChanged =
|
|
2300
|
+
onLayout !== undefined &&
|
|
2301
|
+
isFunction(onLayout) &&
|
|
2302
|
+
onLayout.call(this, this);
|
|
2303
|
+
|
|
2304
|
+
// A container whose size changed queues its parent (one with nothing to
|
|
2305
|
+
// lay out would do nothing).
|
|
2306
|
+
// A removed container keeps its parent link but not its place.
|
|
2307
|
+
const parent = this._detached ? undefined : this.parent;
|
|
2308
|
+
if ((flexChanged || onLayoutChanged) && parent && parent._requiresLayout) {
|
|
2309
|
+
queueLayout(parent);
|
|
1569
2310
|
}
|
|
1570
2311
|
}
|
|
1571
2312
|
|
|
2313
|
+
/**
|
|
2314
|
+
* Apply the `$state` blocks of the active states (design 3.3). The keys
|
|
2315
|
+
* any state wrote since the states were last empty are tracked in
|
|
2316
|
+
* `_undoStyles`, in first-write order; each takes its value from the
|
|
2317
|
+
* active block of highest precedence, else the base value (`theme`, then
|
|
2318
|
+
* `style`, then undefined: pinned). After render a key is written only
|
|
2319
|
+
* when that value differs from the one written last (`_applied`); before
|
|
2320
|
+
* render every key is written, into the props bag, as before 1.7.
|
|
2321
|
+
*/
|
|
1572
2322
|
_stateChanged() {
|
|
1573
2323
|
if (isDev) log('State Changed: ', this, this.states);
|
|
2324
|
+
const states = this.states;
|
|
1574
2325
|
|
|
1575
2326
|
if (isDev) {
|
|
1576
2327
|
const div = (this.lng as IRendererNode)?.div;
|
|
1577
2328
|
if (div) {
|
|
1578
|
-
if (
|
|
1579
|
-
div.dataset.states =
|
|
2329
|
+
if (states.length > 0) {
|
|
2330
|
+
div.dataset.states = states.join(' ');
|
|
1580
2331
|
} else {
|
|
1581
2332
|
delete div.dataset.states;
|
|
1582
2333
|
}
|
|
@@ -1584,89 +2335,171 @@ export class ElementNode {
|
|
|
1584
2335
|
}
|
|
1585
2336
|
|
|
1586
2337
|
if (this.forwardStates) {
|
|
1587
|
-
//
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
2338
|
+
// Children first. They take this list: their setter copies it
|
|
2339
|
+
// (forwardStates overwrites their own states, pinned) and does nothing
|
|
2340
|
+
// when it is unchanged.
|
|
2341
|
+
const children = this.children;
|
|
2342
|
+
for (let i = 0; i < children.length; i++) {
|
|
2343
|
+
children[i]!.states = states;
|
|
2344
|
+
}
|
|
1592
2345
|
}
|
|
1593
2346
|
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
keyExists(this, states)
|
|
1603
|
-
) {
|
|
1604
|
-
let stylesToUndo: { [key: string]: any } | undefined;
|
|
1605
|
-
if (this._undoStyles && this._undoStyles.length) {
|
|
1606
|
-
stylesToUndo = {};
|
|
1607
|
-
this._undoStyles.forEach((styleKey) => {
|
|
1608
|
-
let fallbackValue = this.theme[styleKey];
|
|
1609
|
-
|
|
1610
|
-
if (fallbackValue === undefined) {
|
|
1611
|
-
fallbackValue = this.style[styleKey];
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
if (isDev) {
|
|
1615
|
-
if (fallbackValue === undefined) {
|
|
1616
|
-
console.warn('fallback style key not found: ', styleKey);
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
stylesToUndo![styleKey] = fallbackValue;
|
|
1620
|
-
});
|
|
2347
|
+
const n = states.length;
|
|
2348
|
+
const count = this._undoCount;
|
|
2349
|
+
if (count === 0) {
|
|
2350
|
+
// Nothing to undo: done unless an active state has a block. This runs
|
|
2351
|
+
// on every path element of every focus change.
|
|
2352
|
+
let i = 0;
|
|
2353
|
+
while (i < n && !isObject(this[states[i]!])) {
|
|
2354
|
+
i++;
|
|
1621
2355
|
}
|
|
1622
|
-
|
|
1623
|
-
const numStates = states.length;
|
|
1624
|
-
if (numStates === 0) {
|
|
1625
|
-
Object.assign(this, stylesToUndo);
|
|
1626
|
-
this._undoStyles = [];
|
|
2356
|
+
if (i === n) {
|
|
1627
2357
|
return;
|
|
1628
2358
|
}
|
|
2359
|
+
}
|
|
1629
2360
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
2361
|
+
if (this._undoStyles === undefined) {
|
|
2362
|
+
this._undoStyles = [];
|
|
2363
|
+
}
|
|
2364
|
+
if (this._applied === undefined) {
|
|
2365
|
+
this._applied = Object.create(null) as Record<string, unknown>;
|
|
2366
|
+
}
|
|
2367
|
+
this._writeStates(n);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
/**
|
|
2371
|
+
* The state-style loops of `_stateChanged`, for `n` active states: a
|
|
2372
|
+
* method of its own, so that `_stateChanged`, which runs for every path
|
|
2373
|
+
* element of every focus change, stays the short early-return above. Each
|
|
2374
|
+
* key is written through its setter, as before 1.7: a border or shadow
|
|
2375
|
+
* object merges into the shader props, the later write of a sub-prop
|
|
2376
|
+
* winning.
|
|
2377
|
+
*/
|
|
2378
|
+
_writeStates(n: number) {
|
|
2379
|
+
const states = this._states!;
|
|
2380
|
+
const keys = this._undoStyles!;
|
|
2381
|
+
const applied = this._applied!;
|
|
2382
|
+
const diff = this.rendered;
|
|
2383
|
+
let count = this._undoCount;
|
|
2384
|
+
|
|
2385
|
+
// The border family's keys write one set of shader props. When a change
|
|
2386
|
+
// writes some of the tracked family keys and skips the others as
|
|
2387
|
+
// unchanged, a written one may have overwritten what a skipped one holds
|
|
2388
|
+
// (a `border` sets all four widths): then the family is written again,
|
|
2389
|
+
// every tracked key in tracked order, the order 1.6 wrote the merged
|
|
2390
|
+
// object in, so the later key wins as it did. (The shadow is one key.)
|
|
2391
|
+
let borderKeys = 0;
|
|
2392
|
+
let borderWrites = 0;
|
|
2393
|
+
|
|
2394
|
+
if (n === 0) {
|
|
2395
|
+
// Undo every tracked key, in its order (`transition` too: pinned), to
|
|
2396
|
+
// its base value. A setter that throws leaves the keys after it for
|
|
2397
|
+
// the next change, as before 1.7.
|
|
2398
|
+
for (let i = 0; i < count; i++) {
|
|
2399
|
+
const key = keys[i]!;
|
|
2400
|
+
const value = styleFallback(this, key);
|
|
2401
|
+
const border = BORDER_FAMILY[key] === true;
|
|
2402
|
+
if (border) {
|
|
2403
|
+
borderKeys++;
|
|
1651
2404
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
2405
|
+
if (!diff || value !== applied[key]) {
|
|
2406
|
+
applied[key] = value;
|
|
2407
|
+
this[key] = value;
|
|
2408
|
+
if (border) {
|
|
2409
|
+
borderWrites++;
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
if (borderWrites !== 0 && borderWrites !== borderKeys) {
|
|
2414
|
+
this._rewriteBorderKeys(count);
|
|
1657
2415
|
}
|
|
2416
|
+
this._undoCount = 0;
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
1658
2419
|
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
2420
|
+
// Track the active blocks' keys, block by block in precedence order
|
|
2421
|
+
// (lowest first), after the tracked ones: the key order of the merged
|
|
2422
|
+
// object before 1.7, which decides the write order.
|
|
2423
|
+
const stateOrder = this.stateOrder || Config.stateOrder;
|
|
2424
|
+
const order =
|
|
2425
|
+
n > 1 && stateOrder !== undefined && stateOrder.length > 0
|
|
2426
|
+
? stateOrder
|
|
2427
|
+
: undefined;
|
|
2428
|
+
if (order === undefined) {
|
|
2429
|
+
for (let i = 0; i < n; i++) {
|
|
2430
|
+
count = trackKeys(this[states[i]!], keys, count, applied);
|
|
2431
|
+
}
|
|
2432
|
+
} else {
|
|
2433
|
+
// States not in `order` first, in the order added, then by `order`.
|
|
2434
|
+
let lastRank = -2;
|
|
2435
|
+
let lastPos = -1;
|
|
2436
|
+
for (let done = 0; done < n; done++) {
|
|
2437
|
+
let pick = 0;
|
|
2438
|
+
let pickRank = 0;
|
|
2439
|
+
let found = false;
|
|
2440
|
+
for (let i = 0; i < n; i++) {
|
|
2441
|
+
const rank = order.indexOf(states[i]!);
|
|
2442
|
+
if (
|
|
2443
|
+
(rank > lastRank || (rank === lastRank && i > lastPos)) &&
|
|
2444
|
+
(!found || rank < pickRank)
|
|
2445
|
+
) {
|
|
2446
|
+
pick = i;
|
|
2447
|
+
pickRank = rank;
|
|
2448
|
+
found = true;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
count = trackKeys(this[states[pick]!], keys, count, applied);
|
|
2452
|
+
lastRank = pickRank;
|
|
2453
|
+
lastPos = pick;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
this._undoCount = count;
|
|
2457
|
+
|
|
2458
|
+
// `transition` first, so the other keys animate with it (pinned); one
|
|
2459
|
+
// that resolves to undefined is written in its place.
|
|
2460
|
+
for (let i = 0; i < count; i++) {
|
|
2461
|
+
if (keys[i] === 'transition') {
|
|
2462
|
+
const value = resolveStateValue(this, 'transition', states, order);
|
|
2463
|
+
if (value !== undefined && (!diff || value !== applied.transition)) {
|
|
2464
|
+
applied.transition = value;
|
|
2465
|
+
this.transition = value as ElementNode['transition'];
|
|
2466
|
+
}
|
|
2467
|
+
break;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
for (let i = 0; i < count; i++) {
|
|
2471
|
+
const key = keys[i]!;
|
|
2472
|
+
const value = resolveStateValue(this, key, states, order);
|
|
2473
|
+
const border = BORDER_FAMILY[key] === true;
|
|
2474
|
+
if (border) {
|
|
2475
|
+
borderKeys++;
|
|
2476
|
+
}
|
|
2477
|
+
if (!diff || value !== applied[key]) {
|
|
2478
|
+
applied[key] = value;
|
|
2479
|
+
this[key] = value;
|
|
2480
|
+
if (border) {
|
|
2481
|
+
borderWrites++;
|
|
1664
2482
|
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
if (borderWrites !== 0 && borderWrites !== borderKeys) {
|
|
2486
|
+
// The tracked count as it is now: a setter above may have changed the
|
|
2487
|
+
// states and tracked more keys.
|
|
2488
|
+
this._rewriteBorderKeys(this._undoCount);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
1665
2491
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
2492
|
+
/**
|
|
2493
|
+
* Write every tracked border-family key again, in tracked order, with the
|
|
2494
|
+
* value the state change resolved for it (`_applied`): see `_writeStates`.
|
|
2495
|
+
*/
|
|
2496
|
+
_rewriteBorderKeys(count: number) {
|
|
2497
|
+
const keys = this._undoStyles!;
|
|
2498
|
+
const applied = this._applied!;
|
|
2499
|
+
for (let i = 0; i < count; i++) {
|
|
2500
|
+
const key = keys[i]!;
|
|
2501
|
+
if (BORDER_FAMILY[key] === true) {
|
|
2502
|
+
this[key] = applied[key];
|
|
1670
2503
|
}
|
|
1671
2504
|
}
|
|
1672
2505
|
}
|
|
@@ -1688,7 +2521,7 @@ export class ElementNode {
|
|
|
1688
2521
|
}
|
|
1689
2522
|
|
|
1690
2523
|
if (parent.requiresLayout()) {
|
|
1691
|
-
|
|
2524
|
+
queueLayout(parent);
|
|
1692
2525
|
}
|
|
1693
2526
|
|
|
1694
2527
|
if (this.rendered) {
|
|
@@ -1774,17 +2607,27 @@ export class ElementNode {
|
|
|
1774
2607
|
textProps.maxLines = textProps.maxLines ?? 99;
|
|
1775
2608
|
}
|
|
1776
2609
|
|
|
2610
|
+
// B11: margins live on the ElementNode, not in the renderer props;
|
|
2611
|
+
// resolved as flex resolves them (a side, else the margin array).
|
|
1777
2612
|
if (!textProps.maxWidth) {
|
|
1778
2613
|
textProps.maxWidth =
|
|
1779
|
-
parentWidth -
|
|
2614
|
+
parentWidth -
|
|
2615
|
+
textProps.x! -
|
|
2616
|
+
(node.marginRight || getArrayValue(node.margin, 1));
|
|
1780
2617
|
}
|
|
1781
2618
|
|
|
1782
2619
|
if (textProps.contain === 'both' && !textProps.maxHeight) {
|
|
1783
2620
|
textProps.maxHeight =
|
|
1784
|
-
parentHeight -
|
|
1785
|
-
|
|
2621
|
+
parentHeight -
|
|
2622
|
+
textProps.y! -
|
|
2623
|
+
(node.marginBottom || getArrayValue(node.margin, 2));
|
|
2624
|
+
} else if (textProps.maxLines === 1 && !textProps.maxHeight) {
|
|
2625
|
+
// B12: a lineHeight at or below 3 multiplies the font size.
|
|
2626
|
+
const lineHeight = textProps.lineHeight;
|
|
1786
2627
|
textProps.maxHeight =
|
|
1787
|
-
|
|
2628
|
+
lineHeight && lineHeight <= 3 && textProps.fontSize
|
|
2629
|
+
? lineHeight * textProps.fontSize
|
|
2630
|
+
: lineHeight || textProps.fontSize;
|
|
1788
2631
|
}
|
|
1789
2632
|
// textProps.w = textProps.h = 0;
|
|
1790
2633
|
}
|
|
@@ -1803,11 +2646,9 @@ export class ElementNode {
|
|
|
1803
2646
|
props as Partial<ITextNodeProps> & Partial<IRendererTextNodeProps>,
|
|
1804
2647
|
) as IRendererTextNode;
|
|
1805
2648
|
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
2649
|
+
// A text in a layout parent is queued to be measured below, once its
|
|
2650
|
+
// listeners are on (an `onEvent.loaded` hears the layout measure()
|
|
2651
|
+
// makes).
|
|
1811
2652
|
} else {
|
|
1812
2653
|
// If its not an image or texture apply some defaults
|
|
1813
2654
|
if (!props.texture) {
|
|
@@ -1872,16 +2713,6 @@ export class ElementNode {
|
|
|
1872
2713
|
node.lng = renderer.createNode(
|
|
1873
2714
|
props as Partial<INodeProps> & Partial<IRendererNodeProps>,
|
|
1874
2715
|
);
|
|
1875
|
-
|
|
1876
|
-
if (node._hasRenderedChildren) {
|
|
1877
|
-
node._hasRenderedChildren = false;
|
|
1878
|
-
|
|
1879
|
-
for (const child of node.children) {
|
|
1880
|
-
if (isElementNode(child) && isINode(child.lng)) {
|
|
1881
|
-
child.lng.parent = node.lng as INode;
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
2716
|
}
|
|
1886
2717
|
|
|
1887
2718
|
node.rendered = true;
|
|
@@ -1897,18 +2728,45 @@ export class ElementNode {
|
|
|
1897
2728
|
this.onCreate?.(this);
|
|
1898
2729
|
this.onRender?.(this);
|
|
1899
2730
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
//
|
|
2731
|
+
const onEvent = node.onEvent;
|
|
2732
|
+
if (onEvent) {
|
|
2733
|
+
// for-in with an own-property test, as Object.entries (Chrome 54)
|
|
2734
|
+
// reads it: the floor is Chrome 47.
|
|
1903
2735
|
for (const name in onEvent) {
|
|
1904
|
-
if (
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2736
|
+
if (
|
|
2737
|
+
Object.prototype.hasOwnProperty.call(onEvent, name) &&
|
|
2738
|
+
typeof node.lng.on === 'function'
|
|
2739
|
+
) {
|
|
2740
|
+
const handler = onEvent[name as keyof OnEvent]!;
|
|
2741
|
+
// The listener captures these block-scoped names, not render()'s
|
|
2742
|
+
// `node`: a captured local is allocated in a context on every
|
|
2743
|
+
// call, onEvent or not.
|
|
2744
|
+
const target = node;
|
|
2745
|
+
node.lng.on(name, (_inode, data) =>
|
|
2746
|
+
handler.call(target, target, data),
|
|
2747
|
+
);
|
|
1908
2748
|
}
|
|
1909
2749
|
}
|
|
1910
2750
|
}
|
|
1911
2751
|
|
|
2752
|
+
if (node._type === NodeType.TextNode && parent._requiresLayout === true) {
|
|
2753
|
+
// Its parent's flex reads its size: it is measured in the post-mutation
|
|
2754
|
+
// pass, before the parent's layout (queued above) and before the frame,
|
|
2755
|
+
// instead of waiting for the walk's `loaded`. Not here: a write later
|
|
2756
|
+
// in this tick would lay it out twice (and `loaded` twice).
|
|
2757
|
+
if (isDomRendererActive()) {
|
|
2758
|
+
// The DOM renderer measures again when a web font loads after the
|
|
2759
|
+
// text was measured (its size then was the fallback font's): lay the
|
|
2760
|
+
// container out at that size, as before 1.7.
|
|
2761
|
+
node._listenTextLoaded();
|
|
2762
|
+
} else if (isDev) {
|
|
2763
|
+
(node.lng as IRendererTextNode).on('loaded', () =>
|
|
2764
|
+
node._warnUnmeasuredLayout(),
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
node._textLayoutDirty();
|
|
2768
|
+
}
|
|
2769
|
+
|
|
1912
2770
|
// L3 Inspector adds div to the lng object
|
|
1913
2771
|
const div: HTMLElement | undefined = (node.lng as IRendererNode)?.div;
|
|
1914
2772
|
if (isDev && div) {
|
|
@@ -1920,12 +2778,19 @@ export class ElementNode {
|
|
|
1920
2778
|
|
|
1921
2779
|
if (node._type === NodeType.Element) {
|
|
1922
2780
|
// only element nodes will have children that need rendering
|
|
2781
|
+
// Children rendered before this node (moved in) are reparented here,
|
|
2782
|
+
// in children order with the new ones (B19: v2 draws in that order).
|
|
2783
|
+
const reparent = node._hasRenderedChildren === true;
|
|
2784
|
+
node._hasRenderedChildren = false;
|
|
1923
2785
|
const numChildren = node.children.length;
|
|
1924
2786
|
for (let i = 0; i < numChildren; i++) {
|
|
1925
2787
|
const c = node.children[i];
|
|
1926
2788
|
if (isDev) assertTruthy(c, 'Child is undefined');
|
|
1927
2789
|
// Text elements sneak in from Solid creating tracked nodes
|
|
1928
2790
|
if (isElementNode(c)) {
|
|
2791
|
+
if (reparent && isINode(c.lng)) {
|
|
2792
|
+
c.lng.parent = node.lng as INode;
|
|
2793
|
+
}
|
|
1929
2794
|
c.render();
|
|
1930
2795
|
}
|
|
1931
2796
|
}
|
|
@@ -1940,32 +2805,791 @@ export class ElementNode {
|
|
|
1940
2805
|
}
|
|
1941
2806
|
}
|
|
1942
2807
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2808
|
+
/**
|
|
2809
|
+
* The index of `item` in `list`, scanning from the end: Solid appends and
|
|
2810
|
+
* removes at the tail most often. The first item is checked first, for
|
|
2811
|
+
* Solid's cleanChildren, which removes the first child until none is left.
|
|
2812
|
+
*/
|
|
2813
|
+
function lastIndexOf<T>(list: T[], item: T): number {
|
|
2814
|
+
if (list[0] === item) {
|
|
2815
|
+
return 0;
|
|
2816
|
+
}
|
|
2817
|
+
let i = list.length - 1;
|
|
2818
|
+
while (i > 0 && list[i] !== item) {
|
|
2819
|
+
i--;
|
|
2820
|
+
}
|
|
2821
|
+
return i === 0 ? -1 : i;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
/** The first rendered element in `children` from `from` on: the renderer sibling to draw before. */
|
|
2825
|
+
function nextDrawn(
|
|
2826
|
+
children: ElementNode['children'],
|
|
2827
|
+
from: number,
|
|
2828
|
+
): ElementNode | null {
|
|
2829
|
+
for (let i = from; i < children.length; i++) {
|
|
2830
|
+
const c = children[i];
|
|
2831
|
+
if (c instanceof ElementNode && c.rendered) {
|
|
2832
|
+
return c;
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
return null;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
// Props forwarded to the renderer node, one accessor per prop (design
|
|
2839
|
+
// 3.6.6): every getter and setter below loads or stores one constant name,
|
|
2840
|
+
// so each has its own inline cache. A shared `this.lng[key]` body made from
|
|
2841
|
+
// a loop sees every name at one site: a megamorphic keyed access, and into
|
|
2842
|
+
// renderer v2's prototype accessors a call V8 does not inline (the double
|
|
2843
|
+
// it returns is boxed). Written out rather than made with `new Function`,
|
|
2844
|
+
// which a TV app's CSP may forbid.
|
|
2845
|
+
//
|
|
2846
|
+
// `lng` is the props bag before render and the renderer node after it. An
|
|
2847
|
+
// animatable setter stores directly unless the node has a `transition`,
|
|
2848
|
+
// then `_sendToLightningAnimatable` may animate instead.
|
|
2849
|
+
type Forwarding = Pick<
|
|
2850
|
+
ElementNode,
|
|
2851
|
+
'transition' | '_sendToLightningAnimatable' | '_type' | '_textLayoutDirty'
|
|
2852
|
+
> & { lng: Record<string, unknown> };
|
|
2853
|
+
|
|
2854
|
+
const NO_TEXT_PROPS: Readonly<Record<string, unknown>> = Object.freeze({});
|
|
2855
|
+
|
|
2856
|
+
/**
|
|
2857
|
+
* Where a text-only prop is written: a `<text>`'s renderer node (its props
|
|
2858
|
+
* bag before render); on any other element, the ElementNode's `_textProps`.
|
|
2859
|
+
* A renderer v2 handle takes no field it does not know (it would become a
|
|
2860
|
+
* field of its own) and a view draws no text (B20).
|
|
2861
|
+
*/
|
|
2862
|
+
function textPropsFor(node: ElementNode): Record<string, unknown> {
|
|
2863
|
+
if (node._type === NodeType.TextNode) {
|
|
2864
|
+
return node.lng as Record<string, unknown>;
|
|
2865
|
+
}
|
|
2866
|
+
let own = node._textProps;
|
|
2867
|
+
if (own === undefined) {
|
|
2868
|
+
own = {};
|
|
2869
|
+
node._textProps = own;
|
|
2870
|
+
}
|
|
2871
|
+
return own;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
/** Where a text-only prop is read (textPropsFor), without allocating. */
|
|
2875
|
+
function textPropsOf(node: ElementNode): Readonly<Record<string, unknown>> {
|
|
2876
|
+
if (node._type === NodeType.TextNode) {
|
|
2877
|
+
return node.lng as Record<string, unknown>;
|
|
2878
|
+
}
|
|
2879
|
+
const own = node._textProps;
|
|
2880
|
+
return own === undefined ? NO_TEXT_PROPS : own;
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
/** The setter of a read-only forwarded prop: the write is ignored. */
|
|
2884
|
+
function ignoreWrite(_v: unknown) {}
|
|
2885
|
+
|
|
2886
|
+
Object.defineProperties(ElementNode.prototype, {
|
|
2887
|
+
// Animatable
|
|
2888
|
+
alpha: {
|
|
2889
|
+
get(this: Forwarding) {
|
|
2890
|
+
return this.lng.alpha;
|
|
2891
|
+
},
|
|
2892
|
+
set(this: Forwarding, v: number) {
|
|
2893
|
+
if (
|
|
2894
|
+
this.transition === undefined ||
|
|
2895
|
+
!this._sendToLightningAnimatable('alpha', v)
|
|
2896
|
+
) {
|
|
2897
|
+
this.lng.alpha = v;
|
|
2898
|
+
}
|
|
2899
|
+
},
|
|
2900
|
+
},
|
|
2901
|
+
color: {
|
|
2902
|
+
get(this: Forwarding) {
|
|
2903
|
+
return this.lng.color;
|
|
2904
|
+
},
|
|
2905
|
+
set(this: Forwarding, v: number) {
|
|
2906
|
+
if (
|
|
2907
|
+
this.transition === undefined ||
|
|
2908
|
+
!this._sendToLightningAnimatable('color', v)
|
|
2909
|
+
) {
|
|
2910
|
+
this.lng.color = v;
|
|
2911
|
+
}
|
|
2912
|
+
},
|
|
2913
|
+
},
|
|
2914
|
+
colorTop: {
|
|
2915
|
+
get(this: Forwarding) {
|
|
2916
|
+
return this.lng.colorTop;
|
|
2917
|
+
},
|
|
2918
|
+
set(this: Forwarding, v: number) {
|
|
2919
|
+
if (
|
|
2920
|
+
this.transition === undefined ||
|
|
2921
|
+
!this._sendToLightningAnimatable('colorTop', v)
|
|
2922
|
+
) {
|
|
2923
|
+
this.lng.colorTop = v;
|
|
2924
|
+
}
|
|
2925
|
+
},
|
|
2926
|
+
},
|
|
2927
|
+
colorRight: {
|
|
2928
|
+
get(this: Forwarding) {
|
|
2929
|
+
return this.lng.colorRight;
|
|
2930
|
+
},
|
|
2931
|
+
set(this: Forwarding, v: number) {
|
|
2932
|
+
if (
|
|
2933
|
+
this.transition === undefined ||
|
|
2934
|
+
!this._sendToLightningAnimatable('colorRight', v)
|
|
2935
|
+
) {
|
|
2936
|
+
this.lng.colorRight = v;
|
|
2937
|
+
}
|
|
2938
|
+
},
|
|
2939
|
+
},
|
|
2940
|
+
colorLeft: {
|
|
2941
|
+
get(this: Forwarding) {
|
|
2942
|
+
return this.lng.colorLeft;
|
|
2943
|
+
},
|
|
2944
|
+
set(this: Forwarding, v: number) {
|
|
2945
|
+
if (
|
|
2946
|
+
this.transition === undefined ||
|
|
2947
|
+
!this._sendToLightningAnimatable('colorLeft', v)
|
|
2948
|
+
) {
|
|
2949
|
+
this.lng.colorLeft = v;
|
|
2950
|
+
}
|
|
2951
|
+
},
|
|
2952
|
+
},
|
|
2953
|
+
colorBottom: {
|
|
2954
|
+
get(this: Forwarding) {
|
|
2955
|
+
return this.lng.colorBottom;
|
|
2956
|
+
},
|
|
2957
|
+
set(this: Forwarding, v: number) {
|
|
2958
|
+
if (
|
|
2959
|
+
this.transition === undefined ||
|
|
2960
|
+
!this._sendToLightningAnimatable('colorBottom', v)
|
|
2961
|
+
) {
|
|
2962
|
+
this.lng.colorBottom = v;
|
|
2963
|
+
}
|
|
2964
|
+
},
|
|
2965
|
+
},
|
|
2966
|
+
colorTl: {
|
|
2967
|
+
get(this: Forwarding) {
|
|
2968
|
+
return this.lng.colorTl;
|
|
2969
|
+
},
|
|
2970
|
+
set(this: Forwarding, v: number) {
|
|
2971
|
+
if (
|
|
2972
|
+
this.transition === undefined ||
|
|
2973
|
+
!this._sendToLightningAnimatable('colorTl', v)
|
|
2974
|
+
) {
|
|
2975
|
+
this.lng.colorTl = v;
|
|
2976
|
+
}
|
|
2977
|
+
},
|
|
2978
|
+
},
|
|
2979
|
+
colorTr: {
|
|
2980
|
+
get(this: Forwarding) {
|
|
2981
|
+
return this.lng.colorTr;
|
|
2982
|
+
},
|
|
2983
|
+
set(this: Forwarding, v: number) {
|
|
2984
|
+
if (
|
|
2985
|
+
this.transition === undefined ||
|
|
2986
|
+
!this._sendToLightningAnimatable('colorTr', v)
|
|
2987
|
+
) {
|
|
2988
|
+
this.lng.colorTr = v;
|
|
2989
|
+
}
|
|
2990
|
+
},
|
|
2991
|
+
},
|
|
2992
|
+
colorBl: {
|
|
2993
|
+
get(this: Forwarding) {
|
|
2994
|
+
return this.lng.colorBl;
|
|
2995
|
+
},
|
|
2996
|
+
set(this: Forwarding, v: number) {
|
|
2997
|
+
if (
|
|
2998
|
+
this.transition === undefined ||
|
|
2999
|
+
!this._sendToLightningAnimatable('colorBl', v)
|
|
3000
|
+
) {
|
|
3001
|
+
this.lng.colorBl = v;
|
|
3002
|
+
}
|
|
3003
|
+
},
|
|
3004
|
+
},
|
|
3005
|
+
colorBr: {
|
|
3006
|
+
get(this: Forwarding) {
|
|
3007
|
+
return this.lng.colorBr;
|
|
3008
|
+
},
|
|
3009
|
+
set(this: Forwarding, v: number) {
|
|
3010
|
+
if (
|
|
3011
|
+
this.transition === undefined ||
|
|
3012
|
+
!this._sendToLightningAnimatable('colorBr', v)
|
|
3013
|
+
) {
|
|
3014
|
+
this.lng.colorBr = v;
|
|
3015
|
+
}
|
|
3016
|
+
},
|
|
3017
|
+
},
|
|
3018
|
+
h: {
|
|
3019
|
+
get(this: Forwarding) {
|
|
3020
|
+
return this.lng.h;
|
|
3021
|
+
},
|
|
3022
|
+
set(this: Forwarding, v: number) {
|
|
3023
|
+
if (
|
|
3024
|
+
this.transition === undefined ||
|
|
3025
|
+
!this._sendToLightningAnimatable('h', v)
|
|
3026
|
+
) {
|
|
3027
|
+
this.lng.h = v;
|
|
3028
|
+
}
|
|
3029
|
+
// On a text, the max height (renderer v2), which its layout reads.
|
|
3030
|
+
if (this._type === NodeType.TextNode) {
|
|
3031
|
+
this._textLayoutDirty();
|
|
3032
|
+
}
|
|
3033
|
+
},
|
|
3034
|
+
},
|
|
3035
|
+
mount: {
|
|
3036
|
+
get(this: Forwarding) {
|
|
3037
|
+
return this.lng.mount;
|
|
3038
|
+
},
|
|
3039
|
+
set(this: Forwarding, v: number) {
|
|
3040
|
+
if (
|
|
3041
|
+
this.transition === undefined ||
|
|
3042
|
+
!this._sendToLightningAnimatable('mount', v)
|
|
3043
|
+
) {
|
|
3044
|
+
this.lng.mount = v;
|
|
3045
|
+
}
|
|
3046
|
+
},
|
|
3047
|
+
},
|
|
3048
|
+
mountX: {
|
|
3049
|
+
get(this: Forwarding) {
|
|
3050
|
+
return this.lng.mountX;
|
|
3051
|
+
},
|
|
3052
|
+
set(this: Forwarding, v: number) {
|
|
3053
|
+
if (
|
|
3054
|
+
this.transition === undefined ||
|
|
3055
|
+
!this._sendToLightningAnimatable('mountX', v)
|
|
3056
|
+
) {
|
|
3057
|
+
this.lng.mountX = v;
|
|
3058
|
+
}
|
|
3059
|
+
},
|
|
3060
|
+
},
|
|
3061
|
+
mountY: {
|
|
3062
|
+
get(this: Forwarding) {
|
|
3063
|
+
return this.lng.mountY;
|
|
3064
|
+
},
|
|
3065
|
+
set(this: Forwarding, v: number) {
|
|
3066
|
+
if (
|
|
3067
|
+
this.transition === undefined ||
|
|
3068
|
+
!this._sendToLightningAnimatable('mountY', v)
|
|
3069
|
+
) {
|
|
3070
|
+
this.lng.mountY = v;
|
|
3071
|
+
}
|
|
3072
|
+
},
|
|
3073
|
+
},
|
|
3074
|
+
pivot: {
|
|
3075
|
+
get(this: Forwarding) {
|
|
3076
|
+
return this.lng.pivot;
|
|
3077
|
+
},
|
|
3078
|
+
set(this: Forwarding, v: number) {
|
|
3079
|
+
if (
|
|
3080
|
+
this.transition === undefined ||
|
|
3081
|
+
!this._sendToLightningAnimatable('pivot', v)
|
|
3082
|
+
) {
|
|
3083
|
+
this.lng.pivot = v;
|
|
3084
|
+
}
|
|
3085
|
+
},
|
|
3086
|
+
},
|
|
3087
|
+
pivotX: {
|
|
3088
|
+
get(this: Forwarding) {
|
|
3089
|
+
return this.lng.pivotX;
|
|
3090
|
+
},
|
|
3091
|
+
set(this: Forwarding, v: number) {
|
|
3092
|
+
if (
|
|
3093
|
+
this.transition === undefined ||
|
|
3094
|
+
!this._sendToLightningAnimatable('pivotX', v)
|
|
3095
|
+
) {
|
|
3096
|
+
this.lng.pivotX = v;
|
|
3097
|
+
}
|
|
3098
|
+
},
|
|
3099
|
+
},
|
|
3100
|
+
pivotY: {
|
|
3101
|
+
get(this: Forwarding) {
|
|
3102
|
+
return this.lng.pivotY;
|
|
3103
|
+
},
|
|
3104
|
+
set(this: Forwarding, v: number) {
|
|
3105
|
+
if (
|
|
3106
|
+
this.transition === undefined ||
|
|
3107
|
+
!this._sendToLightningAnimatable('pivotY', v)
|
|
3108
|
+
) {
|
|
3109
|
+
this.lng.pivotY = v;
|
|
3110
|
+
}
|
|
3111
|
+
},
|
|
3112
|
+
},
|
|
3113
|
+
rotation: {
|
|
3114
|
+
get(this: Forwarding) {
|
|
3115
|
+
return this.lng.rotation;
|
|
3116
|
+
},
|
|
3117
|
+
set(this: Forwarding, v: number) {
|
|
3118
|
+
if (
|
|
3119
|
+
this.transition === undefined ||
|
|
3120
|
+
!this._sendToLightningAnimatable('rotation', v)
|
|
3121
|
+
) {
|
|
3122
|
+
this.lng.rotation = v;
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
},
|
|
3126
|
+
scale: {
|
|
3127
|
+
get(this: Forwarding) {
|
|
3128
|
+
return this.lng.scale;
|
|
3129
|
+
},
|
|
3130
|
+
set(this: Forwarding, v: number) {
|
|
3131
|
+
if (
|
|
3132
|
+
this.transition === undefined ||
|
|
3133
|
+
!this._sendToLightningAnimatable('scale', v)
|
|
3134
|
+
) {
|
|
3135
|
+
this.lng.scale = v;
|
|
3136
|
+
}
|
|
3137
|
+
},
|
|
3138
|
+
},
|
|
3139
|
+
scaleX: {
|
|
3140
|
+
get(this: Forwarding) {
|
|
3141
|
+
return this.lng.scaleX;
|
|
3142
|
+
},
|
|
3143
|
+
set(this: Forwarding, v: number) {
|
|
3144
|
+
if (
|
|
3145
|
+
this.transition === undefined ||
|
|
3146
|
+
!this._sendToLightningAnimatable('scaleX', v)
|
|
3147
|
+
) {
|
|
3148
|
+
this.lng.scaleX = v;
|
|
3149
|
+
}
|
|
3150
|
+
},
|
|
3151
|
+
},
|
|
3152
|
+
scaleY: {
|
|
3153
|
+
get(this: Forwarding) {
|
|
3154
|
+
return this.lng.scaleY;
|
|
3155
|
+
},
|
|
3156
|
+
set(this: Forwarding, v: number) {
|
|
3157
|
+
if (
|
|
3158
|
+
this.transition === undefined ||
|
|
3159
|
+
!this._sendToLightningAnimatable('scaleY', v)
|
|
3160
|
+
) {
|
|
3161
|
+
this.lng.scaleY = v;
|
|
3162
|
+
}
|
|
3163
|
+
},
|
|
3164
|
+
},
|
|
3165
|
+
w: {
|
|
3166
|
+
get(this: Forwarding) {
|
|
3167
|
+
return this.lng.w;
|
|
3168
|
+
},
|
|
3169
|
+
set(this: Forwarding, v: number) {
|
|
3170
|
+
if (
|
|
3171
|
+
this.transition === undefined ||
|
|
3172
|
+
!this._sendToLightningAnimatable('w', v)
|
|
3173
|
+
) {
|
|
3174
|
+
this.lng.w = v;
|
|
3175
|
+
}
|
|
3176
|
+
// On a text, the max width (renderer v2), which its layout reads.
|
|
3177
|
+
if (this._type === NodeType.TextNode) {
|
|
3178
|
+
this._textLayoutDirty();
|
|
3179
|
+
}
|
|
3180
|
+
},
|
|
3181
|
+
},
|
|
3182
|
+
x: {
|
|
3183
|
+
get(this: Forwarding) {
|
|
3184
|
+
return this.lng.x;
|
|
3185
|
+
},
|
|
3186
|
+
set(this: Forwarding, v: number) {
|
|
3187
|
+
if (
|
|
3188
|
+
this.transition === undefined ||
|
|
3189
|
+
!this._sendToLightningAnimatable('x', v)
|
|
3190
|
+
) {
|
|
3191
|
+
this.lng.x = v;
|
|
3192
|
+
}
|
|
3193
|
+
},
|
|
3194
|
+
},
|
|
3195
|
+
y: {
|
|
3196
|
+
get(this: Forwarding) {
|
|
3197
|
+
return this.lng.y;
|
|
3198
|
+
},
|
|
3199
|
+
set(this: Forwarding, v: number) {
|
|
3200
|
+
if (
|
|
3201
|
+
this.transition === undefined ||
|
|
3202
|
+
!this._sendToLightningAnimatable('y', v)
|
|
3203
|
+
) {
|
|
3204
|
+
this.lng.y = v;
|
|
3205
|
+
}
|
|
3206
|
+
},
|
|
3207
|
+
},
|
|
3208
|
+
zIndex: {
|
|
3209
|
+
get(this: Forwarding) {
|
|
3210
|
+
return this.lng.zIndex;
|
|
3211
|
+
},
|
|
3212
|
+
set(this: Forwarding, v: number) {
|
|
3213
|
+
if (
|
|
3214
|
+
this.transition === undefined ||
|
|
3215
|
+
!this._sendToLightningAnimatable('zIndex', v)
|
|
3216
|
+
) {
|
|
3217
|
+
this.lng.zIndex = v;
|
|
3218
|
+
}
|
|
3219
|
+
},
|
|
3220
|
+
},
|
|
3221
|
+
// Animatable, text only
|
|
3222
|
+
fontSize: {
|
|
3223
|
+
get(this: ElementNode) {
|
|
3224
|
+
return textPropsOf(this).fontSize;
|
|
1947
3225
|
},
|
|
1948
3226
|
set(this: ElementNode, v: number) {
|
|
1949
|
-
|
|
3227
|
+
if (
|
|
3228
|
+
this._type !== NodeType.TextNode ||
|
|
3229
|
+
this.transition === undefined ||
|
|
3230
|
+
!this._sendToLightningAnimatable('fontSize', v)
|
|
3231
|
+
) {
|
|
3232
|
+
textPropsFor(this).fontSize = v;
|
|
3233
|
+
}
|
|
3234
|
+
this._textLayoutDirty();
|
|
1950
3235
|
},
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
Object.defineProperty(ElementNode.prototype, key, {
|
|
1956
|
-
get(): unknown {
|
|
1957
|
-
return this.lng[key];
|
|
3236
|
+
},
|
|
3237
|
+
lineHeight: {
|
|
3238
|
+
get(this: ElementNode) {
|
|
3239
|
+
return textPropsOf(this).lineHeight;
|
|
1958
3240
|
},
|
|
1959
|
-
set(v:
|
|
1960
|
-
|
|
3241
|
+
set(this: ElementNode, v: number) {
|
|
3242
|
+
if (
|
|
3243
|
+
this._type !== NodeType.TextNode ||
|
|
3244
|
+
this.transition === undefined ||
|
|
3245
|
+
!this._sendToLightningAnimatable('lineHeight', v)
|
|
3246
|
+
) {
|
|
3247
|
+
textPropsFor(this).lineHeight = v;
|
|
3248
|
+
}
|
|
3249
|
+
this._textLayoutDirty();
|
|
1961
3250
|
},
|
|
1962
|
-
}
|
|
1963
|
-
|
|
3251
|
+
},
|
|
3252
|
+
// Not animated
|
|
3253
|
+
atlasGroup: {
|
|
3254
|
+
get(this: Forwarding) {
|
|
3255
|
+
return this.lng.atlasGroup;
|
|
3256
|
+
},
|
|
3257
|
+
set(this: Forwarding, v: unknown) {
|
|
3258
|
+
this.lng.atlasGroup = v;
|
|
3259
|
+
},
|
|
3260
|
+
},
|
|
3261
|
+
autosize: {
|
|
3262
|
+
get(this: Forwarding) {
|
|
3263
|
+
return this.lng.autosize;
|
|
3264
|
+
},
|
|
3265
|
+
set(this: Forwarding, v: unknown) {
|
|
3266
|
+
this.lng.autosize = v;
|
|
3267
|
+
},
|
|
3268
|
+
},
|
|
3269
|
+
clipping: {
|
|
3270
|
+
get(this: Forwarding) {
|
|
3271
|
+
return this.lng.clipping;
|
|
3272
|
+
},
|
|
3273
|
+
set(this: Forwarding, v: unknown) {
|
|
3274
|
+
this.lng.clipping = v;
|
|
3275
|
+
},
|
|
3276
|
+
},
|
|
3277
|
+
componentName: {
|
|
3278
|
+
get(this: Forwarding) {
|
|
3279
|
+
return this.lng.componentName;
|
|
3280
|
+
},
|
|
3281
|
+
set(this: Forwarding, v: unknown) {
|
|
3282
|
+
this.lng.componentName = v;
|
|
3283
|
+
},
|
|
3284
|
+
},
|
|
3285
|
+
componentLocation: {
|
|
3286
|
+
get(this: Forwarding) {
|
|
3287
|
+
return this.lng.componentLocation;
|
|
3288
|
+
},
|
|
3289
|
+
set(this: Forwarding, v: unknown) {
|
|
3290
|
+
this.lng.componentLocation = v;
|
|
3291
|
+
},
|
|
3292
|
+
},
|
|
3293
|
+
data: {
|
|
3294
|
+
get(this: Forwarding) {
|
|
3295
|
+
return this.lng.data;
|
|
3296
|
+
},
|
|
3297
|
+
set(this: Forwarding, v: unknown) {
|
|
3298
|
+
this.lng.data = v;
|
|
3299
|
+
},
|
|
3300
|
+
},
|
|
3301
|
+
ignoreParentAlpha: {
|
|
3302
|
+
get(this: Forwarding) {
|
|
3303
|
+
return this.lng.ignoreParentAlpha;
|
|
3304
|
+
},
|
|
3305
|
+
set(this: Forwarding, v: unknown) {
|
|
3306
|
+
this.lng.ignoreParentAlpha = v;
|
|
3307
|
+
},
|
|
3308
|
+
},
|
|
3309
|
+
imageType: {
|
|
3310
|
+
get(this: Forwarding) {
|
|
3311
|
+
return this.lng.imageType;
|
|
3312
|
+
},
|
|
3313
|
+
set(this: Forwarding, v: unknown) {
|
|
3314
|
+
this.lng.imageType = v;
|
|
3315
|
+
},
|
|
3316
|
+
},
|
|
3317
|
+
placeholderColor: {
|
|
3318
|
+
get(this: Forwarding) {
|
|
3319
|
+
return this.lng.placeholderColor;
|
|
3320
|
+
},
|
|
3321
|
+
set(this: Forwarding, v: unknown) {
|
|
3322
|
+
this.lng.placeholderColor = v;
|
|
3323
|
+
},
|
|
3324
|
+
},
|
|
3325
|
+
srcHeight: {
|
|
3326
|
+
get(this: Forwarding) {
|
|
3327
|
+
return this.lng.srcHeight;
|
|
3328
|
+
},
|
|
3329
|
+
set(this: Forwarding, v: unknown) {
|
|
3330
|
+
this.lng.srcHeight = v;
|
|
3331
|
+
},
|
|
3332
|
+
},
|
|
3333
|
+
srcWidth: {
|
|
3334
|
+
get(this: Forwarding) {
|
|
3335
|
+
return this.lng.srcWidth;
|
|
3336
|
+
},
|
|
3337
|
+
set(this: Forwarding, v: unknown) {
|
|
3338
|
+
this.lng.srcWidth = v;
|
|
3339
|
+
},
|
|
3340
|
+
},
|
|
3341
|
+
srcX: {
|
|
3342
|
+
get(this: Forwarding) {
|
|
3343
|
+
return this.lng.srcX;
|
|
3344
|
+
},
|
|
3345
|
+
set(this: Forwarding, v: unknown) {
|
|
3346
|
+
this.lng.srcX = v;
|
|
3347
|
+
},
|
|
3348
|
+
},
|
|
3349
|
+
srcY: {
|
|
3350
|
+
get(this: Forwarding) {
|
|
3351
|
+
return this.lng.srcY;
|
|
3352
|
+
},
|
|
3353
|
+
set(this: Forwarding, v: unknown) {
|
|
3354
|
+
this.lng.srcY = v;
|
|
3355
|
+
},
|
|
3356
|
+
},
|
|
3357
|
+
texture: {
|
|
3358
|
+
get(this: Forwarding) {
|
|
3359
|
+
return this.lng.texture;
|
|
3360
|
+
},
|
|
3361
|
+
set(this: Forwarding, v: unknown) {
|
|
3362
|
+
this.lng.texture = v;
|
|
3363
|
+
},
|
|
3364
|
+
},
|
|
3365
|
+
textureOptions: {
|
|
3366
|
+
get(this: Forwarding) {
|
|
3367
|
+
return this.lng.textureOptions;
|
|
3368
|
+
},
|
|
3369
|
+
set(this: Forwarding, v: unknown) {
|
|
3370
|
+
this.lng.textureOptions = v;
|
|
3371
|
+
},
|
|
3372
|
+
},
|
|
3373
|
+
// Not animated, text only
|
|
3374
|
+
contain: {
|
|
3375
|
+
get(this: ElementNode) {
|
|
3376
|
+
return textPropsOf(this).contain;
|
|
3377
|
+
},
|
|
3378
|
+
set(this: ElementNode, v: unknown) {
|
|
3379
|
+
textPropsFor(this).contain = v;
|
|
3380
|
+
// The DOM renderer sizes a text by it (renderer v2 only moves the
|
|
3381
|
+
// block: the measure finds nothing to lay out).
|
|
3382
|
+
this._textLayoutDirty();
|
|
3383
|
+
},
|
|
3384
|
+
},
|
|
3385
|
+
forceLoad: {
|
|
3386
|
+
get(this: ElementNode) {
|
|
3387
|
+
return textPropsOf(this).forceLoad;
|
|
3388
|
+
},
|
|
3389
|
+
set(this: ElementNode, v: unknown) {
|
|
3390
|
+
textPropsFor(this).forceLoad = v;
|
|
3391
|
+
},
|
|
3392
|
+
},
|
|
3393
|
+
fontStyle: {
|
|
3394
|
+
get(this: ElementNode) {
|
|
3395
|
+
return textPropsOf(this).fontStyle;
|
|
3396
|
+
},
|
|
3397
|
+
set(this: ElementNode, v: unknown) {
|
|
3398
|
+
textPropsFor(this).fontStyle = v;
|
|
3399
|
+
this._textLayoutDirty();
|
|
3400
|
+
},
|
|
3401
|
+
},
|
|
3402
|
+
letterSpacing: {
|
|
3403
|
+
get(this: ElementNode) {
|
|
3404
|
+
return textPropsOf(this).letterSpacing;
|
|
3405
|
+
},
|
|
3406
|
+
set(this: ElementNode, v: unknown) {
|
|
3407
|
+
textPropsFor(this).letterSpacing = v;
|
|
3408
|
+
this._textLayoutDirty();
|
|
3409
|
+
},
|
|
3410
|
+
},
|
|
3411
|
+
maxHeight: {
|
|
3412
|
+
get(this: ElementNode) {
|
|
3413
|
+
return textPropsOf(this).maxHeight;
|
|
3414
|
+
},
|
|
3415
|
+
set(this: ElementNode, v: unknown) {
|
|
3416
|
+
textPropsFor(this).maxHeight = v;
|
|
3417
|
+
this._textLayoutDirty();
|
|
3418
|
+
},
|
|
3419
|
+
},
|
|
3420
|
+
maxLines: {
|
|
3421
|
+
get(this: ElementNode) {
|
|
3422
|
+
return textPropsOf(this).maxLines;
|
|
3423
|
+
},
|
|
3424
|
+
set(this: ElementNode, v: unknown) {
|
|
3425
|
+
textPropsFor(this).maxLines = v;
|
|
3426
|
+
this._textLayoutDirty();
|
|
3427
|
+
},
|
|
3428
|
+
},
|
|
3429
|
+
maxWidth: {
|
|
3430
|
+
get(this: ElementNode) {
|
|
3431
|
+
return textPropsOf(this).maxWidth;
|
|
3432
|
+
},
|
|
3433
|
+
set(this: ElementNode, v: unknown) {
|
|
3434
|
+
textPropsFor(this).maxWidth = v;
|
|
3435
|
+
this._textLayoutDirty();
|
|
3436
|
+
},
|
|
3437
|
+
},
|
|
3438
|
+
offsetY: {
|
|
3439
|
+
get(this: ElementNode) {
|
|
3440
|
+
return textPropsOf(this).offsetY;
|
|
3441
|
+
},
|
|
3442
|
+
set(this: ElementNode, v: unknown) {
|
|
3443
|
+
textPropsFor(this).offsetY = v;
|
|
3444
|
+
},
|
|
3445
|
+
},
|
|
3446
|
+
overflowSuffix: {
|
|
3447
|
+
get(this: ElementNode) {
|
|
3448
|
+
return textPropsOf(this).overflowSuffix;
|
|
3449
|
+
},
|
|
3450
|
+
set(this: ElementNode, v: unknown) {
|
|
3451
|
+
textPropsFor(this).overflowSuffix = v;
|
|
3452
|
+
this._textLayoutDirty();
|
|
3453
|
+
},
|
|
3454
|
+
},
|
|
3455
|
+
text: {
|
|
3456
|
+
get(this: ElementNode) {
|
|
3457
|
+
return textPropsOf(this).text;
|
|
3458
|
+
},
|
|
3459
|
+
set(this: ElementNode, v: unknown) {
|
|
3460
|
+
textPropsFor(this).text = v;
|
|
3461
|
+
this._textLayoutDirty();
|
|
3462
|
+
},
|
|
3463
|
+
},
|
|
3464
|
+
textAlign: {
|
|
3465
|
+
get(this: ElementNode) {
|
|
3466
|
+
return textPropsOf(this).textAlign;
|
|
3467
|
+
},
|
|
3468
|
+
set(this: ElementNode, v: unknown) {
|
|
3469
|
+
textPropsFor(this).textAlign = v;
|
|
3470
|
+
},
|
|
3471
|
+
},
|
|
3472
|
+
verticalAlign: {
|
|
3473
|
+
get(this: ElementNode) {
|
|
3474
|
+
return textPropsOf(this).verticalAlign;
|
|
3475
|
+
},
|
|
3476
|
+
set(this: ElementNode, v: unknown) {
|
|
3477
|
+
textPropsFor(this).verticalAlign = v;
|
|
3478
|
+
},
|
|
3479
|
+
},
|
|
3480
|
+
wordBreak: {
|
|
3481
|
+
get(this: ElementNode) {
|
|
3482
|
+
return textPropsOf(this).wordBreak;
|
|
3483
|
+
},
|
|
3484
|
+
set(this: ElementNode, v: unknown) {
|
|
3485
|
+
textPropsFor(this).wordBreak = v;
|
|
3486
|
+
this._textLayoutDirty();
|
|
3487
|
+
},
|
|
3488
|
+
},
|
|
3489
|
+
// Read-only on the renderer node: a write would throw there (B20)
|
|
3490
|
+
absX: {
|
|
3491
|
+
get(this: Forwarding) {
|
|
3492
|
+
return this.lng.absX;
|
|
3493
|
+
},
|
|
3494
|
+
set: ignoreWrite,
|
|
3495
|
+
},
|
|
3496
|
+
absY: {
|
|
3497
|
+
get(this: Forwarding) {
|
|
3498
|
+
return this.lng.absY;
|
|
3499
|
+
},
|
|
3500
|
+
set: ignoreWrite,
|
|
3501
|
+
},
|
|
3502
|
+
destroyed: {
|
|
3503
|
+
get(this: Forwarding) {
|
|
3504
|
+
return this.lng.destroyed;
|
|
3505
|
+
},
|
|
3506
|
+
set: ignoreWrite,
|
|
3507
|
+
},
|
|
3508
|
+
});
|
|
3509
|
+
|
|
3510
|
+
// The DOM renderer draws fontStretch; a rendered WebGL text node has no such
|
|
3511
|
+
// prop, and a @solidtv/renderer 2.0 node would take it as a field of its own.
|
|
3512
|
+
// Before render the value waits in the props bag, which the renderer's
|
|
3513
|
+
// createTextNode ignores.
|
|
3514
|
+
Object.defineProperty(ElementNode.prototype, 'fontStretch', {
|
|
3515
|
+
get(this: ElementNode): unknown {
|
|
3516
|
+
return (this.lng as unknown as Record<string, unknown>).fontStretch;
|
|
3517
|
+
},
|
|
3518
|
+
set(this: ElementNode, v: unknown) {
|
|
3519
|
+
if (this.rendered && !isDomRendererActive()) return;
|
|
3520
|
+
(this.lng as unknown as Record<string, unknown>).fontStretch = v;
|
|
3521
|
+
},
|
|
3522
|
+
});
|
|
1964
3523
|
|
|
1965
3524
|
export function createRawShaderAccessor<T>(key: keyof StyleEffects) {
|
|
1966
3525
|
return {
|
|
1967
3526
|
set(this: ElementNode, value: T) {
|
|
3527
|
+
const shader = this.lng.shader as IRendererShader | null | undefined;
|
|
3528
|
+
if ((value as unknown) == null) {
|
|
3529
|
+
// Clear the shader this accessor made; createShader would make one
|
|
3530
|
+
// with the type's defaults. A shader made otherwise is not ours.
|
|
3531
|
+
if (shader != null && gradientShaders.get(shader) === key) {
|
|
3532
|
+
this._shaderProps = undefined;
|
|
3533
|
+
this.lng.shader = null;
|
|
3534
|
+
}
|
|
3535
|
+
return;
|
|
3536
|
+
}
|
|
3537
|
+
if (
|
|
3538
|
+
shader != null &&
|
|
3539
|
+
isObject(value) &&
|
|
3540
|
+
gradientShaders.get(shader) === key
|
|
3541
|
+
) {
|
|
3542
|
+
// The gradient shader this accessor made: update it, not a new one,
|
|
3543
|
+
// to the props createShader would have built from `value`: a
|
|
3544
|
+
// declared prop `value` does not name takes its default. The type's
|
|
3545
|
+
// declaration is read here, each set: a gradient is set rarely.
|
|
3546
|
+
const type = shader.shaderType as unknown;
|
|
3547
|
+
const defs = isObject(type) ? type.props : undefined;
|
|
3548
|
+
if (!isObject(defs)) {
|
|
3549
|
+
// The DOM renderer keeps the given object as the props.
|
|
3550
|
+
shader.props = value as IRendererShaderProps;
|
|
3551
|
+
} else {
|
|
3552
|
+
const props = shader.props as Record<string, unknown>;
|
|
3553
|
+
// Props first, then aliases, each in declaration order, as
|
|
3554
|
+
// createShader applies them; an alias only writes when given.
|
|
3555
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
3556
|
+
for (const name in defs) {
|
|
3557
|
+
const def = defs[name];
|
|
3558
|
+
// An AdvancedProp has a default (the registry's test).
|
|
3559
|
+
const advanced = isObject(def) && def.default !== undefined;
|
|
3560
|
+
const alias =
|
|
3561
|
+
advanced && (def as AdvancedPropLike).set !== undefined;
|
|
3562
|
+
if (alias !== (pass === 1)) {
|
|
3563
|
+
continue;
|
|
3564
|
+
}
|
|
3565
|
+
const resolves =
|
|
3566
|
+
advanced && (def as AdvancedPropLike).resolve !== undefined;
|
|
3567
|
+
const given = value[name];
|
|
3568
|
+
if (given !== undefined) {
|
|
3569
|
+
// createShader copies an array, unless the prop resolves it.
|
|
3570
|
+
props[name] = resolves ? given : copyOf(given);
|
|
3571
|
+
} else if (!alias) {
|
|
3572
|
+
// What a shader created without it holds: a prop that
|
|
3573
|
+
// resolves its value resolves its default from undefined, a
|
|
3574
|
+
// plain one takes a copy of its default.
|
|
3575
|
+
props[name] = resolves
|
|
3576
|
+
? undefined
|
|
3577
|
+
: copyOf(advanced ? (def as AdvancedPropLike).default : def);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
if (this.rendered && isDomRendererActive()) {
|
|
3583
|
+
// The DOM renderer restyles when its shader is assigned.
|
|
3584
|
+
(this.lng as IRendererNode).shader = shader;
|
|
3585
|
+
}
|
|
3586
|
+
return;
|
|
3587
|
+
}
|
|
1968
3588
|
this.shader = [key, value as unknown as IRendererShaderProps];
|
|
3589
|
+
const created = this.lng.shader as object | null | undefined;
|
|
3590
|
+
if (created != null) {
|
|
3591
|
+
gradientShaders.set(created, key);
|
|
3592
|
+
}
|
|
1969
3593
|
},
|
|
1970
3594
|
|
|
1971
3595
|
get(this: ElementNode) {
|
|
@@ -1986,47 +3610,84 @@ export function shaderAccessor<T extends Record<string, any> | number>(
|
|
|
1986
3610
|
) {
|
|
1987
3611
|
return {
|
|
1988
3612
|
set(this: ElementNode, value: T) {
|
|
1989
|
-
let
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
3613
|
+
let effects = this._effects;
|
|
3614
|
+
if (effects === undefined) {
|
|
3615
|
+
effects = this._effects = {};
|
|
3616
|
+
}
|
|
3617
|
+
const prev: unknown = effects[key];
|
|
3618
|
+
effects[key] = value;
|
|
3619
|
+
// The radius (a number written to a border key too), else a border or
|
|
3620
|
+
// shadow object: as before 1.7, its sub-props merge into the shader
|
|
3621
|
+
// props, the later write winning, so a state undo that writes the
|
|
3622
|
+
// style's object back leaves the sub-props it does not name (B18, not
|
|
3623
|
+
// fixed in 1.7); undefined writes nothing.
|
|
3624
|
+
const radius = key === 'rounded' || typeof value === 'number';
|
|
3625
|
+
const shader = this.lng.shader as IRendererShader | null | undefined;
|
|
3626
|
+
const props = shader != null ? shader.props : undefined;
|
|
3627
|
+
let target: Record<string, unknown>;
|
|
1993
3628
|
let animationSettings: AnimationSettings | undefined;
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
3629
|
+
if (props != null) {
|
|
3630
|
+
target = props as Record<string, unknown>;
|
|
3631
|
+
// With a transition for the key, the sub-props go into a target of
|
|
3632
|
+
// their own, which animates (one of `true` is built and dropped, as
|
|
3633
|
+
// before 1.7).
|
|
3634
|
+
const transition = this.transition;
|
|
3635
|
+
if (transition) {
|
|
3636
|
+
const setting =
|
|
3637
|
+
transition === true
|
|
3638
|
+
? true
|
|
3639
|
+
: transition[key === 'rounded' ? 'borderRadius' : key];
|
|
3640
|
+
if (setting) {
|
|
3641
|
+
target = {};
|
|
3642
|
+
animationSettings =
|
|
3643
|
+
setting === true ? undefined : (setting as AnimationSettings);
|
|
3644
|
+
}
|
|
2009
3645
|
}
|
|
3646
|
+
} else {
|
|
3647
|
+
// No shader yet: before render, the props bag createShader reads at
|
|
3648
|
+
// render; after render, the props of a new shader. (A rendered DOM
|
|
3649
|
+
// node without one holds the renderer's shared default: never write
|
|
3650
|
+
// into it.)
|
|
3651
|
+
target =
|
|
3652
|
+
shader != null && !this.rendered
|
|
3653
|
+
? (shader as unknown as Record<string, unknown>)
|
|
3654
|
+
: {};
|
|
3655
|
+
}
|
|
3656
|
+
if (radius) {
|
|
3657
|
+
// Into the shader's props only when it changed. An animated undo to
|
|
3658
|
+
// no radius animates to 0, which is what 1.6.4 showed: renderer 1.9
|
|
3659
|
+
// made a track for undefined and resolved it to [0, 0, 0, 0];
|
|
3660
|
+
// renderer 2.0 makes no track for undefined.
|
|
3661
|
+
if (target === props && value === prev) {
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3664
|
+
target.radius =
|
|
3665
|
+
value === undefined && animationSettings !== undefined ? 0 : value;
|
|
3666
|
+
} else if (isObject(value)) {
|
|
3667
|
+
parseAndAssignShaderProps(key, value, target);
|
|
2010
3668
|
}
|
|
2011
3669
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
3670
|
+
// A shader convertToShader made keeps its props and swaps its type when
|
|
3671
|
+
// a border width moves to or from 0. An animated write swaps a border
|
|
3672
|
+
// it adds in before the animation reads its start values; one it
|
|
3673
|
+
// removes stays until the animation stops.
|
|
3674
|
+
const kept = this._shaderProps;
|
|
3675
|
+
if (kept !== undefined) {
|
|
3676
|
+
const animated = target !== props;
|
|
2017
3677
|
if (animated) this._syncShaderType(target);
|
|
2018
|
-
if (
|
|
3678
|
+
if (kept !== target) {
|
|
3679
|
+
if (radius) kept.radius = target.radius;
|
|
3680
|
+
else if (isObject(value)) parseAndAssignShaderProps(key, value, kept);
|
|
3681
|
+
}
|
|
2019
3682
|
if (!animated) this._syncShaderType();
|
|
2020
3683
|
}
|
|
2021
|
-
|
|
2022
3684
|
this._writeShaderTarget(target);
|
|
2023
|
-
|
|
2024
|
-
if (animationSettings) {
|
|
3685
|
+
if (animationSettings !== undefined) {
|
|
2025
3686
|
const animation = this.animate(
|
|
2026
3687
|
{ shaderProps: target },
|
|
2027
3688
|
animationSettings,
|
|
2028
3689
|
).start();
|
|
2029
|
-
if (
|
|
3690
|
+
if (kept !== undefined) {
|
|
2030
3691
|
void animation.waitUntilStopped().then(() => this._syncShaderType());
|
|
2031
3692
|
}
|
|
2032
3693
|
}
|
|
@@ -2057,4 +3718,8 @@ Object.defineProperties(ElementNode.prototype, {
|
|
|
2057
3718
|
createRawShaderAccessor<LinearGradientProps>('linearGradient'),
|
|
2058
3719
|
radialGradient:
|
|
2059
3720
|
createRawShaderAccessor<RadialGradientProps>('radialGradient'),
|
|
3721
|
+
dashedBorder:
|
|
3722
|
+
createRawShaderAccessor<AddColorString<Partial<DashedBorderProps>>>(
|
|
3723
|
+
'dashedBorder',
|
|
3724
|
+
),
|
|
2060
3725
|
});
|