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-background.ts
DELETED
|
@@ -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
|
-
}
|