@triniwiz/nativescript-masonkit 1.0.0-beta.106 → 1.0.0-beta.107

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 (66) hide show
  1. package/common.d.ts +17 -0
  2. package/common.js +96 -5
  3. package/common.js.map +1 -1
  4. package/css-shorthands.js +11 -1
  5. package/css-shorthands.js.map +1 -1
  6. package/package.json +1 -1
  7. package/platforms/android/masonkit-release.aar +0 -0
  8. package/platforms/ios/Mason.xcframework/Info.plist +9 -9
  9. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +5 -0
  10. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/mason_native.h +33 -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 +3178 -11939
  14. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +4 -4
  15. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  16. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +4 -4
  17. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  18. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8709 -8673
  19. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +10 -0
  20. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/mason_native.h +33 -0
  21. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  22. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  23. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  24. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +3178 -11939
  25. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +4 -4
  26. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  27. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -4
  28. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +3178 -11939
  29. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +4 -4
  30. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  31. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +4 -4
  32. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +28 -28
  33. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  34. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8703 -8667
  35. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +8306 -8285
  36. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Headers/Mason-Swift.h +5 -0
  37. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Headers/mason_native.h +33 -0
  38. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Mason +0 -0
  39. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros.swiftsourceinfo +0 -0
  40. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.abi.json +3178 -11939
  41. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.private.swiftinterface +4 -4
  42. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.swiftdoc +0 -0
  43. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.swiftinterface +4 -4
  44. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  45. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8202 -8165
  46. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Headers/Mason-Swift.h +5 -0
  47. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Headers/mason_native.h +33 -0
  48. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Mason +0 -0
  49. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros-simulator.swiftsourceinfo +0 -0
  50. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.abi.json +3178 -11939
  51. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.private.swiftinterface +4 -4
  52. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.swiftdoc +0 -0
  53. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.swiftinterface +4 -4
  54. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/_CodeSignature/CodeResources +16 -16
  55. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  56. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +8202 -8165
  57. package/scroll/index.ios.js +1 -0
  58. package/scroll/index.ios.js.map +1 -1
  59. package/style.js +11 -28
  60. package/style.js.map +1 -1
  61. package/text/index.android.js +9 -2
  62. package/text/index.android.js.map +1 -1
  63. package/text/index.ios.js +11 -2
  64. package/text/index.ios.js.map +1 -1
  65. package/view/index.ios.js +1 -0
  66. package/view/index.ios.js.map +1 -1
package/common.d.ts CHANGED
@@ -229,8 +229,19 @@ export declare class ViewBase extends CustomLayoutView implements AddChildFromBu
229
229
  _unregisterNativeEvent(arg: string, callback: any, thisArg?: any): void;
230
230
  initNativeView(): void;
231
231
  _setNativeViewFrame(nativeView: any, frame: CGRect): void;
232
+ /**
233
+ * iOS: the views in this subtree a root's layout pass must visit (non-Mason children, which core
234
+ * lays out, and Mason views listening to layoutChanged). The pass skips subtrees where it's 0.
235
+ */
236
+ _masonLayoutWork: number;
237
+ private _masonAddLayoutWork;
238
+ private _masonListensToLayout;
239
+ _addViewCore(view: any, atIndex?: number): void;
240
+ _removeViewCore(view: any): void;
232
241
  addEventListener(arg: string, callback: any, thisArg?: any): void;
233
242
  removeEventListener(arg: string, callback: any, thisArg?: any): void;
243
+ private _addEventListener;
244
+ private _removeEventListener;
234
245
  private _applyPseudoClassStyles;
235
246
  _hoverHandler(subscribe: boolean): void;
236
247
  _handler(subscribe: boolean): void;
@@ -251,9 +262,15 @@ export declare class ViewBase extends CustomLayoutView implements AddChildFromBu
251
262
  * it when its native sizing can't express one. `false` when core should handle it.
252
263
  */
253
264
  _setChildPercentSize(child: any, horizontal: boolean, fraction: number | null): boolean;
265
+ /**
266
+ * A native removal relays out natively but runs no core layout pass, so `layoutChanged`
267
+ * and non-Mason descendants miss it. Ask for one; a subtree being torn down is unloaded.
268
+ */
269
+ _masonRequestLayoutAfterRemoval(): void;
254
270
  /** Lay out the non-Mason views in this root's subtree from the frames Mason set. */
255
271
  _masonLayoutForeignDescendants(): void;
256
272
  requestLayout(): void;
273
+ _parentChanged(oldParent: any): void;
257
274
  getMeasuredWidth(): number;
258
275
  getMeasuredHeight(): number;
259
276
  eachChildView(callback: (child: NSView) => boolean): void;
