@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
@@ -0,0 +1,100 @@
1
+ const IDENTITY = [1, 0, 0, 1, 0, 0];
2
+ function multiply(m, n) {
3
+ return [m[0] * n[0] + m[2] * n[1], m[1] * n[0] + m[3] * n[1], m[0] * n[2] + m[2] * n[3], m[1] * n[2] + m[3] * n[3], m[0] * n[4] + m[2] * n[5] + m[4], m[1] * n[4] + m[3] * n[5] + m[5]];
4
+ }
5
+ export function parseAngle(token) {
6
+ const t = token.trim().toLowerCase();
7
+ const n = parseFloat(t);
8
+ if (!Number.isFinite(n))
9
+ return 0;
10
+ if (t.endsWith('grad'))
11
+ return (n * Math.PI) / 200;
12
+ if (t.endsWith('rad'))
13
+ return n;
14
+ if (t.endsWith('turn'))
15
+ return n * 2 * Math.PI;
16
+ return (n * Math.PI) / 180;
17
+ }
18
+ export function parseCssTransform(value, toDip, size) {
19
+ const s = (value ?? '').trim();
20
+ if (!s || s === 'none')
21
+ return null;
22
+ const length = (token, axis) => {
23
+ if (token == null)
24
+ return 0;
25
+ const t = token.trim();
26
+ if (t.endsWith('%'))
27
+ return (parseFloat(t) / 100) * axis;
28
+ return toDip(t) ?? parseFloat(t) ?? 0;
29
+ };
30
+ const num = (token, fallback) => {
31
+ if (token == null || token.trim() === '')
32
+ return fallback;
33
+ const t = token.trim();
34
+ const n = t.endsWith('%') ? parseFloat(t) / 100 : parseFloat(t);
35
+ return Number.isFinite(n) ? n : fallback;
36
+ };
37
+ let m = IDENTITY;
38
+ let found = false;
39
+ const re = /([a-zA-Z0-9]+)\(([^)]*)\)/g;
40
+ let match;
41
+ while ((match = re.exec(s))) {
42
+ const name = match[1].toLowerCase();
43
+ const args = match[2].split(/\s*,\s*|\s+/).filter((a) => a !== '');
44
+ let f = null;
45
+ switch (name) {
46
+ case 'translate':
47
+ case 'translate3d':
48
+ f = [1, 0, 0, 1, length(args[0], size.width), length(args[1], size.height)];
49
+ break;
50
+ case 'translatex':
51
+ f = [1, 0, 0, 1, length(args[0], size.width), 0];
52
+ break;
53
+ case 'translatey':
54
+ f = [1, 0, 0, 1, 0, length(args[0], size.height)];
55
+ break;
56
+ case 'scale':
57
+ case 'scale3d': {
58
+ const sx = num(args[0], 1);
59
+ f = [sx, 0, 0, num(args[1], sx), 0, 0];
60
+ break;
61
+ }
62
+ case 'scalex':
63
+ f = [num(args[0], 1), 0, 0, 1, 0, 0];
64
+ break;
65
+ case 'scaley':
66
+ f = [1, 0, 0, num(args[0], 1), 0, 0];
67
+ break;
68
+ case 'rotate':
69
+ case 'rotatez': {
70
+ const a = parseAngle(args[0] ?? '0');
71
+ f = [Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0];
72
+ break;
73
+ }
74
+ case 'skew':
75
+ f = [1, Math.tan(parseAngle(args[1] ?? '0')), Math.tan(parseAngle(args[0] ?? '0')), 1, 0, 0];
76
+ break;
77
+ case 'skewx':
78
+ f = [1, 0, Math.tan(parseAngle(args[0] ?? '0')), 1, 0, 0];
79
+ break;
80
+ case 'skewy':
81
+ f = [1, Math.tan(parseAngle(args[0] ?? '0')), 0, 1, 0, 0];
82
+ break;
83
+ case 'matrix':
84
+ if (args.length >= 6)
85
+ f = args.slice(0, 6).map((a) => parseFloat(a) || 0);
86
+ break;
87
+ case 'matrix3d':
88
+ if (args.length >= 16) {
89
+ const v = args.map((a) => parseFloat(a) || 0);
90
+ f = [v[0], v[1], v[4], v[5], v[12], v[13]];
91
+ }
92
+ break;
93
+ }
94
+ if (!f)
95
+ continue;
96
+ found = true;
97
+ m = multiply(m, f);
98
+ }
99
+ return found ? m : null;
100
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Reporting for CSS mason could not use.
3
+ *
4
+ * Every parser in the stack drops what it doesn't understand in silence — there
5
+ * was not one `console.warn` in style.ts or a single log line in the native HTML
6
+ * parser. Pasting a real stylesheet therefore produced a layout that was wrong
7
+ * in ways nothing would tell you about.
8
+ *
9
+ * Off by default. Beyond the obvious developer use, this is a test oracle: a
10
+ * Node test can feed a real-world stylesheet through and assert the drop list
11
+ * matches a snapshot, which covers "what would silently break" without needing
12
+ * a fixture per property or a device.
13
+ */
14
+ export type CssDiagnosticKind =
15
+ /** A property mason has no support for at all. */
16
+ 'unknown-property'
17
+ /** A known property whose value could not be parsed. */
18
+ | 'unparsable-value'
19
+ /** A unit mason cannot resolve (an unknown one, or `vw` before the viewport is known). */
20
+ | 'unsupported-unit'
21
+ /** A tag with no mason element behind it. */
22
+ | 'unknown-tag'
23
+ /** Understood, but deliberately not implemented yet. */
24
+ | 'not-implemented';
25
+ export interface CssDiagnostic {
26
+ kind: CssDiagnosticKind;
27
+ /** Property or tag name, as written. */
28
+ name: string;
29
+ /** The value as written, when there was one. */
30
+ value?: string;
31
+ /** Why it was dropped, and what to do instead where there is an answer. */
32
+ detail?: string;
33
+ }
34
+ export interface CssDiagnosticsOptions {
35
+ /** Also write each diagnostic to the console. Default true when enabled. */
36
+ log?: boolean;
37
+ /** Cap on retained diagnostics; oldest are dropped past it. Default 500. */
38
+ limit?: number;
39
+ }
40
+ /**
41
+ * Turn diagnostics on or off. Call with `true` during development to find out
42
+ * what a pasted stylesheet lost.
43
+ */
44
+ export declare function setCssDiagnostics(value: boolean, options?: CssDiagnosticsOptions): void;
45
+ export declare function cssDiagnosticsEnabled(): boolean;
46
+ /** Everything reported since diagnostics were enabled (or last cleared). */
47
+ export declare function getCssDiagnostics(): readonly CssDiagnostic[];
48
+ export declare function clearCssDiagnostics(): void;
49
+ export declare function reportCssDiagnostic(diagnostic: CssDiagnostic): void;
50
+ /** Format the diagnostics as lines, for a snapshot or a bug report. */
51
+ export declare function formatCssDiagnostics(): string;
package/diagnostics.js ADDED
@@ -0,0 +1,52 @@
1
+ let enabled = false;
2
+ let log = true;
3
+ let limit = 500;
4
+ const collected = [];
5
+ const seen = new Set();
6
+ /**
7
+ * Turn diagnostics on or off. Call with `true` during development to find out
8
+ * what a pasted stylesheet lost.
9
+ */
10
+ export function setCssDiagnostics(value, options = {}) {
11
+ enabled = value;
12
+ log = options.log ?? true;
13
+ limit = options.limit ?? 500;
14
+ if (!value) {
15
+ clearCssDiagnostics();
16
+ }
17
+ }
18
+ export function cssDiagnosticsEnabled() {
19
+ return enabled;
20
+ }
21
+ /** Everything reported since diagnostics were enabled (or last cleared). */
22
+ export function getCssDiagnostics() {
23
+ return collected;
24
+ }
25
+ export function clearCssDiagnostics() {
26
+ collected.length = 0;
27
+ seen.clear();
28
+ }
29
+ export function reportCssDiagnostic(diagnostic) {
30
+ if (!enabled) {
31
+ return;
32
+ }
33
+ // Deduplicate: a repeated declaration in a long stylesheet would otherwise
34
+ // bury the distinct problems.
35
+ const key = `${diagnostic.kind}|${diagnostic.name}|${diagnostic.value ?? ''}`;
36
+ if (seen.has(key)) {
37
+ return;
38
+ }
39
+ seen.add(key);
40
+ collected.push(diagnostic);
41
+ if (collected.length > limit) {
42
+ collected.shift();
43
+ }
44
+ if (log) {
45
+ const where = diagnostic.value === undefined ? diagnostic.name : `${diagnostic.name}: ${diagnostic.value}`;
46
+ console.warn(`[mason css] ${diagnostic.kind} — ${where}${diagnostic.detail ? ` (${diagnostic.detail})` : ''}`);
47
+ }
48
+ }
49
+ /** Format the diagnostics as lines, for a snapshot or a bug report. */
50
+ export function formatCssDiagnostics() {
51
+ return collected.map((d) => `${d.kind} ${d.name}${d.value === undefined ? '' : `: ${d.value}`}${d.detail ? ` — ${d.detail}` : ''}`).join('\n');
52
+ }
@@ -0,0 +1,9 @@
1
+ export declare function displayDensity(): number;
2
+ /** Records the density after a configuration change; core's own value is used until then. */
3
+ export declare function setDisplayDensity(value: number): void;
4
+ /** core's `layout` conversions, against the current density. */
5
+ export declare const masonLayout: {
6
+ getDisplayDensity: typeof displayDensity;
7
+ toDevicePixels: (value: number) => number;
8
+ toDeviceIndependentPixels: (value: number) => number;
9
+ };
@@ -0,0 +1,20 @@
1
+ import { layout as coreLayout } from '@nativescript/core/utils';
2
+ // Core reads the display density once per process. A density change (Settings > Display size)
3
+ // relaunches the Activity and restyles Mason's views, so Mason converts with the new value.
4
+ let changed = 0;
5
+ export function displayDensity() {
6
+ return changed || coreLayout.getDisplayDensity();
7
+ }
8
+ /** Records the density after a configuration change; core's own value is used until then. */
9
+ export function setDisplayDensity(value) {
10
+ if (value > 0 && value !== coreLayout.getDisplayDensity())
11
+ changed = value;
12
+ else
13
+ changed = 0;
14
+ }
15
+ /** core's `layout` conversions, against the current density. */
16
+ export const masonLayout = {
17
+ getDisplayDensity: displayDensity,
18
+ toDevicePixels: (value) => value * displayDensity(),
19
+ toDeviceIndependentPixels: (value) => value / displayDensity(),
20
+ };
package/fonts.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Point the native font resolver at the app's `fonts` folder.
3
+ *
4
+ * iOS needs nothing here: the runtime registers every file in `app/fonts` with
5
+ * CoreText at startup, so a custom `@font-face` family resolves by name.
6
+ * Android has no system-wide registration, so the native side has to be told
7
+ * where the bundled font files live before it can honour a custom family.
8
+ */
9
+ export declare function registerAppFontsDirectory(): void;
10
+ /** Splits a CSS `font-family` list into family names, without their quotes. */
11
+ export declare function parseFontFamilyList(value: string): string[];
12
+ /** Whether a named family can be drawn here: installed, registered from the app's fonts folder, or bundled. */
13
+ export declare function isFontFamilyAvailable(family: string): boolean;
14
+ /**
15
+ * The single family the natives should use for a CSS `font-family` value: the first
16
+ * family in the list that is generic or available, as CSS font matching picks it.
17
+ * Quotes are removed, so `'Mukta Mahee'` and `Mukta Mahee` name the same family.
18
+ * Falls back to the first family named when none is available.
19
+ */
20
+ export declare function pickFontFamily(value: string, isAvailable?: (family: string) => boolean): string;
package/fonts.js ADDED
@@ -0,0 +1,88 @@
1
+ import { knownFolders, path } from '@nativescript/core';
2
+ let registered = false;
3
+ /**
4
+ * Point the native font resolver at the app's `fonts` folder.
5
+ *
6
+ * iOS needs nothing here: the runtime registers every file in `app/fonts` with
7
+ * CoreText at startup, so a custom `@font-face` family resolves by name.
8
+ * Android has no system-wide registration, so the native side has to be told
9
+ * where the bundled font files live before it can honour a custom family.
10
+ */
11
+ export function registerAppFontsDirectory() {
12
+ if (!__ANDROID__ || registered) {
13
+ return;
14
+ }
15
+ registered = true;
16
+ try {
17
+ const dir = path.join(knownFolders.currentApp().path, 'fonts');
18
+ org.nativescript.mason.masonkit.AppFonts.setFontsDirectory(dir);
19
+ }
20
+ catch (e) {
21
+ registered = false;
22
+ }
23
+ }
24
+ const GENERIC_FAMILIES = new Set(['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded', 'emoji', 'math']);
25
+ /** Splits a CSS `font-family` list into family names, without their quotes. */
26
+ export function parseFontFamilyList(value) {
27
+ const families = [];
28
+ let current = '';
29
+ let quote = null;
30
+ for (const ch of value) {
31
+ if (quote) {
32
+ if (ch === quote)
33
+ quote = null;
34
+ else
35
+ current += ch;
36
+ }
37
+ else if (ch === '"' || ch === "'") {
38
+ quote = ch;
39
+ }
40
+ else if (ch === ',') {
41
+ families.push(current);
42
+ current = '';
43
+ }
44
+ else {
45
+ current += ch;
46
+ }
47
+ }
48
+ families.push(current);
49
+ return families.map((family) => family.trim().replace(/\s+/g, ' ')).filter(Boolean);
50
+ }
51
+ const availableFamilies = new Set();
52
+ /** Whether a named family can be drawn here: installed, registered from the app's fonts folder, or bundled. */
53
+ export function isFontFamilyAvailable(family) {
54
+ const key = family.toLowerCase();
55
+ if (availableFamilies.has(key))
56
+ return true;
57
+ let found = true;
58
+ if (__APPLE__) {
59
+ found = false;
60
+ const names = UIFont.familyNames;
61
+ for (let i = 0; i < names.count; i++) {
62
+ if (names.objectAtIndex(i).toLowerCase() === key) {
63
+ found = true;
64
+ break;
65
+ }
66
+ }
67
+ }
68
+ else if (__ANDROID__) {
69
+ registerAppFontsDirectory();
70
+ found = org.nativescript.mason.masonkit.AppFonts.resolve(family) != null || !android.graphics.Typeface.create(family, android.graphics.Typeface.NORMAL).equals(android.graphics.Typeface.DEFAULT);
71
+ }
72
+ // Only hits are cached: a family can be registered later, a font file can't disappear.
73
+ if (found)
74
+ availableFamilies.add(key);
75
+ return found;
76
+ }
77
+ /**
78
+ * The single family the natives should use for a CSS `font-family` value: the first
79
+ * family in the list that is generic or available, as CSS font matching picks it.
80
+ * Quotes are removed, so `'Mukta Mahee'` and `Mukta Mahee` name the same family.
81
+ * Falls back to the first family named when none is available.
82
+ */
83
+ export function pickFontFamily(value, isAvailable = isFontFamilyAvailable) {
84
+ const families = parseFontFamilyList(value);
85
+ if (families.length === 0)
86
+ return value;
87
+ return families.find((family) => GENERIC_FAMILIES.has(family.toLowerCase()) || isAvailable(family)) ?? families[0];
88
+ }
@@ -0,0 +1,6 @@
1
+ /** Start mirroring a plain child's layout styles into its Mason leaf. Call after the native insert. */
2
+ export declare function adoptForeignLayout(view: any): void;
3
+ /** iOS: a content change core reports through requestLayout drops the child's cached Mason measurement. */
4
+ export declare function invalidateOnLayoutRequest(view: any, mason: any): void;
5
+ /** Stop mirroring and give the child its own Style prototype and requestLayout back. */
6
+ export declare function releaseForeignLayout(view: any): void;
@@ -0,0 +1,151 @@
1
+ import { releaseCssEnvironmentStyle } from './css-environment';
2
+ import { masonLayout as layout } from './display-density';
3
+ import { widthProperty, heightProperty, minWidthProperty, minHeightProperty, maxWidthProperty, maxHeightProperty, marginTopProperty, marginRightProperty, marginBottomProperty, marginLeftProperty } from '@nativescript/core/ui/styling/style-properties';
4
+ import { alignSelfProperty, flexGrowProperty, flexShrinkProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
5
+ import { aspectRatioProperty, bottomProperty, flexBasisProperty, gridColumnEndProperty, gridColumnStartProperty, gridRowEndProperty, gridRowStartProperty, justifySelfProperty, leftProperty, positionProperty, rightProperty, topProperty } from './properties';
6
+ import { Style } from './style';
7
+ import { isMasonView_ } from './symbols';
8
+ const foreignStyle_ = Symbol('mason:foreignStyle');
9
+ const foreignProto_ = Symbol('mason:foreignProto');
10
+ const foreignInvalidate_ = Symbol('mason:foreignInvalidate');
11
+ // Core px objects are device pixels; Mason reads px as CSS pixels, and numbers as dip.
12
+ function toMason(value) {
13
+ return value?.unit === 'px' ? layout.toDeviceIndependentPixels(value.value) : value;
14
+ }
15
+ function scalar(property, fallback = property.defaultValue) {
16
+ const { name } = property;
17
+ const unset = toMason(fallback);
18
+ return (helper, style) => {
19
+ helper[name] = property.isSet(style) ? toMason(style[name]) : unset;
20
+ };
21
+ }
22
+ function selfAlign(property) {
23
+ const { name } = property;
24
+ return (helper, style) => {
25
+ const value = style[name];
26
+ helper[name] = value == null || value === 'auto' ? 'normal' : value;
27
+ };
28
+ }
29
+ const gridEdges = [gridRowStartProperty, gridColumnStartProperty, gridRowEndProperty, gridColumnEndProperty];
30
+ // One complete area, so a single edge never inherits stale native shorthand state.
31
+ const writeGrid = (helper, style) => {
32
+ helper.gridArea = `${style.gridRowStart ?? 'auto'} / ${style.gridColumnStart ?? 'auto'} / ${style.gridRowEnd ?? 'auto'} / ${style.gridColumnEnd ?? 'auto'}`;
33
+ };
34
+ // Windows panels copy these from the XAML element on every measure.
35
+ const entries = [];
36
+ function add(properties, write) {
37
+ for (const property of properties)
38
+ entries.push([property, write(property)]);
39
+ }
40
+ // Windows panels copy these from the XAML element on every measure.
41
+ if (!false) {
42
+ add([widthProperty, heightProperty, maxWidthProperty, maxHeightProperty, marginTopProperty, marginRightProperty, marginBottomProperty, marginLeftProperty], scalar);
43
+ // Core's 0 default would disable Mason's automatic minimum size.
44
+ add([minWidthProperty, minHeightProperty], (p) => scalar(p, 'auto'));
45
+ }
46
+ add([flexGrowProperty, flexShrinkProperty, flexBasisProperty, aspectRatioProperty, positionProperty, leftProperty, rightProperty, topProperty, bottomProperty], scalar);
47
+ add([alignSelfProperty, justifySelfProperty], selfAlign);
48
+ add(gridEdges, () => writeGrid);
49
+ const foreignProtos = new WeakMap();
50
+ // Native views whose leaf this bridge has written; a leaf outlives a detach.
51
+ const written = new WeakSet();
52
+ function foreignProto(proto) {
53
+ let shadow = foreignProtos.get(proto);
54
+ if (shadow)
55
+ return shadow;
56
+ shadow = Object.create(proto);
57
+ for (const [property, write] of entries) {
58
+ for (const key of new Set([property.name, property.cssName, property.cssLocalName, property.keyframe])) {
59
+ if (!key)
60
+ continue;
61
+ let owner = proto;
62
+ let descriptor;
63
+ while (owner && !(descriptor = Object.getOwnPropertyDescriptor(owner, key)))
64
+ owner = Object.getPrototypeOf(owner);
65
+ const set = descriptor?.set;
66
+ if (!set)
67
+ continue;
68
+ Object.defineProperty(shadow, key, {
69
+ configurable: true,
70
+ enumerable: descriptor.enumerable,
71
+ get: descriptor.get,
72
+ set(value) {
73
+ set.call(this, value);
74
+ const helper = this.viewRef?.get()?.[foreignStyle_];
75
+ if (helper)
76
+ write(helper, this);
77
+ },
78
+ });
79
+ }
80
+ }
81
+ Object.defineProperty(shadow, foreignProto_, { value: true });
82
+ foreignProtos.set(proto, shadow);
83
+ return shadow;
84
+ }
85
+ /** Start mirroring a plain child's layout styles into its Mason leaf. Call after the native insert. */
86
+ export function adoptForeignLayout(view) {
87
+ const style = view?.style;
88
+ const native = view?.nativeViewProtected;
89
+ if (!style || !native || view[isMasonView_])
90
+ return;
91
+ const helper = Style.fromView(view, native);
92
+ view[foreignStyle_] = helper;
93
+ if (!style[foreignProto_])
94
+ Object.setPrototypeOf(style, foreignProto(Object.getPrototypeOf(style)));
95
+ // A fresh leaf already holds Mason's defaults, so it only needs the values core has set.
96
+ const all = written.has(native);
97
+ written.add(native);
98
+ let grid = false;
99
+ for (const [property, write] of entries) {
100
+ if (!all && !property.isSet(style))
101
+ continue;
102
+ if (write === writeGrid)
103
+ grid = true;
104
+ else
105
+ write(helper, style);
106
+ }
107
+ if (grid)
108
+ writeGrid(helper, style);
109
+ }
110
+ /** iOS: a content change core reports through requestLayout drops the child's cached Mason measurement. */
111
+ export function invalidateOnLayoutRequest(view, mason) {
112
+ const hook = view[foreignInvalidate_];
113
+ if (hook) {
114
+ hook.mason = mason;
115
+ return;
116
+ }
117
+ const original = view.requestLayout;
118
+ if (typeof original !== 'function')
119
+ return;
120
+ const state = {
121
+ mason,
122
+ own: Object.getOwnPropertyDescriptor(view, 'requestLayout'),
123
+ requestLayout() {
124
+ const native = this.nativeViewProtected;
125
+ if (native)
126
+ state.mason.invalidateForeignView(native);
127
+ return original.call(this);
128
+ },
129
+ };
130
+ view.requestLayout = state.requestLayout;
131
+ view[foreignInvalidate_] = state;
132
+ }
133
+ /** Stop mirroring and give the child its own Style prototype and requestLayout back. */
134
+ export function releaseForeignLayout(view) {
135
+ const hook = view?.[foreignInvalidate_];
136
+ if (hook) {
137
+ view[foreignInvalidate_] = undefined;
138
+ if (hook.own)
139
+ Object.defineProperty(view, 'requestLayout', hook.own);
140
+ else
141
+ delete view.requestLayout;
142
+ }
143
+ if (!view?.[foreignStyle_])
144
+ return;
145
+ releaseCssEnvironmentStyle(view[foreignStyle_]);
146
+ view[foreignStyle_].resetState();
147
+ view[foreignStyle_] = undefined;
148
+ const style = view.style;
149
+ if (style?.[foreignProto_])
150
+ Object.setPrototypeOf(style, Object.getPrototypeOf(Object.getPrototypeOf(style)));
151
+ }
@@ -0,0 +1,25 @@
1
+ /** A stop with two positions (`red 10% 30%`) is two stops of the same colour. */
2
+ export declare function expandColorStops(stops: string[]): string[];
3
+ /**
4
+ * Fills in the positions a gradient leaves out, per CSS Images: the first and
5
+ * last stops default to 0 and 1, a position before an earlier one moves up to
6
+ * it, and a run of stops without positions spreads evenly between its neighbours.
7
+ */
8
+ export declare function resolveStopPositions(positions: Array<number | null>): number[];
9
+ /** A repeating gradient's stops tiled across [0, end], so a plain gradient draws it. */
10
+ export declare function repeatStops(offsets: number[], colors: number[], end?: number): {
11
+ offsets: number[];
12
+ colors: number[];
13
+ };
14
+ /** How far past its ending shape a radial gradient reaches in the box, in radii (at least 1). */
15
+ export declare function radialReach(cx: number, cy: number, rx: number, ry: number): number;
16
+ /** A repeating radial gradient as a plain one: stops tiled to the farthest corner, radii grown to match. */
17
+ export declare function repeatRadial<T extends {
18
+ rx: number;
19
+ ry: number;
20
+ offsets: number[];
21
+ colors: number[];
22
+ }>(g: T & {
23
+ cx: number;
24
+ cy: number;
25
+ }): T;
@@ -0,0 +1,112 @@
1
+ import { tokenizeCss } from './css-shorthands';
2
+ // Mirrors GradientStops.kt, for platforms that parse gradients in TS (Windows).
3
+ /** A stop with two positions (`red 10% 30%`) is two stops of the same colour. */
4
+ export function expandColorStops(stops) {
5
+ return stops.flatMap((stop) => {
6
+ let parts;
7
+ try {
8
+ parts = tokenizeCss(stop);
9
+ }
10
+ catch {
11
+ return [stop];
12
+ }
13
+ return parts.length === 3 ? [`${parts[0]} ${parts[1]}`, `${parts[0]} ${parts[2]}`] : [stop];
14
+ });
15
+ }
16
+ /**
17
+ * Fills in the positions a gradient leaves out, per CSS Images: the first and
18
+ * last stops default to 0 and 1, a position before an earlier one moves up to
19
+ * it, and a run of stops without positions spreads evenly between its neighbours.
20
+ */
21
+ export function resolveStopPositions(positions) {
22
+ const n = positions.length;
23
+ const resolved = new Array(n).fill(0);
24
+ let anchor = -1;
25
+ for (let i = 0; i < n; i++) {
26
+ let given = positions[i];
27
+ if (given == null) {
28
+ if (i === 0)
29
+ given = 0;
30
+ else if (i === n - 1)
31
+ given = 1;
32
+ else
33
+ continue;
34
+ }
35
+ const position = anchor >= 0 ? Math.max(given, resolved[anchor]) : given;
36
+ resolved[i] = position;
37
+ if (anchor >= 0) {
38
+ const start = resolved[anchor];
39
+ for (let k = anchor + 1; k < i; k++) {
40
+ resolved[k] = start + ((position - start) * (k - anchor)) / (i - anchor);
41
+ }
42
+ }
43
+ anchor = i;
44
+ }
45
+ return resolved;
46
+ }
47
+ const MAX_REPEATED_STOPS = 2048;
48
+ function mixArgb(a, b, f) {
49
+ let out = 0;
50
+ for (const shift of [24, 16, 8, 0]) {
51
+ const ca = (a >>> shift) & 0xff;
52
+ const cb = (b >>> shift) & 0xff;
53
+ out |= Math.round(ca + (cb - ca) * f) << shift;
54
+ }
55
+ return out >>> 0;
56
+ }
57
+ function colorAt(offsets, colors, t, fromRight) {
58
+ const n = offsets.length;
59
+ if (t < offsets[0] || (!fromRight && t === offsets[0]))
60
+ return colors[0] >>> 0;
61
+ for (let i = 1; i < n; i++) {
62
+ if (t < offsets[i] || (!fromRight && t === offsets[i])) {
63
+ const span = offsets[i] - offsets[i - 1];
64
+ return mixArgb(colors[i - 1], colors[i], span > 0 ? (t - offsets[i - 1]) / span : 1);
65
+ }
66
+ }
67
+ return colors[n - 1] >>> 0;
68
+ }
69
+ /** A repeating gradient's stops tiled across [0, end], so a plain gradient draws it. */
70
+ export function repeatStops(offsets, colors, end = 1) {
71
+ const n = offsets.length;
72
+ if (n < 2 || colors.length !== n)
73
+ return { offsets, colors };
74
+ const first = offsets[0];
75
+ const period = offsets[n - 1] - first;
76
+ if (!(period > 1e-4))
77
+ return { offsets, colors };
78
+ const tiledOffsets = [];
79
+ const tiledColors = [];
80
+ for (let k = Math.floor(-first / period); first + k * period <= end && tiledOffsets.length < MAX_REPEATED_STOPS; k++) {
81
+ for (let i = 0; i < n; i++) {
82
+ tiledOffsets.push(offsets[i] + k * period);
83
+ tiledColors.push(colors[i] >>> 0);
84
+ }
85
+ }
86
+ const outOffsets = [0];
87
+ const outColors = [colorAt(tiledOffsets, tiledColors, 0, true)];
88
+ for (let i = 0; i < tiledOffsets.length; i++) {
89
+ if (tiledOffsets[i] > 0 && tiledOffsets[i] < end) {
90
+ outOffsets.push(tiledOffsets[i]);
91
+ outColors.push(tiledColors[i]);
92
+ }
93
+ }
94
+ outOffsets.push(end);
95
+ outColors.push(colorAt(tiledOffsets, tiledColors, end, false));
96
+ return { offsets: outOffsets, colors: outColors };
97
+ }
98
+ /** How far past its ending shape a radial gradient reaches in the box, in radii (at least 1). */
99
+ export function radialReach(cx, cy, rx, ry) {
100
+ let reach = 1;
101
+ for (const x of [0, 1]) {
102
+ for (const y of [0, 1])
103
+ reach = Math.max(reach, Math.hypot((x - cx) / rx, (y - cy) / ry));
104
+ }
105
+ return reach;
106
+ }
107
+ /** A repeating radial gradient as a plain one: stops tiled to the farthest corner, radii grown to match. */
108
+ export function repeatRadial(g) {
109
+ const reach = radialReach(g.cx, g.cy, g.rx, g.ry);
110
+ const tiled = repeatStops(g.offsets, g.colors, reach);
111
+ return { ...g, rx: g.rx * reach, ry: g.ry * reach, offsets: tiled.offsets.map((o) => o / reach), colors: tiled.colors };
112
+ }
@@ -0,0 +1,11 @@
1
+ export { View } from './view';
2
+ export { Scroll } from './scroll';
3
+ export { ViewBase, Event } from './common';
4
+ export type { ScrollBehavior, ScrollLogicalPosition, ScrollToOptions, ScrollIntoViewOptions } from './common';
5
+ export { Style } from './style';
6
+ export { setCssEnvironment, clearCssEnvironment, bindCssEnvironment, refreshCssEnvironment } from './css-environment';
7
+ export type { CssSafeAreaInsets, CssEnvironmentHost, CssEnvironmentSource } from './css-environment';
8
+ export { setCssDiagnostics, getCssDiagnostics, clearCssDiagnostics, formatCssDiagnostics, cssDiagnosticsEnabled } from './diagnostics';
9
+ export { setCssUnitContext, cssUnits } from './units';
10
+ export { registerAppFontsDirectory } from './fonts';
11
+ export type * from './layout-types';
@@ -0,0 +1,9 @@
1
+ /// <reference path="./typings/native.d.ts" />
2
+ export { View } from './view';
3
+ export { Scroll } from './scroll';
4
+ export { ViewBase, Event } from './common';
5
+ export { Style } from './style';
6
+ export { setCssEnvironment, clearCssEnvironment, bindCssEnvironment, refreshCssEnvironment } from './css-environment';
7
+ export { setCssDiagnostics, getCssDiagnostics, clearCssDiagnostics, formatCssDiagnostics, cssDiagnosticsEnabled } from './diagnostics';
8
+ export { setCssUnitContext, cssUnits } from './units';
9
+ export { registerAppFontsDirectory } from './fonts';