ember-nativescript 0.1.2 → 0.2.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.
Files changed (65) hide show
  1. package/README.md +11 -3
  2. package/dist/components/Platform.d.ts +7 -0
  3. package/dist/components/Platform.d.ts.map +1 -1
  4. package/dist/components/Platform.js +9 -2
  5. package/dist/components/Platform.js.map +1 -1
  6. package/dist/src/adapter.d.ts +3 -2
  7. package/dist/src/adapter.d.ts.map +1 -1
  8. package/dist/src/dom.js +1 -1
  9. package/dist/src/dom.js.map +1 -1
  10. package/dist/src/index.d.ts +2 -2
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/index.js +3 -3
  13. package/dist/src/navigator.d.ts +6 -0
  14. package/dist/src/navigator.d.ts.map +1 -1
  15. package/dist/src/navigator.js +6 -1
  16. package/dist/src/navigator.js.map +1 -1
  17. package/dist/src/platform.d.ts +4 -2
  18. package/dist/src/platform.d.ts.map +1 -1
  19. package/dist/src/platform.js +2 -1
  20. package/dist/src/platform.js.map +1 -1
  21. package/dist/src/render.d.ts.map +1 -1
  22. package/dist/src/render.js.map +1 -1
  23. package/dist/src/vite-web.d.ts +5 -0
  24. package/dist/src/vite-web.d.ts.map +1 -0
  25. package/dist/src/vite-web.js +41 -0
  26. package/dist/src/vite-web.js.map +1 -0
  27. package/dist/src/vite.d.ts.map +1 -1
  28. package/dist/src/vite.js +4 -1
  29. package/dist/src/vite.js.map +1 -1
  30. package/dist/src/vitest.d.ts.map +1 -1
  31. package/dist/src/vitest.js +1 -0
  32. package/dist/src/vitest.js.map +1 -1
  33. package/dist/src/web-adapter.d.ts +31 -0
  34. package/dist/src/web-adapter.d.ts.map +1 -0
  35. package/dist/src/web-adapter.js +701 -0
  36. package/dist/src/web-adapter.js.map +1 -0
  37. package/dist/src/web-app.d.ts +23 -0
  38. package/dist/src/web-app.d.ts.map +1 -0
  39. package/dist/src/web-app.js +53 -0
  40. package/dist/src/web-app.js.map +1 -0
  41. package/dist/src/web-core.d.ts +56 -0
  42. package/dist/src/web-core.d.ts.map +1 -0
  43. package/dist/src/web-core.js +84 -0
  44. package/dist/src/web-core.js.map +1 -0
  45. package/dist/src/web-css.d.ts +7 -0
  46. package/dist/src/web-css.d.ts.map +1 -0
  47. package/dist/src/web-css.js +118 -0
  48. package/dist/src/web-css.js.map +1 -0
  49. package/dist/src/web-host.d.ts +18 -0
  50. package/dist/src/web-host.d.ts.map +1 -0
  51. package/dist/src/web-host.js +165 -0
  52. package/dist/src/web-host.js.map +1 -0
  53. package/dist/src/web-router.d.ts +51 -0
  54. package/dist/src/web-router.d.ts.map +1 -0
  55. package/dist/src/web-router.js +83 -0
  56. package/dist/src/web-router.js.map +1 -0
  57. package/dist/src/web-styles.d.ts +4 -0
  58. package/dist/src/web-styles.d.ts.map +1 -0
  59. package/dist/src/web-styles.js +157 -0
  60. package/dist/src/web-styles.js.map +1 -0
  61. package/dist/src/web.d.ts +7 -0
  62. package/dist/src/web.d.ts.map +1 -0
  63. package/dist/src/web.js +7 -0
  64. package/dist/types/glint.d.ts +6 -1
  65. package/package.json +26 -16
package/README.md CHANGED
@@ -26,11 +26,17 @@ export default class Home extends Component<{ Args: { nav: Navigator } }> {
26
26
  }
27
27
  ```
28
28
 
29
- **Status:** early (0.1). Everything below is tested in Node against an in-memory toolkit, typechecked against
29
+ **Docs:** https://betocantu93.github.io/ember-nativescript/
30
+
31
+ **Status:** early (0.2). Everything below is tested in Node against an in-memory toolkit, typechecked against
30
32
  @nativescript/core, and bundles for both platforms with @nativescript/vite. On iOS it runs: the demo on the simulator,
31
33
  and Pace (`run/`: MapKit, the GPS, animations, navigation) on an iPhone. Android hasn't run yet, nor a release build;
32
34
  see [Proven and unverified](#proven-and-unverified).
33
35
 
36
+ **In a browser, too (experimental):** the same screens on HTML elements, each at its own URL, with the browser's back
37
+ button as back: `npm run web` in an app from the template. For links, demos and previews; native code needs a
38
+ `__WEB__` branch. See [In a browser](https://betocantu93.github.io/ember-nativescript/guide/web).
39
+
34
40
  ## Start an app
35
41
 
36
42
  ```bash
@@ -345,8 +351,10 @@ refuse. `pnpm build` writes `dist/` (JavaScript, declarations, the Glint types).
345
351
  `pnpm test` also runs the template's tests against this source, and `pnpm typecheck` checks the template, so a
346
352
  change that breaks a new app fails here.
347
353
 
348
- To publish a version, raise `version` in both package.json files (the root and `template/`, whose `ember-nativescript`
349
- range follows it), add it to CHANGELOG.md, then publish the package before the template, which depends on it:
354
+ To publish a version, raise `version` in the root package.json and the `ember-nativescript` range in
355
+ `template/package.json`, add it to CHANGELOG.md, then publish the package before the template, which depends on it. The
356
+ template's own version follows NativeScript's major (9.x), as NativeScript's templates do: `ns create --template` without
357
+ a version asks for `^<CLI major>.0.0`.
350
358
 
