flexily 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. package/README.md +14 -16
  2. package/dist/classic/layout.d.ts.map +1 -1
  3. package/dist/classic/layout.js +10 -1
  4. package/dist/classic/layout.js.map +1 -1
  5. package/dist/classic/node.js +1 -1
  6. package/dist/constants.d.ts +1 -0
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/constants.js +2 -1
  9. package/dist/constants.js.map +1 -1
  10. package/dist/index-classic.d.ts +1 -1
  11. package/dist/index-classic.d.ts.map +1 -1
  12. package/dist/index-classic.js +5 -5
  13. package/dist/index-classic.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/layout-helpers.d.ts +1 -4
  19. package/dist/layout-helpers.d.ts.map +1 -1
  20. package/dist/layout-helpers.js +2 -7
  21. package/dist/layout-helpers.js.map +1 -1
  22. package/dist/layout-zero.js +195 -39
  23. package/dist/layout-zero.js.map +1 -1
  24. package/dist/logger.js +2 -2
  25. package/dist/logger.js.map +1 -1
  26. package/dist/node-zero.js +1 -1
  27. package/dist/testing.js +4 -4
  28. package/dist/trace.js +1 -1
  29. package/dist/types.js +2 -2
  30. package/dist/types.js.map +1 -1
  31. package/dist/utils.d.ts +11 -3
  32. package/dist/utils.d.ts.map +1 -1
  33. package/dist/utils.js +46 -21
  34. package/dist/utils.js.map +1 -1
  35. package/package.json +11 -3
  36. package/src/CLAUDE.md +36 -21
  37. package/src/classic/layout.ts +105 -45
  38. package/src/classic/node.ts +60 -0
  39. package/src/constants.ts +2 -1
  40. package/src/index-classic.ts +1 -1
  41. package/src/index.ts +1 -1
  42. package/src/layout-flex-lines.ts +70 -3
  43. package/src/layout-helpers.ts +27 -7
  44. package/src/layout-stats.ts +0 -2
  45. package/src/layout-zero.ts +587 -160
  46. package/src/node-zero.ts +98 -2
  47. package/src/testing.ts +20 -14
  48. package/src/types.ts +22 -15
  49. package/src/utils.ts +47 -21
@@ -9,13 +9,8 @@ import * as C from "./constants.js"
9
9
  import type { Value } from "./types.js"
10
10
  import { resolveValue } from "./utils.js"
11
11
 
12
- // ============================================================================
13
- // Constants for Edge Indices (avoid magic numbers)
14
- // ============================================================================
15
- export const EDGE_LEFT = 0
16
- export const EDGE_TOP = 1
17
- export const EDGE_RIGHT = 2
18
- export const EDGE_BOTTOM = 3
12
+ // Re-export edge constants (canonical definitions in constants.ts)
13
+ export { EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM } from "./constants.js"
19
14
 
20
15
  // ============================================================================
21
16
  // Helper Functions
@@ -119,6 +114,31 @@ export function isEdgeAuto(
119
114
  * - LTR: START->left, END->right
120
115
  * - RTL: START->right, END->left
121
116
  */
117
+ /**
118
+ * Resolve logical (START/END) position edges to physical values.
119
+ * Returns the resolved Value for a physical position index, considering
120
+ * logical EDGE_START/EDGE_END. Logical takes precedence over physical.
121
+ *
122
+ * EDGE_START/EDGE_END always resolve along the inline (horizontal) axis:
123
+ * - LTR: START->left, END->right
124
+ * - RTL: START->right, END->left
125
+ */
126
+ export function resolvePositionEdge(
127
+ arr: [Value, Value, Value, Value, Value, Value],
128
+ physicalIndex: number, // 0=left, 1=top, 2=right, 3=bottom
129
+ direction: number = C.DIRECTION_LTR,
130
+ ): Value {
131
+ const logicalValue = getLogicalEdgeValue(arr, physicalIndex, 0 /* unused */, direction)
132
+
133
+ // Logical takes precedence if defined
134
+ if (logicalValue && logicalValue.unit !== C.UNIT_UNDEFINED) {
135
+ return logicalValue
136
+ }
137
+
138
+ // Fall back to physical
139
+ return arr[physicalIndex]!
140
+ }
141
+
122
142
  export function resolveEdgeBorderValue(
123
143
  arr: [number, number, number, number, number, number],
124
144
  physicalIndex: number, // 0=left, 1=top, 2=right, 3=bottom
@@ -8,7 +8,6 @@
8
8
  // Layout statistics for debugging
9
9
  export let layoutNodeCalls = 0
10
10
  export let measureNodeCalls = 0
11
- export let resolveEdgeCalls = 0
12
11
  export let layoutSizingCalls = 0 // Calls for intrinsic sizing (offset=0,0)
13
12
  export let layoutPositioningCalls = 0 // Calls for final positioning
14
13
  export let layoutCacheHits = 0
@@ -16,7 +15,6 @@ export let layoutCacheHits = 0
16
15
  export function resetLayoutStats(): void {
17
16
  layoutNodeCalls = 0
18
17
  measureNodeCalls = 0
19
- resolveEdgeCalls = 0
20
18
  layoutSizingCalls = 0
21
19
  layoutPositioningCalls = 0
22
20
  layoutCacheHits = 0