@ng-native/device 0.14.0 → 0.16.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.
package/README.md CHANGED
@@ -38,8 +38,8 @@ setup, and one nobody injects is never constructed.
38
38
  - `Screen`, `SafeArea` - the window, the physical display, orientation and safe-area insets.
39
39
  - `ColorScheme`, `Accessibility`, `Direction` - light or dark, screen reader and reduced-motion
40
40
  state, and text direction.
41
- - `StatusBar`, `Keyboard`, `HardwareBack`, `AppState`, `DeepLinks`, `AndroidPermissions`,
42
- `LayoutAnimation` - the rest of the system surfaces a screen reads from.
41
+ - `StatusBar`, `NavigationBar`, `Keyboard`, `HardwareBack`, `AppState`, `DeepLinks`,
42
+ `AndroidPermissions`, `LayoutAnimation` - the rest of the system surfaces a screen reads from.
43
43
  - `Dialogs`, `Sharing`, `Vibration` - the platform's own alert, share sheet and vibration motor.
44
44
  - `DevMenu` - switches in the shake menu, gone in a release build.
45
45
 
@@ -11,6 +11,10 @@ export interface DeepLinkSource {
11
11
  /** Optional, so a source written before there was one is still a source. */
12
12
  openSettings?(): void;
13
13
  }
14
+ /**
15
+ * React Native's `Linking`, with each url whole: the scheme, host, query and fragment that
16
+ * `DeepLinks` strips to a path. Off a device, a source that never delivers a link.
17
+ */
14
18
  export declare function deepLinkSource(): DeepLinkSource;
15
19
  export declare function pathOf(url: string | null): string | null;
