@triniwiz/nativescript-masonkit 1.0.0-beta.119 → 1.0.0-beta.120

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 (99) hide show
  1. package/DOCS.md +43 -0
  2. package/button/index.android.js +1 -0
  3. package/button/index.android.js.map +1 -1
  4. package/button/index.ios.js +1 -0
  5. package/button/index.ios.js.map +1 -1
  6. package/button/index.windows.js +13 -2
  7. package/button/index.windows.js.map +1 -1
  8. package/common.d.ts +41 -0
  9. package/common.js +162 -1
  10. package/common.js.map +1 -1
  11. package/foreign-layout.d.ts +4 -0
  12. package/foreign-layout.js +117 -0
  13. package/foreign-layout.js.map +1 -0
  14. package/index.d.ts +34 -0
  15. package/li/index.android.js +1 -0
  16. package/li/index.android.js.map +1 -1
  17. package/li/index.ios.js +1 -0
  18. package/li/index.ios.js.map +1 -1
  19. package/li/index.windows.js +4 -1
  20. package/li/index.windows.js.map +1 -1
  21. package/list/index.windows.js +4 -1
  22. package/list/index.windows.js.map +1 -1
  23. package/package.json +1 -1
  24. package/platforms/android/masonkit-release.aar +0 -0
  25. package/platforms/ios/Mason.xcframework/Info.plist +7 -7
  26. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +9 -0
  27. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  28. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  29. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +14208 -4349
  30. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +20 -0
  31. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  32. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +20 -0
  33. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  34. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8952 -8902
  35. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +18 -0
  36. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  37. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  38. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  39. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +14208 -4349
  40. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +20 -0
  41. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  42. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +20 -0
  43. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +14208 -4349
  44. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +20 -0
  45. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  46. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +20 -0
  47. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +26 -26
  48. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +2 -2
  49. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8946 -8896
  50. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +8528 -8483
  51. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Headers/Mason-Swift.h +9 -0
  52. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Mason +0 -0
  53. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros.swiftsourceinfo +0 -0
  54. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.abi.json +14208 -4349
  55. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.private.swiftinterface +20 -0
  56. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.swiftdoc +0 -0
  57. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.swiftinterface +20 -0
  58. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  59. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8442 -8392
  60. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Headers/Mason-Swift.h +9 -0
  61. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Mason +0 -0
  62. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros-simulator.swiftsourceinfo +0 -0
  63. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.abi.json +14208 -4349
  64. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.private.swiftinterface +20 -0
  65. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.swiftdoc +0 -0
  66. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.swiftinterface +20 -0
  67. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/_CodeSignature/CodeResources +14 -14
  68. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  69. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8441 -8391
  70. package/platforms/windows/arm64/NativeScript.Mason.dll +0 -0
  71. package/platforms/windows/arm64/NativeScript.Mason.winmd +0 -0
  72. package/platforms/windows/x64/NativeScript.Mason.dll +0 -0
  73. package/platforms/windows/x64/NativeScript.Mason.winmd +0 -0
  74. package/properties.js +33 -4
  75. package/properties.js.map +1 -1
  76. package/scroll/index.android.js +1 -0
  77. package/scroll/index.android.js.map +1 -1
  78. package/scroll/index.ios.js +1 -0
  79. package/scroll/index.ios.js.map +1 -1
  80. package/scroll/index.windows.js +4 -1
  81. package/scroll/index.windows.js.map +1 -1
  82. package/style.d.ts +5 -0
  83. package/style.js +89 -19
  84. package/style.js.map +1 -1
  85. package/text/index.android.js +2 -0
  86. package/text/index.android.js.map +1 -1
  87. package/text/index.ios.js +1 -0
  88. package/text/index.ios.js.map +1 -1
  89. package/text/index.windows.js +3 -2
  90. package/text/index.windows.js.map +1 -1
  91. package/typings/android.d.ts +22 -0
  92. package/typings/objc!ObjectiveC.d.ts +16 -0
  93. package/typings/windows.d.ts +13 -0
  94. package/view/index.android.js +1 -0
  95. package/view/index.android.js.map +1 -1
  96. package/view/index.ios.js +1 -0
  97. package/view/index.ios.js.map +1 -1
  98. package/view/index.windows.js +4 -1
  99. package/view/index.windows.js.map +1 -1
