flexily 0.2.0 → 0.3.1

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.
Files changed (85) hide show
  1. package/README.md +16 -16
  2. package/package.json +24 -24
  3. package/src/CLAUDE.md +36 -21
  4. package/src/classic/layout.ts +107 -47
  5. package/src/classic/node.ts +60 -0
  6. package/src/constants.ts +2 -1
  7. package/src/index-classic.ts +1 -1
  8. package/src/index.ts +1 -1
  9. package/src/layout-flex-lines.ts +70 -3
  10. package/src/layout-helpers.ts +29 -9
  11. package/src/layout-stats.ts +0 -2
  12. package/src/layout-zero.ts +587 -160
  13. package/src/node-zero.ts +98 -2
  14. package/src/testing.ts +20 -14
  15. package/src/types.ts +22 -15
  16. package/src/utils.ts +47 -21
  17. package/dist/classic/layout.d.ts +0 -57
  18. package/dist/classic/layout.d.ts.map +0 -1
  19. package/dist/classic/layout.js +0 -1558
  20. package/dist/classic/layout.js.map +0 -1
  21. package/dist/classic/node.d.ts +0 -648
  22. package/dist/classic/node.d.ts.map +0 -1
  23. package/dist/classic/node.js +0 -1002
  24. package/dist/classic/node.js.map +0 -1
  25. package/dist/constants.d.ts +0 -58
  26. package/dist/constants.d.ts.map +0 -1
  27. package/dist/constants.js +0 -70
  28. package/dist/constants.js.map +0 -1
  29. package/dist/index-classic.d.ts +0 -30
  30. package/dist/index-classic.d.ts.map +0 -1
  31. package/dist/index-classic.js +0 -57
  32. package/dist/index-classic.js.map +0 -1
  33. package/dist/index.d.ts +0 -30
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/index.js +0 -57
  36. package/dist/index.js.map +0 -1
  37. package/dist/layout-flex-lines.d.ts +0 -77
  38. package/dist/layout-flex-lines.d.ts.map +0 -1
  39. package/dist/layout-flex-lines.js +0 -317
  40. package/dist/layout-flex-lines.js.map +0 -1
  41. package/dist/layout-helpers.d.ts +0 -48
  42. package/dist/layout-helpers.d.ts.map +0 -1
  43. package/dist/layout-helpers.js +0 -108
  44. package/dist/layout-helpers.js.map +0 -1
  45. package/dist/layout-measure.d.ts +0 -25
  46. package/dist/layout-measure.d.ts.map +0 -1
  47. package/dist/layout-measure.js +0 -231
  48. package/dist/layout-measure.js.map +0 -1
  49. package/dist/layout-stats.d.ts +0 -19
  50. package/dist/layout-stats.d.ts.map +0 -1
  51. package/dist/layout-stats.js +0 -37
  52. package/dist/layout-stats.js.map +0 -1
  53. package/dist/layout-traversal.d.ts +0 -28
  54. package/dist/layout-traversal.d.ts.map +0 -1
  55. package/dist/layout-traversal.js +0 -65
  56. package/dist/layout-traversal.js.map +0 -1
  57. package/dist/layout-zero.d.ts +0 -26
  58. package/dist/layout-zero.d.ts.map +0 -1
  59. package/dist/layout-zero.js +0 -1601
  60. package/dist/layout-zero.js.map +0 -1
  61. package/dist/logger.d.ts +0 -14
  62. package/dist/logger.d.ts.map +0 -1
  63. package/dist/logger.js +0 -61
  64. package/dist/logger.js.map +0 -1
  65. package/dist/node-zero.d.ts +0 -702
  66. package/dist/node-zero.d.ts.map +0 -1
  67. package/dist/node-zero.js +0 -1268
  68. package/dist/node-zero.js.map +0 -1
  69. package/dist/testing.d.ts +0 -69
  70. package/dist/testing.d.ts.map +0 -1
  71. package/dist/testing.js +0 -179
  72. package/dist/testing.js.map +0 -1
  73. package/dist/trace.d.ts +0 -74
  74. package/dist/trace.d.ts.map +0 -1
  75. package/dist/trace.js +0 -191
  76. package/dist/trace.js.map +0 -1
  77. package/dist/types.d.ts +0 -170
  78. package/dist/types.d.ts.map +0 -1
  79. package/dist/types.js +0 -43
  80. package/dist/types.js.map +0 -1
  81. package/dist/utils.d.ts +0 -41
  82. package/dist/utils.d.ts.map +0 -1
  83. package/dist/utils.js +0 -197
  84. package/dist/utils.js.map +0 -1
  85. package/src/beorn-logger.d.ts +0 -10
