create-octane-xplat 0.18.0 → 0.20.0

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 (77) hide show
  1. package/README.md +2 -144
  2. package/compatibility.json +97 -19
  3. package/compatibility.ts +141 -72
  4. package/dist/compatibility.js +66 -26
  5. package/dist/index.js +127 -64
  6. package/dist/package-manager.js +62 -0
  7. package/dist/scaffold.js +377 -127
  8. package/index.ts +256 -154
  9. package/library-template/AGENTS.md +6 -4
  10. package/library-template/README.md +22 -18
  11. package/library-template/bunfig +4 -0
  12. package/library-template/package.json +115 -18
  13. package/library-template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
  14. package/library-template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
  15. package/library-template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
  16. package/library-template/patches/@nativescript__core@9.1.3.patch +1280 -0
  17. package/library-template/patches/@nativescript__doctor@2.0.18.patch +13 -0
  18. package/library-template/patches/@nativescript__vite@8.0.20.patch +2019 -0
  19. package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  20. package/library-template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
  21. package/library-template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
  22. package/library-template/patches/css@3.0.0.patch +52 -0
  23. package/library-template/patches/octane@0.16.3.patch +1479 -0
  24. package/library-template/src/Badge.tsx +7 -6
  25. package/library-template/src/Badge.web.tsx +7 -6
  26. package/library-template/src/Welcome.stories.tsx +12 -0
  27. package/library-template/src/normalizeBadgeLabel.ts +1 -1
  28. package/library-template/src/props.ts +11 -11
  29. package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
  30. package/library-template/tests/packed-consumer.mjs +140 -123
  31. package/library-template/tsconfig.envs.json +1 -0
  32. package/library-template/tsconfig.json +1 -0
  33. package/library-template/tsconfig.types.json +15 -1
  34. package/library-template/tsrx-typegen.json +1 -1
  35. package/library-template/workshop.config.ts +3 -0
  36. package/package-manager.ts +93 -0
  37. package/package.json +70 -58
  38. package/scaffold.ts +1056 -526
  39. package/template/.agents/skills/xplat/SKILL.md +6 -6
  40. package/template/.agents/skills/xplat/references/components.md +1 -1
  41. package/template/.agents/skills/xplat/references/navigation.md +1 -1
  42. package/template/.agents/skills/xplat/references/styling.md +14 -14
  43. package/template/AGENTS.md +10 -10
  44. package/template/bunfig +4 -0
  45. package/template/gitignore +1 -0
  46. package/template/nativescript.config.ts +13 -16
  47. package/template/package.json +119 -10
  48. package/template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
  49. package/template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
  50. package/template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
  51. package/template/patches/@nativescript__core@9.1.3.patch +1280 -0
  52. package/template/patches/@nativescript__doctor@2.0.18.patch +13 -0
  53. package/template/patches/@nativescript__vite@8.0.20.patch +2019 -0
  54. package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  55. package/template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
  56. package/template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
  57. package/template/patches/css@3.0.0.patch +52 -0
  58. package/template/patches/octane@0.16.3.patch +1479 -0
  59. package/template/src/App.tsrx +77 -42
  60. package/template/src/Welcome.stories.tsx +22 -0
  61. package/template/src/app.spec.tsrx +169 -163
  62. package/template/src/app.web.test.tsx +18 -13
  63. package/template/src/failure-reporting.spec.ts +3 -3
  64. package/template/src/main.ts +14 -13
  65. package/template/src/main.tsrx +2 -0
  66. package/template/src/main.web.tsrx +5 -5
  67. package/template/src/native-runtime.spec.ts +13 -11
  68. package/template/src/test-setup.web.ts +9 -8
  69. package/template/src/test.ts +6 -6
  70. package/template/tsconfig.json +17 -1
  71. package/template/vite.config.native.mts +1 -2
  72. package/template/vite.config.ts +29 -23
  73. package/template/vitest.config.mts +18 -18
  74. package/template/vitest.web.config.mts +7 -7
  75. package/template/workshop.config.ts +3 -0
  76. package/library-template/pnpm-workspace.yaml +0 -171
  77. package/template/pnpm-workspace.yaml +0 -192