16
20
  /**
@@ -4,6 +4,10 @@
4
4
  import { ErrorHandler, InjectionToken, Injector, Service, inject } from '@angular/core';
5
5
  import { reactNative } from "./react-native.js";
6
6
  import * as i0 from "@angular/core";
7
+ /**
8
+ * React Native's `Linking`, with each url whole: the scheme, host, query and fragment that
9
+ * `DeepLinks` strips to a path. Off a device, a source that never delivers a link.
10
+ */
7
11
  export function deepLinkSource() {
8
12
  const native = reactNative();
9
13
  if (!native) {
@@ -1 +1 @@
1
- {"version":3,"file":"deep-links.js","sourceRoot":"","sources":["../src/deep-links.ts"],"names":[],"mappings":"AAAA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AAC,CAAC;YAC5B,CAAC;YAAC,OAAO,SAAS,EAAE,CAAC;gBACnB,IAAI,SAAS,KAAK,KAAK;oBAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;oBACzC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,0FAA0F;IAC1F,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;IAC/B,CAAC;uGAxEU,SAAS;wGAAT,SAAS;;2FAAT,SAAS;kBADrB,OAAO","sourcesContent":["/**\n * Links that arrive from outside the app: a `canary://` url, a universal link, a notification.\n */\nimport { ErrorHandler, InjectionToken, Injector, Service, inject } from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport interface DeepLinkSource {\n /** The url the app was launched with. A promise, and nothing says it settles before mount. */\n launchUrl(): Promise<string | null>;\n subscribe(listener: (url: string) => void): () => void;\n open(url: string): void;\n /** Optional, so a source written before there was one is still a source. */\n openSettings?(): void;\n}\n\nexport function deepLinkSource(): DeepLinkSource {\n const native = reactNative();\n if (!native) {\n return {\n launchUrl: () => Promise.resolve(null),\n subscribe: () => () => {},\n open: () => {},\n openSettings: () => {},\n };\n }\n\n return {\n launchUrl: () => native.Linking.getInitialURL(),\n subscribe: (listener) => {\n const subscription = native.Linking.addEventListener('url', ({ url }) => listener(url));\n return () => subscription.remove();\n },\n open: (url) => void native.Linking.openURL(url).catch(() => {}),\n openSettings: () => void native.Linking.openSettings().catch(() => {}),\n };\n}\n\n/**\n * The path a url means to this app: everything after the scheme and host.\n *\n * Prefixes are app configuration and every app's are different, but stripping one is not: what a\n * router can navigate to is a path. `canary://primitives` and `https://example.com/primitives`\n * both mean `/primitives` - which takes noticing that only the second one has a host.\n *\n * Expo Go is the exception worth handling here rather than in every app: it serves every project\n * from one development url, puts the app's own path after `/--`, and has a host like a web url\n * rather than a path like an app's own scheme.\n *\n * The development client is the other. `expo run:ios` launches the app through\n * `<scheme>://expo-development-client/?url=...`, which is Expo telling its own launcher which\n * bundle to load and means nothing to the app. Left alone it reaches the router as a path, matches\n * no route, and the app shows a blank screen on every launch during development - which looks\n * exactly like a bug in the app.\n */\n\n/** Expo's own launch hosts. Not paths: instructions to the launcher, which the app never routes. */\nconst EXPO_INTERNAL = new Set(['expo-development-client']);\n\n/** Whether the first segment names one of Expo's launchers rather than something in the app. */\nfunction isLauncher(rest: string): boolean {\n return EXPO_INTERNAL.has(rest.split(/[/?#]/, 1)[0] ?? '');\n}\n\n/** Schemes that carry a host to skip before the path starts. */\nconst HAS_HOST = new Set(['http', 'https', 'exp', 'exps']);\n\n/**\n * The app's path after Expo Go's `/--/`, or null for a url with none in its path. In a query or a\n * fragment, `/--/` is the app's own: a search for it is not a launch prefix.\n */\nfunction expoGoPath(rest: string): string | null {\n const end = rest.search(/[?#]/);\n const marker = (end === -1 ? rest : rest.slice(0, end)).indexOf('/--/');\n return marker === -1 ? null : rest.slice(marker + 3);\n}\n\nexport function pathOf(url: string | null): string | null {\n if (!url) return null;\n const scheme = /^([a-z][a-z0-9+.-]*):\\/\\//i.exec(url);\n const rest = scheme ? url.slice(scheme[0].length) : url;\n\n const expoGo = expoGoPath(rest);\n if (expoGo !== null) return expoGo;\n if (isLauncher(rest)) return null;\n\n // A url with a host has one to skip. A custom scheme does not: `canary://settings` names a\n // path, not a machine, and treating the two alike is how it quietly becomes `/`.\n if (HAS_HOST.has(scheme?.[1]?.toLowerCase() ?? '')) {\n // The host ends at the path, or at a query or fragment when there is no path.\n const end = rest.search(/[/?#]/);\n if (end === -1) return '/';\n return rest[end] === '/' ? rest.slice(end) : `/${rest.slice(end)}`;\n }\n return rest.startsWith('/') ? rest : `/${rest}`;\n}\n\n/**\n * The launch url is delivered whichever way is true at the time: as the initial url if it is\n * known before anything asks, and as an ordinary link if the app is already up. Both happen -\n * the promise races the first navigation and neither order is guaranteed - and a link that\n * arrives late is still a link, so nothing is dropped either way.\n */\n@Service()\nexport class DeepLinks {\n /** Overridden in a test to deliver a link with no platform under it. */\n static readonly SOURCE = new InjectionToken<DeepLinkSource>('angular-native.deepLinkSource', {\n factory: deepLinkSource,\n });\n\n private readonly source = inject(DeepLinks.SOURCE);\n private readonly injector = inject(Injector);\n private launch: string | null = null;\n private readonly listeners = new Set<(path: string) => void>();\n\n constructor() {\n void this.source.launchUrl().then((url) => {\n const path = pathOf(url);\n if (!path || path === '/') return;\n if (this.listeners.size) this.listeners.forEach((listener) => this.deliver(listener, path));\n else this.launch = path;\n });\n }\n\n /** The path the app was launched with, if it is known yet. */\n initialUrl(): string | null {\n return this.launch;\n }\n\n /** Links that arrive while the app is running, as paths. Returns an unsubscribe. */\n subscribe(listener: (path: string) => void): () => void {\n // Each subscription is its own entry, so the same function subscribed twice stops once.\n const subscription = (path: string) => listener(path);\n this.listeners.add(subscription);\n const unsubscribe = this.source.subscribe((url) => {\n const path = pathOf(url);\n if (path) listener(path);\n });\n return () => {\n this.listeners.delete(subscription);\n unsubscribe();\n };\n }\n\n /**\n * One listener throwing is reported, and does not keep the launch url from the rest. The\n * `ErrorHandler` is looked up when that happens rather than when this is made: an app's handler\n * that injects the router reaches `DeepLinks` through the location, and would be a cycle at boot.\n */\n private deliver(listener: (path: string) => void, path: string): void {\n try {\n listener(path);\n } catch (error) {\n // A handler that rethrows, as some apps' do, would otherwise stop the listeners after this.\n try {\n const errors = this.injector.get(ErrorHandler, null);\n if (errors) errors.handleError(error);\n else console.error(error);\n } catch (reporting) {\n if (reporting === error) console.error(error);\n else console.error(error, reporting);\n }\n }\n }\n\n /** Hand a url to whatever else on the device handles it: a browser, Maps, another app. */\n open(url: string): void {\n this.source.open(url);\n }\n\n /**\n * Open the app's own page in the system settings, where a person turns on a permission the\n * platform no longer asks for. Android has no url for that page, so `open()` cannot reach it.\n */\n openSettings(): void {\n this.source.openSettings?.();\n }\n}\n"]}
1
+ {"version":3,"file":"deep-links.js","sourceRoot":"","sources":["../src/deep-links.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAWhD;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACtC,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC;YACzB,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;SACvB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE;QAC/C,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YACxF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;QAC/D,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,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YAAY,EAAE,IAAI,CAAC,CAAC;gBACrD,IAAI,MAAM;oBAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;;oBACjC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,SAAS,EAAE,CAAC;gBACnB,IAAI,SAAS,KAAK,KAAK;oBAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;oBACzC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,0FAA0F;IAC1F,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;IAC/B,CAAC;uGAxEU,SAAS;wGAAT,SAAS;;2FAAT,SAAS;kBADrB,OAAO","sourcesContent":["/**\n * Links that arrive from outside the app: a `canary://` url, a universal link, a notification.\n */\nimport { ErrorHandler, InjectionToken, Injector, Service, inject } from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport interface DeepLinkSource {\n /** The url the app was launched with. A promise, and nothing says it settles before mount. */\n launchUrl(): Promise<string | null>;\n subscribe(listener: (url: string) => void): () => void;\n open(url: string): void;\n /** Optional, so a source written before there was one is still a source. */\n openSettings?(): void;\n}\n\n/**\n * React Native's `Linking`, with each url whole: the scheme, host, query and fragment that\n * `DeepLinks` strips to a path. Off a device, a source that never delivers a link.\n */\nexport function deepLinkSource(): DeepLinkSource {\n const native = reactNative();\n if (!native) {\n return {\n launchUrl: () => Promise.resolve(null),\n subscribe: () => () => {},\n open: () => {},\n openSettings: () => {},\n };\n }\n\n return {\n launchUrl: () => native.Linking.getInitialURL(),\n subscribe: (listener) => {\n const subscription = native.Linking.addEventListener('url', ({ url }) => listener(url));\n return () => subscription.remove();\n },\n open: (url) => void native.Linking.openURL(url).catch(() => {}),\n openSettings: () => void native.Linking.openSettings().catch(() => {}),\n };\n}\n\n/**\n * The path a url means to this app: everything after the scheme and host.\n *\n * Prefixes are app configuration and every app's are different, but stripping one is not: what a\n * router can navigate to is a path. `canary://primitives` and `https://example.com/primitives`\n * both mean `/primitives` - which takes noticing that only the second one has a host.\n *\n * Expo Go is the exception worth handling here rather than in every app: it serves every project\n * from one development url, puts the app's own path after `/--`, and has a host like a web url\n * rather than a path like an app's own scheme.\n *\n * The development client is the other. `expo run:ios` launches the app through\n * `<scheme>://expo-development-client/?url=...`, which is Expo telling its own launcher which\n * bundle to load and means nothing to the app. Left alone it reaches the router as a path, matches\n * no route, and the app shows a blank screen on every launch during development - which looks\n * exactly like a bug in the app.\n */\n\n/** Expo's own launch hosts. Not paths: instructions to the launcher, which the app never routes. */\nconst EXPO_INTERNAL = new Set(['expo-development-client']);\n\n/** Whether the first segment names one of Expo's launchers rather than something in the app. */\nfunction isLauncher(rest: string): boolean {\n return EXPO_INTERNAL.has(rest.split(/[/?#]/, 1)[0] ?? '');\n}\n\n/** Schemes that carry a host to skip before the path starts. */\nconst HAS_HOST = new Set(['http', 'https', 'exp', 'exps']);\n\n/**\n * The app's path after Expo Go's `/--/`, or null for a url with none in its path. In a query or a\n * fragment, `/--/` is the app's own: a search for it is not a launch prefix.\n */\nfunction expoGoPath(rest: string): string | null {\n const end = rest.search(/[?#]/);\n const marker = (end === -1 ? rest : rest.slice(0, end)).indexOf('/--/');\n return marker === -1 ? null : rest.slice(marker + 3);\n}\n\nexport function pathOf(url: string | null): string | null {\n if (!url) return null;\n const scheme = /^([a-z][a-z0-9+.-]*):\\/\\//i.exec(url);\n const rest = scheme ? url.slice(scheme[0].length) : url;\n\n const expoGo = expoGoPath(rest);\n if (expoGo !== null) return expoGo;\n if (isLauncher(rest)) return null;\n\n // A url with a host has one to skip. A custom scheme does not: `canary://settings` names a\n // path, not a machine, and treating the two alike is how it quietly becomes `/`.\n if (HAS_HOST.has(scheme?.[1]?.toLowerCase() ?? '')) {\n // The host ends at the path, or at a query or fragment when there is no path.\n const end = rest.search(/[/?#]/);\n if (end === -1) return '/';\n return rest[end] === '/' ? rest.slice(end) : `/${rest.slice(end)}`;\n }\n return rest.startsWith('/') ? rest : `/${rest}`;\n}\n\n/**\n * The launch url is delivered whichever way is true at the time: as the initial url if it is\n * known before anything asks, and as an ordinary link if the app is already up. Both happen -\n * the promise races the first navigation and neither order is guaranteed - and a link that\n * arrives late is still a link, so nothing is dropped either way.\n */\n@Service()\nexport class DeepLinks {\n /** Overridden in a test to deliver a link with no platform under it. */\n static readonly SOURCE = new InjectionToken<DeepLinkSource>('angular-native.deepLinkSource', {\n factory: deepLinkSource,\n });\n\n private readonly source = inject(DeepLinks.SOURCE);\n private readonly injector = inject(Injector);\n private launch: string | null = null;\n private readonly listeners = new Set<(path: string) => void>();\n\n constructor() {\n void this.source.launchUrl().then((url) => {\n const path = pathOf(url);\n if (!path || path === '/') return;\n if (this.listeners.size) this.listeners.forEach((listener) => this.deliver(listener, path));\n else this.launch = path;\n });\n }\n\n /** The path the app was launched with, if it is known yet. */\n initialUrl(): string | null {\n return this.launch;\n }\n\n /** Links that arrive while the app is running, as paths. Returns an unsubscribe. */\n subscribe(listener: (path: string) => void): () => void {\n // Each subscription is its own entry, so the same function subscribed twice stops once.\n const subscription = (path: string) => listener(path);\n this.listeners.add(subscription);\n const unsubscribe = this.source.subscribe((url) => {\n const path = pathOf(url);\n if (path) listener(path);\n });\n return () => {\n this.listeners.delete(subscription);\n unsubscribe();\n };\n }\n\n /**\n * One listener throwing is reported, and does not keep the launch url from the rest. The\n * `ErrorHandler` is looked up when that happens rather than when this is made: an app's handler\n * that injects the router reaches `DeepLinks` through the location, and would be a cycle at boot.\n */\n private deliver(listener: (path: string) => void, path: string): void {\n try {\n listener(path);\n } catch (error) {\n // A handler that rethrows, as some apps' do, would otherwise stop the listeners after this.\n try {\n const errors = this.injector.get(ErrorHandler, null);\n if (errors) errors.handleError(error);\n else console.error(error);\n } catch (reporting) {\n if (reporting === error) console.error(error);\n else console.error(error, reporting);\n }\n }\n }\n\n /** Hand a url to whatever else on the device handles it: a browser, Maps, another app. */\n open(url: string): void {\n this.source.open(url);\n }\n\n /**\n * Open the app's own page in the system settings, where a person turns on a permission the\n * platform no longer asks for. Android has no url for that page, so `open()` cannot reach it.\n */\n openSettings(): void {\n this.source.openSettings?.();\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { Accessibility, type AccessibilitySettings, type AccessibilitySource, }
9
9
  export { AppState, type AppStateSource, type AppStatus } from './app-state.ts';
10
10
  export { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';
11
11
  export { currentConditions, deviceTokens, watchConditions, type WatchOptions, } from './conditions.ts';
12
- export { DeepLinks, pathOf, type DeepLinkSource } from './deep-links.ts';
12
+ export { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';
13
13
  export { Direction, type DirectionContext, type DirectionSource, type LayoutDirection, } from './direction.ts';
14
14
  export { androidPermission, type AndroidPermissions, type PermissionAnswer, } from './android-permissions.ts';
15
15
  export { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';
@@ -23,5 +23,6 @@ export type { NativeKeyboardEvent } from './react-native.ts';
23
23
  export { SafeArea, type Frame, type Insets } from './safe-area.ts';
24
24
  export { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';
25
25
  export { StatusBar, statusBarSource, type PlatformStatusBarStyle, type StatusBarSource, type StatusBarState, type StatusBarStyle, } from './status-bar.ts';
26
+ export { NavigationBar, navigationBarSource, type NavigationBarSource, type NavigationBarState, type NavigationBarStyle, } from './navigation-bar.ts';
26
27
  export { SCREEN_IN_FRONT } from './screen-in-front.ts';
27
28
  export { OS_VERSION } from './os-version.ts';
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { Accessibility, } from "./accessibility.js";
9
9
  export { AppState } from "./app-state.js";
10
10
  export { ColorScheme } from "./color-scheme.js";
11
11
  export { currentConditions, deviceTokens, watchConditions, } from "./conditions.js";
12
- export { DeepLinks, pathOf } from "./deep-links.js";
12
+ export { DeepLinks, deepLinkSource, pathOf } from "./deep-links.js";
13
13
  export { Direction, } from "./direction.js";
14
14
  export { androidPermission, } from "./android-permissions.js";
15
15
  export { DevMenu } from "./dev-menu.js";
@@ -22,6 +22,7 @@ export { Keyboard } from "./keyboard.js";
22
22
  export { SafeArea } from "./safe-area.js";
23
23
  export { COMPACT_WIDTH, Screen } from "./screen.js";
24
24
  export { StatusBar, statusBarSource, } from "./status-bar.js";
25
+ export { NavigationBar, navigationBarSource, } from "./navigation-bar.js";
25
26
  export { SCREEN_IN_FRONT } from "./screen-in-front.js";
26
27
  export { OS_VERSION } from "./os-version.js";
27
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAuC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAuC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,SAAS,GAIV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAmC,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAyC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAA6C,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,EAA4C,MAAM,aAAa,CAAC;AAC9F,OAAO,EACL,SAAS,EACT,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * The host: the device, the operating system, and the user's settings.\n *\n * Every capability here is a service with its own factory, so injecting one is the whole setup\n * and one nobody injects is never constructed. Off a device each falls back to doing nothing,\n * which is what makes the whole package importable by the test suite.\n */\nexport {\n Accessibility,\n type AccessibilitySettings,\n type AccessibilitySource,\n} from './accessibility.ts';\nexport { AppState, type AppStateSource, type AppStatus } from './app-state.ts';\nexport { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';\nexport {\n currentConditions,\n deviceTokens,\n watchConditions,\n type WatchOptions,\n} from './conditions.ts';\nexport { DeepLinks, pathOf, type DeepLinkSource } from './deep-links.ts';\nexport {\n Direction,\n type DirectionContext,\n type DirectionSource,\n type LayoutDirection,\n} from './direction.ts';\nexport {\n androidPermission,\n type AndroidPermissions,\n type PermissionAnswer,\n} from './android-permissions.ts';\nexport { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';\nexport { Dialogs, type Choice, type NativeDialogs } from './dialogs.ts';\nexport {\n LayoutAnimation,\n type LayoutChange,\n type LayoutEasing,\n type NativeLayoutAnimation,\n} from './layout-animation.ts';\nexport { Sharing, type NativeSharing, type ShareRequest } from './sharing.ts';\nexport { Vibration, type NativeVibration } from './vibration.ts';\nexport { HardwareBack, hardwareBackSource, type HardwareBackSource } from './hardware-back.ts';\nexport { Keyboard, type KeyboardMetrics, type KeyboardSource } from './keyboard.ts';\nexport type { NativeKeyboardEvent } from './react-native.ts';\nexport { SafeArea, type Frame, type Insets } from './safe-area.ts';\nexport { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';\nexport {\n StatusBar,\n statusBarSource,\n type PlatformStatusBarStyle,\n type StatusBarSource,\n type StatusBarState,\n type StatusBarStyle,\n} from './status-bar.ts';\nexport { SCREEN_IN_FRONT } from './screen-in-front.ts';\nexport { OS_VERSION } from './os-version.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAuC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAuC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AACzF,OAAO,EACL,SAAS,GAIV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAmC,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAyC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAA6C,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,EAA4C,MAAM,aAAa,CAAC;AAC9F,OAAO,EACL,SAAS,EACT,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * The host: the device, the operating system, and the user's settings.\n *\n * Every capability here is a service with its own factory, so injecting one is the whole setup\n * and one nobody injects is never constructed. Off a device each falls back to doing nothing,\n * which is what makes the whole package importable by the test suite.\n */\nexport {\n Accessibility,\n type AccessibilitySettings,\n type AccessibilitySource,\n} from './accessibility.ts';\nexport { AppState, type AppStateSource, type AppStatus } from './app-state.ts';\nexport { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';\nexport {\n currentConditions,\n deviceTokens,\n watchConditions,\n type WatchOptions,\n} from './conditions.ts';\nexport { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';\nexport {\n Direction,\n type DirectionContext,\n type DirectionSource,\n type LayoutDirection,\n} from './direction.ts';\nexport {\n androidPermission,\n type AndroidPermissions,\n type PermissionAnswer,\n} from './android-permissions.ts';\nexport { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';\nexport { Dialogs, type Choice, type NativeDialogs } from './dialogs.ts';\nexport {\n LayoutAnimation,\n type LayoutChange,\n type LayoutEasing,\n type NativeLayoutAnimation,\n} from './layout-animation.ts';\nexport { Sharing, type NativeSharing, type ShareRequest } from './sharing.ts';\nexport { Vibration, type NativeVibration } from './vibration.ts';\nexport { HardwareBack, hardwareBackSource, type HardwareBackSource } from './hardware-back.ts';\nexport { Keyboard, type KeyboardMetrics, type KeyboardSource } from './keyboard.ts';\nexport type { NativeKeyboardEvent } from './react-native.ts';\nexport { SafeArea, type Frame, type Insets } from './safe-area.ts';\nexport { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';\nexport {\n StatusBar,\n statusBarSource,\n type PlatformStatusBarStyle,\n type StatusBarSource,\n type StatusBarState,\n type StatusBarStyle,\n} from './status-bar.ts';\nexport {\n NavigationBar,\n navigationBarSource,\n type NavigationBarSource,\n type NavigationBarState,\n type NavigationBarStyle,\n} from './navigation-bar.ts';\nexport { SCREEN_IN_FRONT } from './screen-in-front.ts';\nexport { OS_VERSION } from './os-version.ts';\n"]}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Android's navigation bar: the colour of its buttons, and whether it is there at all.
3
+ *
4
+ * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and
5
+ * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a
6
+ * theme the app sets included, and a fixed style holds through a scheme change.
7
+ *
8
+ * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the
9
+ * package. Expo Go carries it; a development build has it once the app installs
10
+ * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept
11
+ * but changes nothing.
12
+ */
13
+ import { InjectionToken, type Signal } from '@angular/core';
14
+ import * as i0 from "@angular/core";
15
+ /**
16
+ * The colour of the bar's buttons. `dark` is dark buttons, for a light screen behind them, and
17
+ * `light` light ones, as `StatusBarStyle` names its text. `auto` is dark buttons in the light
18
+ * colour scheme and light ones in the dark one, and follows `ColorScheme`.
19
+ */
20
+ export type NavigationBarStyle = 'light' | 'dark' | 'auto';
21
+ /** What a claim asks for. Anything absent is left as whatever the claim underneath said. */
22
+ export interface NavigationBarState {
23
+ readonly style?: NavigationBarStyle;
24
+ /** Hide the bar until a swipe from the edge of the screen shows it for a moment. */
25
+ readonly hidden?: boolean;
26
+ }
27
+ /** Where the bar actually is. A fake stands in for the platform in tests. */
28
+ export interface NavigationBarSource {
29
+ setStyle(style: Exclude<NavigationBarStyle, 'auto'>): void;
30
+ setHidden(hidden: boolean): void;
31
+ /**
32
+ * react-native-screens shows or hides the bar each time a screen appears, from that screen's own
33
+ * `navigationBarHidden`, once any screen has set one. So a hidden claim rides on every screen too.
34
+ */
35
+ readonly screensSetBar?: boolean;
36
+ }
37
+ export declare function navigationBarSource(): NavigationBarSource;
38
+ /**
39
+ * A stack, not a setter, for the same reason as `StatusBar`'s: whatever hid the bar has to give it
40
+ * back to whatever was there before. `push` returns the function that drops the claim.
41
+ */
42
+ export declare class NavigationBar {
43
+ /** Overridden in a test to watch the bar without one on screen. */
44
+ static readonly SOURCE: InjectionToken<NavigationBarSource>;
45
+ private readonly source;
46
+ private readonly scheme;
47
+ private readonly stack;
48
+ /** What is actually showing: every claim in order, later ones winning per property. */
49
+ readonly state: Signal<NavigationBarState>;
50
+ /**
51
+ * What a screen with no `navigationBarHidden` of its own carries, so the claim still holds when
52
+ * it appears. Empty but on Android. The router passes it on.
53
+ */
54
+ readonly forScreens: Signal<{
55
+ readonly hidden?: boolean;
56
+ }>;
57
+ constructor();
58
+ /** The base claim, for an app that sets the bar once at startup. */
59
+ set(state: NavigationBarState): void;
60
+ /** A claim on top of whatever is there. Call the returned function to drop it. */
61
+ push(state: NavigationBarState): () => void;
62
+ /** The properties a claim has had the platform change, which no claim names any more. */
63
+ private readonly changed;
64
+ /** Whether a claim has ever set the style, after which an unclaimed bar follows the scheme. */
65
+ private styled;
66
+ /**
67
+ * Push the merged state at the platform. A property the last claim to name it has dropped goes
68
+ * back, once: the style to `auto`, which then keeps following the scheme, and the bar to shown.
69
+ */
70
+ private apply;
71
+ private changes;
72
+ static ɵfac: i0.ɵɵFactoryDeclaration<NavigationBar, never>;
73
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
74
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Android's navigation bar: the colour of its buttons, and whether it is there at all.
3
+ *
4
+ * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and
5
+ * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a
6
+ * theme the app sets included, and a fixed style holds through a scheme change.
7
+ *
8
+ * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the
9
+ * package. Expo Go carries it; a development build has it once the app installs
10
+ * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept
11
+ * but changes nothing.
12
+ */
13
+ import { DestroyRef, InjectionToken, Service, computed, inject, signal, untracked, } from '@angular/core';
14
+ import { ColorScheme } from "./color-scheme.js";
15
+ import { reactNative } from "./react-native.js";
16
+ import * as i0 from "@angular/core";
17
+ const NONE = { setStyle: () => { }, setHidden: () => { } };
18
+ export function navigationBarSource() {
19
+ if (reactNative()?.Platform?.OS !== 'android')
20
+ return NONE;
21
+ const modules = globalThis.expo?.modules;
22
+ const native = modules?.['ExpoNavigationBar'];
23
+ // Without the module a claim changes nothing, so it does not ride on the screens either, where
24
+ // react-native-screens would hide the bar the next time one appears.
25
+ if (!native)
26
+ return NONE;
27
+ return {
28
+ setStyle: (style) => void native.setStyle?.(style)?.catch(() => { }),
29
+ setHidden: (hidden) => void native.setHidden?.(hidden)?.catch(() => { }),
30
+ screensSetBar: true,
31
+ };
32
+ }
33
+ /**
34
+ * A stack, not a setter, for the same reason as `StatusBar`'s: whatever hid the bar has to give it
35
+ * back to whatever was there before. `push` returns the function that drops the claim.
36
+ */
37
+ export class NavigationBar {
38
+ /** Overridden in a test to watch the bar without one on screen. */
39
+ static SOURCE = new InjectionToken('angular-native.navigationBarSource', { factory: navigationBarSource });
40
+ source = inject(NavigationBar.SOURCE);
41
+ scheme = inject(ColorScheme);
42
+ stack = signal([{}], /* @ts-ignore */
43
+ ...(ngDevMode ? [{ debugName: "stack" }] : /* istanbul ignore next */ []));
44
+ /** What is actually showing: every claim in order, later ones winning per property. */
45
+ state = computed(() => this.stack().reduce((merged, entry) => ({ ...merged, ...entry }), {}), /* @ts-ignore */
46
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
47
+ /**
48
+ * What a screen with no `navigationBarHidden` of its own carries, so the claim still holds when
49
+ * it appears. Empty but on Android. The router passes it on.
50
+ */
51
+ forScreens = computed(() => this.source.screensSetBar ? { hidden: this.state().hidden } : {}, /* @ts-ignore */
52
+ ...(ngDevMode ? [{ debugName: "forScreens" }] : /* istanbul ignore next */ []));
53
+ constructor() {
54
+ // Straight from the source, as `StatusBar` does, so the buttons change in the same turn as the
55
+ // scheme. Android puts the buttons back to the new scheme's own on a scheme change, so a fixed
56
+ // style is sent again too. A bar no style claim names any more is `auto`, once one has named
57
+ // a style.
58
+ const stop = inject(ColorScheme.SOURCE).subscribe((scheme) => {
59
+ const style = untracked(this.state).style ?? (this.styled ? 'auto' : undefined);
60
+ if (style !== undefined)
61
+ this.source.setStyle(resolve(style, scheme));
62
+ });
63
+ inject(DestroyRef).onDestroy(stop);
64
+ }
65
+ /** The base claim, for an app that sets the bar once at startup. */
66
+ set(state) {
67
+ this.stack.update((entries) => [state, ...entries.slice(1)]);
68
+ this.apply();
69
+ }
70
+ /** A claim on top of whatever is there. Call the returned function to drop it. */
71
+ push(state) {
72
+ const entry = { ...state };
73
+ this.stack.update((entries) => [...entries, entry]);
74
+ this.apply();
75
+ return () => {
76
+ this.stack.update((entries) => entries.filter((one) => one !== entry));
77
+ this.apply();
78
+ };
79
+ }
80
+ /** The properties a claim has had the platform change, which no claim names any more. */
81
+ changed = new Set();
82
+ /** Whether a claim has ever set the style, after which an unclaimed bar follows the scheme. */
83
+ styled = false;
84
+ /**
85
+ * Push the merged state at the platform. A property the last claim to name it has dropped goes
86
+ * back, once: the style to `auto`, which then keeps following the scheme, and the bar to shown.
87
+ */
88
+ apply() {
89
+ const { style, hidden } = untracked(this.state);
90
+ if (this.changes('style', style)) {
91
+ this.styled = true;
92
+ this.source.setStyle(resolve(style ?? 'auto', untracked(this.scheme.current)));
93
+ }
94
+ if (this.changes('hidden', hidden))
95
+ this.source.setHidden(hidden ?? false);
96
+ }
97
+ changes(property, value) {
98
+ if (value === undefined)
99
+ return this.changed.delete(property);
100
+ this.changed.add(property);
101
+ return true;
102
+ }
103
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NavigationBar, deps: [], target: i0.ɵɵFactoryTarget.Service });
104
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: NavigationBar });
105
+ }
106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NavigationBar, decorators: [{
107
+ type: Service
108
+ }], ctorParameters: () => [] });
109
+ /** Dark buttons on the light scheme's light background, light ones on the dark one's. */
110
+ function resolve(style, scheme) {
111
+ if (style !== 'auto')
112
+ return style;
113
+ return scheme === 'dark' ? 'light' : 'dark';
114
+ }
115
+ //# sourceMappingURL=navigation-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-bar.js","sourceRoot":"","sources":["../src/navigation-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAiChD,MAAM,IAAI,GAAwB,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;AAE9E,MAAM,UAAU,mBAAmB;IACjC,IAAI,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,OAAO,GAAI,UAA+D,CAAC,IAAI,EAAE,OAAO,CAAC;IAC/F,MAAM,MAAM,GAAG,OAAO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of its buttons, and whether it is there at all.\n *\n * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and\n * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a\n * theme the app sets included, and a fixed style holds through a scheme change.\n *\n * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the\n * package. Expo Go carries it; a development build has it once the app installs\n * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept\n * but changes nothing.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n signal,\n untracked,\n type Signal,\n} from '@angular/core';\nimport { ColorScheme, type Scheme } from './color-scheme.ts';\nimport { reactNative } from './react-native.ts';\n\n/**\n * The colour of the bar's buttons. `dark` is dark buttons, for a light screen behind them, and\n * `light` light ones, as `StatusBarStyle` names its text. `auto` is dark buttons in the light\n * colour scheme and light ones in the dark one, and follows `ColorScheme`.\n */\nexport type NavigationBarStyle = 'light' | 'dark' | 'auto';\n\n/** What a claim asks for. Anything absent is left as whatever the claim underneath said. */\nexport interface NavigationBarState {\n readonly style?: NavigationBarStyle;\n /** Hide the bar until a swipe from the edge of the screen shows it for a moment. */\n readonly hidden?: boolean;\n}\n\n/** Where the bar actually is. A fake stands in for the platform in tests. */\nexport interface NavigationBarSource {\n setStyle(style: Exclude<NavigationBarStyle, 'auto'>): void;\n setHidden(hidden: boolean): void;\n /**\n * react-native-screens shows or hides the bar each time a screen appears, from that screen's own\n * `navigationBarHidden`, once any screen has set one. So a hidden claim rides on every screen too.\n */\n readonly screensSetBar?: boolean;\n}\n\n/** `expo-navigation-bar`'s native module, as much of it as this uses. */\ninterface NativeNavigationBar {\n setStyle?(style: 'light' | 'dark'): Promise<void>;\n setHidden?(hidden: boolean): Promise<void>;\n}\n\nconst NONE: NavigationBarSource = { setStyle: () => {}, setHidden: () => {} };\n\nexport function navigationBarSource(): NavigationBarSource {\n if (reactNative()?.Platform?.OS !== 'android') return NONE;\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n const native = modules?.['ExpoNavigationBar'] as NativeNavigationBar | undefined;\n // Without the module a claim changes nothing, so it does not ride on the screens either, where\n // react-native-screens would hide the bar the next time one appears.\n if (!native) return NONE;\n return {\n setStyle: (style) => void native.setStyle?.(style)?.catch(() => {}),\n setHidden: (hidden) => void native.setHidden?.(hidden)?.catch(() => {}),\n screensSetBar: true,\n };\n}\n\n/**\n * A stack, not a setter, for the same reason as `StatusBar`'s: whatever hid the bar has to give it\n * back to whatever was there before. `push` returns the function that drops the claim.\n */\n@Service()\nexport class NavigationBar {\n /** Overridden in a test to watch the bar without one on screen. */\n static readonly SOURCE = new InjectionToken<NavigationBarSource>(\n 'angular-native.navigationBarSource',\n { factory: navigationBarSource },\n );\n\n private readonly source = inject(NavigationBar.SOURCE);\n private readonly scheme = inject(ColorScheme);\n private readonly stack = signal<readonly NavigationBarState[]>([{}]);\n\n /** What is actually showing: every claim in order, later ones winning per property. */\n readonly state: Signal<NavigationBarState> = computed(() =>\n this.stack().reduce((merged, entry) => ({ ...merged, ...entry }), {}),\n );\n\n /**\n * What a screen with no `navigationBarHidden` of its own carries, so the claim still holds when\n * it appears. Empty but on Android. The router passes it on.\n */\n readonly forScreens: Signal<{ readonly hidden?: boolean }> = computed(() =>\n this.source.screensSetBar ? { hidden: this.state().hidden } : {},\n );\n\n constructor() {\n // Straight from the source, as `StatusBar` does, so the buttons change in the same turn as the\n // scheme. Android puts the buttons back to the new scheme's own on a scheme change, so a fixed\n // style is sent again too. A bar no style claim names any more is `auto`, once one has named\n // a style.\n const stop = inject(ColorScheme.SOURCE).subscribe((scheme) => {\n const style = untracked(this.state).style ?? (this.styled ? 'auto' : undefined);\n if (style !== undefined) this.source.setStyle(resolve(style, scheme));\n });\n inject(DestroyRef).onDestroy(stop);\n }\n\n /** The base claim, for an app that sets the bar once at startup. */\n set(state: NavigationBarState): void {\n this.stack.update((entries) => [state, ...entries.slice(1)]);\n this.apply();\n }\n\n /** A claim on top of whatever is there. Call the returned function to drop it. */\n push(state: NavigationBarState): () => void {\n const entry = { ...state };\n this.stack.update((entries) => [...entries, entry]);\n this.apply();\n return () => {\n this.stack.update((entries) => entries.filter((one) => one !== entry));\n this.apply();\n };\n }\n\n /** The properties a claim has had the platform change, which no claim names any more. */\n private readonly changed = new Set<keyof NavigationBarState>();\n\n /** Whether a claim has ever set the style, after which an unclaimed bar follows the scheme. */\n private styled = false;\n\n /**\n * Push the merged state at the platform. A property the last claim to name it has dropped goes\n * back, once: the style to `auto`, which then keeps following the scheme, and the bar to shown.\n */\n private apply(): void {\n const { style, hidden } = untracked(this.state);\n if (this.changes('style', style)) {\n this.styled = true;\n this.source.setStyle(resolve(style ?? 'auto', untracked(this.scheme.current)));\n }\n if (this.changes('hidden', hidden)) this.source.setHidden(hidden ?? false);\n }\n\n private changes(property: keyof NavigationBarState, value: unknown): boolean {\n if (value === undefined) return this.changed.delete(property);\n this.changed.add(property);\n return true;\n }\n}\n\n/** Dark buttons on the light scheme's light background, light ones on the dark one's. */\nfunction resolve(style: NavigationBarStyle, scheme: Scheme): 'light' | 'dark' {\n if (style !== 'auto') return style;\n return scheme === 'dark' ? 'light' : 'dark';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/device",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Angular Native device services: keyboard, screen, color scheme, app state, accessibility, hardware back and deep links.",
5
5
  "keywords": [
6
6
  "angular",
@@ -17,7 +17,7 @@
17
17
  "type": "module",
18
18
  "main": "dist/index.js",
19
19
  "dependencies": {
20
- "@ng-native/fabric": "0.14.0"
20
+ "@ng-native/fabric": "0.16.0"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@angular/core": "^22.0.0",