ember-nativescript 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/components/Platform.d.ts +7 -0
- package/dist/components/Platform.d.ts.map +1 -1
- package/dist/components/Platform.js +9 -2
- package/dist/components/Platform.js.map +1 -1
- package/dist/components/RouteError.d.ts +8 -0
- package/dist/components/RouteError.d.ts.map +1 -0
- package/dist/components/RouteError.js +13 -0
- package/dist/components/RouteError.js.map +1 -0
- package/dist/src/adapter.d.ts +3 -2
- package/dist/src/adapter.d.ts.map +1 -1
- package/dist/src/application-entry.d.ts +4 -0
- package/dist/src/application-entry.d.ts.map +1 -0
- package/dist/src/application-entry.js +4 -0
- package/dist/src/application-testing.d.ts +19 -0
- package/dist/src/application-testing.d.ts.map +1 -0
- package/dist/src/application-testing.js +32 -0
- package/dist/src/application-testing.js.map +1 -0
- package/dist/src/application.d.ts +45 -0
- package/dist/src/application.d.ts.map +1 -0
- package/dist/src/application.js +136 -0
- package/dist/src/application.js.map +1 -0
- package/dist/src/dom.js +1 -1
- package/dist/src/dom.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/nativescript-application.d.ts +8 -0
- package/dist/src/nativescript-application.d.ts.map +1 -0
- package/dist/src/nativescript-application.js +23 -0
- package/dist/src/nativescript-application.js.map +1 -0
- package/dist/src/navigator.d.ts +6 -0
- package/dist/src/navigator.d.ts.map +1 -1
- package/dist/src/navigator.js +6 -1
- package/dist/src/navigator.js.map +1 -1
- package/dist/src/platform.d.ts +4 -2
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.js +2 -1
- package/dist/src/platform.js.map +1 -1
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js.map +1 -1
- package/dist/src/testing.d.ts +2 -0
- package/dist/src/testing.d.ts.map +1 -1
- package/dist/src/testing.js +7 -2
- package/dist/src/testing.js.map +1 -1
- package/dist/src/vite-web.d.ts +5 -0
- package/dist/src/vite-web.d.ts.map +1 -0
- package/dist/src/vite-web.js +41 -0
- package/dist/src/vite-web.js.map +1 -0
- package/dist/src/vite.d.ts.map +1 -1
- package/dist/src/vite.js +4 -1
- package/dist/src/vite.js.map +1 -1
- package/dist/src/vitest.d.ts.map +1 -1
- package/dist/src/vitest.js +1 -0
- package/dist/src/vitest.js.map +1 -1
- package/dist/src/web-adapter.d.ts +31 -0
- package/dist/src/web-adapter.d.ts.map +1 -0
- package/dist/src/web-adapter.js +664 -0
- package/dist/src/web-adapter.js.map +1 -0
- package/dist/src/web-app.d.ts +29 -0
- package/dist/src/web-app.d.ts.map +1 -0
- package/dist/src/web-app.js +61 -0
- package/dist/src/web-app.js.map +1 -0
- package/dist/src/web-application.d.ts +10 -0
- package/dist/src/web-application.d.ts.map +1 -0
- package/dist/src/web-application.js +37 -0
- package/dist/src/web-application.js.map +1 -0
- package/dist/src/web-core.d.ts +56 -0
- package/dist/src/web-core.d.ts.map +1 -0
- package/dist/src/web-core.js +84 -0
- package/dist/src/web-core.js.map +1 -0
- package/dist/src/web-css.d.ts +7 -0
- package/dist/src/web-css.d.ts.map +1 -0
- package/dist/src/web-css.js +118 -0
- package/dist/src/web-css.js.map +1 -0
- package/dist/src/web-host.d.ts +25 -0
- package/dist/src/web-host.d.ts.map +1 -0
- package/dist/src/web-host.js +172 -0
- package/dist/src/web-host.js.map +1 -0
- package/dist/src/web-list.d.ts +18 -0
- package/dist/src/web-list.d.ts.map +1 -0
- package/dist/src/web-list.js +224 -0
- package/dist/src/web-list.js.map +1 -0
- package/dist/src/web-router.d.ts +51 -0
- package/dist/src/web-router.d.ts.map +1 -0
- package/dist/src/web-router.js +83 -0
- package/dist/src/web-router.js.map +1 -0
- package/dist/src/web-styles.d.ts +4 -0
- package/dist/src/web-styles.d.ts.map +1 -0
- package/dist/src/web-styles.js +160 -0
- package/dist/src/web-styles.js.map +1 -0
- package/dist/src/web.d.ts +7 -0
- package/dist/src/web.d.ts.map +1 -0
- package/dist/src/web.js +7 -0
- package/dist/types/glint.d.ts +6 -1
- package/package.json +35 -16
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 };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RoutedApp, type StartApplicationOptions } from './application.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs NativeScript with a Frame, boots the Ember Application, and shows the route at `url` in the Frame. Resolves
|
|
4
|
+
* once the first screen is on its way. NativeScript needs `Application.run` right away, so the Frame comes up empty
|
|
5
|
+
* for the moment the boot takes (under the splash screen), and a Frame queues the first page until it's loaded.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createNativeApplication(options?: StartApplicationOptions): Promise<RoutedApp>;
|
|
8
|
+
//# sourceMappingURL=nativescript-application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativescript-application.d.ts","sourceRoot":"","sources":["../../src/nativescript-application.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,uBAAuB,EAAkB,MAAM,kBAAkB,CAAC;AAMhG;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,SAAS,CAAC,CAQjG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Application, Frame } from "@nativescript/core";
|
|
2
|
+
import { startRoutedApp } from "./application.js";
|
|
3
|
+
import { FrameNavigationHost } from "./frame-host.js";
|
|
4
|
+
import { NativeScriptAdapter } from "./nativescript-adapter.js";
|
|
5
|
+
import { createDocument } from "./render.js";
|
|
6
|
+
// src/nativescript-application.ts
|
|
7
|
+
/**
|
|
8
|
+
* Runs NativeScript with a Frame, boots the Ember Application, and shows the route at `url` in the Frame. Resolves
|
|
9
|
+
* once the first screen is on its way. NativeScript needs `Application.run` right away, so the Frame comes up empty
|
|
10
|
+
* for the moment the boot takes (under the splash screen), and a Frame queues the first page until it's loaded.
|
|
11
|
+
*/
|
|
12
|
+
function createNativeApplication(options = {}) {
|
|
13
|
+
const document = createDocument(new NativeScriptAdapter());
|
|
14
|
+
const frame = new Frame();
|
|
15
|
+
Application.run({ create: () => frame });
|
|
16
|
+
return startRoutedApp(document, new FrameNavigationHost(frame), options).catch((error) => {
|
|
17
|
+
console.error("[ember-nativescript] The Ember Application failed to boot:", error);
|
|
18
|
+
throw error;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export { createNativeApplication };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=nativescript-application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativescript-application.js","names":["Application","Frame","startRoutedApp","FrameNavigationHost","NativeScriptAdapter","createDocument","createNativeApplication","options","document","frame","run","create","catch","error","console"],"sources":["../../src/nativescript-application.ts"],"sourcesContent":["// Opt-in: starts a full Ember Application on NativeScript, with Ember's router choosing the screens (see\n// application.ts). The default, createNativeApp, stays as it is: a thin owner and the navigator.\n//\n// // src/app.ts\n// import { createNativeApplication } from 'ember-nativescript/application';\n// createNativeApplication({\n// modules: import.meta.glob('./{router.ts,routes,controllers,services,templates}/**', { eager: true }),\n// });\n\nimport { Application, Frame } from '@nativescript/core';\n\nimport { type RoutedApp, type StartApplicationOptions, startRoutedApp } from './application.ts';\nimport { FrameNavigationHost } from './frame-host.ts';\nimport { NativeScriptAdapter } from './nativescript-adapter.ts';\nimport type { FrameHost } from './navigator.ts';\nimport { createDocument } from './render.ts';\n\n/**\n * Runs NativeScript with a Frame, boots the Ember Application, and shows the route at `url` in the Frame. Resolves\n * once the first screen is on its way. NativeScript needs `Application.run` right away, so the Frame comes up empty\n * for the moment the boot takes (under the splash screen), and a Frame queues the first page until it's loaded.\n */\nexport function createNativeApplication(options: StartApplicationOptions = {}): Promise<RoutedApp> {\n const document = createDocument(new NativeScriptAdapter());\n const frame = new Frame();\n Application.run({ create: () => frame });\n return startRoutedApp(document, new FrameNavigationHost(frame) as FrameHost, options).catch((error: unknown) => {\n console.error('[ember-nativescript] The Ember Application failed to boot:', error);\n throw error;\n });\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgBM,wBAAwBC,UAAmC,CAAC,GAAuB;CACjG,MAAMC,WAAWH,eAAe,IAAID,oBAAoB,CAAC;CACzD,MAAMK,QAAQ,IAAIR,MAAM;CACxBD,YAAYU,IAAI,EAAEC,cAAcF,MAAM,CAAC;CACvC,OAAOP,eAAeM,UAAU,IAAIL,oBAAoBM,KAAK,GAAgBF,OAAO,CAAC,CAACK,OAAOC,UAAmB;EAC9GC,QAAQD,MAAM,8DAA8DA,KAAK;EACjF,MAAMA;CACR,CAAC;AACH"}
|
package/dist/src/navigator.d.ts
CHANGED
|
@@ -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;IAC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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;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derNative","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":";;;;AA2E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AE,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"}
|
package/dist/src/platform.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare
|
|
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":"
|
|
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"}
|
package/dist/src/platform.js
CHANGED
|
@@ -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
|
-
|
|
9
|
+
var isWeb = () => current === "web";
|
|
10
|
+
export { isAndroid, isIOS, isWeb, platform, setPlatform };
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=platform.js.map
|
package/dist/src/platform.js.map
CHANGED
|
@@ -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.\
|
|
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"}
|
package/dist/src/render.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/src/render.js.map
CHANGED
|
@@ -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":";;;;
|
|
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"}
|
package/dist/src/testing.d.ts
CHANGED
|
@@ -35,4 +35,6 @@ export interface TestApp {
|
|
|
35
35
|
}
|
|
36
36
|
/** Starts the app on its first screen, as createNativeApp does on a phone, and waits for it to render. */
|
|
37
37
|
export declare function startApp(main: object, options?: StartAppOptions): Promise<TestApp>;
|
|
38
|
+
/** The helpers of a TestApp, for an app already started on a fake Frame. */
|
|
39
|
+
export declare function testApp(owner: NativeOwner, nav: Navigator, frame: FakeFrame): TestApp;
|
|
38
40
|
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5F,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,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,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,8EAA8E;IAC9E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,sFAAsF;IACtF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,uEAAuE;IACvE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,kDAAkD;IAClD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC;IAC5B,uGAAuG;IACvG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAQD,0GAA0G;AAC1G,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAU5F;AAED,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CA6CrF"}
|
package/dist/src/testing.js
CHANGED
|
@@ -25,6 +25,12 @@ async function startApp(main, options = {}) {
|
|
|
25
25
|
name: "main",
|
|
26
26
|
animated: false
|
|
27
27
|
});
|
|
28
|
+
const app = testApp(owner, nav, frame);
|
|
29
|
+
await app.settled();
|
|
30
|
+
return app;
|
|
31
|
+
}
|
|
32
|
+
/** The helpers of a TestApp, for an app already started on a fake Frame. */
|
|
33
|
+
function testApp(owner, nav, frame) {
|
|
28
34
|
const view = (target) => typeof target === "string" ? app.find(target) : target;
|
|
29
35
|
const settled = async () => {
|
|
30
36
|
await renderSettled();
|
|
@@ -66,9 +72,8 @@ async function startApp(main, options = {}) {
|
|
|
66
72
|
service: (name) => owner.lookup(`service:${name}`),
|
|
67
73
|
settled
|
|
68
74
|
};
|
|
69
|
-
await settled();
|
|
70
75
|
return app;
|
|
71
76
|
}
|
|
72
|
-
export { FAKE_TAGS, FAKE_UNLOADED_TAGS, FakeFrame, FakeView, startApp };
|
|
77
|
+
export { FAKE_TAGS, FAKE_UNLOADED_TAGS, FakeFrame, FakeView, startApp, testApp };
|
|
73
78
|
|
|
74
79
|
//# sourceMappingURL=testing.js.map
|
package/dist/src/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","names":["renderSettled","FakeAdapter","FakeFrame","Navigator","createOwner","createDocument","matches","selector","view","startsWith","props","get","slice","split","includes","tag","startApp","main","options","document","platform","owner","services","modules","frame","nav","register","instantiate","navigate","args","name","animated","
|
|
1
|
+
{"version":3,"file":"testing.js","names":["renderSettled","FakeAdapter","FakeFrame","Navigator","createOwner","createDocument","matches","selector","view","startsWith","props","get","slice","split","includes","tag","startApp","main","options","document","platform","owner","services","modules","frame","nav","register","instantiate","navigate","args","name","animated","app","testApp","settled","target","find","list","top","findAll","each","undefined","layout","page","found","Error","toXML","fire","event","data","notify","tap","tapRow","index","String","type","text","back","service","lookup"],"sources":["../../src/testing.ts"],"sourcesContent":["// Tests for an app, in Node and without a phone: the app's screens render into fake views that keep their properties,\n// children and listeners, and a fake Frame that navigates as NativeScript's does.\n//\n// const app = await startApp(Home, { services: { session: Session } });\n// await app.type('#name', 'Ada');\n// await app.tap('.save');\n// expect(app.find('.greeting').text).toBe('Hello, Ada');\n//\n// Run them with Vitest and `emberTestConfig()` from 'ember-nativescript/vitest', which stands a stub in for\n// @nativescript/core. Native code (animations, the GPS, a plugin's view) doesn't run here: stub it with vi.mock.\nimport { renderSettled } from '@ember/renderer';\n\nimport { FakeAdapter, FakeFrame, type FakeView } from './fake-adapter.ts';\nimport { Navigator } from './navigator.ts';\nimport { createOwner, type Modules, type NativeOwner, type ServiceEntry } from './owner.ts';\nimport { createDocument } from './render.ts';\n\nexport { FAKE_TAGS, FAKE_UNLOADED_TAGS, FakeFrame, FakeView } from './fake-adapter.ts';\n\nexport interface StartAppOptions {\n args?: Record<string, unknown>;\n services?: Record<string, ServiceEntry>;\n modules?: Modules;\n platform?: 'ios' | 'android';\n}\n\n/** A view, or a selector for one on the current screen: `#id`, `.class` or a tag. */\nexport type Target = FakeView | string;\n\nexport interface TestApp {\n owner: NativeOwner;\n nav: Navigator;\n frame: FakeFrame;\n /** The page on screen. */\n readonly page: FakeView;\n /** The first view on the current screen that matches; throws, printing the screen, when none does. */\n find(selector: string): FakeView;\n findAll(selector: string): FakeView[];\n /** Fires `tap` and waits for Ember to re-render. */\n tap(target: Target): Promise<void>;\n /** Taps the row at `index` of a NativeList, as a finger on that cell does. */\n tapRow(target: Target, index: number): Promise<void>;\n /** Types into a TextField or TextView: sets `text`, fires `textChange`, and waits. */\n type(target: Target, text: string): Promise<void>;\n /** Fires any event with its data, as NativeScript would, and waits. */\n fire(target: Target, event: string, data?: Record<string, unknown>): Promise<void>;\n /** The back button on Android, a swipe on iOS. */\n back(): Promise<void>;\n service<T>(name: string): T;\n /** Waits for Ember to re-render, then lays out the screen's lists, as the phone's next frame would. */\n settled(): Promise<void>;\n}\n\nconst matches = (selector: string) => (view: FakeView) => {\n if (selector.startsWith('#')) return view.props.get('id') === selector.slice(1);\n if (selector.startsWith('.')) return (view.props.get('class') ?? '').split(/\\s+/).includes(selector.slice(1));\n return view.tag === selector;\n};\n\n/** Starts the app on its first screen, as createNativeApp does on a phone, and waits for it to render. */\nexport async function startApp(main: object, options: StartAppOptions = {}): Promise<TestApp> {\n const document = createDocument(new FakeAdapter(options.platform ?? 'ios'));\n const owner = createOwner({ services: options.services, modules: options.modules });\n const frame = new FakeFrame();\n const nav = new Navigator(document, frame, owner);\n owner.register('service:navigator', nav, { instantiate: false });\n nav.navigate(main, { args: options.args, name: 'main', animated: false });\n const app = testApp(owner, nav, frame);\n await app.settled();\n return app;\n}\n\n/** The helpers of a TestApp, for an app already started on a fake Frame. */\nexport function testApp(owner: NativeOwner, nav: Navigator, frame: FakeFrame): TestApp {\n const view = (target: Target): FakeView => (typeof target === 'string' ? app.find(target) : target);\n // The lists show the rows that fit (ten), as ListView does once laid out: their cells are then on the screen.\n const settled = async (): Promise<void> => {\n await renderSettled();\n for (const list of frame.top.findAll((each) => each.list !== undefined)) list.list!.layout();\n await renderSettled();\n };\n\n const app: TestApp = {\n owner,\n nav,\n frame,\n get page() {\n return frame.top;\n },\n find(selector) {\n const found = frame.top.find(matches(selector));\n if (!found) throw new Error(`Nothing matches ${selector} on\\n${frame.top.toXML()}`);\n return found;\n },\n findAll: (selector) => frame.top.findAll(matches(selector)),\n async fire(target, event, data = {}) {\n view(target).notify(event, data);\n await settled();\n },\n tap: (target) => app.fire(target, 'tap'),\n async tapRow(target, index) {\n const list = view(target).list;\n if (!list) throw new Error(`${String(target)} is not a NativeList`);\n list.tap(index);\n await settled();\n },\n async type(target, text) {\n view(target).type(text);\n await settled();\n },\n async back() {\n frame.back();\n await settled();\n },\n service: <T>(name: string) => owner.lookup(`service:${name}`) as T,\n settled,\n };\n return app;\n}\n"],"mappings":";;;;;;;AAqDA,IAAMM,WAAWC,cAAsBC,SAAmB;CACxD,IAAID,SAASE,WAAW,GAAG,GAAG,OAAOD,KAAKE,MAAMC,IAAI,IAAI,MAAMJ,SAASK,MAAM,CAAC;CAC9E,IAAIL,SAASE,WAAW,GAAG,GAAG,QAAQD,KAAKE,MAAMC,IAAI,OAAO,KAAK,GAAA,CAAIE,MAAM,KAAK,CAAC,CAACC,SAASP,SAASK,MAAM,CAAC,CAAC;CAC5G,OAAOJ,KAAKO,QAAQR;AACtB;;AAGA,eAAsBS,SAASC,MAAcC,UAA2B,CAAC,GAAqB;CAC5F,MAAMC,WAAWd,eAAe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AOC,IAAI;GAC/B,MAAMf,QAAQ;EAChB;EACAiB,MAAMhB,WAAWH,IAAIe,KAAKZ,QAAQ,KAAK;EACvC,MAAMiB,OAAOjB,QAAQkB,OAAO;GAC1B,MAAMhB,OAAO7B,KAAK2B,MAAM,CAAC,CAACE;GAC1B,IAAI,CAACA,MAAM,MAAM,IAAIQ,MAAM,GAAGS,OAAOnB,MAAM,EAAC,qBAAsB;GAClEE,KAAKc,IAAIE,KAAK;GACd,MAAMnB,QAAQ;EAChB;EACA,MAAMqB,KAAKpB,QAAQqB,MAAM;GACvBhD,KAAK2B,MAAM,CAAC,CAACoB,KAAKC,IAAI;GACtB,MAAMtB,QAAQ;EAChB;EACA,MAAMuB,OAAO;GACXjC,MAAMiC,KAAK;GACX,MAAMvB,QAAQ;EAChB;EACAwB,UAAa5B,SAAiBT,MAAMsC,OAAO,WAAW7B,MAAM;EAC5DI;CACF;CACA,OAAOF;AACT"}
|
|
@@ -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"}
|
package/dist/src/vite.d.ts.map
CHANGED
|
@@ -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,
|
|
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 }), {
|
|
10
|
+
return mergeConfig(mergeConfig(typescriptConfig({ mode }), {
|
|
11
|
+
plugins: [ember()],
|
|
12
|
+
define: { __WEB__: "false" }
|
|
13
|
+
}), overrides);
|
|
11
14
|
}
|
|
12
15
|
export { emberConfig, emberVendorExcludes };
|
|
13
16
|
|
package/dist/src/vite.js.map
CHANGED
|
@@ -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()] })
|
|
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"}
|
package/dist/src/vitest.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/src/vitest.js
CHANGED
package/dist/src/vitest.js.map
CHANGED
|
@@ -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;
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ListBinding, Listener, ListOptions, NativeAdapter } from './adapter.js';
|
|
2
|
+
import type { FrameHost } from './navigator.js';
|
|
3
|
+
type View = HTMLElement;
|
|
4
|
+
/** Raises a NativeScript event on a view, with NativeScript's data shape: `{ eventName, object, …data }`. */
|
|
5
|
+
export declare function emit(view: View, eventName: string, data?: Record<string, unknown>): void;
|
|
6
|
+
/** Raises `loaded` on a view and everything in it, once it is in the document. */
|
|
7
|
+
export declare function emitLoaded(view: View): void;
|
|
8
|
+
/** A NativeScript length (device-independent pixels, a percentage, `auto`) as CSS. */
|
|
9
|
+
export declare function cssLength(value: unknown): string;
|
|
10
|
+
/** GridLayout's `rows`/`columns` (`'*, auto, 2*, 100'`) as a CSS grid template. */
|
|
11
|
+
export declare function gridTemplate(value: unknown): string;
|
|
12
|
+
/** The web adapter: NativeScript's views as HTML elements. */
|
|
13
|
+
export declare class WebAdapter implements NativeAdapter<View> {
|
|
14
|
+
#private;
|
|
15
|
+
readonly platform: "web";
|
|
16
|
+
createView(tag: string): View | null;
|
|
17
|
+
setProperty(view: View, name: string, value: unknown): void;
|
|
18
|
+
hasProperty(_view: View, name: string): boolean;
|
|
19
|
+
takesText(view: View): boolean;
|
|
20
|
+
insertChild(parent: View, child: View, index: number): void;
|
|
21
|
+
removeChild(_parent: View, child: View): void;
|
|
22
|
+
setSlot(parent: View, property: string, child: View | null): void;
|
|
23
|
+
insertInSlot(parent: View, property: string, child: View, index: number): void;
|
|
24
|
+
removeFromSlot(parent: View, _property: string, child: View): void;
|
|
25
|
+
on(view: View, event: string, listener: Listener): void;
|
|
26
|
+
off(view: View, event: string, listener: Listener): void;
|
|
27
|
+
frameHost(view: View): FrameHost<View> | null;
|
|
28
|
+
bindList(view: View, cell: (container: View, index: number) => void, options?: ListOptions): ListBinding | null;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=web-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-adapter.d.ts","sourceRoot":"","sources":["../../src/web-adapter.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAA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