@pilates/core 1.0.0-rc.1 → 1.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/LICENSE +1 -1
- package/README.md +14 -8
- package/dist/algorithm/axis.d.ts +13 -0
- package/dist/algorithm/axis.d.ts.map +1 -1
- package/dist/algorithm/axis.js +24 -0
- package/dist/algorithm/axis.js.map +1 -1
- package/dist/algorithm/cache.d.ts +225 -0
- package/dist/algorithm/cache.d.ts.map +1 -0
- package/dist/algorithm/cache.js +312 -0
- package/dist/algorithm/cache.js.map +1 -0
- package/dist/algorithm/index.d.ts +7 -0
- package/dist/algorithm/index.d.ts.map +1 -1
- package/dist/algorithm/index.js +128 -4
- package/dist/algorithm/index.js.map +1 -1
- package/dist/algorithm/main-axis.d.ts +1 -1
- package/dist/algorithm/main-axis.d.ts.map +1 -1
- package/dist/algorithm/main-axis.js +253 -58
- package/dist/algorithm/main-axis.js.map +1 -1
- package/dist/algorithm/round.d.ts +17 -0
- package/dist/algorithm/round.d.ts.map +1 -1
- package/dist/algorithm/round.js +42 -4
- package/dist/algorithm/round.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +8 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +1 -1
- package/dist/layout.js.map +1 -1
- package/dist/node.d.ts +179 -6
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +292 -37
- package/dist/node.js.map +1 -1
- package/dist/style.d.ts +20 -1
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +5 -1
- package/dist/style.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/algorithm/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,YAAY;IACf,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AAG,EAAE,CAAC,QAAQ,CAAC;IAC5B,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,CAAmB,EAAE,CAAmB;IAClE,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,oCAAoC,CAAC,CAAC,MAAM,oBAAoB,CAAC,CAAC,MAAM,EAAE,CAAC;IACpF,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;IAC1F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACjB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,OAAO,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
* 2. Recursively lay out children in floating-point coordinates.
|
|
7
7
|
* 3. Round the whole tree to integer cells.
|
|
8
8
|
* 4. Mark every node clean.
|
|
9
|
+
*
|
|
10
|
+
* When `PILATES_DIFFERENTIAL_LAYOUT=1` is set in the environment, the
|
|
11
|
+
* exported `calculateLayout` runs the algorithm twice — once normally
|
|
12
|
+
* (with caches active), then again with all caches cleared and every
|
|
13
|
+
* node forcibly re-dirtied — and asserts the two snapshots are byte
|
|
14
|
+
* identical. Used by the test suite (`pnpm test:differential`) to
|
|
15
|
+
* catch any cache-correctness regression as soon as it lands.
|
|
9
16
|
*/
|
|
10
17
|
import type { Node } from '../node.js';
|
|
11
18
|
export declare function calculateLayout(root: Node, availableWidth: number | undefined, availableHeight: number | undefined): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/algorithm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/algorithm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAevC,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC,IAAI,CAsBN"}
|
package/dist/algorithm/index.js
CHANGED
|
@@ -6,21 +6,145 @@
|
|
|
6
6
|
* 2. Recursively lay out children in floating-point coordinates.
|
|
7
7
|
* 3. Round the whole tree to integer cells.
|
|
8
8
|
* 4. Mark every node clean.
|
|
9
|
+
*
|
|
10
|
+
* When `PILATES_DIFFERENTIAL_LAYOUT=1` is set in the environment, the
|
|
11
|
+
* exported `calculateLayout` runs the algorithm twice — once normally
|
|
12
|
+
* (with caches active), then again with all caches cleared and every
|
|
13
|
+
* node forcibly re-dirtied — and asserts the two snapshots are byte
|
|
14
|
+
* identical. Used by the test suite (`pnpm test:differential`) to
|
|
15
|
+
* catch any cache-correctness regression as soon as it lands.
|
|
9
16
|
*/
|
|
17
|
+
import { LayoutCache, clearAllCaches, diffLayouts, markDirtyDeep, restoreFromCache, snapshotForCache, snapshotTreeLayouts, } from './cache.js';
|
|
10
18
|
import { layoutChildren, resolveRootAxisSize } from './main-axis.js';
|
|
11
19
|
import { roundLayout } from './round.js';
|
|
20
|
+
const DIFFERENTIAL = process.env.PILATES_DIFFERENTIAL_LAYOUT === '1';
|
|
12
21
|
export function calculateLayout(root, availableWidth, availableHeight) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
if (!DIFFERENTIAL) {
|
|
23
|
+
calculateLayoutImpl(root, availableWidth, availableHeight);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// First pass: cached path (normal).
|
|
27
|
+
calculateLayoutImpl(root, availableWidth, availableHeight);
|
|
28
|
+
const cachedSnapshot = snapshotTreeLayouts(root);
|
|
29
|
+
// Second pass: clear caches, re-dirty, recompute cold.
|
|
30
|
+
clearAllCaches(root);
|
|
31
|
+
markDirtyDeep(root);
|
|
32
|
+
calculateLayoutImpl(root, availableWidth, availableHeight);
|
|
33
|
+
const coldSnapshot = snapshotTreeLayouts(root);
|
|
34
|
+
const diff = diffLayouts(cachedSnapshot, coldSnapshot);
|
|
35
|
+
if (diff !== '') {
|
|
36
|
+
throw new Error(`[pilates differential layout] cache produced different result than fresh recompute:\n ${diff}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function calculateLayoutImpl(root, availableWidth, availableHeight) {
|
|
40
|
+
const widthMode = availableWidth === undefined ? 'undefined' : 'exactly';
|
|
41
|
+
const heightMode = availableHeight === undefined ? 'undefined' : 'exactly';
|
|
42
|
+
const aw = availableWidth ?? Number.POSITIVE_INFINITY;
|
|
43
|
+
const ah = availableHeight ?? Number.POSITIVE_INFINITY;
|
|
44
|
+
const key = {
|
|
45
|
+
availableWidth: aw,
|
|
46
|
+
widthMode,
|
|
47
|
+
availableHeight: ah,
|
|
48
|
+
heightMode,
|
|
49
|
+
};
|
|
50
|
+
// Cache hit at root: clean tree + matching inputs.
|
|
51
|
+
if (!root.isDirty() && root._layoutCache !== undefined) {
|
|
52
|
+
const hit = root._layoutCache.lookup(key);
|
|
53
|
+
if (hit !== undefined) {
|
|
54
|
+
root._layout.left = 0;
|
|
55
|
+
root._layout.top = 0;
|
|
56
|
+
root._floatLeft = 0;
|
|
57
|
+
root._floatTop = 0;
|
|
58
|
+
restoreFromCache(root, hit);
|
|
59
|
+
// Children may have their own caches; recurse to either hit those
|
|
60
|
+
// or fall back to recompute on miss. Pass useCache=true so inner nodes
|
|
61
|
+
// can also use their caches. This is safe because the root cache-hit
|
|
62
|
+
// path skips roundLayout — cached values were already rounded at their
|
|
63
|
+
// original absolute positions, which are unchanged when the root hits.
|
|
64
|
+
//
|
|
65
|
+
// Phase 3 optimisation: a child can be skipped entirely when BOTH
|
|
66
|
+
// (a) the child itself is not dirty, AND
|
|
67
|
+
// (b) no descendant of the child is dirty.
|
|
68
|
+
// Condition (b) is tracked by `_hasDirtyDescendant`. A boundary that
|
|
69
|
+
// stops dirty propagation still sets `_hasDirtyDescendant = true` on
|
|
70
|
+
// its ancestors (without marking them dirty), so a clean direct child
|
|
71
|
+
// of root with `_hasDirtyDescendant = true` is the signal that a
|
|
72
|
+
// boundary somewhere below needs to be re-laid out.
|
|
73
|
+
// When both flags are false, the subtree is fully clean: layout values
|
|
74
|
+
// are unchanged from the last pass and no recursion is needed.
|
|
75
|
+
for (let i = 0; i < root.getChildCount(); i++) {
|
|
76
|
+
const c = root.getChild(i);
|
|
77
|
+
if (c.style.display === 'none')
|
|
78
|
+
continue;
|
|
79
|
+
if (!c.isDirty() && !c._hasDirtyDescendant)
|
|
80
|
+
continue;
|
|
81
|
+
// c._layout.{width,height} were populated by restoreFromCache(root, ...)
|
|
82
|
+
// above. layoutChildren will use them as the EXACTLY-sized container
|
|
83
|
+
// and either hit c's own cache or recompute.
|
|
84
|
+
layoutChildren(c, true);
|
|
85
|
+
}
|
|
86
|
+
markClean(root);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Cold path
|
|
91
|
+
root._layout.left = 0;
|
|
92
|
+
root._layout.top = 0;
|
|
93
|
+
root._floatLeft = 0;
|
|
94
|
+
root._floatTop = 0;
|
|
95
|
+
root._layout.width = resolveRootAxisSize(root, 'row', availableWidth);
|
|
96
|
+
root._layout.height = resolveRootAxisSize(root, 'column', availableHeight);
|
|
17
97
|
layoutChildren(root);
|
|
18
98
|
roundLayout(root);
|
|
99
|
+
computeScrollSizes(root);
|
|
19
100
|
markClean(root);
|
|
101
|
+
// Store the root's result (computeScrollSizes already cached inner nodes).
|
|
102
|
+
if (root._layoutCache === undefined)
|
|
103
|
+
root._layoutCache = new LayoutCache();
|
|
104
|
+
root._layoutCache.store(key, snapshotForCache(root));
|
|
20
105
|
}
|
|
21
106
|
function markClean(node) {
|
|
22
107
|
node.clearDirty();
|
|
23
108
|
for (let i = 0; i < node.getChildCount(); i++)
|
|
24
109
|
markClean(node.getChild(i));
|
|
25
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Walk the tree post-rounding and record each node's content bounding box on
|
|
113
|
+
* `_layout.scrollWidth` / `_layout.scrollHeight`. We compute this for every
|
|
114
|
+
* node — not just `overflow !== 'visible'` ones — so consumers see a stable
|
|
115
|
+
* shape: for non-overflow parents the values collapse to the node's own
|
|
116
|
+
* width/height (children never exceed the box at layout time anyway), while
|
|
117
|
+
* for overflow parents the values reflect the natural child extent that
|
|
118
|
+
* would otherwise be invisible behind the scroll viewport.
|
|
119
|
+
*
|
|
120
|
+
* Runs after `roundLayout` so the recorded extent is in integer cells and
|
|
121
|
+
* matches what the renderer paints.
|
|
122
|
+
*/
|
|
123
|
+
function computeScrollSizes(node) {
|
|
124
|
+
for (let i = 0; i < node.getChildCount(); i++)
|
|
125
|
+
computeScrollSizes(node.getChild(i));
|
|
126
|
+
let contentRight = 0;
|
|
127
|
+
let contentBottom = 0;
|
|
128
|
+
for (let i = 0; i < node.getChildCount(); i++) {
|
|
129
|
+
const c = node.getChild(i);
|
|
130
|
+
const cl = c._layout;
|
|
131
|
+
contentRight = Math.max(contentRight, cl.left + cl.width);
|
|
132
|
+
contentBottom = Math.max(contentBottom, cl.top + cl.height);
|
|
133
|
+
}
|
|
134
|
+
node._layout.scrollWidth = Math.max(node._layout.width, contentRight);
|
|
135
|
+
node._layout.scrollHeight = Math.max(node._layout.height, contentBottom);
|
|
136
|
+
// Cache the node's layout for next pass. Skip root (cached separately
|
|
137
|
+
// by calculateLayoutImpl with the original root key).
|
|
138
|
+
if (node.getParent() !== null) {
|
|
139
|
+
const innerKey = {
|
|
140
|
+
availableWidth: node.layout.width,
|
|
141
|
+
widthMode: 'exactly',
|
|
142
|
+
availableHeight: node.layout.height,
|
|
143
|
+
heightMode: 'exactly',
|
|
144
|
+
};
|
|
145
|
+
if (node._layoutCache === undefined)
|
|
146
|
+
node._layoutCache = new LayoutCache();
|
|
147
|
+
node._layoutCache.store(innerKey, snapshotForCache(node));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
26
150
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/algorithm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/algorithm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG,CAAC;AAErE,MAAM,UAAU,eAAe,CAC7B,IAAU,EACV,cAAkC,EAClC,eAAmC;IAEnC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;QAC3D,OAAO;IACT,CAAC;IAED,oCAAoC;IACpC,mBAAmB,CAA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,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC;QACrB,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1D,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEzE,sEAAsE;IACtE,sDAAsD;IACtD,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG;YACf,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACjC,SAAS,EAAE,SAAkB;YAC7B,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YACnC,UAAU,EAAE,SAAkB;SAC/B,CAAC;QACF,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;YAAE,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;QAC3E,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -47,7 +47,7 @@ import { type Axis } from './axis.js';
|
|
|
47
47
|
* non-hidden child so their own descendants are laid out within the box
|
|
48
48
|
* we just assigned them.
|
|
49
49
|
*/
|
|
50
|
-
export declare function layoutChildren(node: Node): void;
|
|
50
|
+
export declare function layoutChildren(node: Node, useCache?: boolean, parentAbsX?: number, parentAbsY?: number): void;
|
|
51
51
|
/**
|
|
52
52
|
* Resolve the root node's own size from style + caller-supplied availability.
|
|
53
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-axis.d.ts","sourceRoot":"","sources":["../../src/algorithm/main-axis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EACL,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"main-axis.d.ts","sourceRoot":"","sources":["../../src/algorithm/main-axis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EACL,KAAK,IAAI,EAYV,MAAM,WAAW,CAAC;AA8DnB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,UAAQ,EAAE,UAAU,SAAI,EAAE,UAAU,SAAI,GAAG,IAAI,CAgGjG;AA4xBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAgBjG"}
|