@ng-native/web 0.24.0 → 0.26.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/dist/mount.js CHANGED
@@ -33,7 +33,8 @@
33
33
  * Refresh's fallback path specifically; a browser dev server has its own, unrelated story for
34
34
  * picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.
35
35
  */
36
- import { APP_BOOTSTRAP_LISTENER, ApplicationInitStatus, ApplicationRef, DOCUMENT, PLATFORM_ID, EnvironmentInjector, ErrorHandler, LOCALE_ID, RendererFactory2, createComponent, effect, createEnvironmentInjector, ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal, ɵsetLocaleId as setLocaleId, } from '@angular/core';
36
+ import { APP_BOOTSTRAP_LISTENER, ApplicationInitStatus, ApplicationRef, DOCUMENT, PLATFORM_ID, EnvironmentInjector, ErrorHandler, LOCALE_ID, RendererFactory2, createComponent, effect, createEnvironmentInjector, ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal, } from '@angular/core';
37
+ import * as core from '@angular/core';
37
38
  import { HostEngine } from '@ng-native/fabric';
38
39
  import { ColorScheme, Direction, HardwareBack, OS, Screen, StatusBar } from '@ng-native/device';
39
40
  import { browserColorSchemeSource, browserDirectionSource, browserScreenSource, } from "./device-sources.js";
@@ -260,4 +261,13 @@ function setInputs(componentRef, inputs) {
260
261
  for (const [name, value] of Object.entries(inputs))
261
262
  componentRef.setInput(name, value);
262
263
  }
264
+ /**
265
+ * Tells Angular's i18n runtime the app's locale, on Angular 22.2 and earlier, which keep it in a
266
+ * global. 22.3 removed that global and each view reads `LOCALE_ID` from its injector. A named import
267
+ * of the removed export fails a Vite build and is undefined under Metro; a namespace member read in
268
+ * place is undefined (Vite warns) and still tree-shakes.
269
+ */
270
+ function setLocaleId(id) {
271
+ core.ɵsetLocaleId?.(id);
272
+ }
263
273
  //# sourceMappingURL=mount.js.map
