@ng-native/components 0.19.1 → 0.19.2

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.
@@ -11,6 +11,12 @@ import * as i0 from "@angular/core";
11
11
  * `setNativeRefreshing`; so does this. If the app never sets `refreshing` after a pull, the
12
12
  * spinner is stopped again, which is what RN's documentation warns about.
13
13
  *
14
+ * On iOS a control that is already refreshing when its page is pushed, or when its tab is first
15
+ * shown, starts spinning once the screen has appeared (`SCREEN_SHOWN`). Begun any earlier,
16
+ * native moves the content down by the spinner's height under a large title, and the gap stays
17
+ * after the spinner stops, and on scroll views of screens shown after it. React Native's own
18
+ * `RefreshControl` leaves that gap.
19
+ *
14
20
  * On Android the swipe layout has to be the scroll view's *parent*, as RN's `ScrollView.js` makes
15
21
  * it, with the layout half of the scroll view's style moved onto it. It is written as a child all
16
22
  * the same, like on iOS, and moved into place after each pass; see `SwipeRefreshLayout`.
@@ -38,6 +44,8 @@ export declare class RefreshControl extends ViewBase implements AfterViewChecked
38
44
  /** Android: the spinner's size. */
39
45
  readonly size: import("@angular/core").InputSignal<"large" | "default" | undefined>;
40
46
  private readonly nativeRefreshing;
47
+ private readonly shown;
48
+ protected readonly committedRefreshing: import("@angular/core").Signal<boolean>;
41
49
  /** Android only: what moves this control's node to wrap the scroll view. */
42
50
  private readonly wrap;
43
51
  constructor();
@@ -1,4 +1,5 @@
1
- import { Directive, DestroyRef, afterEveryRender, effect, inject, input, model, signal, } from '@angular/core';
1
+ import { Directive, DestroyRef, afterEveryRender, computed, effect, inject, input, model, signal, } from '@angular/core';
2
+ import { SCREEN_SHOWN } from '@ng-native/device';
2
3
  import { Engine, nativePlatform } from '@ng-native/fabric';
3
4
  import { SwipeRefreshLayout } from "./swipe-refresh-layout.js";
4
5
  import { optionalBoolean, optionalNumber } from "./transforms.js";
@@ -14,6 +15,12 @@ import * as i0 from "@angular/core";
14
15
  * `setNativeRefreshing`; so does this. If the app never sets `refreshing` after a pull, the
15
16
  * spinner is stopped again, which is what RN's documentation warns about.
16
17
  *
18
+ * On iOS a control that is already refreshing when its page is pushed, or when its tab is first
19
+ * shown, starts spinning once the screen has appeared (`SCREEN_SHOWN`). Begun any earlier,
20
+ * native moves the content down by the spinner's height under a large title, and the gap stays
21
+ * after the spinner stops, and on scroll views of screens shown after it. React Native's own
22
+ * `RefreshControl` leaves that gap.
23
+ *
17
24
  * On Android the swipe layout has to be the scroll view's *parent*, as RN's `ScrollView.js` makes
18
25
  * it, with the layout half of the scroll view's style moved onto it. It is written as a child all
19
26
  * the same, like on iOS, and moved into place after each pass; see `SwipeRefreshLayout`.