351
359
  ```bash
352
360
  npm publish
@@ -17,5 +17,12 @@ export declare const Android: import("@ember/component/template-only").TemplateO
17
17
  };
18
18
  };
19
19
  }>, unknown>> & import("@glint/template/-private/integration").HasContext<import("@glint/ember-tsc/types").ComponentContext<null, Signature>>);
20
+ export declare const Web: import("@ember/component/template-only").TemplateOnlyComponent<never> & (abstract new () => import("@glint/template/-private/integration").InvokableInstance<() => import("@glint/template/-private/integration").ComponentReturn<import("@glint/template/-private/integration").FlattenBlockParams<{
21
+ default: {
22
+ Params: {
23
+ Positional: [];
24
+ };
25
+ };
26
+ }>, unknown>> & import("@glint/template/-private/integration").HasContext<import("@glint/ember-tsc/types").ComponentContext<null, Signature>>);
20
27
  export {};
21
28
  //# sourceMappingURL=Platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../components/Platform.gts"],"names":[],"mappings":"AAQA,UAAU,SAAS;IACjB,MAAM,EAAE;QAAE,OAAO,EAAE,EAAE,CAAA;KAAE,CAAC;CACzB;AAED,eAAO,MAAM,GAAG;;;;;;8IAAgF,CAAC;AACjG,eAAO,MAAM,OAAO;;;;;;8IAAoF,CAAC"}
1
+ {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../components/Platform.gts"],"names":[],"mappings":"AAQA,UAAU,SAAS;IACjB,MAAM,EAAE;QAAE,OAAO,EAAE,EAAE,CAAA;KAAE,CAAC;CACzB;AAED,eAAO,MAAM,GAAG;;;;;;8IAAgF,CAAC;AACjG,eAAO,MAAM,OAAO;;;;;;8IAAoF,CAAC;AACzG,eAAO,MAAM,GAAG;;;;;;8IAAgF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { isAndroid, isIOS } from "../src/platform.js";
1
+ import { isAndroid, isIOS, isWeb } from "../src/platform.js";
2
2
  import { setComponentTemplate } from "@ember/component";
3
3
  import { createTemplateFactory } from "@ember/template-factory";
4
4
  import templateOnly from "@ember/component/template-only";
@@ -17,6 +17,13 @@ var Android = setComponentTemplate(createTemplateFactory({
17
17
  "scope": () => ({ isAndroid }),
18
18
  "isStrictMode": true
19
19
  }), templateOnly());
20
- export { Android, IOS };
20
+ var Web = setComponentTemplate(createTemplateFactory({
21
+ "id": null,
22
+ "block": "[[[41,[28,[32,0],null,null],[[[18,1,null]],[]],null]],[\"&default\"],[\"if\",\"yield\"]]",
23
+ "moduleName": "(unknown template module)",
24
+ "scope": () => ({ isWeb }),
25
+ "isStrictMode": true
26
+ }), templateOnly());
27
+ export { Android, IOS, Web };
21
28
 
22
29
  //# sourceMappingURL=Platform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.js","names":["isAndroid","isIOS","setComponentTemplate","createTemplateFactory","templateOnly","IOS","Android"],"sources":["../../components/Platform.gts"],"sourcesContent":["// What only one platform shows, like NativeScript-Vue's <ios> and <android> blocks:\n//\n// <IOS><label text='Swipe down to close' /></IOS>\n// <Android><button text='Close' {{on 'tap' @closeModal}} /></Android>\nimport type { TOC } from '@ember/component/template-only';\n\nimport { isAndroid, isIOS } from '../src/platform.ts';\n\ninterface Signature {\n Blocks: { default: [] };\n}\n\nexport const IOS = <template>{{#if (isIOS)}}{{yield}}{{/if}}</template> satisfies TOC<Signature>;\nexport const Android = <template>{{#if (isAndroid)}}{{yield}}{{/if}}</template> satisfies TOC<Signature>;\n"],"mappings":";;;;;AAYA,IAAaK,MAAAH,qBAAAC,sBAAA;CAAA,MAAA;CAAA,SAAA;CAAA,cAAA;CAAA,gBAAA,EAAAF,MAAA;CAAA,gBAAA;AAAA,CAAA,GAAAG,aAAA,CAAA;AACb,IAAaE,UAAAJ,qBAAAC,sBAAA;CAAA,MAAA;CAAA,SAAA;CAAA,cAAA;CAAA,gBAAA,EAAAH,UAAA;CAAA,gBAAA;AAAA,CAAA,GAAAI,aAAA,CAAA"}
1
+ {"version":3,"file":"Platform.js","names":["isAndroid","isIOS","isWeb","setComponentTemplate","createTemplateFactory","templateOnly","IOS","Android","Web"],"sources":["../../components/Platform.gts"],"sourcesContent":["// What only one platform shows, like NativeScript-Vue's <ios> and <android> blocks (and <Web> for the browser):\n//\n// <IOS><label text='Swipe down to close' /></IOS>\n// <Android><button text='Close' {{on 'tap' @closeModal}} /></Android>\nimport type { TOC } from '@ember/component/template-only';\n\nimport { isAndroid, isIOS, isWeb } from '../src/platform.ts';\n\ninterface Signature {\n Blocks: { default: [] };\n}\n\nexport const IOS = <template>{{#if (isIOS)}}{{yield}}{{/if}}</template> satisfies TOC<Signature>;\nexport const Android = <template>{{#if (isAndroid)}}{{yield}}{{/if}}</template> satisfies TOC<Signature>;\nexport const Web = <template>{{#if (isWeb)}}{{yield}}{{/if}}</template> satisfies TOC<Signature>;\n"],"mappings":";;;;;AAYA,IAAaM,MAAAH,qBAAAC,sBAAA;CAAA,MAAA;CAAA,SAAA;CAAA,cAAA;CAAA,gBAAA,EAAAH,MAAA;CAAA,gBAAA;AAAA,CAAA,GAAAI,aAAA,CAAA;AACb,IAAaE,UAAAJ,qBAAAC,sBAAA;CAAA,MAAA;CAAA,SAAA;CAAA,cAAA;CAAA,gBAAA,EAAAJ,UAAA;CAAA,gBAAA;AAAA,CAAA,GAAAK,aAAA,CAAA;AACb,IAAaG,MAAAL,qBAAAC,sBAAA;CAAA,MAAA;CAAA,SAAA;CAAA,cAAA;CAAA,gBAAA,EAAAF,MAAA;CAAA,gBAAA;AAAA,CAAA,GAAAG,aAAA,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import type { FrameHost } from './navigator.js';
2
+ import type { Platform } from './platform.js';
2
3
  export type Listener = (data: unknown) => void;
3
4
  /** A list view's rows, for {@link NativeAdapter.bindList}. */
4
5
  export interface ListOptions {
@@ -28,8 +29,8 @@ export interface NativeAdapter<View = unknown> {
28
29
  hasProperty?(view: View, name: string): boolean;
29
30
  /** Whether text children of this view become its `text` property (labels, buttons, text fields). */
30
31
  takesText(view: View): boolean;
31
- /** Which platform the views are for, for `ios:` and `android:` attributes and the isIOS/isAndroid helpers. */
32
- readonly platform?: 'ios' | 'android';
32
+ /** Which platform the views are for, for `ios:`, `android:` and `web:` attributes and the isIOS/isAndroid helpers. */
33
+ readonly platform?: Platform;
33
34
  /** Puts `child` at `index` among the views `parent` holds. */
34
35
  insertChild(parent: View, child: View, index: number): void;
35
36
  removeChild(parent: View, child: View): void;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;AAE/C,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,6GAA6G;IAC7G,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,uCAAuC;IACvC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8BAA8B;IAC9B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,aAA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AAW,GAAG,WAAW,GAAG,IAAI,CAAC;CAClH"}
package/dist/src/dom.js CHANGED
@@ -221,7 +221,7 @@ var NativeElement = class NativeElement extends NativeParent {
221
221
  return unsupported("insertAdjacentHTML (a triple-curly {{{html}}} or htmlSafe string)");
222
222
  }
223
223
  #forThisPlatform(name) {
224
- const match = /^(ios|android):(.+)$/.exec(name);
224
+ const match = /^(ios|android|web):(.+)$/.exec(name);
225
225
  if (!match) return name;
226
226
  return match[1] === this.#adapter.platform ? match[2] : void 0;
227
227
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","names":[],"sources":["../../src/dom.ts"],"sourcesContent":["// A minimal DOM for Glimmer whose elements are native views. Glimmer builds and updates a tree of\n// elements, text nodes and comments through a small part of the DOM API; this file implements that part\n// and mirrors every change onto views through a NativeAdapter.\n//\n// - An element gets a view from the adapter by its tag. Its element children with views become the\n// view's children, in order; comments, text nodes and elements without views are skipped when the\n// native index is worked out.\n// - Text children of a view that takes text (label, button, textField) become its `text` property.\n// Text anywhere else has no native counterpart and is dropped (`droppedText` counts it).\n// - Some children go into a property of their parent instead (a page's ActionBar, a label's FormattedString): see\n// elements.ts.\n// - `ios:` and `android:` attributes only apply on that platform, as in NativeScript's XML.\n// - Attributes become view properties: a static attribute as the string it is, as NativeScript's XML assigns it, and\n// a dynamic one as its value (an array of items, a Date, an image), the way Vue and React set props.\n// - Event listeners become view listeners.\n// - What a native toolkit can't do (HTML strings, SVG) throws with a message instead of half-working.\n\nimport type { Listener, NativeAdapter } from './adapter.ts';\nimport { type Slot, slotFor } from './elements.ts';\n\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const COMMENT_NODE = 8;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\n\nexport const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n\nconst unsupported = (what: string): never => {\n throw new Error(`[ember-nativescript] ${what} has no native counterpart.`);\n};\n\nexport abstract class NativeNode {\n abstract readonly nodeType: number;\n parentNode: NativeParent | null = null;\n previousSibling: NativeNode | null = null;\n nextSibling: NativeNode | null = null;\n\n constructor(readonly ownerDocument: NativeDocument) {}\n\n get parentElement(): NativeElement | null {\n return this.parentNode instanceof NativeElement ? this.parentNode : null;\n }\n\n abstract get nodeName(): string;\n}\n\nabstract class NativeParent extends NativeNode {\n firstChild: NativeNode | null = null;\n lastChild: NativeNode | null = null;\n\n get childNodes(): NativeNode[] {\n const nodes: NativeNode[] = [];\n for (let node = this.firstChild; node; node = node.nextSibling) nodes.push(node);\n return nodes;\n }\n\n appendChild<T extends NativeNode>(node: T): T {\n return this.insertBefore(node, null);\n }\n\n insertBefore<T extends NativeNode>(node: T, reference: NativeNode | null): T {\n if (node instanceof NativeFragment) {\n for (let child = node.firstChild; child;) {\n const next = child.nextSibling;\n this.insertBefore(child, reference);\n child = next;\n }\n return node;\n }\n\n if (reference && reference.parentNode !== this) {\n throw new Error('[ember-nativescript] insertBefore: the reference node is not a child of this node.');\n }\n\n node.parentNode?.removeChild(node);\n\n const previous = reference ? reference.previousSibling : this.lastChild;\n node.parentNode = this;\n node.previousSibling = previous;\n node.nextSibling = reference;\n if (previous) previous.nextSibling = node;\n else this.firstChild = node;\n if (reference) reference.previousSibling = node;\n else this.lastChild = node;\n\n this.childInserted(node);\n return node;\n }\n\n removeChild<T extends NativeNode>(node: T): T {\n if (node.parentNode !== this) {\n throw new Error('[ember-nativescript] removeChild: the node is not a child of this node.');\n }\n\n this.childRemoving(node);\n\n if (node.previousSibling) node.previousSibling.nextSibling = node.nextSibling;\n else this.firstChild = node.nextSibling;\n if (node.nextSibling) node.nextSibling.previousSibling = node.previousSibling;\n else this.lastChild = node.previousSibling;\n node.parentNode = node.previousSibling = node.nextSibling = null;\n\n this.childRemoved(node);\n return node;\n }\n\n protected childInserted(_node: NativeNode): void {}\n protected childRemoving(_node: NativeNode): void {}\n protected childRemoved(_node: NativeNode): void {}\n}\n\nexport class NativeText extends NativeNode {\n readonly nodeType = TEXT_NODE;\n #data: string;\n\n constructor(document: NativeDocument, data: string) {\n super(document);\n this.#data = data;\n }\n\n get nodeName(): string {\n return '#text';\n }\n\n get nodeValue(): string {\n return this.#data;\n }\n\n // Glimmer updates dynamic text by assigning nodeValue.\n set nodeValue(value: string) {\n this.#data = value;\n this.parentElement?.syncText();\n }\n\n get data(): string {\n return this.#data;\n }\n\n set data(value: string) {\n this.nodeValue = value;\n }\n\n get textContent(): string {\n return this.#data;\n }\n}\n\nexport class NativeComment extends NativeNode {\n readonly nodeType = COMMENT_NODE;\n\n constructor(\n document: NativeDocument,\n public nodeValue: string,\n ) {\n super(document);\n }\n\n get nodeName(): string {\n return '#comment';\n }\n}\n\nexport class NativeFragment extends NativeParent {\n readonly nodeType = DOCUMENT_FRAGMENT_NODE;\n\n get nodeName(): string {\n return '#document-fragment';\n }\n}\n\nexport class NativeElement extends NativeParent {\n readonly nodeType = ELEMENT_NODE;\n readonly namespaceURI = HTML_NAMESPACE;\n readonly attributes = new Map<string, string>();\n /** Values set as properties, as they are: what dynamic attributes such as `items={{this.list}}` assigned. */\n readonly properties = new Map<string, unknown>();\n readonly view: unknown;\n readonly #listeners = new Map<string, Map<Listener, Listener>>();\n #text: string | undefined;\n\n constructor(\n document: NativeDocument,\n readonly localName: string,\n view?: unknown,\n ) {\n super(document);\n this.view = view === undefined ? document.adapter.createView(localName) : view;\n if (this.view) exposeViewProperties(this);\n }\n\n get tagName(): string {\n return this.localName.toUpperCase();\n }\n\n get nodeName(): string {\n return this.tagName;\n }\n\n // Ember's development build of {{on}} names the element in its errors with these.\n get id(): string {\n return this.attributes.get('id') ?? '';\n }\n\n // Glimmer sets a dynamic attribute as a property when `name in element`, which a getter makes true.\n set id(value: string) {\n this.setAttribute('id', value);\n }\n\n get classList(): string[] {\n return (this.attributes.get('class') ?? '').split(/\\s+/).filter(Boolean);\n }\n\n get #adapter(): NativeAdapter {\n return this.ownerDocument.adapter;\n }\n\n getAttribute(name: string): string | null {\n return this.attributes.get(name) ?? null;\n }\n\n hasAttribute(name: string): boolean {\n return this.attributes.has(name);\n }\n\n setAttribute(name: string, value: string): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.setAttribute(local, value);\n const string = String(value);\n this.attributes.set(name, string);\n this.properties.delete(name);\n if (this.view) this.#adapter.setProperty(this.view, name, string);\n }\n\n removeAttribute(name: string): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.removeAttribute(local);\n this.attributes.delete(name);\n this.properties.delete(name);\n if (this.view) this.#adapter.setProperty(this.view, name, null);\n }\n\n /** Sets a view property to a value as it is. Glimmer does this for dynamic attributes, through `element[name] = value`. */\n setProperty(name: string, value: unknown): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.setProperty(local, value);\n if (value === null || value === undefined) {\n this.attributes.delete(name);\n this.properties.delete(name);\n } else {\n this.properties.set(name, value);\n if (typeof value === 'object' || typeof value === 'function') this.attributes.delete(name);\n else this.attributes.set(name, String(value));\n }\n\n if (this.view) this.#adapter.setProperty(this.view, name, value ?? null);\n }\n\n // Glimmer only uses namespaced attributes for SVG and xlink.\n setAttributeNS(namespace: string | null, name: string, value: string): void {\n if (namespace) unsupported(`The attribute ${name} in namespace ${namespace}`);\n this.setAttribute(name, value);\n }\n\n removeAttributeNS(_namespace: string | null, name: string): void {\n this.removeAttribute(name);\n }\n\n addEventListener(event: string, listener: Listener | { handleEvent: Listener }): void {\n let byListener = this.#listeners.get(event);\n if (!byListener) this.#listeners.set(event, (byListener = new Map()));\n if (byListener.has(listener as Listener)) return;\n\n const handle: Listener =\n typeof listener === 'function' ? listener : (data) => (listener as { handleEvent: Listener }).handleEvent(data);\n // As on the web, the handler can tell which element it was added on.\n const call: Listener = (data) => {\n if (data !== null && typeof data === 'object') (data as { currentTarget?: unknown }).currentTarget = this;\n handle(data);\n };\n byListener.set(listener as Listener, call);\n if (this.view) this.#adapter.on(this.view, event, call);\n }\n\n removeEventListener(event: string, listener: Listener): void {\n const call = this.#listeners.get(event)?.get(listener);\n if (!call) return;\n\n this.#listeners.get(event)!.delete(listener);\n if (this.view) this.#adapter.off(this.view, event, call);\n }\n\n /** How many listeners the element holds, for tests that check clean-up. */\n get listenerCount(): number {\n let count = 0;\n for (const byListener of this.#listeners.values()) count += byListener.size;\n return count;\n }\n\n get textContent(): string {\n return this.childNodes.map((node) => (node as { textContent?: string }).textContent ?? '').join('');\n }\n\n // `renderComponent` clears its target the first time; nothing else may be assigned.\n set innerHTML(html: string) {\n if (html !== '') unsupported('Setting innerHTML (a triple-curly {{{html}}} or htmlSafe string)');\n while (this.firstChild) this.removeChild(this.firstChild);\n }\n\n insertAdjacentHTML(): never {\n return unsupported('insertAdjacentHTML (a triple-curly {{{html}}} or htmlSafe string)');\n }\n\n // `ios:title` is `title` on iOS and nothing on Android, and the other way round.\n #forThisPlatform(name: string): string | undefined {\n const match = /^(ios|android):(.+)$/.exec(name);\n if (!match) return name;\n return match[1] === this.#adapter.platform ? match[2] : undefined;\n }\n\n /** Recomputes the text property of a view that takes text from its text children. */\n syncText(): void {\n if (!this.view || !this.#adapter.takesText(this.view)) return;\n\n let text = '';\n for (let node = this.firstChild; node; node = node.nextSibling) {\n if (node instanceof NativeText) text += node.nodeValue;\n }\n\n if (text !== this.#text) {\n this.#text = text;\n this.#adapter.setProperty(this.view, 'text', text);\n }\n }\n\n protected override childInserted(node: NativeNode): void {\n if (node instanceof NativeText) {\n if (this.view && this.#adapter.takesText(this.view)) this.syncText();\n else if (node.nodeValue.trim()) this.ownerDocument.droppedText.push(node.nodeValue);\n return;\n }\n\n const slot = node instanceof NativeElement ? this.#slotOf(node) : undefined;\n\n if (slot && this.view && (node as NativeElement).view) {\n const child = (node as NativeElement).view;\n if (slot.list)\n this.#adapter.insertInSlot(this.view, slot.property, child, this.#indexIn(slot, node as NativeElement));\n else this.#adapter.setSlot(this.view, slot.property, child);\n } else if (node instanceof NativeElement && node.view && this.view) {\n this.#adapter.insertChild(this.view, node.view, this.#nativeIndexOf(node));\n } else if (node instanceof NativeElement && node.view && !this.view) {\n unsupported(`A <${node.localName}> inside <${this.localName}>, which has no view,`);\n }\n }\n\n protected override childRemoving(node: NativeNode): void {\n if (!(node instanceof NativeElement) || !node.view || !this.view) return;\n\n const slot = this.#slotOf(node);\n if (slot?.list) this.#adapter.removeFromSlot(this.view, slot.property, node.view);\n else if (slot) this.#adapter.setSlot(this.view, slot.property, null);\n else this.#adapter.removeChild(this.view, node.view);\n }\n\n protected override childRemoved(node: NativeNode): void {\n if (node instanceof NativeText) this.syncText();\n }\n\n #slotOf(child: NativeElement): Slot | undefined {\n return slotFor(this.localName, child.localName);\n }\n\n // Where a child view goes among its parent's views: children that went into a slot don't count.\n #nativeIndexOf(target: NativeElement): number {\n let index = 0;\n for (let node = this.firstChild; node && node !== target; node = node.nextSibling) {\n if (node instanceof NativeElement && node.view && !this.#slotOf(node)) index++;\n }\n return index;\n }\n\n // Where a child goes in a list slot: after the earlier children in the same slot.\n #indexIn(slot: Slot, target: NativeElement): number {\n let index = 0;\n for (let node = this.firstChild; node && node !== target; node = node.nextSibling) {\n if (node instanceof NativeElement && node.view && this.#slotOf(node)?.property === slot.property) index++;\n }\n return index;\n }\n}\n\n// Glimmer sets a dynamic attribute as a property when `name in element`, and otherwise turns its value into a string\n// for setAttribute. Each element with a view gets a prototype that answers `in` for the properties its view has\n// (adapter.hasProperty) and sends assignments to them to setProperty, so `items={{this.contacts}}` reaches a\n// ListPicker as an array. It's a proxy in the prototype chain rather than around the element, which would break the\n// element's private fields; it only sees names the element itself doesn't have.\nfunction exposeViewProperties(element: NativeElement): void {\n const { view } = element;\n const adapter = element.ownerDocument.adapter;\n const isViewProperty = (target: object, key: string | symbol): key is string =>\n typeof key === 'string' && !Reflect.has(target, key) && Boolean(adapter.hasProperty?.(view, key));\n\n Object.setPrototypeOf(\n element,\n new Proxy(NativeElement.prototype, {\n getPrototypeOf: () => NativeElement.prototype,\n has: (target, key) => Reflect.has(target, key) || isViewProperty(target, key),\n get(target, key, receiver) {\n return receiver === element && isViewProperty(target, key)\n ? element.properties.get(key)\n : Reflect.get(target, key, receiver);\n },\n set(target, key, value, receiver) {\n if (receiver !== element || !isViewProperty(target, key)) return Reflect.set(target, key, value, receiver);\n element.setProperty(key, value);\n return true;\n },\n }),\n );\n}\n\nexport class NativeDocument extends NativeParent {\n readonly nodeType = DOCUMENT_NODE;\n /** Text that landed outside a view that takes text, so nothing shows it. */\n readonly droppedText: string[] = [];\n\n constructor(readonly adapter: NativeAdapter) {\n super(undefined as unknown as NativeDocument);\n (this as { ownerDocument: NativeDocument }).ownerDocument = this;\n }\n\n get nodeName(): string {\n return '#document';\n }\n\n createElement(tag: string): NativeElement {\n return new NativeElement(this, tag);\n }\n\n createElementNS(namespace: string | null, tag: string): NativeElement {\n if (namespace && namespace !== HTML_NAMESPACE) unsupported(`<${tag}> in namespace ${namespace} (SVG or MathML)`);\n return this.createElement(tag);\n }\n\n /** An element for a view the toolkit made itself, such as a list's cell, so Glimmer can render into it. */\n adopt(view: unknown, tag = 'cell'): NativeElement {\n return new NativeElement(this, tag, view);\n }\n\n createTextNode(data: string): NativeText {\n return new NativeText(this, data);\n }\n\n createComment(data: string): NativeComment {\n return new NativeComment(this, data);\n }\n\n createDocumentFragment(): NativeFragment {\n return new NativeFragment(this);\n }\n}\n"],"mappings":";AA0BA,IAAa,iBAAiB;AAE9B,IAAM,eAAe,SAAwB;CAC3C,MAAM,IAAI,MAAM,wBAAwB,KAAK,4BAA4B;AAC3E;AAEA,IAAsB,aAAtB,MAAiC;CAMV;CAJrB,aAAkC;CAClC,kBAAqC;CACrC,cAAiC;CAEjC,YAAqB,eAA+B;EAA/B,KAAA,gBAAA;CAAgC;CAErD,IAAI,gBAAsC;EACxC,OAAO,KAAK,sBAAsB,gBAAgB,KAAK,aAAa;CACtE;AAGF;AAEA,IAAe,eAAf,cAAoC,WAAW;CAC7C,aAAgC;CAChC,YAA+B;CAE/B,IAAI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er whose elements are native views. Glimmer builds and updates a tree of\n// elements, text nodes and comments through a small part of the DOM API; this file implements that part\n// and mirrors every change onto views through a NativeAdapter.\n//\n// - An element gets a view from the adapter by its tag. Its element children with views become the\n// view's children, in order; comments, text nodes and elements without views are skipped when the\n// native index is worked out.\n// - Text children of a view that takes text (label, button, textField) become its `text` property.\n// Text anywhere else has no native counterpart and is dropped (`droppedText` counts it).\n// - Some children go into a property of their parent instead (a page's ActionBar, a label's FormattedString): see\n// elements.ts.\n// - `ios:`, `android:` and `web:` attributes only apply on that platform, as in NativeScript's XML.\n// - Attributes become view properties: a static attribute as the string it is, as NativeScript's XML assigns it, and\n// a dynamic one as its value (an array of items, a Date, an image), the way Vue and React set props.\n// - Event listeners become view listeners.\n// - What a native toolkit can't do (HTML strings, SVG) throws with a message instead of half-working.\n\nimport type { Listener, NativeAdapter } from './adapter.ts';\nimport { type Slot, slotFor } from './elements.ts';\n\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const COMMENT_NODE = 8;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\n\nexport const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n\nconst unsupported = (what: string): never => {\n throw new Error(`[ember-nativescript] ${what} has no native counterpart.`);\n};\n\nexport abstract class NativeNode {\n abstract readonly nodeType: number;\n parentNode: NativeParent | null = null;\n previousSibling: NativeNode | null = null;\n nextSibling: NativeNode | null = null;\n\n constructor(readonly ownerDocument: NativeDocument) {}\n\n get parentElement(): NativeElement | null {\n return this.parentNode instanceof NativeElement ? this.parentNode : null;\n }\n\n abstract get nodeName(): string;\n}\n\nabstract class NativeParent extends NativeNode {\n firstChild: NativeNode | null = null;\n lastChild: NativeNode | null = null;\n\n get childNodes(): NativeNode[] {\n const nodes: NativeNode[] = [];\n for (let node = this.firstChild; node; node = node.nextSibling) nodes.push(node);\n return nodes;\n }\n\n appendChild<T extends NativeNode>(node: T): T {\n return this.insertBefore(node, null);\n }\n\n insertBefore<T extends NativeNode>(node: T, reference: NativeNode | null): T {\n if (node instanceof NativeFragment) {\n for (let child = node.firstChild; child;) {\n const next = child.nextSibling;\n this.insertBefore(child, reference);\n child = next;\n }\n return node;\n }\n\n if (reference && reference.parentNode !== this) {\n throw new Error('[ember-nativescript] insertBefore: the reference node is not a child of this node.');\n }\n\n node.parentNode?.removeChild(node);\n\n const previous = reference ? reference.previousSibling : this.lastChild;\n node.parentNode = this;\n node.previousSibling = previous;\n node.nextSibling = reference;\n if (previous) previous.nextSibling = node;\n else this.firstChild = node;\n if (reference) reference.previousSibling = node;\n else this.lastChild = node;\n\n this.childInserted(node);\n return node;\n }\n\n removeChild<T extends NativeNode>(node: T): T {\n if (node.parentNode !== this) {\n throw new Error('[ember-nativescript] removeChild: the node is not a child of this node.');\n }\n\n this.childRemoving(node);\n\n if (node.previousSibling) node.previousSibling.nextSibling = node.nextSibling;\n else this.firstChild = node.nextSibling;\n if (node.nextSibling) node.nextSibling.previousSibling = node.previousSibling;\n else this.lastChild = node.previousSibling;\n node.parentNode = node.previousSibling = node.nextSibling = null;\n\n this.childRemoved(node);\n return node;\n }\n\n protected childInserted(_node: NativeNode): void {}\n protected childRemoving(_node: NativeNode): void {}\n protected childRemoved(_node: NativeNode): void {}\n}\n\nexport class NativeText extends NativeNode {\n readonly nodeType = TEXT_NODE;\n #data: string;\n\n constructor(document: NativeDocument, data: string) {\n super(document);\n this.#data = data;\n }\n\n get nodeName(): string {\n return '#text';\n }\n\n get nodeValue(): string {\n return this.#data;\n }\n\n // Glimmer updates dynamic text by assigning nodeValue.\n set nodeValue(value: string) {\n this.#data = value;\n this.parentElement?.syncText();\n }\n\n get data(): string {\n return this.#data;\n }\n\n set data(value: string) {\n this.nodeValue = value;\n }\n\n get textContent(): string {\n return this.#data;\n }\n}\n\nexport class NativeComment extends NativeNode {\n readonly nodeType = COMMENT_NODE;\n\n constructor(\n document: NativeDocument,\n public nodeValue: string,\n ) {\n super(document);\n }\n\n get nodeName(): string {\n return '#comment';\n }\n}\n\nexport class NativeFragment extends NativeParent {\n readonly nodeType = DOCUMENT_FRAGMENT_NODE;\n\n get nodeName(): string {\n return '#document-fragment';\n }\n}\n\nexport class NativeElement extends NativeParent {\n readonly nodeType = ELEMENT_NODE;\n readonly namespaceURI = HTML_NAMESPACE;\n readonly attributes = new Map<string, string>();\n /** Values set as properties, as they are: what dynamic attributes such as `items={{this.list}}` assigned. */\n readonly properties = new Map<string, unknown>();\n readonly view: unknown;\n readonly #listeners = new Map<string, Map<Listener, Listener>>();\n #text: string | undefined;\n\n constructor(\n document: NativeDocument,\n readonly localName: string,\n view?: unknown,\n ) {\n super(document);\n this.view = view === undefined ? document.adapter.createView(localName) : view;\n if (this.view) exposeViewProperties(this);\n }\n\n get tagName(): string {\n return this.localName.toUpperCase();\n }\n\n get nodeName(): string {\n return this.tagName;\n }\n\n // Ember's development build of {{on}} names the element in its errors with these.\n get id(): string {\n return this.attributes.get('id') ?? '';\n }\n\n // Glimmer sets a dynamic attribute as a property when `name in element`, which a getter makes true.\n set id(value: string) {\n this.setAttribute('id', value);\n }\n\n get classList(): string[] {\n return (this.attributes.get('class') ?? '').split(/\\s+/).filter(Boolean);\n }\n\n get #adapter(): NativeAdapter {\n return this.ownerDocument.adapter;\n }\n\n getAttribute(name: string): string | null {\n return this.attributes.get(name) ?? null;\n }\n\n hasAttribute(name: string): boolean {\n return this.attributes.has(name);\n }\n\n setAttribute(name: string, value: string): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.setAttribute(local, value);\n const string = String(value);\n this.attributes.set(name, string);\n this.properties.delete(name);\n if (this.view) this.#adapter.setProperty(this.view, name, string);\n }\n\n removeAttribute(name: string): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.removeAttribute(local);\n this.attributes.delete(name);\n this.properties.delete(name);\n if (this.view) this.#adapter.setProperty(this.view, name, null);\n }\n\n /** Sets a view property to a value as it is. Glimmer does this for dynamic attributes, through `element[name] = value`. */\n setProperty(name: string, value: unknown): void {\n const local = this.#forThisPlatform(name);\n if (local === undefined) return;\n if (local !== name) return this.setProperty(local, value);\n if (value === null || value === undefined) {\n this.attributes.delete(name);\n this.properties.delete(name);\n } else {\n this.properties.set(name, value);\n if (typeof value === 'object' || typeof value === 'function') this.attributes.delete(name);\n else this.attributes.set(name, String(value));\n }\n\n if (this.view) this.#adapter.setProperty(this.view, name, value ?? null);\n }\n\n // Glimmer only uses namespaced attributes for SVG and xlink.\n setAttributeNS(namespace: string | null, name: string, value: string): void {\n if (namespace) unsupported(`The attribute ${name} in namespace ${namespace}`);\n this.setAttribute(name, value);\n }\n\n removeAttributeNS(_namespace: string | null, name: string): void {\n this.removeAttribute(name);\n }\n\n addEventListener(event: string, listener: Listener | { handleEvent: Listener }): void {\n let byListener = this.#listeners.get(event);\n if (!byListener) this.#listeners.set(event, (byListener = new Map()));\n if (byListener.has(listener as Listener)) return;\n\n const handle: Listener =\n typeof listener === 'function' ? listener : (data) => (listener as { handleEvent: Listener }).handleEvent(data);\n // As on the web, the handler can tell which element it was added on.\n const call: Listener = (data) => {\n if (data !== null && typeof data === 'object') (data as { currentTarget?: unknown }).currentTarget = this;\n handle(data);\n };\n byListener.set(listener as Listener, call);\n if (this.view) this.#adapter.on(this.view, event, call);\n }\n\n removeEventListener(event: string, listener: Listener): void {\n const call = this.#listeners.get(event)?.get(listener);\n if (!call) return;\n\n this.#listeners.get(event)!.delete(listener);\n if (this.view) this.#adapter.off(this.view, event, call);\n }\n\n /** How many listeners the element holds, for tests that check clean-up. */\n get listenerCount(): number {\n let count = 0;\n for (const byListener of this.#listeners.values()) count += byListener.size;\n return count;\n }\n\n get textContent(): string {\n return this.childNodes.map((node) => (node as { textContent?: string }).textContent ?? '').join('');\n }\n\n // `renderComponent` clears its target the first time; nothing else may be assigned.\n set innerHTML(html: string) {\n if (html !== '') unsupported('Setting innerHTML (a triple-curly {{{html}}} or htmlSafe string)');\n while (this.firstChild) this.removeChild(this.firstChild);\n }\n\n insertAdjacentHTML(): never {\n return unsupported('insertAdjacentHTML (a triple-curly {{{html}}} or htmlSafe string)');\n }\n\n // `ios:title` is `title` on iOS and nothing elsewhere; `android:` and `web:` likewise.\n #forThisPlatform(name: string): string | undefined {\n const match = /^(ios|android|web):(.+)$/.exec(name);\n if (!match) return name;\n return match[1] === this.#adapter.platform ? match[2] : undefined;\n }\n\n /** Recomputes the text property of a view that takes text from its text children. */\n syncText(): void {\n if (!this.view || !this.#adapter.takesText(this.view)) return;\n\n let text = '';\n for (let node = this.firstChild; node; node = node.nextSibling) {\n if (node instanceof NativeText) text += node.nodeValue;\n }\n\n if (text !== this.#text) {\n this.#text = text;\n this.#adapter.setProperty(this.view, 'text', text);\n }\n }\n\n protected override childInserted(node: NativeNode): void {\n if (node instanceof NativeText) {\n if (this.view && this.#adapter.takesText(this.view)) this.syncText();\n else if (node.nodeValue.trim()) this.ownerDocument.droppedText.push(node.nodeValue);\n return;\n }\n\n const slot = node instanceof NativeElement ? this.#slotOf(node) : undefined;\n\n if (slot && this.view && (node as NativeElement).view) {\n const child = (node as NativeElement).view;\n if (slot.list)\n this.#adapter.insertInSlot(this.view, slot.property, child, this.#indexIn(slot, node as NativeElement));\n else this.#adapter.setSlot(this.view, slot.property, child);\n } else if (node instanceof NativeElement && node.view && this.view) {\n this.#adapter.insertChild(this.view, node.view, this.#nativeIndexOf(node));\n } else if (node instanceof NativeElement && node.view && !this.view) {\n unsupported(`A <${node.localName}> inside <${this.localName}>, which has no view,`);\n }\n }\n\n protected override childRemoving(node: NativeNode): void {\n if (!(node instanceof NativeElement) || !node.view || !this.view) return;\n\n const slot = this.#slotOf(node);\n if (slot?.list) this.#adapter.removeFromSlot(this.view, slot.property, node.view);\n else if (slot) this.#adapter.setSlot(this.view, slot.property, null);\n else this.#adapter.removeChild(this.view, node.view);\n }\n\n protected override childRemoved(node: NativeNode): void {\n if (node instanceof NativeText) this.syncText();\n }\n\n #slotOf(child: NativeElement): Slot | undefined {\n return slotFor(this.localName, child.localName);\n }\n\n // Where a child view goes among its parent's views: children that went into a slot don't count.\n #nativeIndexOf(target: NativeElement): number {\n let index = 0;\n for (let node = this.firstChild; node && node !== target; node = node.nextSibling) {\n if (node instanceof NativeElement && node.view && !this.#slotOf(node)) index++;\n }\n return index;\n }\n\n // Where a child goes in a list slot: after the earlier children in the same slot.\n #indexIn(slot: Slot, target: NativeElement): number {\n let index = 0;\n for (let node = this.firstChild; node && node !== target; node = node.nextSibling) {\n if (node instanceof NativeElement && node.view && this.#slotOf(node)?.property === slot.property) index++;\n }\n return index;\n }\n}\n\n// Glimmer sets a dynamic attribute as a property when `name in element`, and otherwise turns its value into a string\n// for setAttribute. Each element with a view gets a prototype that answers `in` for the properties its view has\n// (adapter.hasProperty) and sends assignments to them to setProperty, so `items={{this.contacts}}` reaches a\n// ListPicker as an array. It's a proxy in the prototype chain rather than around the element, which would break the\n// element's private fields; it only sees names the element itself doesn't have.\nfunction exposeViewProperties(element: NativeElement): void {\n const { view } = element;\n const adapter = element.ownerDocument.adapter;\n const isViewProperty = (target: object, key: string | symbol): key is string =>\n typeof key === 'string' && !Reflect.has(target, key) && Boolean(adapter.hasProperty?.(view, key));\n\n Object.setPrototypeOf(\n element,\n new Proxy(NativeElement.prototype, {\n getPrototypeOf: () => NativeElement.prototype,\n has: (target, key) => Reflect.has(target, key) || isViewProperty(target, key),\n get(target, key, receiver) {\n return receiver === element && isViewProperty(target, key)\n ? element.properties.get(key)\n : Reflect.get(target, key, receiver);\n },\n set(target, key, value, receiver) {\n if (receiver !== element || !isViewProperty(target, key)) return Reflect.set(target, key, value, receiver);\n element.setProperty(key, value);\n return true;\n },\n }),\n );\n}\n\nexport class NativeDocument extends NativeParent {\n readonly nodeType = DOCUMENT_NODE;\n /** Text that landed outside a view that takes text, so nothing shows it. */\n readonly droppedText: string[] = [];\n\n constructor(readonly adapter: NativeAdapter) {\n super(undefined as unknown as NativeDocument);\n (this as { ownerDocument: NativeDocument }).ownerDocument = this;\n }\n\n get nodeName(): string {\n return '#document';\n }\n\n createElement(tag: string): NativeElement {\n return new NativeElement(this, tag);\n }\n\n createElementNS(namespace: string | null, tag: string): NativeElement {\n if (namespace && namespace !== HTML_NAMESPACE) unsupported(`<${tag}> in namespace ${namespace} (SVG or MathML)`);\n return this.createElement(tag);\n }\n\n /** An element for a view the toolkit made itself, such as a list's cell, so Glimmer can render into it. */\n adopt(view: unknown, tag = 'cell'): NativeElement {\n return new NativeElement(this, tag, view);\n }\n\n createTextNode(data: string): NativeText {\n return new NativeText(this, data);\n }\n\n createComment(data: string): NativeComment {\n return new NativeComment(this, data);\n }\n\n createDocumentFragment(): NativeFragment {\n return new NativeFragment(this);\n }\n}\n"],"mappings":";AA0BA,IAAa,iBAAiB;AAE9B,IAAM,eAAe,SAAwB;CAC3C,MAAM,IAAI,MAAM,wBAAwB,KAAK,4BAA4B;AAC3E;AAEA,IAAsB,aAAtB,MAAiC;CAMV;CAJrB,aAAkC;CAClC,kBAAqC;CACrC,cAAiC;CAEjC,YAAqB,eAA+B;EAA/B,KAAA,gBAAA;CAAgC;CAErD,IAAI,gBAAsC;EACxC,OAAO,KAAK,sBAAsB,gBAAgB,KAAK,aAAa;CACtE;AAGF;AAEA,IAAe,eAAf,cAAoC,WAAW;CAC7C,aAAgC;CAChC,YAA+B;CAE/B,IAAI,aAA2B;EAC7B,MAAM,QAAsB,CAAC;EAC7B,KAAK,IAAI,OAAO,KAAK,YAAY,MAAM,OAAO,KAAK,aAAa,MAAM,KAAK,IAAI;EAC/E,OAAO;CACT;CAEA,YAAkC,MAAY;EAC5C,OAAO,KAAK,aAAa,MAAM,IAAI;CACrC;CAEA,aAAmC,MAAS,WAAiC;EAC3E,IAAI,gBAAgB,gBAAgB;GAClC,KAAK,IAAI,QAAQ,KAAK,YAAY,QAAQ;IACxC,MAAM,OAAO,MAAM;IACnB,KAAK,aAAa,OAAO,SAAS;IAClC,QAAQ;GACV;GACA,OAAO;EACT;EAEA,IAAI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AAQ,KAAK,OAAO,QAAQ;GACzG,QAAQ,YAAY,KAAK,KAAK;GAC9B,OAAO;EACT;CACF,CAAC,CACH;AACF;AAEA,IAAa,iBAAb,cAAoC,aAAa;CAK1B;CAJZ,WAAA;;CAEA,cAAwB,CAAC;CAElC,YAAqB,SAAwB;EAC3C,MAAM,KAAA,CAAsC;EADzB,KAAA,UAAA;EAElB,KAA2C,gBAAgB;CAC9D;CAEA,IAAI,WAAmB;EACrB,OAAO;CACT;CAEA,cAAc,KAA4B;EACxC,OAAO,IAAI,cAAc,MAAM,GAAG;CACpC;CAEA,gBAAgB,WAA0B,KAA4B;EACpE,IAAI,aAAa,cAAA,gCAA8B,YAAY,IAAI,IAAI,iBAAiB,UAAU,iBAAiB;EAC/G,OAAO,KAAK,cAAc,GAAG;CAC/B;;CAGA,MAAM,MAAe,MAAM,QAAuB;EAChD,OAAO,IAAI,cAAc,MAAM,KAAK,IAAI;CAC1C;CAEA,eAAe,MAA0B;EACvC,OAAO,IAAI,WAAW,MAAM,IAAI;CAClC;CAEA,cAAc,MAA6B;EACzC,OAAO,IAAI,cAAc,MAAM,IAAI;CACrC;CAEA,yBAAyC;EACvC,OAAO,IAAI,eAAe,IAAI;CAChC;AACF"}
@@ -7,12 +7,12 @@ export { type FrameHost, type ModalOptions, type NavigateOptions, Navigator, typ
7
7
  export { createNativeApp, FrameNavigationHost, type NativeApp, type NativeAppOptions } from './nativescript-app.js';
8
8
  export { NativeScriptAdapter, registerElement } from './nativescript-adapter.js';
9
9
  export { createOwner, type CreateOwnerOptions, type NativeOwner, type ServiceEntry } from './owner.js';
10
- export { isAndroid, isIOS, platform } from './platform.js';
10
+ export { isAndroid, isIOS, isWeb, platform, type Platform } from './platform.js';
11
11
  export { createDocument, type NativeRoot, renderNative } from './render.js';
12
12
  export { bind } from './bind.js';
13
13
  export { nativeView } from './native-view.js';
14
14
  export { default as NativeFrame } from '../components/NativeFrame.js';
15
15
  export { default as NativeList } from '../components/NativeList.js';
16
- export { Android, IOS } from '../components/Platform.js';
16
+ export { Android, IOS, Web } from '../components/Platform.js';
17
17
  export type { NativeAttributes, NativeElementFor, NativeElementTagNameMap, NativeEvent } from '../types/glint.js';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACtH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C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UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/src/index.js CHANGED
@@ -6,12 +6,12 @@ import { Navigator } from "./navigator.js";
6
6
  import { createNativeApp } from "./nativescript-app.js";
7
7
  import { NativeScriptAdapter, registerElement } from "./nativescript-adapter.js";
8
8
  import { createOwner } from "./owner.js";
9
- import { isAndroid, isIOS, platform } from "./platform.js";
9
+ import { isAndroid, isIOS, isWeb, platform } from "./platform.js";
10
10
  import { FrameNavigationHost } from "./frame-host.js";
11
11
  import { createDocument, renderNative } from "./render.js";
12
12
  import { bind } from "./bind.js";
13
13
  import { nativeView } from "./native-view.js";
14
14
  import NativeFrame from "../components/NativeFrame.js";
15
15
  import NativeList from "../components/NativeList.js";
16
- import { Android, IOS } from "../components/Platform.js";
17
- export { Android, FrameNavigationHost, IOS, NativeDocument, NativeElement, NativeFrame, NativeList, NativeScriptAdapter, Navigator, bind, bindListRows, createDocument, createNativeApp, createOwner, defineElement, isAndroid, isIOS, modifier, nativeView, platform, registerElement, renderNative };
16
+ import { Android, IOS, Web } from "../components/Platform.js";
17
+ export { Android, FrameNavigationHost, IOS, NativeDocument, NativeElement, NativeFrame, NativeList, NativeScriptAdapter, Navigator, Web, bind, bindListRows, createDocument, createNativeApp, createOwner, defineElement, isAndroid, isIOS, isWeb, modifier, nativeView, platform, registerElement, renderNative };
@@ -2,6 +2,12 @@ import type { NativeDocument } from './dom.js';
2
2
  import { type NativeRoot } from './render.js';
3
3
  export interface ShowOptions {
4
4
  animated: boolean;
5
+ /** The screen being shown, for a host that names it (the web host's URL). Native hosts ignore it. */
6
+ screen?: {
7
+ component: object;
8
+ args?: Record<string, unknown>;
9
+ name: string;
10
+ };
5
11
  /** Passed to the host as is: a NativeScript NavigationTransition. */
6
12
  transition?: unknown;
7
13
  clearHistory: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"navigator.d.ts","sourceRoot":"","sources":["../../src/navigator.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,4GAA4G;IAC5G,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,SAAS,CAAC,IAAI,GAAG,OAAO;IACvC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7C,IAAI,IAAI,IAAI,CAAC;IACb,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAA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igator = class {
68
68
  animated: options.animated ?? this.#stack.length + this.#dropped.length > 1,
69
69
  transition: options.transition,
70
70
  clearHistory: options.clearHistory ?? false,
71
- backstackVisible: screen.backstackVisible
71
+ backstackVisible: screen.backstackVisible,
72
+ screen: {
73
+ component,
74
+ args: options.args,
75
+ name: screen.name
76
+ }
72
77
  });
73
78
  return root;
74
79
  };
@@ -1 +1 @@
1
- {"version":3,"file":"navigator.js","names":["tracked","renderNative","g","i","Navigator","prototype","depth","current","modals","constructor","document","host","owner","canGoBack","navigate","component","options","root","args","nav","onNavigatedTo","onNavigatedFrom","data","isBackNavigation","screen","name","backstackVisible","release","element","removeEventListener","destroy","previous","at","clearHistory","push","splice","pop","addEventListener","show","view","animated","length","transition","back","showModal","Promise","resolve","open","closeModal","result","onClose","indexOf","fullscreen","stretched","close","reverse","index"],"sources":["../../src/navigator.ts"],"sourcesContent":["// Screens and modals, the way NativeScript-Vue's navigateTo, navigateBack, showModal and closeModal work.\n//\n// Each screen is a component rendered into its own <page>, shown through the host (NativeScript's Frame on a\n// device, an array in tests). The page's own events keep the stack honest: a page leaves with `navigatedFrom` and\n// `isBackNavigation`, whether the back came from here, from Android's back button or from iOS's swipe, and that is\n// when its render is destroyed. Pages the Frame drops without a back (clearHistory, backstackVisible: false) are\n// destroyed once the next page has arrived (`navigatedTo`).\n//\n// A modal is a component rendered into a view of its own and shown over the current page. It gets `@closeModal`;\n// showModal() resolves with what it passes, or with undefined when the user dismisses it.\n\nimport { tracked } from '@glimmer/tracking';\n\nimport type { NativeDocument } from './dom.ts';\nimport { type NativeRoot, renderNative } from './render.ts';\n\nexport interface ShowOptions {\n animated: boolean;\n /** Passed to the host as is: a NativeScript NavigationTransition. */\n transition?: unknown;\n clearHistory: boolean;\n backstackVisible: boolean;\n}\n\nexport interface ModalHostOptions {\n fullscreen: boolean;\n animated: boolean;\n stretched: boolean;\n /** The host calls this once the modal is gone, with the result it was closed with (none when dismissed). */\n onClose: (result?: unknown) => void;\n}\n\nexport interface FrameHost<View = unknown> {\n show(page: View, options: ShowOptions): void;\n back(): void;\n showModal(view: View, options: ModalHostOptions): void;\n closeModal(view: View, result: unknown): void;\n}\n\nexport interface NavigateOptions {\n args?: Record<string, unknown>;\n /** A name for the screen, for `navigator.current` and tests. */\n name?: string;\n /** Animates the change of page. Defaults to true except for the first screen. */\n animated?: boolean;\n transition?: unknown;\n /** Drops every screen before this one: there is nothing to go back to. */\n clearHistory?: boolean;\n /** False to leave this screen out of the back stack once the next one is shown (a splash, a login). */\n backstackVisible?: boolean;\n}\n\nexport interface ModalOptions {\n args?: Record<string, unknown>;\n fullscreen?: boolean;\n animated?: boolean;\n stretched?: boolean;\n /** The tag of the view the modal renders into. */\n root?: string;\n}\n\ninterface Screen {\n name: string;\n root: NativeRoot;\n backstackVisible: boolean;\n /** Stops listening to the page and destroys the render. */\n release(): void;\n}\n\ninterface NavigatedData {\n isBackNavigation?: boolean;\n}\n\nexport class Navigator {\n /** How many screens are in the stack. */\n @tracked depth = 0;\n /** The name of the screen on top. */\n @tracked current: string | undefined;\n /** How many modals are open. */\n @tracked modals = 0;\n readonly #stack: Screen[] = [];\n readonly #closers: Array<(result?: unknown) => void> = [];\n // Screens the Frame dropped without a back, destroyed when the next page has arrived.\n #dropped: Screen[] = [];\n\n constructor(\n readonly document: NativeDocument,\n readonly host: FrameHost,\n readonly owner: object = {},\n ) {}\n\n get canGoBack(): boolean {\n return this.depth > 1;\n }\n\n navigate = (component: object, options: NavigateOptions = {}): NativeRoot => {\n const root = renderNative(component, {\n document: this.document,\n root: 'page',\n owner: this.owner,\n args: { ...options.args, nav: this },\n });\n const onNavigatedTo = (): void => this.#destroyDropped();\n const onNavigatedFrom = (data: unknown): void => {\n if ((data as NavigatedData).isBackNavigation) this.#popped(screen);\n };\n const screen: Screen = {\n name: options.name ?? 'screen',\n root,\n backstackVisible: options.backstackVisible ?? true,\n release() {\n root.element.removeEventListener('navigatedTo', onNavigatedTo);\n root.element.removeEventListener('navigatedFrom', onNavigatedFrom);\n root.destroy();\n },\n };\n const previous = this.#stack.at(-1);\n\n if (options.clearHistory) this.#dropped.push(...this.#stack.splice(0));\n else if (previous && !previous.backstackVisible) this.#dropped.push(this.#stack.pop()!);\n\n root.element.addEventListener('navigatedTo', onNavigatedTo);\n root.element.addEventListener('navigatedFrom', onNavigatedFrom);\n\n this.#stack.push(screen);\n this.#changed();\n this.host.show(root.view, {\n animated: options.animated ?? this.#stack.length + this.#dropped.length > 1,\n transition: options.transition,\n clearHistory: options.clearHistory ?? false,\n backstackVisible: screen.backstackVisible,\n });\n return root;\n };\n\n /** Goes back a screen. The screen is destroyed when its page has left. */\n back = (): void => {\n if (this.#stack.length > 1) this.host.back();\n };\n\n showModal = <Result = unknown>(component: object, options: ModalOptions = {}): Promise<Result | undefined> => {\n return new Promise((resolve) => {\n let open = true;\n let root: NativeRoot | undefined;\n\n const closeModal = (result?: unknown): void => {\n if (open && root) this.host.closeModal(root.view, result);\n };\n const onClose = (result?: unknown): void => {\n if (!open) return;\n open = false;\n this.#closers.splice(this.#closers.indexOf(closeModal), 1);\n this.modals = this.#closers.length;\n root?.destroy();\n resolve(result as Result | undefined);\n };\n\n root = renderNative(component, {\n document: this.document,\n root: options.root ?? 'contentView',\n owner: this.owner,\n args: { ...options.args, nav: this, closeModal },\n });\n this.#closers.push(closeModal);\n this.modals = this.#closers.length;\n this.host.showModal(root.view, {\n fullscreen: options.fullscreen ?? false,\n animated: options.animated ?? true,\n stretched: options.stretched ?? false,\n onClose,\n });\n });\n };\n\n /** Closes the modal on top with a result, as its own `@closeModal` would. */\n closeModal = (result?: unknown): void => {\n this.#closers.at(-1)?.(result);\n };\n\n /** Destroys every screen, and closes open modals with no result. For a frame that goes away (a tab's). */\n destroy = (): void => {\n for (const screen of [...this.#stack.splice(0), ...this.#dropped.splice(0)]) screen.release();\n this.#changed();\n for (const close of [...this.#closers].reverse()) close();\n };\n\n #popped(screen: Screen): void {\n const index = this.#stack.indexOf(screen);\n if (index === -1) return;\n this.#stack.splice(index, 1);\n this.#changed();\n screen.release();\n }\n\n #changed(): void {\n this.depth = this.#stack.length;\n this.current = this.#stack.at(-1)?.name;\n }\n\n #destroyDropped(): void {\n for (const screen of this.#dropped.splice(0)) screen.release();\n }\n}\n"],"mappings":";;;;AAyEA,IAAaI,YAAb,MAAuB;CAAA;EAAAF,gBAAA,KAAAG,WAAA,SAAA,CAEpBL,OAAO,GAAA,WAAA;GAAA,OAAS;EAAC,CAAA;CAAA;CAAA,UAAAG,4BAAA,MAAA,OAAA,GAAA,KAAA;;CADlB;EAAAD,gBAAA,KAAAG,WAAA,WAAA,CAGCL,OAAO,CAAA;CAAA;CAAA,YAAAG,4BAAA,MAAA,SAAA,GAAA,KAAA;;CADR;EAAAD,gBAAA,KAAAG,WAAA,UAAA,CAGCL,OAAO,GAAA,WAAA;GAAA,OAAU;EAAC,CAAA;CAAA;CAAA,WAAAG,4BAAA,MAAA,QAAA,GAAA,KAAA;;CACV,SAAmB,CAAA;CACnB,WAA8C,CAAA;CAEvD,WAAqB,CAAA;CAErBM,YACWC,UACAC,MACAC,QAAgB,CAAC,GAC1B;EAAA,KAHSF,WAAAA;EAAwB,KACxBC,OAAAA;EAAe,KACfC,QAAAA;CACR;CAEH,IAAIC,YAAqB;EACvB,OAAO,KAAKP,QAAQ;CACtB;CAEAQ,YAAYC,WAAmBC,UAA2B,CAAC,MAAkB;EAC3E,MAAMC,OAAOhB,aAAac,WAAW;GACnCL,UAAU,KAAKA;GACfO,MAAM;GACNL,OAAO,KAAKA;GACZM,MAAM;IAAE,GAAGF,QAAQE;IAAMC,KAAK;GAAK;EACrC,CAAC;EACD,MAAMC,sBAA4B,KAAK,gBAAgB;EACvD,MAAMC,mBAAmBC,SAAwB;GAC/C,IAAKA,KAAuBC,kBAAkB,KAAK,QAAQC,MAAM;EACnE;EACA,MAAMA,SAAiB;GACrBC,MAAMT,QAAQS,QAAQ;GACtBR;GACAS,kBAAkBV,QAAQU,oBAAoB;GAC9CC,UAAU;IACRV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AOhB,aAAac,WAAW;IAC7BL,UAAU,KAAKA;IACfO,MAAMD,QAAQC,QAAQ;IACtBL,OAAO,KAAKA;IACZM,MAAM;KAAE,GAAGF,QAAQE;KAAMC,KAAK;KAAM6B;IAAW;GACjD,CAAC;GACD,KAAK,SAASd,KAAKc,UAAU;GAC7B,KAAKxC,SAAS,KAAK,SAASiC;GAC5B,KAAK9B,KAAKiC,UAAU3B,KAAKsB,MAAM;IAC7Ba,YAAYpC,QAAQoC,cAAc;IAClCZ,UAAUxB,QAAQwB,YAAY;IAC9Ba,WAAWrC,QAAQqC,aAAa;IAChCH;GACF,CAAC;EACH,CAAC;CACH;;CAGAF,cAAcC,WAA2B;EACvC,KAAK,SAASjB,GAAG,EAAE,CAAC,GAAGiB,MAAM;CAC/B;;CAGAnB,gBAAsB;EACpB,KAAK,MAAMN,UAAU,CAAC,GAAG,KAAK,OAAOW,OAAO,CAAC,GAAG,GAAG,KAAK,SAASA,OAAO,CAAC,CAAC,GAAGX,OAAOG,QAAQ;EAC5F,KAAK,SAAS;EACd,KAAK,MAAM2B,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,CAACC,QAAQ,GAAGD,MAAM;CAC1D;CAEA,QAAQ9B,QAAsB;EAC5B,MAAMgC,QAAQ,KAAK,OAAOL,QAAQ3B,MAAM;EACxC,IAAIgC,UAAU,IAAI;EAClB,KAAK,OAAOrB,OAAOqB,OAAO,CAAC;EAC3B,KAAK,SAAS;EACdhC,OAAOG,QAAQ;CACjB;CAEA,WAAiB;EACf,KAAKrB,QAAQ,KAAK,OAAOmC;EACzB,KAAKlC,UAAU,KAAK,OAAOyB,GAAG,EAAE,CAAC,EAAEP;CACrC;CAEA,kBAAwB;EACtB,KAAK,MAAMD,UAAU,KAAK,SAASW,OAAO,CAAC,GAAGX,OAAOG,QAAQ;CAC/D;AACF"}
1
+ {"version":3,"file":"navigator.js","names":["tracked","renderNative","g","i","Navigator","prototype","depth","current","modals","constructor","document","host","owner","canGoBack","navigate","component","options","root","args","nav","onNavigatedTo","onNavigatedFrom","data","isBackNavigation","screen","name","backstackVisible","release","element","removeEventListener","destroy","previous","at","clearHistory","push","splice","pop","addEventListener","show","view","animated","length","transition","back","showModal","Promise","resolve","open","closeModal","result","onClose","indexOf","fullscreen","stretched","close","reverse","index"],"sources":["../../src/navigator.ts"],"sourcesContent":["// Screens and modals, the way NativeScript-Vue's navigateTo, navigateBack, showModal and closeModal work.\n//\n// Each screen is a component rendered into its own <page>, shown through the host (NativeScript's Frame on a\n// device, an array in tests). The page's own events keep the stack honest: a page leaves with `navigatedFrom` and\n// `isBackNavigation`, whether the back came from here, from Android's back button or from iOS's swipe, and that is\n// when its render is destroyed. Pages the Frame drops without a back (clearHistory, backstackVisible: false) are\n// destroyed once the next page has arrived (`navigatedTo`).\n//\n// A modal is a component rendered into a view of its own and shown over the current page. It gets `@closeModal`;\n// showModal() resolves with what it passes, or with undefined when the user dismisses it.\n\nimport { tracked } from '@glimmer/tracking';\n\nimport type { NativeDocument } from './dom.ts';\nimport { type NativeRoot, renderNative } from './render.ts';\n\nexport interface ShowOptions {\n animated: boolean;\n /** The screen being shown, for a host that names it (the web host's URL). Native hosts ignore it. */\n screen?: { component: object; args?: Record<string, unknown>; name: string };\n /** Passed to the host as is: a NativeScript NavigationTransition. */\n transition?: unknown;\n clearHistory: boolean;\n backstackVisible: boolean;\n}\n\nexport interface ModalHostOptions {\n fullscreen: boolean;\n animated: boolean;\n stretched: boolean;\n /** The host calls this once the modal is gone, with the result it was closed with (none when dismissed). */\n onClose: (result?: unknown) => void;\n}\n\nexport interface FrameHost<View = unknown> {\n show(page: View, options: ShowOptions): void;\n back(): void;\n showModal(view: View, options: ModalHostOptions): void;\n closeModal(view: View, result: unknown): void;\n}\n\nexport interface NavigateOptions {\n args?: Record<string, unknown>;\n /** A name for the screen, for `navigator.current` and tests. */\n name?: string;\n /** Animates the change of page. Defaults to true except for the first screen. */\n animated?: boolean;\n transition?: unknown;\n /** Drops every screen before this one: there is nothing to go back to. */\n clearHistory?: boolean;\n /** False to leave this screen out of the back stack once the next one is shown (a splash, a login). */\n backstackVisible?: boolean;\n}\n\nexport interface ModalOptions {\n args?: Record<string, unknown>;\n fullscreen?: boolean;\n animated?: boolean;\n stretched?: boolean;\n /** The tag of the view the modal renders into. */\n root?: string;\n}\n\ninterface Screen {\n name: string;\n root: NativeRoot;\n backstackVisible: boolean;\n /** Stops listening to the page and destroys the render. */\n release(): void;\n}\n\ninterface NavigatedData {\n isBackNavigation?: boolean;\n}\n\nexport class Navigator {\n /** How many screens are in the stack. */\n @tracked depth = 0;\n /** The name of the screen on top. */\n @tracked current: string | undefined;\n /** How many modals are open. */\n @tracked modals = 0;\n readonly #stack: Screen[] = [];\n readonly #closers: Array<(result?: unknown) => void> = [];\n // Screens the Frame dropped without a back, destroyed when the next page has arrived.\n #dropped: Screen[] = [];\n\n constructor(\n readonly document: NativeDocument,\n readonly host: FrameHost,\n readonly owner: object = {},\n ) {}\n\n get canGoBack(): boolean {\n return this.depth > 1;\n }\n\n navigate = (component: object, options: NavigateOptions = {}): NativeRoot => {\n const root = renderNative(component, {\n document: this.document,\n root: 'page',\n owner: this.owner,\n args: { ...options.args, nav: this },\n });\n const onNavigatedTo = (): void => this.#destroyDropped();\n const onNavigatedFrom = (data: unknown): void => {\n if ((data as NavigatedData).isBackNavigation) this.#popped(screen);\n };\n const screen: Screen = {\n name: options.name ?? 'screen',\n root,\n backstackVisible: options.backstackVisible ?? true,\n release() {\n root.element.removeEventListener('navigatedTo', onNavigatedTo);\n root.element.removeEventListener('navigatedFrom', onNavigatedFrom);\n root.destroy();\n },\n };\n const previous = this.#stack.at(-1);\n\n if (options.clearHistory) this.#dropped.push(...this.#stack.splice(0));\n else if (previous && !previous.backstackVisible) this.#dropped.push(this.#stack.pop()!);\n\n root.element.addEventListener('navigatedTo', onNavigatedTo);\n root.element.addEventListener('navigatedFrom', onNavigatedFrom);\n\n this.#stack.push(screen);\n this.#changed();\n this.host.show(root.view, {\n animated: options.animated ?? this.#stack.length + this.#dropped.length > 1,\n transition: options.transition,\n clearHistory: options.clearHistory ?? false,\n backstackVisible: screen.backstackVisible,\n screen: { component, args: options.args, name: screen.name },\n });\n return root;\n };\n\n /** Goes back a screen. The screen is destroyed when its page has left. */\n back = (): void => {\n if (this.#stack.length > 1) this.host.back();\n };\n\n showModal = <Result = unknown>(component: object, options: ModalOptions = {}): Promise<Result | undefined> => {\n return new Promise((resolve) => {\n let open = true;\n let root: NativeRoot | undefined;\n\n const closeModal = (result?: unknown): void => {\n if (open && root) this.host.closeModal(root.view, result);\n };\n const onClose = (result?: unknown): void => {\n if (!open) return;\n open = false;\n this.#closers.splice(this.#closers.indexOf(closeModal), 1);\n this.modals = this.#closers.length;\n root?.destroy();\n resolve(result as Result | undefined);\n };\n\n root = renderNative(component, {\n document: this.document,\n root: options.root ?? 'contentView',\n owner: this.owner,\n args: { ...options.args, nav: this, closeModal },\n });\n this.#closers.push(closeModal);\n this.modals = this.#closers.length;\n this.host.showModal(root.view, {\n fullscreen: options.fullscreen ?? false,\n animated: options.animated ?? true,\n stretched: options.stretched ?? false,\n onClose,\n });\n });\n };\n\n /** Closes the modal on top with a result, as its own `@closeModal` would. */\n closeModal = (result?: unknown): void => {\n this.#closers.at(-1)?.(result);\n };\n\n /** Destroys every screen, and closes open modals with no result. For a frame that goes away (a tab's). */\n destroy = (): void => {\n for (const screen of [...this.#stack.splice(0), ...this.#dropped.splice(0)]) screen.release();\n this.#changed();\n for (const close of [...this.#closers].reverse()) close();\n };\n\n #popped(screen: Screen): void {\n const index = this.#stack.indexOf(screen);\n if (index === -1) return;\n this.#stack.splice(index, 1);\n this.#changed();\n screen.release();\n }\n\n #changed(): void {\n this.depth = this.#stack.length;\n this.current = this.#stack.at(-1)?.name;\n }\n\n #destroyDropped(): void {\n for (const screen of this.#dropped.splice(0)) screen.release();\n }\n}\n"],"mappings":";;;;AA2EA,IAAaI,YAAb,MAAuB;CAAA;EAAAF,gBAAA,KAAAG,WAAA,S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GACD,KAAK,SAASd,KAAKc,UAAU;GAC7B,KAAKxC,SAAS,KAAK,SAASiC;GAC5B,KAAK9B,KAAKiC,UAAU3B,KAAKsB,MAAM;IAC7Ba,YAAYpC,QAAQoC,cAAc;IAClCZ,UAAUxB,QAAQwB,YAAY;IAC9Ba,WAAWrC,QAAQqC,aAAa;IAChCH;GACF,CAAC;EACH,CAAC;CACH;;CAGAF,cAAcC,WAA2B;EACvC,KAAK,SAASjB,GAAG,EAAE,CAAC,GAAGiB,MAAM;CAC/B;;CAGAnB,gBAAsB;EACpB,KAAK,MAAMN,UAAU,CAAC,GAAG,KAAK,OAAOW,OAAO,CAAC,GAAG,GAAG,KAAK,SAASA,OAAO,CAAC,CAAC,GAAGX,OAAOG,QAAQ;EAC5F,KAAK,SAAS;EACd,KAAK,MAAM2B,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,CAACC,QAAQ,GAAGD,MAAM;CAC1D;CAEA,QAAQ9B,QAAsB;EAC5B,MAAMgC,QAAQ,KAAK,OAAOL,QAAQ3B,MAAM;EACxC,IAAIgC,UAAU,IAAI;EAClB,KAAK,OAAOrB,OAAOqB,OAAO,CAAC;EAC3B,KAAK,SAAS;EACdhC,OAAOG,QAAQ;CACjB;CAEA,WAAiB;EACf,KAAKrB,QAAQ,KAAK,OAAOmC;EACzB,KAAKlC,UAAU,KAAK,OAAOyB,GAAG,EAAE,CAAC,EAAEP;CACrC;CAEA,kBAAwB;EACtB,KAAK,MAAMD,UAAU,KAAK,SAASW,OAAO,CAAC,GAAGX,OAAOG,QAAQ;CAC/D;AACF"}
@@ -1,5 +1,7 @@
1
- export declare function setPlatform(platform: 'ios' | 'android' | undefined): void;
2
- export declare const platform: () => "ios" | "android" | undefined;
1
+ export type Platform = 'ios' | 'android' | 'web';
2
+ export declare function setPlatform(platform: Platform | undefined): void;
3
+ export declare const platform: () => Platform | undefined;
3
4
  export declare const isIOS: () => boolean;
4
5
  export declare const isAndroid: () => boolean;
6
+ export declare const isWeb: () => boolean;
5
7
  //# sourceMappingURL=platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAEzE;AAED,eAAO,MAAM,QAAQ,QAAO,KAAK,GAAG,SAAS,GAAG,SAAoB,CAAC;AACrE,eAAO,MAAM,KAAK,QAAO,OAA4B,CAAC;AACtD,eAAO,MAAM,SAAS,QAAO,OAAgC,CAAC"}
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;AAIjD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAEhE;AAED,eAAO,MAAM,QAAQ,QAAO,QAAQ,GAAG,SAAoB,CAAC;AAC5D,eAAO,MAAM,KAAK,QAAO,OAA4B,CAAC;AACtD,eAAO,MAAM,SAAS,QAAO,OAAgC,CAAC;AAC9D,eAAO,MAAM,KAAK,QAAO,OAA4B,CAAC"}
@@ -6,6 +6,7 @@ function setPlatform(platform) {
6
6
  var platform = () => current;
7
7
  var isIOS = () => current === "ios";
8
8
  var isAndroid = () => current === "android";
9
- export { isAndroid, isIOS, platform, setPlatform };
9
+ var isWeb = () => current === "web";
10
+ export { isAndroid, isIOS, isWeb, platform, setPlatform };
10
11
 
11
12
  //# sourceMappingURL=platform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","names":[],"sources":["../../src/platform.ts"],"sourcesContent":["// Which platform the app runs on, for templates: {{#if (isIOS)}}…{{/if}}. Set from the adapter when a document is\n// created, which happens once, before anything renders.\nlet current: 'ios' | 'android' | undefined;\n\nexport function setPlatform(platform: 'ios' | 'android' | undefined): void {\n current = platform;\n}\n\nexport const platform = (): 'ios' | 'android' | undefined => current;\nexport const isIOS = (): boolean => current === 'ios';\nexport const isAndroid = (): boolean => current === 'android';\n"],"mappings":";AAEA,IAAI;AAEJ,SAAgB,YAAY,UAA+C;CACzE,UAAU;AACZ;AAEA,IAAa,iBAAgD;AAC7D,IAAa,cAAuB,YAAY;AAChD,IAAa,kBAA2B,YAAY"}
1
+ {"version":3,"file":"platform.js","names":[],"sources":["../../src/platform.ts"],"sourcesContent":["// Which platform the app runs on, for templates: {{#if (isIOS)}}…{{/if}}. Set from the adapter when a document is\n// created, which happens once, before anything renders. `web` is the browser, through the web adapter.\nexport type Platform = 'ios' | 'android' | 'web';\n\nlet current: Platform | undefined;\n\nexport function setPlatform(platform: Platform | undefined): void {\n current = platform;\n}\n\nexport const platform = (): Platform | undefined => current;\nexport const isIOS = (): boolean => current === 'ios';\nexport const isAndroid = (): boolean => current === 'android';\nexport const isWeb = (): boolean => current === 'web';\n"],"mappings":";AAIA,IAAI;AAEJ,SAAgB,YAAY,UAAsC;CAChE,UAAU;AACZ;AAEA,IAAa,iBAAuC;AACpD,IAAa,cAAuB,YAAY;AAChD,IAAa,kBAA2B,YAAY;AACpD,IAAa,cAAuB,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQzD,MAAM,WAAW,UAAU,CAAC,IAAI,GAAG,OAAO;IACxC,4DAA4D;IAC5D,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,cAAc,CAAC;IACzB,4FAA4F;IAC5F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAGrE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAC/B,SAAS,EAAE,MAAM,EACjB,EAAE,QAAQ,EAAE,IAAa,EAAE,IAAI,EAAE,KAAU,EAAE,EAAE,mBAAmB,GACjE,UAAU,CAAC,IAAI,CAAC,CAgBlB"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzD,MAAM,WAAW,UAAU,CAAC,IAAI,GAAG,OAAO;IACxC,4DAA4D;IAC5D,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,cAAc,CAAC;IACzB,4FAA4F;IAC5F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAGrE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAC/B,SAAS,EAAE,MAAM,EACjB,EAAE,QAAQ,EAAE,IAAa,EAAE,IAAI,EAAE,KAAU,EAAE,EAAE,mBAAmB,GACjE,UAAU,CAAC,IAAI,CAAC,CAgBlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["renderComponent","NativeDocument","NativeElement","setPlatform","globals","globalThis","Element","createDocument","adapter","platform","renderNative","component","document","root","args","owner","element","createElement","view","Error","result","into","env","isInteractive","hasDOM","destroy"],"sources":["../../src/render.ts"],"sourcesContent":["// Renders Ember components into native views with Ember's public `renderComponent`, which takes the\n// document to build with (`env.document`). Nothing private from Ember is used here.\n\nimport { renderComponent } from '@ember/renderer';\n\nimport type { NativeAdapter } from './adapter.ts';\nimport { NativeDocument, NativeElement } from './dom.ts';\nimport { setPlatform } from './platform.ts';\n\n// `renderComponent` checks `into instanceof Element` before clearing its target. Neither Node nor\n// NativeScript has a global Element, so the shim's element class stands in for it.\nconst globals = globalThis as { Element?: unknown };\nglobals.Element ??= NativeElement;\n\nexport interface NativeRoot<View = unknown> {\n /** The root element; its view is what the toolkit shows. */\n element: NativeElement;\n view: View;\n destroy(): void;\n}\n\nexport interface RenderNativeOptions {\n document: NativeDocument;\n /** The tag of the root view the component renders into, such as `page` or `stackLayout`. */\n root?: string;\n args?: Record<string, unknown>;\n owner?: object;\n}\n\nexport function createDocument(adapter: NativeAdapter): NativeDocument {\n setPlatform(adapter.platform);\n return new NativeDocument(adapter);\n}\n\nexport function renderNative<View>(\n component: object,\n { document, root = 'page', args, owner = {} }: RenderNativeOptions,\n): NativeRoot<View> {\n const element = document.createElement(root);\n if (!element.view) throw new Error(`[ember-nativescript] <${root}> has no view, so it can't be a root.`);\n\n const result = renderComponent(component, {\n into: element as unknown as Element,\n owner,\n args,\n env: { document: document as unknown as Document, isInteractive: true, hasDOM: true } as never,\n });\n\n return {\n element,\n view: element.view as View,\n destroy: () => result.destroy(),\n };\n}\n"],"mappings":";;;;AAWA,IAAMI,UAAUC;AAChBD,QAAQE,YAAYJ;AAiBpB,SAAgBK,eAAeC,SAAwC;CACrEL,YAAYK,QAAQC,QAAQ;CAC5B,OAAO,IAAIR,eAAeO,OAAO;AACnC;AAEA,SAAgBE,aACdC,WACA,EAAEC,UAAUC,OAAO,QAAQC,MAAMC,QAAQ,CAAC,KACxB;CAClB,MAAMC,UAAUJ,SAASK,cAAcJ,IAAI;CAC3C,IAAI,CAACG,QAAQE,MAAM,MAAM,IAAIC,MAAM,yBAAyBN,KAAI,sCAAuC;CAEvG,MAAMO,SAASpB,gBAAgBW,WAAW;EACxCU,MAAML;EACND;EACAD;EACAQ,KAAK;GAAYV;GAAiCW,eAAe;GAAMC,QAAQ;EAAK;CACtF,CAAC;CAED,OAAO;EACLR;EACAE,MAAMF,QAAQE;EACdO,eAAeL,OAAOK,QAAQ;CAChC;AACF"}
1
+ {"version":3,"file":"render.js","names":["renderComponent","NativeDocument","NativeElement","setPlatform","globals","globalThis","Element","createDocument","adapter","platform","renderNative","component","document","root","args","owner","element","createElement","view","Error","result","into","env","isInteractive","hasDOM","destroy"],"sources":["../../src/render.ts"],"sourcesContent":["// Renders Ember components into native views with Ember's public `renderComponent`, which takes the\n// document to build with (`env.document`). Nothing private from Ember is used here.\n\nimport { renderComponent } from '@ember/renderer';\n\nimport type { NativeAdapter } from './adapter.ts';\nimport { NativeDocument, NativeElement } from './dom.ts';\nimport { setPlatform } from './platform.ts';\n\n// `renderComponent` checks `into instanceof Element` before clearing its target. Neither Node nor\n// NativeScript has a global Element, so the shim's element class stands in for it. A browser has one: there the check\n// fails, and renderComponent only skips clearing the target, which is a new element anyway.\nconst globals = globalThis as { Element?: unknown };\nglobals.Element ??= NativeElement;\n\nexport interface NativeRoot<View = unknown> {\n /** The root element; its view is what the toolkit shows. */\n element: NativeElement;\n view: View;\n destroy(): void;\n}\n\nexport interface RenderNativeOptions {\n document: NativeDocument;\n /** The tag of the root view the component renders into, such as `page` or `stackLayout`. */\n root?: string;\n args?: Record<string, unknown>;\n owner?: object;\n}\n\nexport function createDocument(adapter: NativeAdapter): NativeDocument {\n setPlatform(adapter.platform);\n return new NativeDocument(adapter);\n}\n\nexport function renderNative<View>(\n component: object,\n { document, root = 'page', args, owner = {} }: RenderNativeOptions,\n): NativeRoot<View> {\n const element = document.createElement(root);\n if (!element.view) throw new Error(`[ember-nativescript] <${root}> has no view, so it can't be a root.`);\n\n const result = renderComponent(component, {\n into: element as unknown as Element,\n owner,\n args,\n env: { document: document as unknown as Document, isInteractive: true, hasDOM: true } as never,\n });\n\n return {\n element,\n view: element.view as View,\n destroy: () => result.destroy(),\n };\n}\n"],"mappings":";;;;AAYA,IAAMI,UAAUC;AAChBD,QAAQE,YAAYJ;AAiBpB,SAAgBK,eAAeC,SAAwC;CACrEL,YAAYK,QAAQC,QAAQ;CAC5B,OAAO,IAAIR,eAAeO,OAAO;AACnC;AAEA,SAAgBE,aACdC,WACA,EAAEC,UAAUC,OAAO,QAAQC,MAAMC,QAAQ,CAAC,KACxB;CAClB,MAAMC,UAAUJ,SAASK,cAAcJ,IAAI;CAC3C,IAAI,CAACG,QAAQE,MAAM,MAAM,IAAIC,MAAM,yBAAyBN,KAAI,sCAAuC;CAEvG,MAAMO,SAASpB,gBAAgBW,WAAW;EACxCU,MAAML;EACND;EACAD;EACAQ,KAAK;GAAYV;GAAiCW,eAAe;GAAMC,QAAQ;EAAK;CACtF,CAAC;CAED,OAAO;EACLR;EACAE,MAAMF,QAAQE;EACdO,eAAeL,OAAOK,QAAQ;CAChC;AACF"}
@@ -0,0 +1,5 @@
1
+ import { type Plugin, type UserConfig } from 'vite';
2
+ /** Converts the app's own .css files (not those of packages) from NativeScript's CSS to the browser's. */
3
+ export declare function nativeScriptCss(): Plugin;
4
+ export declare function emberWebConfig(overrides?: UserConfig): UserConfig;
5
+ //# sourceMappingURL=vite-web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-web.d.ts","sourceRoot":"","sources":["../../src/vite-web.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAUjE,0GAA0G;AAC1G,wBAAgB,eAAe,IAAI,MAAM,CAUxC;AAED,wBAAgB,cAAc,CAAC,SAAS,GAAE,UAAe,GAAG,UAAU,CASrE"}
@@ -0,0 +1,41 @@
1
+ import { existsSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { mergeConfig } from "vite";
4
+ import ember from "vite-plugin-ember-gts";
5
+ import { convertNativeScriptCss } from "./web-css.js";
6
+ // src/vite-web.ts
7
+ var webCore = ["./web-core.js", "./web-core.ts"].map((name) => fileURLToPath(new URL(name, import.meta.url))).find((path) => existsSync(path));
8
+ /** Converts the app's own .css files (not those of packages) from NativeScript's CSS to the browser's. */
9
+ function nativeScriptCss() {
10
+ return {
11
+ name: "ember-nativescript:css",
12
+ enforce: "pre",
13
+ transform(code, id) {
14
+ const path = id.split("?")[0];
15
+ if (!path.endsWith(".css") || path.includes("/node_modules/")) return null;
16
+ return {
17
+ code: convertNativeScriptCss(code),
18
+ map: null
19
+ };
20
+ }
21
+ };
22
+ }
23
+ function emberWebConfig(overrides = {}) {
24
+ return mergeConfig({
25
+ plugins: [ember(), nativeScriptCss()],
26
+ resolve: { alias: [{
27
+ find: /^@nativescript\/core$/,
28
+ replacement: webCore
29
+ }] },
30
+ define: {
31
+ __WEB__: "true",
32
+ __IOS__: "false",
33
+ __ANDROID__: "false",
34
+ __APPLE__: "false",
35
+ __VISIONOS__: "false"
36
+ }
37
+ }, overrides);
38
+ }
39
+ export { emberWebConfig, nativeScriptCss };
40
+
41
+ //# sourceMappingURL=vite-web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-web.js","names":["existsSync","fileURLToPath","mergeConfig","ember","convertNativeScriptCss","webCore","map","name","URL","import","url","find","path","nativeScriptCss","enforce","transform","code","id","split","endsWith","includes","emberWebConfig","overrides","plugins","resolve","alias","replacement","define","__WEB__","__IOS__","__ANDROID__","__APPLE__","__VISIONOS__"],"sources":["../../src/vite-web.ts"],"sourcesContent":["// Vite config for an app's web build: .gts and decorators through vite-plugin-ember-gts, @nativescript/core replaced\n// by web-core.ts, `__WEB__` true and the native platforms false, and the app's NativeScript CSS converted to the web's\n// (units on sizes, NativeScript's view names as the adapter's classes).\n//\n// // vite.web.config.mts\n// import { defineConfig } from 'vite';\n// import { emberWebConfig } from 'ember-nativescript/vite-web';\n//\n// export default defineConfig(emberWebConfig());\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nimport { mergeConfig, type Plugin, type UserConfig } from 'vite';\nimport ember from 'vite-plugin-ember-gts';\n\nimport { convertNativeScriptCss } from './web-css.ts';\n\n// web-core.ts here, web-core.js once built into dist/.\nconst webCore = ['./web-core.js', './web-core.ts']\n .map((name) => fileURLToPath(new URL(name, import.meta.url)))\n .find((path) => existsSync(path))!;\n\n/** Converts the app's own .css files (not those of packages) from NativeScript's CSS to the browser's. */\nexport function nativeScriptCss(): Plugin {\n return {\n name: 'ember-nativescript:css',\n enforce: 'pre',\n transform(code, id) {\n const path = id.split('?')[0]!;\n if (!path.endsWith('.css') || path.includes('/node_modules/')) return null;\n return { code: convertNativeScriptCss(code), map: null };\n },\n };\n}\n\nexport function emberWebConfig(overrides: UserConfig = {}): UserConfig {\n return mergeConfig(\n {\n plugins: [ember(), nativeScriptCss()],\n resolve: { alias: [{ find: /^@nativescript\\/core$/, replacement: webCore }] },\n define: { __WEB__: 'true', __IOS__: 'false', __ANDROID__: 'false', __APPLE__: 'false', __VISIONOS__: 'false' },\n } as UserConfig,\n overrides,\n );\n}\n"],"mappings":";;;;;;AAkBA,IAAMK,UAAU,CAAC,iBAAiB,eAAe,CAAC,CAC/CC,KAAKC,SAASN,cAAc,IAAIO,IAAID,MAAME,YAAYC,GAAG,CAAC,CAAC,CAAC,CAC5DC,MAAMC,SAASZ,WAAWY,IAAI,CAAC;;AAGlC,SAAgBC,kBAA0B;CACxC,OAAO;EACLN,MAAM;EACNO,SAAS;EACTC,UAAUC,MAAMC,IAAI;GAClB,MAAML,OAAOK,GAAGC,MAAM,GAAG,CAAC,CAAC;GAC3B,IAAI,CAACN,KAAKO,SAAS,MAAM,KAAKP,KAAKQ,SAAS,gBAAgB,GAAG,OAAO;GACtE,OAAO;IAAEJ,MAAMZ,uBAAuBY,IAAI;IAAGV,KAAK;GAAK;EACzD;CACF;AACF;AAEA,SAAgBe,eAAeC,YAAwB,CAAC,GAAe;CACrE,OAAOpB,YACL;EACEqB,SAAS,CAACpB,MAAM,GAAGU,gBAAgB,CAAC;EACpCW,SAAS,EAAEC,OAAO,CAAC;GAAEd,MAAM;GAAyBe,aAAarB;EAAQ,CAAC,EAAE;EAC5EsB,QAAQ;GAAEC,SAAS;GAAQC,SAAS;GAASC,aAAa;GAASC,WAAW;GAASC,cAAc;EAAQ;CAC/G,GACAV,SACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/vite.ts"],"names":[],"mappings":"AAcA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,oHAAoH;IACpH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,WAAW,CACzB,EAAE,IAAI,EAAE,WAA2B,EAAE,EAAE,kBAAkB,EACzD,SAAS,GAAE,UAAe,GACzB,UAAU,CAUZ"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/vite.ts"],"names":[],"mappings":"AAcA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,oHAAoH;IACpH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,WAAW,CACzB,EAAE,IAAI,EAAE,WAA2B,EAAE,EAAE,kBAAkB,EACzD,SAAS,GAAE,UAAe,GACzB,UAAU,CAcZ"}
package/dist/src/vite.js CHANGED
@@ -7,7 +7,10 @@ function emberConfig({ mode, projectRoot = process.cwd() }, overrides = {}) {
7
7
  const excludes = /* @__PURE__ */ new Set([...(process.env.NS_VENDOR_EXCLUDE ?? "").split(",").map((name) => name.trim()), ...emberVendorExcludes(projectRoot)]);
8
8
  excludes.delete("");
9
9
  process.env.NS_VENDOR_EXCLUDE = [...excludes].join(",");
10
- return mergeConfig(mergeConfig(typescriptConfig({ mode }), { plugins: [ember()] }), overrides);
10
+ return mergeConfig(mergeConfig(typescriptConfig({ mode }), {
11
+ plugins: [ember()],
12
+ define: { __WEB__: "false" }
13
+ }), overrides);
11
14
  }
12
15
  export { emberConfig, emberVendorExcludes };
13
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":["typescriptConfig","mergeConfig","ember","emberVendorExcludes","emberConfig","mode","projectRoot","process","cwd","overrides","excludes","Set","env","NS_VENDOR_EXCLUDE","split","map","name","trim","delete","join","plugins"],"sources":["../../src/vite.ts"],"sourcesContent":["// Vite config for an Ember app on NativeScript: NativeScript's TypeScript config, vite-plugin-ember-gts for .gts\n// components and decorators, and Ember kept out of the HMR dev server's vendor bundle.\n//\n// // vite.config.mts\n// import { defineConfig } from 'vite';\n// import { emberConfig } from 'ember-nativescript/vite';\n//\n// export default defineConfig(({ mode }) => emberConfig({ mode }));\n//\n// Why the vendor bundle: under `ns run` (HMR), @nativescript/vite pre-bundles the app's dependencies with esbuild,\n// without Vite's plugins. ember-source has no root entry, and Ember packages import `@ember/*` and `@glimmer/*`,\n// which only vite-plugin-ember-gts resolves (to ember-source's modules). Kept out of the vendor bundle, they are\n// served module by module through the dev server, where the plugin resolves them.\nimport { typescriptConfig } from '@nativescript/vite/typescript';\nimport { mergeConfig, type UserConfig } from 'vite';\nimport ember from 'vite-plugin-ember-gts';\n\nimport { emberVendorExcludes } from './vendor-excludes.ts';\n\nexport { emberVendorExcludes };\n\nexport interface EmberConfigOptions {\n mode: string;\n /** The app's folder, where its package.json is. Defaults to the working directory, as the NativeScript CLI runs. */\n projectRoot?: string;\n}\n\nexport function emberConfig(\n { mode, projectRoot = process.cwd() }: EmberConfigOptions,\n overrides: UserConfig = {},\n): UserConfig {\n const excludes = new Set([\n ...(process.env.NS_VENDOR_EXCLUDE ?? '').split(',').map((name) => name.trim()),\n ...emberVendorExcludes(projectRoot),\n ]);\n excludes.delete('');\n // @nativescript/vite reads this when it collects the vendor bundle, after the config has loaded.\n process.env.NS_VENDOR_EXCLUDE = [...excludes].join(',');\n\n return mergeConfig(mergeConfig(typescriptConfig({ mode }), { plugins: [ember()] }), overrides);\n}\n"],"mappings":";;;;;AA2BA,SAAgBI,YACd,EAAEC,MAAMC,cAAcC,QAAQC,IAAI,KAClCC,YAAwB,CAAC,GACb;CACZ,MAAMC,2BAAW,IAAIC,IAAI,CACvB,IAAIJ,QAAQK,IAAIC,qBAAqB,GAAA,CAAIC,MAAM,GAAG,CAAC,CAACC,KAAKC,SAASA,KAAKC,KAAK,CAAC,GAC7E,GAAGd,oBAAoBG,WAAW,CAAC,CACpC;CACDI,SAASQ,OAAO,EAAE;CAElBX,QAAQK,IAAIC,oBAAoB,CAAC,GAAGH,QAAQ,CAAC,CAACS,KAAK,GAAG;CAEtD,OAAOlB,YAAYA,YAAYD,iBAAiB,EAAEK,KAAK,CAAC,GAAG,EAAEe,SAAS,CAAClB,MAAM,CAAC,EAAE,CAAC,GAAGO,SAAS;AAC/F"}
1
+ {"version":3,"file":"vite.js","names":["typescriptConfig","mergeConfig","ember","emberVendorExcludes","emberConfig","mode","projectRoot","process","cwd","overrides","excludes","Set","env","NS_VENDOR_EXCLUDE","split","map","name","trim","delete","join","plugins","define","__WEB__"],"sources":["../../src/vite.ts"],"sourcesContent":["// Vite config for an Ember app on NativeScript: NativeScript's TypeScript config, vite-plugin-ember-gts for .gts\n// components and decorators, and Ember kept out of the HMR dev server's vendor bundle.\n//\n// // vite.config.mts\n// import { defineConfig } from 'vite';\n// import { emberConfig } from 'ember-nativescript/vite';\n//\n// export default defineConfig(({ mode }) => emberConfig({ mode }));\n//\n// Why the vendor bundle: under `ns run` (HMR), @nativescript/vite pre-bundles the app's dependencies with esbuild,\n// without Vite's plugins. ember-source has no root entry, and Ember packages import `@ember/*` and `@glimmer/*`,\n// which only vite-plugin-ember-gts resolves (to ember-source's modules). Kept out of the vendor bundle, they are\n// served module by module through the dev server, where the plugin resolves them.\nimport { typescriptConfig } from '@nativescript/vite/typescript';\nimport { mergeConfig, type UserConfig } from 'vite';\nimport ember from 'vite-plugin-ember-gts';\n\nimport { emberVendorExcludes } from './vendor-excludes.ts';\n\nexport { emberVendorExcludes };\n\nexport interface EmberConfigOptions {\n mode: string;\n /** The app's folder, where its package.json is. Defaults to the working directory, as the NativeScript CLI runs. */\n projectRoot?: string;\n}\n\nexport function emberConfig(\n { mode, projectRoot = process.cwd() }: EmberConfigOptions,\n overrides: UserConfig = {},\n): UserConfig {\n const excludes = new Set([\n ...(process.env.NS_VENDOR_EXCLUDE ?? '').split(',').map((name) => name.trim()),\n ...emberVendorExcludes(projectRoot),\n ]);\n excludes.delete('');\n // @nativescript/vite reads this when it collects the vendor bundle, after the config has loaded.\n process.env.NS_VENDOR_EXCLUDE = [...excludes].join(',');\n\n // `__WEB__` is false on a phone, so `if (__WEB__)` blocks are dropped from the bundle (vite-web.ts sets it true).\n return mergeConfig(\n mergeConfig(typescriptConfig({ mode }), { plugins: [ember()], define: { __WEB__: 'false' } }),\n overrides,\n );\n}\n"],"mappings":";;;;;AA2BA,SAAgBI,YACd,EAAEC,MAAMC,cAAcC,QAAQC,IAAI,KAClCC,YAAwB,CAAC,GACb;CACZ,MAAMC,2BAAW,IAAIC,IAAI,CACvB,IAAIJ,QAAQK,IAAIC,qBAAqB,GAAA,CAAIC,MAAM,GAAG,CAAC,CAACC,KAAKC,SAASA,KAAKC,KAAK,CAAC,GAC7E,GAAGd,oBAAoBG,WAAW,CAAC,CACpC;CACDI,SAASQ,OAAO,EAAE;CAElBX,QAAQK,IAAIC,oBAAoB,CAAC,GAAGH,QAAQ,CAAC,CAACS,KAAK,GAAG;CAGtD,OAAOlB,YACLA,YAAYD,iBAAiB,EAAEK,KAAK,CAAC,GAAG;EAAEe,SAAS,CAAClB,MAAM,CAAC;EAAGmB,QAAQ,EAAEC,SAAS,QAAQ;CAAE,CAAC,GAC5Fb,SACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/vitest.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAQpD,wBAAgB,eAAe,CAAC,SAAS,GAAE,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GAAG,UAAU,CAc3G"}
1
+ {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/vitest.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAQpD,wBAAgB,eAAe,CAAC,SAAS,GAAE,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GAAG,UAAU,CAgB3G"}
@@ -11,6 +11,7 @@ function emberTestConfig(overrides = {}) {
11
11
  find: /^@nativescript\/core$/,
12
12
  replacement: stub
13
13
  }] },
