forked from ultraworkers/claw-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.ts
More file actions
152 lines (136 loc) · 4.24 KB
/
node.ts
File metadata and controls
152 lines (136 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// --
// Adapter interface for the layout engine (Yoga)
export const LayoutEdge = {
All: 'all',
Horizontal: 'horizontal',
Vertical: 'vertical',
Left: 'left',
Right: 'right',
Top: 'top',
Bottom: 'bottom',
Start: 'start',
End: 'end',
} as const
export type LayoutEdge = (typeof LayoutEdge)[keyof typeof LayoutEdge]
export const LayoutGutter = {
All: 'all',
Column: 'column',
Row: 'row',
} as const
export type LayoutGutter = (typeof LayoutGutter)[keyof typeof LayoutGutter]
export const LayoutDisplay = {
Flex: 'flex',
None: 'none',
} as const
export type LayoutDisplay = (typeof LayoutDisplay)[keyof typeof LayoutDisplay]
export const LayoutFlexDirection = {
Row: 'row',
RowReverse: 'row-reverse',
Column: 'column',
ColumnReverse: 'column-reverse',
} as const
export type LayoutFlexDirection =
(typeof LayoutFlexDirection)[keyof typeof LayoutFlexDirection]
export const LayoutAlign = {
Auto: 'auto',
Stretch: 'stretch',
FlexStart: 'flex-start',
Center: 'center',
FlexEnd: 'flex-end',
} as const
export type LayoutAlign = (typeof LayoutAlign)[keyof typeof LayoutAlign]
export const LayoutJustify = {
FlexStart: 'flex-start',
Center: 'center',
FlexEnd: 'flex-end',
SpaceBetween: 'space-between',
SpaceAround: 'space-around',
SpaceEvenly: 'space-evenly',
} as const
export type LayoutJustify = (typeof LayoutJustify)[keyof typeof LayoutJustify]
export const LayoutWrap = {
NoWrap: 'nowrap',
Wrap: 'wrap',
WrapReverse: 'wrap-reverse',
} as const
export type LayoutWrap = (typeof LayoutWrap)[keyof typeof LayoutWrap]
export const LayoutPositionType = {
Relative: 'relative',
Absolute: 'absolute',
} as const
export type LayoutPositionType =
(typeof LayoutPositionType)[keyof typeof LayoutPositionType]
export const LayoutOverflow = {
Visible: 'visible',
Hidden: 'hidden',
Scroll: 'scroll',
} as const
export type LayoutOverflow =
(typeof LayoutOverflow)[keyof typeof LayoutOverflow]
export type LayoutMeasureFunc = (
width: number,
widthMode: LayoutMeasureMode,
) => { width: number; height: number }
export const LayoutMeasureMode = {
Undefined: 'undefined',
Exactly: 'exactly',
AtMost: 'at-most',
} as const
export type LayoutMeasureMode =
(typeof LayoutMeasureMode)[keyof typeof LayoutMeasureMode]
export type LayoutNode = {
// Tree
insertChild(child: LayoutNode, index: number): void
removeChild(child: LayoutNode): void
getChildCount(): number
getParent(): LayoutNode | null
// Layout computation
calculateLayout(width?: number, height?: number): void
setMeasureFunc(fn: LayoutMeasureFunc): void
unsetMeasureFunc(): void
markDirty(): void
// Layout reading (post-layout)
getComputedLeft(): number
getComputedTop(): number
getComputedWidth(): number
getComputedHeight(): number
getComputedBorder(edge: LayoutEdge): number
getComputedPadding(edge: LayoutEdge): number
// Style setters
setWidth(value: number): void
setWidthPercent(value: number): void
setWidthAuto(): void
setHeight(value: number): void
setHeightPercent(value: number): void
setHeightAuto(): void
setMinWidth(value: number): void
setMinWidthPercent(value: number): void
setMinHeight(value: number): void
setMinHeightPercent(value: number): void
setMaxWidth(value: number): void
setMaxWidthPercent(value: number): void
setMaxHeight(value: number): void
setMaxHeightPercent(value: number): void
setFlexDirection(dir: LayoutFlexDirection): void
setFlexGrow(value: number): void
setFlexShrink(value: number): void
setFlexBasis(value: number): void
setFlexBasisPercent(value: number): void
setFlexWrap(wrap: LayoutWrap): void
setAlignItems(align: LayoutAlign): void
setAlignSelf(align: LayoutAlign): void
setJustifyContent(justify: LayoutJustify): void
setDisplay(display: LayoutDisplay): void
getDisplay(): LayoutDisplay
setPositionType(type: LayoutPositionType): void
setPosition(edge: LayoutEdge, value: number): void
setPositionPercent(edge: LayoutEdge, value: number): void
setOverflow(overflow: LayoutOverflow): void
setMargin(edge: LayoutEdge, value: number): void
setPadding(edge: LayoutEdge, value: number): void
setBorder(edge: LayoutEdge, value: number): void
setGap(gutter: LayoutGutter, value: number): void
// Lifecycle
free(): void
freeRecursive(): void
}