elit 3.4.7 → 3.4.9
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/README.md +4 -0
- package/dist/cli.js +5396 -5221
- package/dist/index.js +5722 -5603
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5722 -5603
- package/dist/index.mjs.map +1 -1
- package/dist/mobile-cli.d.ts +1 -0
- package/dist/mobile-cli.d.ts.map +1 -1
- package/dist/native-background.d.ts +18 -0
- package/dist/native-background.d.ts.map +1 -0
- package/dist/native-border.d.ts +7 -0
- package/dist/native-border.d.ts.map +1 -0
- package/dist/native-canvas.d.ts +14 -0
- package/dist/native-canvas.d.ts.map +1 -0
- package/dist/native-color.d.ts +62 -0
- package/dist/native-color.d.ts.map +1 -0
- package/dist/native-estimation.d.ts +7 -0
- package/dist/native-estimation.d.ts.map +1 -0
- package/dist/native-grid.d.ts +33 -0
- package/dist/native-grid.d.ts.map +1 -0
- package/dist/native-interaction.d.ts +74 -0
- package/dist/native-interaction.d.ts.map +1 -0
- package/dist/native-layout.d.ts +36 -0
- package/dist/native-layout.d.ts.map +1 -0
- package/dist/native-link.d.ts +8 -0
- package/dist/native-link.d.ts.map +1 -0
- package/dist/native-render-support.d.ts +23 -0
- package/dist/native-render-support.d.ts.map +1 -0
- package/dist/native-spacing.d.ts +16 -0
- package/dist/native-spacing.d.ts.map +1 -0
- package/dist/native-state.d.ts +25 -0
- package/dist/native-state.d.ts.map +1 -0
- package/dist/native-strings.d.ts +7 -0
- package/dist/native-strings.d.ts.map +1 -0
- package/dist/native-transform.d.ts +12 -0
- package/dist/native-transform.d.ts.map +1 -0
- package/dist/native-types.d.ts +396 -0
- package/dist/native-types.d.ts.map +1 -0
- package/dist/native-typography.d.ts +21 -0
- package/dist/native-typography.d.ts.map +1 -0
- package/dist/native-units.d.ts +28 -0
- package/dist/native-units.d.ts.map +1 -0
- package/dist/native-vector.d.ts +33 -0
- package/dist/native-vector.d.ts.map +1 -0
- package/dist/native.d.mts +1 -0
- package/dist/native.d.ts +2 -120
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +5722 -5603
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +5722 -5603
- package/dist/native.mjs.map +1 -1
- package/package.json +1 -1
- package/src/desktop/native_renderer/action_widgets.rs +184 -0
- package/src/desktop/native_renderer/app_models.rs +171 -0
- package/src/desktop/native_renderer/app_runtime.rs +140 -0
- package/src/desktop/native_renderer/container_rendering.rs +610 -0
- package/src/desktop/native_renderer/content_widgets.rs +634 -0
- package/src/desktop/native_renderer/css_models.rs +371 -0
- package/src/desktop/native_renderer/embedded_surfaces.rs +414 -0
- package/src/desktop/native_renderer/form_controls.rs +516 -0
- package/src/desktop/native_renderer/interaction_dispatch.rs +89 -0
- package/src/desktop/native_renderer/runtime_support.rs +135 -0
- package/src/desktop/native_renderer/utilities.rs +495 -0
- package/src/desktop/native_renderer/vector_drawing.rs +491 -0
- package/src/desktop/native_renderer.rs +2449 -6530
- package/src/mobile-cli.ts +103 -8
- package/src/native-background.ts +444 -0
- package/src/native-border.ts +343 -0
- package/src/native-canvas.ts +260 -0
- package/src/native-color.ts +904 -0
- package/src/native-estimation.ts +194 -0
- package/src/native-grid.ts +590 -0
- package/src/native-interaction.ts +1289 -0
- package/src/native-layout.ts +568 -0
- package/src/native-link.ts +76 -0
- package/src/native-render-support.ts +361 -0
- package/src/native-spacing.ts +231 -0
- package/src/native-state.ts +318 -0
- package/src/native-strings.ts +46 -0
- package/src/native-transform.ts +120 -0
- package/src/native-types.ts +439 -0
- package/src/native-typography.ts +254 -0
- package/src/native-units.ts +441 -0
- package/src/native-vector.ts +910 -0
- package/src/native.ts +1711 -9103
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { type NativeStyleResolveOptions } from './style';
|
|
2
|
+
import type { NativeNode, NativePropValue } from './native-types';
|
|
3
|
+
import { isFillValue, parseBoxShadowList, resolveBackdropBlurRadius, resolveStyleCurrentColor } from './native-color';
|
|
4
|
+
import { parseCssUnitValue, resolveAxisUnitNumber, toDpLiteral, toScaledUnitNumber, getNativeStyleResolveOptions } from './native-units';
|
|
5
|
+
import { flattenTextContent } from './native-strings';
|
|
6
|
+
import { estimateHorizontalPadding, estimateVerticalPadding } from './native-spacing';
|
|
7
|
+
import { resolveNativeBackgroundLayersFromStyle } from './native-background';
|
|
8
|
+
import { resolveNativeBorder } from './native-border';
|
|
9
|
+
|
|
10
|
+
const INLINE_DISPLAY_VALUES = new Set(['inline', 'inline-block', 'inline-flex', 'inline-grid']);
|
|
11
|
+
const DEFAULT_BLOCK_FILL_SOURCE_TAGS = new Set([
|
|
12
|
+
'html',
|
|
13
|
+
'body',
|
|
14
|
+
'main',
|
|
15
|
+
'header',
|
|
16
|
+
'footer',
|
|
17
|
+
'nav',
|
|
18
|
+
'section',
|
|
19
|
+
'article',
|
|
20
|
+
'aside',
|
|
21
|
+
'div',
|
|
22
|
+
'form',
|
|
23
|
+
'fieldset',
|
|
24
|
+
'figure',
|
|
25
|
+
'details',
|
|
26
|
+
'dialog',
|
|
27
|
+
'menu',
|
|
28
|
+
'ul',
|
|
29
|
+
'ol',
|
|
30
|
+
'li',
|
|
31
|
+
'table',
|
|
32
|
+
'tbody',
|
|
33
|
+
'thead',
|
|
34
|
+
'tfoot',
|
|
35
|
+
'tr',
|
|
36
|
+
]);
|
|
37
|
+
const FILL_WIDTH_EXCLUDED_COMPONENTS = new Set(['Text', 'Button', 'Link', 'Toggle', 'TextInput', 'Image', 'Media', 'WebView', 'Canvas', 'Vector', 'Math']);
|
|
38
|
+
|
|
39
|
+
export function shouldFillChunkedCellChild(node: NativeNode): boolean {
|
|
40
|
+
if (node.kind !== 'element') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return !FILL_WIDTH_EXCLUDED_COMPONENTS.has(node.component);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function hasNativeContainerSpacing(
|
|
48
|
+
style: Record<string, NativePropValue>,
|
|
49
|
+
styleResolveOptions: NativeStyleResolveOptions = getNativeStyleResolveOptions('generic'),
|
|
50
|
+
): boolean {
|
|
51
|
+
return [
|
|
52
|
+
style.padding,
|
|
53
|
+
style.paddingHorizontal,
|
|
54
|
+
style.paddingVertical,
|
|
55
|
+
style.paddingTop,
|
|
56
|
+
style.paddingRight,
|
|
57
|
+
style.paddingBottom,
|
|
58
|
+
style.paddingLeft,
|
|
59
|
+
style.paddingStart,
|
|
60
|
+
style.paddingEnd,
|
|
61
|
+
style.gap,
|
|
62
|
+
style.rowGap,
|
|
63
|
+
style.columnGap,
|
|
64
|
+
].some((value) => toScaledUnitNumber(value, styleResolveOptions) !== undefined);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function hasNativeContainerDecoration(
|
|
68
|
+
style: Record<string, NativePropValue>,
|
|
69
|
+
styleResolveOptions: NativeStyleResolveOptions = getNativeStyleResolveOptions('generic'),
|
|
70
|
+
): boolean {
|
|
71
|
+
return resolveNativeBackgroundLayersFromStyle(style, styleResolveOptions).length > 0
|
|
72
|
+
|| resolveBackdropBlurRadius(style, styleResolveOptions) !== undefined
|
|
73
|
+
|| resolveNativeBorder(style, (value) => toDpLiteral(value, styleResolveOptions)) !== undefined
|
|
74
|
+
|| parseBoxShadowList(style.boxShadow, resolveStyleCurrentColor(style)).length > 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function shouldDefaultFillWidthHint(
|
|
78
|
+
node: NativeNode,
|
|
79
|
+
style: Record<string, NativePropValue> | undefined,
|
|
80
|
+
styleResolveOptions: NativeStyleResolveOptions = getNativeStyleResolveOptions('generic'),
|
|
81
|
+
): boolean {
|
|
82
|
+
if (node.kind !== 'element' || !shouldFillChunkedCellChild(node)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const display = typeof style?.display === 'string'
|
|
87
|
+
? style.display.trim().toLowerCase()
|
|
88
|
+
: undefined;
|
|
89
|
+
|
|
90
|
+
if (display && INLINE_DISPLAY_VALUES.has(display)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (display === 'flex' || display === 'grid' || typeof style?.flexDirection === 'string') {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (style && (hasNativeContainerSpacing(style, styleResolveOptions) || hasNativeContainerDecoration(style, styleResolveOptions))) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return DEFAULT_BLOCK_FILL_SOURCE_TAGS.has(node.sourceTag);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function estimateNodePreferredWidth(
|
|
106
|
+
node: NativeNode,
|
|
107
|
+
style: Record<string, NativePropValue> | undefined,
|
|
108
|
+
styleResolveOptions: NativeStyleResolveOptions,
|
|
109
|
+
): number {
|
|
110
|
+
if (node.kind === 'text') {
|
|
111
|
+
return Math.max(48, node.value.trim().length * 8);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (style?.width && isFillValue(style.width)) {
|
|
115
|
+
return styleResolveOptions.viewportWidth ?? 390;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const explicitWidth = resolveAxisUnitNumber(style?.width ?? style?.minWidth, 'horizontal', undefined, styleResolveOptions);
|
|
119
|
+
if (explicitWidth !== undefined && explicitWidth > 0) {
|
|
120
|
+
return explicitWidth;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const fontSize = toScaledUnitNumber(style?.fontSize, styleResolveOptions) ?? 16;
|
|
124
|
+
const text = flattenTextContent(node.children)
|
|
125
|
+
|| (typeof node.props.placeholder === 'string' ? node.props.placeholder : '');
|
|
126
|
+
let baseWidth = text
|
|
127
|
+
? Math.max(56, text.length * fontSize * (node.component === 'Button' || node.component === 'Link' ? 0.58 : 0.52))
|
|
128
|
+
: 0;
|
|
129
|
+
|
|
130
|
+
switch (node.component) {
|
|
131
|
+
case 'Button':
|
|
132
|
+
case 'Link':
|
|
133
|
+
baseWidth = Math.max(baseWidth, 120);
|
|
134
|
+
break;
|
|
135
|
+
case 'TextInput':
|
|
136
|
+
baseWidth = Math.max(baseWidth, 220);
|
|
137
|
+
break;
|
|
138
|
+
case 'Toggle':
|
|
139
|
+
baseWidth = Math.max(baseWidth, 56);
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
baseWidth = Math.max(baseWidth, 160);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return baseWidth + estimateHorizontalPadding(style, styleResolveOptions);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function estimateNodePreferredHeight(
|
|
150
|
+
node: NativeNode,
|
|
151
|
+
style: Record<string, NativePropValue> | undefined,
|
|
152
|
+
styleResolveOptions: NativeStyleResolveOptions,
|
|
153
|
+
): number | undefined {
|
|
154
|
+
if (node.kind === 'text') {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (style?.height && isFillValue(style.height)) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const explicitHeight = resolveAxisUnitNumber(style?.height ?? style?.minHeight, 'vertical', undefined, styleResolveOptions);
|
|
163
|
+
if (explicitHeight !== undefined && explicitHeight > 0) {
|
|
164
|
+
return explicitHeight;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const fontSize = toScaledUnitNumber(style?.fontSize, styleResolveOptions) ?? 16;
|
|
168
|
+
const lineHeightValue = parseCssUnitValue(style?.lineHeight);
|
|
169
|
+
const lineHeight = lineHeightValue?.unit === '' && lineHeightValue.value > 0 && lineHeightValue.value <= 4
|
|
170
|
+
? fontSize * lineHeightValue.value
|
|
171
|
+
: toScaledUnitNumber(style?.lineHeight, styleResolveOptions) ?? (fontSize * 1.2);
|
|
172
|
+
const text = flattenTextContent(node.children)
|
|
173
|
+
|| (typeof node.props.placeholder === 'string' ? node.props.placeholder : '');
|
|
174
|
+
const lineCount = text ? text.split(/\r?\n/).length : 0;
|
|
175
|
+
let baseHeight = lineCount > 0 ? lineHeight * lineCount : 0;
|
|
176
|
+
|
|
177
|
+
switch (node.component) {
|
|
178
|
+
case 'Button':
|
|
179
|
+
case 'Link':
|
|
180
|
+
baseHeight = Math.max(baseHeight, 40);
|
|
181
|
+
break;
|
|
182
|
+
case 'TextInput':
|
|
183
|
+
baseHeight = Math.max(baseHeight, 44);
|
|
184
|
+
break;
|
|
185
|
+
case 'Toggle':
|
|
186
|
+
baseHeight = Math.max(baseHeight, 32);
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
baseHeight = Math.max(baseHeight, 24);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return baseHeight + estimateVerticalPadding(style, styleResolveOptions);
|
|
194
|
+
}
|