elit 3.5.6 → 3.5.7
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/Cargo.toml +1 -1
- package/README.md +1 -1
- package/desktop/build.rs +83 -0
- package/desktop/icon.rs +106 -0
- package/desktop/lib.rs +2 -0
- package/desktop/main.rs +235 -0
- package/desktop/native_main.rs +128 -0
- package/desktop/native_renderer/action_widgets.rs +184 -0
- package/desktop/native_renderer/app_models.rs +171 -0
- package/desktop/native_renderer/app_runtime.rs +140 -0
- package/desktop/native_renderer/container_rendering.rs +610 -0
- package/desktop/native_renderer/content_widgets.rs +634 -0
- package/desktop/native_renderer/css_models.rs +371 -0
- package/desktop/native_renderer/embedded_surfaces.rs +414 -0
- package/desktop/native_renderer/form_controls.rs +516 -0
- package/desktop/native_renderer/interaction_dispatch.rs +89 -0
- package/desktop/native_renderer/runtime_support.rs +135 -0
- package/desktop/native_renderer/utilities.rs +495 -0
- package/desktop/native_renderer/vector_drawing.rs +491 -0
- package/desktop/native_renderer.rs +4122 -0
- package/desktop/runtime/external.rs +422 -0
- package/desktop/runtime/mod.rs +67 -0
- package/desktop/runtime/quickjs.rs +106 -0
- package/desktop/window.rs +383 -0
- package/package.json +6 -3
- package/dist/build.d.mts +0 -20
- package/dist/chokidar.d.mts +0 -134
- package/dist/cli.d.mts +0 -81
- package/dist/config.d.mts +0 -254
- package/dist/coverage.d.mts +0 -85
- package/dist/database.d.mts +0 -52
- package/dist/desktop.d.mts +0 -68
- package/dist/dom.d.mts +0 -87
- package/dist/el.d.mts +0 -208
- package/dist/fs.d.mts +0 -255
- package/dist/hmr.d.mts +0 -38
- package/dist/http.d.mts +0 -169
- package/dist/https.d.mts +0 -108
- package/dist/index.d.mts +0 -13
- package/dist/mime-types.d.mts +0 -48
- package/dist/native.d.mts +0 -136
- package/dist/path.d.mts +0 -163
- package/dist/router.d.mts +0 -49
- package/dist/runtime.d.mts +0 -97
- package/dist/server-D0Dp4R5z.d.mts +0 -449
- package/dist/server.d.mts +0 -7
- package/dist/state.d.mts +0 -117
- package/dist/style.d.mts +0 -232
- package/dist/test-reporter.d.mts +0 -77
- package/dist/test-runtime.d.mts +0 -122
- package/dist/test.d.mts +0 -39
- package/dist/types.d.mts +0 -586
- package/dist/universal.d.mts +0 -21
- package/dist/ws.d.mts +0 -200
- package/dist/wss.d.mts +0 -108
- package/src/build.ts +0 -362
- package/src/chokidar.ts +0 -427
- package/src/cli.ts +0 -1162
- package/src/config.ts +0 -509
- package/src/coverage.ts +0 -1479
- package/src/database.ts +0 -1410
- package/src/desktop-auto-render.ts +0 -317
- package/src/desktop-cli.ts +0 -1533
- package/src/desktop.ts +0 -99
- package/src/dev-build.ts +0 -340
- package/src/dom.ts +0 -901
- package/src/el.ts +0 -183
- package/src/fs.ts +0 -609
- package/src/hmr.ts +0 -149
- package/src/http.ts +0 -856
- package/src/https.ts +0 -411
- package/src/index.ts +0 -16
- package/src/mime-types.ts +0 -222
- package/src/mobile-cli.ts +0 -2313
- package/src/native-background.ts +0 -444
- package/src/native-border.ts +0 -343
- package/src/native-canvas.ts +0 -260
- package/src/native-cli.ts +0 -414
- package/src/native-color.ts +0 -904
- package/src/native-estimation.ts +0 -194
- package/src/native-grid.ts +0 -590
- package/src/native-interaction.ts +0 -1289
- package/src/native-layout.ts +0 -568
- package/src/native-link.ts +0 -76
- package/src/native-render-support.ts +0 -361
- package/src/native-spacing.ts +0 -231
- package/src/native-state.ts +0 -318
- package/src/native-strings.ts +0 -46
- package/src/native-transform.ts +0 -120
- package/src/native-types.ts +0 -439
- package/src/native-typography.ts +0 -254
- package/src/native-units.ts +0 -441
- package/src/native-vector.ts +0 -910
- package/src/native.ts +0 -5606
- package/src/path.ts +0 -493
- package/src/pm-cli.ts +0 -2498
- package/src/preview-build.ts +0 -294
- package/src/render-context.ts +0 -138
- package/src/router.ts +0 -260
- package/src/runtime.ts +0 -97
- package/src/server.ts +0 -2294
- package/src/state.ts +0 -556
- package/src/style.ts +0 -1790
- package/src/test-globals.d.ts +0 -184
- package/src/test-reporter.ts +0 -609
- package/src/test-runtime.ts +0 -1359
- package/src/test.ts +0 -368
- package/src/types.ts +0 -381
- package/src/universal.ts +0 -81
- package/src/wapk-cli.ts +0 -3213
- package/src/workspace-package.ts +0 -102
- package/src/ws.ts +0 -648
- package/src/wss.ts +0 -241
package/src/native-grid.ts
DELETED
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
import { type NativeStyleResolveOptions } from './style';
|
|
2
|
-
import type {
|
|
3
|
-
NativeElementNode,
|
|
4
|
-
NativeGridColumnTrackSizeSpec,
|
|
5
|
-
NativeGridTemplateAreaPlacement,
|
|
6
|
-
NativeGridTrackDefinition,
|
|
7
|
-
NativeGridTrackSizeSpec,
|
|
8
|
-
NativePropValue,
|
|
9
|
-
} from './native-types';
|
|
10
|
-
import { toScaledUnitNumber } from './native-units';
|
|
11
|
-
|
|
12
|
-
export function createNativeGridPlaceholderNode(): NativeElementNode {
|
|
13
|
-
return {
|
|
14
|
-
kind: 'element',
|
|
15
|
-
component: 'View',
|
|
16
|
-
sourceTag: 'div',
|
|
17
|
-
props: {},
|
|
18
|
-
events: [],
|
|
19
|
-
children: [],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function splitCssTrackList(value: string): string[] {
|
|
24
|
-
const tracks: string[] = [];
|
|
25
|
-
let token = '';
|
|
26
|
-
let functionDepth = 0;
|
|
27
|
-
let bracketDepth = 0;
|
|
28
|
-
|
|
29
|
-
for (const char of value.trim()) {
|
|
30
|
-
if (char === '(') {
|
|
31
|
-
functionDepth += 1;
|
|
32
|
-
} else if (char === ')' && functionDepth > 0) {
|
|
33
|
-
functionDepth -= 1;
|
|
34
|
-
} else if (char === '[') {
|
|
35
|
-
bracketDepth += 1;
|
|
36
|
-
} else if (char === ']' && bracketDepth > 0) {
|
|
37
|
-
bracketDepth -= 1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (/\s/.test(char) && functionDepth === 0 && bracketDepth === 0) {
|
|
41
|
-
const trimmed = token.trim();
|
|
42
|
-
if (trimmed) {
|
|
43
|
-
tracks.push(trimmed);
|
|
44
|
-
token = '';
|
|
45
|
-
}
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
token += char;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const trailing = token.trim();
|
|
53
|
-
if (trailing) {
|
|
54
|
-
tracks.push(trailing);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return tracks;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function extractNativeGridLineNames(token: string): string[] | undefined {
|
|
61
|
-
const trimmed = token.trim();
|
|
62
|
-
if (!trimmed.startsWith('[') || !trimmed.endsWith(']')) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const names = trimmed.slice(1, -1).trim().split(/\s+/).filter(Boolean);
|
|
67
|
-
return names.length > 0 ? names : undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function expandRepeatTrackList(value: string): string[] | undefined {
|
|
71
|
-
const trimmed = value.trim();
|
|
72
|
-
if (!trimmed.endsWith(')') || !trimmed.toLowerCase().startsWith('repeat(')) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const commaIdx = trimmed.indexOf(',', 'repeat('.length);
|
|
77
|
-
if (commaIdx < 0) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const countStr = trimmed.slice('repeat('.length, commaIdx).trim();
|
|
82
|
-
if (!/^\d+$/.test(countStr)) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const count = Number(countStr);
|
|
87
|
-
if (!Number.isFinite(count) || count <= 0) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const inner = trimmed.slice(commaIdx + 1, -1).trim();
|
|
92
|
-
if (!inner) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const innerTracks = splitCssTrackList(inner);
|
|
97
|
-
if (innerTracks.length === 0) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return Array.from({ length: count }, () => innerTracks).flat();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function parseFractionTrackWeight(track: string): number | undefined {
|
|
105
|
-
const directMatch = track.trim().match(/^(-?\d+(?:\.\d+)?)fr$/i);
|
|
106
|
-
if (directMatch) {
|
|
107
|
-
return Number(directMatch[1]);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const minmaxMatch = track.trim().match(/^minmax\([^,()]*,\s*(-?\d+(?:\.\d+)?)fr\s*\)$/i);
|
|
111
|
-
return minmaxMatch ? Number(minmaxMatch[1]) : undefined;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function parseNativeGridTrackDefinition(value: string): NativeGridTrackDefinition | undefined {
|
|
115
|
-
const tokens = expandRepeatTrackList(value.trim()) ?? splitCssTrackList(value.trim());
|
|
116
|
-
if (tokens.length === 0) {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const tracks: string[] = [];
|
|
121
|
-
const lineNames = new Map<string, number[]>();
|
|
122
|
-
let lineIndex = 1;
|
|
123
|
-
|
|
124
|
-
for (const token of tokens) {
|
|
125
|
-
const names = extractNativeGridLineNames(token);
|
|
126
|
-
if (names) {
|
|
127
|
-
for (const name of names) {
|
|
128
|
-
const normalizedName = name.toLowerCase();
|
|
129
|
-
const existing = lineNames.get(normalizedName) ?? [];
|
|
130
|
-
existing.push(lineIndex);
|
|
131
|
-
lineNames.set(normalizedName, existing);
|
|
132
|
-
}
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
tracks.push(token);
|
|
137
|
-
lineIndex += 1;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return tracks.length > 0 ? { tracks, lineNames, lineCount: lineIndex } : undefined;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function parseGridTrackSizeSpec(
|
|
144
|
-
track: string,
|
|
145
|
-
styleResolveOptions: NativeStyleResolveOptions,
|
|
146
|
-
): NativeGridTrackSizeSpec | undefined {
|
|
147
|
-
const trimmed = track.trim();
|
|
148
|
-
if (!trimmed) {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const direct = toScaledUnitNumber(trimmed, styleResolveOptions);
|
|
153
|
-
if (direct !== undefined && direct >= 0) {
|
|
154
|
-
return { minHeight: direct, height: direct };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const normalized = trimmed.toLowerCase();
|
|
158
|
-
if (normalized === 'auto') {
|
|
159
|
-
return { stretchEligible: true };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (normalized === 'min-content' || normalized === 'max-content') {
|
|
163
|
-
return { intrinsicHeight: true };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const fitContentMatch = trimmed.match(/^fit-content\(([^()]+)\)$/i);
|
|
167
|
-
if (fitContentMatch) {
|
|
168
|
-
const fitContent = toScaledUnitNumber(fitContentMatch[1].trim(), styleResolveOptions);
|
|
169
|
-
return fitContent !== undefined && fitContent >= 0 ? { maxHeight: fitContent } : undefined;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const minmaxMatch = trimmed.match(/^minmax\(([^,()]+),([^,()]+)\)$/i);
|
|
173
|
-
if (minmaxMatch) {
|
|
174
|
-
const minToken = minmaxMatch[1].trim();
|
|
175
|
-
const maxToken = minmaxMatch[2].trim();
|
|
176
|
-
const normalizedMinToken = minToken.toLowerCase();
|
|
177
|
-
const normalizedMaxToken = maxToken.toLowerCase();
|
|
178
|
-
const minTrack = toScaledUnitNumber(minToken, styleResolveOptions);
|
|
179
|
-
const maxTrack = toScaledUnitNumber(maxToken, styleResolveOptions);
|
|
180
|
-
const trackWeight = parseFractionTrackWeight(trimmed);
|
|
181
|
-
const hasFixedTrack = minTrack !== undefined && maxTrack !== undefined && Math.abs(minTrack - maxTrack) < 0.001;
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
...(minTrack !== undefined && minTrack >= 0 ? { minHeight: minTrack } : {}),
|
|
185
|
-
...((normalizedMinToken === 'min-content' || normalizedMinToken === 'max-content') ? { intrinsicMinHeight: true } : {}),
|
|
186
|
-
...(hasFixedTrack && maxTrack !== undefined ? { height: maxTrack } : {}),
|
|
187
|
-
...(!hasFixedTrack && maxTrack !== undefined && maxTrack >= 0 ? { maxHeight: maxTrack } : {}),
|
|
188
|
-
...((normalizedMaxToken === 'min-content' || normalizedMaxToken === 'max-content') ? { intrinsicMaxHeight: true } : {}),
|
|
189
|
-
...(minTrack === undefined && maxTrack === undefined && minToken.toLowerCase() === 'auto' && maxToken.toLowerCase() === 'auto' && trackWeight === undefined ? { stretchEligible: true } : {}),
|
|
190
|
-
...(trackWeight !== undefined && Number.isFinite(trackWeight) && trackWeight > 0 ? { trackWeight } : {}),
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const directWeight = parseFractionTrackWeight(trimmed);
|
|
195
|
-
if (directWeight !== undefined && Number.isFinite(directWeight) && directWeight > 0) {
|
|
196
|
-
return { trackWeight: directWeight };
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function parseGridColumnTrackSizeSpec(
|
|
203
|
-
track: string,
|
|
204
|
-
styleResolveOptions: NativeStyleResolveOptions,
|
|
205
|
-
): NativeGridColumnTrackSizeSpec | undefined {
|
|
206
|
-
const trimmed = track.trim();
|
|
207
|
-
if (!trimmed) {
|
|
208
|
-
return undefined;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const direct = toScaledUnitNumber(trimmed, styleResolveOptions);
|
|
212
|
-
if (direct !== undefined && direct >= 0) {
|
|
213
|
-
return { minWidth: direct, width: direct };
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const normalized = trimmed.toLowerCase();
|
|
217
|
-
if (normalized === 'auto') {
|
|
218
|
-
return { trackWeight: 1 };
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (normalized === 'min-content' || normalized === 'max-content') {
|
|
222
|
-
return { intrinsicWidth: true };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const fitContentMatch = trimmed.match(/^fit-content\(([^()]+)\)$/i);
|
|
226
|
-
if (fitContentMatch) {
|
|
227
|
-
const fitContent = toScaledUnitNumber(fitContentMatch[1].trim(), styleResolveOptions);
|
|
228
|
-
return fitContent !== undefined && fitContent >= 0 ? { maxWidth: fitContent } : undefined;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const minmaxMatch = trimmed.match(/^minmax\(([^,()]+),([^,()]+)\)$/i);
|
|
232
|
-
if (minmaxMatch) {
|
|
233
|
-
const minToken = minmaxMatch[1].trim();
|
|
234
|
-
const maxToken = minmaxMatch[2].trim();
|
|
235
|
-
const normalizedMinToken = minToken.toLowerCase();
|
|
236
|
-
const normalizedMaxToken = maxToken.toLowerCase();
|
|
237
|
-
const minTrack = toScaledUnitNumber(minToken, styleResolveOptions);
|
|
238
|
-
const maxTrack = toScaledUnitNumber(maxToken, styleResolveOptions);
|
|
239
|
-
const trackWeight = parseFractionTrackWeight(trimmed);
|
|
240
|
-
const hasFixedTrack = minTrack !== undefined && maxTrack !== undefined && Math.abs(minTrack - maxTrack) < 0.001;
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
...(minTrack !== undefined && minTrack >= 0 ? { minWidth: minTrack } : {}),
|
|
244
|
-
...((normalizedMinToken === 'min-content' || normalizedMinToken === 'max-content') ? { intrinsicMinWidth: true } : {}),
|
|
245
|
-
...(hasFixedTrack && maxTrack !== undefined ? { width: maxTrack } : {}),
|
|
246
|
-
...(!hasFixedTrack && maxTrack !== undefined && maxTrack >= 0 ? { maxWidth: maxTrack } : {}),
|
|
247
|
-
...((normalizedMaxToken === 'min-content' || normalizedMaxToken === 'max-content') ? { intrinsicMaxWidth: true } : {}),
|
|
248
|
-
...(minTrack === undefined && maxTrack === undefined && normalizedMinToken === 'auto' && normalizedMaxToken === 'auto' && trackWeight === undefined ? { trackWeight: 1 } : {}),
|
|
249
|
-
...(trackWeight !== undefined && Number.isFinite(trackWeight) && trackWeight > 0 ? { trackWeight } : {}),
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const directWeight = parseFractionTrackWeight(trimmed);
|
|
254
|
-
if (directWeight !== undefined && Number.isFinite(directWeight) && directWeight > 0) {
|
|
255
|
-
return { trackWeight: directWeight };
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return { trackWeight: 1 };
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function resolveGridTrackSizeSpecs(
|
|
262
|
-
value: NativePropValue | undefined,
|
|
263
|
-
styleResolveOptions: NativeStyleResolveOptions,
|
|
264
|
-
): Array<NativeGridTrackSizeSpec | undefined> | undefined {
|
|
265
|
-
if (typeof value !== 'string') {
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const tracks = parseNativeGridTrackDefinition(value.trim())?.tracks ?? [];
|
|
270
|
-
if (tracks.length === 0) {
|
|
271
|
-
return undefined;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return tracks.map((track) => parseGridTrackSizeSpec(track, styleResolveOptions));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export function resolveGridColumnTrackSizeSpecs(
|
|
278
|
-
value: NativePropValue | undefined,
|
|
279
|
-
styleResolveOptions: NativeStyleResolveOptions,
|
|
280
|
-
columnGap: number,
|
|
281
|
-
): Array<NativeGridColumnTrackSizeSpec | undefined> | undefined {
|
|
282
|
-
if (typeof value !== 'string') {
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const trimmed = value.trim();
|
|
287
|
-
const viewportWidth = styleResolveOptions.viewportWidth ?? 390;
|
|
288
|
-
const autoRepeatMatch = trimmed.match(/^repeat\(\s*auto-(?:fit|fill)\s*,\s*(minmax\([^,()]+,[^,()]+\))\s*\)$/i);
|
|
289
|
-
if (autoRepeatMatch) {
|
|
290
|
-
const repeatedSpec = parseGridColumnTrackSizeSpec(autoRepeatMatch[1].trim(), styleResolveOptions);
|
|
291
|
-
const minWidth = repeatedSpec?.width ?? repeatedSpec?.minWidth;
|
|
292
|
-
if (minWidth === undefined || minWidth <= 0) {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const columnCount = Math.max(1, Math.floor((viewportWidth + columnGap) / (minWidth + columnGap)));
|
|
297
|
-
return Array.from({ length: columnCount }, () => repeatedSpec ? { ...repeatedSpec } : { trackWeight: 1 });
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const tracks = parseNativeGridTrackDefinition(trimmed)?.tracks ?? [];
|
|
301
|
-
if (tracks.length === 0) {
|
|
302
|
-
return undefined;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return tracks.map((track) => parseGridColumnTrackSizeSpec(track, styleResolveOptions));
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export function isWrapEnabled(style: Record<string, NativePropValue> | undefined): boolean {
|
|
309
|
-
if (!style || typeof style.flexWrap !== 'string') {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const flexWrap = style.flexWrap.trim().toLowerCase();
|
|
314
|
-
return flexWrap === 'wrap' || flexWrap === 'wrap-reverse';
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export function isRowFlexLayout(style: Record<string, NativePropValue> | undefined): boolean {
|
|
318
|
-
if (!style) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (typeof style.flexDirection === 'string') {
|
|
323
|
-
return style.flexDirection.trim().toLowerCase() === 'row';
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (typeof style.display !== 'string') {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const display = style.display.trim().toLowerCase();
|
|
331
|
-
return display === 'flex' || display === 'inline-flex';
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export function resolveGridTrackCount(value: NativePropValue | undefined): number | undefined {
|
|
335
|
-
if (typeof value !== 'string') {
|
|
336
|
-
return undefined;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const tracks = parseNativeGridTrackDefinition(value.trim())?.tracks ?? [];
|
|
340
|
-
return tracks.length > 0 ? tracks.length : undefined;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function parseNativeGridTemplateAreas(value: NativePropValue | undefined): string[][] | undefined {
|
|
344
|
-
if (typeof value !== 'string') {
|
|
345
|
-
return undefined;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const rows = Array.from(value.matchAll(/"([^"]*)"/g))
|
|
349
|
-
.map((match) => match[1].trim().split(/\s+/).filter(Boolean))
|
|
350
|
-
.filter((row) => row.length > 0);
|
|
351
|
-
if (rows.length === 0) {
|
|
352
|
-
return undefined;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const columnCount = rows[0]?.length ?? 0;
|
|
356
|
-
if (columnCount === 0 || rows.some((row) => row.length !== columnCount)) {
|
|
357
|
-
return undefined;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return rows;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export function resolveNativeGridTemplateAreaPlacements(
|
|
364
|
-
value: NativePropValue | undefined,
|
|
365
|
-
): Map<string, NativeGridTemplateAreaPlacement> | undefined {
|
|
366
|
-
const rows = parseNativeGridTemplateAreas(value);
|
|
367
|
-
if (!rows) {
|
|
368
|
-
return undefined;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const bounds = new Map<string, { minRow: number; maxRow: number; minColumn: number; maxColumn: number }>();
|
|
372
|
-
for (const [rowIndex, row] of rows.entries()) {
|
|
373
|
-
for (const [columnIndex, areaName] of row.entries()) {
|
|
374
|
-
if (areaName === '.') {
|
|
375
|
-
continue;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const existing = bounds.get(areaName);
|
|
379
|
-
if (existing) {
|
|
380
|
-
existing.minRow = Math.min(existing.minRow, rowIndex);
|
|
381
|
-
existing.maxRow = Math.max(existing.maxRow, rowIndex);
|
|
382
|
-
existing.minColumn = Math.min(existing.minColumn, columnIndex);
|
|
383
|
-
existing.maxColumn = Math.max(existing.maxColumn, columnIndex);
|
|
384
|
-
} else {
|
|
385
|
-
bounds.set(areaName, {
|
|
386
|
-
minRow: rowIndex,
|
|
387
|
-
maxRow: rowIndex,
|
|
388
|
-
minColumn: columnIndex,
|
|
389
|
-
maxColumn: columnIndex,
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const placements = new Map<string, NativeGridTemplateAreaPlacement>();
|
|
396
|
-
for (const [areaName, bound] of bounds.entries()) {
|
|
397
|
-
let isRectangular = true;
|
|
398
|
-
for (let rowIndex = bound.minRow; rowIndex <= bound.maxRow && isRectangular; rowIndex += 1) {
|
|
399
|
-
for (let columnIndex = bound.minColumn; columnIndex <= bound.maxColumn; columnIndex += 1) {
|
|
400
|
-
if (rows[rowIndex]?.[columnIndex] !== areaName) {
|
|
401
|
-
isRectangular = false;
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (!isRectangular) {
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
placements.set(areaName, {
|
|
412
|
-
rowPlacement: { start: bound.minRow + 1, span: (bound.maxRow - bound.minRow) + 1 },
|
|
413
|
-
columnPlacement: { start: bound.minColumn + 1, span: (bound.maxColumn - bound.minColumn) + 1 },
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return placements.size > 0 ? placements : undefined;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export function resolveNativeGridAutoFlow(value: NativePropValue | undefined): { axis: 'row' | 'column'; dense: boolean } {
|
|
421
|
-
if (typeof value !== 'string') {
|
|
422
|
-
return { axis: 'row', dense: false };
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const tokens = value
|
|
426
|
-
.trim()
|
|
427
|
-
.toLowerCase()
|
|
428
|
-
.split(/\s+/)
|
|
429
|
-
.filter(Boolean);
|
|
430
|
-
|
|
431
|
-
return {
|
|
432
|
-
axis: tokens.includes('column') ? 'column' : 'row',
|
|
433
|
-
dense: tokens.includes('dense'),
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export function parseNativeGridLineIndexValue(
|
|
438
|
-
value: NativePropValue | undefined,
|
|
439
|
-
lineNames?: Map<string, number[]>,
|
|
440
|
-
explicitLineCount?: number,
|
|
441
|
-
): number | undefined {
|
|
442
|
-
const resolveNumericLine = (lineIndex: number): number | undefined => {
|
|
443
|
-
if (!Number.isInteger(lineIndex) || lineIndex === 0) {
|
|
444
|
-
return undefined;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (lineIndex > 0) {
|
|
448
|
-
return lineIndex;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (explicitLineCount === undefined || explicitLineCount <= 0) {
|
|
452
|
-
return undefined;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
const resolvedIndex = explicitLineCount + lineIndex + 1;
|
|
456
|
-
return resolvedIndex >= 1 && resolvedIndex <= explicitLineCount ? resolvedIndex : undefined;
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
if (typeof value === 'number') {
|
|
460
|
-
return resolveNumericLine(value);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if (typeof value !== 'string') {
|
|
464
|
-
return undefined;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const trimmed = value.trim().toLowerCase();
|
|
468
|
-
if (!trimmed || trimmed === 'auto') {
|
|
469
|
-
return undefined;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
const match = trimmed.match(/^(-?\d+)$/);
|
|
473
|
-
if (match) {
|
|
474
|
-
return resolveNumericLine(Number(match[1]));
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const namedLineMatch = trimmed.match(/^([_a-z][-_a-z0-9]*)(?:\s+(-?\d+))?$|^(-?\d+)\s+([_a-z][-_a-z0-9]*)$/i);
|
|
478
|
-
if (!namedLineMatch) {
|
|
479
|
-
return undefined;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
const lineName = (namedLineMatch[1] ?? namedLineMatch[4])?.toLowerCase();
|
|
483
|
-
const occurrence = Number(namedLineMatch[2] ?? namedLineMatch[3] ?? '1');
|
|
484
|
-
if (!lineName || !Number.isFinite(occurrence) || occurrence === 0) {
|
|
485
|
-
return undefined;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
const namedLines = lineNames?.get(lineName);
|
|
489
|
-
if (!namedLines || namedLines.length === 0) {
|
|
490
|
-
return undefined;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
if (occurrence > 0) {
|
|
494
|
-
return namedLines.length >= occurrence ? namedLines[occurrence - 1] : undefined;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
const reverseIndex = namedLines.length + occurrence;
|
|
498
|
-
return reverseIndex >= 0 ? namedLines[reverseIndex] : undefined;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
export function parseNativeGridSpanValue(value: NativePropValue | undefined): number | undefined {
|
|
502
|
-
if (typeof value !== 'string') {
|
|
503
|
-
return undefined;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const match = value.trim().toLowerCase().match(/^span\s+(\d+)$/);
|
|
507
|
-
return match ? Math.max(1, Number(match[1])) : undefined;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
export function resolveNativeGridPlacementValue(
|
|
511
|
-
value: NativePropValue | undefined,
|
|
512
|
-
lineNames?: Map<string, number[]>,
|
|
513
|
-
explicitLineCount?: number,
|
|
514
|
-
): { start?: number; span: number } | undefined {
|
|
515
|
-
const directStart = parseNativeGridLineIndexValue(value, lineNames, explicitLineCount);
|
|
516
|
-
if (directStart !== undefined) {
|
|
517
|
-
return { start: directStart, span: 1 };
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
const directSpan = parseNativeGridSpanValue(value);
|
|
521
|
-
if (directSpan !== undefined) {
|
|
522
|
-
return { span: directSpan };
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (typeof value !== 'string') {
|
|
526
|
-
return undefined;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
const tokens = value.split('/').map((entry) => entry.trim()).filter(Boolean);
|
|
530
|
-
if (tokens.length === 0) {
|
|
531
|
-
return undefined;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const firstStart = parseNativeGridLineIndexValue(tokens[0], lineNames, explicitLineCount);
|
|
535
|
-
const firstSpan = parseNativeGridSpanValue(tokens[0]);
|
|
536
|
-
const secondStart = tokens[1] ? parseNativeGridLineIndexValue(tokens[1], lineNames, explicitLineCount) : undefined;
|
|
537
|
-
const secondSpan = tokens[1] ? parseNativeGridSpanValue(tokens[1]) : undefined;
|
|
538
|
-
const start = firstStart ?? secondStart;
|
|
539
|
-
const span = secondSpan
|
|
540
|
-
?? firstSpan
|
|
541
|
-
?? (firstStart !== undefined && secondStart !== undefined ? Math.max(1, secondStart - firstStart) : 1);
|
|
542
|
-
|
|
543
|
-
return start !== undefined || span !== 1
|
|
544
|
-
? { ...(start !== undefined ? { start } : {}), span }
|
|
545
|
-
: undefined;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export function resolveNativeGridAreaPlacement(
|
|
549
|
-
value: NativePropValue | undefined,
|
|
550
|
-
rowLineNames?: Map<string, number[]>,
|
|
551
|
-
columnLineNames?: Map<string, number[]>,
|
|
552
|
-
rowExplicitLineCount?: number,
|
|
553
|
-
columnExplicitLineCount?: number,
|
|
554
|
-
): { rowPlacement?: { start?: number; span: number }; columnPlacement?: { start?: number; span: number } } | undefined {
|
|
555
|
-
if (typeof value !== 'string') {
|
|
556
|
-
return undefined;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
const tokens = value.split('/').map((entry) => entry.trim()).filter(Boolean);
|
|
560
|
-
if (tokens.length < 2) {
|
|
561
|
-
return undefined;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
const rowStart = parseNativeGridLineIndexValue(tokens[0], rowLineNames, rowExplicitLineCount);
|
|
565
|
-
const columnStart = parseNativeGridLineIndexValue(tokens[1], columnLineNames, columnExplicitLineCount);
|
|
566
|
-
const rowEnd = tokens[2] ? parseNativeGridLineIndexValue(tokens[2], rowLineNames, rowExplicitLineCount) : undefined;
|
|
567
|
-
const rowSpan = tokens[2] ? parseNativeGridSpanValue(tokens[2]) : undefined;
|
|
568
|
-
const columnEnd = tokens[3] ? parseNativeGridLineIndexValue(tokens[3], columnLineNames, columnExplicitLineCount) : undefined;
|
|
569
|
-
const columnSpan = tokens[3] ? parseNativeGridSpanValue(tokens[3]) : undefined;
|
|
570
|
-
|
|
571
|
-
const rowPlacement = rowStart !== undefined || rowEnd !== undefined || rowSpan !== undefined
|
|
572
|
-
? {
|
|
573
|
-
...(rowStart !== undefined ? { start: rowStart } : {}),
|
|
574
|
-
span: rowSpan ?? (rowStart !== undefined && rowEnd !== undefined ? Math.max(1, rowEnd - rowStart) : 1),
|
|
575
|
-
}
|
|
576
|
-
: undefined;
|
|
577
|
-
const columnPlacement = columnStart !== undefined || columnEnd !== undefined || columnSpan !== undefined
|
|
578
|
-
? {
|
|
579
|
-
...(columnStart !== undefined ? { start: columnStart } : {}),
|
|
580
|
-
span: columnSpan ?? (columnStart !== undefined && columnEnd !== undefined ? Math.max(1, columnEnd - columnStart) : 1),
|
|
581
|
-
}
|
|
582
|
-
: undefined;
|
|
583
|
-
|
|
584
|
-
return rowPlacement || columnPlacement
|
|
585
|
-
? {
|
|
586
|
-
...(rowPlacement ? { rowPlacement } : {}),
|
|
587
|
-
...(columnPlacement ? { columnPlacement } : {}),
|
|
588
|
-
}
|
|
589
|
-
: undefined;
|
|
590
|
-
}
|