@triniwiz/nativescript-masonkit 1.0.0-beta.103 → 1.0.0-beta.105

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 (61) hide show
  1. package/common.d.ts +17 -0
  2. package/common.js +138 -15
  3. package/common.js.map +1 -1
  4. package/index.d.ts +17 -3
  5. package/list/common.d.ts +2 -0
  6. package/list/common.js +9 -0
  7. package/list/common.js.map +1 -1
  8. package/list/index.android.js +2 -1
  9. package/list/index.android.js.map +1 -1
  10. package/list/index.ios.d.ts +1 -0
  11. package/list/index.ios.js +9 -3
  12. package/list/index.ios.js.map +1 -1
  13. package/package.json +1 -1
  14. package/platforms/android/masonkit-release.aar +0 -0
  15. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  16. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  17. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +12939 -4082
  18. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  19. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7471 -7471
  20. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  21. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  22. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  23. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +12939 -4082
  24. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +12939 -4082
  25. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +12 -12
  26. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  27. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7457 -7457
  28. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +7147 -7147
  29. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Mason +0 -0
  30. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros.swiftsourceinfo +0 -0
  31. package/platforms/ios/Mason.xcframework/xros-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros.abi.json +12939 -4082
  32. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  33. package/platforms/ios/Mason.xcframework/xros-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +6960 -6960
  34. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Mason +0 -0
  35. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-xros-simulator.swiftsourceinfo +0 -0
  36. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-xros-simulator.abi.json +12939 -4082
  37. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/Mason.framework/_CodeSignature/CodeResources +6 -6
  38. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  39. package/platforms/ios/Mason.xcframework/xros-arm64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +6968 -6968
  40. package/platforms/windows/arm64/NativeScript.Mason.dll +0 -0
  41. package/platforms/windows/arm64/NativeScript.Mason.winmd +0 -0
  42. package/platforms/windows/x64/NativeScript.Mason.dll +0 -0
  43. package/platforms/windows/x64/NativeScript.Mason.winmd +0 -0
  44. package/scroll/index.android.js +2 -2
  45. package/scroll/index.android.js.map +1 -1
  46. package/scroll/index.ios.js +2 -2
  47. package/scroll/index.ios.js.map +1 -1
  48. package/style.d.ts +7 -0
  49. package/style.js +100 -15
  50. package/style.js.map +1 -1
  51. package/text/index.android.js +3 -3
  52. package/text/index.android.js.map +1 -1
  53. package/text/index.ios.js +2 -2
  54. package/text/index.ios.js.map +1 -1
  55. package/text-runs.d.ts +1 -0
  56. package/text-runs.js +1 -0
  57. package/text-runs.js.map +1 -1
  58. package/view/index.android.js +2 -2
  59. package/view/index.android.js.map +1 -1
  60. package/view/index.ios.js +2 -2
  61. package/view/index.ios.js.map +1 -1
package/common.d.ts CHANGED
@@ -264,6 +264,12 @@ export declare class ViewBase extends CustomLayoutView implements AddChildFromBu
264
264
  addChild(child: any): void;
265
265
  insertBefore(child: any, reference: any): void;
266
266
  private _nativeIndexFor;
267
+ private _attachCursor;
268
+ _nativeAttachIndex(child: any, atIndex: number): {
269
+ jsIndex: number;
270
+ nativeIndex: number;
271
+ };
272
+ _invalidateAttachCursor(): void;
267
273
  _windowsNativeIndexOf(child: any, atIndex: number): number;
268
274
  _childIndexToNativeChildIndex(index?: number): number;
269
275
  insertChild(child: any, atIndex: number): void;