@@ -0,0 +1,1280 @@
1
+ diff --git a/css/css-tree-parser.js b/css/css-tree-parser.js
2
+ index ee888000bf860ec2a376926f05b64cb5999c3b4f..6098f60b5281ca64c9255b16642046f25266af0d 100644
3
+ --- a/css/css-tree-parser.js
4
+ +++ b/css/css-tree-parser.js
5
+ @@ -70,6 +70,10 @@ function transformAst(node, css, type = null) {
6
+ atrule.keyframes = transformAst(node.block, css, 'keyframe');
7
+ atrule.vendor = undefined;
8
+ }
9
+ + else if (node.name === 'layer') {
10
+ + atrule.layer = node.prelude ? node.prelude.value.trim() : '';
11
+ + atrule.rules = transformAst(node.block, css);
12
+ + }
13
+ else {
14
+ atrule.rules = transformAst(node.block, css);
15
+ }
16
+ diff --git a/css/reworkcss.d.ts b/css/reworkcss.d.ts
17
+ index 3ac4f618f307864cb95b70cd01f4ecdc42c9d9e4..1906ed1457de195a799c9e938136f078e7ed6307 100644
18
+ --- a/css/reworkcss.d.ts
19
+ +++ b/css/reworkcss.d.ts
20
+ @@ -10,7 +10,7 @@ export interface Position {
21
+ };
22
+ }
23
+ export interface Node {
24
+ - type: 'rule' | 'keyframes' | 'declaration' | 'import' | 'media';
25
+ + type: 'rule' | 'keyframes' | 'declaration' | 'import' | 'media' | 'layer';
26
+ position: Position;
27
+ }
28
+ export interface Declaration extends Node {
29
+ @@ -21,7 +21,7 @@ export interface Rule extends Node {
30
+ selectors: string[];
31
+ declarations: Declaration[];
32
+ }
33
+ -export type AtRule = KeyFrames | Media;
34
+ +export type AtRule = KeyFrames | Media | Layer;
35
+ export interface Keyframes extends Rule {
36
+ name: string;
37
+ vendor?: string;
38
+ @@ -35,6 +35,11 @@ export interface Media extends Node {
39
+ media: string;
40
+ rules: Array<Rule | AtRule>;
41
+ }
42
+ +export interface Layer extends Node {
43
+ + /** Layer-name prelude — '' for an anonymous block. Statement form (`@layer a, b;`) leaves rules undefined. */
44
+ + layer: string;
45
+ + rules?: Array<Rule | AtRule>;
46
+ +}
47
+ export interface StyleSheet {
48
+ rules: Rule[];
49
+ }
50
+ diff --git a/ui/animation/animation-common.js b/ui/animation/animation-common.js
51
+ index d67e3c208de1a37d07aa3ee97f7f64e58ca1c1c4..60415ea6c023212727d090d724793b4ff5cf3b93 100644
52
+ --- a/ui/animation/animation-common.js
53
+ +++ b/ui/animation/animation-common.js
54
+ @@ -106,10 +106,26 @@ export class AnimationBase {
55
+ console.error(`Property ${item} must be valid number. Value: ${value}`);
56
+ return;
57
+ }
58
+ - else if ((item === Properties.scale || item === Properties.translate) && (typeof value.x !== 'number' || typeof value.y !== 'number')) {
59
+ + else if (item === Properties.scale && (typeof value.x !== 'number' || typeof value.y !== 'number')) {
60
+ console.error(`Property ${item} must be valid Pair. Value: ${value}`);
61
+ return;
62
+ }
63
+ + else if (item === Properties.translate) {
64
+ + // Coerce input into PercentLength values so that percentage
65
+ + // translates (e.g. from keyframe transforms) are preserved.
66
+ + try {
67
+ + const x = PercentLength.parse(value.x);
68
+ + const y = PercentLength.parse(value.y);
69
+ + if (!isValidTranslateValue(x) || !isValidTranslateValue(y)) {
70
+ + throw new Error();
71
+ + }
72
+ + animationDefinition[item] = { x, y };
73
+ + }
74
+ + catch {
75
+ + console.error(`Property ${item} must be valid Pair. Value: ${value}`);
76
+ + return;
77
+ + }
78
+ + }
79
+ else if (item === Properties.backgroundColor && !Color.isValid(animationDefinition.backgroundColor)) {
80
+ console.error(`Property ${item} must be valid color. Value: ${value}`);
81
+ return;
82
+ @@ -236,4 +252,13 @@ export class AnimationBase {
83
+ });
84
+ }
85
+ }
86
+ +function isValidTranslateValue(value) {
87
+ + if (typeof value === 'number') {
88
+ + return true;
89
+ + }
90
+ + if (!value || typeof value !== 'object') {
91
+ + return false;
92
+ + }
93
+ + return (value.unit === 'px' || value.unit === 'dip' || value.unit === '%') && typeof value.value === 'number';
94
+ +}
95
+ //# sourceMappingURL=animation-common.js.map
96
+
97
+ diff --git a/ui/animation/animation-shared.d.ts b/ui/animation/animation-shared.d.ts
98
+ index 4d5239dc6d6d4dd4d22e34f68b9a2c246fb2f16a..eb216e70300d7a186d40b20d27860a17eb6815f4 100644
99
+ --- a/ui/animation/animation-shared.d.ts
100
+ +++ b/ui/animation/animation-shared.d.ts
101
+ @@ -6,17 +6,21 @@ export type Transformation = {
102
+ value: TransformationValue;
103
+ };
104
+ export type TransformationType = 'rotate' | 'rotate3d' | 'rotateX' | 'rotateY' | 'translate' | 'translate3d' | 'translateX' | 'translateY' | 'scale' | 'scale3d' | 'scaleX' | 'scaleY';
105
+ -export type TransformationValue = Point3D | Pair | number;
106
+ +export type TransformationValue = Point3D | Pair | TranslatePair | number;
107
+ export interface Point3D {
108
+ x: number;
109
+ y: number;
110
+ z: number;
111
+ }
112
+ export type TransformFunctionsInfo = {
113
+ - translate: Pair;
114
+ + translate: TranslatePair;
115
+ rotate: Point3D;
116
+ scale: Pair;
117
+ };
118
+ +export interface TranslatePair {
119
+ + x: CoreTypes.PercentLengthType;
120
+ + y: CoreTypes.PercentLengthType;
121
+ +}
122
+ export interface Pair {
123
+ x: number;
124
+ y: number;
125
+ @@ -29,10 +33,7 @@ export interface AnimationDefinition {
126
+ target?: View;
127
+ opacity?: number;
128
+ backgroundColor?: Color | any;
129
+ - translate?: Pair | {
130
+ - x: number;
131
+ - y: number;
132
+ - };
133
+ + translate?: TranslatePair;
134
+ scale?: Pair | {
135
+ x: number;
136
+ y: number;
137
+ diff --git a/ui/animation/index.android.js b/ui/animation/index.android.js
138
+ index a9328887ae7ad20eadc75f46d9829ce4d3716b6f..55d0cad961eb9b4e47b007f4a2de7424a98aa890 100644
139
+ --- a/ui/animation/index.android.js
140
+ +++ b/ui/animation/index.android.js
141
+ @@ -304,7 +304,7 @@ export class Animation extends AnimationBase {
142
+ propertyAnimation.target[translateYProperty.setNative](propertyAnimation.target.style.translateY);
143
+ }
144
+ });
145
+ - animators.push(createAnimationSet([createObjectAnimator(nativeView, 'translationX', propertyAnimation.value.x * density), createObjectAnimator(nativeView, 'translationY', propertyAnimation.value.y * density)], propertyAnimation.iterations));
146
+ + animators.push(createAnimationSet([createObjectAnimator(nativeView, 'translationX', PercentLength.toDevicePixels(propertyAnimation.value.x, 0, nativeView.getWidth())), createObjectAnimator(nativeView, 'translationY', PercentLength.toDevicePixels(propertyAnimation.value.y, 0, nativeView.getHeight()))], propertyAnimation.iterations));
147
+ break;
148
+ case Properties.scale:
149
+ scaleXProperty._initDefaultNativeValue(style);
150
+ diff --git a/ui/animation/index.d.ts b/ui/animation/index.d.ts
151
+ index 24292e7aa38a0e915e19843551121d336d39d477..47307b90625d2dc09b3ca00b91882d7d8e542864 100644
152
+ --- a/ui/animation/index.d.ts
153
+ +++ b/ui/animation/index.d.ts
154
+ @@ -1,4 +1,4 @@
155
+ -export type { Pair, Transformation, TransformationType, TransformationValue, TransformFunctionsInfo, Point3D, AnimationPromise, Cancelable } from './animation-types';
156
+ +export type { Pair, TranslatePair, Transformation, TransformationType, TransformationValue, TransformFunctionsInfo, Point3D, AnimationPromise, Cancelable } from './animation-types';
157
+ export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation';
158
+ import type { AnimationDefinition, AnimationPromise } from './animation-types';
159
+
160
+ diff --git a/ui/animation/index.ios.js b/ui/animation/index.ios.js
161
+ index 25f3c19349a389341676963351b6315f9181c1fc..f2d0eeb42ac12daa0fa4dd5ce1c704103501a736 100644
162
+ --- a/ui/animation/index.ios.js
163
+ +++ b/ui/animation/index.ios.js
164
+ @@ -3,6 +3,7 @@ import { AnimationBase, Properties } from './animation-common';
165
+ import { CubicBezierAnimationCurve } from '../../core-types/animation-types';
166
+ import { Trace } from '../../trace';
167
+ import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty } from '../styling/style-properties';
168
+ +import { resolveTranslate } from '../styling/css-transform';
169
+ import { PercentLength } from '../styling/length-shared';
170
+ import { ios as iosBackground } from '../styling/background';
171
+ import { ios as iosViewUtils } from '../utils';
172
+ @@ -329,7 +330,8 @@ export class Animation extends AnimationBase {
173
+ };
174
+ propertyNameToAnimate = 'transform';
175
+ fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
176
+ - toValue = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, toValue.x, toValue.y, 0));
177
+ + const bounds = nativeView.bounds.size;
178
+ + toValue = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, resolveTranslate(toValue.x, bounds.width), resolveTranslate(toValue.y, bounds.height), 0));
179
+ break;
180
+ case Properties.scale:
181
+ if (toValue.x === 0) {
182
+ @@ -583,8 +585,9 @@ export class Animation extends AnimationBase {
183
+ const value = animation.value;
184
+ let result = CATransform3DIdentity;
185
+ if (value[Properties.translate] !== undefined) {
186
+ - const x = value[Properties.translate].x;
187
+ - const y = value[Properties.translate].y;
188
+ + const bounds = animation.target.nativeViewProtected ? animation.target.nativeViewProtected.bounds.size : { width: 0, height: 0 };
189
+ + const x = resolveTranslate(value[Properties.translate].x, bounds.width);
190
+ + const y = resolveTranslate(value[Properties.translate].y, bounds.height);
191
+ result = CATransform3DTranslate(result, x, y, 0);
192
+ }
193
+ if (value[Properties.scale] !== undefined) {
194
+ @@ -793,7 +796,8 @@ function calculateTransform(view) {
195
+ if (view.rotateX || view.rotateY) {
196
+ expectedTransform.m34 = -1 / perspective;
197
+ }
198
+ - expectedTransform = CATransform3DTranslate(expectedTransform, view.translateX, view.translateY, 0);
199
+ + const bounds = view.nativeViewProtected ? view.nativeViewProtected.bounds.size : { width: 0, height: 0 };
200
+ + expectedTransform = CATransform3DTranslate(expectedTransform, resolveTranslate(view.translateX, bounds.width), resolveTranslate(view.translateY, bounds.height), 0);
201
+ expectedTransform = iosHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate);
202
+ expectedTransform = CATransform3DScale(expectedTransform, scaleX, scaleY, 1);
203
+ return expectedTransform;
204
+ diff --git a/ui/animation/keyframe-animation.d.ts b/ui/animation/keyframe-animation.d.ts
205
+ index 3be12d5c382176ca302bc318f8d24e0434e00f51..7e34c4329780fb0cc623dbf28934b17610d427c6 100644
206
+ --- a/ui/animation/keyframe-animation.d.ts
207
+ +++ b/ui/animation/keyframe-animation.d.ts
208
+ @@ -38,8 +38,8 @@ interface Keyframe {
209
+ y: number;
210
+ };
211
+ translate?: {
212
+ - x: number;
213
+ - y: number;
214
+ + x: CoreTypes.PercentLengthType;
215
+ + y: CoreTypes.PercentLengthType;
216
+ };
217
+ rotate?: {
218
+ x: number;
219
+ diff --git a/ui/core/view/index.android.d.ts b/ui/core/view/index.android.d.ts
220
+ index d5780663fe6823ad2be0bb44e682358e86c272eb..a82a8e052a0588e449728733b4e943268009ac47 100644
221
+ --- a/ui/core/view/index.android.d.ts
222
+ +++ b/ui/core/view/index.android.d.ts
223
+ @@ -58,8 +58,8 @@ export declare class View extends ViewCommon {
224
+ [perspectiveProperty.setNative]: (value: number) => void;
225
+ [scaleXProperty.setNative]: (value: number) => void;
226
+ [scaleYProperty.setNative]: (value: number) => void;
227
+ - [translateXProperty.setNative]: (value: CoreTypes.dip) => void;
228
+ - [translateYProperty.setNative]: (value: CoreTypes.dip) => void;
229
+ + [translateXProperty.setNative]: (value: CoreTypes.PercentLengthType) => void;
230
+ + [translateYProperty.setNative]: (value: CoreTypes.PercentLengthType) => void;
231
+ [zIndexProperty.getDefault]: () => number;
232
+ [zIndexProperty.setNative]: (value: number) => void;
233
+ [backgroundInternalProperty.getDefault]: () => android.graphics.drawable.Drawable;
234
+ diff --git a/ui/core/view/index.android.js b/ui/core/view/index.android.js
235
+ index 7fd9d50a663a053535c29c071a0308c7d78c3303..adb2295f7fb0606335debb41a1eb5d136f51c1c7 100644
236
+ --- a/ui/core/view/index.android.js
237
+ +++ b/ui/core/view/index.android.js
238
+ @@ -7,6 +7,8 @@ import { Trace } from '../../../trace';
239
+ import { hiddenProperty } from '../view-base';
240
+ import { isCssWideKeyword } from '../properties/property-shared';
241
+ import { perspectiveProperty, visibilityProperty, opacityProperty, horizontalAlignmentProperty, verticalAlignmentProperty, minWidthProperty, minHeightProperty, maxWidthProperty, maxHeightProperty, widthProperty, heightProperty, marginLeftProperty, marginTopProperty, marginRightProperty, marginBottomProperty, rotateProperty, rotateXProperty, rotateYProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty, androidElevationProperty, androidDynamicElevationOffsetProperty } from '../../styling/style-properties';
242
+ +import { isPercentTranslate } from '../../styling/css-transform';
243
+ +import { PercentLength } from '../../styling/length-shared';
244
+ import { CoreTypes } from '../../../core-types';
245
+ import { Background, refreshBorderDrawable } from '../../styling/background';
246
+ import { profile } from '../../../profiling';
247
+ @@ -718,8 +720,16 @@ export class View extends ViewCommon {
248
+ return false;
249
+ }
250
+ layoutNativeView(left, top, right, bottom) {
251
+ - if (this.nativeViewProtected) {
252
+ - this.nativeViewProtected.layout(left, top, right, bottom);
253
+ + const nativeView = this.nativeViewProtected;
254
+ + if (nativeView) {
255
+ + nativeView.layout(left, top, right, bottom);
256
+ + // Percentage translates are resolved against the view's own size.
257
+ + if (isPercentTranslate(this.translateX)) {
258
+ + org.nativescript.widgets.ViewHelper.setTranslateX(nativeView, PercentLength.toDevicePixels(this.translateX, 0, nativeView.getWidth()));
259
+ + }
260
+ + if (isPercentTranslate(this.translateY)) {
261
+ + org.nativescript.widgets.ViewHelper.setTranslateY(nativeView, PercentLength.toDevicePixels(this.translateY, 0, nativeView.getHeight()));
262
+ + }
263
+ }
264
+ }
265
+ requestLayout() {
266
+ @@ -1296,10 +1306,10 @@ export class View extends ViewCommon {
267
+ org.nativescript.widgets.ViewHelper.setScaleY(this.nativeViewProtected, float(value));
268
+ }
269
+ [translateXProperty.setNative](value) {
270
+ - org.nativescript.widgets.ViewHelper.setTranslateX(this.nativeViewProtected, layout.toDevicePixels(value));
271
+ + org.nativescript.widgets.ViewHelper.setTranslateX(this.nativeViewProtected, PercentLength.toDevicePixels(value, 0, this.nativeViewProtected ? this.nativeViewProtected.getWidth() : 0));
272
+ }
273
+ [translateYProperty.setNative](value) {
274
+ - org.nativescript.widgets.ViewHelper.setTranslateY(this.nativeViewProtected, layout.toDevicePixels(value));
275
+ + org.nativescript.widgets.ViewHelper.setTranslateY(this.nativeViewProtected, PercentLength.toDevicePixels(value, 0, this.nativeViewProtected ? this.nativeViewProtected.getHeight() : 0));
276
+ }
277
+ [zIndexProperty.getDefault]() {
278
+ return 0;
279
+ diff --git a/ui/core/view/index.d.ts b/ui/core/view/index.d.ts
280
+ index f5cc0e283779eb9049932b99fd9c8285526c05f9..af4b295ebed3886b31c0678b2d6e5103ad470ae1 100644
281
+ --- a/ui/core/view/index.d.ts
282
+ +++ b/ui/core/view/index.d.ts
283
+ @@ -549,18 +549,20 @@ export abstract class View extends ViewCommon {
284
+ perspective: number;
285
+
286
+ /**
287
+ - * Gets or sets the translateX affine transform of the view in device independent pixels.
288
+ + * Gets or sets the translateX affine transform of the view.
289
+ + * Percentages are resolved against the view's own width.
290
+ *
291
+ * @nsProperty
292
+ */
293
+ - translateX: CoreTypes.dip;
294
+ + translateX: CoreTypes.PercentLengthType;
295
+
296
+ /**
297
+ - * Gets or sets the translateY affine transform of the view in device independent pixels.
298
+ + * Gets or sets the translateY affine transform of the view.
299
+ + * Percentages are resolved against the view's own height.
300
+ *
301
+ * @nsProperty
302
+ */
303
+ - translateY: CoreTypes.dip;
304
+ + translateY: CoreTypes.PercentLengthType;
305
+
306
+ /**
307
+ * Gets or sets the scaleX affine transform of the view.
308
+ diff --git a/ui/core/view/index.ios.d.ts b/ui/core/view/index.ios.d.ts
309
+ index ce122eb22174264e5840dccbaa053ae96a3cf16d..fc203e7744833f9e311510926c58c83d4a787745 100644
310
+ --- a/ui/core/view/index.ios.d.ts
311
+ +++ b/ui/core/view/index.ios.d.ts
312
+ @@ -51,9 +51,9 @@ export declare class View extends ViewCommon {
313
+ [scaleYProperty.getDefault]: () => number;
314
+ [scaleYProperty.setNative]: (value: number) => void;
315
+ [translateXProperty.getDefault]: () => CoreTypes.dip;
316
+ - [translateXProperty.setNative]: (value: CoreTypes.dip) => void;
317
+ + [translateXProperty.setNative]: (value: CoreTypes.PercentLengthType) => void;
318
+ [translateYProperty.getDefault]: () => CoreTypes.dip;
319
+ - [translateYProperty.setNative]: (value: CoreTypes.dip) => void;
320
+ + [translateYProperty.setNative]: (value: CoreTypes.PercentLengthType) => void;
321
+ [zIndexProperty.getDefault]: () => number;
322
+ [zIndexProperty.setNative]: (value: number) => void;
323
+ [backgroundInternalProperty.getDefault]: () => UIColor;
324
+ diff --git a/ui/core/view/index.ios.js b/ui/core/view/index.ios.js
325
+ index 63f0ed7f7bbb587e5f081f7fc6c9cb80df81127d..8e9d901af0801df8b1a174691b2882c01164ebe4 100644
326
+ --- a/ui/core/view/index.ios.js
327
+ +++ b/ui/core/view/index.ios.js
328
+ @@ -8,6 +8,7 @@ import { SDK_VERSION, supportsGlass } from '../../../utils/constants';
329
+ import { IOSHelper } from './view-helper';
330
+ import { ios as iosBackground } from '../../styling/background';
331
+ import { perspectiveProperty, visibilityProperty, opacityProperty, rotateProperty, rotateXProperty, rotateYProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty, directionProperty } from '../../styling/style-properties';
332
+ +import { isPercentTranslate, resolveTranslate } from '../../styling/css-transform';
333
+ import { profile } from '../../../profiling';
334
+ import { accessibilityEnabledProperty, accessibilityHiddenProperty, accessibilityHintProperty, accessibilityIdentifierProperty, accessibilityLabelProperty, accessibilityLanguageProperty, accessibilityLiveRegionProperty, accessibilityMediaSessionProperty, accessibilityRoleProperty, accessibilityStateProperty, accessibilityValueProperty, accessibilityIgnoresInvertColorsProperty } from '../../../accessibility/accessibility-properties';
335
+ import { IOSPostAccessibilityNotificationType } from '../../../accessibility';
336
+ @@ -352,6 +353,10 @@ export class View extends ViewCommon {
337
+ if (this._nativeBackgroundState === 'invalid' || (this._nativeBackgroundState === 'drawn' && backgroundDependsOnSize)) {
338
+ this._redrawNativeBackground(background);
339
+ }
340
+ + // Percentage translates are resolved against the view's own size.
341
+ + if (isPercentTranslate(this.translateX) || isPercentTranslate(this.translateY)) {
342
+ + this.updateNativeTransform();
343
+ + }
344
+ }
345
+ updateNativeTransform() {
346
+ const scaleX = this.scaleX || 1e-6;
347
+ @@ -363,7 +368,8 @@ export class View extends ViewCommon {
348
+ if (this.rotateX || this.rotateY) {
349
+ transform.m34 = -1 / perspective;
350
+ }
351
+ - transform = CATransform3DTranslate(transform, this.translateX, this.translateY, 0);
352
+ + const bounds = nativeView.bounds.size;
353
+ + transform = CATransform3DTranslate(transform, resolveTranslate(this.translateX, bounds.width), resolveTranslate(this.translateY, bounds.height), 0);
354
+ transform = iosUtils.applyRotateTransform(transform, this.rotateX, this.rotateY, this.rotate);
355
+ transform = CATransform3DScale(transform, scaleX, scaleY, 1);
356
+ if (!CATransform3DEqualToTransform(this.nativeViewProtected.layer.transform, transform)) {
357
+ diff --git a/ui/core/view/view-common.d.ts b/ui/core/view/view-common.d.ts
358
+ index e08bd0515f328334feb43be5c0a608099cc7efd3..5ab1064575441d664a6854f15d92b79d6bd122de 100644
359
+ --- a/ui/core/view/view-common.d.ts
360
+ +++ b/ui/core/view/view-common.d.ts
361
+ @@ -228,10 +228,10 @@ export declare abstract class ViewCommon extends ViewBase {
362
+ set perspective(value: number);
363
+ get textTransform(): CoreTypes.TextTransformType;
364
+ set textTransform(value: CoreTypes.TextTransformType);
365
+ - get translateX(): CoreTypes.dip;
366
+ - set translateX(value: CoreTypes.dip);
367
+ - get translateY(): CoreTypes.dip;
368
+ - set translateY(value: CoreTypes.dip);
369
+ + get translateX(): CoreTypes.PercentLengthType;
370
+ + set translateX(value: CoreTypes.PercentLengthType);
371
+ + get translateY(): CoreTypes.PercentLengthType;
372
+ + set translateY(value: CoreTypes.PercentLengthType);
373
+ get scaleX(): number;
374
+ set scaleX(value: number);
375
+ get scaleY(): number;
376
+ diff --git a/ui/index.d.ts b/ui/index.d.ts
377
+ index ef5209d97b83fadf0da672fc2677faa1d56199b6..b2eac9a30234e05ca859c0f664b77ca40f06793c 100644
378
+ --- a/ui/index.d.ts
379
+ +++ b/ui/index.d.ts
380
+ @@ -2,7 +2,7 @@ export { ActionBar, ActionItem, ActionItems, NavigationButton } from './action-b
381
+ export { ActivityIndicator } from './activity-indicator';
382
+ export { Animation, _resolveAnimationCurve } from './animation';
383
+ export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation/keyframe-animation';
384
+ -export type { AnimationDefinition, Pair, Transformation, TransformationType, TransformationValue, TransformFunctionsInfo, Point3D, AnimationPromise, Cancelable } from './animation/animation-types';
385
+ +export type { AnimationDefinition, Pair, TranslatePair, Transformation, TransformationType, TransformationValue, TransformFunctionsInfo, Point3D, AnimationPromise, Cancelable } from './animation/animation-types';
386
+ export * from './animation/animation-shared';
387
+ export { Builder } from './builder';
388
+ export type { LoadOptions } from './builder';
389
+ diff --git a/ui/layouts/flexbox-layout/flexbox-layout-common.js b/ui/layouts/flexbox-layout/flexbox-layout-common.js
390
+ index 54a037138b909446c71da47eb1cd682d5286fb18..64fa8712dae8260998f88eb26b053f5f48002c9e 100644
391
+ --- a/ui/layouts/flexbox-layout/flexbox-layout-common.js
392
+ +++ b/ui/layouts/flexbox-layout/flexbox-layout-common.js
393
+ @@ -193,7 +193,21 @@ let FlexboxLayoutBase = class FlexboxLayoutBase extends LayoutBase {
394
+ validateArgs(view).style.alignSelf = align;
395
+ }
396
+ static getAlignSelf(view) {
397
+ - return validateArgs(view).style.alignSelf;
398
+ + const style = validateArgs(view).style;
399
+ + const alignSelf = style.alignSelf;
400
+ + if (alignSelf !== 'auto' && alignSelf !== 'stretch') {
401
+ + return alignSelf;
402
+ + }
403
+ + const parent = view.parent;
404
+ + if (!(parent instanceof FlexboxLayoutBase)) {
405
+ + return alignSelf;
406
+ + }
407
+ + if (alignSelf === 'auto' && parent.alignItems !== 'stretch') {
408
+ + return alignSelf;
409
+ + }
410
+ + const isRow = parent.flexDirection === 'row' || parent.flexDirection === 'row-reverse';
411
+ + const crossSize = isRow ? style.height : style.width;
412
+ + return crossSize == null || crossSize === 'auto' ? alignSelf : 'flex-start';
413
+ }
414
+ static setFlexWrapBefore(view, wrap) {
415
+ validateArgs(view).style.flexWrapBefore = wrap;
416
+ diff --git a/ui/layouts/flexbox-layout/index.android.js b/ui/layouts/flexbox-layout/index.android.js
417
+ index ed354fddfe1caf982e73b603798cb8f5bf0d3501..7191092e40ba07c3dc3e6555059dbda028418d9c 100644
418
+ --- a/ui/layouts/flexbox-layout/index.android.js
419
+ +++ b/ui/layouts/flexbox-layout/index.android.js
420
+ @@ -1,7 +1,7 @@
421
+ import { FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, FlexboxLayoutBase, orderProperty, flexGrowProperty, flexShrinkProperty, flexWrapBeforeProperty, alignSelfProperty, AlignSelf, flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty } from './flexbox-layout-common';
422
+ import { View } from '../../core/view';
423
+ import { Length } from '../../styling/length-shared';
424
+ -import { columnGapProperty, rowGapProperty } from '../../styling/style-properties';
425
+ +import { columnGapProperty, rowGapProperty, widthProperty, heightProperty } from '../../styling/style-properties';
426
+ export * from './flexbox-layout-common';
427
+ let widgetFlexboxLayout;
428
+ let widgetLayoutParams;
429
+ @@ -27,6 +27,25 @@ View.prototype[flexGrowProperty.setNative] = makeNativeSetter((lp, value) => (lp
430
+ View.prototype[flexShrinkProperty.setNative] = makeNativeSetter((lp, value) => (lp.flexShrink = value));
431
+ View.prototype[flexWrapBeforeProperty.setNative] = makeNativeSetter((lp, value) => (lp.wrapBefore = value));
432
+ View.prototype[alignSelfProperty.setNative] = makeNativeSetter((lp, value) => (lp.alignSelf = alignSelfMap[value]));
433
+ +function refreshFlexboxParent(child) {
434
+ + const parent = child.parent;
435
+ + if (parent instanceof FlexboxLayoutBase) {
436
+ + parent._updateNativeLayoutParams(child);
437
+ + }
438
+ +}
439
+ +function wrapChildLayoutProperty(property) {
440
+ + const setter = View.prototype[property.setNative];
441
+ + if (typeof setter !== 'function') {
442
+ + return;
443
+ + }
444
+ + View.prototype[property.setNative] = function (value) {
445
+ + setter.call(this, value);
446
+ + refreshFlexboxParent(this);
447
+ + };
448
+ +}
449
+ +wrapChildLayoutProperty(widthProperty);
450
+ +wrapChildLayoutProperty(heightProperty);
451
+ +wrapChildLayoutProperty(alignSelfProperty);
452
+ const flexDirectionMap = {
453
+ [FlexDirection.ROW]: 0, //FlexboxLayoutWidget.FLEX_DIRECTION_ROW,
454
+ [FlexDirection.ROW_REVERSE]: 1, //FlexboxLayoutWidget.FLEX_DIRECTION_ROW_REVERSE,
455
+ @@ -85,6 +104,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
456
+ }
457
+ [flexDirectionProperty.setNative](flexDirection) {
458
+ this.nativeViewProtected.setFlexDirection(flexDirectionMap[flexDirection]);
459
+ + this.eachLayoutChild((child) => this._updateNativeLayoutParams(child));
460
+ }
461
+ [flexWrapProperty.getDefault]() {
462
+ return flexWrapProperty.defaultValue;
463
+ @@ -103,6 +123,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
464
+ }
465
+ [alignItemsProperty.setNative](alignItems) {
466
+ this.nativeViewProtected.setAlignItems(alignItemsMap[alignItems]);
467
+ + this.eachLayoutChild((child) => this._updateNativeLayoutParams(child));
468
+ }
469
+ [alignContentProperty.getDefault]() {
470
+ return alignContentProperty.defaultValue;
471
+ @@ -136,7 +157,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
472
+ lp.flexGrow = style.flexGrow;
473
+ lp.flexShrink = style.flexShrink;
474
+ lp.wrapBefore = style.flexWrapBefore;
475
+ - lp.alignSelf = alignSelfMap[style.alignSelf];
476
+ + lp.alignSelf = alignSelfMap[FlexboxLayoutBase.getAlignSelf(child)];
477
+ child.nativeViewProtected.setLayoutParams(lp);
478
+ }
479
+ _setChildMinWidthNative(child, value) {
480
+ diff --git a/ui/layouts/liquid-glass-container/index.ios.js b/ui/layouts/liquid-glass-container/index.ios.js
481
+ index 6b3a474048271321d450e6c12a4c23215ac6efc2..5001783b44ab83f68829265b4e61d6a6f2f12081 100644
482
+ --- a/ui/layouts/liquid-glass-container/index.ios.js
483
+ +++ b/ui/layouts/liquid-glass-container/index.ios.js
484
+ @@ -1,5 +1,6 @@
485
+ import { supportsGlass } from '../../../utils/constants';
486
+ import { iosGlassEffectProperty, IOSHelper } from '../../core/view';
487
+ +import { resolveTranslate } from '../../styling/css-transform';
488
+ import { LiquidGlassContainerCommon } from './liquid-glass-container-common';
489
+ import { toUIGlassStyle } from '../liquid-glass';
490
+ export class LiquidGlassContainer extends LiquidGlassContainerCommon {
491
+ @@ -118,13 +119,14 @@ export class LiquidGlassContainer extends LiquidGlassContainerCommon {
492
+ const child = this.getChildAt(i);
493
+ if (!child)
494
+ continue;
495
+ - const tx = child.translateX || 0;
496
+ - const ty = child.translateY || 0;
497
+ - if (!tx && !ty)
498
+ - continue;
499
+ const native = child.nativeViewProtected;
500
+ if (!native)
501
+ continue;
502
+ + const bounds = native.bounds.size;
503
+ + const tx = resolveTranslate(child.translateX, bounds.width);
504
+ + const ty = resolveTranslate(child.translateY, bounds.height);
505
+ + if (!tx && !ty)
506
+ + continue;
507
+ // Skip if the child is still animating (unless forced)
508
+ if (!force) {
509
+ const keys = native.layer.animationKeys ? native.layer.animationKeys() : null;
510
+ diff --git a/ui/styling/background.ios.js b/ui/styling/background.ios.js
511
+ index 810720f038afa5a76efd00b04af80b13afeac50e..1c7fb37ee0376ac55501e7b3e5f11c7350c6a703 100644
512
+ --- a/ui/styling/background.ios.js
513
+ +++ b/ui/styling/background.ios.js
514
+ @@ -197,8 +197,8 @@ export var ios;
515
+ bottomLeft: cappedRadius + spreadRadius,
516
+ bottomRight: cappedRadius + spreadRadius,
517
+ };
518
+ - innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
519
+ - shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius);
520
+ + innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii, 0, background.cornerShape === CoreTypes.CornerShape.squircle);
521
+ + shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius, background.cornerShape === CoreTypes.CornerShape.squircle);
522
+ }
523
+ else {
524
+ const outerTopLeftRadius = layout.toDeviceIndependentPixels(background.borderTopLeftRadius);
525
+ @@ -223,8 +223,8 @@ export var ios;
526
+ bottomLeft: cappedOuterRadii.bottomLeft > 0 ? cappedOuterRadii.bottomLeft + spreadRadius : cappedOuterRadii.bottomLeft,
527
+ bottomRight: cappedOuterRadii.bottomRight > 0 ? cappedOuterRadii.bottomRight + spreadRadius : cappedOuterRadii.bottomRight,
528
+ };
529
+ - innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
530
+ - shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius);
531
+ + innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii, 0, background.cornerShape === CoreTypes.CornerShape.squircle);
532
+ + shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius, background.cornerShape === CoreTypes.CornerShape.squircle);
533
+ }
534
+ }
535
+ else {
536
+ @@ -292,7 +292,7 @@ export var ios;
537
+ function generateNonUniformBorderOuterClipRoundedPath(view, bounds) {
538
+ const background = view.style.backgroundInternal;
539
+ const cappedOuterRadii = calculateNonUniformBorderCappedRadii(bounds, background);
540
+ - return generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
541
+ + return generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii, 0, background.cornerShape === CoreTypes.CornerShape.squircle);
542
+ }
543
+ ios.generateNonUniformBorderOuterClipRoundedPath = generateNonUniformBorderOuterClipRoundedPath;
544
+ function generateNonUniformMultiColorBorderRoundedPaths(view, bounds) {
545
+ @@ -626,7 +626,7 @@ function drawNonUniformBorders(nativeView, background) {
546
+ layer.cornerRadius = 0;
547
+ const cappedOuterRadii = calculateNonUniformBorderCappedRadii(layerBounds, background);
548
+ if (nativeView.maskType === iosViewUtils.LayerMask.BORDER && layer.mask instanceof CAShapeLayer) {
549
+ - layer.mask.path = generateNonUniformBorderOuterClipPath(layerBounds, cappedOuterRadii);
550
+ + layer.mask.path = generateNonUniformBorderOuterClipPath(layerBounds, cappedOuterRadii, 0, background.cornerShape === CoreTypes.CornerShape.squircle);
551
+ }
552
+ if (background.hasBorderWidth()) {
553
+ if (!nativeView.hasNonUniformBorder) {
554
+ @@ -694,15 +694,57 @@ function calculateInnerBorderClipRadius(radius, insetX, insetY) {
555
+ maxRadius: innerMaxRadius,
556
+ };
557
+ }
558
+ +// Squircle corner curve — superellipse |x|^n + |y|^n = r^n with n=4, the
559
+ +// approximation of Apple's "continuous" corner that CSS `corner-shape:
560
+ +// squircle` specifies. Sampled as a short polyline per corner (the mask is
561
+ +// rasterized once per bounds change, so segment count doesn't matter at
562
+ +// screen scale).
563
+ +const SQUIRCLE_EXPONENT = 4;
564
+ +const SQUIRCLE_CORNER_STEPS = 12;
565
+ +/**
566
+ + * Appends a straight line to the incoming tangent point, then a squircle
567
+ + * quarter arc to the exit tangent — same semantics as CGPathAddArcToPoint.
568
+ + *
569
+ + * @param path
570
+ + * @param t1x/t1y tangent point on the incoming edge
571
+ + * @param t2x/t2y tangent point on the outgoing edge
572
+ + * @param vx/vy corner vertex where the two edges would meet
573
+ + */
574
+ +function addSquircleArcToPoint(path, t1x, t1y, t2x, t2y, vx, vy) {
575
+ + CGPathAddLineToPoint(path, null, t1x, t1y);
576
+ + // The corner-box corner opposite the vertex is the arc's center.
577
+ + const cx = t1x + t2x - vx;
578
+ + const cy = t1y + t2y - vy;
579
+ + const e = 2 / SQUIRCLE_EXPONENT;
580
+ + // t1 sits on a horizontal edge when its offset from the center is
581
+ + // vertical; parametrize θ: 0 → π/2 so the polyline always runs t1 → t2.
582
+ + if (Math.abs(t1y - cy) >= Math.abs(t1x - cx)) {
583
+ + const ax = t2x - cx;
584
+ + const ay = t1y - cy;
585
+ + for (let i = 1; i <= SQUIRCLE_CORNER_STEPS; i++) {
586
+ + const a = (i / SQUIRCLE_CORNER_STEPS) * (Math.PI / 2);
587
+ + CGPathAddLineToPoint(path, null, cx + ax * Math.pow(Math.sin(a), e), cy + ay * Math.pow(Math.cos(a), e));
588
+ + }
589
+ + }
590
+ + else {
591
+ + const ax = t1x - cx;
592
+ + const ay = t2y - cy;
593
+ + for (let i = 1; i <= SQUIRCLE_CORNER_STEPS; i++) {
594
+ + const a = (i / SQUIRCLE_CORNER_STEPS) * (Math.PI / 2);
595
+ + CGPathAddLineToPoint(path, null, cx + ax * Math.pow(Math.cos(a), e), cy + ay * Math.pow(Math.sin(a), e));
596
+ + }
597
+ + }
598
+ +}
599
+ /**
600
+ * Generates a path that represents the rounded view area.
601
+ *
602
+ * @param bounds
603
+ * @param cappedRadii
604
+ * @param offset
605
+ + * @param squircle draw corner arcs as squircles instead of circular arcs
606
+ * @returns
607
+ */
608
+ -function generateNonUniformBorderOuterClipPath(bounds, cappedRadii, offset = 0) {
609
+ +function generateNonUniformBorderOuterClipPath(bounds, cappedRadii, offset = 0, squircle = false) {
610
+ const { width, height } = bounds.size;
611
+ const { x, y } = bounds.origin;
612
+ const left = x - offset;
613
+ @@ -711,10 +753,18 @@ function generateNonUniformBorderOuterClipPath(bounds, cappedRadii, offset = 0)
614
+ const bottom = y + height + offset;
615
+ const clipPath = CGPathCreateMutable();
616
+ CGPathMoveToPoint(clipPath, null, left + cappedRadii.topLeft, top);
617
+ - CGPathAddArcToPoint(clipPath, null, right, top, right, top + cappedRadii.topRight, cappedRadii.topRight);
618
+ - CGPathAddArcToPoint(clipPath, null, right, bottom, right - cappedRadii.bottomRight, bottom, cappedRadii.bottomRight);
619
+ - CGPathAddArcToPoint(clipPath, null, left, bottom, left, bottom - cappedRadii.bottomLeft, cappedRadii.bottomLeft);
620
+ - CGPathAddArcToPoint(clipPath, null, left, top, left + cappedRadii.topLeft, top, cappedRadii.topLeft);
621
+ + if (squircle) {
622
+ + addSquircleArcToPoint(clipPath, right - cappedRadii.topRight, top, right, top + cappedRadii.topRight, right, top);
623
+ + addSquircleArcToPoint(clipPath, right, bottom - cappedRadii.bottomRight, right - cappedRadii.bottomRight, bottom, right, bottom);
624
+ + addSquircleArcToPoint(clipPath, left + cappedRadii.bottomLeft, bottom, left, bottom - cappedRadii.bottomLeft, left, bottom);
625
+ + addSquircleArcToPoint(clipPath, left, top + cappedRadii.topLeft, left + cappedRadii.topLeft, top, left, top);
626
+ + }
627
+ + else {
628
+ + CGPathAddArcToPoint(clipPath, null, right, top, right, top + cappedRadii.topRight, cappedRadii.topRight);
629
+ + CGPathAddArcToPoint(clipPath, null, right, bottom, right - cappedRadii.bottomRight, bottom, cappedRadii.bottomRight);
630
+ + CGPathAddArcToPoint(clipPath, null, left, bottom, left, bottom - cappedRadii.bottomLeft, cappedRadii.bottomLeft);
631
+ + CGPathAddArcToPoint(clipPath, null, left, top, left + cappedRadii.topLeft, top, cappedRadii.topLeft);
632
+ + }
633
+ CGPathCloseSubpath(clipPath);
634
+ return clipPath;
635
+ }
636
+ @@ -747,6 +797,7 @@ function generateNonUniformBorderInnerClipPath(bounds, background, cappedOuterRa
637
+ const cappedBorderLeftWidth = borderLeftWidth && borderLeftWidth * Math.min(1, width / borderHWidth);
638
+ const clipPath = CGPathCreateMutable();
639
+ CGPathAddRect(clipPath, null, CGRectMake(x, y, width, height));
640
+ + const squircle = background.cornerShape === CoreTypes.CornerShape.squircle;
641
+ // Inner clip paths
642
+ if (cappedBorderTopWidth > 0 || cappedBorderLeftWidth > 0) {
643
+ CGPathMoveToPoint(clipPath, null, position.left + cappedOuterRadii.topLeft, position.top + cappedBorderTopWidth);
644
+ @@ -756,32 +807,52 @@ function generateNonUniformBorderInnerClipPath(bounds, background, cappedOuterRa
645
+ }
646
+ if (cappedBorderTopWidth > 0 || cappedBorderRightWidth > 0) {
647
+ const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.topRight, cappedBorderRightWidth, cappedBorderTopWidth);
648
+ - const innerTopRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.top + cappedBorderTopWidth + yRadius);
649
+ - CGPathAddArc(clipPath, innerTopRightTransform, 0, 0, maxRadius, (Math.PI * 3) / 2, 0, false);
650
+ + if (squircle) {
651
+ + addSquircleArcToPoint(clipPath, position.right - cappedBorderRightWidth - xRadius, position.top + cappedBorderTopWidth, position.right - cappedBorderRightWidth, position.top + cappedBorderTopWidth + yRadius, position.right - cappedBorderRightWidth, position.top + cappedBorderTopWidth);
652
+ + }
653
+ + else {
654
+ + const innerTopRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.top + cappedBorderTopWidth + yRadius);
655
+ + CGPathAddArc(clipPath, innerTopRightTransform, 0, 0, maxRadius, (Math.PI * 3) / 2, 0, false);
656
+ + }
657
+ }
658
+ else {
659
+ CGPathAddLineToPoint(clipPath, null, position.right, position.top);
660
+ }
661
+ if (cappedBorderBottomWidth > 0 || cappedBorderRightWidth > 0) {
662
+ const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.bottomRight, cappedBorderRightWidth, cappedBorderBottomWidth);
663
+ - const innerBottomRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
664
+ - CGPathAddArc(clipPath, innerBottomRightTransform, 0, 0, maxRadius, 0, Math.PI / 2, false);
665
+ + if (squircle) {
666
+ + addSquircleArcToPoint(clipPath, position.right - cappedBorderRightWidth, position.bottom - cappedBorderBottomWidth - yRadius, position.right - cappedBorderRightWidth - xRadius, position.bottom - cappedBorderBottomWidth, position.right - cappedBorderRightWidth, position.bottom - cappedBorderBottomWidth);
667
+ + }
668
+ + else {
669
+ + const innerBottomRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
670
+ + CGPathAddArc(clipPath, innerBottomRightTransform, 0, 0, maxRadius, 0, Math.PI / 2, false);
671
+ + }
672
+ }
673
+ else {
674
+ CGPathAddLineToPoint(clipPath, null, position.right, position.bottom);
675
+ }
676
+ if (cappedBorderBottomWidth > 0 || cappedBorderLeftWidth > 0) {
677
+ const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.bottomLeft, cappedBorderLeftWidth, cappedBorderBottomWidth);
678
+ - const innerBottomLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
679
+ - CGPathAddArc(clipPath, innerBottomLeftTransform, 0, 0, maxRadius, Math.PI / 2, Math.PI, false);
680
+ + if (squircle) {
681
+ + addSquircleArcToPoint(clipPath, position.left + cappedBorderLeftWidth + xRadius, position.bottom - cappedBorderBottomWidth, position.left + cappedBorderLeftWidth, position.bottom - cappedBorderBottomWidth - yRadius, position.left + cappedBorderLeftWidth, position.bottom - cappedBorderBottomWidth);
682
+ + }
683
+ + else {
684
+ + const innerBottomLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
685
+ + CGPathAddArc(clipPath, innerBottomLeftTransform, 0, 0, maxRadius, Math.PI / 2, Math.PI, false);
686
+ + }
687
+ }
688
+ else {
689
+ CGPathAddLineToPoint(clipPath, null, position.left, position.bottom);
690
+ }
691
+ if (cappedBorderTopWidth > 0 || cappedBorderLeftWidth > 0) {
692
+ const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.topLeft, cappedBorderLeftWidth, cappedBorderTopWidth);
693
+ - const innerTopLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.top + cappedBorderTopWidth + yRadius);
694
+ - CGPathAddArc(clipPath, innerTopLeftTransform, 0, 0, maxRadius, Math.PI, (Math.PI * 3) / 2, false);
695
+ + if (squircle) {
696
+ + addSquircleArcToPoint(clipPath, position.left + cappedBorderLeftWidth, position.top + cappedBorderTopWidth + yRadius, position.left + cappedBorderLeftWidth + xRadius, position.top + cappedBorderTopWidth, position.left + cappedBorderLeftWidth, position.top + cappedBorderTopWidth);
697
+ + }
698
+ + else {
699
+ + const innerTopLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.top + cappedBorderTopWidth + yRadius);
700
+ + CGPathAddArc(clipPath, innerTopLeftTransform, 0, 0, maxRadius, Math.PI, (Math.PI * 3) / 2, false);
701
+ + }
702
+ }
703
+ else {
704
+ CGPathAddLineToPoint(clipPath, null, position.left, position.top);
705
+ diff --git a/ui/styling/css-selector.d.ts b/ui/styling/css-selector.d.ts
706
+ index 734d886877b867e69b36fd75785b0a4372008f0f..d90f0e4fcf0f136bf4e9b10f9b08cc14f9b73e32 100644
707
+ --- a/ui/styling/css-selector.d.ts
708
+ +++ b/ui/styling/css-selector.d.ts
709
+ @@ -222,6 +222,8 @@ export declare class RuleSet {
710
+ mediaQueryString: string | string[];
711
+ tag?: string | number;
712
+ scopedTag?: string;
713
+ + /** Cascade-layer rank per nesting depth; undefined/shortest path sorts after every layer (unlayered styles win). */
714
+ + layerPath?: number[];
715
+ constructor(selectors: SelectorCore[], declarations: Declaration[]);
716
+ toString(): string;
717
+ lookupSort(sorter: LookupSorter): void;
718
+ diff --git a/ui/styling/css-selector.js b/ui/styling/css-selector.js
719
+ index 702ca508f27ace527938860dfe4b13dbcbb93c2f..b6fa55a9570d4ed0714f053301bbe69efbd6900c 100644
720
+ --- a/ui/styling/css-selector.js
721
+ +++ b/ui/styling/css-selector.js
722
+ @@ -1081,9 +1081,27 @@ export class StyleSheetSelectorScope extends SelectorScope {
723
+ return matchSelectorCandidates(node, this.collectCandidates(node));
724
+ }
725
+ }
726
+ -/** Cascade order: specificity, then source order - (tier, position) across stylesheets. */
727
+ +/**
728
+ + * Cascade layers order before specificity: rules in an earlier-declared layer lose
729
+ + * to rules in a later-declared layer regardless of specificity, and unlayered
730
+ + * rules (absent rank at a depth) beat every layered rule.
731
+ + */
732
+ +function compareLayerPaths(a, b) {
733
+ + const aLength = a?.length ?? 0;
734
+ + const bLength = b?.length ?? 0;
735
+ + const length = Math.max(aLength, bLength);
736
+ + for (let i = 0; i < length; i++) {
737
+ + const rankA = i < aLength ? a[i] : Number.POSITIVE_INFINITY;
738
+ + const rankB = i < bLength ? b[i] : Number.POSITIVE_INFINITY;
739
+ + if (rankA !== rankB) {
740
+ + return rankA - rankB;
741
+ + }
742
+ + }
743
+ + return 0;
744
+ +}
745
+ +/** Cascade order: cascade layer, then specificity, then source order - (tier, position) across stylesheets. */
746
+ function compareSelectors(a, b) {
747
+ - return a.specificity - b.specificity || a.tier - b.tier || a.pos - b.pos;
748
+ + return compareLayerPaths(a.ruleset?.layerPath, b.ruleset?.layerPath) || a.specificity - b.specificity || a.tier - b.tier || a.pos - b.pos;
749
+ }
750
+ /**
751
+ * Resolve collected candidates against a node, compacting the array in place.
752
+ diff --git a/ui/styling/css-transform.d.ts b/ui/styling/css-transform.d.ts
753
+ index bf6a93847dc04ddf6d91a7912b033ab2ba93659e..b9a1e13824ec36c871c72acc53bdf3ff2de70180 100644
754
+ --- a/ui/styling/css-transform.d.ts
755
+ +++ b/ui/styling/css-transform.d.ts
756
+ @@ -1,2 +1,5 @@
757
+ import { TransformFunctionsInfo } from '../animation/animation-types';
758
+ +import type { CoreTypes } from '../../core-types';
759
+ export declare function transformConverter(text: string): TransformFunctionsInfo;
760
+ +export declare function isPercentTranslate(value: CoreTypes.PercentLengthType): boolean;
761
+ +export declare function resolveTranslate(value: CoreTypes.PercentLengthType, basis: number): CoreTypes.dip;
762
+ diff --git a/ui/styling/css-transform.js b/ui/styling/css-transform.js
763
+ index 181e6e370d64d1b18bf867eec6d3af4b3f7612b1..35ac4c45a7295cb3603b8c7781013890a6f472bd 100644
764
+ --- a/ui/styling/css-transform.js
765
+ +++ b/ui/styling/css-transform.js
766
+ @@ -1,3 +1,5 @@
767
+ +import { PercentLength } from './length-shared';
768
+ +import { layout } from '../../utils/layout-helper';
769
+ import { radiansToDegrees } from '../../utils/number-utils';
770
+ import { decompose2DTransformMatrix, getTransformMatrix, matrixArrayToCssMatrix, multiplyAffine2d } from '../../matrix';
771
+ import { hasDuplicates } from '../../utils';
772
+ @@ -8,6 +10,7 @@ const IDENTITY_TRANSFORMATION = {
773
+ };
774
+ const TRANSFORM_SPLITTER = new RegExp(/\s*(.+?)\((.*?)\)/g);
775
+ const TRANSFORMATIONS = Object.freeze(['rotate', 'rotateX', 'rotateY', 'rotate3d', 'translate', 'translate3d', 'translateX', 'translateY', 'scale', 'scale3d', 'scaleX', 'scaleY']);
776
+ +const TRANSLATE_TRANSFORMATIONS = Object.freeze(['translate', 'translate3d', 'translateX', 'translateY']);
777
+ const STYLE_TRANSFORMATION_MAP = Object.freeze({
778
+ scale: (value) => ({ property: 'scale', value }),
779
+ scale3d: (value) => ({ property: 'scale', value }),
780
+ @@ -60,7 +63,18 @@ export function transformConverter(text) {
781
+ if (text === 'none' || text === '' || !transformations.length) {
782
+ return IDENTITY_TRANSFORMATION;
783
+ }
784
+ - const usedTransforms = transformations.map((t) => t.property);
785
+ + let usedTransforms = transformations.map((t) => t.property);
786
+ + if (hasDuplicates(usedTransforms)) {
787
+ + // Percent translate values can't be resolved to a concrete value at
788
+ + // parse time (they depend on the view's size), so duplicate translate
789
+ + // functions are merged axis-wise instead of going through the matrix
790
+ + // multiplication below.
791
+ + const duplicated = usedTransforms.filter((property, index) => usedTransforms.indexOf(property) !== index);
792
+ + if (duplicated.every((property) => property === 'translate')) {
793
+ + mergeTranslateTransformations(transformations);
794
+ + usedTransforms = transformations.map((t) => t.property);
795
+ + }
796
+ + }
797
+ if (!hasDuplicates(usedTransforms)) {
798
+ const fullTransformations = { ...IDENTITY_TRANSFORMATION };
799
+ transformations.forEach((transform) => {
800
+ @@ -68,10 +82,39 @@ export function transformConverter(text) {
801
+ });
802
+ return fullTransformations;
803
+ }
804
+ - const affineMatrix = transformations.map(getTransformMatrix).reduce(multiplyAffine2d);
805
+ + const affineMatrix = transformations.map(normalizeTransformation).map(getTransformMatrix).reduce(multiplyAffine2d);
806
+ const cssMatrix = matrixArrayToCssMatrix(affineMatrix);
807
+ return decompose2DTransformMatrix(cssMatrix);
808
+ }
809
+ +/**
810
+ + * Whether a translate value is a percentage that has to be resolved
811
+ + * against the element's own size.
812
+ + */
813
+ +export function isPercentTranslate(value) {
814
+ + return typeof value === 'object' && value !== null && value.unit === '%';
815
+ +}
816
+ +/**
817
+ + * Resolves a translate axis value to dips. Percentage units are resolved
818
+ + * against the given basis, which is the element's own size along that axis.
819
+ + * @param value The translate axis value as a PercentLengthType.
820
+ + * @param basis The element's size in dips along the translated axis.
821
+ + */
822
+ +export function resolveTranslate(value, basis) {
823
+ + if (typeof value === 'number') {
824
+ + return value;
825
+ + }
826
+ + if (typeof value !== 'object' || value === null) {
827
+ + return 0;
828
+ + }
829
+ + switch (value.unit) {
830
+ + case 'px':
831
+ + return layout.toDeviceIndependentPixels(value.value);
832
+ + case '%':
833
+ + return basis * value.value;
834
+ + default:
835
+ + return value.value;
836
+ + }
837
+ +}
838
+ function isTransformType(propertyName) {
839
+ return TRANSFORMATIONS.indexOf(propertyName) !== -1;
840
+ }
841
+ @@ -91,20 +134,78 @@ function parseTransformString(text) {
842
+ return matches;
843
+ }
844
+ function convertTransformValue(property, rawValue) {
845
+ + if (property === 'rotate' || property === 'rotateX' || property === 'rotateY') {
846
+ + const x = parseFloat(rawValue);
847
+ + return rawValue.slice(-3) === 'rad' ? radiansToDegrees(x) : x;
848
+ + }
849
+ + if (TRANSLATE_TRANSFORMATIONS.indexOf(property) !== -1) {
850
+ + const values = rawValue.split(',').map(PercentLength.parse);
851
+ + const x = values[0];
852
+ + const y = property === 'translate' ? (values[1] ?? IDENTITY_TRANSFORMATION.translate.y) : (values[1] ?? x);
853
+ + return { x, y };
854
+ + }
855
+ const values = rawValue.split(',').map(parseFloat);
856
+ const x = values[0];
857
+ - let y = values[1];
858
+ - let z = values[2];
859
+ - if (property === 'translate') {
860
+ - y ?? (y = IDENTITY_TRANSFORMATION.translate.y);
861
+ + const y = values[1] ?? x;
862
+ + const z = values[2] ?? y;
863
+ + return { x, y, z };
864
+ +}
865
+ +function mergeTranslateTransformations(transformations) {
866
+ + const xValues = [];
867
+ + const yValues = [];
868
+ + for (let i = transformations.length - 1; i >= 0; i--) {
869
+ + const transformation = transformations[i];
870
+ + if (transformation.property === 'translate') {
871
+ + const value = transformation.value;
872
+ + xValues.unshift(value.x);
873
+ + yValues.unshift(value.y);
874
+ + transformations.splice(i, 1);
875
+ + }
876
+ }
877
+ - else {
878
+ - y ?? (y = x);
879
+ - z ?? (z = y);
880
+ + transformations.unshift({ property: 'translate', value: { x: mergeTranslateAxis(xValues), y: mergeTranslateAxis(yValues) } });
881
+ +}
882
+ +function mergeTranslateAxis(values) {
883
+ + const nonZero = values.filter((value) => !isZeroTranslate(value));
884
+ + if (nonZero.length === 0) {
885
+ + return 0;
886
+ }
887
+ - if (property === 'rotate' || property === 'rotateX' || property === 'rotateY') {
888
+ - return rawValue.slice(-3) === 'rad' ? radiansToDegrees(x) : x;
889
+ + if (nonZero.length === 1) {
890
+ + return nonZero[0];
891
+ }
892
+ - return { x, y, z };
893
+ + // Values in the same unit can be summed without losing the unit.
894
+ + const unit = typeof nonZero[0] === 'object' && nonZero[0] !== null ? nonZero[0].unit : null;
895
+ + if (unit !== null && nonZero.every((value) => typeof value === 'object' && value !== null && value.unit === unit)) {
896
+ + return { unit, value: nonZero.reduce((sum, value) => sum + value.value, 0) };
897
+ + }
898
+ + // Mixed units can't be combined into a single static value; coerce them
899
+ + // to their numeric value like the old parseFloat-based parsing did.
900
+ + return nonZero.reduce((sum, value) => sum + translateValueToNumber(value), 0);
901
+ +}
902
+ +function isZeroTranslate(value) {
903
+ + if (typeof value === 'number') {
904
+ + return value === 0;
905
+ + }
906
+ + if (typeof value !== 'object' || value === null) {
907
+ + return true;
908
+ + }
909
+ + return value.value === 0;
910
+ +}
911
+ +function translateValueToNumber(value) {
912
+ + if (typeof value === 'number') {
913
+ + return value;
914
+ + }
915
+ + if (typeof value !== 'object' || value === null) {
916
+ + return 0;
917
+ + }
918
+ + // A % value stores its fraction (e.g. -50% => -0.5); the pre-unit-aware
919
+ + // parser produced the raw number (-50), which matrix composition keeps.
920
+ + return value.unit === '%' ? value.value * 100 : value.value;
921
+ +}
922
+ +function normalizeTransformation(transformation) {
923
+ + if (transformation.property === 'translate') {
924
+ + const { x, y } = transformation.value;
925
+ + return { property: 'translate', value: { x: translateValueToNumber(x), y: translateValueToNumber(y) } };
926
+ + }
927
+ + return transformation;
928
+ }
929
+ //# sourceMappingURL=css-transform.js.map
930
+
931
+ diff --git a/ui/styling/font.android.js b/ui/styling/font.android.js
932
+ index a275f112af0ef85433c983cbce31f043b3aa7599..c270115eeb24a2fbf4d33eea08e6dca8fbd5df4e 100644
933
+ --- a/ui/styling/font.android.js
934
+ +++ b/ui/styling/font.android.js
935
+ @@ -38,7 +38,7 @@ export class Font extends FontBase {
936
+ Font.default = new Font(undefined, undefined);
937
+ function computeFontCacheKey(fontFamily, font) {
938
+ const sep = ':';
939
+ - return [fontFamily, String(FontVariationSettings.toString(font.fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_')].join(sep);
940
+ + return [fontFamily, String(getNumericFontWeight(font.fontWeight)), String(FontVariationSettings.toString(font.fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_')].join(sep);
941
+ }
942
+ function loadFontFromFile(fontFamily, font) {
943
+ const cacheKey = SDK_VERSION >= 26 ? computeFontCacheKey(fontFamily, font) : fontFamily;
944
+ @@ -71,8 +71,26 @@ function loadFontFromFile(fontFamily, font) {
945
+ if (SDK_VERSION >= 26) {
946
+ const builder = new android.graphics.Typeface.Builder(fontAssetPath);
947
+ if (builder) {
948
+ - builder.setFontVariationSettings(font.fontVariationSettings?.length ? FontVariationSettings.toString(font.fontVariationSettings) : '');
949
+ - result = builder.build();
950
+ + const explicitSettings = FontVariationSettings.toString(font.fontVariationSettings) || '';
951
+ + const variationSettings = font.fontVariationSettings?.length ? [...font.fontVariationSettings] : [];
952
+ + const hasWeightAxis = variationSettings.some(({ axis }) => axis.toLowerCase() === 'wght');
953
+ + if (!hasWeightAxis) {
954
+ + variationSettings.push({ axis: 'wght', value: getNumericFontWeight(font.fontWeight) });
955
+ + }
956
+ + try {
957
+ + builder.setFontVariationSettings(FontVariationSettings.toString(variationSettings) || '');
958
+ + result = builder.build();
959
+ + }
960
+ + catch (e) {
961
+ + if (hasWeightAxis) {
962
+ + throw e;
963
+ + }
964
+ + }
965
+ + if (!result && !hasWeightAxis) {
966
+ + const fallbackBuilder = new android.graphics.Typeface.Builder(fontAssetPath);
967
+ + fallbackBuilder.setFontVariationSettings(explicitSettings);
968
+ + result = fallbackBuilder.build();
969
+ + }
970
+ }
971
+ else {
972
+ result = android.graphics.Typeface.createFromFile(fontAssetPath);
973
+ diff --git a/ui/styling/style/index.d.ts b/ui/styling/style/index.d.ts
974
+ index 6146930bd639001c4f27bc80cbf6237f0abb43bd..05259a5a3d4483900da37debea6a3fcbb48d02d2 100644
975
+ --- a/ui/styling/style/index.d.ts
976
+ +++ b/ui/styling/style/index.d.ts
977
+ @@ -52,8 +52,8 @@ export declare class Style extends Observable {
978
+ perspective: number;
979
+ scaleX: number;
980
+ scaleY: number;
981
+ - translateX: CoreTypes.dip;
982
+ - translateY: CoreTypes.dip;
983
+ + translateX: CoreTypes.PercentLengthType;
984
+ + translateY: CoreTypes.PercentLengthType;
985
+ clipPath: string | ClipPathFunction;
986
+ color: Color;
987
+ tintColor: Color;
988
+ diff --git a/ui/styling/style-properties.d.ts b/ui/styling/style-properties.d.ts
989
+ index 4d4b15f1397bca6403029acb6615a40f872419b9..6c930a1de6e3f4d28371f94e9eb7fcb57d0df4dd 100644
990
+ --- a/ui/styling/style-properties.d.ts
991
+ +++ b/ui/styling/style-properties.d.ts
992
+ @@ -31,8 +31,8 @@ export declare const rotateYProperty: CssAnimationProperty<Style, number>;
993
+ export declare const perspectiveProperty: CssAnimationProperty<Style, number>;
994
+ export declare const scaleXProperty: CssAnimationProperty<Style, number>;
995
+ export declare const scaleYProperty: CssAnimationProperty<Style, number>;
996
+ -export declare const translateXProperty: CssAnimationProperty<Style, CoreTypes.FixedLengthType>;
997
+ -export declare const translateYProperty: CssAnimationProperty<Style, CoreTypes.FixedLengthType>;
998
+ +export declare const translateXProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
999
+ +export declare const translateYProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
1000
+ export declare const backgroundInternalProperty: CssProperty<Style, Background>;
1001
+ export declare const backgroundImageProperty: CssProperty<Style, string | LinearGradient>;
1002
+ export declare const backgroundColorProperty: CssAnimationProperty<Style, Color>;
1003
+ diff --git a/ui/styling/style-properties.js b/ui/styling/style-properties.js
1004
+ index 0f34471ac6f2fa146dafdd23e3c4290864c11c1b..95214a3c4ff5a40eff8af44e61888db02e78d448 100644
1005
+ --- a/ui/styling/style-properties.js
1006
+ +++ b/ui/styling/style-properties.js
1007
+ @@ -6,7 +6,7 @@ import { Font, parseFont, FontStyle, FontWeight, FontVariationSettings } from '.
1008
+ import { Background } from './background';
1009
+ import { Trace } from '../../trace';
1010
+ import { CoreTypes } from '../../core-types';
1011
+ -import { Length, FixedLength, PercentLength } from './length-shared';
1012
+ +import { Length, PercentLength } from './length-shared';
1013
+ import { parseBackground } from '../../css/parser';
1014
+ import { LinearGradient } from './linear-gradient';
1015
+ import { parseCSSShadow } from './css-shadow';
1016
+ @@ -564,16 +564,16 @@ export const translateXProperty = new CssAnimationProperty({
1017
+ name: 'translateX',
1018
+ cssName: 'translateX',
1019
+ defaultValue: 0,
1020
+ - equalityComparer: FixedLength.equals,
1021
+ - valueConverter: FixedLength.parse,
1022
+ + equalityComparer: PercentLength.equals,
1023
+ + valueConverter: PercentLength.parse,
1024
+ });
1025
+ translateXProperty.register(Style);
1026
+ export const translateYProperty = new CssAnimationProperty({
1027
+ name: 'translateY',
1028
+ cssName: 'translateY',
1029
+ defaultValue: 0,
1030
+ - equalityComparer: FixedLength.equals,
1031
+ - valueConverter: FixedLength.parse,
1032
+ + equalityComparer: PercentLength.equals,
1033
+ + valueConverter: PercentLength.parse,
1034
+ });
1035
+ translateYProperty.register(Style);
1036
+ const transformProperty = new ShorthandProperty({
1037
+ @@ -589,7 +589,7 @@ const transformProperty = new ShorthandProperty({
1038
+ const rotateY = this.rotateY;
1039
+ let result = '';
1040
+ if (translateX !== 0 || translateY !== 0) {
1041
+ - result += `translate(${translateX}, ${translateY}) `;
1042
+ + result += `translate(${PercentLength.convertToString(translateX)}, ${PercentLength.convertToString(translateY)}) `;
1043
+ }
1044
+ if (scaleX !== 1 || scaleY !== 1) {
1045
+ result += `scale(${scaleX}, ${scaleY}) `;
1046
+ diff --git a/ui/styling/style-scope.d.ts b/ui/styling/style-scope.d.ts
1047
+ index d6f026616cc33cf02f312a5e4f3b6effd71b5dda..321217d036b2fc726c88bf2076d82dcc62e6917e 100644
1048
+ --- a/ui/styling/style-scope.d.ts
1049
+ +++ b/ui/styling/style-scope.d.ts
1050
+ @@ -8,7 +8,7 @@ import { Keyframes, KeyframeAnimationInfo, KeyframeAnimation } from '../animatio
1051
+ */
1052
+ export declare function mergeCssSelectors(): void;
1053
+ export declare function mergeCssKeyframes(): void;
1054
+ -export declare function _populateRules(nodes: ReworkCSS.Node[], rulesets: RuleSet[], keyframes: Keyframes[], mediaQueryString?: string | string[]): void;
1055
+ +export declare function _populateRules(nodes: ReworkCSS.Node[], rulesets: RuleSet[], keyframes: Keyframes[], mediaQueryString?: string | string[], layerPath?: number[], layerPrefix?: string): void;
1056
+ export declare function removeTaggedAdditionalCSS(tag: string | number): boolean;
1057
+ export declare function addTaggedAdditionalCSS(cssText: string, tag?: string | number): boolean;
1058
+ export declare const loadAppCSS: any;
1059
+ diff --git a/ui/styling/style-scope.js b/ui/styling/style-scope.js
1060
+ index e75c7c8010e23917a7138c7351243aab0bad1f49..7cf9244c0290a76b186c15f13cc94ca754dfa9bb 100644
1061
+ --- a/ui/styling/style-scope.js
1062
+ +++ b/ui/styling/style-scope.js
1063
+ @@ -344,6 +344,33 @@ __decorate([
1064
+ __metadata("design:paramtypes", [String, String]),
1065
+ __metadata("design:returntype", String)
1066
+ ], CSSSource, "resolveCSSPathFromURL", null);
1067
+ +// Cascade-layer registry: qualified name -> first-seen ordinal, shared across
1068
+ +// every stylesheet feeding the cascade (layer order is document-wide per spec).
1069
+ +// '~' synthesizes names for anonymous layers, which authors cannot reference —
1070
+ +// the char is illegal in a CSS ident, so they never collide with named layers.
1071
+ +const cascadeLayerOrdinals = new Map();
1072
+ +let cascadeLayerCount = 0;
1073
+ +let anonymousLayerCount = 0;
1074
+ +function layerOrdinal(name) {
1075
+ + let ordinal = cascadeLayerOrdinals.get(name);
1076
+ + if (ordinal === undefined) {
1077
+ + ordinal = cascadeLayerCount++;
1078
+ + cascadeLayerOrdinals.set(name, ordinal);
1079
+ + }
1080
+ + return ordinal;
1081
+ +}
1082
+ +// Rank path for `name` nested under the layer at prefixPath/prefixName. Dotted
1083
+ +// names register each ancestor on the way down, so a top-level `@layer a.b`
1084
+ +// refers to the same layer as `@layer a { @layer b }`.
1085
+ +function layerPathFor(name, prefixPath, prefixName) {
1086
+ + const path = [...prefixPath];
1087
+ + let qualified = prefixName;
1088
+ + for (const segment of name.split('.')) {
1089
+ + qualified = qualified ? `${qualified}.${segment}` : segment;
1090
+ + path.push(layerOrdinal(qualified));
1091
+ + }
1092
+ + return path;
1093
+ +}
1094
+ function populateRulesFromImports(nodes, rulesets, keyframes) {
1095
+ const imports = nodes.filter((r) => r.type === 'import');
1096
+ if (!imports.length) {
1097
+ @@ -354,6 +381,11 @@ function populateRulesFromImports(nodes, rulesets, keyframes) {
1098
+ const urlMatch = importItem && importItem.match(pattern);
1099
+ return urlMatch && urlMatch[2];
1100
+ };
1101
+ + const layerFromImportObject = (importObject) => {
1102
+ + const importItem = importObject['import'];
1103
+ + const layerMatch = importItem && importItem.match(/\blayer\b(?:\(\s*([^)]*?)\s*\))?/);
1104
+ + return layerMatch ? layerMatch[1] ?? '' : null;
1105
+ + };
1106
+ const sourceFromImportObject = (importObject) => importObject['position'] && importObject['position']['source'];
1107
+ const toUrlSourcePair = (importObject) => ({
1108
+ url: urlFromImportObject(importObject),
1109
+ @@ -361,17 +393,25 @@ function populateRulesFromImports(nodes, rulesets, keyframes) {
1110
+ });
1111
+ const getCssFile = ({ url, source }) => (source ? CSSSource.fromFileImport(url, source) : CSSSource.fromURI(url));
1112
+ const cssFiles = imports
1113
+ - .map(toUrlSourcePair)
1114
+ + .map((importObject) => ({ ...toUrlSourcePair(importObject), layer: layerFromImportObject(importObject) }))
1115
+ .filter(({ url }) => !!url)
1116
+ - .map(getCssFile);
1117
+ - for (const cssFile of cssFiles) {
1118
+ + .map(({ url, source, layer }) => ({ cssFile: getCssFile({ url, source }), layer }));
1119
+ + for (const { cssFile, layer } of cssFiles) {
1120
+ if (cssFile) {
1121
+ + if (layer !== null) {
1122
+ + // @import "x.css" layer(name) — the imported sheet joins the named
1123
+ + // layer; its own layers become nested sublayers of it.
1124
+ + const importPath = [layerOrdinal(layer.trim() || `~import-${anonymousLayerCount++}`)];
1125
+ + for (const ruleset of cssFile.selectors) {
1126
+ + ruleset.layerPath = [...importPath, ...(ruleset.layerPath ?? [])];
1127
+ + }
1128
+ + }
1129
+ rulesets.push(...cssFile.selectors);
1130
+ keyframes.push(...cssFile.keyframes);
1131
+ }
1132
+ }
1133
+ }
1134
+ -export function _populateRules(nodes, rulesets, keyframes, mediaQueryString) {
1135
+ +export function _populateRules(nodes, rulesets, keyframes, mediaQueryString, layerPath, layerPrefix) {
1136
+ for (const node of nodes) {
1137
+ if (isKeyframe(node)) {
1138
+ const keyframeRule = {
1139
+ @@ -396,11 +436,32 @@ export function _populateRules(nodes, rulesets, keyframes, mediaQueryString) {
1140
+ else {
1141
+ compositeMediaQuery = node.media;
1142
+ }
1143
+ - _populateRules(node.rules, rulesets, keyframes, compositeMediaQuery);
1144
+ + _populateRules(node.rules, rulesets, keyframes, compositeMediaQuery, layerPath, layerPrefix);
1145
+ + }
1146
+ + else if (isLayer(node)) {
1147
+ + const name = (node.layer ?? '').trim();
1148
+ + if (node.rules) {
1149
+ + // Block at-rule: a single name, or anonymous when the prelude is empty.
1150
+ + const qualified = name ? (layerPrefix ? `${layerPrefix}.${name}` : name) : `${layerPrefix ?? ''}~${anonymousLayerCount++}`;
1151
+ + const childPath = name ? layerPathFor(name, layerPath ?? [], layerPrefix ?? '') : [...(layerPath ?? []), layerOrdinal(qualified)];
1152
+ + _populateRules(node.rules, rulesets, keyframes, mediaQueryString, childPath, qualified);
1153
+ + }
1154
+ + else {
1155
+ + // Statement at-rule: `@layer a, b;` pre-declares order only.
1156
+ + for (const declared of name.split(',')) {
1157
+ + const declaredName = declared.trim();
1158
+ + if (declaredName) {
1159
+ + layerPathFor(declaredName, layerPath ?? [], layerPrefix ?? '');
1160
+ + }
1161
+ + }
1162
+ + }
1163
+ }
1164
+ else if (isRule(node)) {
1165
+ const ruleset = fromAstNode(node);
1166
+ ruleset.mediaQueryString = mediaQueryString;
1167
+ + if (layerPath?.length) {
1168
+ + ruleset.layerPath = layerPath;
1169
+ + }
1170
+ rulesets.push(ruleset);
1171
+ }
1172
+ }
1173
+ @@ -1263,6 +1324,9 @@ function isMedia(node) {
1174
+ function isKeyframe(node) {
1175
+ return node.type === 'keyframes';
1176
+ }
1177
+ +function isLayer(node) {
1178
+ + return node.type === 'layer';
1179
+ +}
1180
+ function isRule(node) {
1181
+ return node.type === 'rule';
1182
+ }
1183
+ diff --git a/ui/styling/font.ios.js b/ui/styling/font.ios.js
1184
+ index 31fd457fd1929618042db5c35ca687e23b0c05d7..8938d4224a86a996e21f7217d8785547214d5cbd 100644
1185
+ --- a/ui/styling/font.ios.js
1186
+ +++ b/ui/styling/font.ios.js
1187
+ @@ -4,9 +4,9 @@ import { File, Folder, knownFolders, path } from '../../file-system';
1188
+ export { FontStyle, FontWeight, FontVariationSettings, parseFont } from './font-common';
1189
+ const uiFontCache = new Map();
1190
+ function computeFontCacheKey(fontDescriptor) {
1191
+ - const { fontFamily, fontSize, fontWeight, fontVariationSettings, isBold, isItalic } = fontDescriptor;
1192
+ + const { fontFamily, fontSize, fontWeight, cssFontWeight, fontVariationSettings, isBold, isItalic } = fontDescriptor;
1193
+ const sep = ':';
1194
+ - return [fontFamily.join(sep), fontSize, fontWeight, String(FontVariationSettings.toString(fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_'), isBold, isItalic].join(sep);
1195
+ + return [fontFamily.join(sep), fontSize, fontWeight, cssFontWeight, String(FontVariationSettings.toString(fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_'), isBold, isItalic].join(sep);
1196
+ }
1197
+ function getUIFontCached(fontDescriptor) {
1198
+ const cacheKey = computeFontCacheKey(fontDescriptor);
1199
+ @@ -17,25 +17,38 @@ function getUIFontCached(fontDescriptor) {
1200
+ return uiFontCache.get(cacheKey);
1201
+ }
1202
+ let uiFont = NativeScriptUtils.createUIFont(fontDescriptor);
1203
+ - if (fontDescriptor.fontVariationSettings?.length) {
1204
+ - let font = CGFontCreateWithFontName(uiFont.fontName);
1205
+ - const variationAxes = CGFontCopyVariationAxes(font);
1206
+ - // This can be null if font doesn't support axes
1207
+ - if (variationAxes?.count) {
1208
+ - const variationSettings = NSMutableDictionary.new();
1209
+ - const variationAxesCount = variationAxes.count;
1210
+ - const variationAxesNames = [];
1211
+ - for (let i = 0, length = variationAxes.count; i < length; i++) {
1212
+ - variationAxesNames.push(String(variationAxes[i].objectForKey('kCGFontVariationAxisName')));
1213
+ - }
1214
+ - for (const variationSetting of fontDescriptor.fontVariationSettings) {
1215
+ - const axisName = fuzzySearch(variationSetting.axis, variationAxesNames);
1216
+ - if (axisName?.length) {
1217
+ - variationSettings.setValueForKey(variationSetting.value, axisName[0]);
1218
+ - }
1219
+ + // Resolve axes after the native CSS cascade has produced this Font. Keep
1220
+ + // derived coordinates out of the authored/inherited variation settings.
1221
+ + const axes = CTFontCopyVariationAxes(uiFont);
1222
+ + if (axes?.count) {
1223
+ + const variations = NSMutableDictionary.new();
1224
+ + const current = CTFontCopyVariation(uiFont);
1225
+ + if (current) {
1226
+ + variations.addEntriesFromDictionary(current);
1227
+ + }
1228
+ + let changed = false;
1229
+ + const settings = fontDescriptor.fontVariationSettings || [];
1230
+ + for (let index = 0; index < axes.count; index++) {
1231
+ + const axis = axes.objectAtIndex(index);
1232
+ + const identifier = Number(axis.objectForKey(kCTFontVariationAxisIdentifierKey));
1233
+ + const tag = String.fromCharCode(identifier >>> 24, (identifier >>> 16) & 255, (identifier >>> 8) & 255, identifier & 255);
1234
+ + const name = String(axis.objectForKey(kCTFontVariationAxisNameKey));
1235
+ + const explicit = settings.find((setting) => setting.axis.toLowerCase() === tag.toLowerCase())
1236
+ + || settings.find((setting) => fuzzySearch(setting.axis, [name]).length > 0);
1237
+ + const value = explicit ? explicit.value : tag === 'wght' ? fontDescriptor.cssFontWeight : undefined;
1238
+ + if (value === undefined) {
1239
+ + continue;
1240
+ }
1241
+ - font = CGFontCreateCopyWithVariations(font, variationSettings);
1242
+ - uiFont = CTFontCreateWithGraphicsFont(font, fontDescriptor.fontSize, null, null);
1243
+ + const minimum = Number(axis.objectForKey(kCTFontVariationAxisMinimumValueKey));
1244
+ + const maximum = Number(axis.objectForKey(kCTFontVariationAxisMaximumValueKey));
1245
+ + variations.setObjectForKey(Math.max(minimum, Math.min(maximum, value)), identifier);
1246
+ + changed = true;
1247
+ + }
1248
+ + if (changed) {
1249
+ + // Copy the resolved font so family, italic transforms and other
1250
+ + // selected coordinates survive the weight adjustment.
1251
+ + const descriptor = UIFontDescriptor.fontDescriptorWithFontAttributes({ [kCTFontVariationAttribute]: variations });
1252
+ + uiFont = CTFontCreateCopyWithAttributes(uiFont, fontDescriptor.fontSize, null, descriptor);
1253
+ }
1254
+ }
1255
+ uiFontCache.set(cacheKey, uiFont);
1256
+ @@ -72,6 +85,7 @@ export class Font extends FontBase {
1257
+ // Apply a11y scale and calculate proper font size (avoid applying multiplier to native point size as it's messing calculations)
1258
+ fontSize: this.fontSize ? this.fontSize * this.fontScale : defaultFont.pointSize,
1259
+ fontWeight: getNativeFontWeight(this.fontWeight),
1260
+ + cssFontWeight: getNumericFontWeight(this.fontWeight),
1261
+ fontVariationSettings: this.fontVariationSettings,
1262
+ isBold: this.isBold,
1263
+ isItalic: this.isItalic,
1264
+ @@ -82,6 +96,16 @@ export class Font extends FontBase {
1265
+ }
1266
+ }
1267
+ Font.default = new Font(undefined, undefined);
1268
+ +function getNumericFontWeight(weight) {
1269
+ + if (weight == null || weight === FontWeight.NORMAL) {
1270
+ + return 400;
1271
+ + }
1272
+ + if (weight === FontWeight.BOLD) {
1273
+ + return 700;
1274
+ + }
1275
+ + const numeric = Number(weight);
1276
+ + return Number.isFinite(numeric) ? numeric : 400;
1277
+ +}
1278
+ function getNativeFontWeight(fontWeight) {
1279
+ const value = typeof fontWeight === 'number' ? fontWeight + '' : fontWeight;
1280
+ switch (value) {