package/common.js CHANGED
@@ -212,6 +212,19 @@ function clearWindowsActive(view) {
212
212
  const TEARDOWN_SLICE_MS = 8;
213
213
  // Reading the clock costs more than a teardown on some devices.
214
214
  const TEARDOWNS_PER_CLOCK_READ = 16;
215
+ // Mason roots whose requestLayout already climbed to the page in this turn.
216
+ let climbedRoots = null;
217
+ function markClimbed(root) {
218
+ if (!climbedRoots) {
219
+ climbedRoots = new Set();
220
+ queueMicrotask(() => (climbedRoots = null));
221
+ }
222
+ climbedRoots.add(root);
223
+ }
224
+ // A layout in between clears core's flag, so the next request climbs again.
225
+ function climbedThisTurn(root) {
226
+ return !!climbedRoots?.has(root) && !!root.isLayoutRequested;
227
+ }
215
228
  export class ViewBase extends CustomLayoutView {
216
229
  _tearDownUI(force) {
217
230
  if ((__ANDROID__ || __APPLE__ || __WINDOWS__) && !force && !this.reusable && this._context && this.nativeViewProtected) {
@@ -314,6 +327,11 @@ export class ViewBase extends CustomLayoutView {
314
327
  this[_c] = false;
315
328
  this[_d] = {};
316
329
  this._pendingEventsRegistration = [];
330
+ /**
331
+ * iOS: the views in this subtree a root's layout pass must visit (non-Mason children, which core
332
+ * lays out, and Mason views listening to layoutChanged). The pass skips subtrees where it's 0.
333
+ */
334
+ this._masonLayoutWork = 0;
317
335
  // `width`/`height` are core CssAnimationProperties whose stylesheet accessor
318
336
  // is non-configurable, so units Mason understands but core does not (`vh`,
319
337
  // `rem`, `pt`, …) have to be resolved on this view's own Style object.
@@ -530,7 +548,50 @@ export class ViewBase extends CustomLayoutView {
530
548
  _setNativeViewFrame(nativeView, frame) {
531
549
  // nativeView.frame = frame;
532
550
  }
551
+ _masonAddLayoutWork(delta) {
552
+ // Up to the root: a non-Mason parent is laid out by core and its Mason roots keep their own count.
553
+ let view = this;
554
+ while (view?.[isMasonView_]) {
555
+ view._masonLayoutWork += delta;
556
+ view = view.parent;
557
+ }
558
+ }
559
+ _masonListensToLayout() {
560
+ return this.hasListeners(NSView.layoutChangedEvent);
561
+ }
562
+ _addViewCore(view, atIndex) {
563
+ // Before setup: listeners the child gains while loading add themselves through `parent`.
564
+ if (__APPLE__) {
565
+ const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
566
+ if (work)
567
+ this._masonAddLayoutWork(work);
568
+ }
569
+ // @ts-ignore
570
+ super._addViewCore(view, atIndex);
571
+ }
572
+ _removeViewCore(view) {
573
+ // @ts-ignore
574
+ super._removeViewCore(view);
575
+ // After teardown: listeners removed while unloading already subtracted themselves.
576
+ if (__APPLE__) {
577
+ const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
578
+ if (work)
579
+ this._masonAddLayoutWork(-work);
580
+ }
581
+ }
533
582
  addEventListener(arg, callback, thisArg) {
583
+ const listened = __APPLE__ && this._masonListensToLayout();
584
+ this._addEventListener(arg, callback, thisArg);
585
+ if (__APPLE__ && !listened && this._masonListensToLayout())
586
+ this._masonAddLayoutWork(1);
587
+ }
588
+ removeEventListener(arg, callback, thisArg) {
589
+ const listened = __APPLE__ && this._masonListensToLayout();
590
+ this._removeEventListener(arg, callback, thisArg);
591
+ if (__APPLE__ && listened && !this._masonListensToLayout())
592
+ this._masonAddLayoutWork(-1);
593
+ }
594
+ _addEventListener(arg, callback, thisArg) {
534
595
  if (typeof thisArg === 'boolean') {
535
596
  thisArg = {
536
597
  capture: thisArg,
@@ -548,7 +609,7 @@ export class ViewBase extends CustomLayoutView {
548
609
  }
549
610
  super.addEventListener(arg, callback, thisArg);
550
611
  }
551
- removeEventListener(arg, callback, thisArg) {
612
+ _removeEventListener(arg, callback, thisArg) {
552
613
  if (typeof thisArg === 'boolean') {
553
614
  thisArg = {
554
615
  capture: thisArg,
@@ -714,6 +775,14 @@ export class ViewBase extends CustomLayoutView {
714
775
  }
715
776
  return true;
716
777
  }
778
+ /**
779
+ * A native removal relays out natively but runs no core layout pass, so `layoutChanged`
780
+ * and non-Mason descendants miss it. Ask for one; a subtree being torn down is unloaded.
781
+ */
782
+ _masonRequestLayoutAfterRemoval() {
783
+ if (__APPLE__ && this.isLoaded)
784
+ this.requestLayout();
785
+ }
717
786
  /** Lay out the non-Mason views in this root's subtree from the frames Mason set. */
718
787
  _masonLayoutForeignDescendants() {
719
788
  if (!__APPLE__)
@@ -721,6 +790,8 @@ export class ViewBase extends CustomLayoutView {
721
790
  const visit = (view) => {
722
791
  view.eachChildView((child) => {
723
792
  if (child[isMasonView_]) {
793
+ if (!(child._masonLayoutWork > 0))
794
+ return true;
724
795
  // Keep `layoutChanged` working for the few views that listen to it.
725
796
  if (child.hasListeners?.(NSView.layoutChangedEvent)) {
726
797
  const b = child._getCurrentLayoutBounds();
@@ -749,10 +820,21 @@ export class ViewBase extends CustomLayoutView {
749
820
  let root = this.parent;
750
821
  while (root?.parent?.[isMasonView_])
751
822
  root = root.parent;
823
+ if (root && climbedThisTurn(root))
824
+ return;
752
825
  root?.requestLayout();
753
826
  return;
754
827
  }
828
+ // Core climbs on every call, once per changed property; once per turn is enough.
829
+ if (__APPLE__ && climbedThisTurn(this))
830
+ return;
755
831
  super.requestLayout();
832
+ if (__APPLE__)
833
+ markClimbed(this);
834
+ }
835
+ _parentChanged(oldParent) {
836
+ climbedRoots?.delete(this);
837
+ super._parentChanged(oldParent);
756
838
  }
757
839
  getMeasuredWidth() {
758
840
  if (this._masonPlacedNatively && this.nativeViewProtected) {
@@ -1582,7 +1664,7 @@ export class ViewBase extends CustomLayoutView {
1582
1664
  _nativeBorderRadiusCorners() {
1583
1665
  // @ts-ignore
1584
1666
  const style = this._styleHelper;
1585
- if (__ANDROID__ && style && !style.hasBorderRadius()) {
1667
+ if ((__ANDROID__ || __APPLE__) && style && !style.hasBorderRadius()) {
1586
1668
  return borderRadiusCorners('0');
1587
1669
  }
1588
1670
  const native = String(style?.borderRadius ?? '').trim();
@@ -1606,13 +1688,18 @@ export class ViewBase extends CustomLayoutView {
1606
1688
  const css = lengthToCssString(masonLength(value));
1607
1689
  const radius = (corners[corner] = /\s/.test(css) ? parseCornerRadius(css) : [css, css]);
1608
1690
  const shorthand = composeBorderRadius(corners);
1609
- if (__ANDROID__ && style._writeCornerRadius(corner, radius, shorthand)) {
1691
+ if ((__ANDROID__ || __APPLE__) && style._writeCornerRadius(corner, radius, shorthand)) {
1610
1692
  return;
1611
1693
  }
1612
1694
  // @ts-ignore
1613
1695
  style.borderRadius = shorthand;
1614
1696
  }
1615
1697
  _nativeCornerRadius(corner) {
1698
+ // @ts-ignore
1699
+ const style = this._styleHelper;
1700
+ if ((__ANDROID__ || __APPLE__) && style && !style.hasBorderRadius()) {
1701
+ return '0';
1702
+ }
1616
1703
  const [h, v] = this._nativeBorderRadiusCorners()[corner];
1617
1704
  return h === v ? h : `${h} ${v}`;
1618
1705
  }
@@ -1641,7 +1728,7 @@ export class ViewBase extends CustomLayoutView {
1641
1728
  this._borderRadiusCorner(3, value);
1642
1729
  }
1643
1730
  _borderSideColor(side, value) {
1644
- if (__ANDROID__) {
1731
+ if (__ANDROID__ || __APPLE__) {
1645
1732
  const s = this._styleHelper;
1646
1733
  if (s) {
1647
1734
  s.setBorderSideColor(side === 't' ? 'top' : side === 'r' ? 'right' : side === 'b' ? 'bottom' : 'left', value);
@@ -1854,8 +1941,12 @@ export class ViewBase extends CustomLayoutView {
1854
1941
  nodeHelper().setBorderColor(this.nativeView, String(value));
1855
1942
  }
1856
1943
  else if (__APPLE__) {
1944
+ const s = this._styleHelper;
1945
+ if (s)
1946
+ s.setBorderColor(String(value));
1857
1947
  // @ts-ignore
1858
- this.nativeView.style.setBorderColor(String(value));
1948
+ else
1949
+ this.nativeView.style.setBorderColor(String(value));
1859
1950
  }
1860
1951
  else if (__WINDOWS__) {
1861
1952
  // @ts-ignore