@@ -427,6 +433,8 @@ export declare class Event {
427
433
  set button(_: number);
428
434
  get target(): any;
429
435
  set target(_: any);
436
+ get object(): any;
437
+ get eventName(): string;
430
438
  set currentTarget(_: any);
431
439
  set bubbles(_: boolean);
432
440
  set cancelable(_: boolean);
@@ -437,3 +445,12 @@ export declare class InputEvent extends Event {
437
445
  get data(): any;
438
446
  get inputType(): any;
439
447
  }
448
+ /** DOM KeyboardEvent: dispatched on Windows. */
449
+ export declare class KeyboardEvent extends Event {
450
+ get key(): string;
451
+ get repeat(): boolean;
452
+ get ctrlKey(): boolean;
453
+ get shiftKey(): boolean;
454
+ get altKey(): boolean;
455
+ get metaKey(): boolean;
456
+ }
package/common.js CHANGED
@@ -114,8 +114,12 @@ function masonNativeEventName(eventName) {
114
114
  case 'tap':
115
115
  case 'click':
116
116
  return 'click';
117
+ case 'beforeinput':
117
118
  case 'input':
118
119
  case 'change':
120
+ case 'focus':
121
+ case 'blur':
122
+ case 'keydown':
119
123
  return eventName;
120
124
  default:
121
125
  return null;
@@ -388,13 +392,7 @@ export class ViewBase extends CustomLayoutView {
388
392
  invoke(event) {
389
393
  const owner = ref.get();
390
394
  if (owner) {
391
- let ret;
392
- if (arg === 'input') {
393
- ret = new InputEvent();
394
- }
395
- else {
396
- ret = new Event();
397
- }
395
+ const ret = wrapNativeEvent(arg);
398
396
  ret[native_] = event;
399
397
  ret._target = owner;
400
398
  callback.call(thisArg || owner, ret);
@@ -408,13 +406,7 @@ export class ViewBase extends CustomLayoutView {
408
406
  if (__APPLE__) {
409
407
  //@ts-ignore
410
408
  const id = this._view.mason_addEventListener(arg, (event) => {
411
- let ret;
412
- if (arg === 'input') {
413
- ret = new InputEvent();
414
- }
415
- else {
416
- ret = new Event();
417
- }
409
+ const ret = wrapNativeEvent(arg);
418
410
  ret[native_] = event;
419
411
  ret._target = this;
420
412
  callback.call(thisArg || this, ret);
@@ -454,6 +446,21 @@ export class ViewBase extends CustomLayoutView {
454
446
  }
455
447
  catch (_) { }
456
448
  }
449
+ else if (typeof this._view.AddEventListener === 'function') {
450
+ const ref = new WeakRef(this);
451
+ const listener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
452
+ const owner = ref.deref();
453
+ if (!owner)
454
+ return;
455
+ const ret = wrapNativeEvent(arg);
456
+ ret[native_] = event;
457
+ ret._target = owner;
458
+ callback.call(thisArg || owner, ret);
459
+ });
460
+ callback['mason:event:id'] = this._view.AddEventListener(arg, listener);
461
+ // Held so the delegate isn't collected.
462
+ callback['mason:event:listener'] = listener;
463
+ }
457
464
  }
458
465
  }
459
466
  }
@@ -497,6 +504,11 @@ export class ViewBase extends CustomLayoutView {
497
504
  callback['mason:event:id'] = undefined;
498
505
  callback['mason:event:tapped'] = undefined;
499
506
  }
507
+ else if (id && typeof this._view.RemoveEventListener === 'function') {
508
+ this._view.RemoveEventListener(arg, id);
509
+ callback['mason:event:id'] = undefined;
510
+ callback['mason:event:listener'] = undefined;
511
+ }
500
512
  }
501
513
  }
502
514
  }
@@ -864,6 +876,24 @@ export class ViewBase extends CustomLayoutView {
864
876
  }
865
877
  return index;
866
878
  }