package/dist/mount.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,yBAAyB,EAMzB,8BAA8B,IAAI,6BAA6B,EAC/D,eAAe,IAAI,cAAc,EACjC,uCAAuC,IAAI,sCAAsC,EACjF,YAAY,IAAI,WAAW,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB;IACtD,WAAW,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAk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AAC;QAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzF,CAAC","sourcesContent":["/**\n * Put an Angular application on a page.\n *\n * The browser counterpart to `@ng-native/platform`'s `mount()`, and named the same on\n * purpose: an app imports one or the other, never both, and which one it gets is the import path's\n * job to say rather than the identifier's. Reading the native one first is worth it - this follows\n * its shape and its documented distinction\n * between `ApplicationRef` and the root `ComponentRef` (`createComponent` resolves the latter;\n * `applicationRef.components` needs it pushed by hand, the same bookkeeping\n * `ApplicationRef.bootstrap()` would otherwise do, for the same reason - a routed app's initial\n * navigation checks `applicationRef.components[0]` before it will run at all).\n *\n * What is different from the native `mount()`, and why:\n *\n * - **The first argument is a real `Element`, not a numeric root tag.** Fabric addresses its root\n * by the tag React Native's host gave it; a browser page has no such number, only the element\n * an app mounts into (`document.getElementById('app-root')`, or one `document.body` itself).\n * - **No `FabricUIManager`, and no `Engine` provided under its own token.** Only `HostEngine` is\n * provided. `worklet-style`, `worklet-scroll` and `native-gesture`\n * `inject(Engine)` directly (see `packages/fabric/src/host.ts`'s doc comment for why that is\n * the honest place to draw the line) - on native `Engine` is provided under both tokens so both\n * paths resolve; here it is provided under neither, so an app that uses one of those three on\n * the web gets Angular's own `NullInjectorError` at the point it tries to inject `Engine`,\n * which names exactly what is unsupported rather than rendering something silently wrong.\n * - **`DOCUMENT` is the real `document`**, not the stub the native `mount()` builds for\n * `TransferState`'s\n * `getElementById`. A browser host already has one.\n * - **No dev-mode animation warning, no HMR reload hook.** The native check exists\n * because `@angular/core` reads whether `animate.enter`/`animate.leave` do anything from a\n * global a Metro polyfill has to set before `@angular/core` first evaluates; a real browser\n * already has `document.documentElement.getAnimations`, which is the same thing that global\n * stands in for on native, so there is nothing to warn about. The reload hook is Metro Fast\n * Refresh's fallback path specifically; a browser dev server has its own, unrelated story for\n * picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.\n */\nimport {\n APP_BOOTSTRAP_LISTENER,\n ApplicationInitStatus,\n ApplicationRef,\n DOCUMENT,\n PLATFORM_ID,\n EnvironmentInjector,\n ErrorHandler,\n LOCALE_ID,\n RendererFactory2,\n createComponent,\n effect,\n createEnvironmentInjector,\n type ComponentRef,\n type EnvironmentProviders,\n type Injector,\n type Provider,\n type Type,\n ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector,\n ɵINJECTOR_SCOPE as INJECTOR_SCOPE,\n ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal,\n ɵsetLocaleId as setLocaleId,\n} from '@angular/core';\nimport { HostEngine } from '@ng-native/fabric';\nimport { ColorScheme, Direction, HardwareBack, OS, Screen, StatusBar } from '@ng-native/device';\nimport {\n browserColorSchemeSource,\n browserDirectionSource,\n browserScreenSource,\n} from './device-sources.ts';\nimport { BrowserEngine } from './browser-engine.ts';\nimport { BrowserRendererFactory } from './browser-renderer.ts';\nimport { ISLAND_RESET_CSS, RESET_CSS } from './reset-css.ts';\n\nconst RESET_STYLE_ID = 'angular-native-web-reset';\nconst ISLAND_RESET_STYLE_ID = 'angular-native-web-island-reset';\n\n/**\n * Injects `reset.css`'s content as a `<style>` in `document.head`, once per document. Idempotent,\n * so an app free to call it itself (or to load `reset.css` through its own bundler instead, and\n * pass `injectReset: false` to `mount`) never ends up with the rule twice.\n */\nexport function injectResetStylesheet(document: Document): void {\n injectStyle(document, RESET_STYLE_ID, RESET_CSS);\n}\n\n/**\n * The same for an island inside someone else's page: `ISLAND_RESET_CSS`, which leaves the host's\n * `html` and `body` alone. Its own id, so it sits beside a full reset if the page has both kinds.\n */\nexport function injectIslandResetStylesheet(document: Document): void {\n injectStyle(document, ISLAND_RESET_STYLE_ID, ISLAND_RESET_CSS);\n}\n\nfunction injectStyle(document: Document, id: string, css: string): void {\n if (document.getElementById(id)) return;\n const style = document.createElement('style');\n style.id = id;\n // In Tailwind's `base` layer, below every utility, as `@import '@ng-native/web/reset.css'\n // layer(base)` puts it. Injected unlayered after the app's stylesheet, a reset rule is as\n // specific as a class and later, so it beat `border-2`, `flex-row` and `hidden` alike. With no\n // Tailwind on the page, a layered rule still loses to every unlayered one, as a reset should.\n style.textContent = `@layer base {\\n${css}\\n}`;\n // First in the head: a layer is ordered by where it is first declared, and the documented entry\n // (theme.css and utilities.css) declares no `base`. Declared after it, `base` came after\n // `utilities` and beat every utility again.\n document.head.insertBefore(style, document.head.firstChild);\n}\n\nexport interface MountOptions {\n readonly providers?: (Provider | EnvironmentProviders)[];\n /**\n * The component's inputs, by their public name, set before its first render - so an\n * `input.required()` has its value from the start rather than throwing on the first check.\n * Change them afterwards with `componentRef.setInput`.\n */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * Injects the reset stylesheet into `document.head` before mounting. Defaults to `true`. With\n * `injector` it is the island reset, which leaves the host page's `html` and `body` alone.\n */\n readonly injectReset?: boolean;\n /**\n * Mount inside an existing Angular app instead of as an app of its own: pass an injector from\n * that app - `inject(Injector)` in the component that owns `rootElement` is the usual one.\n *\n * The island then shares the host app's services (anything `providedIn: 'root'`, and anything\n * its `bootstrapApplication` or a component above it provides) and is checked by the host's\n * change detection. Only what the island has to render differently is its own: the renderer,\n * the engine, and the device services that read the browser rather than a phone. See\n * `packages/web/islands.md` in the documentation.\n */\n readonly injector?: Injector;\n /**\n * Keeps a `dark` class on `rootElement` in step with `ColorScheme`, which is what\n * `@ng-native/tailwind`'s `dark:` variant and a theme's `.dark` block match beneath: the system's\n * `prefers-color-scheme`, or what `ColorScheme.set()` chose over it. Defaults to `true`, as\n * `watchConditions` does on a device. An app that puts `dark` on its own root view turns it off.\n */\n readonly darkClass?: boolean;\n}\n\nexport interface MountResult {\n readonly componentRef: ComponentRef<unknown>;\n /** The island's own app, or with `injector` the host app it was mounted into. */\n readonly applicationRef: ApplicationRef;\n readonly factory: BrowserRendererFactory;\n readonly engine: BrowserEngine;\n /**\n * Takes the island down: its component, and whatever it owns. With `injector` that is only the\n * island - the host app it was mounted into keeps running - so call this rather than\n * `applicationRef.destroy()`, which there would destroy the host.\n */\n destroy(): void;\n}\n\nexport function mount(\n rootElement: Element,\n component: Type<unknown>,\n options: MountOptions = {},\n): MountResult {\n const {\n providers: extraProviders = [],\n inputs = {},\n injectReset = true,\n injector: host,\n darkClass = true,\n } = options;\n const document = rootElement.ownerDocument;\n if (injectReset) {\n if (host) injectIslandResetStylesheet(document);\n else injectResetStylesheet(document);\n }\n // What `reset.css` hangs the root's height off. Stamped rather than required of the app,\n // because an app that forgot it would get a page whose `flex: 1` silently resolved to zero.\n rootElement.setAttribute('data-rn-root', '');\n // What `@ng-native/tailwind`'s `web:` variant matches beneath, as `platform-ios` does on a phone.\n rootElement.classList.add('platform-web');\n\n const engine = new BrowserEngine(document);\n const factory = new BrowserRendererFactory(engine, document);\n // `wrapRoot` marks the element `ngSkipHydration`; an island gives back what it had on unmount.\n const skipHydration = rootElement.getAttribute('ngSkipHydration');\n const rootNode = engine.wrapRoot(rootElement) as unknown as Element;\n const own = hostProviders(engine, factory, document.defaultView);\n\n const mounted = host\n ? mountInside(\n host,\n rootElement,\n rootNode,\n component,\n [...own, ...extraProviders],\n inputs,\n {\n factory,\n engine,\n },\n skipHydration,\n )\n : mountAlone(rootNode, component, [...own, ...extraProviders], inputs, document, {\n factory,\n engine,\n });\n // The engine listens on the whole document, so it has to stop once its app is gone, however\n // the app went: through `destroy()` or straight through the component ref.\n mounted.componentRef.onDestroy(() => engine.dispose());\n if (darkClass) keepDarkClass(rootElement, mounted.componentRef);\n return mounted;\n}\n\n/** The `darkClass` option: the class now, and again whenever `ColorScheme` changes. */\nfunction keepDarkClass(rootElement: Element, componentRef: ComponentRef<unknown>): void {\n const scheme = componentRef.injector.get(ColorScheme);\n const apply = () => rootElement.classList.toggle('dark', scheme.current() === 'dark');\n apply();\n effect(apply, { injector: componentRef.injector });\n componentRef.onDestroy(() => rootElement.classList.remove('dark'));\n}\n\n/**\n * What an island has to have of its own, whichever way it is mounted: the renderer and engine\n * that turn `<view>` into a `<div>`, and the device capabilities answered by the browser.\n */\nfunction hostProviders(\n engine: BrowserEngine,\n factory: BrowserRendererFactory,\n view: Document['defaultView'],\n): (Provider | EnvironmentProviders)[] {\n return [\n { provide: RendererFactory2, useValue: factory },\n // The one seam the shared packages inject. See the file doc for why `Engine` itself is not\n // also provided here.\n { provide: HostEngine, useValue: engine },\n // The device capabilities, from the browser rather than from React Native. Without these\n // `Screen` falls back to its off-device answer of a zero-sized window, and every component\n // that branches on `compact()` takes the phone tree. See `device-sources.ts`.\n ...(view\n ? [\n { provide: Screen.SOURCE, useValue: browserScreenSource(view) },\n { provide: ColorScheme.SOURCE, useValue: browserColorSchemeSource(view) },\n { provide: Direction.SOURCE, useValue: browserDirectionSource(view) },\n ]\n : []),\n // The engine renders as iOS here, so the off-device fallback would say iOS too.\n { provide: OS, useValue: 'web' },\n // A tab has no hardware back button, so this is the same inert fallback\n // `hardwareBackSource()`'s own off-device branch answers with, provided here so the browser\n // host says so itself rather than relying on that branch.\n { provide: HardwareBack.SOURCE, useValue: { subscribe: () => () => {} } },\n // A tab has no status bar either.\n {\n provide: StatusBar.SOURCE,\n useValue: {\n setStyle: () => {},\n setHidden: () => {},\n setBackgroundColor: () => {},\n setTranslucent: () => {},\n height: undefined,\n },\n },\n ];\n}\n\n/** An app of its own: its own root injector, change detection and `ApplicationRef`. */\nfunction mountAlone(\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n document: Document,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n): MountResult {\n // Parent the app injector to the platform injector, exactly as `internalCreateApplication`\n // does and `mount()` documents: some Angular services are `providedIn: 'platform'`, and with a\n // null parent they simply do not exist.\n const platformInjector = createOrReusePlatformInjector();\n\n const injector = createEnvironmentInjector(\n [\n { provide: INJECTOR_SCOPE, useValue: 'root' },\n provideZonelessChangeDetectionInternal(),\n { provide: DOCUMENT, useValue: document },\n // A DOM is what this is running in, so libraries that check isPlatformBrowser() are right to\n // use it. An island inside an app is the app's own and inherits its value instead.\n { provide: PLATFORM_ID, useValue: 'browser' },\n { provide: ErrorHandler, useClass: ErrorHandler },\n ...providers,\n ],\n platformInjector as EnvironmentInjector,\n );\n runInitializers(injector);\n setLocaleId(injector.get(LOCALE_ID) || 'en-US');\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n const applicationRef = injector.get(ApplicationRef);\n\n // Mirrors `ApplicationRef.bootstrap()`, which is not used directly because it wants a DOM\n // selector rather than an element `mount`'s own caller already resolved.\n applicationRef.componentTypes.push(component);\n applicationRef.attachView(componentRef.hostView);\n applicationRef.tick();\n // Load-bearing, not bookkeeping: the router's bootstrap listener returns early unless the ref\n // it is handed is `ApplicationRef.components[0]`.\n applicationRef.components.push(componentRef);\n componentRef.onDestroy(() => {\n applicationRef.detachView(componentRef.hostView);\n const at = applicationRef.components.indexOf(componentRef);\n if (at !== -1) applicationRef.components.splice(at, 1);\n });\n\n for (const listener of injector.get(APP_BOOTSTRAP_LISTENER, [])) {\n listener(componentRef);\n }\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n applicationRef.destroy();\n },\n };\n}\n\n/**\n * The app initializers, before the root component exists, as the native `mount()` runs them (see\n * its `runInitializers` for why through `ApplicationInitStatus`): a promise is started, not awaited,\n * and a failed one reaches the `ErrorHandler`. A copy, as this package cannot import the platform.\n */\nfunction runInitializers(injector: EnvironmentInjector): void {\n const status = injector.get(ApplicationInitStatus);\n (status as unknown as { runInitializers(): void }).runInitializers();\n status.donePromise.catch((error: unknown) => injector.get(ErrorHandler).handleError(error));\n}\n\n/**\n * An island inside a running app. Its environment injector is a child of the host's, without a\n * root scope of its own, so anything it does not provide - a `providedIn: 'root'` service, the\n * host's `ApplicationRef` and scheduler, its `ErrorHandler` - resolves from the host, once, for\n * both. What it does provide is only what has to differ: the renderer and engine, the browser's\n * device sources, and the five device services that read them. Those five are provided here as\n * classes so they are built in the island, against its sources, rather than in the host's root\n * against the phone defaults.\n *\n * The host's element injector goes in too, so a service a component above the island provides\n * is visible to it as well as one the app does.\n */\nfunction mountInside(\n hostInjector: Injector,\n rootElement: Element,\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n skipHydration: string | null,\n): MountResult {\n const injector = createEnvironmentInjector(\n [Screen, ColorScheme, Direction, HardwareBack, StatusBar, ...providers],\n hostInjector.get(EnvironmentInjector),\n );\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n elementInjector: hostInjector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n // The host's own change detection checks the island from here on, like any view of its own.\n const applicationRef = hostInjector.get(ApplicationRef);\n applicationRef.attachView(componentRef.hostView);\n componentRef.changeDetectorRef.detectChanges();\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n injector.destroy();\n rootElement.removeAttribute('data-rn-root');\n if (skipHydration === null) rootElement.removeAttribute('ngSkipHydration');\n else rootElement.setAttribute('ngSkipHydration', skipHydration);\n rootElement.classList.remove('platform-web');\n },\n };\n}\n\nfunction setInputs(componentRef: ComponentRef<unknown>, inputs: Readonly<Record<string, unknown>>) {\n for (const [name, value] of Object.entries(inputs)) componentRef.setInput(name, value);\n}\n"]}
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,yBAAyB,EAMzB,8BAA8B,IAAI,6BAA6B,EAC/D,eAAe,IAAI,cAAc,EACjC,uCAAuC,IAAI,sCAAsC,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,GAAG,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACxD,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACjD,YAAY,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC;IAE/C,OAAO;QACL,YAAY;QACZ,cAAc;QACd,GAAG,IAAI;QACP,OAAO,EAAE,GAAG,EAAE;YACZ,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC5C,IAAI,aAAa,KAAK,IAAI;gBAAE,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;;gBACtE,WAAW,CAAC,YAAY,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAChE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,YAAmC,EAAE,MAAyC;IAC/F,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,EAAU;IAC5B,IAAgD,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Put an Angular application on a page.\n *\n * The browser counterpart to `@ng-native/platform`'s `mount()`, and named the same on\n * purpose: an app imports one or the other, never both, and which one it gets is the import path's\n * job to say rather than the identifier's. Reading the native one first is worth it - this follows\n * its shape and its documented distinction\n * between `ApplicationRef` and the root `ComponentRef` (`createComponent` resolves the latter;\n * `applicationRef.components` needs it pushed by hand, the same bookkeeping\n * `ApplicationRef.bootstrap()` would otherwise do, for the same reason - a routed app's initial\n * navigation checks `applicationRef.components[0]` before it will run at all).\n *\n * What is different from the native `mount()`, and why:\n *\n * - **The first argument is a real `Element`, not a numeric root tag.** Fabric addresses its root\n * by the tag React Native's host gave it; a browser page has no such number, only the element\n * an app mounts into (`document.getElementById('app-root')`, or one `document.body` itself).\n * - **No `FabricUIManager`, and no `Engine` provided under its own token.** Only `HostEngine` is\n * provided. `worklet-style`, `worklet-scroll` and `native-gesture`\n * `inject(Engine)` directly (see `packages/fabric/src/host.ts`'s doc comment for why that is\n * the honest place to draw the line) - on native `Engine` is provided under both tokens so both\n * paths resolve; here it is provided under neither, so an app that uses one of those three on\n * the web gets Angular's own `NullInjectorError` at the point it tries to inject `Engine`,\n * which names exactly what is unsupported rather than rendering something silently wrong.\n * - **`DOCUMENT` is the real `document`**, not the stub the native `mount()` builds for\n * `TransferState`'s\n * `getElementById`. A browser host already has one.\n * - **No dev-mode animation warning, no HMR reload hook.** The native check exists\n * because `@angular/core` reads whether `animate.enter`/`animate.leave` do anything from a\n * global a Metro polyfill has to set before `@angular/core` first evaluates; a real browser\n * already has `document.documentElement.getAnimations`, which is the same thing that global\n * stands in for on native, so there is nothing to warn about. The reload hook is Metro Fast\n * Refresh's fallback path specifically; a browser dev server has its own, unrelated story for\n * picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.\n */\nimport {\n APP_BOOTSTRAP_LISTENER,\n ApplicationInitStatus,\n ApplicationRef,\n DOCUMENT,\n PLATFORM_ID,\n EnvironmentInjector,\n ErrorHandler,\n LOCALE_ID,\n RendererFactory2,\n createComponent,\n effect,\n createEnvironmentInjector,\n type ComponentRef,\n type EnvironmentProviders,\n type Injector,\n type Provider,\n type Type,\n ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector,\n ɵINJECTOR_SCOPE as INJECTOR_SCOPE,\n ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal,\n} from '@angular/core';\nimport * as core from '@angular/core';\nimport { HostEngine } from '@ng-native/fabric';\nimport { ColorScheme, Direction, HardwareBack, OS, Screen, StatusBar } from '@ng-native/device';\nimport {\n browserColorSchemeSource,\n browserDirectionSource,\n browserScreenSource,\n} from './device-sources.ts';\nimport { BrowserEngine } from './browser-engine.ts';\nimport { BrowserRendererFactory } from './browser-renderer.ts';\nimport { ISLAND_RESET_CSS, RESET_CSS } from './reset-css.ts';\n\nconst RESET_STYLE_ID = 'angular-native-web-reset';\nconst ISLAND_RESET_STYLE_ID = 'angular-native-web-island-reset';\n\n/**\n * Injects `reset.css`'s content as a `<style>` in `document.head`, once per document. Idempotent,\n * so an app free to call it itself (or to load `reset.css` through its own bundler instead, and\n * pass `injectReset: false` to `mount`) never ends up with the rule twice.\n */\nexport function injectResetStylesheet(document: Document): void {\n injectStyle(document, RESET_STYLE_ID, RESET_CSS);\n}\n\n/**\n * The same for an island inside someone else's page: `ISLAND_RESET_CSS`, which leaves the host's\n * `html` and `body` alone. Its own id, so it sits beside a full reset if the page has both kinds.\n */\nexport function injectIslandResetStylesheet(document: Document): void {\n injectStyle(document, ISLAND_RESET_STYLE_ID, ISLAND_RESET_CSS);\n}\n\nfunction injectStyle(document: Document, id: string, css: string): void {\n if (document.getElementById(id)) return;\n const style = document.createElement('style');\n style.id = id;\n // In Tailwind's `base` layer, below every utility, as `@import '@ng-native/web/reset.css'\n // layer(base)` puts it. Injected unlayered after the app's stylesheet, a reset rule is as\n // specific as a class and later, so it beat `border-2`, `flex-row` and `hidden` alike. With no\n // Tailwind on the page, a layered rule still loses to every unlayered one, as a reset should.\n style.textContent = `@layer base {\\n${css}\\n}`;\n // First in the head: a layer is ordered by where it is first declared, and the documented entry\n // (theme.css and utilities.css) declares no `base`. Declared after it, `base` came after\n // `utilities` and beat every utility again.\n document.head.insertBefore(style, document.head.firstChild);\n}\n\nexport interface MountOptions {\n readonly providers?: (Provider | EnvironmentProviders)[];\n /**\n * The component's inputs, by their public name, set before its first render - so an\n * `input.required()` has its value from the start rather than throwing on the first check.\n * Change them afterwards with `componentRef.setInput`.\n */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * Injects the reset stylesheet into `document.head` before mounting. Defaults to `true`. With\n * `injector` it is the island reset, which leaves the host page's `html` and `body` alone.\n */\n readonly injectReset?: boolean;\n /**\n * Mount inside an existing Angular app instead of as an app of its own: pass an injector from\n * that app - `inject(Injector)` in the component that owns `rootElement` is the usual one.\n *\n * The island then shares the host app's services (anything `providedIn: 'root'`, and anything\n * its `bootstrapApplication` or a component above it provides) and is checked by the host's\n * change detection. Only what the island has to render differently is its own: the renderer,\n * the engine, and the device services that read the browser rather than a phone. See\n * `packages/web/islands.md` in the documentation.\n */\n readonly injector?: Injector;\n /**\n * Keeps a `dark` class on `rootElement` in step with `ColorScheme`, which is what\n * `@ng-native/tailwind`'s `dark:` variant and a theme's `.dark` block match beneath: the system's\n * `prefers-color-scheme`, or what `ColorScheme.set()` chose over it. Defaults to `true`, as\n * `watchConditions` does on a device. An app that puts `dark` on its own root view turns it off.\n */\n readonly darkClass?: boolean;\n}\n\nexport interface MountResult {\n readonly componentRef: ComponentRef<unknown>;\n /** The island's own app, or with `injector` the host app it was mounted into. */\n readonly applicationRef: ApplicationRef;\n readonly factory: BrowserRendererFactory;\n readonly engine: BrowserEngine;\n /**\n * Takes the island down: its component, and whatever it owns. With `injector` that is only the\n * island - the host app it was mounted into keeps running - so call this rather than\n * `applicationRef.destroy()`, which there would destroy the host.\n */\n destroy(): void;\n}\n\nexport function mount(\n rootElement: Element,\n component: Type<unknown>,\n options: MountOptions = {},\n): MountResult {\n const {\n providers: extraProviders = [],\n inputs = {},\n injectReset = true,\n injector: host,\n darkClass = true,\n } = options;\n const document = rootElement.ownerDocument;\n if (injectReset) {\n if (host) injectIslandResetStylesheet(document);\n else injectResetStylesheet(document);\n }\n // What `reset.css` hangs the root's height off. Stamped rather than required of the app,\n // because an app that forgot it would get a page whose `flex: 1` silently resolved to zero.\n rootElement.setAttribute('data-rn-root', '');\n // What `@ng-native/tailwind`'s `web:` variant matches beneath, as `platform-ios` does on a phone.\n rootElement.classList.add('platform-web');\n\n const engine = new BrowserEngine(document);\n const factory = new BrowserRendererFactory(engine, document);\n // `wrapRoot` marks the element `ngSkipHydration`; an island gives back what it had on unmount.\n const skipHydration = rootElement.getAttribute('ngSkipHydration');\n const rootNode = engine.wrapRoot(rootElement) as unknown as Element;\n const own = hostProviders(engine, factory, document.defaultView);\n\n const mounted = host\n ? mountInside(\n host,\n rootElement,\n rootNode,\n component,\n [...own, ...extraProviders],\n inputs,\n {\n factory,\n engine,\n },\n skipHydration,\n )\n : mountAlone(rootNode, component, [...own, ...extraProviders], inputs, document, {\n factory,\n engine,\n });\n // The engine listens on the whole document, so it has to stop once its app is gone, however\n // the app went: through `destroy()` or straight through the component ref.\n mounted.componentRef.onDestroy(() => engine.dispose());\n if (darkClass) keepDarkClass(rootElement, mounted.componentRef);\n return mounted;\n}\n\n/** The `darkClass` option: the class now, and again whenever `ColorScheme` changes. */\nfunction keepDarkClass(rootElement: Element, componentRef: ComponentRef<unknown>): void {\n const scheme = componentRef.injector.get(ColorScheme);\n const apply = () => rootElement.classList.toggle('dark', scheme.current() === 'dark');\n apply();\n effect(apply, { injector: componentRef.injector });\n componentRef.onDestroy(() => rootElement.classList.remove('dark'));\n}\n\n/**\n * What an island has to have of its own, whichever way it is mounted: the renderer and engine\n * that turn `<view>` into a `<div>`, and the device capabilities answered by the browser.\n */\nfunction hostProviders(\n engine: BrowserEngine,\n factory: BrowserRendererFactory,\n view: Document['defaultView'],\n): (Provider | EnvironmentProviders)[] {\n return [\n { provide: RendererFactory2, useValue: factory },\n // The one seam the shared packages inject. See the file doc for why `Engine` itself is not\n // also provided here.\n { provide: HostEngine, useValue: engine },\n // The device capabilities, from the browser rather than from React Native. Without these\n // `Screen` falls back to its off-device answer of a zero-sized window, and every component\n // that branches on `compact()` takes the phone tree. See `device-sources.ts`.\n ...(view\n ? [\n { provide: Screen.SOURCE, useValue: browserScreenSource(view) },\n { provide: ColorScheme.SOURCE, useValue: browserColorSchemeSource(view) },\n { provide: Direction.SOURCE, useValue: browserDirectionSource(view) },\n ]\n : []),\n // The engine renders as iOS here, so the off-device fallback would say iOS too.\n { provide: OS, useValue: 'web' },\n // A tab has no hardware back button, so this is the same inert fallback\n // `hardwareBackSource()`'s own off-device branch answers with, provided here so the browser\n // host says so itself rather than relying on that branch.\n { provide: HardwareBack.SOURCE, useValue: { subscribe: () => () => {} } },\n // A tab has no status bar either.\n {\n provide: StatusBar.SOURCE,\n useValue: {\n setStyle: () => {},\n setHidden: () => {},\n setBackgroundColor: () => {},\n setTranslucent: () => {},\n height: undefined,\n },\n },\n ];\n}\n\n/** An app of its own: its own root injector, change detection and `ApplicationRef`. */\nfunction mountAlone(\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n document: Document,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n): MountResult {\n // Parent the app injector to the platform injector, exactly as `internalCreateApplication`\n // does and `mount()` documents: some Angular services are `providedIn: 'platform'`, and with a\n // null parent they simply do not exist.\n const platformInjector = createOrReusePlatformInjector();\n\n const injector = createEnvironmentInjector(\n [\n { provide: INJECTOR_SCOPE, useValue: 'root' },\n provideZonelessChangeDetectionInternal(),\n { provide: DOCUMENT, useValue: document },\n // A DOM is what this is running in, so libraries that check isPlatformBrowser() are right to\n // use it. An island inside an app is the app's own and inherits its value instead.\n { provide: PLATFORM_ID, useValue: 'browser' },\n { provide: ErrorHandler, useClass: ErrorHandler },\n ...providers,\n ],\n platformInjector as EnvironmentInjector,\n );\n runInitializers(injector);\n setLocaleId(injector.get(LOCALE_ID) || 'en-US');\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n const applicationRef = injector.get(ApplicationRef);\n\n // Mirrors `ApplicationRef.bootstrap()`, which is not used directly because it wants a DOM\n // selector rather than an element `mount`'s own caller already resolved.\n applicationRef.componentTypes.push(component);\n applicationRef.attachView(componentRef.hostView);\n applicationRef.tick();\n // Load-bearing, not bookkeeping: the router's bootstrap listener returns early unless the ref\n // it is handed is `ApplicationRef.components[0]`.\n applicationRef.components.push(componentRef);\n componentRef.onDestroy(() => {\n applicationRef.detachView(componentRef.hostView);\n const at = applicationRef.components.indexOf(componentRef);\n if (at !== -1) applicationRef.components.splice(at, 1);\n });\n\n for (const listener of injector.get(APP_BOOTSTRAP_LISTENER, [])) {\n listener(componentRef);\n }\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n applicationRef.destroy();\n },\n };\n}\n\n/**\n * The app initializers, before the root component exists, as the native `mount()` runs them (see\n * its `runInitializers` for why through `ApplicationInitStatus`): a promise is started, not awaited,\n * and a failed one reaches the `ErrorHandler`. A copy, as this package cannot import the platform.\n */\nfunction runInitializers(injector: EnvironmentInjector): void {\n const status = injector.get(ApplicationInitStatus);\n (status as unknown as { runInitializers(): void }).runInitializers();\n status.donePromise.catch((error: unknown) => injector.get(ErrorHandler).handleError(error));\n}\n\n/**\n * An island inside a running app. Its environment injector is a child of the host's, without a\n * root scope of its own, so anything it does not provide - a `providedIn: 'root'` service, the\n * host's `ApplicationRef` and scheduler, its `ErrorHandler` - resolves from the host, once, for\n * both. What it does provide is only what has to differ: the renderer and engine, the browser's\n * device sources, and the five device services that read them. Those five are provided here as\n * classes so they are built in the island, against its sources, rather than in the host's root\n * against the phone defaults.\n *\n * The host's element injector goes in too, so a service a component above the island provides\n * is visible to it as well as one the app does.\n */\nfunction mountInside(\n hostInjector: Injector,\n rootElement: Element,\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n skipHydration: string | null,\n): MountResult {\n const injector = createEnvironmentInjector(\n [Screen, ColorScheme, Direction, HardwareBack, StatusBar, ...providers],\n hostInjector.get(EnvironmentInjector),\n );\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n elementInjector: hostInjector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n // The host's own change detection checks the island from here on, like any view of its own.\n const applicationRef = hostInjector.get(ApplicationRef);\n applicationRef.attachView(componentRef.hostView);\n componentRef.changeDetectorRef.detectChanges();\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n injector.destroy();\n rootElement.removeAttribute('data-rn-root');\n if (skipHydration === null) rootElement.removeAttribute('ngSkipHydration');\n else rootElement.setAttribute('ngSkipHydration', skipHydration);\n rootElement.classList.remove('platform-web');\n },\n };\n}\n\nfunction setInputs(componentRef: ComponentRef<unknown>, inputs: Readonly<Record<string, unknown>>) {\n for (const [name, value] of Object.entries(inputs)) componentRef.setInput(name, value);\n}\n\n/**\n * Tells Angular's i18n runtime the app's locale, on Angular 22.2 and earlier, which keep it in a\n * global. 22.3 removed that global and each view reads `LOCALE_ID` from its injector. A named import\n * of the removed export fails a Vite build and is undefined under Metro; a namespace member read in\n * place is undefined (Vite warns) and still tree-shakes.\n */\nfunction setLocaleId(id: string): void {\n (core as { ɵsetLocaleId?: (id: string) => void }).ɵsetLocaleId?.(id);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/web",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "A browser host for Angular Native: the same components, rendered into the DOM instead of native views.",
5
5
  "keywords": [
6
6
  "angular",
@@ -35,8 +35,8 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@ng-native/device": "0.24.0",
39
- "@ng-native/fabric": "0.24.0",
38
+ "@ng-native/device": "0.26.0",
39
+ "@ng-native/fabric": "0.26.0",
40
40
  "@oxc-angular/vite": "0.0.41"
41
41
  },
42
42
  "peerDependencies": {
@@ -54,11 +54,11 @@
54
54
  "@angular/localize": "22.2.0",
55
55
  "@angular/platform-browser": "22.2.0",
56
56
  "@ng-icons/core": "^36.0.0",
57
- "@ng-native/components": "0.24.0",
58
- "@ng-native/icons": "0.24.0",
59
- "@ng-native/metro": "0.24.0",
60
- "@ng-native/tailwind": "0.24.0",
61
- "@ng-native/testing": "0.24.0",
57
+ "@ng-native/components": "0.26.0",
58
+ "@ng-native/icons": "0.26.0",
59
+ "@ng-native/metro": "0.26.0",
60
+ "@ng-native/tailwind": "0.26.0",
61
+ "@ng-native/testing": "0.26.0",
62
62
  "@tailwindcss/vite": "^4.3.3",
63
63
  "@types/jsdom": "^27.0.0",
64
64
  "@vitest/browser": "^5.0.2",