@octane-xplat/nativescript-mason-core 0.0.1 → 1.0.0-beta.1

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 (194) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +198 -2
  3. package/artifact-inventory.json +774 -0
  4. package/box-shadow.d.ts +10 -0
  5. package/box-shadow.js +48 -0
  6. package/common.d.ts +485 -0
  7. package/common.js +2659 -0
  8. package/css-colors.d.ts +17 -0
  9. package/css-colors.js +54 -0
  10. package/css-environment.d.ts +49 -0
  11. package/css-environment.js +309 -0
  12. package/css-filter.d.ts +17 -0
  13. package/css-filter.js +140 -0
  14. package/css-keyframes.d.ts +41 -0
  15. package/css-keyframes.js +437 -0
  16. package/css-math.d.ts +34 -0
  17. package/css-math.js +300 -0
  18. package/css-shorthands.d.ts +65 -0
  19. package/css-shorthands.js +673 -0
  20. package/css-transform.d.ts +6 -0
  21. package/css-transform.js +100 -0
  22. package/diagnostics.d.ts +51 -0
  23. package/diagnostics.js +52 -0
  24. package/display-density.d.ts +9 -0
  25. package/display-density.js +20 -0
  26. package/fonts.d.ts +20 -0
  27. package/fonts.js +88 -0
  28. package/foreign-layout.d.ts +6 -0
  29. package/foreign-layout.js +151 -0
  30. package/gradient-stops.d.ts +25 -0
  31. package/gradient-stops.js +112 -0
  32. package/index.android.d.ts +11 -0
  33. package/index.android.js +9 -0
  34. package/index.d.ts +12 -0
  35. package/index.ios.d.ts +11 -0
  36. package/index.ios.js +9 -0
  37. package/ios-host-README.md +124 -0
  38. package/layout-types.d.ts +192 -0
  39. package/mask.d.ts +54 -0
  40. package/mask.js +26 -0
  41. package/native-environment.android.d.ts +3 -0
  42. package/native-environment.android.js +69 -0
  43. package/native-environment.d.ts +3 -0
  44. package/native-environment.ios.d.ts +3 -0
  45. package/native-environment.ios.js +65 -0
  46. package/native-types-README.md +51 -0
  47. package/package.json +47 -6
  48. package/panel-helpers.d.ts +3 -0
  49. package/panel-helpers.js +8 -0
  50. package/platforms/android/MasonCore.aar +0 -0
  51. package/platforms/android/include.gradle +6 -0
  52. package/platforms/android/manifest.json +73 -0
  53. package/platforms/ios/FontManager.LICENSE +201 -0
  54. package/platforms/ios/MasonCore.xcframework/Info.plist +43 -0
  55. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/Mason.h +25 -0
  56. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
  57. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/mason_native.h +601 -0
  58. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Info.plist +0 -0
  59. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/MasonCore +0 -0
  60. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  61. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.abi.json +100095 -0
  62. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.private.swiftinterface +3174 -0
  63. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  64. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftinterface +3174 -0
  65. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/module.modulemap +9 -0
  66. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
  67. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
  68. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/Mason.h +25 -0
  69. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
  70. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/mason_native.h +601 -0
  71. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Info.plist +0 -0
  72. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/MasonCore +0 -0
  73. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  74. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.abi.json +100095 -0
  75. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3174 -0
  76. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  77. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3174 -0
  78. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/module.modulemap +9 -0
  79. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
  80. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
  81. package/platforms/ios/Package.resolved +24 -0
  82. package/platforms/ios/SDWebImage.LICENSE +20 -0
  83. package/platforms/ios/build.xcconfig +4 -0
  84. package/platforms/ios/device-manifest.json +213 -0
  85. package/platforms/ios/include/FontManager/NSCFontDescriptors.h +36 -0
  86. package/platforms/ios/include/FontManager/NSCFontFace.h +98 -0
  87. package/platforms/ios/include/FontManager/NSCFontFaceSet.h +73 -0
  88. package/platforms/ios/include/FontManager/NSCFontManagerUmbrella.h +7 -0
  89. package/platforms/ios/include/FontManager/NSCFontParser.h +22 -0
  90. package/platforms/ios/include/FontManager/NSCFontRegex.h +4 -0
  91. package/platforms/ios/include/FontManager/NSCFontResolver.h +43 -0
  92. package/platforms/ios/include/FontManager/NSCFontStyle.h +27 -0
  93. package/platforms/ios/include/FontManager/NSCFontTypes.h +41 -0
  94. package/platforms/ios/include/SDWebImage/NSButton+WebCache.h +340 -0
  95. package/platforms/ios/include/SDWebImage/NSData+ImageContentType.h +63 -0
  96. package/platforms/ios/include/SDWebImage/NSImage+Compatibility.h +67 -0
  97. package/platforms/ios/include/SDWebImage/SDAnimatedImage.h +136 -0
  98. package/platforms/ios/include/SDWebImage/SDAnimatedImagePlayer.h +113 -0
  99. package/platforms/ios/include/SDWebImage/SDAnimatedImageRep.h +33 -0
  100. package/platforms/ios/include/SDWebImage/SDAnimatedImageView+WebCache.h +168 -0
  101. package/platforms/ios/include/SDWebImage/SDAnimatedImageView.h +125 -0
  102. package/platforms/ios/include/SDWebImage/SDCallbackQueue.h +59 -0
  103. package/platforms/ios/include/SDWebImage/SDDiskCache.h +146 -0
  104. package/platforms/ios/include/SDWebImage/SDGraphicsImageRenderer.h +84 -0
  105. package/platforms/ios/include/SDWebImage/SDImageAPNGCoder.h +19 -0
  106. package/platforms/ios/include/SDWebImage/SDImageAWebPCoder.h +23 -0
  107. package/platforms/ios/include/SDWebImage/SDImageCache.h +482 -0
  108. package/platforms/ios/include/SDWebImage/SDImageCacheConfig.h +153 -0
  109. package/platforms/ios/include/SDWebImage/SDImageCacheDefine.h +179 -0
  110. package/platforms/ios/include/SDWebImage/SDImageCachesManager.h +81 -0
  111. package/platforms/ios/include/SDWebImage/SDImageCoder.h +347 -0
  112. package/platforms/ios/include/SDWebImage/SDImageCoderHelper.h +251 -0
  113. package/platforms/ios/include/SDWebImage/SDImageCodersManager.h +58 -0
  114. package/platforms/ios/include/SDWebImage/SDImageFrame.h +44 -0
  115. package/platforms/ios/include/SDWebImage/SDImageGIFCoder.h +22 -0
  116. package/platforms/ios/include/SDWebImage/SDImageGraphics.h +28 -0
  117. package/platforms/ios/include/SDWebImage/SDImageHEICCoder.h +25 -0
  118. package/platforms/ios/include/SDWebImage/SDImageIOAnimatedCoder.h +65 -0
  119. package/platforms/ios/include/SDWebImage/SDImageIOCoder.h +30 -0
  120. package/platforms/ios/include/SDWebImage/SDImageLoader.h +146 -0
  121. package/platforms/ios/include/SDWebImage/SDImageLoadersManager.h +40 -0
  122. package/platforms/ios/include/SDWebImage/SDImageTransformer.h +283 -0
  123. package/platforms/ios/include/SDWebImage/SDMemoryCache.h +78 -0
  124. package/platforms/ios/include/SDWebImage/SDWebImage.h +91 -0
  125. package/platforms/ios/include/SDWebImage/SDWebImageCacheKeyFilter.h +35 -0
  126. package/platforms/ios/include/SDWebImage/SDWebImageCacheSerializer.h +39 -0
  127. package/platforms/ios/include/SDWebImage/SDWebImageCompat.h +102 -0
  128. package/platforms/ios/include/SDWebImage/SDWebImageDefine.h +420 -0
  129. package/platforms/ios/include/SDWebImage/SDWebImageDownloader.h +320 -0
  130. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderConfig.h +113 -0
  131. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderDecryptor.h +52 -0
  132. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderOperation.h +191 -0
  133. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderRequestModifier.h +72 -0
  134. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderResponseModifier.h +72 -0
  135. package/platforms/ios/include/SDWebImage/SDWebImageError.h +33 -0
  136. package/platforms/ios/include/SDWebImage/SDWebImageIndicator.h +119 -0
  137. package/platforms/ios/include/SDWebImage/SDWebImageManager.h +290 -0
  138. package/platforms/ios/include/SDWebImage/SDWebImageOperation.h +27 -0
  139. package/platforms/ios/include/SDWebImage/SDWebImageOptionsProcessor.h +78 -0
  140. package/platforms/ios/include/SDWebImage/SDWebImagePrefetcher.h +168 -0
  141. package/platforms/ios/include/SDWebImage/SDWebImageTransition.h +131 -0
  142. package/platforms/ios/include/SDWebImage/UIButton+WebCache.h +402 -0
  143. package/platforms/ios/include/SDWebImage/UIImage+ExtendedCacheData.h +24 -0
  144. package/platforms/ios/include/SDWebImage/UIImage+ForceDecode.h +52 -0
  145. package/platforms/ios/include/SDWebImage/UIImage+GIF.h +26 -0
  146. package/platforms/ios/include/SDWebImage/UIImage+MemoryCacheCost.h +27 -0
  147. package/platforms/ios/include/SDWebImage/UIImage+Metadata.h +104 -0
  148. package/platforms/ios/include/SDWebImage/UIImage+MultiFormat.h +81 -0
  149. package/platforms/ios/include/SDWebImage/UIImage+Transform.h +164 -0
  150. package/platforms/ios/include/SDWebImage/UIImageView+HighlightedWebCache.h +142 -0
  151. package/platforms/ios/include/SDWebImage/UIImageView+WebCache.h +209 -0
  152. package/platforms/ios/include/SDWebImage/UIView+WebCache.h +131 -0
  153. package/platforms/ios/include/SDWebImage/UIView+WebCacheOperation.h +52 -0
  154. package/platforms/ios/include/SDWebImage/UIView+WebCacheState.h +63 -0
  155. package/platforms/ios/include/module.modulemap +2 -0
  156. package/platforms/ios/manifest.json +132 -0
  157. package/platforms/ios/simulator-manifest.json +213 -0
  158. package/plugin-README.md +234 -0
  159. package/properties.d.ts +154 -0
  160. package/properties.js +2456 -0
  161. package/pseudo.d.ts +9 -0
  162. package/pseudo.js +57 -0
  163. package/scroll/index.android.d.ts +15 -0
  164. package/scroll/index.android.js +72 -0
  165. package/scroll/index.d.ts +5 -0
  166. package/scroll/index.ios.d.ts +18 -0
  167. package/scroll/index.ios.js +106 -0
  168. package/style.d.ts +768 -0
  169. package/style.js +7167 -0
  170. package/symbols.d.ts +25 -0
  171. package/symbols.js +41 -0
  172. package/tree/index.android.d.ts +11 -0
  173. package/tree/index.android.js +42 -0
  174. package/tree/index.d.ts +15 -0
  175. package/tree/index.ios.d.ts +26 -0
  176. package/tree/index.ios.js +53 -0
  177. package/typings/android-declarations.d.ts +4 -0
  178. package/typings/android.d.ts +9730 -0
  179. package/typings/manifest.json +45 -0
  180. package/typings/native.d.ts +5 -0
  181. package/typings/objc!FontManager.d.ts +389 -0
  182. package/typings/objc!MasonCore.d.ts +2472 -0
  183. package/typings/objc!SDWebImage.d.ts +3378 -0
  184. package/units.d.ts +29 -0
  185. package/units.js +44 -0
  186. package/utils/index.android.d.ts +211 -0
  187. package/utils/index.android.js +595 -0
  188. package/utils/index.ios.d.ts +222 -0
  189. package/utils/index.ios.js +790 -0
  190. package/view/index.android.d.ts +13 -0
  191. package/view/index.android.js +74 -0
  192. package/view/index.d.ts +2 -0
  193. package/view/index.ios.d.ts +24 -0
  194. package/view/index.ios.js +157 -0