package/dist/types.d.ts DELETED
@@ -1,170 +0,0 @@
1
- /**
2
- * Flexily Types
3
- *
4
- * TypeScript interfaces for the flexbox layout engine.
5
- */
6
- /**
7
- * A value with a unit (point, percent, or auto).
8
- */
9
- export interface Value {
10
- value: number;
11
- unit: number;
12
- }
13
- /**
14
- * Measure function signature for intrinsic sizing.
15
- * Called by the layout algorithm to determine a node's natural size.
16
- */
17
- export type MeasureFunc = (width: number, widthMode: number, height: number, heightMode: number) => {
18
- width: number;
19
- height: number;
20
- };
21
- /**
22
- * Baseline function signature for baseline alignment.
23
- * Called by the layout algorithm to determine a node's baseline offset from its top edge.
24
- * Used with ALIGN_BASELINE to align text baselines across siblings.
25
- *
26
- * @param width - The computed width of the node
27
- * @param height - The computed height of the node
28
- * @returns The baseline offset from the top of the node (in points)
29
- */
30
- export type BaselineFunc = (width: number, height: number) => number;
31
- /**
32
- * Cache entry for measure results.
33
- * Stores input constraints (w, wm, h, hm) and output (rw, rh).
34
- */
35
- export interface MeasureEntry {
36
- w: number;
37
- wm: number;
38
- h: number;
39
- hm: number;
40
- rw: number;
41
- rh: number;
42
- }
43
- /**
44
- * Cache entry for layout results.
45
- * Stores input available dimensions and computed size.
46
- * Used to avoid redundant recursive layout calls during a single pass.
47
- */
48
- export interface LayoutCacheEntry {
49
- availW: number;
50
- availH: number;
51
- computedW: number;
52
- computedH: number;
53
- }
54
- /**
55
- * Per-node flex calculation state for zero-allocation layout.
56
- *
57
- * This interface enables the layout engine to avoid heap allocations during
58
- * layout passes by storing all intermediate calculation state directly on
59
- * each Node. Fields are mutated (not recreated) each pass.
60
- *
61
- * Design rationale:
62
- * - Eliminates ChildLayout object allocation (previously created per child per pass)
63
- * - Enables filtered iteration via relativeIndex (avoids temporary array allocation)
64
- * - Stores line membership for flex-wrap (avoids FlexLine[] allocation)
65
- *
66
- * All numeric fields use number (Float64 in V8) for precision. Boolean fields
67
- * track state that affects the CSS Flexbox algorithm's iterative distribution.
68
- *
69
- * @see layout.ts for usage in layoutNode() and distributeFlexSpaceForLine()
70
- */
71
- export interface FlexInfo {
72
- /** Computed main-axis size after flex distribution */
73
- mainSize: number;
74
- /** Original base size before flex distribution (used for weighted shrink) */
75
- baseSize: number;
76
- /** Total main-axis margin (non-auto margins only) */
77
- mainMargin: number;
78
- /** flex-grow factor from style */
79
- flexGrow: number;
80
- /** flex-shrink factor from style */
81
- flexShrink: number;
82
- /** Resolved min-width/height constraint on main axis */
83
- minMain: number;
84
- /** Resolved max-width/height constraint on main axis (Infinity if none) */
85
- maxMain: number;
86
- /** Whether main-start margin is auto (absorbs free space) */
87
- mainStartMarginAuto: boolean;
88
- /** Whether main-end margin is auto (absorbs free space) */
89
- mainEndMarginAuto: boolean;
90
- /** Resolved main-start margin value (0 if auto, computed later) */
91
- mainStartMarginValue: number;
92
- /** Resolved main-end margin value (0 if auto, computed later) */
93
- mainEndMarginValue: number;
94
- /** Cached resolved margin values [left, top, right, bottom] */
95
- marginL: number;
96
- marginT: number;
97
- marginR: number;
98
- marginB: number;
99
- /** Frozen in flex distribution (clamped to min/max constraint) */
100
- frozen: boolean;
101
- /** Line index for flex-wrap (0-based, which line this child belongs to) */
102
- lineIndex: number;
103
- /**
104
- * Relative index for filtered iteration.
105
- * -1 = absolute positioned or display:none (skip in flex layout)
106
- * 0+ = index among relative children (participates in flex layout)
107
- */
108
- relativeIndex: number;
109
- /** Computed baseline offset for ALIGN_BASELINE (zero-alloc: avoids per-pass array) */
110
- baseline: number;
111
- /** Last availableWidth passed to layoutNode */
112
- lastAvailW: number;
113
- /** Last availableHeight passed to layoutNode */
114
- lastAvailH: number;
115
- /** Last offsetX passed to layoutNode */
116
- lastOffsetX: number;
117
- /** Last offsetY passed to layoutNode */
118
- lastOffsetY: number;
119
- /** Whether cached layout is valid (fingerprint matched, not dirty) */
120
- layoutValid: boolean;
121
- /** Last direction passed to layoutNode */
122
- lastDir: number;
123
- }
124
- /**
125
- * Computed layout result for a node.
126
- */
127
- export interface Layout {
128
- left: number;
129
- top: number;
130
- width: number;
131
- height: number;
132
- }
133
- /**
134
- * Internal style properties for a node.
135
- */
136
- export interface Style {
137
- display: number;
138
- positionType: number;
139
- position: [Value, Value, Value, Value, Value, Value];
140
- flexDirection: number;
141
- flexWrap: number;
142
- flexGrow: number;
143
- flexShrink: number;
144
- flexBasis: Value;
145
- alignItems: number;
146
- alignSelf: number;
147
- alignContent: number;
148
- justifyContent: number;
149
- width: Value;
150
- height: Value;
151
- minWidth: Value;
152
- minHeight: Value;
153
- maxWidth: Value;
154
- maxHeight: Value;
155
- aspectRatio: number;
156
- margin: [Value, Value, Value, Value, Value, Value];
157
- padding: [Value, Value, Value, Value, Value, Value];
158
- border: [number, number, number, number, number, number];
159
- gap: [number, number];
160
- overflow: number;
161
- }
162
- /**
163
- * Create a default Value (undefined).
164
- */
165
- export declare function createValue(value?: number, unit?: number): Value;
166
- /**
167
- * Create default style.
168
- */
169
- export declare function createDefaultStyle(): Style;
170
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,KACf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtC;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;AAEpE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACX;A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A;IAGxD,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAGrB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,SAAI,EAAE,IAAI,SAAI,GAAG,KAAK,CAEtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,KAAK,CA2B1C"}
package/dist/types.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * Flexture Types
3
- *
4
- * TypeScript interfaces for the flexbox layout engine.
5
- */
6
- /**
7
- * Create a default Value (undefined).
8
- */
9
- export function createValue(value = 0, unit = 0) {
10
- return { value, unit };
11
- }
12
- /**
13
- * Create default style.
14
- */
15
- export function createDefaultStyle() {
16
- return {
17
- display: 0, // DISPLAY_FLEX
18
- positionType: 1, // POSITION_TYPE_RELATIVE
19
- position: [createValue(), createValue(), createValue(), createValue(), createValue(), createValue()],
20
- flexDirection: 0, // FLEX_DIRECTION_COLUMN (Yoga default, not CSS!)
21
- flexWrap: 0, // WRAP_NO_WRAP
22
- flexGrow: 0,
23
- flexShrink: 0, // Yoga native default (CSS uses 1)
24
- flexBasis: createValue(0, 3), // AUTO
25
- alignItems: 4, // ALIGN_STRETCH
26
- alignSelf: 0, // ALIGN_AUTO
27
- alignContent: 1, // ALIGN_FLEX_START
28
- justifyContent: 0, // JUSTIFY_FLEX_START
29
- width: createValue(0, 3), // AUTO
30
- height: createValue(0, 3), // AUTO
31
- minWidth: createValue(),
32
- minHeight: createValue(),
33
- maxWidth: createValue(),
34
- maxHeight: createValue(),
35
- aspectRatio: NaN, // undefined by default
36
- margin: [createValue(), createValue(), createValue(), createValue(), createValue(), createValue()],
37
- padding: [createValue(), createValue(), createValue(), createValue(), createValue(), createValue()],
38
- border: [0, 0, 0, 0, NaN, NaN],
39
- gap: [0, 0],
40
- overflow: 0, // OVERFLOW_VISIBLE
41
- };
42
- }
43
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0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EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC;QAClG,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC;QACnG,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;QAC9B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE,CAAC,EAAE,mBAAmB;KACjC,CAAA;AACH,CAAC"}
package/dist/utils.d.ts DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * Flexily Utility Functions
3
- *
4
- * Helper functions for edge value manipulation and value resolution.
5
- */
6
- import type { Value } from "./types.js";
7
- /**
8
- * Shared traversal stack for iterative tree operations.
9
- * Avoids recursion (prevents stack overflow on deep trees) and avoids
10
- * allocation during layout passes.
11
- */
12
- export declare const traversalStack: unknown[];
13
- /**
14
- * Set a value on an edge array (supports all edge types including logical START/END).
15
- */
16
- export declare function setEdgeValue(arr: [Value, Value, Value, Value, Value, Value], edge: number, value: number, unit: number): void;
17
- /**
18
- * Set a border value on an edge array.
19
- */
20
- export declare function setEdgeBorder(arr: [number, number, number, number, number, number], edge: number, value: number): void;
21
- /**
22
- * Get a value from an edge array.
23
- */
24
- export declare function getEdgeValue(arr: [Value, Value, Value, Value, Value, Value], edge: number): Value;
25
- /**
26
- * Get a border value from an edge array.
27
- */
28
- export declare function getEdgeBorderValue(arr: [number, number, number, number, number, number], edge: number): number;
29
- /**
30
- * Resolve a value (point or percent) to an absolute number.
31
- */
32
- export declare function resolveValue(value: Value, availableSize: number): number;
33
- /**
34
- * Apply min/max constraints to a size.
35
- *
36
- * When size is NaN (auto-sized), min constraints establish a floor.
37
- * This handles the case where a parent has minWidth/maxWidth but no explicit width -
38
- * children need to resolve percentages against the constrained size.
39
- */
40
- export declare function applyMinMax(size: number, min: Value, max: Value, available: number): number;
41
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AASvC;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,EAAO,CAAA;AAE3C;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAC/C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,IAAI,CAsCN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACrD,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,IAAI,CAqCN;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAiBjG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB9G;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAaxE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CA8B3F"}
package/dist/utils.js DELETED
@@ -1,197 +0,0 @@
1
- /**
2
- * Flexture Utility Functions
3
- *
4
- * Helper functions for edge value manipulation and value resolution.
5
- */
6
- import * as C from "./constants.js";
7
- // ============================================================================
8
- // Shared Traversal Stack
9
- // ============================================================================
10
- // Pre-allocated stack array for iterative tree traversal. Shared across all
11
- // layout functions to avoid multiple allocations. Using a single stack is safe
12
- // because layout operations are synchronous (no concurrent traversals).
13
- /**
14
- * Shared traversal stack for iterative tree operations.
15
- * Avoids recursion (prevents stack overflow on deep trees) and avoids
16
- * allocation during layout passes.
17
- */
18
- export const traversalStack = [];
19
- /**
20
- * Set a value on an edge array (supports all edge types including logical START/END).
21
- */
22
- export function setEdgeValue(arr, edge, value, unit) {
23
- const v = { value, unit };
24
- switch (edge) {
25
- case C.EDGE_LEFT:
26
- arr[0] = v;
27
- break;
28
- case C.EDGE_TOP:
29
- arr[1] = v;
30
- break;
31
- case C.EDGE_RIGHT:
32
- arr[2] = v;
33
- break;
34
- case C.EDGE_BOTTOM:
35
- arr[3] = v;
36
- break;
37
- case C.EDGE_HORIZONTAL:
38
- arr[0] = v;
39
- arr[2] = v;
40
- break;
41
- case C.EDGE_VERTICAL:
42
- arr[1] = v;
43
- arr[3] = v;
44
- break;
45
- case C.EDGE_ALL:
46
- arr[0] = v;
47
- arr[1] = v;
48
- arr[2] = v;
49
- arr[3] = v;
50
- break;
51
- case C.EDGE_START:
52
- // Store in logical START slot (resolved to physical at layout time)
53
- arr[4] = v;
54
- break;
55
- case C.EDGE_END:
56
- // Store in logical END slot (resolved to physical at layout time)
57
- arr[5] = v;
58
- break;
59
- }
60
- }
61
- /**
62
- * Set a border value on an edge array.
63
- */
64
- export function setEdgeBorder(arr, edge, value) {
65
- switch (edge) {
66
- case C.EDGE_LEFT:
67
- arr[0] = value;
68
- break;
69
- case C.EDGE_TOP:
70
- arr[1] = value;
71
- break;
72
- case C.EDGE_RIGHT:
73
- arr[2] = value;
74
- break;
75
- case C.EDGE_BOTTOM:
76
- arr[3] = value;
77
- break;
78
- case C.EDGE_HORIZONTAL:
79
- arr[0] = value;
80
- arr[2] = value;
81
- break;
82
- case C.EDGE_VERTICAL:
83
- arr[1] = value;
84
- arr[3] = value;
85
- break;
86
- case C.EDGE_ALL:
87
- arr[0] = value;
88
- arr[1] = value;
89
- arr[2] = value;
90
- arr[3] = value;
91
- break;
92
- case C.EDGE_START:
93
- // Store in logical START slot (resolved to physical at layout time)
94
- arr[4] = value;
95
- break;
96
- case C.EDGE_END:
97
- // Store in logical END slot (resolved to physical at layout time)
98
- arr[5] = value;
99
- break;
100
- }
101
- }
102
- /**
103
- * Get a value from an edge array.
104
- */
105
- export function getEdgeValue(arr, edge) {
106
- switch (edge) {
107
- case C.EDGE_LEFT:
108
- return arr[0];
109
- case C.EDGE_TOP:
110
- return arr[1];
111
- case C.EDGE_RIGHT:
112
- return arr[2];
113
- case C.EDGE_BOTTOM:
114
- return arr[3];
115
- case C.EDGE_START:
116
- return arr[4];
117
- case C.EDGE_END:
118
- return arr[5];
119
- default:
120
- return arr[0]; // Default to left
121
- }
122
- }
123
- /**
124
- * Get a border value from an edge array.
125
- */
126
- export function getEdgeBorderValue(arr, edge) {
127
- switch (edge) {
128
- case C.EDGE_LEFT:
129
- return arr[0];
130
- case C.EDGE_TOP:
131
- return arr[1];
132
- case C.EDGE_RIGHT:
133
- return arr[2];
134
- case C.EDGE_BOTTOM:
135
- return arr[3];
136
- case C.EDGE_START:
137
- return arr[4];
138
- case C.EDGE_END:
139
- return arr[5];
140
- default:
141
- return arr[0]; // Default to left
142
- }
143
- }
144
- /**
145
- * Resolve a value (point or percent) to an absolute number.
146
- */
147
- export function resolveValue(value, availableSize) {
148
- switch (value.unit) {
149
- case C.UNIT_POINT:
150
- return value.value;
151
- case C.UNIT_PERCENT:
152
- // Percentage against NaN (auto-sized parent) resolves to 0
153
- if (Number.isNaN(availableSize)) {
154
- return 0;
155
- }
156
- return availableSize * (value.value / 100);
157
- default:
158
- return 0;
159
- }
160
- }
161
- /**
162
- * Apply min/max constraints to a size.
163
- *
164
- * When size is NaN (auto-sized), min constraints establish a floor.
165
- * This handles the case where a parent has minWidth/maxWidth but no explicit width -
166
- * children need to resolve percentages against the constrained size.
167
- */
168
- export function applyMinMax(size, min, max, available) {
169
- let result = size;
170
- if (min.unit !== C.UNIT_UNDEFINED) {
171
- const minValue = resolveValue(min, available);
172
- // Only apply if minValue is valid (not NaN from percent with NaN available)
173
- if (!Number.isNaN(minValue)) {
174
- // When size is NaN (auto-sized), min establishes the floor
175
- if (Number.isNaN(result)) {
176
- result = minValue;
177
- }
178
- else {
179
- result = Math.max(result, minValue);
180
- }
181
- }
182
- }
183
- if (max.unit !== C.UNIT_UNDEFINED) {
184
- const maxValue = resolveValue(max, available);
185
- // Only apply if maxValue is valid (not NaN from percent with NaN available)
186
- if (!Number.isNaN(maxValue)) {
187
- // When size is NaN (auto-sized), max alone doesn't set the size
188
- // (the element should shrink-wrap to content, then be capped by max)
189
- // Only apply max if we have a concrete size to constrain
190
- if (!Number.isNaN(result)) {
191
- result = Math.min(result, maxValue);
192
- }
193
- }
194
- }
195
- return result;
196
- }
197
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAA;AAGnC,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,wEAAwE;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAc,EAAE,CAAA;AAE3C;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,GAA+C,EAC/C,IAAY,EACZ,KAAa,EACb,IAAY;IAEZ,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAA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AC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,10 +0,0 @@
1
- // Optional dependency - resolved via km monorepo workspace, falls back at runtime
2
- declare module "loggily" {
3
- export function createLogger(namespace: string): {
4
- debug?: (msg: string) => void
5
- info?: (msg: string) => void
6
- warn?: (msg: string) => void
7
- error?: (msg: string | Error) => void
8
- trace?: (msg: string) => void
9
- }
10
- }