14
+ define: { __WEB__: "false" },
14
15
  test: {
15
16
  environment: "node",
16
17
  include: ["tests/**/*.test.ts"],
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.js","names":["existsSync","fileURLToPath","mergeConfig","ember","stub","map","name","URL","import","url","find","path","emberTestConfig","overrides","plugins","resolve","alias","replacement","test","environment","include","server","deps","inline"],"sources":["../../src/vitest.ts"],"sourcesContent":["// Vitest config for an Ember app on NativeScript: .gts components and decorators through vite-plugin-ember-gts, Node\n// as the environment, and a stub for @nativescript/core (testing-core.ts), so the app's modules and ember-nativescript\n// load without a phone. Pair it with startApp from 'ember-nativescript/testing'.\n//\n// // vitest.config.mts\n// import { defineConfig } from 'vitest/config';\n// import { emberTestConfig } from 'ember-nativescript/vitest';\n//\n// export default defineConfig(emberTestConfig());\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nimport { mergeConfig, type UserConfig } from 'vite';\nimport ember from 'vite-plugin-ember-gts';\n\n// testing-core.ts here, testing-core.js once built into dist/.\nconst stub = ['./testing-core.js', './testing-core.ts']\n .map((name) => fileURLToPath(new URL(name, import.meta.url)))\n .find((path) => existsSync(path))!;\n\nexport function emberTestConfig(overrides: UserConfig & { test?: Record<string, unknown> } = {}): UserConfig {\n return mergeConfig(\n {\n plugins: [ember()],\n resolve: { alias: [{ find: /^@nativescript\\/core$/, replacement: stub }] },\n test: {\n environment: 'node',\n include: ['tests/**/*.test.ts'],\n // Run ember-nativescript through Vite, so its own imports of @nativescript/core get the stub too.\n server: { deps: { inline: ['ember-nativescript'] } },\n },\n } as UserConfig,\n overrides,\n );\n}\n"],"mappings":";;;;;AAgBA,IAAMI,OAAO,CAAC,qBAAqB,mBAAmB,CAAC,CACpDC,KAAKC,SAASL,cAAc,IAAIM,IAAID,MAAME,YAAYC,GAAG,CAAC,CAAC,CAAC,CAC5DC,MAAMC,SAASX,WAAWW,IAAI,CAAC;AAElC,SAAgBC,gBAAgBC,YAA6D,CAAC,GAAe;CAC3G,OAAOX,YACL;EACEY,SAAS,CAACX,MAAM,CAAC;EACjBY,SAAS,EAAEC,OAAO,CAAC;GAAEN,MAAM;GAAyBO,aAAab;EAAK,CAAC,EAAE;EACzEc,MAAM;GACJC,aAAa;GACbC,SAAS,CAAC,oBAAoB;GAE9BC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,CAAC,oBAAoB,EAAE,EAAE;EACrD;CACF,GACAV,SACF;AACF"}
1
+ {"version":3,"file":"vitest.js","names":["existsSync","fileURLToPath","mergeConfig","ember","stub","map","name","URL","import","url","find","path","emberTestConfig","overrides","plugins","resolve","alias","replacement","define","__WEB__","test","environment","include","server","deps","inline"],"sources":["../../src/vitest.ts"],"sourcesContent":["// Vitest config for an Ember app on NativeScript: .gts components and decorators through vite-plugin-ember-gts, Node\n// as the environment, and a stub for @nativescript/core (testing-core.ts), so the app's modules and ember-nativescript\n// load without a phone. Pair it with startApp from 'ember-nativescript/testing'.\n//\n// // vitest.config.mts\n// import { defineConfig } from 'vitest/config';\n// import { emberTestConfig } from 'ember-nativescript/vitest';\n//\n// export default defineConfig(emberTestConfig());\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nimport { mergeConfig, type UserConfig } from 'vite';\nimport ember from 'vite-plugin-ember-gts';\n\n// testing-core.ts here, testing-core.js once built into dist/.\nconst stub = ['./testing-core.js', './testing-core.ts']\n .map((name) => fileURLToPath(new URL(name, import.meta.url)))\n .find((path) => existsSync(path))!;\n\nexport function emberTestConfig(overrides: UserConfig & { test?: Record<string, unknown> } = {}): UserConfig {\n return mergeConfig(\n {\n plugins: [ember()],\n resolve: { alias: [{ find: /^@nativescript\\/core$/, replacement: stub }] },\n // The tests run the app as on a phone.\n define: { __WEB__: 'false' },\n test: {\n environment: 'node',\n include: ['tests/**/*.test.ts'],\n // Run ember-nativescript through Vite, so its own imports of @nativescript/core get the stub too.\n server: { deps: { inline: ['ember-nativescript'] } },\n },\n } as UserConfig,\n overrides,\n );\n}\n"],"mappings":";;;;;AAgBA,IAAMI,OAAO,CAAC,qBAAqB,mBAAmB,CAAC,CACpDC,KAAKC,SAASL,cAAc,IAAIM,IAAID,MAAME,YAAYC,GAAG,CAAC,CAAC,CAAC,CAC5DC,MAAMC,SAASX,WAAWW,IAAI,CAAC;AAElC,SAAgBC,gBAAgBC,YAA6D,CAAC,GAAe;CAC3G,OAAOX,YACL;EACEY,SAAS,CAACX,MAAM,CAAC;EACjBY,SAAS,EAAEC,OAAO,CAAC;GAAEN,MAAM;GAAyBO,aAAab;EAAK,CAAC,EAAE;EAEzEc,QAAQ,EAAEC,SAAS,QAAQ;EAC3BC,MAAM;GACJC,aAAa;GACbC,SAAS,CAAC,oBAAoB;GAE9BC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,CAAC,oBAAoB,EAAE,EAAE;EACrD;CACF,GACAZ,SACF;AACF"}