package/style.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { layout as coreLayout } from '@nativescript/core/utils';
2
2
  import { cssUnits } from './units';
3
- import { style_ } from './symbols';
3
+ import { isMasonView_, style_ } from './symbols';
4
4
  import { pickFontFamily } from './fonts';
5
5
  import { masonEngine } from './windows-panel-helpers';
6
6
  import { reportCssDiagnostic } from './diagnostics';
@@ -1425,7 +1425,9 @@ function appleHasWritableStyleValues(nativeView) {
1425
1425
  }
1426
1426
  return !!appleWritableStyleValues;
1427
1427
  }
1428
- function windowsStyleValues(nativeView) {
1428
+ function windowsStyleValues(nativeView, foreign) {
1429
+ if (foreign && nativeView)
1430
+ return masonEngine().ForeignStyleValues(nativeView);
1429
1431
  if (nativeView?.Node)
1430
1432
  return masonEngine().StyleValues(nativeView);
1431
1433
  return NativeScript.Mason.Mason.Instance().CreateNode(false).Style.Values;
@@ -1485,7 +1487,7 @@ export class Style {
1485
1487
  }
1486
1488
  get style_view() {
1487
1489
  if (!this._bufferRequested)
1488
- this.loadBuffer(false);
1490
+ this.loadBuffer();
1489
1491
  return this._sv;
1490
1492
  }
1491
1493
  set style_view(value) {
@@ -1494,7 +1496,7 @@ export class Style {
1494
1496
  }
1495
1497
  get i8View() {
1496
1498
  if (!this._bufferRequested)
1497
- this.loadBuffer(false);
1499
+ this.loadBuffer();
1498
1500
  if (this._i8 === undefined && this._sv)
1499
1501
  this._i8 = new Int8Array(this._sv.buffer, this._sv.byteOffset, this._sv.byteLength);
1500
1502
  return this._i8;
@@ -1504,7 +1506,7 @@ export class Style {
1504
1506
  }
1505
1507
  get u8View() {
1506
1508
  if (!this._bufferRequested)
1507
- this.loadBuffer(false);
1509
+ this.loadBuffer();
1508
1510
  if (this._u8 === undefined && this._sv)
1509
1511
  this._u8 = new Uint8Array(this._sv.buffer, this._sv.byteOffset, this._sv.byteLength);
1510
1512
  return this._u8;
@@ -1526,9 +1528,10 @@ export class Style {
1526
1528
  this._i8 = undefined;
1527
1529
  this._u8 = undefined;
1528
1530
  }
1529
- // A new node shares the arena's default buffer, so a style whose first use
1530
- // is a write asks for its own copy up front instead of fetching twice.
1531
- loadBuffer(writable) {
1531
+ // A new node shares the arena's default buffer. Every style here gets written
1532
+ // (core reads defaults right before its setters), so the first access takes
1533
+ // the node's own copy: one native fetch instead of a shared read plus a copy.
1534
+ loadBuffer() {
1532
1535
  this._bufferRequested = true;
1533
1536
  if (__ANDROID__) {
1534
1537
  this.setBuffer(ArrayBuffer.from(androidWritableStyleBuffer(this.nativeView)));
@@ -1536,13 +1539,12 @@ export class Style {
1536
1539
  else if (__APPLE__) {
1537
1540
  const nativeView = this.nativeView;
1538
1541
  let data = null;
1539
- if (writable && appleHasWritableStyleValues(nativeView)) {
1542
+ if (appleHasWritableStyleValues(nativeView)) {
1540
1543
  data = nativeView.mason_writableStyleValues();
1541
1544
  }
1542
1545
  if (!data) {
1543
1546
  const style = this.appleStyle;
1544
- if (writable)
1545
- style.prepareMut();
1547
+ style.prepareMut();
1546
1548
  data = style.values;
1547
1549
  }
1548
1550
  this.setBuffer(interop.bufferFromData(data));
@@ -1552,7 +1554,7 @@ export class Style {
1552
1554
  // projects it as a writable ArrayBuffer, so the same StyleKeys-offset writes used on
1553
1555
  // iOS/Android land straight in the node's style.
1554
1556
  //@ts-ignore
1555
- this.setBuffer(NSWinRT.interop.arrayBufferFromBuffer(windowsStyleValues(this.nativeView)));
1557
+ this.setBuffer(NSWinRT.interop.arrayBufferFromBuffer(windowsStyleValues(this.nativeView, !!this.view_ && !this.view_[isMasonView_])));
1556
1558
  }
1557
1559
  }
1558
1560
  /** The dirty mask as one value, `-1n` when clean (tests and diagnostics). */
@@ -2028,8 +2030,13 @@ export class Style {
2028
2030
  if (__ANDROID__) {
2029
2031
  //@ts-ignore
2030
2032
  const view = this.view?.android ?? this.view._view;
2031
- // @ts-ignore - syncStyleParts is a newer native method; typings regenerate from the AAR separately.
2032
- view.syncStyleParts(this._d0, this._d1, this._d2, this._d3);
2033
+ if (this.view[isMasonView_]) {
2034
+ // @ts-ignore - syncStyleParts typings regenerate from the AAR separately.
2035
+ view.syncStyleParts(this._d0, this._d1, this._d2, this._d3);
2036
+ }
2037
+ else {
2038
+ org.nativescript.mason.masonkit.Mason.getShared().syncStyleParts(view, this._d0, this._d1, this._d2, this._d3);
2039
+ }
2033
2040
  }
2034
2041
  else if (__APPLE__) {
2035
2042
  //@ts-ignore
@@ -2038,13 +2045,17 @@ export class Style {
2038
2045
  view.mason_syncStyleParts(this._d0, this._d1, this._d2, this._d3);
2039
2046
  }
2040
2047
  else if (__WINDOWS__) {
2041
- // @ts-ignore
2042
- const view = this.view?.windows ?? this.view._view;
2043
2048
  const all = !this._hasDirty;
2044
2049
  const d0 = all ? -1 : this._d0;
2045
2050
  const d1 = all ? -1 : this._d1;
2046
2051
  const d2 = all ? -1 : this._d2;
2047
2052
  const d3 = all ? -1 : this._d3;
2053
+ if (!this.view[isMasonView_]) {
2054
+ masonEngine().SyncForeignStyle(this.nativeView, d0, d1, d2, d3);
2055
+ return;
2056
+ }
2057
+ // @ts-ignore
2058
+ const view = this.view?.windows ?? this.view._view;
2048
2059
  view.SyncStyle(d0, d1, d2, d3);
2049
2060
  const text = StateKeys.WINDOWS_TEXT;
2050
2061
  if ((d0 & text.w0) | (d1 & text.w1) | (d2 & text.w2) | (d3 & text.w3)) {
@@ -2142,14 +2153,14 @@ export class Style {
2142
2153
  return;
2143
2154
  }
2144
2155
  if (!this._bufferRequested) {
2145
- this.loadBuffer(true);
2156
+ this.loadBuffer();
2146
2157
  }
2147
2158
  if (this._turnSnapshot === undefined && !this._hasDirty && this._sv) {
2148
2159
  this._turnSnapshot = this._synced ? this.u8View.slice() : false;
2149
2160
  }
2150
2161
  if (getUint32(this._sv, StyleKeys.REF_COUNT) !== 1) {
2151
- // Still the shared buffer (read before the first write): take a copy.
2152
- this.loadBuffer(true);
2162
+ // Still shared (a native without the writable fetch): take a copy.
2163
+ this.loadBuffer();
2153
2164
  }
2154
2165
  }
2155
2166
  get boxSizing() {
@@ -5180,6 +5191,8 @@ export class Style {
5180
5191
  if (!this.nativeView) {
5181
5192
  return '';
5182
5193
  }
5194
+ if (this._borderRadiusCss === null)
5195
+ this._borderRadiusCss = this._radiusCssFromBuffer();
5183
5196
  if (__ANDROID__) {
5184
5197
  return this._borderRadiusCss ?? nodeHelper().getBorderRadius(this.nativeView);
5185
5198
  }
@@ -5204,6 +5217,63 @@ export class Style {
5204
5217
  this._borderRadiusCss = undefined;
5205
5218
  this.setPseudoCssStringValue('border-radius', value, () => nodeHelper().setBorderRadius(this.nativeView, value), () => (this.appleStyle.borderRadius = value));
5206
5219
  }
5220
+ /** One corner from a core length (dip number or `{ value, unit }`) without the string round trip; false when it needs one. */
5221
+ _writeCornerLength(corner, value, scale = deviceScale()) {
5222
+ let type = 0;
5223
+ let amount;
5224
+ if (typeof value === 'number') {
5225
+ amount = Math.min(9999, Math.max(-9999, value)) * scale;
5226
+ }
5227
+ else if (value && typeof value === 'object' && typeof value.value === 'number') {
5228
+ const { unit, value: v } = value;
5229
+ if (unit === '%') {
5230
+ type = 1;
5231
+ amount = v;
5232
+ }
5233
+ else if (unit === 'px' || unit === 'dip') {
5234
+ amount = Math.min(9999, Math.max(-9999, v)) * scale;
5235
+ }
5236
+ else {
5237
+ return false;
5238
+ }
5239
+ }
5240
+ else {
5241
+ return false;
5242
+ }
5243
+ if (!Number.isFinite(amount) || !this.nativeView || this._pseudo || !this.style_view)
5244
+ return false;
5245
+ this._borderRadiusCss = null;
5246
+ this.prepareMut();
5247
+ const keys = RADIUS_KEYS[corner][1];
5248
+ setUint8(this.style_view, keys.xType, type);
5249
+ setFloat32(this.style_view, keys.xValue, amount);
5250
+ setUint8(this.style_view, keys.yType, type);
5251
+ setFloat32(this.style_view, keys.yValue, amount);
5252
+ this.commitState(StateKeys.BORDER_RADIUS);
5253
+ return true;
5254
+ }
5255
+ // The four corners as border-radius CSS, from the buffer.
5256
+ _radiusCssFromBuffer(scale = deviceScale()) {
5257
+ const view = this.style_view;
5258
+ const token = (type, v) => (type === 1 ? `${Math.round(v * 1e5) / 1e3}%` : `${Math.round((v / scale) * 1e3) / 1e3}px`);
5259
+ const h = [];
5260
+ const v = [];
5261
+ for (const [, keys] of RADIUS_KEYS) {
5262
+ h.push(token(getUint8(view, keys.xType), getFloat32(view, keys.xValue)));
5263
+ v.push(token(getUint8(view, keys.yType), getFloat32(view, keys.yValue)));
5264
+ }
5265
+ const hs = h.every((t) => t === h[0]) ? h[0] : h.join(' ');
5266
+ const vs = v.every((t) => t === v[0]) ? v[0] : v.join(' ');
5267
+ return hs === vs ? hs : `${hs} / ${vs}`;
5268
+ }
5269
+ /** Whether one corner has no radius, read straight from the buffer. */
5270
+ _cornerRadiusIsZero(corner) {
5271
+ const view = this.style_view;
5272
+ if (!view)
5273
+ return false;
5274
+ const keys = RADIUS_KEYS[corner][1];
5275
+ return getFloat32(view, keys.xValue) === 0 && getFloat32(view, keys.yValue) === 0;
5276
+ }
5207
5277
  _writeCornerRadius(corner, radius, shorthand, scale = deviceScale()) {
5208
5278
  if (!this.nativeView || this._pseudo || !this.style_view)
5209
5279
  return false;