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.
Files changed (113) hide show
  1. package/Cargo.toml +1 -1
  2. package/README.md +1 -1
  3. package/desktop/build.rs +83 -0
  4. package/desktop/icon.rs +106 -0
  5. package/desktop/lib.rs +2 -0
  6. package/desktop/main.rs +235 -0
  7. package/desktop/native_main.rs +128 -0
  8. package/desktop/native_renderer/action_widgets.rs +184 -0
  9. package/desktop/native_renderer/app_models.rs +171 -0
  10. package/desktop/native_renderer/app_runtime.rs +140 -0
  11. package/desktop/native_renderer/container_rendering.rs +610 -0
  12. package/desktop/native_renderer/content_widgets.rs +634 -0
  13. package/desktop/native_renderer/css_models.rs +371 -0
  14. package/desktop/native_renderer/embedded_surfaces.rs +414 -0
  15. package/desktop/native_renderer/form_controls.rs +516 -0
  16. package/desktop/native_renderer/interaction_dispatch.rs +89 -0
  17. package/desktop/native_renderer/runtime_support.rs +135 -0
  18. package/desktop/native_renderer/utilities.rs +495 -0
  19. package/desktop/native_renderer/vector_drawing.rs +491 -0
  20. package/desktop/native_renderer.rs +4122 -0
  21. package/desktop/runtime/external.rs +422 -0
  22. package/desktop/runtime/mod.rs +67 -0
  23. package/desktop/runtime/quickjs.rs +106 -0
  24. package/desktop/window.rs +383 -0
  25. package/package.json +6 -3
  26. package/dist/build.d.mts +0 -20
  27. package/dist/chokidar.d.mts +0 -134
  28. package/dist/cli.d.mts +0 -81
  29. package/dist/config.d.mts +0 -254
  30. package/dist/coverage.d.mts +0 -85
  31. package/dist/database.d.mts +0 -52
  32. package/dist/desktop.d.mts +0 -68
  33. package/dist/dom.d.mts +0 -87
  34. package/dist/el.d.mts +0 -208
  35. package/dist/fs.d.mts +0 -255
  36. package/dist/hmr.d.mts +0 -38
  37. package/dist/http.d.mts +0 -169
  38. package/dist/https.d.mts +0 -108
  39. package/dist/index.d.mts +0 -13
  40. package/dist/mime-types.d.mts +0 -48
  41. package/dist/native.d.mts +0 -136
  42. package/dist/path.d.mts +0 -163
  43. package/dist/router.d.mts +0 -49
  44. package/dist/runtime.d.mts +0 -97
  45. package/dist/server-D0Dp4R5z.d.mts +0 -449
  46. package/dist/server.d.mts +0 -7
  47. package/dist/state.d.mts +0 -117
  48. package/dist/style.d.mts +0 -232
  49. package/dist/test-reporter.d.mts +0 -77
  50. package/dist/test-runtime.d.mts +0 -122
  51. package/dist/test.d.mts +0 -39
  52. package/dist/types.d.mts +0 -586
  53. package/dist/universal.d.mts +0 -21
  54. package/dist/ws.d.mts +0 -200
  55. package/dist/wss.d.mts +0 -108
  56. package/src/build.ts +0 -362
  57. package/src/chokidar.ts +0 -427
  58. package/src/cli.ts +0 -1162
  59. package/src/config.ts +0 -509
  60. package/src/coverage.ts +0 -1479
  61. package/src/database.ts +0 -1410
  62. package/src/desktop-auto-render.ts +0 -317
  63. package/src/desktop-cli.ts +0 -1533
  64. package/src/desktop.ts +0 -99
  65. package/src/dev-build.ts +0 -340
  66. package/src/dom.ts +0 -901
  67. package/src/el.ts +0 -183
  68. package/src/fs.ts +0 -609
  69. package/src/hmr.ts +0 -149
  70. package/src/http.ts +0 -856
  71. package/src/https.ts +0 -411
  72. package/src/index.ts +0 -16
  73. package/src/mime-types.ts +0 -222
  74. package/src/mobile-cli.ts +0 -2313
  75. package/src/native-background.ts +0 -444
  76. package/src/native-border.ts +0 -343
  77. package/src/native-canvas.ts +0 -260
  78. package/src/native-cli.ts +0 -414
  79. package/src/native-color.ts +0 -904
  80. package/src/native-estimation.ts +0 -194
  81. package/src/native-grid.ts +0 -590
  82. package/src/native-interaction.ts +0 -1289
  83. package/src/native-layout.ts +0 -568
  84. package/src/native-link.ts +0 -76
  85. package/src/native-render-support.ts +0 -361
  86. package/src/native-spacing.ts +0 -231
  87. package/src/native-state.ts +0 -318
  88. package/src/native-strings.ts +0 -46
  89. package/src/native-transform.ts +0 -120
  90. package/src/native-types.ts +0 -439
  91. package/src/native-typography.ts +0 -254
  92. package/src/native-units.ts +0 -441
  93. package/src/native-vector.ts +0 -910
  94. package/src/native.ts +0 -5606
  95. package/src/path.ts +0 -493
  96. package/src/pm-cli.ts +0 -2498
  97. package/src/preview-build.ts +0 -294
  98. package/src/render-context.ts +0 -138
  99. package/src/router.ts +0 -260
  100. package/src/runtime.ts +0 -97
  101. package/src/server.ts +0 -2294
  102. package/src/state.ts +0 -556
  103. package/src/style.ts +0 -1790
  104. package/src/test-globals.d.ts +0 -184
  105. package/src/test-reporter.ts +0 -609
  106. package/src/test-runtime.ts +0 -1359
  107. package/src/test.ts +0 -368
  108. package/src/types.ts +0 -381
  109. package/src/universal.ts +0 -81
  110. package/src/wapk-cli.ts +0 -3213
  111. package/src/workspace-package.ts +0 -102
  112. package/src/ws.ts +0 -648
  113. package/src/wss.ts +0 -241