879
+ _nativeAttachIndex(child, atIndex) {
880
+ const cur = this._attachCursor;
881
+ let jsIndex;
882
+ let nativeIndex;
883
+ if (atIndex <= -1 && cur && this._children[cur.jsIndex] === cur.child && this._children[cur.jsIndex + 1] === child) {
884
+ jsIndex = cur.jsIndex + 1;
885
+ nativeIndex = cur.nativeIndex + 1;
886
+ }
887
+ else {
888
+ jsIndex = atIndex <= -1 ? this._children.indexOf(child) : atIndex;
889
+ nativeIndex = jsIndex <= -1 ? jsIndex : this._nativeIndexFor(jsIndex);
890
+ }
891
+ this._attachCursor = jsIndex >= 0 && nativeIndex >= 0 ? { child, jsIndex, nativeIndex } : undefined;
892
+ return { jsIndex, nativeIndex };
893
+ }
894
+ _invalidateAttachCursor() {
895
+ this._attachCursor = undefined;
896
+ }
867
897
  // Windows attaches element children on load with no index, after text runs that attached
868
898
  // straight away, so an append would land them after text that comes later.
869
899
  _windowsNativeIndexOf(child, atIndex) {
@@ -879,6 +909,7 @@ export class ViewBase extends CustomLayoutView {
879
909
  return super._childIndexToNativeChildIndex(index);
880
910
  }
881
911
  insertChild(child, atIndex) {
912
+ this._invalidateAttachCursor();
882
913
  if (__WINDOWS__) {
883
914
  this._windowsSplitAnonymousText(atIndex);
884
915
  }
@@ -909,6 +940,7 @@ export class ViewBase extends CustomLayoutView {
909
940
  }
910
941
  }
911
942
  replaceChild(child, atIndex) {
943
+ this._invalidateAttachCursor();
912
944
  if (child && child[isPlaceholder_] && child._view) {
913
945
  this._children[atIndex] = child;
914
946
  if (this[isText_]) {
@@ -956,6 +988,7 @@ export class ViewBase extends CustomLayoutView {
956
988
  }
957
989
  }
958
990
  removeChild(child) {
991
+ this._invalidateAttachCursor();
959
992
  // Placeholder (e.g. Br): it was attached straight to the mason tree via the
960
993
  // native element APIs (never `_addView`-ed), so `_removeView` would throw.
961
994
  // Remove the native node directly instead.
@@ -1080,6 +1113,7 @@ export class ViewBase extends CustomLayoutView {
1080
1113
  this._forEachAnonymousText((anonymous) => masonEngine().RemoveChild(this._view, anonymous));
1081
1114
  }
1082
1115
  this._children.splice(0);
1116
+ this._invalidateAttachCursor();
1083
1117
  }
1084
1118
  [(_a = isMasonView_, _b = isTextChild_, _c = isText_, _d = pseudoStyles_, zIndexProperty.setNative)](value) {
1085
1119
  // @ts-ignore
@@ -1285,6 +1319,7 @@ export class ViewBase extends CustomLayoutView {
1285
1319
  }
1286
1320
  // -- Unified text node update (cross-platform) --
1287
1321
  _updateTextNode(node, operation = null) {
1322
+ this._invalidateAttachCursor();
1288
1323
  const text = String(node.text ?? node.data ?? '');
1289
1324
  const textNode = this._createOrUpdateNativeTextNode(node, text);
1290
1325
  if (!operation)
@@ -1573,6 +1608,13 @@ export class ViewBase extends CustomLayoutView {
1573
1608
  this._borderRadiusCorner(3, value);
1574
1609
  }
1575
1610
  _borderSideColor(side, value) {
1611
+ if (__ANDROID__) {
1612
+ const s = this._styleHelper;
1613
+ if (s) {
1614
+ s.setBorderSideColor(side === 't' ? 'top' : side === 'r' ? 'right' : side === 'b' ? 'bottom' : 'left', value);
1615
+ return;
1616
+ }
1617
+ }
1576
1618
  let sides = this[borderSideColors_];
1577
1619
  if (!sides) {
1578
1620
  sides = this[borderSideColors_] = { t: 'transparent', r: 'transparent', b: 'transparent', l: 'transparent' };
@@ -1771,8 +1813,12 @@ export class ViewBase extends CustomLayoutView {
1771
1813
  // @ts-ignore
1772
1814
  [borderColorProperty.setNative](value) {
1773
1815
  if (__ANDROID__) {
1816
+ const s = this._styleHelper;
1817
+ if (s)
1818
+ s.setBorderColor(String(value));
1774
1819
  // @ts-ignore
1775
- org.nativescript.mason.masonkit.NodeHelper.getShared().setBorderColor(this.nativeView, String(value));
1820
+ else
1821
+ org.nativescript.mason.masonkit.NodeHelper.getShared().setBorderColor(this.nativeView, String(value));
1776
1822
  }
1777
1823
  else if (__APPLE__) {
1778
1824
  // @ts-ignore
@@ -2653,6 +2699,9 @@ export class Event {
2653
2699
  if (__APPLE__) {
2654
2700
  return this[native_]?.bubbles;
2655
2701
  }
2702
+ if (__WINDOWS__) {
2703
+ return this[native_]?.Bubbles ?? false;
2704
+ }
2656
2705
  return false;
2657
2706
  }
2658
2707
  get cancelable() {
@@ -2662,6 +2711,9 @@ export class Event {
2662
2711
  if (__APPLE__) {
2663
2712
  return this[native_]?.cancelable;
2664
2713
  }
2714
+ if (__WINDOWS__) {
2715
+ return this[native_]?.Cancelable ?? false;
2716
+ }
2665
2717
  return false;
2666
2718
  }
2667
2719
  get isComposing() {
@@ -2671,6 +2723,9 @@ export class Event {
2671
2723
  if (__APPLE__) {
2672
2724
  return this[native_]?.isComposing;
2673
2725
  }
2726
+ if (__WINDOWS__) {
2727
+ return this[native_]?.IsComposing ?? false;
2728
+ }
2674
2729
  return false;
2675
2730
  }
2676
2731
  get timeStamp() {
@@ -2680,6 +2735,9 @@ export class Event {
2680
2735
  if (__APPLE__) {
2681
2736
  return this[native_]?.timeStamp;
2682
2737
  }
2738
+ if (__WINDOWS__) {
2739
+ return this[native_]?.TimeStamp ?? 0;
2740
+ }
2683
2741
  return 0;
2684
2742
  }
2685
2743
  get defaultPrevented() {
@@ -2689,6 +2747,9 @@ export class Event {
2689
2747
  if (__APPLE__) {
2690
2748
  return this[native_]?.defaultPrevented;
2691
2749
  }
2750
+ if (__WINDOWS__) {
2751
+ return this[native_]?.DefaultPrevented ?? false;
2752
+ }
2692
2753
  return false;
2693
2754
  }
2694
2755
  get propagationStopped() {
@@ -2698,6 +2759,9 @@ export class Event {
2698
2759
  if (__APPLE__) {
2699
2760
  return this[native_]?.propagationStopped;
2700
2761
  }
2762
+ if (__WINDOWS__) {
2763
+ return this[native_]?.PropagationStopped ?? false;
2764
+ }
2701
2765
  return false;
2702
2766
  }
2703
2767
  get immediatePropagationStopped() {
@@ -2707,6 +2771,9 @@ export class Event {
2707
2771
  if (__APPLE__) {
2708
2772
  return this[native_]?.immediatePropagationStopped;
2709
2773
  }
2774
+ if (__WINDOWS__) {
2775
+ return this[native_]?.ImmediatePropagationStopped ?? false;
2776
+ }
2710
2777
  return false;
2711
2778
  }
2712
2779
  get currentTarget() {
@@ -2722,6 +2789,9 @@ export class Event {
2722
2789
  if (__APPLE__) {
2723
2790
  return this[native_]?.stopImmediatePropagation();
2724
2791
  }
2792
+ if (__WINDOWS__) {
2793
+ return this[native_]?.StopImmediatePropagation();
2794
+ }
2725
2795
  }
2726
2796
  stopPropagation() {
2727
2797
  if (__ANDROID__) {
@@ -2730,6 +2800,9 @@ export class Event {
2730
2800
  if (__APPLE__) {
2731
2801
  return this[native_]?.stopPropagation();
2732
2802
  }
2803
+ if (__WINDOWS__) {
2804
+ return this[native_]?.StopPropagation();
2805
+ }
2733
2806
  }
2734
2807
  preventDefault() {
2735
2808
  if (__ANDROID__) {
@@ -2738,6 +2811,9 @@ export class Event {
2738
2811
  if (__APPLE__) {
2739
2812
  return this[native_]?.preventDefault();
2740
2813
  }
2814
+ if (__WINDOWS__) {
2815
+ return this[native_]?.PreventDefault();
2816
+ }
2741
2817
  }
2742
2818
  // Writable on purpose, unlike the DOM's read-only `Event.type`. Aliases
2743
2819
  // (e.g. 'tap') are folded onto the native name ('click') before the event
@@ -2752,6 +2828,9 @@ export class Event {
2752
2828
  if (__ANDROID__) {
2753
2829
  return this[native_]?.getType();
2754
2830
  }
2831
+ if (__WINDOWS__) {
2832
+ return this[native_]?.Type;
2833
+ }
2755
2834
  return this[native_]?.type;
2756
2835
  }
2757
2836
  set type(value) {
@@ -2768,6 +2847,12 @@ export class Event {
2768
2847
  return this['_target'];
2769
2848
  }
2770
2849
  set target(_) { }
2850
+ get object() {
2851
+ return this['_target'];
2852
+ }
2853
+ get eventName() {
2854
+ return this.type;
2855
+ }
2771
2856
  set currentTarget(_) { }
2772
2857
  set bubbles(_) { }
2773
2858
  set cancelable(_) { }
@@ -2807,6 +2892,9 @@ export class InputEvent extends Event {
2807
2892
  }
2808
2893
  return this[native_]?.data;
2809
2894
  }
2895
+ if (__WINDOWS__) {
2896
+ return this[native_]?.Data ?? null;
2897
+ }
2810
2898
  return false;
2811
2899
  }
2812
2900
  get inputType() {
@@ -2816,7 +2904,42 @@ export class InputEvent extends Event {
2816
2904
  if (__APPLE__) {
2817
2905
  return this[native_]?.inputType;
2818
2906
  }
2907
+ if (__WINDOWS__) {
2908
+ return this[native_]?.InputType ?? '';
2909
+ }
2819
2910
  return false;
2820
2911
  }
2821
2912
  }
2913
+ /** DOM KeyboardEvent: dispatched on Windows. */
2914
+ export class KeyboardEvent extends Event {
2915
+ get key() {
2916
+ return this[native_]?.Key ?? '';
2917
+ }
2918
+ get repeat() {
2919
+ return this[native_]?.Repeat ?? false;
2920
+ }
2921
+ get ctrlKey() {
2922
+ return this[native_]?.CtrlKey ?? false;
2923
+ }
2924
+ get shiftKey() {
2925
+ return this[native_]?.ShiftKey ?? false;
2926
+ }
2927
+ get altKey() {
2928
+ return this[native_]?.AltKey ?? false;
2929
+ }
2930
+ get metaKey() {
2931
+ return this[native_]?.MetaKey ?? false;
2932
+ }
2933
+ }
2934
+ function wrapNativeEvent(type) {
2935
+ switch (type) {
2936
+ case 'beforeinput':
2937
+ case 'input':
2938
+ return new InputEvent();
2939
+ case 'keydown':
2940
+ return new KeyboardEvent();
2941
+ default:
2942
+ return new Event();
2943
+ }
2944
+ }
2822
2945
  //# sourceMappingURL=common.js.map