@@ -49,6 +56,9 @@ export class RefreshControl extends ViewBase {
49
56
  ...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
50
57
  nativeRefreshing = signal(null, /* @ts-ignore */
51
58
  ...(ngDevMode ? [{ debugName: "nativeRefreshing" }] : /* istanbul ignore next */ []));
59
+ shown = nativePlatform() === 'ios' ? inject(SCREEN_SHOWN) : null;
60
+ committedRefreshing = computed(() => this.refreshing() && (this.shown?.() ?? true), /* @ts-ignore */
61
+ ...(ngDevMode ? [{ debugName: "committedRefreshing" }] : /* istanbul ignore next */ []));
52
62
  /** Android only: what moves this control's node to wrap the scroll view. */
53
63
  wrap = nativePlatform() === 'android'
54
64
  ? new SwipeRefreshLayout(inject(Engine), this.node)
@@ -83,14 +93,14 @@ export class RefreshControl extends ViewBase {
83
93
  this.nativeRefreshing.set(true);
84
94
  }
85
95
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: RefreshControl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
86
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: RefreshControl, isStandalone: true, selector: "refresh-control", inputs: { refreshing: { classPropertyName: "refreshing", publicName: "refreshing", isSignal: true, isRequired: false, transformFunction: null }, progressViewOffset: { classPropertyName: "progressViewOffset", publicName: "progressViewOffset", isSignal: true, isRequired: false, transformFunction: null }, tintColor: { classPropertyName: "tintColor", publicName: "tintColor", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, titleColor: { classPropertyName: "titleColor", publicName: "titleColor", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, progressBackgroundColor: { classPropertyName: "progressBackgroundColor", publicName: "progressBackgroundColor", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { refreshing: "refreshingChange" }, host: { listeners: { "refresh": "onNativeRefresh()" }, properties: { "refreshing": "refreshing()", "progressViewOffset": "progressViewOffset()", "tintColor": "tintColor()", "title": "title()", "titleColor": "titleColor()", "colors": "colors()", "enabled": "enabled()", "progressBackgroundColor": "progressBackgroundColor()", "size": "size()" } }, usesInheritance: true, ngImport: i0 });
96
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: RefreshControl, isStandalone: true, selector: "refresh-control", inputs: { refreshing: { classPropertyName: "refreshing", publicName: "refreshing", isSignal: true, isRequired: false, transformFunction: null }, progressViewOffset: { classPropertyName: "progressViewOffset", publicName: "progressViewOffset", isSignal: true, isRequired: false, transformFunction: null }, tintColor: { classPropertyName: "tintColor", publicName: "tintColor", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, titleColor: { classPropertyName: "titleColor", publicName: "titleColor", isSignal: true, isRequired: false, transformFunction: null }, colors: { classPropertyName: "colors", publicName: "colors", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, progressBackgroundColor: { classPropertyName: "progressBackgroundColor", publicName: "progressBackgroundColor", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { refreshing: "refreshingChange" }, host: { listeners: { "refresh": "onNativeRefresh()" }, properties: { "refreshing": "committedRefreshing()", "progressViewOffset": "progressViewOffset()", "tintColor": "tintColor()", "title": "title()", "titleColor": "titleColor()", "colors": "colors()", "enabled": "enabled()", "progressBackgroundColor": "progressBackgroundColor()", "size": "size()" } }, usesInheritance: true, ngImport: i0 });
87
97
  }
88
98
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: RefreshControl, decorators: [{
89
99
  type: Directive,
90
100
  args: [{
91
101
  selector: 'refresh-control',
92
102
  host: {
93
- '[refreshing]': 'refreshing()',
103
+ '[refreshing]': 'committedRefreshing()',
94
104
  '[progressViewOffset]': 'progressViewOffset()',
95
105
  '[tintColor]': 'tintColor()',
96
106
  '[title]': 'title()',
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-control.js","sourceRoot":"","sources":["../src/refresh-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAmB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;;;;;;;;;;GAaG;AAgBH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C;;;OAGG;IACM,UAAU,GAAG,KAAK,CAAC,KAAK;mFAAC,CAAC;IACnC,6CAA6C;IACpC,k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AAE,CAAC;gBAC1C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,6FAA6F;IACnF,eAAe;QACvB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;uGA7DU,cAAc;2FAAd,cAAc;;2FAAd,cAAc;kBAf1B,SAAS;mBAAC;oBACT,QAAQ,EAAE,iBAAiB;oBAC3B,IAAI,EAAE;wBACJ,cAAc,EAAE,cAAc;wBAC9B,sBAAsB,EAAE,sBAAsB;wBAC9C,aAAa,EAAE,aAAa;wBAC5B,SAAS,EAAE,SAAS;wBACpB,cAAc,EAAE,cAAc;wBAC9B,UAAU,EAAE,UAAU;wBACtB,WAAW,EAAE,WAAW;wBACxB,2BAA2B,EAAE,2BAA2B;wBACxD,QAAQ,EAAE,QAAQ;wBAClB,WAAW,EAAE,mBAAmB;qBACjC;iBACF","sourcesContent":["import {\n type AfterViewChecked,\n Directive,\n DestroyRef,\n afterEveryRender,\n effect,\n inject,\n input,\n model,\n signal,\n} from '@angular/core';\nimport { Engine, type EngineNode, nativePlatform } from '@ng-native/fabric';\nimport { SwipeRefreshLayout } from './swipe-refresh-layout.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * Pull to refresh, as a child of a scroll view. Commits as `PullToRefreshView` on iOS and\n * `AndroidSwipeRefreshLayout` on Android.\n *\n * `refreshing` is a model: the pull fires `(refresh)`, the app sets `refreshing` to true while\n * it works and back to false when done. Native shows the spinner the instant the user pulls,\n * before the app has said anything, so the two can disagree. RN's wrapper reconciles them with\n * `setNativeRefreshing`; so does this. If the app never sets `refreshing` after a pull, the\n * spinner is stopped again, which is what RN's documentation warns about.\n *\n * On Android the swipe layout has to be the scroll view's *parent*, as RN's `ScrollView.js` makes\n * it, with the layout half of the scroll view's style moved onto it. It is written as a child all\n * the same, like on iOS, and moved into place after each pass; see `SwipeRefreshLayout`.\n */\n@Directive({\n selector: 'refresh-control',\n host: {\n '[refreshing]': 'refreshing()',\n '[progressViewOffset]': 'progressViewOffset()',\n '[tintColor]': 'tintColor()',\n '[title]': 'title()',\n '[titleColor]': 'titleColor()',\n '[colors]': 'colors()',\n '[enabled]': 'enabled()',\n '[progressBackgroundColor]': 'progressBackgroundColor()',\n '[size]': 'size()',\n '(refresh)': 'onNativeRefresh()',\n },\n})\nexport class RefreshControl extends ViewBase implements AfterViewChecked {\n /**\n * Whether the spinner shows. Only the app changes it: a pull fires `(refresh)` and leaves this\n * alone, so `[(refreshing)]` and `[refreshing]` behave the same.\n */\n readonly refreshing = model(false);\n /** How far from the top the spinner sits. */\n readonly progressViewOffset = input(undefined, { transform: optionalNumber });\n /** iOS: the spinner's colour. */\n readonly tintColor = input<string>();\n /** iOS: a label under the spinner. */\n readonly title = input<string>();\n /** iOS: the label's colour. */\n readonly titleColor = input<string>();\n /** Android: the colours the spinner cycles through. */\n readonly colors = input<readonly string[]>();\n /** Android: whether pulling does anything. Defaults to true. */\n readonly enabled = input(undefined, { transform: optionalBoolean });\n /** Android: the spinner's background. */\n readonly progressBackgroundColor = input<string>();\n /** Android: the spinner's size. */\n readonly size = input<'default' | 'large'>();\n\n private readonly nativeRefreshing = signal<boolean | null>(null);\n\n /** Android only: what moves this control's node to wrap the scroll view. */\n private readonly wrap =\n nativePlatform() === 'android'\n ? new SwipeRefreshLayout(inject(Engine), this.node as EngineNode)\n : null;\n\n constructor() {\n super();\n const wrap = this.wrap;\n if (wrap) {\n // After every render as well as after this control's own pass: Angular moving the scroll\n // view happens in some other component's pass, and this one's hooks would not see it.\n afterEveryRender(() => wrap.sync());\n inject(DestroyRef).onDestroy(() => wrap.unwrap());\n }\n effect(() => {\n const desired = this.refreshing();\n const native = this.nativeRefreshing();\n if (native !== null && native !== desired) {\n this.nativeRefreshing.set(desired);\n this.engine.dispatchCommand(this.node, 'setNativeRefreshing', [desired]);\n }\n });\n }\n\n /**\n * The scroll view's style is written in the pass that declared this control, so splitting it\n * here reaches native in the same commit.\n */\n ngAfterViewChecked(): void {\n this.wrap?.sync();\n }\n\n /** Native has already started spinning; the app is told and expected to set `refreshing`. */\n protected onNativeRefresh(): void {\n this.nativeRefreshing.set(true);\n }\n}\n"]}
1
+ {"version":3,"file":"refresh-control.js","sourceRoot":"","sources":["../src/refresh-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAmB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AAgBH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C;;;OAGG;IACM,UAAU,GAAG,KAAK,CAAC,KAAK;mFAAC,CAAC;IACnC,6CAA6C;IACpC,kBAAkB,GAAG,KAAK,CAAC,SAAS,0FAAI,SAAS,EAAE,cAAc,GAAG,CAAC;IAC9E,iCAAiC;IACxB,SAAS,GAAG,KAAK;6FAAU,CAAC;IACrC,sCAAsC;IAC7B,KAAK,GAAG,KAAK;yFAAU,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AM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACvC,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC1C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,6FAA6F;IACnF,eAAe;QACvB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;uGAlEU,cAAc;2FAAd,cAAc;;2FAAd,cAAc;kBAf1B,SAAS;mBAAC;oBACT,QAAQ,EAAE,iBAAiB;oBAC3B,IAAI,EAAE;wBACJ,cAAc,EAAE,uBAAuB;wBACvC,sBAAsB,EAAE,sBAAsB;wBAC9C,aAAa,EAAE,aAAa;wBAC5B,SAAS,EAAE,SAAS;wBACpB,cAAc,EAAE,cAAc;wBAC9B,UAAU,EAAE,UAAU;wBACtB,WAAW,EAAE,WAAW;wBACxB,2BAA2B,EAAE,2BAA2B;wBACxD,QAAQ,EAAE,QAAQ;wBAClB,WAAW,EAAE,mBAAmB;qBACjC;iBACF","sourcesContent":["import {\n type AfterViewChecked,\n Directive,\n DestroyRef,\n afterEveryRender,\n computed,\n effect,\n inject,\n input,\n model,\n signal,\n} from '@angular/core';\nimport { SCREEN_SHOWN } from '@ng-native/device';\nimport { Engine, type EngineNode, nativePlatform } from '@ng-native/fabric';\nimport { SwipeRefreshLayout } from './swipe-refresh-layout.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * Pull to refresh, as a child of a scroll view. Commits as `PullToRefreshView` on iOS and\n * `AndroidSwipeRefreshLayout` on Android.\n *\n * `refreshing` is a model: the pull fires `(refresh)`, the app sets `refreshing` to true while\n * it works and back to false when done. Native shows the spinner the instant the user pulls,\n * before the app has said anything, so the two can disagree. RN's wrapper reconciles them with\n * `setNativeRefreshing`; so does this. If the app never sets `refreshing` after a pull, the\n * spinner is stopped again, which is what RN's documentation warns about.\n *\n * On iOS a control that is already refreshing when its page is pushed, or when its tab is first\n * shown, starts spinning once the screen has appeared (`SCREEN_SHOWN`). Begun any earlier,\n * native moves the content down by the spinner's height under a large title, and the gap stays\n * after the spinner stops, and on scroll views of screens shown after it. React Native's own\n * `RefreshControl` leaves that gap.\n *\n * On Android the swipe layout has to be the scroll view's *parent*, as RN's `ScrollView.js` makes\n * it, with the layout half of the scroll view's style moved onto it. It is written as a child all\n * the same, like on iOS, and moved into place after each pass; see `SwipeRefreshLayout`.\n */\n@Directive({\n selector: 'refresh-control',\n host: {\n '[refreshing]': 'committedRefreshing()',\n '[progressViewOffset]': 'progressViewOffset()',\n '[tintColor]': 'tintColor()',\n '[title]': 'title()',\n '[titleColor]': 'titleColor()',\n '[colors]': 'colors()',\n '[enabled]': 'enabled()',\n '[progressBackgroundColor]': 'progressBackgroundColor()',\n '[size]': 'size()',\n '(refresh)': 'onNativeRefresh()',\n },\n})\nexport class RefreshControl extends ViewBase implements AfterViewChecked {\n /**\n * Whether the spinner shows. Only the app changes it: a pull fires `(refresh)` and leaves this\n * alone, so `[(refreshing)]` and `[refreshing]` behave the same.\n */\n readonly refreshing = model(false);\n /** How far from the top the spinner sits. */\n readonly progressViewOffset = input(undefined, { transform: optionalNumber });\n /** iOS: the spinner's colour. */\n readonly tintColor = input<string>();\n /** iOS: a label under the spinner. */\n readonly title = input<string>();\n /** iOS: the label's colour. */\n readonly titleColor = input<string>();\n /** Android: the colours the spinner cycles through. */\n readonly colors = input<readonly string[]>();\n /** Android: whether pulling does anything. Defaults to true. */\n readonly enabled = input(undefined, { transform: optionalBoolean });\n /** Android: the spinner's background. */\n readonly progressBackgroundColor = input<string>();\n /** Android: the spinner's size. */\n readonly size = input<'default' | 'large'>();\n\n private readonly nativeRefreshing = signal<boolean | null>(null);\n\n private readonly shown = nativePlatform() === 'ios' ? inject(SCREEN_SHOWN) : null;\n protected readonly committedRefreshing = computed(\n () => this.refreshing() && (this.shown?.() ?? true),\n );\n\n /** Android only: what moves this control's node to wrap the scroll view. */\n private readonly wrap =\n nativePlatform() === 'android'\n ? new SwipeRefreshLayout(inject(Engine), this.node as EngineNode)\n : null;\n\n constructor() {\n super();\n const wrap = this.wrap;\n if (wrap) {\n // After every render as well as after this control's own pass: Angular moving the scroll\n // view happens in some other component's pass, and this one's hooks would not see it.\n afterEveryRender(() => wrap.sync());\n inject(DestroyRef).onDestroy(() => wrap.unwrap());\n }\n effect(() => {\n const desired = this.refreshing();\n const native = this.nativeRefreshing();\n if (native !== null && native !== desired) {\n this.nativeRefreshing.set(desired);\n this.engine.dispatchCommand(this.node, 'setNativeRefreshing', [desired]);\n }\n });\n }\n\n /**\n * The scroll view's style is written in the pass that declared this control, so splitting it\n * here reaches native in the same commit.\n */\n ngAfterViewChecked(): void {\n this.wrap?.sync();\n }\n\n /** Native has already started spinning; the app is told and expected to set `refreshing`. */\n protected onNativeRefresh(): void {\n this.nativeRefreshing.set(true);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/components",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "Angular Native's core components: view, text, image, pressable, scroll-view, virtual-list, text-input and the rest of React Native's set.",
5
5
  "keywords": [
6
6
  "angular",
@@ -61,8 +61,8 @@
61
61
  "access": "public"
62
62
  },
63
63
  "dependencies": {
64
- "@ng-native/device": "0.19.1",
65
- "@ng-native/fabric": "0.19.1"
64
+ "@ng-native/device": "0.19.2",
65
+ "@ng-native/fabric": "0.19.2"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@angular/core": "^22.0.0",