@nativescript/angular 21.2.0-alpha.0 → 21.2.0-rc.0

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.
@@ -4,7 +4,7 @@ import * as i0 from '@angular/core';
4
4
  import { InjectionToken, EmbeddedViewRef, ComponentRef, NgModuleRef, ApplicationRef, Provider, EnvironmentProviders, PlatformRef, ɵNgModuleFactory as _NgModuleFactory, Type, CompilerOptions, NgZone, Injector, NgModuleFactory, StaticProvider, Sanitizer, ApplicationConfig as ApplicationConfig$1, ViewContainerRef, ComponentFactoryResolver, TemplateRef, ElementRef, OnInit, OnDestroy, Renderer2, EventEmitter, ChangeDetectorRef, ComponentFactory, AfterViewInit, OnChanges, SimpleChanges, DoCheck, AfterContentInit, IterableDiffer, IterableDiffers, ErrorHandler, RendererStyleFlags2, RendererType2, RendererFactory2, EnvironmentInjector, QueryList, ModuleWithProviders, NgZoneOptions } from '@angular/core';
5
5
  import * as _nativescript_angular from '@nativescript/angular';
6
6
  import * as rxjs from 'rxjs';
7
- import { Observable, ReplaySubject, Subject, BehaviorSubject } from 'rxjs';
7
+ import { Observable, Subject, BehaviorSubject } from 'rxjs';
8
8
  import * as i1 from '@angular/common';
9
9
  import { LocationStrategy, XhrFactory } from '@angular/common';
10
10
  import * as i1$2 from '@angular/router';
@@ -172,17 +172,7 @@ type NgModuleEvent = {
172
172
  reason: NgModuleReason | string;
173
173
  };
174
174
  declare const preAngularDisposal$: Subject<NgModuleEvent>;
175
- /**
176
- * Stream that emits when an Angular module finishes bootstrapping. Modeled
177
- * as a `ReplaySubject(1)` so consumers (e.g. `NativeDialog`) instantiated
178
- * lazily — *after* the bootstrap event has already fired — still receive
179
- * the latest event and can react. Without buffering, a service that the
180
- * user app injects on first need (after bootstrap) would silently miss the
181
- * `hotreload` notification and skip HMR-only work like restoring captured
182
- * modal state. The buffer size of 1 means each new HMR cycle replaces the
183
- * cached event so cycle N's late subscribers don't see cycle N-1's event.
184
- */
185
- declare const postAngularBootstrap$: ReplaySubject<NgModuleEvent>;
175
+ declare const postAngularBootstrap$: Subject<NgModuleEvent>;
186
176
  /**
187
177
  * @deprecated
188
178
  */
@@ -1107,22 +1097,6 @@ declare class NativeDialogConfig<D = any> {
1107
1097
  */
1108
1098
  componentFactoryResolver?: ComponentFactoryResolver;
1109
1099
  nativeOptions?: NativeShowModalOptions;
1110
- /**
1111
- * When true, this dialog will be re-opened automatically on Angular HMR
1112
- * reboots so the user does not lose context every time a related file
1113
- * changes. The new dialog reuses the same component class and `data` payload
1114
- * (provided via `data`); other config such as `nativeOptions` is preserved
1115
- * verbatim.
1116
- *
1117
- * The original `dialogRef.afterClosed()` subject is wired to the restored
1118
- * dialog so consumers `await openModal(...)` resolve normally when the user
1119
- * eventually closes the restored modal.
1120
- *
1121
- * Only opens via component class are restorable — `TemplateRef` openings
1122
- * carry references that don't survive an HMR reboot and are silently
1123
- * skipped. Has no effect outside of HMR.
1124
- */
1125
- preserveOnHmr?: boolean;
1126
1100
  }
1127
1101
 