package/common.js ADDED
@@ -0,0 +1,2659 @@
1
+ var _a, _b, _c, _d;
2
+ import { isCssEnvironmentShorthand } from './css-environment';
3
+ import { registerAutomaticCssEnvironment } from './css-environment';
4
+ import { nativeCssEnvironmentSource } from './native-environment';
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
7
+ import { CustomLayoutView, Utils, View as NSView, getViewById, widthProperty, heightProperty, marginLeftProperty, marginRightProperty, marginTopProperty, marginBottomProperty, minWidthProperty, minHeightProperty, fontSizeProperty, fontWeightProperty, fontStyleProperty, colorProperty, Color, lineHeightProperty, letterSpacingProperty, textAlignmentProperty, textDecorationProperty, borderLeftWidthProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, backgroundColorProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, paddingBottomProperty, zIndexProperty, directionProperty, PseudoClassHandler, } from '@nativescript/core';
8
+ import { alignItemsProperty, alignSelfProperty, flexDirectionProperty, flexGrowProperty, flexShrinkProperty, flexWrapProperty, justifyContentProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
9
+ // The per-corner radius and per-side colour longhands core's `border-radius`
10
+ // / `border-color` shorthands expand into. They live in the styling module
11
+ // rather than core's root export, unlike the border *width* longhands above.
12
+ import { backgroundInternalProperty, borderTopLeftRadiusProperty, borderTopRightRadiusProperty, borderBottomRightRadiusProperty, borderBottomLeftRadiusProperty, borderTopColorProperty, borderRightColorProperty, borderBottomColorProperty, borderLeftColorProperty } from '@nativescript/core/ui/styling/style-properties';
13
+ import { _forceStyleUpdate } from './utils';
14
+ import { borderRadiusCorners, composeBorderRadius, isCssLength, parseCornerRadius, toCamelCase } from './css-shorthands';
15
+ import { originXProperty, originYProperty } from '@nativescript/core/ui/core/view';
16
+ import { animateTransforms } from './css-keyframes';
17
+ import { adoptForeignLayout, invalidateOnLayoutRequest, releaseForeignLayout } from './foreign-layout';
18
+ import { Style, nodeHelper, cssLengthToDip, resolveCssMathIn } from './style';
19
+ import { encodeBoxShadows, parseBoxShadows } from './box-shadow';
20
+ import { parseCssTransform } from './css-transform';
21
+ import { alignContentProperty, aspectRatioProperty, backgroundProperty, borderRadiusProperty, bottomProperty, boxSizingProperty, clearProperty, columnGapProperty, cornerShapeProperty, displayProperty, filterProperty, flexBasisProperty, floatProperty, gridAreaProperty, gridAutoColumnsProperty, gridAutoFlowProperty, gridAutoRowsProperty, gridColumnEndProperty, gridColumnProperty, gridColumnStartProperty, gridRowEndProperty, gridRowProperty, gridRowStartProperty, gridTemplateAreasProperty, gridTemplateColumnsProperty, gridTemplateRowsProperty, justifyItemsProperty, justifySelfProperty, leftProperty, marginProperty, maxHeightProperty, maxWidthProperty, overflowXProperty, overflowYProperty, paddingProperty, positionProperty, rightProperty, rowGapProperty, scrollBarWidthProperty, textOverFlowProperty, textWrapProperty, topProperty, verticalAlignProperty, boxShadowProperty, transformProperty, borderColorProperty, borderTopStyleProperty, borderRightStyleProperty, borderBottomStyleProperty, borderLeftStyleProperty, backgroundImageProperty, listStyleTypeProperty, listStylePositionProperty, installMasonSizeUnits, masonRawDeclaration, } from './properties';
22
+ import { masonLayout } from './display-density';
23
+ import { isMasonView_, isTextChild_, isText_, isPlaceholder_, native_, pseudoStyles_, borderRadiusCorners_, borderSideColors_, eventType_, touchAction_ } from './symbols';
24
+ import { Tree } from './tree';
25
+ import { masonEngine } from './panel-helpers';
26
+ import { compile } from './pseudo';
27
+ function getViewStyle(view) {
28
+ const ret = (__ANDROID__ ? view.get() : view.deref());
29
+ return ret._styleHelper;
30
+ }
31
+ function getWeakRefValue(value) {
32
+ if (!value)
33
+ return null;
34
+ const maybeWeakRef = value;
35
+ if (typeof maybeWeakRef.get === 'function')
36
+ return maybeWeakRef.get();
37
+ if (typeof maybeWeakRef.deref === 'function')
38
+ return maybeWeakRef.deref();
39
+ return value;
40
+ }
41
+ function nativeOwnerFor(nativeView) {
42
+ return getWeakRefValue(nativeView?.__masonOwner);
43
+ }
44
+ function nativeViewFor(owner) {
45
+ return owner?.nativeViewProtected ?? owner?.[native_];
46
+ }
47
+ function masonNativeEventName(eventName) {
48
+ switch (eventName) {
49
+ case 'tap':
50
+ case 'click':
51
+ return 'click';
52
+ case 'beforeinput':
53
+ case 'input':
54
+ case 'change':
55
+ case 'cancel':
56
+ case 'compositionstart':
57
+ case 'compositionupdate':
58
+ case 'compositionend':
59
+ case 'focus':
60
+ case 'blur':
61
+ case 'keydown':
62
+ case 'scroll':
63
+ case 'scrollend':
64
+ return eventName;
65
+ default:
66
+ return null;
67
+ }
68
+ }
69
+ const SCROLL_POSITIONS = { start: 0, center: 1, end: 2, nearest: 3 };
70
+ // Scroll offsets and sizes are read from the native view on demand, in CSS pixels.
71
+ function nativeScrollOffset(view, vertical) {
72
+ const native = view[native_];
73
+ if (!native)
74
+ return 0;
75
+ if (__ANDROID__) {
76
+ const scroll = org.nativescript.mason.masonkit.WebScroll;
77
+ return masonLayout.toDeviceIndependentPixels(vertical ? scroll.scrollTop(native) : scroll.scrollLeft(native));
78
+ }
79
+ if (__APPLE__) {
80
+ return (vertical ? native.mason_scrollTop : native.mason_scrollLeft) ?? 0;
81
+ }
82
+ if (false) {
83
+ return (vertical ? masonEngine().ScrollTop(native) : masonEngine().ScrollLeft(native)) ?? 0;
84
+ }
85
+ return 0;
86
+ }
87
+ function nativeScrollMetric(view, metric) {
88
+ const native = view[native_];
89
+ if (!native)
90
+ return 0;
91
+ let value = 0;
92
+ if (__ANDROID__) {
93
+ value = masonLayout.toDeviceIndependentPixels(org.nativescript.mason.masonkit.WebScroll[metric](native));
94
+ }
95
+ else if (__APPLE__) {
96
+ value = native[`mason_${metric}`];
97
+ }
98
+ else if (false) {
99
+ value = masonEngine()[metric.charAt(0).toUpperCase() + metric.slice(1)](native);
100
+ }
101
+ // Whole pixels, as on the web.
102
+ return Math.round(value || 0);
103
+ }
104
+ /** NaN keeps an axis. Before the native view exists, the request is kept for `initNativeView`. */
105
+ function nativeScrollTo(view, left, top, smooth) {
106
+ const native = view[native_];
107
+ if (!native) {
108
+ const pending = (view._masonPendingScroll ?? (view._masonPendingScroll = { left: NaN, top: NaN, smooth }));
109
+ if (!isNaN(left))
110
+ pending.left = left;
111
+ if (!isNaN(top))
112
+ pending.top = top;
113
+ pending.smooth = smooth;
114
+ return;
115
+ }
116
+ if (__ANDROID__) {
117
+ org.nativescript.mason.masonkit.WebScroll.scrollTo(native, isNaN(left) ? NaN : masonLayout.toDevicePixels(left), isNaN(top) ? NaN : masonLayout.toDevicePixels(top), smooth);
118
+ }
119
+ else if (__APPLE__) {
120
+ native.mason_scrollTo(left, top, smooth);
121
+ }
122
+ else if (false) {
123
+ masonEngine().ScrollTo(native, left, top, smooth);
124
+ }
125
+ }
126
+ /** Non-finite scroll coordinates become 0, as on the web. */
127
+ function scrollCoordinate(value) {
128
+ const n = Number(value);
129
+ return Number.isFinite(n) ? n : 0;
130
+ }
131
+ function findOwnerForNativeView(owner, nativeView) {
132
+ if (!owner || !nativeView)
133
+ return null;
134
+ const ownNativeView = nativeViewFor(owner);
135
+ if (ownNativeView === nativeView || owner?.[native_] === nativeView)
136
+ return owner;
137
+ const children = owner._children ?? owner._viewChildren;
138
+ if (!children)
139
+ return null;
140
+ for (const child of children) {
141
+ const match = findOwnerForNativeView(child, nativeView);
142
+ if (match)
143
+ return match;
144
+ }
145
+ return null;
146
+ }
147
+ function masonLength(value) {
148
+ return isCssLength(value) && !isCssEnvironmentShorthand(value) ? value.css : value;
149
+ }
150
+ /** A core `Length` (number of dip, or `{ value, unit }`) as a CSS string. */
151
+ function lengthToCssString(value) {
152
+ if (value == null) {
153
+ return '0';
154
+ }
155
+ if (typeof value === 'string') {
156
+ return value;
157
+ }
158
+ if (typeof value === 'number') {
159
+ return `${value}px`;
160
+ }
161
+ const unit = value.unit;
162
+ const amount = value.value ?? 0;
163
+ return unit === '%' ? `${amount * 100}%` : `${amount}px`;
164
+ }
165
+ /**
166
+ * A core colour value as a CSS string. Duck-typed rather than
167
+ * `instanceof Color` on purpose: a `Color` can arrive from a different
168
+ * `@nativescript/core` copy, where `instanceof` fails.
169
+ */
170
+ function colorToCssString(value) {
171
+ if (value == null) {
172
+ return 'transparent';
173
+ }
174
+ if (typeof value === 'string') {
175
+ return value;
176
+ }
177
+ const hex = value.hex;
178
+ if (typeof hex === 'string') {
179
+ return hex;
180
+ }
181
+ return String(value);
182
+ }
183
+ function backgroundImageToCssString(value) {
184
+ const gradient = value;
185
+ if (value && typeof value === 'object' && typeof gradient.angle === 'number' && Array.isArray(gradient.colorStops)) {
186
+ const stops = gradient.colorStops.map((stop) => (stop.offset ? `${colorToCssString(stop.color)} ${stop.offset.value * 100}%` : colorToCssString(stop.color)));
187
+ return `linear-gradient(${gradient.angle}rad, ${stops.join(', ')})`;
188
+ }
189
+ return value == null ? 'none' : String(value);
190
+ }
191
+ // Windows raises no pressed state natively, so :active follows the pointer, as core's Button does.
192
+ const WINDOWS_ACTIVE_STATES = ['active', 'highlighted'];
193
+ function onWindowsActiveTouch(args) {
194
+ if (args.action === 'down') {
195
+ for (const state of WINDOWS_ACTIVE_STATES)
196
+ args.object._addVisualState(state);
197
+ }
198
+ else if (args.action === 'up' || args.action === 'cancel') {
199
+ clearWindowsActive(args.object);
200
+ }
201
+ }
202
+ // Core's touch gesture reports no cancel, and a release outside the view isn't delivered to it.
203
+ function onWindowsActiveLeave(args) {
204
+ clearWindowsActive(args.object);
205
+ }
206
+ function clearWindowsActive(view) {
207
+ for (const state of WINDOWS_ACTIVE_STATES)
208
+ view._removeVisualState(state);
209
+ }
210
+ function onWindowsHoverEnter(args) {
211
+ args.object._addVisualState('hover');
212
+ }
213
+ function onWindowsHoverLeave(args) {
214
+ args.object._removeVisualState('hover');
215
+ }
216
+ function onWindowsFocus() {
217
+ this._addVisualState('focus');
218
+ }
219
+ function onWindowsBlur() {
220
+ this._removeVisualState('focus');
221
+ }
222
+ /**
223
+ * iOS: sets the frame of a Mason root, a Mason view whose parent is a core view. Core leaves
224
+ * the safe area to each view (`View._modifyNativeViewFrame`), so the root honours
225
+ * `iosOverflowSafeArea` the same way: when the frame grows past the safe area it lays out
226
+ * again at the new size. Like core views, it raises `layoutChanged` when the frame changes.
227
+ */
228
+ /** Reports the device px size `mason_measure` returns, packed as width * 2^24 + height. */
229
+ export function setMeasuredFromNative(view, packed) {
230
+ const width = Math.floor(packed / 16777216);
231
+ view.setMeasuredDimension(width, packed - width * 16777216);
232
+ }
233
+ export function setRootNativeViewFrame(view, nativeView, frame) {
234
+ // Place the view before adjusting, as core does: the safe-area math reads its
235
+ // position on screen, and a stale one applied the insets twice.
236
+ nativeView.frame = frame;
237
+ const adjusted = view.applySafeAreaInsets(frame) ?? frame;
238
+ if (!CGRectEqualToRect(adjusted, frame)) {
239
+ nativeView.frame = adjusted;
240
+ }
241
+ // A host can place a root beyond its measured safe-area size even when no
242
+ // inset adjustment was needed. Recompute at the final frame in either case.
243
+ const width = masonLayout.toDevicePixels(adjusted.size.width);
244
+ const height = masonLayout.toDevicePixels(adjusted.size.height);
245
+ const layout = view.ios.node.computedLayout;
246
+ if (Math.round(layout.width) !== Math.round(width) || Math.round(layout.height) !== Math.round(height)) {
247
+ view.ios.mason_computeWithSize(width, height);
248
+ view.ios.mason_markRootComputeAppliedWithSize(width, height);
249
+ }
250
+ const previous = view._masonRootFrame;
251
+ if (!previous || !CGRectEqualToRect(previous, adjusted)) {
252
+ view._masonRootFrame = adjusted;
253
+ view._raiseLayoutChangedEvent();
254
+ }
255
+ }
256
+ const TEARDOWN_SLICE_MS = 8;
257
+ // Reading the clock costs more than a teardown on some devices.
258
+ const TEARDOWNS_PER_CLOCK_READ = 16;
259
+ // Mason roots whose requestLayout already climbed to the page in this turn.
260
+ let climbedRoots = null;
261
+ function markClimbed(root) {
262
+ if (!climbedRoots) {
263
+ climbedRoots = new Set();
264
+ queueMicrotask(() => (climbedRoots = null));
265
+ }
266
+ climbedRoots.add(root);
267
+ }
268
+ // A layout in between clears core's flag, so the next request climbs again.
269
+ function climbedThisTurn(root) {
270
+ return !!climbedRoots?.has(root) && !!root.isLayoutRequested;
271
+ }
272
+ export class ViewBase extends CustomLayoutView {
273
+ _masonCheckChild(child) {
274
+ if (!(child instanceof NSView))
275
+ throw new TypeError('Mason core children must be NativeScript views.');
276
+ if (child.parent)
277
+ throw new Error('Remove the child from its parent before inserting it.');
278
+ for (let ancestor = this; ancestor; ancestor = ancestor.parent) {
279
+ if (ancestor === child)
280
+ throw new Error('A Mason core container cannot contain itself or an ancestor.');
281
+ }
282
+ }
283
+ addChild(child) {
284
+ this.insertChild(child, this._children.length);
285
+ }
286
+ insertBefore(child, reference) {
287
+ const index = reference == null ? this._children.length : this._children.indexOf(reference);
288
+ if (index < 0)
289
+ throw new Error('The reference view is not a child of this container.');
290
+ this.insertChild(child, index);
291
+ }
292
+ insertChild(child, atIndex) {
293
+ this._masonCheckChild(child);
294
+ if (!Number.isInteger(atIndex) || atIndex < 0 || atIndex > this._children.length) {
295
+ throw new RangeError('The child index is outside the container.');
296
+ }
297
+ this._masonSettleNativeAdds();
298
+ this._invalidateAttachCursor();
299
+ this._children.splice(atIndex, 0, child);
300
+ try {
301
+ this._addView(child, atIndex);
302
+ }
303
+ catch (error) {
304
+ this._children.splice(atIndex, 1);
305
+ throw error;
306
+ }
307
+ }
308
+ replaceChild(child, atIndex) {
309
+ const previous = this._children[atIndex];
310
+ if (!Number.isInteger(atIndex) || !previous)
311
+ throw new RangeError('The child index is outside the container.');
312
+ if (child === previous)
313
+ return;
314
+ this._masonCheckChild(child);
315
+ this.removeChild(previous);
316
+ this.insertChild(child, atIndex);
317
+ }
318
+ removeChild(child) {
319
+ const index = this._children.indexOf(child);
320
+ if (index < 0)
321
+ return;
322
+ this._masonSettleNativeAdds();
323
+ this._invalidateAttachCursor();
324
+ this._children.splice(index, 1);
325
+ this._removeView(child);
326
+ }
327
+ removeChildren() {
328
+ this._masonSettleNativeAdds();
329
+ this._invalidateAttachCursor();
330
+ while (this._children.length)
331
+ this._removeView(this._children.pop());
332
+ this.requestLayout();
333
+ }
334
+ _nativeIndexFor(atIndex) {
335
+ let count = 0;
336
+ for (let index = 0; index < Math.min(atIndex, this._children.length); index++) {
337
+ if (this._children[index]._isMasonChild)
338
+ count++;
339
+ }
340
+ return count;
341
+ }
342
+ _tearDownUI(force) {
343
+ if ((__ANDROID__ || __APPLE__ || false) && !force && !this.reusable && this._context && this.nativeViewProtected) {
344
+ // A keyed move tears down and re-adds within one patch. Detach only this
345
+ // element and defer the recursive teardown; _setupUI cancels it on re-attach.
346
+ if (this.parent) {
347
+ this.parent._removeViewFromNativeVisualTree(this);
348
+ }
349
+ this._masonPendingTeardown = true;
350
+ ViewBase._pendingTeardowns.push(this);
351
+ if (!ViewBase._teardownScheduled) {
352
+ ViewBase._teardownScheduled = true;
353
+ setTimeout(() => ViewBase._drainTeardowns(), 0);
354
+ }
355
+ return;
356
+ }
357
+ super._tearDownUI(force);
358
+ }
359
+ _setupUI(context, atIndex, parentIsLoaded) {
360
+ if ((__ANDROID__ || __APPLE__ || false) && this._masonPendingTeardown) {
361
+ this._masonPendingTeardown = false;
362
+ if (this._context === context) {
363
+ // core 9.1 renamed mIsRootView to the private _isRootView
364
+ const isRootView = this._isRootView ?? this.mIsRootView;
365
+ if (!isRootView && this.parent && !this._isAddedToNativeVisualTree) {
366
+ const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex ?? -1);
367
+ this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
368
+ }
369
+ return;
370
+ }
371
+ }
372
+ super._setupUI(context, atIndex, parentIsLoaded);
373
+ }
374
+ // Core's CustomLayoutView finds the child with a WinRT call per sibling. Mason's containers remove
375
+ // their children natively themselves, so only core's bookkeeping is kept.
376
+ _removeViewFromNativeVisualTree(child) {
377
+ releaseForeignLayout(child);
378
+ if (false) {
379
+ child._isAddedToNativeVisualTree = false;
380
+ return;
381
+ }
382
+ super._removeViewFromNativeVisualTree(child);
383
+ }
384
+ /** Mirror a plain child's CSS layout into its Mason leaf; containers call this after the native insert. */
385
+ _masonAdoptForeign(child) {
386
+ adoptForeignLayout(child);
387
+ }
388
+ _masonFinishTeardown() {
389
+ if (!this._masonPendingTeardown) {
390
+ return;
391
+ }
392
+ this._masonPendingTeardown = false;
393
+ super._tearDownUI(true);
394
+ }
395
+ static _drainTeardowns() {
396
+ ViewBase._teardownScheduled = false;
397
+ const deadline = Date.now() + TEARDOWN_SLICE_MS;
398
+ let done = 0;
399
+ while (ViewBase._pendingTeardowns.length > 0) {
400
+ const view = ViewBase._pendingTeardowns.shift();
401
+ view._masonFinishTeardown();
402
+ if (++done % TEARDOWNS_PER_CLOCK_READ === 0 && Date.now() >= deadline) {
403
+ break;
404
+ }
405
+ }
406
+ if (ViewBase._pendingTeardowns.length > 0) {
407
+ ViewBase._teardownScheduled = true;
408
+ setTimeout(() => ViewBase._drainTeardowns(), 0);
409
+ }
410
+ }
411
+ /**
412
+ * Enable or disable CSS Preflight (web-normalised / Tailwind-like) defaults
413
+ * for the entire Mason tree.
414
+ *
415
+ * When `true` every element starts from a clean, browser-normalised slate:
416
+ * - `box-sizing: border-box`
417
+ * - `margin: 0`, `padding: 0`, `border-width: 0`
418
+ * - `background: transparent`
419
+ * - `list-style: none` on `<ul>` / `<ol>`
420
+ * - `display: block` on `<img>` (replaced elements)
421
+ *
422
+ * This is a **tree-global** flag; it should ideally be set **before** views are
423
+ * created so that all new nodes inherit the preflight baseline. Changing it
424
+ * after views have been created re-seeds the arena defaults but does not
425
+ * retroactively restyle individually modified nodes.
426
+ *
427
+ * @example
428
+ * ```ts
429
+ * import { ViewBase } from '@octane-xplat/nativescript-masonkit';
430
+ * ViewBase.preflight = true; // enable at app startup
431
+ * ```
432
+ */
433
+ static get preflight() {
434
+ return Tree.instance.preflight;
435
+ }
436
+ static set preflight(value) {
437
+ Tree.instance.preflight = value;
438
+ }
439
+ constructor() {
440
+ super();
441
+ this._children = [];
442
+ this[_a] = false;
443
+ this._masonPendingTeardown = false;
444
+ this[_b] = false;
445
+ this[_c] = false;
446
+ this[_d] = {};
447
+ this._pendingEventsRegistration = [];
448
+ /**
449
+ * iOS: the views in this subtree a root's layout pass must visit (non-Mason children, which core
450
+ * lays out, and Mason views listening to layoutChanged). The pass skips subtrees where it's 0.
451
+ */
452
+ this._masonLayoutWork = 0;
453
+ this._windowsActiveId = 0;
454
+ this._masonClimbTurn = null;
455
+ // `width`/`height` are core CssAnimationProperties whose stylesheet accessor
456
+ // is non-configurable, so units Mason understands but core does not (`vh`,
457
+ // `rem`, `pt`, …) have to be resolved on this view's own Style object.
458
+ installMasonSizeUnits(this.style);
459
+ if (__ANDROID__) {
460
+ this._isPaddingRelative = false;
461
+ }
462
+ // Core's ContainerView defaults this to true: the view extends under the
463
+ // status bar and home indicator, and core layouts pad their children by
464
+ // the insets. Mason lays children out from its own style, so a root kept
465
+ // that default drew its content under the bars. As on the web, content
466
+ // stays in the safe area; set it to true for a full-bleed root (like
467
+ // `viewport-fit=cover`) and pad it yourself.
468
+ this.iosOverflowSafeArea = false;
469
+ }
470
+ _rememberNativeOwner(nativeView = nativeViewFor(this)) {
471
+ if (!nativeView)
472
+ return;
473
+ try {
474
+ nativeView.__masonOwner = new WeakRef(this);
475
+ }
476
+ catch (_) {
477
+ // Some host objects do not accept expandos; fallback tree matching still works.
478
+ }
479
+ }
480
+ /**
481
+ * Returns the top-most Mason/NativeScript element at a point in this view's
482
+ * visible local coordinate space, similar to the browser's elementFromPoint().
483
+ * `x` and `y` are CSS pixels (dips) on every platform, the unit touch events report.
484
+ */
485
+ elementFromPoint(x, y) {
486
+ const nativeView = nativeViewFor(this) ?? this._view;
487
+ if (!nativeView)
488
+ return null;
489
+ this._rememberNativeOwner(nativeView);
490
+ let nativeHit = null;
491
+ if (__ANDROID__ && typeof nativeView.elementFromPoint === 'function') {
492
+ // Android views hit-test in device pixels.
493
+ nativeHit = nativeView.elementFromPoint(masonLayout.toDevicePixels(x), masonLayout.toDevicePixels(y));
494
+ }
495
+ else if (__APPLE__) {
496
+ const hitTest = nativeView.mason_elementFromPointY ?? nativeView.mason_elementFromPoint ?? nativeView.elementFromPoint;
497
+ if (typeof hitTest === 'function') {
498
+ nativeHit = hitTest.call(nativeView, x, y);
499
+ }
500
+ }
501
+ else if (false && typeof masonEngine().ElementFromPoint === 'function') {
502
+ nativeHit = masonEngine().ElementFromPoint(nativeView, x, y);
503
+ }
504
+ if (!nativeHit)
505
+ return null;
506
+ const known = nativeOwnerFor(nativeHit);
507
+ if (known)
508
+ return known;
509
+ // Owners are remembered on first hit rather than for every view at init.
510
+ const found = findOwnerForNativeView(this, nativeHit);
511
+ found?._rememberNativeOwner?.(nativeHit);
512
+ return found;
513
+ }
514
+ // Scrolling. Size reads run a pending layout first; "scroll"/"scrollend" are only raised for
515
+ // an element with a listener.
516
+ /** Vertical scroll offset; setting it scrolls, clamped to the scroll range. */
517
+ get scrollTop() {
518
+ return nativeScrollOffset(this, true);
519
+ }
520
+ set scrollTop(value) {
521
+ nativeScrollTo(this, NaN, scrollCoordinate(value), false);
522
+ }
523
+ /** Horizontal scroll offset; setting it scrolls, clamped to the scroll range. */
524
+ get scrollLeft() {
525
+ return nativeScrollOffset(this, false);
526
+ }
527
+ set scrollLeft(value) {
528
+ nativeScrollTo(this, scrollCoordinate(value), NaN, false);
529
+ }
530
+ /** Content width, at least `clientWidth`. */
531
+ get scrollWidth() {
532
+ return nativeScrollMetric(this, 'scrollWidth');
533
+ }
534
+ /** Content height, at least `clientHeight`. */
535
+ get scrollHeight() {
536
+ return nativeScrollMetric(this, 'scrollHeight');
537
+ }
538
+ /** Padding box width. */
539
+ get clientWidth() {
540
+ return nativeScrollMetric(this, 'clientWidth');
541
+ }
542
+ /** Padding box height. */
543
+ get clientHeight() {
544
+ return nativeScrollMetric(this, 'clientHeight');
545
+ }
546
+ scrollTo(xOrOptions, y) {
547
+ if (xOrOptions !== null && typeof xOrOptions === 'object') {
548
+ const { left, top, behavior } = xOrOptions;
549
+ nativeScrollTo(this, left === undefined ? NaN : scrollCoordinate(left), top === undefined ? NaN : scrollCoordinate(top), behavior === 'smooth');
550
+ }
551
+ else {
552
+ nativeScrollTo(this, scrollCoordinate(xOrOptions), scrollCoordinate(y), false);
553
+ }
554
+ }
555
+ scroll(xOrOptions, y) {
556
+ this.scrollTo(xOrOptions, y);
557
+ }
558
+ scrollBy(xOrOptions, y) {
559
+ let dx;
560
+ let dy;
561
+ let smooth = false;
562
+ if (xOrOptions !== null && typeof xOrOptions === 'object') {
563
+ dx = scrollCoordinate(xOrOptions.left);
564
+ dy = scrollCoordinate(xOrOptions.top);
565
+ smooth = xOrOptions.behavior === 'smooth';
566
+ }
567
+ else {
568
+ dx = scrollCoordinate(xOrOptions);
569
+ dy = scrollCoordinate(y);
570
+ }
571
+ // Relative to a request still waiting for the native view, if any.
572
+ const pending = this._masonPendingScroll;
573
+ const left = !dx ? NaN : (pending && !isNaN(pending.left) ? pending.left : this.scrollLeft) + dx;
574
+ const top = !dy ? NaN : (pending && !isNaN(pending.top) ? pending.top : this.scrollTop) + dy;
575
+ nativeScrollTo(this, left, top, smooth);
576
+ }
577
+ /** Scrolls the scroll containers above this element so it's visible. */
578
+ scrollIntoView(arg) {
579
+ const native = this[native_];
580
+ if (!native)
581
+ return;
582
+ const options = arg !== null && typeof arg === 'object' ? arg : { block: arg === false ? 'end' : 'start' };
583
+ const block = SCROLL_POSITIONS[options.block ?? 'start'] ?? 0;
584
+ const inline = SCROLL_POSITIONS[options.inline ?? 'nearest'] ?? 3;
585
+ const smooth = options.behavior === 'smooth';
586
+ if (__ANDROID__) {
587
+ org.nativescript.mason.masonkit.WebScroll.scrollIntoView(native, block, inline, smooth);
588
+ }
589
+ else if (__APPLE__) {
590
+ native.mason_scrollIntoView(block, inline, smooth);
591
+ }
592
+ else if (false) {
593
+ masonEngine().ScrollIntoView(native, block, inline, smooth);
594
+ }
595
+ }
596
+ _registerNativeEvent(arg, callback, thisArg) {
597
+ if (!this[native_]) {
598
+ this._pendingEventsRegistration.push({ arg, callback, thisArg });
599
+ return;
600
+ }
601
+ //@ts-ignore
602
+ if (this._view) {
603
+ if (__ANDROID__) {
604
+ const ref = new WeakRef(this);
605
+ const cb = new kotlin.jvm.functions.Function1({
606
+ invoke(event) {
607
+ const owner = ref.get();
608
+ if (owner) {
609
+ const ret = wrapNativeEvent(arg);
610
+ ret[native_] = event;
611
+ ret._target = owner;
612
+ callback.call(thisArg || owner, ret);
613
+ }
614
+ },
615
+ });
616
+ //@ts-ignore
617
+ const id = this._view.addEventListener(arg, cb);
618
+ callback['mason:event:id'] = id;
619
+ }
620
+ if (__APPLE__) {
621
+ //@ts-ignore
622
+ const id = this._view.mason_addEventListener(arg, (event) => {
623
+ const ret = wrapNativeEvent(arg);
624
+ ret[native_] = event;
625
+ ret._target = this;
626
+ callback.call(thisArg || this, ret);
627
+ });
628
+ callback['mason:event:id'] = id;
629
+ }
630
+ if (false) {
631
+ if (typeof masonEngine().AddEventListener === 'function') {
632
+ const ref = new WeakRef(this);
633
+ const listener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
634
+ const owner = ref.deref();
635
+ if (!owner)
636
+ return;
637
+ const ret = wrapNativeEvent(arg);
638
+ ret[native_] = event;
639
+ ret._target = owner;
640
+ callback.call(thisArg || owner, ret);
641
+ });
642
+ callback['mason:event:id'] = masonEngine().AddEventListener(this._view, arg, listener);
643
+ callback['mason:event:listener'] = listener;
644
+ }
645
+ else if (arg === 'click' || arg === 'tap') {
646
+ try {
647
+ const NSWinRT_ = globalThis.NSWinRT;
648
+ const MUX = globalThis.Microsoft;
649
+ const owner = this;
650
+ const view = this._view;
651
+ const delegate = NSWinRT_.asDelegate('Microsoft.UI.Xaml.Input.TappedEventHandler', (_sender, _e) => {
652
+ const ret = {};
653
+ ret[native_] = _e;
654
+ ret._target = owner;
655
+ callback.call(thisArg || owner, ret);
656
+ });
657
+ if (view.Background == null && MUX?.UI?.Xaml?.Media?.SolidColorBrush) {
658
+ view.Background = new MUX.UI.Xaml.Media.SolidColorBrush(MUX.UI.Colors.Transparent);
659
+ }
660
+ const tappedEvent = MUX?.UI?.Xaml?.UIElement?.TappedEvent ?? view.TappedEvent;
661
+ let attached = false;
662
+ if (tappedEvent && typeof view.AddHandler === 'function') {
663
+ try {
664
+ view.AddHandler(tappedEvent, delegate, true);
665
+ callback['mason:event:tapped'] = tappedEvent;
666
+ attached = true;
667
+ }
668
+ catch (_e) { }
669
+ }
670
+ if (!attached) {
671
+ view.Tapped = delegate;
672
+ }
673
+ callback['mason:event:id'] = delegate;
674
+ }
675
+ catch (_) { }
676
+ }
677
+ else if (typeof this._view.AddEventListener === 'function') {
678
+ const ref = new WeakRef(this);
679
+ const listener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
680
+ const owner = ref.deref();
681
+ if (!owner)
682
+ return;
683
+ const ret = wrapNativeEvent(arg);
684
+ ret[native_] = event;
685
+ ret._target = owner;
686
+ callback.call(thisArg || owner, ret);
687
+ });
688
+ callback['mason:event:id'] = this._view.AddEventListener(arg, listener);
689
+ // Held so the delegate isn't collected.
690
+ callback['mason:event:listener'] = listener;
691
+ }
692
+ }
693
+ }
694
+ }
695
+ _unregisterNativeEvent(arg, callback, thisArg) {
696
+ const id = callback['mason:event:id'];
697
+ if (!this[native_]) {
698
+ this._pendingEventsRegistration = this._pendingEventsRegistration.filter((registration) => {
699
+ return !(registration.arg === arg && registration.callback === callback && registration.thisArg === thisArg);
700
+ });
701
+ return;
702
+ }
703
+ //@ts-ignore
704
+ if (this._view) {
705
+ if (__ANDROID__) {
706
+ if (id) {
707
+ //@ts-ignore
708
+ const removed = this._view.removeEventListener(arg, id);
709
+ callback['mason:event:id'] = undefined;
710
+ }
711
+ }
712
+ if (__APPLE__) {
713
+ if (id) {
714
+ //@ts-ignore
715
+ const removed = this._view.mason_removeEventListenerId(arg, id);
716
+ callback['mason:event:id'] = undefined;
717
+ }
718
+ }
719
+ if (false) {
720
+ if (id && callback['mason:event:listener'] && !callback['mason:event:tapped']) {
721
+ masonEngine().RemoveEventListener(this._view, arg, id);
722
+ callback['mason:event:id'] = undefined;
723
+ callback['mason:event:listener'] = undefined;
724
+ }
725
+ else if (id && (arg === 'click' || arg === 'tap')) {
726
+ try {
727
+ const view = this._view;
728
+ const tappedEvent = callback['mason:event:tapped'];
729
+ if (tappedEvent && typeof view.RemoveHandler === 'function') {
730
+ view.RemoveHandler(tappedEvent, id);
731
+ }
732
+ else if (view) {
733
+ view.Tapped = null;
734
+ }
735
+ }
736
+ catch (_) { }
737
+ callback['mason:event:id'] = undefined;
738
+ callback['mason:event:tapped'] = undefined;
739
+ }
740
+ else if (id && typeof this._view.RemoveEventListener === 'function') {
741
+ this._view.RemoveEventListener(arg, id);
742
+ callback['mason:event:id'] = undefined;
743
+ callback['mason:event:listener'] = undefined;
744
+ }
745
+ }
746
+ }
747
+ }
748
+ /** Hands `touch-action` to the native node, where the scroll views read it. */
749
+ _applyTouchAction() {
750
+ const flags = this[touchAction_];
751
+ const native = this[native_];
752
+ if (flags === undefined || !native)
753
+ return;
754
+ const node = native.node ?? (__IOS__ ? this.ios?.node : undefined);
755
+ if (node)
756
+ node.touchAction = flags;
757
+ }
758
+ initNativeView() {
759
+ super.initNativeView();
760
+ this._applyTouchAction();
761
+ const scroll = this._masonPendingScroll;
762
+ if (scroll) {
763
+ this._masonPendingScroll = undefined;
764
+ nativeScrollTo(this, scroll.left, scroll.top, scroll.smooth);
765
+ }
766
+ if (this._pendingEventsRegistration.length > 0) {
767
+ const pending = this._pendingEventsRegistration.splice(0);
768
+ for (const registration of pending) {
769
+ this._registerNativeEvent(registration.arg, registration.callback, registration.thisArg);
770
+ }
771
+ }
772
+ }
773
+ _setNativeViewFrame(nativeView, frame) {
774
+ // nativeView.frame = frame;
775
+ }
776
+ _masonAddLayoutWork(delta) {
777
+ // Up to the root: a non-Mason parent is laid out by core and its Mason roots keep their own count.
778
+ let view = this;
779
+ while (view?.[isMasonView_]) {
780
+ view._masonLayoutWork += delta;
781
+ view = view.parent;
782
+ }
783
+ }
784
+ _masonListensToLayout() {
785
+ return this.hasListeners(NSView.layoutChangedEvent);
786
+ }
787
+ _addViewCore(view, atIndex) {
788
+ // Before setup: listeners the child gains while loading add themselves through `parent`.
789
+ if (__APPLE__) {
790
+ const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
791
+ if (work)
792
+ this._masonAddLayoutWork(work);
793
+ }
794
+ // @ts-ignore
795
+ super._addViewCore(view, atIndex);
796
+ }
797
+ _removeViewCore(view) {
798
+ // @ts-ignore
799
+ super._removeViewCore(view);
800
+ // After teardown: listeners removed while unloading already subtracted themselves.
801
+ if (__APPLE__) {
802
+ const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
803
+ if (work)
804
+ this._masonAddLayoutWork(-work);
805
+ }
806
+ }
807
+ addEventListener(arg, callback, thisArg) {
808
+ const listened = __APPLE__ && this._masonListensToLayout();
809
+ this._addEventListener(arg, callback, thisArg);
810
+ if (__APPLE__ && !listened && this._masonListensToLayout())
811
+ this._masonAddLayoutWork(1);
812
+ }
813
+ removeEventListener(arg, callback, thisArg) {
814
+ const listened = __APPLE__ && this._masonListensToLayout();
815
+ this._removeEventListener(arg, callback, thisArg);
816
+ if (__APPLE__ && listened && !this._masonListensToLayout())
817
+ this._masonAddLayoutWork(-1);
818
+ }
819
+ _addEventListener(arg, callback, thisArg) {
820
+ if (typeof thisArg === 'boolean') {
821
+ thisArg = {
822
+ capture: thisArg,
823
+ };
824
+ }
825
+ if (typeof arg !== 'string') {
826
+ super.addEventListener(arg, callback, thisArg);
827
+ return;
828
+ }
829
+ const nativeEventName = masonNativeEventName(arg);
830
+ if (nativeEventName) {
831
+ super.addEventListener(nativeEventName, callback, thisArg);
832
+ this._registerNativeEvent(nativeEventName, callback, thisArg);
833
+ return;
834
+ }
835
+ super.addEventListener(arg, callback, thisArg);
836
+ }
837
+ _removeEventListener(arg, callback, thisArg) {
838
+ if (typeof thisArg === 'boolean') {
839
+ thisArg = {
840
+ capture: thisArg,
841
+ };
842
+ }
843
+ if (typeof arg === 'string') {
844
+ const nativeEventName = masonNativeEventName(arg);
845
+ if (nativeEventName) {
846
+ super.removeEventListener(nativeEventName, callback, thisArg);
847
+ this._unregisterNativeEvent(nativeEventName, callback, thisArg);
848
+ return;
849
+ }
850
+ }
851
+ super.removeEventListener(arg, callback, thisArg);
852
+ }
853
+ _applyPseudoClassStyles(pseudoClass, view, styles) {
854
+ if (pseudoClass && styles && pseudoClass in styles) {
855
+ const current = styles[pseudoClass];
856
+ //@ts-ignore
857
+ const existing = this[pseudoStyles_]?.[pseudoClass];
858
+ const style = existing ?? Style.fromPseudo(pseudoClass, this, view);
859
+ if (style) {
860
+ for (const prop in current) {
861
+ // ruleset props are kebab-case; Style only has camelCase accessors.
862
+ style[toCamelCase(prop)] = current[prop];
863
+ }
864
+ this[pseudoStyles_][pseudoClass] = style;
865
+ }
866
+ }
867
+ }
868
+ _hoverHandler(subscribe) {
869
+ const styles = compile(this);
870
+ //@ts-ignore
871
+ this._applyPseudoClassStyles('hover', this._view, styles);
872
+ if (false) {
873
+ if (subscribe) {
874
+ this.on('mouseEnter', onWindowsHoverEnter);
875
+ this.on('mouseLeave', onWindowsHoverLeave);
876
+ }
877
+ else {
878
+ this.off('mouseEnter', onWindowsHoverEnter);
879
+ this.off('mouseLeave', onWindowsHoverLeave);
880
+ this._removeVisualState('hover');
881
+ }
882
+ }
883
+ }
884
+ _handler(subscribe) {
885
+ const styles = compile(this);
886
+ //@ts-ignore
887
+ this._applyPseudoClassStyles('active', this._view, styles);
888
+ if (false) {
889
+ if (subscribe) {
890
+ this.on('touch', onWindowsActiveTouch);
891
+ this.on('mouseLeave', onWindowsActiveLeave);
892
+ }
893
+ else {
894
+ this.off('touch', onWindowsActiveTouch);
895
+ this.off('mouseLeave', onWindowsActiveLeave);
896
+ clearWindowsActive(this);
897
+ }
898
+ this._windowsListenActive(subscribe);
899
+ // A button dims while held only when it has no :active style of its own.
900
+ // @ts-ignore
901
+ const view = this._view;
902
+ if (view?.IsButton)
903
+ view.DimsWhenPressed = !subscribe;
904
+ }
905
+ }
906
+ // Inline elements a Text draws get no pointer events of their own; the Text reports their presses.
907
+ _windowsListenActive(on) {
908
+ const view = this._view;
909
+ if (!view || typeof masonEngine().AddEventListener !== 'function')
910
+ return;
911
+ if (on && !this._windowsActiveId) {
912
+ const ref = new WeakRef(this);
913
+ this._windowsActiveListener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
914
+ const owner = ref.deref();
915
+ if (!owner)
916
+ return;
917
+ if (event.Data === '1') {
918
+ for (const state of WINDOWS_ACTIVE_STATES)
919
+ owner._addVisualState(state);
920
+ }
921
+ else {
922
+ clearWindowsActive(owner);
923
+ }
924
+ });
925
+ this._windowsActiveId = masonEngine().AddEventListener(view, 'mason:active', this._windowsActiveListener);
926
+ }
927
+ else if (!on && this._windowsActiveId) {
928
+ masonEngine().RemoveEventListener(view, 'mason:active', this._windowsActiveId);
929
+ this._windowsActiveId = 0;
930
+ this._windowsActiveListener = undefined;
931
+ }
932
+ }
933
+ _disableHandler(subscribe) {
934
+ const styles = compile(this);
935
+ //@ts-ignore
936
+ this._applyPseudoClassStyles('disabled', this._view, styles);
937
+ }
938
+ _focusHandler(subscribe) {
939
+ const styles = compile(this);
940
+ //@ts-ignore
941
+ this._applyPseudoClassStyles('focus', this._view, styles);
942
+ if (false) {
943
+ if (subscribe) {
944
+ this.on('focus', onWindowsFocus, this);
945
+ this.on('blur', onWindowsBlur, this);
946
+ }
947
+ else {
948
+ this.off('focus', onWindowsFocus, this);
949
+ this.off('blur', onWindowsBlur, this);
950
+ this._removeVisualState('focus');
951
+ }
952
+ }
953
+ }
954
+ _blurHandler(subscribe) {
955
+ const styles = compile(this);
956
+ //@ts-ignore
957
+ this._applyPseudoClassStyles('blur', this._view, styles);
958
+ }
959
+ forceStyleUpdate() {
960
+ _forceStyleUpdate(this);
961
+ }
962
+ get _viewChildren() {
963
+ return this._children.filter((child) => {
964
+ return !child[isPlaceholder_] && child instanceof NSView;
965
+ });
966
+ }
967
+ eachLayoutChild(callback) {
968
+ let lastChild = null;
969
+ this.eachChildView((cv) => {
970
+ cv._eachLayoutView((lv) => {
971
+ if (lastChild && !lastChild.isCollapsed) {
972
+ callback(lastChild, false);
973
+ }
974
+ lastChild = lv;
975
+ });
976
+ return true;
977
+ });
978
+ if (lastChild && !lastChild.isCollapsed) {
979
+ callback(lastChild, true);
980
+ }
981
+ }
982
+ eachChild(callback) {
983
+ this._eachViewChild(callback);
984
+ }
985
+ // Live and allocation-free, like core's LayoutBase.eachChildView (walks run per view).
986
+ _eachViewChild(callback) {
987
+ const children = this._children;
988
+ for (let i = 0, length = children.length; i < length; i++) {
989
+ const child = children[i];
990
+ if (child && !child[isPlaceholder_] && child instanceof NSView) {
991
+ callback(child);
992
+ }
993
+ }
994
+ }
995
+ // Core's iOS requestLayout climbs to the Page and re-measures the whole tree in JS.
996
+ // A Mason root's native compute already places every Mason descendant, so it skips
997
+ // them and only runs core's layout for non-Mason views inside its subtree.
998
+ /** True for a Mason view whose frame the Mason tree sets natively (iOS). */
999
+ get _masonPlacedNatively() {
1000
+ return __APPLE__ && !!this[isMasonView_] && !!this.parent?.[isMasonView_];
1001
+ }
1002
+ /** Size a non-Mason child with core's measure: its native view rarely implements sizeThatFits. */
1003
+ _masonMeasureForeign(child) {
1004
+ if (!__APPLE__ || child[isMasonView_] || !child.nativeViewProtected)
1005
+ return;
1006
+ // Text views (MasonText) have no `mason` of their own; their node does.
1007
+ const native = this.nativeViewProtected;
1008
+ const mason = native?.mason ?? native?.node?.mason;
1009
+ if (typeof mason?.setMeasureForViewBlock !== 'function')
1010
+ return;
1011
+ invalidateOnLayoutRequest(child, mason);
1012
+ const parentRef = new WeakRef(this);
1013
+ const childRef = new WeakRef(child);
1014
+ const spec = (known, available) => {
1015
+ if (!isNaN(known))
1016
+ return Utils.layout.makeMeasureSpec(known, Utils.layout.EXACTLY);
1017
+ if (available > 0)
1018
+ return Utils.layout.makeMeasureSpec(available, Utils.layout.AT_MOST);
1019
+ return Utils.layout.makeMeasureSpec(0, Utils.layout.UNSPECIFIED);
1020
+ };
1021
+ mason.setMeasureForViewBlock(child.nativeViewProtected, (knownW, knownH, availW, availH) => {
1022
+ const parent = parentRef.deref();
1023
+ const view = childRef.deref();
1024
+ if (!parent || !view)
1025
+ return CGSizeMake(0, 0);
1026
+ NSView.measureChild(parent, view, spec(knownW, availW), spec(knownH, availH));
1027
+ return CGSizeMake(view.getMeasuredWidth(), view.getMeasuredHeight());
1028
+ });
1029
+ }
1030
+ /**
1031
+ * Sets a non-Mason child's percentage width/height (`null` clears it), resolved against the
1032
+ * containing block. Windows core calls this for every percentage; on Android and iOS a view calls
1033
+ * it when its native sizing can't express one. `false` when core should handle it.
1034
+ */
1035
+ _setChildPercentSize(child, horizontal, fraction) {
1036
+ const nativeChild = child?.nativeViewProtected;
1037
+ if (!nativeChild || child[isMasonView_])
1038
+ return false;
1039
+ const value = fraction ?? NaN;
1040
+ if (false) {
1041
+ if (horizontal)
1042
+ masonEngine().SetPercentWidth(nativeChild, value);
1043
+ else
1044
+ masonEngine().SetPercentHeight(nativeChild, value);
1045
+ }
1046
+ else if (__ANDROID__) {
1047
+ const mason = org.nativescript.mason.masonkit.Mason.getShared();
1048
+ if (horizontal)
1049
+ mason.setPercentWidth(nativeChild, value);
1050
+ else
1051
+ mason.setPercentHeight(nativeChild, value);
1052
+ }
1053
+ else if (__APPLE__) {
1054
+ if (horizontal)
1055
+ NSCMason.shared.setPercentWidth(nativeChild, value);
1056
+ else
1057
+ NSCMason.shared.setPercentHeight(nativeChild, value);
1058
+ }
1059
+ else {
1060
+ return false;
1061
+ }
1062
+ return true;
1063
+ }
1064
+ /**
1065
+ * A native removal relays out natively but runs no core layout pass, so `layoutChanged`
1066
+ * and non-Mason descendants miss it. Ask for one; a subtree being torn down is unloaded.
1067
+ */
1068
+ _masonRequestLayoutAfterRemoval() {
1069
+ if (__APPLE__ && this.isLoaded)
1070
+ this.requestLayout();
1071
+ }
1072
+ /** Lay out the non-Mason views in this root's subtree from the frames Mason set. */
1073
+ _masonLayoutForeignDescendants() {
1074
+ if (!__APPLE__)
1075
+ return;
1076
+ const visit = (view) => {
1077
+ view.eachChildView((child) => {
1078
+ if (child[isMasonView_]) {
1079
+ if (!(child._masonLayoutWork > 0))
1080
+ return true;
1081
+ // Keep `layoutChanged` working for the few views that listen to it.
1082
+ if (child.hasListeners?.(NSView.layoutChangedEvent)) {
1083
+ const b = child._getCurrentLayoutBounds();
1084
+ if (child._setCurrentLayoutBounds(b.left, b.top, b.right, b.bottom).boundsChanged) {
1085
+ child._raiseLayoutChangedEvent();
1086
+ }
1087
+ }
1088
+ visit(child);
1089
+ }
1090
+ else if (child.nativeViewProtected) {
1091
+ const b = child._getCurrentLayoutBounds();
1092
+ const w = Utils.layout.makeMeasureSpec(b.right - b.left, Utils.layout.EXACTLY);
1093
+ const h = Utils.layout.makeMeasureSpec(b.bottom - b.top, Utils.layout.EXACTLY);
1094
+ NSView.measureChild(view, child, w, h);
1095
+ child.layout(b.left, b.top, b.right, b.bottom);
1096
+ }
1097
+ return true;
1098
+ });
1099
+ };
1100
+ visit(this);
1101
+ }
1102
+ requestLayout() {
1103
+ // A natively placed view only needs its Mason root re-measured: skip the
1104
+ // per-ancestor hops (each a JS call plus a native setNeedsLayout).
1105
+ if (this._masonPlacedNatively) {
1106
+ // CSS asks once per layout property; reuse this turn's root while it is still flagged.
1107
+ if (climbedRoots && this._masonClimbTurn === climbedRoots && climbedThisTurn(this._masonClimbRoot))
1108
+ return;
1109
+ let root = this.parent;
1110
+ while (root?.parent?.[isMasonView_])
1111
+ root = root.parent;
1112
+ if (root && !climbedThisTurn(root))
1113
+ root.requestLayout();
1114
+ this._masonClimbRoot = root;
1115
+ this._masonClimbTurn = climbedRoots;
1116
+ return;
1117
+ }
1118
+ // Core climbs on every call, once per changed property; once per turn is enough.
1119
+ if (__APPLE__ && climbedThisTurn(this))
1120
+ return;
1121
+ super.requestLayout();
1122
+ if (__APPLE__)
1123
+ markClimbed(this);
1124
+ }
1125
+ _parentChanged(oldParent) {
1126
+ climbedRoots?.delete(this);
1127
+ this._masonClimbTurn = null;
1128
+ super._parentChanged(oldParent);
1129
+ }
1130
+ getMeasuredWidth() {
1131
+ if (this._masonPlacedNatively && this.nativeViewProtected) {
1132
+ return Math.round(masonLayout.toDevicePixels(this.nativeViewProtected.frame.size.width));
1133
+ }
1134
+ return super.getMeasuredWidth();
1135
+ }
1136
+ getMeasuredHeight() {
1137
+ if (this._masonPlacedNatively && this.nativeViewProtected) {
1138
+ return Math.round(masonLayout.toDevicePixels(this.nativeViewProtected.frame.size.height));
1139
+ }
1140
+ return super.getMeasuredHeight();
1141
+ }
1142
+ eachChildView(callback) {
1143
+ this._eachViewChild(callback);
1144
+ }
1145
+ _addChildFromBuilder(name, value) {
1146
+ this.addChild(value);
1147
+ }
1148
+ getChildrenCount() {
1149
+ let count = 0;
1150
+ this._eachViewChild(() => count++);
1151
+ return count;
1152
+ }
1153
+ get _childrenCount() {
1154
+ return this.getChildrenCount();
1155
+ }
1156
+ getChildAt(index) {
1157
+ let found;
1158
+ let i = 0;
1159
+ this._eachViewChild((child) => {
1160
+ if (i++ === index)
1161
+ found = child;
1162
+ });
1163
+ return found;
1164
+ }
1165
+ getChildIndex(child) {
1166
+ let index = -1;
1167
+ let i = 0;
1168
+ this._eachViewChild((c) => {
1169
+ if (c === child && index === -1)
1170
+ index = i;
1171
+ i++;
1172
+ });
1173
+ return index;
1174
+ }
1175
+ getChildById(id) {
1176
+ return getViewById(this, id);
1177
+ }
1178
+ _nativeAttachIndex(child, atIndex) {
1179
+ const cur = this._attachCursor;
1180
+ let jsIndex;
1181
+ let nativeIndex;
1182
+ if (atIndex <= -1 && cur && this._children[cur.jsIndex] === cur.child && this._children[cur.jsIndex + 1] === child) {
1183
+ jsIndex = cur.jsIndex + 1;
1184
+ nativeIndex = cur.nativeIndex + 1;
1185
+ }
1186
+ else {
1187
+ jsIndex = atIndex <= -1 ? this._children.indexOf(child) : atIndex;
1188
+ nativeIndex = jsIndex <= -1 ? jsIndex : this._nativeIndexFor(jsIndex);
1189
+ }
1190
+ this._attachCursor = jsIndex >= 0 && nativeIndex >= 0 ? { child, jsIndex, nativeIndex } : undefined;
1191
+ return { jsIndex, nativeIndex };
1192
+ }
1193
+ _invalidateAttachCursor() {
1194
+ this._attachCursor = undefined;
1195
+ }
1196
+ /** Runs an iOS View's queued inserts before a native child edit. */
1197
+ _masonSettleNativeAdds() {
1198
+ if (this._masonPendingAdds)
1199
+ this._masonFlushNativeAdds();
1200
+ }
1201
+ _childIndexToNativeChildIndex(index) {
1202
+ if (false && typeof index === 'number' && index >= 0) {
1203
+ return this._nativeIndexFor(index);
1204
+ }
1205
+ return super._childIndexToNativeChildIndex(index);
1206
+ }
1207
+ [(_a = isMasonView_, _b = isTextChild_, _c = isText_, _d = pseudoStyles_, zIndexProperty.setNative)](value) {
1208
+ // @ts-ignore
1209
+ const style = this._styleHelper;
1210
+ if (style) {
1211
+ // @ts-ignore
1212
+ style.zIndex = value;
1213
+ }
1214
+ }
1215
+ [directionProperty.setNative](value) {
1216
+ // @ts-ignore
1217
+ super[directionProperty.setNative]?.(value);
1218
+ const style = this._styleHelper;
1219
+ if (style)
1220
+ style.direction = value === 'rtl' || value === 'ltr' ? value : 'inherit';
1221
+ }
1222
+ set verticalAlign(value) {
1223
+ this.style.verticalAlign = value;
1224
+ }
1225
+ get verticalAlign() {
1226
+ return this.style.verticalAlign;
1227
+ }
1228
+ [verticalAlignProperty.setNative](value) {
1229
+ // @ts-ignore
1230
+ const style = this._styleHelper;
1231
+ if (style) {
1232
+ // @ts-ignore
1233
+ style.verticalAlign = value;
1234
+ }
1235
+ }
1236
+ // @ts-ignore
1237
+ set flex(value) {
1238
+ this.style.flex = value;
1239
+ }
1240
+ get flex() {
1241
+ return this.style.flex;
1242
+ }
1243
+ set textWrap(value) {
1244
+ this.style.textWrap = value;
1245
+ }
1246
+ get textWrap() {
1247
+ return this.style.textWrap;
1248
+ }
1249
+ [textWrapProperty.setNative](value) {
1250
+ // @ts-ignore
1251
+ const style = this._styleHelper;
1252
+ if (style) {
1253
+ // @ts-ignore
1254
+ style.textWrap = value;
1255
+ }
1256
+ }
1257
+ set aspectRatio(value) {
1258
+ this.style.aspectRatio = value;
1259
+ }
1260
+ get aspectRatio() {
1261
+ return this.style.aspectRatio;
1262
+ }
1263
+ [aspectRatioProperty.setNative](value) {
1264
+ // @ts-ignore
1265
+ const style = this._styleHelper;
1266
+ if (style) {
1267
+ // @ts-ignore
1268
+ style.aspectRatio = value;
1269
+ }
1270
+ }
1271
+ onLoaded() {
1272
+ super.onLoaded();
1273
+ if (!this.parent?.[isMasonView_]) {
1274
+ this._cssEnvironmentStop ?? (this._cssEnvironmentStop = registerAutomaticCssEnvironment(this, () => nativeCssEnvironmentSource(this)));
1275
+ }
1276
+ }
1277
+ onUnloaded() {
1278
+ super.onUnloaded();
1279
+ this._cssEnvironmentStop?.();
1280
+ this._cssEnvironmentStop = undefined;
1281
+ }
1282
+ get filter() {
1283
+ return this.style.filter;
1284
+ }
1285
+ set filter(value) {
1286
+ this.style.filter = value;
1287
+ }
1288
+ [filterProperty.setNative](value) {
1289
+ // @ts-ignore
1290
+ const style = this._styleHelper;
1291
+ if (style) {
1292
+ // @ts-ignore
1293
+ style.filter = value;
1294
+ }
1295
+ }
1296
+ // @ts-ignore
1297
+ set borderRadius(value) {
1298
+ this.style.borderRadius = value;
1299
+ }
1300
+ get borderRadius() {
1301
+ return this.style.borderRadius;
1302
+ }
1303
+ [borderRadiusProperty.setNative](value) {
1304
+ // @ts-ignore
1305
+ const style = this._styleHelper;
1306
+ if (style) {
1307
+ // @ts-ignore
1308
+ style.borderRadius = value;
1309
+ this[borderRadiusCorners_] = undefined;
1310
+ }
1311
+ }
1312
+ [borderRadiusProperty.getDefault]() {
1313
+ // @ts-ignore
1314
+ return this._styleHelper?.borderRadius;
1315
+ }
1316
+ // `border-radius` / `border-color` arriving as core's longhands.
1317
+ _nativeBorderRadiusCorners() {
1318
+ // @ts-ignore
1319
+ const style = this._styleHelper;
1320
+ if ((__ANDROID__ || __APPLE__) && style && !style.hasBorderRadius()) {
1321
+ return borderRadiusCorners('0');
1322
+ }
1323
+ const native = String(style?.borderRadius ?? '').trim();
1324
+ try {
1325
+ return borderRadiusCorners(native || '0');
1326
+ }
1327
+ catch {
1328
+ return borderRadiusCorners('0');
1329
+ }
1330
+ }
1331
+ _borderRadiusCorner(corner, value) {
1332
+ // @ts-ignore
1333
+ const style = this._styleHelper;
1334
+ if (!style) {
1335
+ return;
1336
+ }
1337
+ if ((__ANDROID__ || __APPLE__) && !isCssLength(value) && style._writeCornerLength(corner, value)) {
1338
+ this[borderRadiusCorners_] = undefined;
1339
+ return;
1340
+ }
1341
+ let corners = this[borderRadiusCorners_];
1342
+ if (!corners) {
1343
+ corners = this[borderRadiusCorners_] = this._nativeBorderRadiusCorners();
1344
+ }
1345
+ // Resolve math functions first: the corner parser can't read them.
1346
+ const text = lengthToCssString(masonLength(value));
1347
+ const css = resolveCssMathIn(text, style.emBasisFor(text));
1348
+ const radius = (corners[corner] = /\s/.test(css) ? parseCornerRadius(css) : [css, css]);
1349
+ const shorthand = composeBorderRadius(corners);
1350
+ if ((__ANDROID__ || __APPLE__) && style._writeCornerRadius(corner, radius, shorthand)) {
1351
+ return;
1352
+ }
1353
+ // @ts-ignore
1354
+ style.borderRadius = shorthand;
1355
+ }
1356
+ _nativeCornerRadius(corner) {
1357
+ // @ts-ignore
1358
+ const style = this._styleHelper;
1359
+ if ((__ANDROID__ || __APPLE__) && style && style._cornerRadiusIsZero(corner)) {
1360
+ return '0';
1361
+ }
1362
+ const [h, v] = this._nativeBorderRadiusCorners()[corner];
1363
+ return h === v ? h : `${h} ${v}`;
1364
+ }
1365
+ [borderTopLeftRadiusProperty.getDefault]() {
1366
+ return this._nativeCornerRadius(0);
1367
+ }
1368
+ [borderTopRightRadiusProperty.getDefault]() {
1369
+ return this._nativeCornerRadius(1);
1370
+ }
1371
+ [borderBottomRightRadiusProperty.getDefault]() {
1372
+ return this._nativeCornerRadius(2);
1373
+ }
1374
+ [borderBottomLeftRadiusProperty.getDefault]() {
1375
+ return this._nativeCornerRadius(3);
1376
+ }
1377
+ [borderTopLeftRadiusProperty.setNative](value) {
1378
+ this._borderRadiusCorner(0, value);
1379
+ }
1380
+ [borderTopRightRadiusProperty.setNative](value) {
1381
+ this._borderRadiusCorner(1, value);
1382
+ }
1383
+ [borderBottomRightRadiusProperty.setNative](value) {
1384
+ this._borderRadiusCorner(2, value);
1385
+ }
1386
+ [borderBottomLeftRadiusProperty.setNative](value) {
1387
+ this._borderRadiusCorner(3, value);
1388
+ }
1389
+ _borderSideColor(side, value) {
1390
+ if (__ANDROID__ || __APPLE__) {
1391
+ const s = this._styleHelper;
1392
+ if (s) {
1393
+ s.setBorderSideColor(side === 't' ? 'top' : side === 'r' ? 'right' : side === 'b' ? 'bottom' : 'left', value);
1394
+ return;
1395
+ }
1396
+ }
1397
+ let sides = this[borderSideColors_];
1398
+ if (!sides) {
1399
+ sides = this[borderSideColors_] = { t: 'transparent', r: 'transparent', b: 'transparent', l: 'transparent' };
1400
+ }
1401
+ sides[side] = colorToCssString(value);
1402
+ const shorthand = `${sides.t} ${sides.r} ${sides.b} ${sides.l}`;
1403
+ if (__ANDROID__) {
1404
+ // @ts-ignore
1405
+ nodeHelper().setBorderColor(this.nativeView, shorthand);
1406
+ }
1407
+ else if (__APPLE__) {
1408
+ // @ts-ignore
1409
+ this.nativeView?.style?.setBorderColor(shorthand);
1410
+ }
1411
+ else if (false) {
1412
+ // @ts-ignore
1413
+ this._styleHelper?.setBorderColor(shorthand);
1414
+ }
1415
+ }
1416
+ [borderTopColorProperty.setNative](value) {
1417
+ this._borderSideColor('t', value);
1418
+ }
1419
+ [borderRightColorProperty.setNative](value) {
1420
+ this._borderSideColor('r', value);
1421
+ }
1422
+ [borderBottomColorProperty.setNative](value) {
1423
+ this._borderSideColor('b', value);
1424
+ }
1425
+ [borderLeftColorProperty.setNative](value) {
1426
+ this._borderSideColor('l', value);
1427
+ }
1428
+ set border(value) {
1429
+ this.style.border = value;
1430
+ }
1431
+ get border() {
1432
+ return this.style.border;
1433
+ }
1434
+ // @ts-ignore
1435
+ set background(value) {
1436
+ this.style.background = value;
1437
+ }
1438
+ get background() {
1439
+ return this.style.background;
1440
+ }
1441
+ [backgroundProperty.setNative](value) {
1442
+ // @ts-ignore
1443
+ const style = this._styleHelper;
1444
+ if (style) {
1445
+ // @ts-ignore
1446
+ style.background = value;
1447
+ }
1448
+ }
1449
+ [backgroundColorProperty.setNative](value) {
1450
+ // @ts-ignore
1451
+ const style = this._styleHelper;
1452
+ if (style) {
1453
+ // Pass the raw value straight through — the style setter's normalizeColorValue handles
1454
+ // number / string / Color / {argb} via duck-typing, which is robust even when a `Color`
1455
+ // instance comes from a different @nativescript/core copy (cross-copy `instanceof` fails).
1456
+ // @ts-ignore
1457
+ style.backgroundColor = value;
1458
+ return;
1459
+ // eslint-disable-next-line no-unreachable
1460
+ switch (typeof value) {
1461
+ case 'number':
1462
+ // @ts-ignore
1463
+ style.backgroundColor = value;
1464
+ return;
1465
+ case 'object':
1466
+ if (value instanceof Color) {
1467
+ // @ts-ignore
1468
+ style.backgroundColor = value.argb;
1469
+ return;
1470
+ }
1471
+ break;
1472
+ case 'string':
1473
+ try {
1474
+ const color = new Color(value);
1475
+ // @ts-ignore
1476
+ style.backgroundColor = color.argb;
1477
+ }
1478
+ catch (error) { }
1479
+ return;
1480
+ }
1481
+ }
1482
+ }
1483
+ [borderLeftWidthProperty.setNative](value) {
1484
+ // @ts-ignore
1485
+ const style = this._styleHelper;
1486
+ if (style) {
1487
+ // @ts-ignore
1488
+ style.borderLeftWidth = masonLength(value);
1489
+ }
1490
+ }
1491
+ [borderTopWidthProperty.setNative](value) {
1492
+ // @ts-ignore
1493
+ const style = this._styleHelper;
1494
+ if (style) {
1495
+ // @ts-ignore
1496
+ style.borderTopWidth = masonLength(value);
1497
+ }
1498
+ }
1499
+ [borderRightWidthProperty.setNative](value) {
1500
+ // @ts-ignore
1501
+ const style = this._styleHelper;
1502
+ if (style) {
1503
+ // @ts-ignore
1504
+ style.borderRightWidth = masonLength(value);
1505
+ }
1506
+ }
1507
+ [borderBottomWidthProperty.setNative](value) {
1508
+ // @ts-ignore
1509
+ const style = this._styleHelper;
1510
+ if (style) {
1511
+ // @ts-ignore
1512
+ style.borderBottomWidth = masonLength(value);
1513
+ }
1514
+ }
1515
+ [lineHeightProperty.setNative](value) {
1516
+ // @ts-ignore
1517
+ const style = this._styleHelper;
1518
+ // @ts-ignore
1519
+ if (style)
1520
+ style.lineHeight = masonRawDeclaration(this.style, 'lineHeight', value);
1521
+ }
1522
+ [letterSpacingProperty.setNative](value) {
1523
+ // @ts-ignore
1524
+ const style = this._styleHelper;
1525
+ // @ts-ignore
1526
+ if (style)
1527
+ style.letterSpacing = masonRawDeclaration(this.style, 'letterSpacing', value);
1528
+ }
1529
+ [textAlignmentProperty.setNative](value) {
1530
+ // @ts-ignore
1531
+ const style = this._styleHelper;
1532
+ // @ts-ignore
1533
+ if (style)
1534
+ style.textAlignment = value;
1535
+ }
1536
+ [textDecorationProperty.setNative](value) {
1537
+ // @ts-ignore
1538
+ const style = this._styleHelper;
1539
+ if (style) {
1540
+ style.textDecoration = String(value);
1541
+ // The shorthand resets every longhand natively, but core tracks each as its own
1542
+ // property and won't reapply one it already holds. Put the explicit ones back.
1543
+ const cssStyle = this.style;
1544
+ for (const name of ['textDecorationLine', 'textDecorationStyle', 'textDecorationColor', 'textDecorationThickness']) {
1545
+ const longhand = cssStyle[name];
1546
+ if (longhand !== undefined && longhand !== null && longhand !== '') {
1547
+ style[name] = longhand;
1548
+ }
1549
+ }
1550
+ }
1551
+ }
1552
+ // @ts-ignore
1553
+ [borderColorProperty.setNative](value) {
1554
+ if (__ANDROID__) {
1555
+ const s = this._styleHelper;
1556
+ if (s)
1557
+ s.setBorderColor(String(value));
1558
+ // @ts-ignore
1559
+ else
1560
+ nodeHelper().setBorderColor(this.nativeView, String(value));
1561
+ }
1562
+ else if (__APPLE__) {
1563
+ const s = this._styleHelper;
1564
+ if (s)
1565
+ s.setBorderColor(String(value));
1566
+ // @ts-ignore
1567
+ else
1568
+ this.nativeView.style.setBorderColor(String(value));
1569
+ }
1570
+ else if (false) {
1571
+ // @ts-ignore
1572
+ const style = this._styleHelper;
1573
+ // @ts-ignore
1574
+ if (style)
1575
+ style.setBorderColor(String(value));
1576
+ }
1577
+ }
1578
+ // `border-style`, `border` and `border-<side>` are shorthands over these.
1579
+ [borderTopStyleProperty.setNative](value) {
1580
+ // @ts-ignore
1581
+ const style = this._styleHelper;
1582
+ if (style)
1583
+ style.borderTopStyle = String(value ?? 'none');
1584
+ }
1585
+ [borderRightStyleProperty.setNative](value) {
1586
+ // @ts-ignore
1587
+ const style = this._styleHelper;
1588
+ if (style)
1589
+ style.borderRightStyle = String(value ?? 'none');
1590
+ }
1591
+ [borderBottomStyleProperty.setNative](value) {
1592
+ // @ts-ignore
1593
+ const style = this._styleHelper;
1594
+ if (style)
1595
+ style.borderBottomStyle = String(value ?? 'none');
1596
+ }
1597
+ [borderLeftStyleProperty.setNative](value) {
1598
+ // @ts-ignore
1599
+ const style = this._styleHelper;
1600
+ if (style)
1601
+ style.borderLeftStyle = String(value ?? 'none');
1602
+ }
1603
+ // @ts-ignore
1604
+ [backgroundImageProperty.setNative](value) {
1605
+ // @ts-ignore
1606
+ const style = this._styleHelper;
1607
+ if (style) {
1608
+ // @ts-ignore
1609
+ style.backgroundImage = backgroundImageToCssString(value);
1610
+ }
1611
+ }
1612
+ // @ts-ignore
1613
+ [listStyleTypeProperty.setNative](value) {
1614
+ if (__ANDROID__) {
1615
+ // @ts-ignore
1616
+ nodeHelper().setListStyleType(this.nativeView, String(value));
1617
+ }
1618
+ else if (__APPLE__) {
1619
+ // @ts-ignore
1620
+ this.nativeView.style.applyListStyleType(String(value));
1621
+ }
1622
+ else if (false) {
1623
+ const style = this._styleHelper;
1624
+ const type = String(value).trim().toLowerCase();
1625
+ if (style && (type === 'none' || type === 'disc' || type === 'circle' || type === 'square' || type === 'decimal'))
1626
+ style.listStyleType = type;
1627
+ }
1628
+ }
1629
+ // @ts-ignore
1630
+ [listStylePositionProperty.setNative](value) {
1631
+ if (__ANDROID__) {
1632
+ // @ts-ignore
1633
+ nodeHelper().setListStylePosition(this.nativeView, String(value));
1634
+ }
1635
+ else if (__APPLE__) {
1636
+ // @ts-ignore
1637
+ this.nativeView.style.applyListStylePosition(String(value));
1638
+ }
1639
+ else if (false) {
1640
+ const style = this._styleHelper;
1641
+ const position = String(value).trim().toLowerCase();
1642
+ if (style && (position === 'inside' || position === 'outside'))
1643
+ style.listStylePosition = position;
1644
+ }
1645
+ }
1646
+ get boxSizing() {
1647
+ return this.style.boxSizing;
1648
+ }
1649
+ set boxSizing(value) {
1650
+ this.style.boxSizing = value;
1651
+ }
1652
+ [boxSizingProperty.setNative](value) {
1653
+ // @ts-ignore
1654
+ const style = this._styleHelper;
1655
+ if (style) {
1656
+ // @ts-ignore
1657
+ style.boxSizing = value;
1658
+ }
1659
+ }
1660
+ get display() {
1661
+ return this.style.display;
1662
+ }
1663
+ set display(value) {
1664
+ this.style.display = value;
1665
+ }
1666
+ [displayProperty.setNative](value) {
1667
+ // @ts-ignore
1668
+ const style = this._styleHelper;
1669
+ if (style) {
1670
+ // @ts-ignore
1671
+ style.display = value;
1672
+ }
1673
+ }
1674
+ get overflow() {
1675
+ return this.style.overflow;
1676
+ }
1677
+ set overflow(value) {
1678
+ this.style.overflow = value;
1679
+ }
1680
+ get overflowX() {
1681
+ return this.style.overflowX;
1682
+ }
1683
+ set overflowX(value) {
1684
+ this.style.overflowX = value;
1685
+ }
1686
+ [overflowXProperty.setNative](value) {
1687
+ // @ts-ignore
1688
+ const style = this._styleHelper;
1689
+ if (style) {
1690
+ // @ts-ignore
1691
+ style.overflowX = value;
1692
+ }
1693
+ }
1694
+ get overflowY() {
1695
+ return this.style.overflowY;
1696
+ }
1697
+ set overflowY(value) {
1698
+ this.style.overflowY = value;
1699
+ }
1700
+ [overflowYProperty.setNative](value) {
1701
+ // @ts-ignore
1702
+ const style = this._styleHelper;
1703
+ if (style) {
1704
+ // @ts-ignore
1705
+ style.overflowY = value;
1706
+ }
1707
+ }
1708
+ get scrollBarWidth() {
1709
+ return this.style.scrollBarWidth;
1710
+ }
1711
+ set scrollBarWidth(value) {
1712
+ this.style.scrollBarWidth = value;
1713
+ }
1714
+ [scrollBarWidthProperty.setNative](value) {
1715
+ // @ts-ignore
1716
+ const style = this._styleHelper;
1717
+ if (style) {
1718
+ // @ts-ignore
1719
+ style.scrollBarWidth = value;
1720
+ }
1721
+ }
1722
+ get position() {
1723
+ return this.style.position;
1724
+ }
1725
+ set position(value) {
1726
+ this.style.position = value;
1727
+ }
1728
+ [positionProperty.setNative](value) {
1729
+ // @ts-ignore
1730
+ const style = this._styleHelper;
1731
+ if (style) {
1732
+ // @ts-ignore
1733
+ style.position = value;
1734
+ }
1735
+ }
1736
+ // Font props only land in the style buffer, which the TextBlock-backed text doesn't read, so they
1737
+ // must be forwarded to the native Text control to take visual effect. No-op off a Text container.
1738
+ _applyTextRunProp(method, arg) {
1739
+ if (!false)
1740
+ return;
1741
+ try {
1742
+ const view = this._view;
1743
+ if (view && typeof view[method] === 'function')
1744
+ view[method](arg);
1745
+ }
1746
+ catch (_) { }
1747
+ }
1748
+ [colorProperty.setNative](value) {
1749
+ // @ts-ignore
1750
+ const style = this._styleHelper;
1751
+ if (style) {
1752
+ // Duck-typed via normalizeColorValue (robust to cross-core Color instances).
1753
+ // @ts-ignore
1754
+ style.color = value;
1755
+ if (false) {
1756
+ // Push the resolved color to the Text container's TextBlock (the default for all runs).
1757
+ // Imperative — not during layout.
1758
+ try {
1759
+ const argb = style.color >>> 0 || 0;
1760
+ const view = this._view;
1761
+ if (view && argb && typeof view.SetColor === 'function')
1762
+ view.SetColor(argb);
1763
+ }
1764
+ catch (_) { }
1765
+ }
1766
+ }
1767
+ }
1768
+ [flexWrapProperty.setNative](value) {
1769
+ // @ts-ignore
1770
+ const style = this._styleHelper;
1771
+ if (style) {
1772
+ style.flexWrap = value;
1773
+ }
1774
+ }
1775
+ [flexDirectionProperty.setNative](value) {
1776
+ // @ts-ignore
1777
+ const style = this._styleHelper;
1778
+ if (style) {
1779
+ style.flexDirection = value;
1780
+ }
1781
+ }
1782
+ [flexGrowProperty.setNative](value) {
1783
+ // @ts-ignore
1784
+ const style = this._styleHelper;
1785
+ if (style) {
1786
+ style.flexGrow = value;
1787
+ }
1788
+ }
1789
+ [flexShrinkProperty.setNative](value) {
1790
+ // @ts-ignore
1791
+ const style = this._styleHelper;
1792
+ if (style) {
1793
+ style.flexShrink = value;
1794
+ }
1795
+ }
1796
+ [flexBasisProperty.setNative](value) {
1797
+ // @ts-ignore
1798
+ const style = this._styleHelper;
1799
+ if (style) {
1800
+ style.flexBasis = value;
1801
+ }
1802
+ }
1803
+ [alignItemsProperty.setNative](value) {
1804
+ // @ts-ignore
1805
+ const style = this._styleHelper;
1806
+ if (style) {
1807
+ style.alignItems = value;
1808
+ }
1809
+ }
1810
+ [alignSelfProperty.setNative](value) {
1811
+ // @ts-ignore
1812
+ const style = this._styleHelper;
1813
+ if (style) {
1814
+ style.alignSelf = value;
1815
+ }
1816
+ }
1817
+ get alignContent() {
1818
+ return this.style.alignContent;
1819
+ }
1820
+ set alignContent(value) {
1821
+ this.style.alignContent = value;
1822
+ }
1823
+ [alignContentProperty.setNative](value) {
1824
+ // @ts-ignore
1825
+ const style = this._styleHelper;
1826
+ if (style) {
1827
+ style.alignContent = value;
1828
+ }
1829
+ }
1830
+ get justifyItems() {
1831
+ return this.style.justifyItems;
1832
+ }
1833
+ set justifyItems(value) {
1834
+ this.style.justifyItems = value;
1835
+ }
1836
+ [justifyItemsProperty.setNative](value) {
1837
+ // @ts-ignore
1838
+ const style = this._styleHelper;
1839
+ if (style) {
1840
+ style.justifyItems = value;
1841
+ }
1842
+ }
1843
+ get justifySelf() {
1844
+ return this.style.justifySelf;
1845
+ }
1846
+ set justifySelf(value) {
1847
+ this.style.justifySelf = value;
1848
+ }
1849
+ [justifySelfProperty.setNative](value) {
1850
+ // @ts-ignore
1851
+ const style = this._styleHelper;
1852
+ if (style) {
1853
+ style.justifySelf = value;
1854
+ }
1855
+ }
1856
+ [justifyContentProperty.setNative](value) {
1857
+ // @ts-ignore
1858
+ const style = this._styleHelper;
1859
+ if (style) {
1860
+ style.justifyContent = value;
1861
+ }
1862
+ }
1863
+ [leftProperty.setNative](value) {
1864
+ // @ts-ignore
1865
+ const style = this._styleHelper;
1866
+ if (style) {
1867
+ style.left = value;
1868
+ }
1869
+ }
1870
+ get right() {
1871
+ return this.style.right;
1872
+ }
1873
+ set right(value) {
1874
+ this.style.right = value;
1875
+ }
1876
+ [rightProperty.setNative](value) {
1877
+ // @ts-ignore
1878
+ const style = this._styleHelper;
1879
+ if (style) {
1880
+ style.right = value;
1881
+ }
1882
+ }
1883
+ get bottom() {
1884
+ return this.style.bottom;
1885
+ }
1886
+ set bottom(value) {
1887
+ this.style.bottom = value;
1888
+ }
1889
+ [bottomProperty.setNative](value) {
1890
+ // @ts-ignore
1891
+ const style = this._styleHelper;
1892
+ if (style) {
1893
+ style.bottom = value;
1894
+ }
1895
+ }
1896
+ [topProperty.setNative](value) {
1897
+ // @ts-ignore
1898
+ const style = this._styleHelper;
1899
+ if (style) {
1900
+ style.top = value;
1901
+ }
1902
+ }
1903
+ [minWidthProperty.setNative](value) {
1904
+ // @ts-ignore
1905
+ const style = this._styleHelper;
1906
+ if (style) {
1907
+ style.minWidth = value;
1908
+ }
1909
+ }
1910
+ [minHeightProperty.setNative](value) {
1911
+ // @ts-ignore
1912
+ const style = this._styleHelper;
1913
+ if (style) {
1914
+ style.minHeight = value;
1915
+ }
1916
+ }
1917
+ [heightProperty.setNative](value) {
1918
+ // @ts-ignore
1919
+ const style = this._styleHelper;
1920
+ if (style) {
1921
+ style.height = value;
1922
+ }
1923
+ }
1924
+ [widthProperty.setNative](value) {
1925
+ // @ts-ignore
1926
+ const style = this._styleHelper;
1927
+ if (style) {
1928
+ style.width = value;
1929
+ }
1930
+ }
1931
+ // @ts-ignore core declares maxWidth as a field on View
1932
+ set maxWidth(value) {
1933
+ this.style.maxWidth = value;
1934
+ }
1935
+ // @ts-ignore
1936
+ get maxWidth() {
1937
+ return this.style.maxWidth;
1938
+ }
1939
+ // @ts-ignore core declares maxHeight as a field on View
1940
+ set maxHeight(value) {
1941
+ this.style.maxHeight = value;
1942
+ }
1943
+ // @ts-ignore
1944
+ get maxHeight() {
1945
+ return this.style.maxHeight;
1946
+ }
1947
+ [maxWidthProperty.setNative](value) {
1948
+ // @ts-ignore
1949
+ const style = this._styleHelper;
1950
+ if (style) {
1951
+ style.maxWidth = value;
1952
+ }
1953
+ }
1954
+ [maxHeightProperty.setNative](value) {
1955
+ // @ts-ignore
1956
+ const style = this._styleHelper;
1957
+ if (style) {
1958
+ style.maxHeight = value;
1959
+ }
1960
+ }
1961
+ _redrawNativeBackground(value) { }
1962
+ [backgroundInternalProperty.getDefault]() {
1963
+ if (__ANDROID__ || __APPLE__)
1964
+ return null;
1965
+ // @ts-ignore
1966
+ return super[backgroundInternalProperty.getDefault]?.();
1967
+ }
1968
+ [marginProperty.setNative](value) {
1969
+ // @ts-ignore
1970
+ const style = this._styleHelper;
1971
+ if (style) {
1972
+ style.marginCss = value;
1973
+ }
1974
+ }
1975
+ [marginLeftProperty.setNative](value) {
1976
+ // @ts-ignore
1977
+ const style = this._styleHelper;
1978
+ if (style) {
1979
+ style.marginLeft = masonLength(value);
1980
+ }
1981
+ }
1982
+ [marginRightProperty.setNative](value) {
1983
+ // @ts-ignore
1984
+ const style = this._styleHelper;
1985
+ if (style) {
1986
+ style.marginRight = masonLength(value);
1987
+ }
1988
+ }
1989
+ [marginBottomProperty.setNative](value) {
1990
+ // @ts-ignore
1991
+ const style = this._styleHelper;
1992
+ if (style) {
1993
+ style.marginBottom = masonLength(value);
1994
+ }
1995
+ }
1996
+ [marginTopProperty.setNative](value) {
1997
+ // @ts-ignore
1998
+ const style = this._styleHelper;
1999
+ if (style) {
2000
+ style.marginTop = masonLength(value);
2001
+ }
2002
+ }
2003
+ get padding() {
2004
+ return this.style.padding;
2005
+ }
2006
+ set padding(value) {
2007
+ this.style.padding = value;
2008
+ }
2009
+ [paddingProperty.setNative](value) {
2010
+ // @ts-ignore
2011
+ const style = this._styleHelper;
2012
+ if (style) {
2013
+ // @ts-ignore
2014
+ style.paddingCss = value;
2015
+ }
2016
+ }
2017
+ [paddingLeftProperty.setNative](value) {
2018
+ // @ts-ignore
2019
+ const style = this._styleHelper;
2020
+ if (style) {
2021
+ style.paddingLeft = masonLength(value);
2022
+ }
2023
+ }
2024
+ [paddingRightProperty.setNative](value) {
2025
+ // @ts-ignore
2026
+ const style = this._styleHelper;
2027
+ if (style) {
2028
+ style.paddingRight = masonLength(value);
2029
+ }
2030
+ }
2031
+ [paddingTopProperty.setNative](value) {
2032
+ // @ts-ignore
2033
+ const style = this._styleHelper;
2034
+ if (style) {
2035
+ style.paddingTop = masonLength(value);
2036
+ }
2037
+ }
2038
+ [paddingBottomProperty.setNative](value) {
2039
+ // @ts-ignore
2040
+ const style = this._styleHelper;
2041
+ if (style) {
2042
+ style.paddingBottom = masonLength(value);
2043
+ }
2044
+ }
2045
+ set gap(value) {
2046
+ this.style.gap = value;
2047
+ }
2048
+ get gap() {
2049
+ return this.style.gap;
2050
+ }
2051
+ set gridGap(value) {
2052
+ this.style.gridGap = value;
2053
+ }
2054
+ get gridGap() {
2055
+ return this.style.gridGap;
2056
+ }
2057
+ set rowGap(value) {
2058
+ this.style.rowGap = value;
2059
+ }
2060
+ get rowGap() {
2061
+ return this.style.rowGap;
2062
+ }
2063
+ [rowGapProperty.setNative](value) {
2064
+ // @ts-ignore
2065
+ const style = this._styleHelper;
2066
+ if (style) {
2067
+ // @ts-ignore
2068
+ style.rowGap = value;
2069
+ }
2070
+ }
2071
+ set columnGap(value) {
2072
+ this.style.columnGap = value;
2073
+ }
2074
+ get columnGap() {
2075
+ return this.style.columnGap;
2076
+ }
2077
+ [columnGapProperty.setNative](value) {
2078
+ // @ts-ignore
2079
+ const style = this._styleHelper;
2080
+ if (style) {
2081
+ // @ts-ignore
2082
+ style.columnGap = value;
2083
+ }
2084
+ }
2085
+ set gridColumnStart(value) {
2086
+ this.style.gridColumnStart = value;
2087
+ }
2088
+ get gridColumnStart() {
2089
+ return this.style.gridColumnStart;
2090
+ }
2091
+ [gridColumnStartProperty.setNative](value) {
2092
+ // @ts-ignore
2093
+ const style = this._styleHelper;
2094
+ if (style) {
2095
+ // @ts-ignore
2096
+ style.gridColumnStart = value;
2097
+ }
2098
+ }
2099
+ set gridColumnEnd(value) {
2100
+ this.style.gridColumnEnd = value;
2101
+ }
2102
+ get gridColumnEnd() {
2103
+ return this.style.gridColumnEnd;
2104
+ }
2105
+ [gridColumnEndProperty.setNative](value) {
2106
+ // @ts-ignore
2107
+ const style = this._styleHelper;
2108
+ if (style) {
2109
+ // @ts-ignore
2110
+ style.gridColumnEnd = value;
2111
+ }
2112
+ }
2113
+ get gridColumn() {
2114
+ return this.style.gridColumn;
2115
+ }
2116
+ set gridColumn(value) {
2117
+ this.style.gridColumn = value;
2118
+ }
2119
+ [gridColumnProperty.setNative](value) {
2120
+ // @ts-ignore
2121
+ const style = this._styleHelper;
2122
+ if (style) {
2123
+ // @ts-ignore
2124
+ style.gridColumn = value;
2125
+ }
2126
+ }
2127
+ set gridRowStart(value) {
2128
+ this.style.gridRowStart = value;
2129
+ }
2130
+ get gridRowStart() {
2131
+ return this.style.gridRowStart;
2132
+ }
2133
+ [gridRowStartProperty.setNative](value) {
2134
+ // @ts-ignore
2135
+ const style = this._styleHelper;
2136
+ if (style) {
2137
+ // @ts-ignore
2138
+ style.gridRowStart = value;
2139
+ }
2140
+ }
2141
+ set gridRowEnd(value) {
2142
+ this.style.gridRowEnd = value;
2143
+ }
2144
+ get gridRowEnd() {
2145
+ return this.style.gridRowEnd;
2146
+ }
2147
+ [gridRowEndProperty.setNative](value) {
2148
+ // @ts-ignore
2149
+ const style = this._styleHelper;
2150
+ if (style) {
2151
+ // @ts-ignore
2152
+ style.gridRowEnd = value;
2153
+ }
2154
+ }
2155
+ get gridRow() {
2156
+ return this.style.gridRow;
2157
+ }
2158
+ set gridRow(value) {
2159
+ this.style.gridRow = value;
2160
+ }
2161
+ [gridRowProperty.setNative](value) {
2162
+ // @ts-ignore
2163
+ const style = this._styleHelper;
2164
+ if (style) {
2165
+ // @ts-ignore
2166
+ style.gridRow = value;
2167
+ }
2168
+ }
2169
+ set gridTemplateRows(value) {
2170
+ this.style.gridTemplateRows = value;
2171
+ }
2172
+ get gridTemplateRows() {
2173
+ return this.style.gridTemplateRows;
2174
+ }
2175
+ [gridTemplateRowsProperty.setNative](value) {
2176
+ // @ts-ignore
2177
+ const style = this._styleHelper;
2178
+ if (style) {
2179
+ // @ts-ignore
2180
+ style.gridTemplateRows = value;
2181
+ }
2182
+ }
2183
+ set gridTemplateColumns(value) {
2184
+ this.style.gridTemplateColumns = value;
2185
+ }
2186
+ get gridTemplateColumns() {
2187
+ return this.style.gridTemplateColumns;
2188
+ }
2189
+ [gridTemplateColumnsProperty.setNative](value) {
2190
+ // @ts-ignore
2191
+ const style = this._styleHelper;
2192
+ if (style) {
2193
+ // @ts-ignore
2194
+ style.gridTemplateColumns = value;
2195
+ }
2196
+ }
2197
+ set gridAutoColumns(value) {
2198
+ this.style.gridAutoColumns = value;
2199
+ }
2200
+ get gridAutoColumns() {
2201
+ return this.style.gridAutoColumns;
2202
+ }
2203
+ [gridAutoColumnsProperty.setNative](value) {
2204
+ // @ts-ignore
2205
+ const style = this._styleHelper;
2206
+ if (style) {
2207
+ // @ts-ignore
2208
+ style.gridAutoColumns = value;
2209
+ }
2210
+ }
2211
+ set gridAutoRows(value) {
2212
+ this.style.gridAutoRows = value;
2213
+ }
2214
+ get gridAutoRows() {
2215
+ return this.style.gridAutoRows;
2216
+ }
2217
+ [gridAutoRowsProperty.setNative](value) {
2218
+ // @ts-ignore
2219
+ const style = this._styleHelper;
2220
+ if (style) {
2221
+ // @ts-ignore
2222
+ style.gridAutoRows = value;
2223
+ }
2224
+ }
2225
+ set gridAutoFlow(value) {
2226
+ this.style.gridAutoFlow = value;
2227
+ }
2228
+ get gridAutoFlow() {
2229
+ return this.style.gridAutoFlow;
2230
+ }
2231
+ [gridAutoFlowProperty.setNative](value) {
2232
+ // @ts-ignore
2233
+ const style = this._styleHelper;
2234
+ if (style) {
2235
+ // @ts-ignore
2236
+ style.gridAutoFlow = value;
2237
+ }
2238
+ }
2239
+ set gridArea(value) {
2240
+ this.style.gridArea = value;
2241
+ }
2242
+ get gridArea() {
2243
+ return this.style.gridArea;
2244
+ }
2245
+ [gridAreaProperty.setNative](value) {
2246
+ // @ts-ignore
2247
+ const style = this._styleHelper;
2248
+ if (style) {
2249
+ // @ts-ignore
2250
+ style.gridArea = value;
2251
+ }
2252
+ }
2253
+ set gridTemplateAreas(value) {
2254
+ this.style.gridTemplateAreas = value;
2255
+ }
2256
+ get gridTemplateAreas() {
2257
+ return this.style.gridTemplateAreas;
2258
+ }
2259
+ [gridTemplateAreasProperty.setNative](value) {
2260
+ // @ts-ignore
2261
+ const style = this._styleHelper;
2262
+ if (style) {
2263
+ // @ts-ignore
2264
+ style.gridTemplateAreas = value;
2265
+ }
2266
+ }
2267
+ [fontSizeProperty.setNative](value) {
2268
+ // @ts-ignore
2269
+ if (this._styleHelper) {
2270
+ //@ts-ignore
2271
+ this._styleHelper.fontSize = value;
2272
+ }
2273
+ }
2274
+ [fontWeightProperty.setNative](value) {
2275
+ // @ts-ignore
2276
+ if (this._styleHelper) {
2277
+ //@ts-ignore
2278
+ this._styleHelper.fontWeight = value;
2279
+ }
2280
+ }
2281
+ [fontStyleProperty.setNative](value) {
2282
+ // @ts-ignore
2283
+ if (this._styleHelper) {
2284
+ //@ts-ignore
2285
+ this._styleHelper.fontStyle = value;
2286
+ }
2287
+ }
2288
+ set flexFlowProperty(value) {
2289
+ this.style.flexFlow = value;
2290
+ }
2291
+ get flexFlowProperty() {
2292
+ return this.style.flexFlow;
2293
+ }
2294
+ set inset(value) {
2295
+ // @ts-ignore
2296
+ const style = this._styleHelper;
2297
+ if (style) {
2298
+ style.insetCss = value;
2299
+ }
2300
+ }
2301
+ get inset() {
2302
+ return this.style.inset;
2303
+ }
2304
+ set textOverFlow(value) {
2305
+ this.style.textOverflow = value;
2306
+ }
2307
+ get textOverFlow() {
2308
+ return this.style.textOverflow;
2309
+ }
2310
+ [textOverFlowProperty.setNative](value) {
2311
+ // @ts-ignore
2312
+ const style = this._styleHelper;
2313
+ if (style) {
2314
+ style.textOverflow = value;
2315
+ }
2316
+ }
2317
+ [clearProperty.setNative](value) {
2318
+ // @ts-ignore
2319
+ const style = this._styleHelper;
2320
+ if (style) {
2321
+ // @ts-ignore
2322
+ style.clear = value;
2323
+ }
2324
+ }
2325
+ [floatProperty.setNative](value) {
2326
+ // @ts-ignore
2327
+ const style = this._styleHelper;
2328
+ if (style) {
2329
+ // @ts-ignore
2330
+ style.float = value;
2331
+ }
2332
+ }
2333
+ [cornerShapeProperty.setNative](value) {
2334
+ // @ts-ignore
2335
+ const style = this._styleHelper;
2336
+ if (style) {
2337
+ style.cornerShape = value;
2338
+ }
2339
+ }
2340
+ [boxShadowProperty.setNative](value) {
2341
+ // @ts-ignore
2342
+ const style = this._styleHelper;
2343
+ if (style) {
2344
+ // @ts-ignore
2345
+ style.boxShadow = value;
2346
+ if (false) {
2347
+ const nv = this.nativeViewProtected ?? this._view;
2348
+ try {
2349
+ const shadows = parseBoxShadows(typeof value === 'string' ? value : '', (token) => cssLengthToDip(token, style.emBasisFor(token)));
2350
+ const current = style.color >>> 0 || 0xff000000;
2351
+ const spec = encodeBoxShadows(shadows, (color) => {
2352
+ if (!color || color.toLowerCase() === 'currentcolor')
2353
+ return current;
2354
+ try {
2355
+ return new Color(color).argb >>> 0;
2356
+ }
2357
+ catch (_) {
2358
+ return current;
2359
+ }
2360
+ });
2361
+ NativeScript.Mason.Css.SetBoxShadow(nv, spec);
2362
+ }
2363
+ catch (_) { }
2364
+ }
2365
+ }
2366
+ }
2367
+ // Core's scale/rotate/translate on Windows. Core's own TransformGroup never renders on a Mason
2368
+ // element, so View.rotate etc. did nothing; they're set natively as one matrix instead. CSS
2369
+ // keyframes and animate() play them per frame (css-keyframes.ts).
2370
+ updateNativeTransform() {
2371
+ if (!false) {
2372
+ // @ts-ignore
2373
+ return super.updateNativeTransform?.();
2374
+ }
2375
+ const native = this.nativeViewProtected;
2376
+ if (!native)
2377
+ return;
2378
+ const self = this;
2379
+ const origin = this._windowsTransformOrigin(native);
2380
+ NativeScript.Mason.Css.SetTransforms(native, typeof self.scaleX === 'number' ? self.scaleX : 1, typeof self.scaleY === 'number' ? self.scaleY : 1, self.rotate || 0, self.translateX || 0, self.translateY || 0, origin.x, origin.y);
2381
+ }
2382
+ // CSS transform-origin when set, else core's originX/originY. RenderTransformOrigin is shared
2383
+ // by every part of the element's transform.
2384
+ _windowsTransformOrigin(native) {
2385
+ const self = this;
2386
+ // @ts-ignore
2387
+ const css = this._styleHelper?.transformOriginFraction?.(native?.ActualWidth ?? 0, native?.ActualHeight ?? 0);
2388
+ return css ?? { x: self.originX ?? 0.5, y: self.originY ?? 0.5 };
2389
+ }
2390
+ _applyWindowsTransform(value = this._windowsTransformValue) {
2391
+ // @ts-ignore
2392
+ const style = this._styleHelper;
2393
+ const nv = this.nativeViewProtected ?? this._view;
2394
+ this._windowsTransformValue = value;
2395
+ if (!style || !nv)
2396
+ return;
2397
+ try {
2398
+ const size = { width: nv.ActualWidth ?? 0, height: nv.ActualHeight ?? 0 };
2399
+ const m = parseCssTransform(typeof value === 'string' ? value : '', (token) => cssLengthToDip(token, style.emBasisFor(token)), size);
2400
+ const origin = this._windowsTransformOrigin(nv);
2401
+ if (!m)
2402
+ NativeScript.Mason.Css.ClearTransform(nv);
2403
+ else
2404
+ NativeScript.Mason.Css.ApplyTransform(nv, m[0], m[1], m[2], m[3], m[4], m[5]);
2405
+ NativeScript.Mason.Css.SetTransformOrigin(nv, origin.x, origin.y);
2406
+ }
2407
+ catch (_) { }
2408
+ }
2409
+ animate(options) {
2410
+ if (!false || !options || !('rotate' in options || 'scale' in options || 'translate' in options)) {
2411
+ return super.animate(options);
2412
+ }
2413
+ // Core's storyboards would animate a transform that doesn't show on a Mason view.
2414
+ const { rotate, scale, translate, ...rest } = options;
2415
+ const core = ['opacity', 'backgroundColor', 'width', 'height'].some((key) => key in rest) ? super.animate(rest) : null;
2416
+ const transforms = animateTransforms(this, options);
2417
+ const promise = Promise.all([core, transforms.done]).then(() => undefined);
2418
+ promise.cancel = () => {
2419
+ transforms.cancel();
2420
+ core?.cancel?.();
2421
+ };
2422
+ return promise;
2423
+ }
2424
+ [originXProperty.setNative](value) {
2425
+ if (!false) {
2426
+ // @ts-ignore
2427
+ return super[originXProperty.setNative]?.(value);
2428
+ }
2429
+ this.updateNativeTransform();
2430
+ }
2431
+ [originYProperty.setNative](value) {
2432
+ if (!false) {
2433
+ // @ts-ignore
2434
+ return super[originYProperty.setNative]?.(value);
2435
+ }
2436
+ this.updateNativeTransform();
2437
+ }
2438
+ [transformProperty.setNative](value) {
2439
+ // @ts-ignore
2440
+ const style = this._styleHelper;
2441
+ if (style) {
2442
+ // @ts-ignore
2443
+ style.transform = value;
2444
+ // Windows: transform isn't read from the buffer; it becomes the panel's RenderTransform.
2445
+ if (false)
2446
+ this._applyWindowsTransform(value);
2447
+ }
2448
+ }
2449
+ }
2450
+ ViewBase._pendingTeardowns = [];
2451
+ ViewBase._teardownScheduled = false;
2452
+ __decorate([
2453
+ PseudoClassHandler('hover'),
2454
+ __metadata("design:type", Function),
2455
+ __metadata("design:paramtypes", [Boolean]),
2456
+ __metadata("design:returntype", void 0)
2457
+ ], ViewBase.prototype, "_hoverHandler", null);
2458
+ __decorate([
2459
+ PseudoClassHandler('highlighted', 'pressed', 'active'),
2460
+ __metadata("design:type", Function),
2461
+ __metadata("design:paramtypes", [Boolean]),
2462
+ __metadata("design:returntype", void 0)
2463
+ ], ViewBase.prototype, "_handler", null);
2464
+ __decorate([
2465
+ PseudoClassHandler('disabled'),
2466
+ __metadata("design:type", Function),
2467
+ __metadata("design:paramtypes", [Boolean]),
2468
+ __metadata("design:returntype", void 0)
2469
+ ], ViewBase.prototype, "_disableHandler", null);
2470
+ __decorate([
2471
+ PseudoClassHandler('focus'),
2472
+ __metadata("design:type", Function),
2473
+ __metadata("design:paramtypes", [Boolean]),
2474
+ __metadata("design:returntype", void 0)
2475
+ ], ViewBase.prototype, "_focusHandler", null);
2476
+ __decorate([
2477
+ PseudoClassHandler('blur'),
2478
+ __metadata("design:type", Function),
2479
+ __metadata("design:paramtypes", [Boolean]),
2480
+ __metadata("design:returntype", void 0)
2481
+ ], ViewBase.prototype, "_blurHandler", null);
2482
+ export class Event {
2483
+ get bubbles() {
2484
+ if (__ANDROID__) {
2485
+ return this[native_]?.getBubbles();
2486
+ }
2487
+ if (__APPLE__) {
2488
+ return this[native_]?.bubbles;
2489
+ }
2490
+ if (false) {
2491
+ return this[native_]?.Bubbles ?? false;
2492
+ }
2493
+ return false;
2494
+ }
2495
+ get cancelable() {
2496
+ if (__ANDROID__) {
2497
+ return this[native_]?.getCancelable();
2498
+ }
2499
+ if (__APPLE__) {
2500
+ return this[native_]?.cancelable;
2501
+ }
2502
+ if (false) {
2503
+ return this[native_]?.Cancelable ?? false;
2504
+ }
2505
+ return false;
2506
+ }
2507
+ get isComposing() {
2508
+ if (__ANDROID__) {
2509
+ return this[native_]?.getIsComposing();
2510
+ }
2511
+ if (__APPLE__) {
2512
+ return this[native_]?.isComposing;
2513
+ }
2514
+ if (false) {
2515
+ return this[native_]?.IsComposing ?? false;
2516
+ }
2517
+ return false;
2518
+ }
2519
+ get timeStamp() {
2520
+ if (__ANDROID__) {
2521
+ return this[native_]?.getTimeStamp();
2522
+ }
2523
+ if (__APPLE__) {
2524
+ return this[native_]?.timeStamp;
2525
+ }
2526
+ if (false) {
2527
+ return this[native_]?.TimeStamp ?? 0;
2528
+ }
2529
+ return 0;
2530
+ }
2531
+ get defaultPrevented() {
2532
+ if (__ANDROID__) {
2533
+ return this[native_]?.getDefaultPrevented();
2534
+ }
2535
+ if (__APPLE__) {
2536
+ return this[native_]?.defaultPrevented;
2537
+ }
2538
+ if (false) {
2539
+ return this[native_]?.DefaultPrevented ?? false;
2540
+ }
2541
+ return false;
2542
+ }
2543
+ get propagationStopped() {
2544
+ if (__ANDROID__) {
2545
+ return this[native_]?.getPropagationStopped();
2546
+ }
2547
+ if (__APPLE__) {
2548
+ return this[native_]?.propagationStopped;
2549
+ }
2550
+ if (false) {
2551
+ return this[native_]?.PropagationStopped ?? false;
2552
+ }
2553
+ return false;
2554
+ }
2555
+ get immediatePropagationStopped() {
2556
+ if (__ANDROID__) {
2557
+ return this[native_]?.getImmediatePropagationStopped();
2558
+ }
2559
+ if (__APPLE__) {
2560
+ return this[native_]?.immediatePropagationStopped;
2561
+ }
2562
+ if (false) {
2563
+ return this[native_]?.ImmediatePropagationStopped ?? false;
2564
+ }
2565
+ return false;
2566
+ }
2567
+ get currentTarget() {
2568
+ // DOM semantics: the element the listener is attached to, not the raw
2569
+ // native view. `_target` is set to that same owner at every dispatch
2570
+ // site (_registerNativeEvent), so reuse it here.
2571
+ return this['_target'];
2572
+ }
2573
+ stopImmediatePropagation() {
2574
+ if (__ANDROID__) {
2575
+ return this[native_]?.stopImmediatePropagation();
2576
+ }
2577
+ if (__APPLE__) {
2578
+ return this[native_]?.stopImmediatePropagation();
2579
+ }
2580
+ if (false) {
2581
+ return this[native_]?.StopImmediatePropagation();
2582
+ }
2583
+ }
2584
+ stopPropagation() {
2585
+ if (__ANDROID__) {
2586
+ return this[native_]?.stopPropagation();
2587
+ }
2588
+ if (__APPLE__) {
2589
+ return this[native_]?.stopPropagation();
2590
+ }
2591
+ if (false) {
2592
+ return this[native_]?.StopPropagation();
2593
+ }
2594
+ }
2595
+ preventDefault() {
2596
+ if (__ANDROID__) {
2597
+ return this[native_]?.preventDefault();
2598
+ }
2599
+ if (__APPLE__) {
2600
+ return this[native_]?.preventDefault();
2601
+ }
2602
+ if (false) {
2603
+ return this[native_]?.PreventDefault();
2604
+ }
2605
+ }
2606
+ // Writable on purpose, unlike the DOM's read-only `Event.type`. Aliases
2607
+ // (e.g. 'tap') are folded onto the native name ('click') before the event
2608
+ // reaches JS; a host framework's DOM shim relabels it back to the name the
2609
+ // listener was registered under and re-dispatches, which needs a working
2610
+ // setter or the relabel is silently dropped and the listener never fires.
2611
+ get type() {
2612
+ const override = this[eventType_];
2613
+ if (override !== undefined) {
2614
+ return override;
2615
+ }
2616
+ if (__ANDROID__) {
2617
+ return this[native_]?.getType();
2618
+ }
2619
+ if (false) {
2620
+ return this[native_]?.Type;
2621
+ }
2622
+ return this[native_]?.type;
2623
+ }
2624
+ set type(value) {
2625
+ this[eventType_] = value;
2626
+ }
2627
+ // DOM MouseEvent.button: 0 = primary button. Mason's touch-originated
2628
+ // click has no native concept of mouse buttons, but callers checking
2629
+ // `e.button === 0` (e.g. a router's <Link> onClick guard) expect this.
2630
+ get button() {
2631
+ return 0;
2632
+ }
2633
+ set button(_) { }
2634
+ get target() {
2635
+ // The element the event started at, which differs from currentTarget once it bubbles.
2636
+ const nativeEvent = this[native_];
2637
+ const nativeTarget = __ANDROID__ ? nativeEvent?.getTarget?.() : __APPLE__ ? nativeEvent?.target : false ? nativeEvent?.Target : null;
2638
+ const current = this['_target'];
2639
+ if (nativeTarget && nativeTarget !== nativeViewFor(current)) {
2640
+ const found = nativeOwnerFor(nativeTarget) ?? findOwnerForNativeView(current, nativeTarget);
2641
+ if (found)
2642
+ return found;
2643
+ }
2644
+ return current;
2645
+ }
2646
+ set target(_) { }
2647
+ get object() {
2648
+ return this['_target'];
2649
+ }
2650
+ get eventName() {
2651
+ return this.type;
2652
+ }
2653
+ set currentTarget(_) { }
2654
+ set bubbles(_) { }
2655
+ set cancelable(_) { }
2656
+ set timeStamp(_) { }
2657
+ set defaultPrevented(_) { }
2658
+ }
2659
+ function wrapNativeEvent(_type) { return new Event(); }