@triniwiz/nativescript-masonkit 1.0.0-beta.109 → 1.0.0-beta.110

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 (30) hide show
  1. package/common.d.ts +1 -0
  2. package/common.js +6 -2
  3. package/common.js.map +1 -1
  4. package/fonts.d.ts +11 -0
  5. package/fonts.js +65 -0
  6. package/fonts.js.map +1 -1
  7. package/index.d.ts +2 -1
  8. package/nativescript.webpack.js +30 -0
  9. package/package.json +1 -1
  10. package/platforms/android/masonkit-release.aar +0 -0
  11. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  12. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  13. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +11 -4
  14. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  15. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8479 -8474
  16. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  17. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  18. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  19. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +11 -4
  20. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +11 -4
  21. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +12 -12
  22. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  23. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8473 -8468
  24. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +8093 -8085
  25. package/platforms/windows/arm64/NativeScript.Mason.dll +0 -0
  26. package/platforms/windows/arm64/NativeScript.Mason.winmd +0 -0
  27. package/platforms/windows/x64/NativeScript.Mason.dll +0 -0
  28. package/platforms/windows/x64/NativeScript.Mason.winmd +0 -0
  29. package/style.js +5 -2
  30. package/style.js.map +1 -1
package/fonts.js CHANGED
@@ -21,4 +21,69 @@ export function registerAppFontsDirectory() {
21
21
  registered = false;
22
22
  }
23
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
+ }
24
89
  //# sourceMappingURL=fonts.js.map
package/fonts.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../../packages/nativescript-masonkit/fonts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAExD,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB;IACvC,IAAI,CAAC,WAAW,IAAI,UAAU,EAAE,CAAC;QAC/B,OAAO;IACT,CAAC;IACD,UAAU,GAAG,IAAI,CAA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 
323
323
  /**
324
324
  * Returns the top-most Mason/NativeScript element at a point in this view's
325
- * visible local coordinate space.
325
+ * visible local coordinate space. `x` and `y` are CSS pixels (dips) on every
326
+ * platform, the unit touch events report.
326
327
  */
327
328
  elementFromPoint(x: number, y: number): ViewBase | null;
328
329
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Loads MasonKit before the app's own entry module.
3
+ *
4
+ * @nativescript/webpack's app-css-loader puts `import "./app.css"` at the very top
5
+ * of the app entry, and core parses a stylesheet - splitting every shorthand
6
+ * (`border-radius`, `margin`, `padding`, `background`, ...) into longhands - as
7
+ * soon as it is imported. MasonKit swaps in its own shorthand converters when its
8
+ * properties register, which used to happen only when the app entry imported
9
+ * MasonKit, i.e. after app.css. So app.css was split by core's converters instead:
10
+ * `border-radius: 0 4px 0 4px` lost its 0 corners on a button, `padding: 0` was
11
+ * dropped on mason views, and `rem`/`em` lost their units.
12
+ *
13
+ * Adding the package to the bundle entry right before the app entry registers
14
+ * MasonKit's properties first, exactly as if it were the app's first import.
15
+ *
16
+ * @param {typeof import('@nativescript/webpack')} webpack
17
+ */
18
+ module.exports = (webpack) => {
19
+ webpack.chainWebpack((config) => {
20
+ const bundle = config.entry('bundle');
21
+ const entries = bundle.values();
22
+ const appEntry = entries.lastIndexOf(webpack.Utils.platform.getEntryPath());
23
+ if (appEntry === -1 || entries.includes('@triniwiz/nativescript-masonkit')) {
24
+ return;
25
+ }
26
+ entries.splice(appEntry, 0, '@triniwiz/nativescript-masonkit');
27
+ bundle.clear();
28
+ entries.forEach((entry) => bundle.add(entry));
29
+ });
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triniwiz/nativescript-masonkit",
3
- "version": "1.0.0-beta.109",
3
+ "version": "1.0.0-beta.110",
4
4
  "description": "Web Inspired Layout",
5
5
  "main": "index",
6
6
  "typings": "index.d.ts",
@@ -96628,31 +96628,38 @@
96628
96628
  "length": 3,
96629
96629
  "value": "1.0"
96630
96630
  },
96631
+ {
96632
+ "filePath": "\/Users\/triniwiz\/Documents\/GitHub\/nativescript-mason\/packages\/nativescript-masonkit\/src-native\/mason-ios\/Mason\/Mason\/text\/TextEngine.swift",
96633
+ "kind": "StringLiteral",
96634
+ "offset": 77200,
96635
+ "length": 17,
96636
+ "value": "\" \t\n\r\f\""
96637
+ },
96631
96638
  {
96632
96639
  "filePath": "\/Users\/triniwiz\/Documents\/GitHub\/nativescript-mason\/packages\/nativescript-masonkit\/src-native\/mason-ios\/Mason\/Mason\/text\/TextEngine.swift",
96633
96640
  "kind": "BooleanLiteral",
96634
- "offset": 77305,
96641
+ "offset": 78867,
96635
96642
  "length": 5,
96636
96643
  "value": "false"
96637
96644
  },
96638
96645
  {
96639
96646
  "filePath": "\/Users\/triniwiz\/Documents\/GitHub\/nativescript-mason\/packages\/nativescript-masonkit\/src-native\/mason-ios\/Mason\/Mason\/text\/TextEngine.swift",
96640
96647
  "kind": "IntegerLiteral",
96641
- "offset": 93074,
96648
+ "offset": 95715,
96642
96649
  "length": 4,
96643
96650
  "value": "2048"
96644
96651
  },
96645
96652
  {
96646
96653
  "filePath": "\/Users\/triniwiz\/Documents\/GitHub\/nativescript-mason\/packages\/nativescript-masonkit\/src-native\/mason-ios\/Mason\/Mason\/text\/TextEngine.swift",
96647
96654
  "kind": "Dictionary",
96648
- "offset": 93473,
96655
+ "offset": 96114,
96649
96656
  "length": 3,
96650
96657
  "value": "[]"
96651
96658
  },
96652
96659
  {
96653
96660
  "filePath": "\/Users\/triniwiz\/Documents\/GitHub\/nativescript-mason\/packages\/nativescript-masonkit\/src-native\/mason-ios\/Mason\/Mason\/text\/TextEngine.swift",
96654
96661
  "kind": "IntegerLiteral",
96655
- "offset": 96065,
96662
+ "offset": 98706,
96656
96663
  "length": 1,
96657
96664
  "value": "0"
96658
96665
  },