1128
1102
  declare class FrameService {
@@ -1177,12 +1151,6 @@ declare class NSLocationStrategy extends LocationStrategy implements OnDestroy {
1177
1151
  _modalNavigationDepth: number;
1178
1152
  constructor(frameService: FrameService, startPath?: string);
1179
1153
  getState(): unknown;
1180
- resetForHmr(): {
1181
- outlets: number;
1182
- states: number;
1183
- callbacks: number;
1184
- hadUrlTree: boolean;
1185
- };
1186
1154
  path(): string;
1187
1155
  prepareExternalUrl(internal: string): string;
1188
1156
  pushState(state: any, title: string, url: string, queryParams: string): void;
@@ -1234,16 +1202,6 @@ declare class NativeModalRef {
1234
1202
  portalOutlet: NativeScriptDomPortalOutlet;
1235
1203
  detachedLoaderRef: ComponentRef<DetachedLoader>;
1236
1204
  modalViewRef: NgViewRef<any>;
1237
- /**
1238
- * The actual NativeScript view passed to `parentView.showModal(...)`.
1239
- *
1240
- * For component portals this is the stable `targetView` ContentView
1241
- * wrapper that owns the Angular host PVC. For template portals it
1242
- * remains `modalViewRef.firstNativeLikeView` (the historical
1243
- * behavior). Keeping a direct reference avoids walking parent
1244
- * chains when programmatically closing the modal.
1245
- */
1246
- modalView?: View;
1247
1205
  private _closeCallback;
1248
1206
  private _isDismissed;
1249
1207
  constructor(_config: NativeDialogConfig, _injector: Injector, location?: NSLocationStrategy);
@@ -1332,24 +1290,9 @@ declare const NATIVE_DIALOG_DEFAULT_OPTIONS: InjectionToken<NativeDialogConfig<a
1332
1290
  * for arbitrary dialog refs and dialog container components.
1333
1291
  */
1334
1292
  declare class NativeDialog implements OnDestroy {
1335
- /**
1336
- * Diagnostic instance id. We tag each constructor with a number so
1337
- * the logs make it obvious when a stale `NativeDialog` keeps
1338
- * receiving events after a reboot (e.g. due to a leaked subscription
1339
- * or a service from a previous realm being kept alive).
1340
- */
1341
- private readonly _diagInstanceId;
1342
1293
  private _openDialogsAtThisLevel;
1343
1294
  private readonly _afterAllClosedAtThisLevel;
1344
1295
  private readonly _afterOpenedAtThisLevel;
1345
- /**
1346
- * Maps each open dialog ref back to the `(componentClass, config)` pair it
1347
- * was opened with so the HMR snapshot can replay the call later. Dialogs
1348
- * opened with a `TemplateRef` are tracked with `componentClass: undefined`
1349
- * — the HMR layer skips them automatically.
1350
- */
1351
- private readonly _openDialogMetadata;
1352
- private _hmrSubscriptions;
1353
1296
  /**
1354
1297
  * Stream that emits when all open dialog have finished closing.
1355
1298
  * Will emit on subscribe if there are no open dialogs to begin with.
@@ -1367,8 +1310,6 @@ declare class NativeDialog implements OnDestroy {
1367
1310
  private _nativeModalType;
1368
1311
  private _dialogDataToken;
1369
1312
  private locationStrategy;
1370
- private _diagInstanceIdAssign;
1371
- private _hmrInitMarker;
1372
1313
  /**
1373
1314
  * Opens a modal dialog containing the given component.
1374
1315
  * @param component Type of the component to load into the dialog.
@@ -1394,128 +1335,6 @@ declare class NativeDialog implements OnDestroy {
1394
1335
  */
1395
1336
  getDialogById(id: string): NativeDialogRef<any> | undefined;
1396
1337
  ngOnDestroy(): void;
1397
- /**
1398
- * Tracks whether a restore has already been scheduled for this
1399
- * `NativeDialog` instance's lifetime. We only need to restore once
1400
- * per HMR cycle — the rxjs `ReplaySubject(1)` for
1401
- * `postAngularBootstrap$` delivers both the *previous* cycle's
1402
- * cached event (replay on subscribe) **and** the *current* cycle's
1403
- * fresh event, and the constructor stash peek can independently
1404
- * notice pending work. Without this guard each of those triggers
1405
- * would queue its own `setTimeout` and the logs would show two or
1406
- * three "scheduling restore" lines per save.
1407
- *
1408
- * The guard is per-instance and the stash itself is the source of
1409
- * truth: `_restorePendingDialogs` calls `consumePendingHmrDialogs()`
1410
- * which atomically clears the stash, so even if the guard somehow
1411
- * fired twice, only the first call would do real work.
1412
- */
1413
- private _restoreScheduledForThisInstance;
1414
- /**
1415
- * Wires up HMR capture/restore. Only the root-level dialog manages the
1416
- * stash so a stack of `NativeDialog` instances inside a child injector
1417
- * doesn't fight for it.
1418
- *
1419
- * Production short-circuit: `isAngularHmrEnabled()` returns `false` in
1420
- * release builds and when no NS Vite / webpack HMR runtime is present,
1421
- * so the long-lived subscriptions below never attach in shipping apps.
1422
- *
1423
- * `postAngularBootstrap$` is a `ReplaySubject(1)` (see `application.ts`)
1424
- * which means a `NativeDialog` instantiated *after* the bootstrap event
1425
- * has already fired (typical when the user app injects `NativeDialog`
1426
- * lazily via a service like `view.service.ts`) still receives the
1427
- * buffered event and runs the restore path.
1428
- */
1429
- private _initHmrLifecycle;
1430
- /**
1431
- * Schedule a restore exactly once per `NativeDialog` instance.
1432
- *
1433
- * The work is deferred to the next macrotask for two reasons:
1434
- *
1435
- * 1. `postAngularBootstrap$.next(...)` is fired from inside
1436
- * `emitModuleBootstrapEvent`, which itself runs inside the
1437
- * `bootstrapApplication` callback — so the call stack still
1438
- * contains Angular's ApplicationRef bootstrap pipeline. Doing
1439
- * `this.open(...)` synchronously re-entered Angular DI while a
1440
- * `providedIn: 'root'` factory could still be on the resolution
1441
- * stack, which surfaced as `NG0200: Circular dependency detected
1442
- * for NativeDialog`. Yielding to a macrotask lets the bootstrap
1443
- * stack fully unwind first.
1444
- * 2. The eventual `parent.showModal(...)` cannot present onto a
1445
- * view controller whose view is not yet in the iOS window
1446
- * hierarchy (see `_scheduleRestoreOpenWhenReady` for the second
1447
- * wait stage); a synchronous attempt would silently no-op
1448
- * because iOS rejects the present without throwing.
1449
- */
1450
- private _maybeScheduleRestore;
1451
- private _captureOpenDialogsForHmr;
1452
- /**
1453
- * Per-cycle guard to keep `_restorePendingDialogs` idempotent if more
1454
- * than one subscriber fires for the same bootstrap event. The
1455
- * regression we have seen (`postAngularBootstrap$ → restore` logged
1456
- * twice in the same hot reload) was caused by the `NativeDialogModule`
1457
- * also listing `NativeDialog` in its `providers` array. That has been
1458
- * removed, but we keep this flag as a defensive net so a future stray
1459
- * subscription does not consume the stash twice. The flag is reset
1460
- * after the consume so subsequent HMR cycles can run their own
1461
- * restore.
1462
- */
1463
- private _restoreInFlight;
1464
- private _restorePendingDialogs;
1465
- /**
1466
- * Resolve the freshest known class object for the captured component
1467
- * name and re-open the dialog through the normal `open` path, but
1468
- * only once the new root view is actually attached to the iOS window
1469
- * hierarchy.
1470
- *
1471
- * Why a class lookup at all: an HMR reboot calls
1472
- * `ɵresetCompiledComponents()` which clears each component's `ɵcmp`
1473
- * field but **leaves the class identity unchanged**. The patched
1474
- * `ɵɵdefineComponent` then re-registers the same class object under
1475
- * the same source name when Angular re-renders the component. A
1476
- * fresh-class lookup therefore returns either the same object the
1477
- * stash captured (most common) or, on the rare occasion that the
1478
- * source file's `@Component` decorator was re-evaluated into a brand
1479
- * new class object (e.g. the user added `@Component(...)` to a new
1480
- * exported symbol), the live one. Either way, a single check is
1481
- * enough — the previous retry schedule was a no-op in 100 % of
1482
- * observed cycles because the captured class IS the live class.
1483
- */
1484
- private _restoreSingleDialog;
1485
- /**
1486
- * Maximum time we'll wait for the new root view to attach to the
1487
- * iOS window before giving up and trying the open anyway. NS Vite's
1488
- * worst observed reboot-to-rootview-loaded gap is ~250 ms; one
1489
- * second leaves headroom for slower devices without leaving the
1490
- * captured dialog stuck in the stash if something genuinely goes
1491
- * wrong.
1492
- */
1493
- private static readonly _ROOT_VIEW_LOADED_TIMEOUT_MS;
1494
- /**
1495
- * Defer the actual `this.open(...)` call until the new root view's
1496
- * underlying iOS `UIViewController.view` is in the window hierarchy.
1497
- *
1498
- * iOS silently rejects `presentViewControllerAnimatedCompletion` if
1499
- * the parent controller's view is not yet attached to a `UIWindow`
1500
- * (see `view/index.ios.ts::_showNativeModalView`, which logs to
1501
- * `Trace` and returns without throwing). In dev that would surface
1502
- * as a vanished modal with no actionable error.
1503
- *
1504
- * NS marks a view as `isLoaded === true` from
1505
- * `UILayoutViewController.viewWillAppear`, which fires once iOS has
1506
- * decided to add the view to its window. Listening for the
1507
- * `loadedEvent` (one-shot) plus an extra macrotask gives UIKit a
1508
- * chance to finish window attachment before we present.
1509
- */
1510
- private _scheduleRestoreOpenWhenReady;
1511
- private _pollForRootView;
1512
- private _performRestoreOpen;
1513
- /**
1514
- * Test/debug helper: discard any captured modals without restoring them.
1515
- * Mostly useful when projects want to opt out of restoration without
1516
- * recompiling. Public callers should prefer `preserveOnHmr: false` instead.
1517
- */
1518
- static _clearPendingHmrDialogs(): void;
1519
1338
  /**
1520
1339
  * Attaches the user-provided component to the already-created dialog container.
1521
1340
  * @param componentOrTemplateRef The type of component being loaded into the dialog,
@@ -1571,32 +1390,6 @@ declare class NativeDialogCloseDirective implements OnInit, OnChanges {
1571
1390
  static ɵdir: i0.ɵɵDirectiveDeclaration<NativeDialogCloseDirective, "[native-dialog-close], [nativeDialogClose]", ["nativeDialogClose"], { "dialogResult": { "alias": "native-dialog-close"; "required": false; }; "_matDialogClose": { "alias": "nativeDialogClose"; "required": false; }; }, {}, never, never, true, never>;
1572
1391
  }
1573
1392
 
1574
- /**
1575
- * Convenience module that re-exports the `NativeDialogCloseDirective` for
1576
- * template-driven `[nativeDialogClose]` usage.
1577
- *
1578
- * **Important**: `NativeDialog` itself is **not** listed in this module's
1579
- * `providers` array. The service is `@Injectable({ providedIn: 'root' })`,
1580
- * which already registers a single root-level instance and is fully
1581
- * tree-shakeable. Listing it here as well caused Angular to treat the
1582
- * module-level provider and the `providedIn: 'root'` factory as
1583
- * *separate* registrations once the module was pulled into a standalone
1584
- * app via `importProvidersFrom(NativeDialogModule, ...)`. The duplicate
1585
- * registration triggered:
1586
- *
1587
- * - Two `NativeDialog` instances in the same root environment injector,
1588
- * each subscribing to `postAngularBootstrap$`, which produced
1589
- * duplicate restore attempts during HMR.
1590
- * - `NG0200: Circular dependency detected for NativeDialog` while a
1591
- * captured modal was being re-opened during HMR restore, because the
1592
- * second resolution started while the first was still in progress.
1593
- *
1594
- * Removing the redundant entry collapses both providers back into a
1595
- * single root-level instance, which is what `providedIn: 'root'`
1596
- * documents. App authors who explicitly wire `NativeDialog` themselves
1597
- * (e.g. in a feature module's `providers`) keep working unchanged
1598
- * because they're targeting the same class symbol.
1599
- */
1600
1393
  declare class NativeDialogModule {
1601
1394
  static ɵfac: i0.ɵɵFactoryDeclaration<NativeDialogModule, never>;
1602
1395
  static ɵmod: i0.ɵɵNgModuleDeclaration<NativeDialogModule, never, [typeof NativeDialogCloseDirective], [typeof NativeDialogCloseDirective]>;
@@ -1662,344 +1455,6 @@ declare function generateNativeScriptView<T>(typeOrTemplate: Type<T> | TemplateR
1662
1455
  detachedLoaderRef?: ComponentRef<DetachedLoader>;
1663
1456
  }): NgViewRef<T>;
1664
1457
 
1665
- /**
1666
- * Framework-agnostic Hot-Module-Replacement state cache.
1667
- *
1668
- * The {@link HmrCacheStore} class is intentionally free of any Angular
1669
- * imports so a future `@nativescript/solid` (or any other framework
1670
- * binding) can lift this file as-is and wrap it with its own DI
1671
- * primitive. The Angular DI wrapper lives in
1672
- * `./hmr-cache.service.ts`.
1673
- *
1674
- * # What it does
1675
- *
1676
- * The NativeScript iOS runtime exposes a Vite-spec compliant
1677
- * `import.meta.hot` on every imported module (see
1678
- * `@nativescript/ios` →
1679
- * `runtime/HMRSupport.{h,mm}::InitializeImportMetaHot`). The runtime
1680
- * keeps a per-module persistent `data` object alive in C++ across V8
1681
- * evaluation cycles and canonicalizes the module path so the same
1682
- * bucket survives the URL variations Vite cycles through during a
1683
- * save (HMR boot/live tags, versioned bridge paths, common script
1684
- * extensions). When `@nativescript/vite`'s Angular HMR client calls
1685
- * `globalThis.__nsRunHmrDispose()` before `__reboot_ng_modules__`,
1686
- * every registered `dispose(cb)` fires and is handed the same `data`
1687
- * object the next module evaluation will read from.
1688
- *
1689
- * `HmrCacheStore` rides on top of that primitive:
1690
- *
1691
- * 1. On construction, it copies any previously-stashed entries out
1692
- * of `import.meta.hot.data['ns-hmr-cache']` (or whatever
1693
- * `storageKey` the caller picked) into an in-memory `Map`.
1694
- * 2. It registers a single `import.meta.hot.dispose` callback that
1695
- * writes the in-memory `Map` back as a plain object before the
1696
- * next reboot.
1697
- * 3. Every `set` re-orders the key to the end of the `Map` (LRU);
1698
- * when `size > maxEntries`, the oldest entry is evicted. This
1699
- * stops a long dev session from accumulating unbounded state for
1700
- * features the developer no longer touches.
1701
- * 4. It subscribes to a custom HMR event (default
1702
- * `'ns:cache-invalidate'`) so a Vite plugin or dev server can
1703
- * push targeted cache evictions — e.g. "the OData schema for
1704
- * `/safety/forms` changed, drop anything that depends on it".
1705
- *
1706
- * In production / `--no-hmr` builds `import.meta.hot` is `undefined`,
1707
- * the store collapses to a pure in-memory cache that lives for the
1708
- * lifetime of the process, and the public API is identical so callers
1709
- * never need to special-case build modes.
1710
- *
1711
- * # Why a class and not a plain object
1712
- *
1713
- * Encapsulating the LRU bookkeeping behind named methods (`get`,
1714
- * `set`, `invalidate`, `scope`) lets us evolve the eviction policy
1715
- * (e.g. add TTLs, weighted entries, structured-clone enforcement)
1716
- * without touching every call site. The framework wrappers expose
1717
- * the same surface so app authors learn one API regardless of which
1718
- * framework they use.
1719
- */
1720
- interface HmrCacheStoreOptions {
1721
- /**
1722
- * Maximum number of entries to keep before LRU-evicting the
1723
- * oldest. Set to `0` (or any non-positive number) for unlimited.
1724
- * Default: `256`.
1725
- *
1726
- * Sized for the empirical "depth of features a developer touches in
1727
- * one dev session" — large enough that a working set of ~30 pages,
1728
- * each with a handful of cached fields, never trips eviction during
1729
- * normal hacking; small enough that a runaway producer (e.g. a
1730
- * scroll-driven loop that mints new keys) gets capped instead of
1731
- * leaking memory until the simulator OOMs.
1732
- */
1733
- maxEntries?: number;
1734
- /**
1735
- * Key under which the cache is stashed on `import.meta.hot.data`.
1736
- * Apps that run multiple isolated cache stores (e.g. a feature-
1737
- * isolation plugin) can pick distinct keys to keep their state
1738
- * separate. Default: `'ns-hmr-cache'`.
1739
- */
1740
- storageKey?: string;
1741
- /**
1742
- * Custom HMR event name the store listens for. Payload schema:
1743
- *
1744
- * ```ts
1745
- * { key?: string }
1746
- * ```
1747
- *
1748
- * If `key` is provided, only that entry is dropped. If omitted, the
1749
- * entire cache is cleared. A Vite plugin sends events via the dev
1750
- * server's WebSocket (Vite spec
1751
- * [`server.ws.send`](https://vite.dev/guide/api-plugin.html#server-ws-send-and-server-ws-on));
1752
- * the runtime's `__NS_DISPATCH_HOT_EVENT__` then forwards them to
1753
- * every `import.meta.hot.on` listener. Default:
1754
- * `'ns:cache-invalidate'`.
1755
- */
1756
- invalidateEventName?: string;
1757
- /**
1758
- * Optional logger for diagnostic output. The store calls this with
1759
- * a single string per significant event (rehydrate, dispose, LRU
1760
- * evict, server-side invalidate). Default: no-op.
1761
- */
1762
- log?: (message: string) => void;
1763
- }
1764
- /**
1765
- * A namespaced view of an {@link HmrCacheStore}. Keys are
1766
- * automatically prefixed with `<scope>:`, so callers don't have to
1767
- * negotiate global key names. Returned by {@link HmrCacheStore.scope}.
1768
- */
1769
- interface HmrCacheScope {
1770
- readonly prefix: string;
1771
- get<T>(key: string): T | undefined;
1772
- set<T>(key: string, value: T): void;
1773
- has(key: string): boolean;
1774
- delete(key: string): void;
1775
- /** Drop every entry whose key starts with this scope's prefix. */
1776
- clear(): void;
1777
- /** Number of entries owned by this scope. */
1778
- size(): number;
1779
- }
1780
- declare class HmrCacheStore {
1781
- private readonly _map;
1782
- private readonly _maxEntries;
1783
- private readonly _log;
1784
- /**
1785
- * @param initialEntries Entries to seed the store with (typically
1786
- * the previous session's snapshot read from
1787
- * `import.meta.hot.data`).
1788
- * @param options See {@link HmrCacheStoreOptions}.
1789
- */
1790
- constructor(initialEntries?: Iterable<[string, unknown]>, options?: HmrCacheStoreOptions);
1791
- get<T>(key: string): T | undefined;
1792
- set<T>(key: string, value: T): void;
1793
- has(key: string): boolean;
1794
- delete(key: string): void;
1795
- /**
1796
- * Drop a specific entry, or every entry when `key` is omitted.
1797
- * Equivalent to {@link delete} (with key) or {@link clear} (without)
1798
- * — exposed as a single method so callers and event handlers can
1799
- * forward an optional key without branching.
1800
- */
1801
- invalidate(key?: string): void;
1802
- /** Drop every cached entry. */
1803
- clear(): void;
1804
- /** Total number of cached entries across all scopes. */
1805
- size(): number;
1806
- /** Snapshot of every key currently in the cache. */
1807
- keys(): string[];
1808
- /**
1809
- * Returns a namespaced view of this store. All keys passed to the
1810
- * returned object are auto-prefixed with `<prefix>:`. Useful so
1811
- * each feature module can avoid stomping on neighbours' keys
1812
- * without repeating the prefix at every call site.
1813
- *
1814
- * @example
1815
- * ```ts
1816
- * const cache = createDefaultHmrCacheStore();
1817
- * const submissions = cache.scope('page-my-submissions');
1818
- * submissions.set('items', [...]); // stored under 'page-my-submissions:items'
1819
- * ```
1820
- */
1821
- scope(prefix: string): HmrCacheScope;
1822
- /**
1823
- * Serialize every entry into a plain object suitable for stashing
1824
- * on `import.meta.hot.data`. Used by the dispose callback in
1825
- * {@link createDefaultHmrCacheStore} and re-exported for callers
1826
- * that want to integrate with another persistence layer (e.g. a
1827
- * test harness that snapshots between cases).
1828
- */
1829
- toObject(): Record<string, unknown>;
1830
- private _enforceMaxEntries;
1831
- }
1832
- /**
1833
- * Build an {@link HmrCacheStore} bound to the current module's
1834
- * `import.meta.hot` context — i.e. the store's data survives HMR
1835
- * reboots and listens for the `'ns:cache-invalidate'` custom event.
1836
- *
1837
- * Caller responsibility: invoke this from the module that "owns" the
1838
- * cache. `import.meta` is per-module, so the dispose callback will be
1839
- * registered against whichever module physically calls this function.
1840
- * In `@nativescript/angular` the canonical owner is
1841
- * `hmr-cache.service.ts`; in `@nativescript/solid` it would be the
1842
- * equivalent solid-side module.
1843
- *
1844
- * Returns a freshly-constructed store. Callers should treat it as a
1845
- * singleton — calling this twice from the same module yields two
1846
- * independent stores, which is almost never what you want.
1847
- */
1848
- declare function createDefaultHmrCacheStore(options?: HmrCacheStoreOptions): HmrCacheStore;
1849
-
1850
- /**
1851
- * Skip the API call your component already paid for last save.
1852
- *
1853
- * Inject {@link HmrCacheService} from any Angular component or service
1854
- * to read and write a per-app key/value cache that **survives the
1855
- * `__reboot_ng_modules__` cycle** triggered by every HMR file save.
1856
- * Backed by `@nativescript/ios`'s native `import.meta.hot.data`
1857
- * (`runtime/HMRSupport.{h,mm}`) and drained via
1858
- * `@nativescript/vite`'s `globalThis.__nsRunHmrDispose()` hook before
1859
- * Angular tears down its realm, so the same value the previous
1860
- * component instance produced is handed straight to the freshly-
1861
- * instantiated one — no network round-trip, no spinner flash.
1862
- *
1863
- * In production / `--no-hmr` builds `import.meta.hot` is `undefined`
1864
- * and the cache collapses to a plain in-memory object that lives for
1865
- * the lifetime of the process. The public API is identical, so callers
1866
- * never need to special-case build modes.
1867
- *
1868
- * @example Skip the initial fetch on save
1869
- * ```ts
1870
- * import { HmrCacheService } from '@nativescript/angular';
1871
- *
1872
- * @Component({...})
1873
- * export class MyComponent implements OnInit {
1874
- * private hmrCache = inject(HmrCacheService);
1875
- *
1876
- * ngOnInit() {
1877
- * const cached = this.hmrCache.get<MyResult>('my-feature:items');
1878
- * if (cached) {
1879
- * this.applyResult(cached);
1880
- * return;
1881
- * }
1882
- * this.api.load().subscribe((result) => {
1883
- * this.hmrCache.set('my-feature:items', result);
1884
- * this.applyResult(result);
1885
- * });
1886
- * }
1887
- * }
1888
- * ```
1889
- *
1890
- * @example Namespaced via {@link scope}
1891
- * ```ts
1892
- * private cache = inject(HmrCacheService).scope('page-my-submissions');
1893
- * // …
1894
- * this.cache.set('items', items); // → 'page-my-submissions:items'
1895
- * this.cache.get('items'); // ← 'page-my-submissions:items'
1896
- * ```
1897
- *
1898
- * @example Server-side invalidation from a Vite plugin
1899
- * ```ts
1900
- * // vite.config.ts
1901
- * export default defineConfig({
1902
- * plugins: [
1903
- * {
1904
- * name: 'my-schema-watcher',
1905
- * configureServer(server) {
1906
- * server.watcher.on('change', (path) => {
1907
- * if (path.endsWith('schema.json')) {
1908
- * server.ws.send({
1909
- * type: 'custom',
1910
- * event: 'ns:cache-invalidate',
1911
- * data: { key: 'my-feature:items' },
1912
- * });
1913
- * }
1914
- * });
1915
- * },
1916
- * },
1917
- * ],
1918
- * });
1919
- * ```
1920
- *
1921
- * Memory ceiling: the cache LRU-evicts at 256 entries by default. Pass
1922
- * a custom ceiling via {@link configureHmrCache} if your app churns
1923
- * through more keys than that in a typical dev session, or set `0` for
1924
- * unlimited (unbounded growth — only safe for short-lived dev work).
1925
- *
1926
- * @see HmrCacheStore — the framework-agnostic engine. Stable enough to
1927
- * lift into `@nativescript/solid` / other framework bindings without
1928
- * modification.
1929
- */
1930
- declare class HmrCacheService {
1931
- private readonly _store;
1932
- /**
1933
- * `true` when `import.meta.hot` is wired (i.e. NativeScript Vite HMR
1934
- * is active and `@nativescript/ios` is recent enough to expose
1935
- * `import.meta.hot.data`). `false` in production / `--no-hmr` /
1936
- * legacy webpack builds.
1937
- *
1938
- * Most callers should NOT branch on this — the public API works
1939
- * identically in both cases. Use it only when you want to opt OUT
1940
- * of caching in production (e.g. always fetch fresh data when not
1941
- * developing).
1942
- */
1943
- readonly isHmr: boolean;
1944
- get<T>(key: string): T | undefined;
1945
- set<T>(key: string, value: T): void;
1946
- has(key: string): boolean;
1947
- delete(key: string): void;
1948
- /**
1949
- * Drop a single entry, or every entry when `key` is omitted. Same
1950
- * shape as the `'ns:cache-invalidate'` HMR-event payload the store
1951
- * listens for, so application code can call this directly to mirror
1952
- * a server-side eviction.
1953
- */
1954
- invalidate(key?: string): void;
1955
- /** Drop every cached entry. Equivalent to `invalidate()` with no key. */
1956
- clear(): void;
1957
- /** Total number of entries across every scope. */
1958
- size(): number;
1959
- /** Snapshot of every key currently cached. Useful for debug overlays. */
1960
- keys(): string[];
1961
- /**
1962
- * Returns a namespaced view of the cache. All `get` / `set` /
1963
- * `has` / `delete` calls on the returned object are auto-prefixed
1964
- * with `<scopeName>:`. Recommended over global keys so feature
1965
- * modules don't accidentally collide.
1966
- *
1967
- * @example
1968
- * ```ts
1969
- * private cache = inject(HmrCacheService).scope('page-my-submissions');
1970
- * // …
1971
- * this.cache.set('items', items); // → 'page-my-submissions:items'
1972
- * ```
1973
- */
1974
- scope(scopeName: string): HmrCacheScope;
1975
- static ɵfac: i0.ɵɵFactoryDeclaration<HmrCacheService, never>;
1976
- static ɵprov: i0.ɵɵInjectableDeclaration<HmrCacheService>;
1977
- }
1978
- /**
1979
- * Override the default cache configuration. Must be called BEFORE the
1980
- * first injection of {@link HmrCacheService} (i.e. before Angular
1981
- * bootstrap, or as the very first statement in `main.ts`); otherwise
1982
- * the call is a no-op because the singleton store has already been
1983
- * built with the previous (or default) options.
1984
- *
1985
- * Typical use case: bumping `maxEntries` for a large multi-feature
1986
- * monorepo dev session, or pointing a custom `invalidateEventName` at
1987
- * a Vite plugin that prefixes its events with the project name.
1988
- *
1989
- * Returns `true` if the configuration was applied, `false` if the
1990
- * store had already been instantiated by an earlier injection.
1991
- */
1992
- declare function configureHmrCache(options: HmrCacheStoreOptions): boolean;
1993
- /**
1994
- * Read-only access to the underlying {@link HmrCacheStore}. Exposed
1995
- * for advanced integrations that want to reuse the LRU + dispose +
1996
- * server-side-invalidate plumbing without going through Angular's
1997
- * dependency injection (e.g. a non-component utility that's loaded
1998
- * before the Angular platform has bootstrapped). Application code
1999
- * should prefer {@link HmrCacheService}.
2000
- */
2001
- declare function getHmrCacheStore(): HmrCacheStore;
2002
-
2003
1458
  declare function registerNativeScriptViewComponents(): void;
2004
1459
 
2005
1460
  type ViewResolver = () => any;
@@ -2376,7 +1831,7 @@ declare class ModalDialogService {
2376
1831
  * and reattaches them on back.
2377
1832
  * Reuses routes as long as their route config is the same.
2378
1833
  */
2379
- declare class NSRouteReuseStrategy implements RouteReuseStrategy, OnDestroy {
1834
+ declare class NSRouteReuseStrategy implements RouteReuseStrategy {
2380
1835
  private location;
2381
1836
  private cacheByOutlet;
2382
1837
  constructor(location: NSLocationStrategy);
@@ -2395,8 +1850,6 @@ declare class NSRouteReuseStrategy implements RouteReuseStrategy, OnDestroy {
2395
1850
  markCacheForPop(outletKey: string): void;
2396
1851
  clearMarkedCache(outletKey: string): void;
2397
1852
  clearModalCache(outletKey: string): void;
2398
- clearAllCaches(): number;
2399
- ngOnDestroy(): void;
2400
1853
  static ɵfac: i0.ɵɵFactoryDeclaration<NSRouteReuseStrategy, never>;
2401
1854
  static ɵprov: i0.ɵɵInjectableDeclaration<NSRouteReuseStrategy>;
2402
1855
  }
@@ -2846,35 +2299,6 @@ declare class NativeScriptRouterModule {
2846
2299
  declare function rootRoute(router: Router): ActivatedRoute;
2847
2300
  declare function provideNativeScriptRouter(routes: Routes, ...features: RouterFeatures[]): i0.EnvironmentProviders;
2848
2301
 
2849
- /**
2850
- * True while the Angular HMR layer is restoring a captured route stack
2851
- * onto the freshly-bootstrapped router. The window opens just before
2852
- * `START_PATH` resolves to a deep URL and closes once the router has
2853
- * walked the entire forward navigation list (or aborted it).
2854
- *
2855
- * User-app code that runs default navigations on component init (e.g. a
2856
- * bottom-nav defaulting to its first tab) can consult this flag to skip
2857
- * its default navigation so the framework's restored route survives:
2858
- *
2859
- * ```ts
2860
- * if (isAngularHmrRestoringRoute()) {
2861
- * return; // framework is restoring a deeper route — leave it alone.
2862
- * }
2863
- * defaultTabNavigation();
2864
- * ```
2865
- *
2866
- * Returns `false` outside of HMR or after the replay window has closed.
2867
- * Production builds always see `false` because the framework never
2868
- * opens the window there.
2869
- */
2870
- declare function isAngularHmrRestoringRoute(): boolean;
2871
- /**
2872
- * The target route the framework is currently restoring, or `null` when
2873
- * no replay is in progress. Useful when the consumer wants to compare
2874
- * against the current router URL.
2875
- */
2876
- declare function getAngularHmrRestoringRoute(): string | null;
2877
-
2878
2302
  declare class NativeScriptDebug {
2879
2303
  static readonly animationsTraceCategory = "ns-animations";
2880
2304
  static readonly rendererTraceCategory = "ns-renderer";
@@ -2883,7 +2307,6 @@ declare class NativeScriptDebug {
2883
2307
  static readonly routeReuseStrategyTraceCategory = "ns-route-reuse-strategy";
2884
2308
  static readonly listViewTraceCategory = "ns-list-view";
2885
2309
  static readonly bootstrapCategory = "bootstrap";
2886
- static readonly hmrTraceCategory = "ns-ng-hmr";
2887
2310
  static readonly enabled: boolean;
2888
2311
  static isLogEnabled(): boolean;
2889
2312
  static animationsLog(message: string): void;
@@ -2898,8 +2321,6 @@ declare class NativeScriptDebug {
2898
2321
  static listViewError(message: string): void;
2899
2322
  static bootstrapLog(message: string): void;
2900
2323
  static bootstrapLogError(message: string): void;
2901
- static hmrLog(message: string): void;
2902
- static hmrLogError(message: string): void;
2903
2324
  }
2904
2325
 
2905
2326
  /**
@@ -3059,5 +2480,5 @@ declare class NativeScriptNgZone implements NgZone {
3059
2480
  }
3060
2481
  declare function provideNativeScriptNgZone(options?: NgZoneOptions): i0.StaticProvider[];
3061
2482
 
3062
- export { APP_ROOT_VIEW, ActionBarComponent, ActionBarScope, ActionItemDirective, AndroidFilterComponent, AppHostAsyncView, AppHostView, AppleFilterComponent, BasePortalOutlet, BaseValueAccessor, COMMON_PROVIDERS, CdkPortal, CdkPortalOutlet, CheckedValueAccessor, CommentNode, ComponentPortal, DEVICE, DISABLE_ROOT_VIEW_HANDLING, DateValueAccessor, DetachedLoader, DomPortal, ENABLE_REUSABE_VIEWS, EmulatedRenderer, FrameDirective, FramePageComponent, FramePageModule, FrameService, HmrCacheService, HmrCacheStore, IOSFilterComponent, InjectableAnimationEngine, InvisibleNode, ItemContext, ListViewComponent, ModalDialogParams, ModalDialogService, NAMESPACE_FILTERS, NATIVESCRIPT_MODULE_PROVIDERS, NATIVESCRIPT_MODULE_STATIC_PROVIDERS, NATIVESCRIPT_ROOT_MODULE_ID, NATIVE_DIALOG_DATA, NATIVE_DIALOG_DEFAULT_OPTIONS, NSEmptyOutletComponent, NSFileSystem, NSLocationStrategy, NSRouteReuseStrategy, NSRouterLink, NSRouterLinkActive, NativeDialog, NativeDialogCloseDirective, NativeDialogConfig, NativeDialogModule, NativeDialogRef, NativeDialog as NativeDialogService, NativeDialogState, NativeModalRef, NativeScriptAnimationDriver, NativeScriptAnimationPlayer, NativeScriptAnimationsModule, NativeScriptCommonModule, NativeScriptDocument, NativeScriptDomPortalOutlet, NativeScriptFormsModule, NativeScriptHttpClientModule, NativeScriptLoadingService, NativeScriptModule, NativeScriptNgSafeEvent, NativeScriptNgZone, NativeScriptRendererFactory, NativeScriptRendererHelperService, NativeScriptRouterModule, NativeScriptSanitizer, NativescriptXhrFactory, NavigationButtonDirective, NgViewRef, NsHttpBackEnd, NsTemplatedItem, NumberValueAccessor, Outlet, PAGE_FACTORY, PREVENT_CHANGE_EVENTS_DURING_CD, PREVENT_SPECIFIC_EVENTS_DURING_CD, PageDirective, PageRoute, PageRouterOutlet, PageService, PlatformNamespaceFilter, Portal, PortalModule, RootCompositeModule, RootViewProxy, RouterExtensions, START_PATH, SelectedIndexValueAccessor, TEMPLATED_ITEMS_COMPONENT, TabViewDirective, TabViewItemDirective, TemplateKeyDirective, TemplatePortal, TextNode, TextValueAccessor, TimeValueAccessor, VisionOSFilterComponent, bootstrapApplication, configureHmrCache, createApplication, createDefaultHmrCacheStore, createKeyframeAnimation, customFrameComponentFactory, customFrameDirectiveFactory, customPageFactory, customPageFactoryFromFrame, dashCaseToCamelCase, defaultNavOptions, defaultPageFactory, defaultPageFactoryProvider, detachViewFromParent, disableRootViewHanding, errorHandler, extractSingleViewRecursive, frameMeta, generateDetachedLoader, generateFallbackRootView, generateNativeScriptView, generateRandomId, generateRootLayoutAndProxy, getAngularHmrRestoringRoute, getFirstNativeLikeView, getHmrCacheStore, getItemViewRoot, getSingleViewRecursive, getViewClass, getViewMeta, instantiateDefaultStyleNormalizer, instantiateSupportedAnimationDriver, isAngularHmrRestoringRoute, isBlank, isContentView, isDetachedElement, isInvisibleNode, isJsObject, isKnownView, isLayout, isListLikeIterable, isPresent, isView, onAfterLivesync, onBeforeLivesync, once, platformNativeScript, platformNativeScriptDynamic, postAngularBootstrap$, preAngularDisposal$, provideComponentInputBinding, provideLocationStrategy, provideNativeScriptHttpClient, provideNativeScriptNgZone, provideNativeScriptRouter, registerElement, registerNativeScriptViewComponents, rootRoute, runNativeScriptAngularApp, throwIfAlreadyLoaded, throwNoPortalAttachedError, throwNullPortalError, throwNullPortalOutletError, throwPortalAlreadyAttachedError, throwPortalOutletAlreadyDisposedError, throwUnknownPortalTypeError, COMPONENT_VARIABLE as ɵCOMPONENT_VARIABLE, CONTENT_ATTR as ɵCONTENT_ATTR, HOST_ATTR as ɵHOST_ATTR, NativeScriptDebug as ɵNativeScriptAngularDebug, viewUtil_d as ɵViewUtil, actionBarMeta as ɵactionBarMeta, elementMap as ɵelementMap, isActionItem as ɵisActionItem, isNavigationButton as ɵisNavigationButton };
3063
- export type { AppLaunchView, AppOptions, AppRunOptions, ApplicationConfig, BaseShowModalOptions, BootstrapContext, CdkPortalOutletAttachedRef, ComponentInputBindingOptions, ComponentType, HmrCacheScope, HmrCacheStoreOptions, HmrOptions, Keyframe, LocationState, ModalDialogOptions, NamespaceFilter, NativeShowModalOptions, NavigationOptions, NgModuleEvent, NgModuleReason, NgView, NgViewTemplate, PageFactory, PageFactoryOptions, PortalOutlet, RootLocator, SelectableView, SetupItemViewArgs, ShowDialogOptions, TabViewItemDef, TemplatedItemsHost, TextView, ViewClass, ViewClassMeta, ViewExtensions, ViewResolver };
2483
+ export { APP_ROOT_VIEW, ActionBarComponent, ActionBarScope, ActionItemDirective, AndroidFilterComponent, AppHostAsyncView, AppHostView, AppleFilterComponent, BasePortalOutlet, BaseValueAccessor, COMMON_PROVIDERS, CdkPortal, CdkPortalOutlet, CheckedValueAccessor, CommentNode, ComponentPortal, DEVICE, DISABLE_ROOT_VIEW_HANDLING, DateValueAccessor, DetachedLoader, DomPortal, ENABLE_REUSABE_VIEWS, EmulatedRenderer, FrameDirective, FramePageComponent, FramePageModule, FrameService, IOSFilterComponent, InjectableAnimationEngine, InvisibleNode, ItemContext, ListViewComponent, ModalDialogParams, ModalDialogService, NAMESPACE_FILTERS, NATIVESCRIPT_MODULE_PROVIDERS, NATIVESCRIPT_MODULE_STATIC_PROVIDERS, NATIVESCRIPT_ROOT_MODULE_ID, NATIVE_DIALOG_DATA, NATIVE_DIALOG_DEFAULT_OPTIONS, NSEmptyOutletComponent, NSFileSystem, NSLocationStrategy, NSRouteReuseStrategy, NSRouterLink, NSRouterLinkActive, NativeDialog, NativeDialogCloseDirective, NativeDialogConfig, NativeDialogModule, NativeDialogRef, NativeDialog as NativeDialogService, NativeDialogState, NativeModalRef, NativeScriptAnimationDriver, NativeScriptAnimationPlayer, NativeScriptAnimationsModule, NativeScriptCommonModule, NativeScriptDocument, NativeScriptDomPortalOutlet, NativeScriptFormsModule, NativeScriptHttpClientModule, NativeScriptLoadingService, NativeScriptModule, NativeScriptNgSafeEvent, NativeScriptNgZone, NativeScriptRendererFactory, NativeScriptRendererHelperService, NativeScriptRouterModule, NativeScriptSanitizer, NativescriptXhrFactory, NavigationButtonDirective, NgViewRef, NsHttpBackEnd, NsTemplatedItem, NumberValueAccessor, Outlet, PAGE_FACTORY, PREVENT_CHANGE_EVENTS_DURING_CD, PREVENT_SPECIFIC_EVENTS_DURING_CD, PageDirective, PageRoute, PageRouterOutlet, PageService, PlatformNamespaceFilter, Portal, PortalModule, RootCompositeModule, RootViewProxy, RouterExtensions, START_PATH, SelectedIndexValueAccessor, TEMPLATED_ITEMS_COMPONENT, TabViewDirective, TabViewItemDirective, TemplateKeyDirective, TemplatePortal, TextNode, TextValueAccessor, TimeValueAccessor, VisionOSFilterComponent, bootstrapApplication, createApplication, createKeyframeAnimation, customFrameComponentFactory, customFrameDirectiveFactory, customPageFactory, customPageFactoryFromFrame, dashCaseToCamelCase, defaultNavOptions, defaultPageFactory, defaultPageFactoryProvider, detachViewFromParent, disableRootViewHanding, errorHandler, extractSingleViewRecursive, frameMeta, generateDetachedLoader, generateFallbackRootView, generateNativeScriptView, generateRandomId, generateRootLayoutAndProxy, getFirstNativeLikeView, getItemViewRoot, getSingleViewRecursive, getViewClass, getViewMeta, instantiateDefaultStyleNormalizer, instantiateSupportedAnimationDriver, isBlank, isContentView, isDetachedElement, isInvisibleNode, isJsObject, isKnownView, isLayout, isListLikeIterable, isPresent, isView, onAfterLivesync, onBeforeLivesync, once, platformNativeScript, platformNativeScriptDynamic, postAngularBootstrap$, preAngularDisposal$, provideComponentInputBinding, provideLocationStrategy, provideNativeScriptHttpClient, provideNativeScriptNgZone, provideNativeScriptRouter, registerElement, registerNativeScriptViewComponents, rootRoute, runNativeScriptAngularApp, throwIfAlreadyLoaded, throwNoPortalAttachedError, throwNullPortalError, throwNullPortalOutletError, throwPortalAlreadyAttachedError, throwPortalOutletAlreadyDisposedError, throwUnknownPortalTypeError, COMPONENT_VARIABLE as ɵCOMPONENT_VARIABLE, CONTENT_ATTR as ɵCONTENT_ATTR, HOST_ATTR as ɵHOST_ATTR, NativeScriptDebug as ɵNativeScriptAngularDebug, viewUtil_d as ɵViewUtil, actionBarMeta as ɵactionBarMeta, elementMap as ɵelementMap, isActionItem as ɵisActionItem, isNavigationButton as ɵisNavigationButton };
2484
+ export type { AppLaunchView, AppOptions, AppRunOptions, ApplicationConfig, BaseShowModalOptions, BootstrapContext, CdkPortalOutletAttachedRef, ComponentInputBindingOptions, ComponentType, HmrOptions, Keyframe, LocationState, ModalDialogOptions, NamespaceFilter, NativeShowModalOptions, NavigationOptions, NgModuleEvent, NgModuleReason, NgView, NgViewTemplate, PageFactory, PageFactoryOptions, PortalOutlet, RootLocator, SelectableView, SetupItemViewArgs, ShowDialogOptions, TabViewItemDef, TemplatedItemsHost, TextView, ViewClass, ViewClassMeta, ViewExtensions, ViewResolver };