@@ -1,444 +0,0 @@
1
- import { type NativeStyleResolveOptions } from './style';
2
- import type {
3
- NativeBackgroundLayerSpec,
4
- NativeBackgroundLayerMetadata,
5
- NativeBackgroundRepeat,
6
- NativeColorValue,
7
- NativeGradientValue,
8
- NativePropValue,
9
- NativeVideoPosterFit,
10
- NativeVideoPosterPosition,
11
- } from './native-types';
12
- import { splitCssFunctionArguments } from './native-units';
13
- import { liftColorAlpha, parseCssColor, parseLinearGradient, resolveBackdropBlurRadius, resolveStyleCurrentColor } from './native-color';
14
-
15
- type NativePositionToken = 'leading' | 'center' | 'trailing' | 'top' | 'bottom';
16
-
17
- export function resolveNativeObjectFitStyle(style: Record<string, NativePropValue> | undefined): NativeVideoPosterFit {
18
- const rawValue = typeof style?.objectFit === 'string' ? style.objectFit.trim().toLowerCase() : '';
19
-
20
- switch (rawValue) {
21
- case 'contain':
22
- case 'fill':
23
- case 'none':
24
- case 'scale-down':
25
- return rawValue;
26
- default:
27
- return 'cover';
28
- }
29
- }
30
-
31
- function normalizeNativePositionToken(value: string): NativePositionToken | undefined {
32
- const normalized = value.trim().toLowerCase();
33
-
34
- switch (normalized) {
35
- case 'left':
36
- case '0%':
37
- return 'leading';
38
- case 'right':
39
- case '100%':
40
- return 'trailing';
41
- case 'top':
42
- return 'top';
43
- case 'bottom':
44
- return 'bottom';
45
- case 'center':
46
- case '50%':
47
- return 'center';
48
- default:
49
- return undefined;
50
- }
51
- }
52
-
53
- export function resolveNativeObjectPositionStyle(style: Record<string, NativePropValue> | undefined): NativeVideoPosterPosition {
54
- if (typeof style?.objectPosition !== 'string' || !style.objectPosition.trim()) {
55
- return 'center';
56
- }
57
-
58
- const tokens = style.objectPosition.trim().split(/\s+/).map(normalizeNativePositionToken).filter((value): value is NativePositionToken => Boolean(value));
59
- if (tokens.length === 0) {
60
- return 'center';
61
- }
62
-
63
- let horizontal: 'leading' | 'center' | 'trailing' = 'center';
64
- let vertical: 'top' | 'center' | 'bottom' = 'center';
65
-
66
- for (const token of tokens) {
67
- if (token === 'leading' || token === 'trailing') {
68
- horizontal = token;
69
- } else if (token === 'top' || token === 'bottom') {
70
- vertical = token;
71
- } else if (tokens.length === 1) {
72
- horizontal = 'center';
73
- vertical = 'center';
74
- }
75
- }
76
-
77
- if (horizontal === 'center' && vertical === 'center') {
78
- return 'center';
79
- }
80
-
81
- if (horizontal === 'center') {
82
- return vertical;
83
- }
84
-
85
- if (vertical === 'center') {
86
- return horizontal;
87
- }
88
-
89
- return `${vertical}-${horizontal}` as NativeVideoPosterPosition;
90
- }
91
-
92
- export function extractCssUrlValue(value: string): string | undefined {
93
- const match = value.match(/url\(\s*(?:"([^"]*)"|'([^']*)'|([^\s"'()]+))\s*\)/i);
94
- const resolved = match?.[1] ?? match?.[2] ?? match?.[3];
95
- return resolved?.trim() || undefined;
96
- }
97
-
98
- function extractCssFunctionValue(value: string, functionName: string): string | undefined {
99
- const lowerValue = value.toLowerCase();
100
- const lowerFunctionName = functionName.toLowerCase();
101
- const needle = `${lowerFunctionName}(`;
102
- let searchIndex = 0;
103
-
104
- while (searchIndex < value.length) {
105
- const matchIndex = lowerValue.indexOf(needle, searchIndex);
106
- if (matchIndex < 0) {
107
- return undefined;
108
- }
109
-
110
- const previousChar = matchIndex > 0 ? lowerValue[matchIndex - 1] : undefined;
111
- if (previousChar && /[a-z0-9-]/.test(previousChar)) {
112
- searchIndex = matchIndex + lowerFunctionName.length;
113
- continue;
114
- }
115
-
116
- let depth = 0;
117
- for (let index = matchIndex + lowerFunctionName.length; index < value.length; index += 1) {
118
- const char = value[index];
119
- if (char === '(') {
120
- depth += 1;
121
- } else if (char === ')' && depth > 0) {
122
- depth -= 1;
123
- if (depth === 0) {
124
- return value.slice(matchIndex, index + 1);
125
- }
126
- }
127
- }
128
-
129
- return undefined;
130
- }
131
-
132
- return undefined;
133
- }
134
-
135
- function stripCssFunctionValue(value: string, functionName: string): string {
136
- const functionValue = extractCssFunctionValue(value, functionName);
137
- return functionValue ? value.replace(functionValue, ' ') : value;
138
- }
139
-
140
- export function splitNativeBackgroundLayers(value: NativePropValue | undefined): string[] {
141
- if (typeof value !== 'string' || !value.trim()) {
142
- return [];
143
- }
144
-
145
- return splitCssFunctionArguments(value)
146
- .map((entry) => entry.trim())
147
- .filter(Boolean);
148
- }
149
-
150
- function normalizeNativeBackgroundRepeat(value: string | undefined): NativeBackgroundRepeat | undefined {
151
- switch (value?.trim().toLowerCase()) {
152
- case 'repeat':
153
- case 'repeat-x':
154
- case 'repeat-y':
155
- case 'no-repeat':
156
- return value.trim().toLowerCase() as NativeBackgroundRepeat;
157
- default:
158
- return undefined;
159
- }
160
- }
161
-
162
- function normalizeNativeBackgroundPositionValue(rawPosition: string | undefined): string | undefined {
163
- if (!rawPosition) {
164
- return undefined;
165
- }
166
-
167
- const positionTokens = rawPosition
168
- .split(/\s+/)
169
- .map((token) => token.trim())
170
- .filter((token) => normalizeNativePositionToken(token) !== undefined);
171
- return positionTokens.length > 0 ? positionTokens.join(' ') : undefined;
172
- }
173
-
174
- function normalizeNativeBackgroundSizeValue(rawSize: string | undefined): string | undefined {
175
- const sizeCandidate = rawSize?.trim().toLowerCase();
176
- return sizeCandidate?.startsWith('100% 100%')
177
- ? '100% 100%'
178
- : sizeCandidate?.startsWith('auto auto')
179
- ? 'auto auto'
180
- : sizeCandidate?.startsWith('scale-down')
181
- ? 'scale-down'
182
- : sizeCandidate?.match(/^(contain|cover|fill|none|auto)\b/i)?.[1]?.toLowerCase();
183
- }
184
-
185
- export function resolveNativeBackgroundColorLayer(
186
- color: NativeColorValue | undefined,
187
- style: Record<string, NativePropValue>,
188
- styleResolveOptions: NativeStyleResolveOptions,
189
- ): NativeColorValue | undefined {
190
- const backdropBlur = color ? resolveBackdropBlurRadius(style, styleResolveOptions) : undefined;
191
-
192
- if (!color || backdropBlur === undefined || color.alpha >= 1) {
193
- return color;
194
- }
195
-
196
- return liftColorAlpha(color, Math.min(0.14, backdropBlur / 160));
197
- }
198
-
199
- function parseNativeBackgroundLayerMetadata(
200
- layer: string,
201
- currentColor: NativeColorValue,
202
- ): NativeBackgroundLayerMetadata | undefined {
203
- const sourceToken = extractCssFunctionValue(layer, 'url');
204
- const gradientToken = extractCssFunctionValue(layer, 'linear-gradient');
205
- const source = sourceToken ? extractCssUrlValue(sourceToken) : undefined;
206
- const gradient = gradientToken ? parseLinearGradient(gradientToken, currentColor) : undefined;
207
-
208
- let remainder = stripCssFunctionValue(stripCssFunctionValue(layer, 'url'), 'linear-gradient');
209
-
210
- const repeatMatch = remainder.match(/\b(no-repeat|repeat-[xy]|repeat)\b/i);
211
- const repeat = normalizeNativeBackgroundRepeat(repeatMatch?.[1]);
212
- if (repeatMatch) {
213
- remainder = `${remainder.slice(0, repeatMatch.index)} ${remainder.slice((repeatMatch.index ?? 0) + repeatMatch[0].length)}`.trim();
214
- }
215
-
216
- const [rawPosition, rawSize] = remainder.split('/', 2).map((entry) => entry.trim()) as [string, string | undefined];
217
- const position = normalizeNativeBackgroundPositionValue(rawPosition);
218
- const size = normalizeNativeBackgroundSizeValue(rawSize);
219
- const color = parseCssColor(remainder, currentColor);
220
-
221
- if (!source && !gradient && !color) {
222
- return undefined;
223
- }
224
-
225
- return {
226
- ...(source ? { source } : {}),
227
- ...(gradient ? { gradient } : {}),
228
- ...(color ? { color } : {}),
229
- ...(repeat ? { repeat } : {}),
230
- ...(size ? { size } : {}),
231
- ...(position ? { position } : {}),
232
- };
233
- }
234
-
235
- export function resolveNativeBackgroundShorthandColor(
236
- value: NativePropValue | undefined,
237
- currentColor: NativeColorValue,
238
- ): NativeColorValue | undefined {
239
- if (typeof value !== 'string' || !value.trim()) {
240
- return undefined;
241
- }
242
-
243
- let color: NativeColorValue | undefined;
244
- for (const layer of splitNativeBackgroundLayers(value)) {
245
- color = parseNativeBackgroundLayerMetadata(layer, currentColor)?.color ?? color;
246
- }
247
-
248
- return color;
249
- }
250
-
251
- export function resolveNativeBackgroundShorthandLayers(
252
- value: NativePropValue | undefined,
253
- currentColor: NativeColorValue,
254
- ): NativeBackgroundLayerMetadata[] {
255
- if (typeof value !== 'string' || !value.trim()) {
256
- return [];
257
- }
258
-
259
- return splitNativeBackgroundLayers(value)
260
- .map((layer) => parseNativeBackgroundLayerMetadata(layer, currentColor))
261
- .filter((layer): layer is NativeBackgroundLayerMetadata => Boolean(layer));
262
- }
263
-
264
- export function resolveBackgroundColor(
265
- style: Record<string, NativePropValue>,
266
- styleResolveOptions: NativeStyleResolveOptions,
267
- ): NativeColorValue | undefined {
268
- const currentColor = resolveStyleCurrentColor(style);
269
- const explicitBackgroundColor = parseCssColor(style.backgroundColor, currentColor);
270
- const shorthandBackgroundColor = explicitBackgroundColor ? undefined : resolveNativeBackgroundShorthandColor(style.background, currentColor);
271
- return resolveNativeBackgroundColorLayer(explicitBackgroundColor ?? shorthandBackgroundColor, style, styleResolveOptions);
272
- }
273
-
274
- export function resolveBackgroundGradient(style: Record<string, NativePropValue>): NativeGradientValue | undefined {
275
- return parseLinearGradient(style.background, resolveStyleCurrentColor(style));
276
- }
277
-
278
- export function resolveNativeBackgroundLayersFromStyle(
279
- style: Record<string, NativePropValue> | undefined,
280
- styleResolveOptions: NativeStyleResolveOptions,
281
- ): NativeBackgroundLayerSpec[] {
282
- if (!style) {
283
- return [];
284
- }
285
-
286
- const currentColor = resolveStyleCurrentColor(style);
287
- const layers: NativeBackgroundLayerSpec[] = [];
288
-
289
- if (typeof style.backgroundImage === 'string' && style.backgroundImage.trim()) {
290
- const repeatLayers = splitNativeBackgroundLayers(style.backgroundRepeat);
291
- const sizeLayers = splitNativeBackgroundLayers(style.backgroundSize);
292
- const positionLayers = splitNativeBackgroundLayers(style.backgroundPosition);
293
-
294
- splitNativeBackgroundLayers(style.backgroundImage).forEach((entry, index) => {
295
- const source = extractCssUrlValue(entry);
296
- if (!source) {
297
- const gradient = parseLinearGradient(entry, currentColor);
298
- if (gradient) {
299
- layers.push({ kind: 'gradient', gradient });
300
- }
301
- return;
302
- }
303
-
304
- const repeat = resolveNativeBackgroundRepeatValue(pickNativeBackgroundLayerValue(repeatLayers, index));
305
- const size = pickNativeBackgroundLayerValue(sizeLayers, index);
306
- const position = pickNativeBackgroundLayerValue(positionLayers, index);
307
-
308
- layers.push({
309
- kind: 'image',
310
- source,
311
- fit: resolveNativeBackgroundImageFitValue(size, repeat),
312
- position: resolveNativeBackgroundImagePositionValue(position),
313
- repeat,
314
- });
315
- });
316
- } else {
317
- for (const layer of resolveNativeBackgroundShorthandLayers(style.background, currentColor)) {
318
- if (layer.source) {
319
- const repeat = resolveNativeBackgroundRepeatValue(layer.repeat);
320
- layers.push({
321
- kind: 'image',
322
- source: layer.source,
323
- fit: resolveNativeBackgroundImageFitValue(layer.size, repeat),
324
- position: resolveNativeBackgroundImagePositionValue(layer.position),
325
- repeat,
326
- });
327
- continue;
328
- }
329
-
330
- if (layer.gradient) {
331
- layers.push({ kind: 'gradient', gradient: layer.gradient });
332
- }
333
- }
334
- }
335
-
336
- let explicitBackgroundColor: NativeColorValue | undefined;
337
- if (style.backgroundColor !== undefined) {
338
- const styleWithoutBackground = { ...style };
339
- delete styleWithoutBackground.background;
340
- explicitBackgroundColor = resolveBackgroundColor(styleWithoutBackground, styleResolveOptions);
341
- }
342
- const shouldReadBackgroundColorFallback = typeof style.background === 'string'
343
- && (!style.backgroundImage
344
- || (!/url\(/i.test(style.background) && !/linear-gradient\(/i.test(style.background) && !style.background.includes(',')));
345
- const shorthandBackgroundColor = shouldReadBackgroundColorFallback
346
- ? resolveNativeBackgroundColorLayer(resolveNativeBackgroundShorthandColor(style.background, currentColor), style, styleResolveOptions)
347
- : undefined;
348
- const backgroundColor = explicitBackgroundColor ?? shorthandBackgroundColor;
349
-
350
- if (backgroundColor) {
351
- layers.push({ kind: 'color', color: backgroundColor });
352
- }
353
-
354
- return layers;
355
- }
356
-
357
- export function pickNativeBackgroundLayerValue(layers: string[], index: number): string | undefined {
358
- if (layers.length === 0) {
359
- return undefined;
360
- }
361
-
362
- return layers[index % layers.length];
363
- }
364
-
365
- export function resolveNativeBackgroundRepeatValue(value: string | undefined): NativeBackgroundRepeat {
366
- return normalizeNativeBackgroundRepeat(value) ?? 'no-repeat';
367
- }
368
-
369
- export function resolveNativeBackgroundImageFitValue(rawSize: string | undefined, repeat: NativeBackgroundRepeat): NativeVideoPosterFit {
370
- const normalizedSize = normalizeNativeBackgroundSizeValue(rawSize) ?? '';
371
-
372
- switch (normalizedSize) {
373
- case 'contain':
374
- case 'cover':
375
- case 'fill':
376
- case 'none':
377
- case 'scale-down':
378
- return normalizedSize;
379
- case '100% 100%':
380
- return 'fill';
381
- case 'auto':
382
- case 'auto auto':
383
- return repeat !== 'no-repeat' ? 'none' : 'cover';
384
- default:
385
- return repeat !== 'no-repeat' ? 'none' : 'cover';
386
- }
387
- }
388
-
389
- export function resolveNativeBackgroundImagePositionValue(rawPosition: string | undefined): NativeVideoPosterPosition {
390
- const normalizedPosition = normalizeNativeBackgroundPositionValue(rawPosition);
391
- if (!normalizedPosition) {
392
- return 'center';
393
- }
394
-
395
- const tokens = normalizedPosition.split(/\s+/)
396
- .map(normalizeNativePositionToken)
397
- .filter((value): value is NativePositionToken => Boolean(value));
398
- if (tokens.length === 0) {
399
- return 'center';
400
- }
401
-
402
- let horizontal: 'leading' | 'center' | 'trailing' = 'center';
403
- let vertical: 'top' | 'center' | 'bottom' = 'center';
404
-
405
- for (const token of tokens) {
406
- if (token === 'leading' || token === 'trailing') {
407
- horizontal = token;
408
- } else if (token === 'top' || token === 'bottom') {
409
- vertical = token;
410
- } else if (tokens.length === 1) {
411
- horizontal = 'center';
412
- vertical = 'center';
413
- }
414
- }
415
-
416
- if (horizontal === 'center' && vertical === 'center') {
417
- return 'center';
418
- }
419
-
420
- if (horizontal === 'center') {
421
- return vertical;
422
- }
423
-
424
- if (vertical === 'center') {
425
- return horizontal;
426
- }
427
-
428
- return `${vertical}-${horizontal}` as NativeVideoPosterPosition;
429
- }
430
-
431
- export function stripNativeBackgroundPaintStyles(style: Record<string, NativePropValue> | undefined): Record<string, NativePropValue> | undefined {
432
- if (!style) {
433
- return undefined;
434
- }
435
-
436
- const nextStyle = { ...style };
437
- delete nextStyle.background;
438
- delete nextStyle.backgroundColor;
439
- delete nextStyle.backgroundImage;
440
- delete nextStyle.backgroundRepeat;
441
- delete nextStyle.backgroundPosition;
442
- delete nextStyle.backgroundSize;
443
- return nextStyle;
444
- }