ember-nativescript 0.1.0 → 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 (90) hide show
  1. package/README.md +111 -35
  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/fake-adapter.d.ts +4 -0
  11. package/dist/src/fake-adapter.d.ts.map +1 -1
  12. package/dist/src/fake-adapter.js +12 -3
  13. package/dist/src/fake-adapter.js.map +1 -1
  14. package/dist/src/index.d.ts +2 -2
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +3 -3
  17. package/dist/src/native-view.d.ts +2 -1
  18. package/dist/src/native-view.d.ts.map +1 -1
  19. package/dist/src/native-view.js +21 -1
  20. package/dist/src/native-view.js.map +1 -1
  21. package/dist/src/nativescript-adapter.d.ts.map +1 -1
  22. package/dist/src/nativescript-adapter.js +4 -0
  23. package/dist/src/nativescript-adapter.js.map +1 -1
  24. package/dist/src/navigator.d.ts +6 -0
  25. package/dist/src/navigator.d.ts.map +1 -1
  26. package/dist/src/navigator.js +6 -1
  27. package/dist/src/navigator.js.map +1 -1
  28. package/dist/src/platform.d.ts +4 -2
  29. package/dist/src/platform.d.ts.map +1 -1
  30. package/dist/src/platform.js +2 -1
  31. package/dist/src/platform.js.map +1 -1
  32. package/dist/src/render.d.ts.map +1 -1
  33. package/dist/src/render.js.map +1 -1
  34. package/dist/src/testing-core.d.ts +147 -0
  35. package/dist/src/testing-core.d.ts.map +1 -0
  36. package/dist/src/testing-core.js +110 -0
  37. package/dist/src/testing-core.js.map +1 -0
  38. package/dist/src/testing.d.ts +38 -0
  39. package/dist/src/testing.d.ts.map +1 -0
  40. package/dist/src/testing.js +74 -0
  41. package/dist/src/testing.js.map +1 -0
  42. package/dist/src/vendor-excludes.d.ts +6 -0
  43. package/dist/src/vendor-excludes.d.ts.map +1 -0
  44. package/dist/src/vendor-excludes.js +38 -0
  45. package/dist/src/vendor-excludes.js.map +1 -0
  46. package/dist/src/vite-web.d.ts +5 -0
  47. package/dist/src/vite-web.d.ts.map +1 -0
  48. package/dist/src/vite-web.js +41 -0
  49. package/dist/src/vite-web.js.map +1 -0
  50. package/dist/src/vite.d.ts +10 -0
  51. package/dist/src/vite.d.ts.map +1 -0
  52. package/dist/src/vite.js +17 -0
  53. package/dist/src/vite.js.map +1 -0
  54. package/dist/src/vitest.d.ts +5 -0
  55. package/dist/src/vitest.d.ts.map +1 -0
  56. package/dist/src/vitest.js +24 -0
  57. package/dist/src/vitest.js.map +1 -0
  58. package/dist/src/web-adapter.d.ts +31 -0
  59. package/dist/src/web-adapter.d.ts.map +1 -0
  60. package/dist/src/web-adapter.js +701 -0
  61. package/dist/src/web-adapter.js.map +1 -0
  62. package/dist/src/web-app.d.ts +23 -0
  63. package/dist/src/web-app.d.ts.map +1 -0
  64. package/dist/src/web-app.js +53 -0
  65. package/dist/src/web-app.js.map +1 -0
  66. package/dist/src/web-core.d.ts +56 -0
  67. package/dist/src/web-core.d.ts.map +1 -0
  68. package/dist/src/web-core.js +84 -0
  69. package/dist/src/web-core.js.map +1 -0
  70. package/dist/src/web-css.d.ts +7 -0
  71. package/dist/src/web-css.d.ts.map +1 -0
  72. package/dist/src/web-css.js +118 -0
  73. package/dist/src/web-css.js.map +1 -0
  74. package/dist/src/web-host.d.ts +18 -0
  75. package/dist/src/web-host.d.ts.map +1 -0
  76. package/dist/src/web-host.js +165 -0
  77. package/dist/src/web-host.js.map +1 -0
  78. package/dist/src/web-router.d.ts +51 -0
  79. package/dist/src/web-router.d.ts.map +1 -0
  80. package/dist/src/web-router.js +83 -0
  81. package/dist/src/web-router.js.map +1 -0
  82. package/dist/src/web-styles.d.ts +4 -0
  83. package/dist/src/web-styles.d.ts.map +1 -0
  84. package/dist/src/web-styles.js +157 -0
  85. package/dist/src/web-styles.js.map +1 -0
  86. package/dist/src/web.d.ts +7 -0
  87. package/dist/src/web.d.ts.map +1 -0
  88. package/dist/src/web.js +7 -0
  89. package/dist/types/glint.d.ts +6 -1
  90. package/package.json +58 -15
@@ -0,0 +1,165 @@
1
+ import { emit, emitLoaded } from "./web-adapter.js";
2
+ // src/web-host.ts
3
+ var DURATION = 280;
4
+ var EASE = "cubic-bezier(0.2, 0.8, 0.2, 1)";
5
+ /** Moves between screens in a browser. With a router, it keeps the URL and the browser's history in step. */
6
+ var WebFrameHost = class {
7
+ frame;
8
+ router;
9
+ #stack = [];
10
+ #modals = [];
11
+ #app = Math.random().toString(36).slice(2);
12
+ #ignorePops = 0;
13
+ #restoring = false;
14
+ constructor(frame, router) {
15
+ this.frame = frame;
16
+ this.router = router;
17
+ if (router) addEventListener("popstate", this.#onPopState);
18
+ }
19
+ show(page, options) {
20
+ const previous = this.#stack.at(-1);
21
+ const dropped = options.clearHistory ? this.#stack.splice(0) : previous && !previous.backstackVisible ? [this.#stack.pop()] : [];
22
+ this.#stack.push({
23
+ page,
24
+ backstackVisible: options.backstackVisible
25
+ });
26
+ if (this.router) this.#record(options);
27
+ page.classList.add("ns-current");
28
+ this.frame.append(page);
29
+ emitLoaded(page);
30
+ if (previous) emit(previous.page, "navigatingFrom", { isBackNavigation: false });
31
+ emit(page, "navigatingTo", { isBackNavigation: false });
32
+ const finish = () => {
33
+ if (previous) {
34
+ previous.page.classList.remove("ns-current");
35
+ previous.page.inert = true;
36
+ emit(previous.page, "navigatedFrom", { isBackNavigation: false });
37
+ }
38
+ for (const entry of dropped) entry.page.remove();
39
+ emit(page, "navigatedTo", { isBackNavigation: false });
40
+ };
41
+ if (!options.animated || !previous || prefersLessMotion()) return finish();
42
+ slide(page, ["100%", "0%"], previous.page, ["0%", "-30%"]).then(finish);
43
+ }
44
+ back() {
45
+ if (this.#stack.length < 2) return;
46
+ if (this.router && history.state?.app === this.#app) history.back();
47
+ else this.#pop(true);
48
+ }
49
+ #pop(animated) {
50
+ const leaving = this.#stack.pop();
51
+ const showing = this.#stack.at(-1);
52
+ if (!leaving || !showing) return;
53
+ showing.page.inert = false;
54
+ showing.page.classList.add("ns-current");
55
+ emit(leaving.page, "navigatingFrom", { isBackNavigation: true });
56
+ emit(showing.page, "navigatingTo", { isBackNavigation: true });
57
+ const finish = () => {
58
+ leaving.page.remove();
59
+ emit(leaving.page, "navigatedFrom", { isBackNavigation: true });
60
+ emit(showing.page, "navigatedTo", { isBackNavigation: true });
61
+ };
62
+ if (!animated || prefersLessMotion()) return finish();
63
+ slide(leaving.page, ["0%", "100%"], showing.page, ["-30%", "0%"]).then(finish);
64
+ }
65
+ showModal(view, options) {
66
+ const backdrop = document.createElement("div");
67
+ backdrop.className = "ns-modal-backdrop";
68
+ view.classList.add(options.fullscreen ? "ns-modal-fullscreen" : "ns-modal");
69
+ backdrop.append(view);
70
+ backdrop.addEventListener("click", (click) => {
71
+ if (click.target === backdrop) this.#dismiss(view, void 0, true);
72
+ });
73
+ (this.frame.closest(".ns-app") ?? document.body).append(backdrop);
74
+ this.#modals.push({
75
+ view,
76
+ backdrop,
77
+ onClose: options.onClose
78
+ });
79
+ if (this.router) history.pushState(this.#state(this.#stack.length, true), "", location.href);
80
+ emitLoaded(view);
81
+ if (options.animated && !prefersLessMotion()) {
82
+ view.animate([{ transform: "translateY(100%)" }, { transform: "translateY(0)" }], {
83
+ duration: DURATION,
84
+ easing: EASE
85
+ });
86
+ backdrop.animate([{ opacity: 0 }, { opacity: 1 }], { duration: DURATION });
87
+ }
88
+ }
89
+ closeModal(view, result) {
90
+ this.#dismiss(view, result, true);
91
+ }
92
+ #dismiss(view, result, fromApp) {
93
+ const index = this.#modals.findIndex((modal) => modal.view === view);
94
+ if (index === -1) return;
95
+ const [modal] = this.#modals.splice(index, 1);
96
+ if (fromApp && this.router && history.state?.modal && history.state.app === this.#app) {
97
+ this.#ignorePops++;
98
+ history.back();
99
+ }
100
+ const done = () => modal.backdrop.remove();
101
+ if (prefersLessMotion()) done();
102
+ else Promise.all([modal.view.animate([{ transform: "translateY(0)" }, { transform: "translateY(100%)" }], {
103
+ duration: DURATION,
104
+ easing: EASE
105
+ }).finished, modal.backdrop.animate([{ opacity: 1 }, { opacity: 0 }], { duration: DURATION }).finished]).then(done, done);
106
+ modal.onClose(result);
107
+ }
108
+ #onPopState = (event) => {
109
+ if (this.#ignorePops > 0) {
110
+ this.#ignorePops--;
111
+ return;
112
+ }
113
+ const state = event.state;
114
+ const top = this.#modals.at(-1);
115
+ if (top) return this.#dismiss(top.view, void 0, false);
116
+ if (!state || state.app !== this.#app) {
117
+ this.router?.open(location.pathname, { replace: true });
118
+ return;
119
+ }
120
+ if (state.depth < this.#stack.length) while (this.#stack.length > Math.max(state.depth, 1)) this.#pop(this.#stack.length === state.depth + 1);
121
+ else if (state.depth > this.#stack.length) {
122
+ this.#restoring = true;
123
+ try {
124
+ this.router?.open(location.pathname, { replace: false });
125
+ } finally {
126
+ this.#restoring = false;
127
+ }
128
+ }
129
+ };
130
+ #record(options) {
131
+ const path = this.router.pathFor(options.screen) ?? location.pathname;
132
+ const state = this.#state(this.#stack.length);
133
+ const replace = this.#restoring || this.#stack.length === 1 || options.clearHistory;
134
+ if (options.clearHistory) this.#app = state.app = Math.random().toString(36).slice(2);
135
+ if (replace) history.replaceState(state, "", this.router.href(path));
136
+ else history.pushState(state, "", this.router.href(path));
137
+ const title = this.router.titleFor(options.screen);
138
+ if (title) document.title = title;
139
+ }
140
+ #state(depth, modal = false) {
141
+ return {
142
+ app: this.#app,
143
+ depth,
144
+ ...modal ? { modal } : {}
145
+ };
146
+ }
147
+ /** Stops following the browser's history. */
148
+ destroy() {
149
+ removeEventListener("popstate", this.#onPopState);
150
+ }
151
+ };
152
+ function prefersLessMotion() {
153
+ return matchMedia("(prefers-reduced-motion: reduce)").matches;
154
+ }
155
+ function slide(moving, movingX, under, underX) {
156
+ const timing = {
157
+ duration: DURATION,
158
+ easing: EASE
159
+ };
160
+ const frames = ([from, to]) => [{ transform: `translateX(${from})` }, { transform: `translateX(${to})` }];
161
+ return Promise.all([moving.animate(frames(movingX), timing).finished, under.animate(frames(underX), timing).finished]).catch(() => void 0);
162
+ }
163
+ export { WebFrameHost };
164
+
165
+ //# sourceMappingURL=web-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-host.js","names":[],"sources":["../../src/web-host.ts"],"sourcesContent":["// Shows screens in a browser the way NativeScript's Frame does on a phone: a stack of pages, the new one sliding in\n// over the last, back sliding it out; modals as a sheet over the page. The root frame also keeps the browser's history\n// in step: each screen is a history entry, so the browser's back button is a back, and a screen with a route has its\n// own URL (see web-router.ts). Frames inside a screen (a tab's) keep their stack to themselves.\n\nimport type { FrameHost, ModalHostOptions, ShowOptions } from './navigator.ts';\nimport { emit, emitLoaded } from './web-adapter.ts';\nimport type { WebRouter } from './web-router.ts';\n\ntype View = HTMLElement;\n\ninterface Entry {\n page: View;\n backstackVisible: boolean;\n}\n\ninterface Modal {\n view: View;\n backdrop: HTMLElement;\n onClose: (result?: unknown) => void;\n}\n\ninterface HistoryState {\n /** Which app's entries these are: entries from before a reload or a clearHistory aren't ours. */\n app: string;\n /** How many screens deep this entry is, from 1. */\n depth: number;\n modal?: boolean;\n}\n\nconst DURATION = 280;\nconst EASE = 'cubic-bezier(0.2, 0.8, 0.2, 1)';\n\n/** Moves between screens in a browser. With a router, it keeps the URL and the browser's history in step. */\nexport class WebFrameHost implements FrameHost<View> {\n readonly #stack: Entry[] = [];\n readonly #modals: Modal[] = [];\n #app = Math.random().toString(36).slice(2);\n // A back the host started itself through history.back(): its popstate is already handled.\n #ignorePops = 0;\n // Set while the browser's forward button re-opens a screen: the history entry is already there.\n #restoring = false;\n\n constructor(\n readonly frame: View,\n readonly router?: WebRouter,\n ) {\n if (router) addEventListener('popstate', this.#onPopState);\n }\n\n show(page: View, options: ShowOptions): void {\n const previous = this.#stack.at(-1);\n const dropped = options.clearHistory\n ? this.#stack.splice(0)\n : previous && !previous.backstackVisible\n ? [this.#stack.pop()!]\n : [];\n this.#stack.push({ page, backstackVisible: options.backstackVisible });\n\n if (this.router) this.#record(options);\n\n page.classList.add('ns-current');\n this.frame.append(page);\n emitLoaded(page);\n if (previous) emit(previous.page, 'navigatingFrom', { isBackNavigation: false });\n emit(page, 'navigatingTo', { isBackNavigation: false });\n\n const finish = (): void => {\n if (previous) {\n previous.page.classList.remove('ns-current');\n previous.page.inert = true;\n emit(previous.page, 'navigatedFrom', { isBackNavigation: false });\n }\n for (const entry of dropped) entry.page.remove();\n emit(page, 'navigatedTo', { isBackNavigation: false });\n };\n\n if (!options.animated || !previous || prefersLessMotion()) return finish();\n slide(page, ['100%', '0%'], previous.page, ['0%', '-30%']).then(finish);\n }\n\n back(): void {\n if (this.#stack.length < 2) return;\n // With history, the browser goes back and the popstate does the rest, as when the user presses back.\n if (this.router && history.state?.app === this.#app) history.back();\n else this.#pop(true);\n }\n\n // The top page leaves: it's destroyed by the navigator on navigatedFrom with isBackNavigation.\n #pop(animated: boolean): void {\n const leaving = this.#stack.pop();\n const showing = this.#stack.at(-1);\n if (!leaving || !showing) return;\n\n showing.page.inert = false;\n showing.page.classList.add('ns-current');\n emit(leaving.page, 'navigatingFrom', { isBackNavigation: true });\n emit(showing.page, 'navigatingTo', { isBackNavigation: true });\n\n const finish = (): void => {\n leaving.page.remove();\n emit(leaving.page, 'navigatedFrom', { isBackNavigation: true });\n emit(showing.page, 'navigatedTo', { isBackNavigation: true });\n };\n if (!animated || prefersLessMotion()) return finish();\n slide(leaving.page, ['0%', '100%'], showing.page, ['-30%', '0%']).then(finish);\n }\n\n showModal(view: View, options: ModalHostOptions): void {\n const backdrop = document.createElement('div');\n backdrop.className = 'ns-modal-backdrop';\n view.classList.add(options.fullscreen ? 'ns-modal-fullscreen' : 'ns-modal');\n backdrop.append(view);\n // A tap outside the sheet dismisses it, as a swipe down does on iOS.\n backdrop.addEventListener('click', (click) => {\n if (click.target === backdrop) this.#dismiss(view, undefined, true);\n });\n (this.frame.closest('.ns-app') ?? document.body).append(backdrop);\n this.#modals.push({ view, backdrop, onClose: options.onClose });\n\n if (this.router) history.pushState(this.#state(this.#stack.length, true), '', location.href);\n emitLoaded(view);\n if (options.animated && !prefersLessMotion()) {\n view.animate([{ transform: 'translateY(100%)' }, { transform: 'translateY(0)' }], {\n duration: DURATION,\n easing: EASE,\n });\n backdrop.animate([{ opacity: 0 }, { opacity: 1 }], { duration: DURATION });\n }\n }\n\n closeModal(view: View, result: unknown): void {\n this.#dismiss(view, result, true);\n }\n\n // Closes a modal. `fromApp` when the app or a tap closed it: then its history entry goes too.\n #dismiss(view: View, result: unknown, fromApp: boolean): void {\n const index = this.#modals.findIndex((modal) => modal.view === view);\n if (index === -1) return;\n const [modal] = this.#modals.splice(index, 1);\n if (fromApp && this.router && history.state?.modal && history.state.app === this.#app) {\n this.#ignorePops++;\n history.back();\n }\n const done = (): void => modal!.backdrop.remove();\n if (prefersLessMotion()) done();\n else\n Promise.all([\n modal!.view.animate([{ transform: 'translateY(0)' }, { transform: 'translateY(100%)' }], {\n duration: DURATION,\n easing: EASE,\n }).finished,\n modal!.backdrop.animate([{ opacity: 1 }, { opacity: 0 }], { duration: DURATION }).finished,\n ]).then(done, done);\n modal!.onClose(result);\n }\n\n // The browser's back or forward button.\n #onPopState = (event: PopStateEvent): void => {\n if (this.#ignorePops > 0) {\n this.#ignorePops--;\n return;\n }\n const state = event.state as HistoryState | null;\n const top = this.#modals.at(-1);\n if (top) return this.#dismiss(top.view, undefined, false);\n\n if (!state || state.app !== this.#app) {\n // An entry from before a reload or a clearHistory: there's no screen for it, so show what the URL says.\n this.router?.open(location.pathname, { replace: true });\n return;\n }\n if (state.depth < this.#stack.length) {\n while (this.#stack.length > Math.max(state.depth, 1)) this.#pop(this.#stack.length === state.depth + 1);\n } else if (state.depth > this.#stack.length) {\n // Forward: open the screen the URL names again.\n this.#restoring = true;\n try {\n this.router?.open(location.pathname, { replace: false });\n } finally {\n this.#restoring = false;\n }\n }\n };\n\n // The history entry for a screen just shown: pushed, or replacing the current one for the first screen, after\n // clearHistory, and when the browser already moved (forward).\n #record(options: ShowOptions): void {\n const path = this.router!.pathFor(options.screen) ?? location.pathname;\n const state = this.#state(this.#stack.length);\n const replace = this.#restoring || this.#stack.length === 1 || options.clearHistory;\n if (options.clearHistory) this.#app = state.app = Math.random().toString(36).slice(2);\n if (replace) history.replaceState(state, '', this.router!.href(path));\n else history.pushState(state, '', this.router!.href(path));\n const title = this.router!.titleFor(options.screen);\n if (title) document.title = title;\n }\n\n #state(depth: number, modal = false): HistoryState {\n return { app: this.#app, depth, ...(modal ? { modal } : {}) };\n }\n\n /** Stops following the browser's history. */\n destroy(): void {\n removeEventListener('popstate', this.#onPopState);\n }\n}\n\nfunction prefersLessMotion(): boolean {\n return matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n// The incoming page slides over the outgoing one, which moves a little the other way, as UINavigationController does.\nfunction slide(moving: View, movingX: [string, string], under: View, underX: [string, string]): Promise<unknown> {\n const timing = { duration: DURATION, easing: EASE };\n const frames = ([from, to]: [string, string]) => [\n { transform: `translateX(${from})` },\n { transform: `translateX(${to})` },\n ];\n return Promise.all([\n moving.animate(frames(movingX), timing).finished,\n under.animate(frames(underX), timing).finished,\n ]).catch(() => undefined);\n}\n"],"mappings":";;AA8BA,IAAM,WAAW;AACjB,IAAM,OAAO;;AAGb,IAAa,eAAb,MAAqD;CAUxC;CACA;CAVF,SAAkB,CAAC;CACnB,UAAmB,CAAC;CAC7B,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;CAEzC,cAAc;CAEd,aAAa;CAEb,YACW,OACA,QACT;EAFS,KAAA,QAAA;EACA,KAAA,SAAA;EAET,IAAI,QAAQ,iBAAiB,YAAY,KAAK,WAAW;CAC3D;CAEA,KAAK,MAAY,SAA4B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E,WAAW,cAAc,KAAK,GAAG,GACnC,EAAE,WAAW,cAAc,GAAG,GAAG,CACnC;CACA,OAAO,QAAQ,IAAI,CACjB,OAAO,QAAQ,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,UACxC,MAAM,QAAQ,OAAO,MAAM,GAAG,MAAM,CAAC,CAAC,QACxC,CAAC,CAAC,CAAC,YAAY,KAAA,CAAS;AAC1B"}
@@ -0,0 +1,51 @@
1
+ import type { Navigator } from './navigator.js';
2
+ export type RouteParams = Record<string, string>;
3
+ export interface RouteDefinition {
4
+ screen: object;
5
+ /** The screen's arguments from the path's parameters. Without it, the parameters as strings. */
6
+ args?: (params: RouteParams) => Record<string, unknown>;
7
+ /** The document's title on this screen. */
8
+ title?: string | ((args: Record<string, unknown>) => string);
9
+ }
10
+ export type Routes = Record<string, object | RouteDefinition>;
11
+ interface Route extends RouteDefinition {
12
+ path: string;
13
+ keys: string[];
14
+ pattern: RegExp;
15
+ }
16
+ interface ScreenShown {
17
+ component: object;
18
+ args?: Record<string, unknown>;
19
+ }
20
+ export declare class WebRouter {
21
+ #private;
22
+ /** Where the app is served from, such as `/app`; paths in routes are below it. */
23
+ readonly base: string;
24
+ readonly routes: Route[];
25
+ /** The app's navigator, set when the app starts. */
26
+ navigator?: Navigator;
27
+ constructor(routes: Routes,
28
+ /** Where the app is served from, such as `/app`; paths in routes are below it. */
29
+ base?: string);
30
+ /** The route and parameters for a path (without the base), if one matches. */
31
+ match(pathname: string): {
32
+ route: Route;
33
+ params: RouteParams;
34
+ } | undefined;
35
+ /** The path for a screen being shown, when it has a route and its arguments fill the route's parameters. */
36
+ pathFor(screen: ScreenShown | undefined): string | undefined;
37
+ titleFor(screen: ScreenShown | undefined): string | undefined;
38
+ /** A path as the browser's URL, below the base. */
39
+ href(path: string): string;
40
+ /** The screen's arguments from a matched route. */
41
+ argsFor(route: Route, params: RouteParams): Record<string, unknown>;
42
+ /**
43
+ * Shows the screen a URL names. `replace` for a URL the history has no screen for (from before a reload): the stack
44
+ * starts again from it. Otherwise it goes on top, as the browser's forward button does.
45
+ */
46
+ open(pathname: string, { replace }: {
47
+ replace: boolean;
48
+ }): void;
49
+ }
50
+ export {};
51
+ //# sourceMappingURL=web-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-router.d.ts","sourceRoot":"","sources":["../../src/web-router.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,gGAAgG;IAChG,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC;CAC9D;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC;AAE9D,UAAU,KAAM,SAAQ,eAAe;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAID,qBAAa,SAAS;;IAOlB,kFAAkF;IAClF,QAAQ,CAAC,IAAI;IAPf,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IACzB,oDAAoD;IACpD,SAAS,CAAC,EAAE,SAAS,CAAC;gBAGpB,MAAM,EAAE,MAAM;IACd,kFAAkF;IACzE,IAAI,SAAK;IAkBpB,8EAA8E;IAC9E,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG,SAAS;IAY1E,4GAA4G;IAC5G,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;IAW5D,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;IAO7D,mDAAmD;IACnD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI1B,mDAAmD;IACnD,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAInE;;;OAGG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAgBhE"}
@@ -0,0 +1,83 @@
1
+ // src/web-router.ts
2
+ var isDefinition = (value) => "screen" in value;
3
+ var WebRouter = class {
4
+ base;
5
+ routes;
6
+ /** The app's navigator, set when the app starts. */
7
+ navigator;
8
+ constructor(routes, base = "") {
9
+ this.base = base;
10
+ this.base = base.replace(/\/$/, "");
11
+ this.routes = Object.entries(routes).map(([path, value]) => {
12
+ const definition = isDefinition(value) ? value : { screen: value };
13
+ const keys = [];
14
+ const source = path.split("/").map((part) => {
15
+ if (!part.startsWith(":")) return part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16
+ keys.push(part.slice(1));
17
+ return "([^/]+)";
18
+ }).join("/");
19
+ return {
20
+ ...definition,
21
+ path,
22
+ keys,
23
+ pattern: new RegExp(`^${source || "/"}/?$`)
24
+ };
25
+ });
26
+ }
27
+ /** The route and parameters for a path (without the base), if one matches. */
28
+ match(pathname) {
29
+ const path = this.#strip(pathname);
30
+ for (const route of this.routes) {
31
+ const found = route.pattern.exec(path);
32
+ if (found) return {
33
+ route,
34
+ params: Object.fromEntries(route.keys.map((key, index) => [key, decodeURIComponent(found[index + 1])]))
35
+ };
36
+ }
37
+ }
38
+ /** The path for a screen being shown, when it has a route and its arguments fill the route's parameters. */
39
+ pathFor(screen) {
40
+ if (!screen) return void 0;
41
+ for (const route of this.routes) {
42
+ if (route.screen !== screen.component) continue;
43
+ const args = screen.args ?? {};
44
+ if (route.keys.some((key) => args[key] === void 0 || args[key] === null)) continue;
45
+ return route.path.replace(/:([^/]+)/g, (_, key) => encodeURIComponent(String(args[key])));
46
+ }
47
+ }
48
+ titleFor(screen) {
49
+ if (!screen) return void 0;
50
+ const route = this.routes.find((each) => each.screen === screen.component);
51
+ if (!route?.title) return void 0;
52
+ return typeof route.title === "string" ? route.title : route.title(screen.args ?? {});
53
+ }
54
+ /** A path as the browser's URL, below the base. */
55
+ href(path) {
56
+ return `${this.base}${path.startsWith("/") ? path : `/${path}`}${path === location.pathname ? location.search : ""}`;
57
+ }
58
+ /** The screen's arguments from a matched route. */
59
+ argsFor(route, params) {
60
+ return route.args ? route.args(params) : { ...params };
61
+ }
62
+ /**
63
+ * Shows the screen a URL names. `replace` for a URL the history has no screen for (from before a reload): the stack
64
+ * starts again from it. Otherwise it goes on top, as the browser's forward button does.
65
+ */
66
+ open(pathname, { replace }) {
67
+ const navigator = this.navigator;
68
+ if (!navigator) return;
69
+ const found = this.match(pathname);
70
+ if (!found) return;
71
+ navigator.navigate(found.route.screen, {
72
+ args: this.argsFor(found.route, found.params),
73
+ animated: !replace,
74
+ clearHistory: replace
75
+ });
76
+ }
77
+ #strip(pathname) {
78
+ return (this.base && pathname.startsWith(this.base) ? pathname.slice(this.base.length) : pathname) || "/";
79
+ }
80
+ };
81
+ export { WebRouter };
82
+
83
+ //# sourceMappingURL=web-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-router.js","names":[],"sources":["../../src/web-router.ts"],"sourcesContent":["// URLs for screens, in the browser. A route names a screen and how its arguments read from the path:\n//\n// routes: {\n// '/': Home,\n// '/todos/:id': { screen: TodoScreen, args: ({ id }) => ({ id: Number(id) }), title: ({ id }) => `To-do ${id}` },\n// }\n//\n// Navigating to a screen with a route puts its path in the address bar, filling `:id` from the screen's `id`\n// argument; opening that URL shows the screen, over the first screen so back goes there. A screen without a route\n// keeps the URL it was opened from. Arguments that aren't in the path (an object, a callback) aren't in the URL either,\n// so a screen opened from a URL only gets what the path says.\n\nimport type { Navigator } from './navigator.ts';\n\nexport type RouteParams = Record<string, string>;\n\nexport interface RouteDefinition {\n screen: object;\n /** The screen's arguments from the path's parameters. Without it, the parameters as strings. */\n args?: (params: RouteParams) => Record<string, unknown>;\n /** The document's title on this screen. */\n title?: string | ((args: Record<string, unknown>) => string);\n}\n\nexport type Routes = Record<string, object | RouteDefinition>;\n\ninterface Route extends RouteDefinition {\n path: string;\n keys: string[];\n pattern: RegExp;\n}\n\ninterface ScreenShown {\n component: object;\n args?: Record<string, unknown>;\n}\n\nconst isDefinition = (value: object): value is RouteDefinition => 'screen' in value;\n\nexport class WebRouter {\n readonly routes: Route[];\n /** The app's navigator, set when the app starts. */\n navigator?: Navigator;\n\n constructor(\n routes: Routes,\n /** Where the app is served from, such as `/app`; paths in routes are below it. */\n readonly base = '',\n ) {\n this.base = base.replace(/\\/$/, '');\n this.routes = Object.entries(routes).map(([path, value]) => {\n const definition = isDefinition(value) ? value : { screen: value };\n const keys: string[] = [];\n const source = path\n .split('/')\n .map((part) => {\n if (!part.startsWith(':')) return part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n keys.push(part.slice(1));\n return '([^/]+)';\n })\n .join('/');\n return { ...definition, path, keys, pattern: new RegExp(`^${source || '/'}/?$`) };\n });\n }\n\n /** The route and parameters for a path (without the base), if one matches. */\n match(pathname: string): { route: Route; params: RouteParams } | undefined {\n const path = this.#strip(pathname);\n for (const route of this.routes) {\n const found = route.pattern.exec(path);\n if (found) {\n const params = Object.fromEntries(route.keys.map((key, index) => [key, decodeURIComponent(found[index + 1]!)]));\n return { route, params };\n }\n }\n return undefined;\n }\n\n /** The path for a screen being shown, when it has a route and its arguments fill the route's parameters. */\n pathFor(screen: ScreenShown | undefined): string | undefined {\n if (!screen) return undefined;\n for (const route of this.routes) {\n if (route.screen !== screen.component) continue;\n const args = screen.args ?? {};\n if (route.keys.some((key) => args[key] === undefined || args[key] === null)) continue;\n return route.path.replace(/:([^/]+)/g, (_, key: string) => encodeURIComponent(String(args[key])));\n }\n return undefined;\n }\n\n titleFor(screen: ScreenShown | undefined): string | undefined {\n if (!screen) return undefined;\n const route = this.routes.find((each) => each.screen === screen.component);\n if (!route?.title) return undefined;\n return typeof route.title === 'string' ? route.title : route.title(screen.args ?? {});\n }\n\n /** A path as the browser's URL, below the base. */\n href(path: string): string {\n return `${this.base}${path.startsWith('/') ? path : `/${path}`}${path === location.pathname ? location.search : ''}`;\n }\n\n /** The screen's arguments from a matched route. */\n argsFor(route: Route, params: RouteParams): Record<string, unknown> {\n return route.args ? route.args(params) : { ...params };\n }\n\n /**\n * Shows the screen a URL names. `replace` for a URL the history has no screen for (from before a reload): the stack\n * starts again from it. Otherwise it goes on top, as the browser's forward button does.\n */\n open(pathname: string, { replace }: { replace: boolean }): void {\n const navigator = this.navigator;\n if (!navigator) return;\n const found = this.match(pathname);\n if (!found) return;\n navigator.navigate(found.route.screen, {\n args: this.argsFor(found.route, found.params),\n animated: !replace,\n clearHistory: replace,\n });\n }\n\n #strip(pathname: string): string {\n const path = this.base && pathname.startsWith(this.base) ? pathname.slice(this.base.length) : pathname;\n return path || '/';\n }\n}\n"],"mappings":";AAqCA,IAAM,gBAAgB,UAA4C,YAAY;AAE9E,IAAa,YAAb,MAAuB;CAQV;CAPF;;CAET;CAEA,YACE,QAES,OAAO,IAChB;EADS,KAAA,OAAA;EAET,KAAK,OAAO,KAAK,QAAQ,OAAO,EAAE;EAClC,KAAK,SAAS,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,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AO,OAAO,OAAO,KAAA;EAC1B,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ,MAAM,MAAM,OAAO,QAAQ,CAAC,CAAC;CACtF;;CAGA,KAAK,MAAsB;EACzB,OAAO,GAAG,KAAK,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,SAAS,SAAS,SAAS,WAAW,SAAS,SAAS;CAClH;;CAGA,QAAQ,OAAc,QAA8C;EAClE,OAAO,MAAM,OAAO,MAAM,KAAK,MAAM,IAAI,EAAE,GAAG,OAAO;CACvD;;;;;CAMA,KAAK,UAAkB,EAAE,WAAuC;EAC9D,MAAM,YAAY,KAAK;EACvB,IAAI,CAAC,WAAW;EAChB,MAAM,QAAQ,KAAK,MAAM,QAAQ;EACjC,IAAI,CAAC,OAAO;EACZ,UAAU,SAAS,MAAM,MAAM,QAAQ;GACrC,MAAM,KAAK,QAAQ,MAAM,OAAO,MAAM,MAAM;GAC5C,UAAU,CAAC;GACX,cAAc;EAChB,CAAC;CACH;CAEA,OAAO,UAA0B;EAE/B,QADa,KAAK,QAAQ,SAAS,WAAW,KAAK,IAAI,IAAI,SAAS,MAAM,KAAK,KAAK,MAAM,IAAI,aAC/E;CACjB;AACF"}
@@ -0,0 +1,4 @@
1
+ export declare const WEB_STYLES = "\n.ns-app {\n position: fixed;\n inset: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n margin: 0 auto;\n max-width: 520px;\n font: 17px/1.3 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;\n color: #000;\n background: #fff;\n -webkit-font-smoothing: antialiased;\n -webkit-tap-highlight-color: transparent;\n --ns-accent: #007aff;\n --ns-separator: rgba(60, 60, 67, 0.18);\n --ns-bar: rgba(249, 249, 249, 0.94);\n --ns-fill: rgba(118, 118, 128, 0.12);\n --ns-secondary: #8a8a8e;\n}\n.ns-app.ns-dark {\n color: #fff;\n background: #000;\n --ns-accent: #0a84ff;\n --ns-separator: rgba(84, 84, 88, 0.6);\n --ns-bar: rgba(29, 29, 31, 0.94);\n --ns-fill: rgba(118, 118, 128, 0.24);\n}\n@media (min-width: 560px) {\n .ns-app { inset: 24px auto; left: 50%; transform: translateX(-50%); width: 420px; border-radius: 28px;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.18); }\n body:has(> * > .ns-app), body:has(> .ns-app) { background: #e9e9ee; }\n}\n.ns-app *, .ns-app *::before, .ns-app *::after { box-sizing: border-box; }\n.ns-app [hidden] { display: none !important; }\n\n/* Frames and pages: the page on top shows, the ones under it wait, as in a UINavigationController. */\n.ns-frame { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }\n.ns-page { position: absolute; inset: 0; display: flex; flex-direction: column; }\n/* :where keeps these below an app's own Page { \u2026 } rules. */\n:where(.ns-app) .ns-page { background-color: #fff; }\n:where(.ns-app.ns-dark) .ns-page { background-color: #000; }\n.ns-page:not(.ns-current) { visibility: hidden; }\n.ns-page > :not(.ns-actionBar) { flex: 1 1 auto; min-height: 0; }\n.ns-tabViewItem > .ns-frame, .ns-contentView > * { flex: 1 1 auto; }\n\n/* ActionBar: a title between the back button and the action items. */\n.ns-actionBar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px;\n padding: env(safe-area-inset-top) 8px 0; background: var(--ns-bar); border-bottom: 0.5px solid var(--ns-separator);\n backdrop-filter: blur(20px); }\n.ns-actionBar-title { font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.ns-actionBar-left { justify-self: start; display: flex; }\n.ns-actionBar-right { justify-self: end; display: flex; gap: 4px; }\n.ns-navigationButton, .ns-actionItem { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 8px;\n cursor: pointer; }\n.ns-navigationButton::before { content: '\u2039'; font-size: 30px; line-height: 0; vertical-align: -3px; margin-right: 4px; }\n\n/* Layouts. Children stretch across, as NativeScript's do, unless aligned. */\n.ns-stackLayout { display: flex; }\n.ns-stackLayout.ns-vertical { flex-direction: column; }\n.ns-stackLayout.ns-vertical > * { align-self: var(--ns-ha, stretch); flex: none; }\n.ns-stackLayout.ns-horizontal { flex-direction: row; }\n.ns-stackLayout.ns-horizontal > * { align-self: var(--ns-va, stretch); flex: none; }\n.ns-gridLayout { display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }\n.ns-gridLayout > * { grid-row: 1; grid-column: 1; justify-self: var(--ns-ha, stretch); align-self: var(--ns-va, stretch);\n min-width: 0; min-height: 0; }\n.ns-flexboxLayout { display: flex; }\n.ns-wrapLayout { display: flex; flex-wrap: wrap; align-content: flex-start; }\n.ns-wrapLayout.ns-vertical { flex-direction: column; }\n.ns-wrapLayout > * { width: var(--ns-item-width, auto); height: var(--ns-item-height, auto); }\n.ns-absoluteLayout { position: relative; }\n.ns-absoluteLayout > * { position: absolute; left: 0; top: 0; }\n.ns-dockLayout { display: flex; }\n.ns-rootLayout { display: grid; }\n.ns-rootLayout > * { grid-area: 1 / 1; }\n.ns-scrollView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }\n.ns-scrollView > * { flex: none; }\n.ns-scrollView.ns-horizontal { flex-direction: row; overflow-y: hidden; overflow-x: auto; }\n.ns-contentView { display: flex; flex-direction: column; }\n\n/* Text. A label is one line, cut with an ellipsis, unless textWrap, and centered vertically in its space. */\n.ns-label { display: flex; align-items: center; min-width: 0; }\n.ns-label-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.ns-label.ns-wrap > .ns-label-text { white-space: normal; overflow-wrap: anywhere; }\n.ns-label > .ns-formattedString { flex: 1 1 auto; min-width: 0; }\n.ns-button { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 10px 12px; min-height: 44px;\n cursor: pointer; text-align: center; }\n.ns-button:active { opacity: 0.6; }\n.ns-button:disabled, .ns-disabled { opacity: 0.4; cursor: default; }\n.ns-textField, .ns-searchBar, .ns-textView, .ns-listPicker, .ns-datePicker, .ns-timePicker { font: inherit; color: inherit;\n min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 10px 0; outline: none; }\n.ns-textField::placeholder, .ns-textView::placeholder, .ns-searchBar::placeholder { color: var(--ns-secondary); }\n.ns-searchBar { background: var(--ns-fill); border-radius: 10px; padding: 8px 12px; margin: 8px; }\n.ns-textView { resize: none; min-height: 80px; }\n.ns-image { display: block; min-width: 0; min-height: 0; max-width: 100%; object-fit: contain; }\n\n/* Switch: iOS's toggle. */\n.ns-switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; cursor: pointer; }\n.ns-switch-input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }\n.ns-switch-track { position: absolute; inset: 0; border-radius: 16px; background: var(--ns-fill); transition: background 0.2s; }\n.ns-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;\n background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }\n.ns-switch-input:checked + .ns-switch-track { background: #34c759; }\n.ns-switch-input:checked + .ns-switch-track::after { transform: translateX(20px); }\n.ns-switch-input:focus-visible + .ns-switch-track { outline: 2px solid var(--ns-accent); outline-offset: 2px; }\n\n.ns-slider { accent-color: var(--ns-accent); margin: 10px 0; }\n.ns-progress { accent-color: var(--ns-accent); width: 100%; height: 4px; }\n.ns-activityIndicator { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ns-fill);\n border-top-color: var(--ns-secondary); animation: ns-spin 0.8s linear infinite; align-self: center; }\n.ns-activityIndicator.ns-busy { display: block; }\n@keyframes ns-spin { to { transform: rotate(360deg); } }\n\n.ns-segmentedBar { display: flex; padding: 2px; border-radius: 9px; background: var(--ns-fill); }\n.ns-segmentedBarItem { flex: 1; font: inherit; font-size: 13px; font-weight: 500; color: inherit; background: none; border: 0;\n border-radius: 7px; padding: 6px 8px; cursor: pointer; }\n.ns-segmentedBarItem[aria-selected='true'] { background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }\n.ns-dark .ns-segmentedBarItem[aria-selected='true'] { background: #636366; }\n\n/* TabView: the items, and a tab bar under them. */\n.ns-tabView { display: flex; flex-direction: column; min-height: 0; }\n.ns-tabView-items { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }\n.ns-tabViewItem { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }\n.ns-tabView-bar { flex: none; display: flex; background: var(--ns-bar); border-top: 0.5px solid var(--ns-separator);\n padding-bottom: env(safe-area-inset-bottom); }\n.ns-tabView-tab { flex: 1; font: inherit; font-size: 11px; font-weight: 500; color: var(--ns-secondary); background: none;\n border: 0; padding: 14px 4px; cursor: pointer; }\n.ns-tabView-tab[aria-selected='true'] { color: var(--ns-accent); }\n\n/* Lists: a column that scrolls, rows separated by a hairline. */\n.ns-listView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }\n.ns-listView-cell { flex: none; cursor: pointer; border-bottom: 0.5px solid var(--ns-separator); }\n.ns-listView-cell:active { background: var(--ns-fill); }\n.ns-webView { border: 0; width: 100%; height: 100%; }\n\n/* Modals: a sheet from the bottom over a dimmed screen. */\n.ns-modal-backdrop { position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end;\n background: rgba(0, 0, 0, 0.35); }\n.ns-modal { width: 100%; max-height: 92%; border-radius: 12px 12px 0 0; background: #fff; overflow: auto;\n padding-bottom: env(safe-area-inset-bottom); }\n.ns-modal-fullscreen { position: absolute; inset: 0; background: #fff; overflow: auto; }\n.ns-dark .ns-modal, .ns-dark .ns-modal-fullscreen { background: #1c1c1e; }\n";
2
+ /** Adds the styles to the document, once. */
3
+ export declare function installStyles(): void;
4
+ //# sourceMappingURL=web-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-styles.d.ts","sourceRoot":"","sources":["../../src/web-styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,ywRA8ItB,CAAC;AAIF,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,IAAI,CAOpC"}
@@ -0,0 +1,157 @@
1
+ // src/web-styles.ts
2
+ var WEB_STYLES = `
3
+ .ns-app {
4
+ position: fixed;
5
+ inset: 0;
6
+ display: flex;
7
+ flex-direction: column;
8
+ overflow: hidden;
9
+ margin: 0 auto;
10
+ max-width: 520px;
11
+ font: 17px/1.3 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
12
+ color: #000;
13
+ background: #fff;
14
+ -webkit-font-smoothing: antialiased;
15
+ -webkit-tap-highlight-color: transparent;
16
+ --ns-accent: #007aff;
17
+ --ns-separator: rgba(60, 60, 67, 0.18);
18
+ --ns-bar: rgba(249, 249, 249, 0.94);
19
+ --ns-fill: rgba(118, 118, 128, 0.12);
20
+ --ns-secondary: #8a8a8e;
21
+ }
22
+ .ns-app.ns-dark {
23
+ color: #fff;
24
+ background: #000;
25
+ --ns-accent: #0a84ff;
26
+ --ns-separator: rgba(84, 84, 88, 0.6);
27
+ --ns-bar: rgba(29, 29, 31, 0.94);
28
+ --ns-fill: rgba(118, 118, 128, 0.24);
29
+ }
30
+ @media (min-width: 560px) {
31
+ .ns-app { inset: 24px auto; left: 50%; transform: translateX(-50%); width: 420px; border-radius: 28px;
32
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.18); }
33
+ body:has(> * > .ns-app), body:has(> .ns-app) { background: #e9e9ee; }
34
+ }
35
+ .ns-app *, .ns-app *::before, .ns-app *::after { box-sizing: border-box; }
36
+ .ns-app [hidden] { display: none !important; }
37
+
38
+ /* Frames and pages: the page on top shows, the ones under it wait, as in a UINavigationController. */
39
+ .ns-frame { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }
40
+ .ns-page { position: absolute; inset: 0; display: flex; flex-direction: column; }
41
+ /* :where keeps these below an app's own Page { … } rules. */
42
+ :where(.ns-app) .ns-page { background-color: #fff; }
43
+ :where(.ns-app.ns-dark) .ns-page { background-color: #000; }
44
+ .ns-page:not(.ns-current) { visibility: hidden; }
45
+ .ns-page > :not(.ns-actionBar) { flex: 1 1 auto; min-height: 0; }
46
+ .ns-tabViewItem > .ns-frame, .ns-contentView > * { flex: 1 1 auto; }
47
+
48
+ /* ActionBar: a title between the back button and the action items. */
49
+ .ns-actionBar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px;
50
+ padding: env(safe-area-inset-top) 8px 0; background: var(--ns-bar); border-bottom: 0.5px solid var(--ns-separator);
51
+ backdrop-filter: blur(20px); }
52
+ .ns-actionBar-title { font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
53
+ .ns-actionBar-left { justify-self: start; display: flex; }
54
+ .ns-actionBar-right { justify-self: end; display: flex; gap: 4px; }
55
+ .ns-navigationButton, .ns-actionItem { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 8px;
56
+ cursor: pointer; }
57
+ .ns-navigationButton::before { content: '‹'; font-size: 30px; line-height: 0; vertical-align: -3px; margin-right: 4px; }
58
+
59
+ /* Layouts. Children stretch across, as NativeScript's do, unless aligned. */
60
+ .ns-stackLayout { display: flex; }
61
+ .ns-stackLayout.ns-vertical { flex-direction: column; }
62
+ .ns-stackLayout.ns-vertical > * { align-self: var(--ns-ha, stretch); flex: none; }
63
+ .ns-stackLayout.ns-horizontal { flex-direction: row; }
64
+ .ns-stackLayout.ns-horizontal > * { align-self: var(--ns-va, stretch); flex: none; }
65
+ .ns-gridLayout { display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
66
+ .ns-gridLayout > * { grid-row: 1; grid-column: 1; justify-self: var(--ns-ha, stretch); align-self: var(--ns-va, stretch);
67
+ min-width: 0; min-height: 0; }
68
+ .ns-flexboxLayout { display: flex; }
69
+ .ns-wrapLayout { display: flex; flex-wrap: wrap; align-content: flex-start; }
70
+ .ns-wrapLayout.ns-vertical { flex-direction: column; }
71
+ .ns-wrapLayout > * { width: var(--ns-item-width, auto); height: var(--ns-item-height, auto); }
72
+ .ns-absoluteLayout { position: relative; }
73
+ .ns-absoluteLayout > * { position: absolute; left: 0; top: 0; }
74
+ .ns-dockLayout { display: flex; }
75
+ .ns-rootLayout { display: grid; }
76
+ .ns-rootLayout > * { grid-area: 1 / 1; }
77
+ .ns-scrollView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
78
+ .ns-scrollView > * { flex: none; }
79
+ .ns-scrollView.ns-horizontal { flex-direction: row; overflow-y: hidden; overflow-x: auto; }
80
+ .ns-contentView { display: flex; flex-direction: column; }
81
+
82
+ /* Text. A label is one line, cut with an ellipsis, unless textWrap, and centered vertically in its space. */
83
+ .ns-label { display: flex; align-items: center; min-width: 0; }
84
+ .ns-label-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
85
+ .ns-label.ns-wrap > .ns-label-text { white-space: normal; overflow-wrap: anywhere; }
86
+ .ns-label > .ns-formattedString { flex: 1 1 auto; min-width: 0; }
87
+ .ns-button { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 10px 12px; min-height: 44px;
88
+ cursor: pointer; text-align: center; }
89
+ .ns-button:active { opacity: 0.6; }
90
+ .ns-button:disabled, .ns-disabled { opacity: 0.4; cursor: default; }
91
+ .ns-textField, .ns-searchBar, .ns-textView, .ns-listPicker, .ns-datePicker, .ns-timePicker { font: inherit; color: inherit;
92
+ min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 10px 0; outline: none; }
93
+ .ns-textField::placeholder, .ns-textView::placeholder, .ns-searchBar::placeholder { color: var(--ns-secondary); }
94
+ .ns-searchBar { background: var(--ns-fill); border-radius: 10px; padding: 8px 12px; margin: 8px; }
95
+ .ns-textView { resize: none; min-height: 80px; }
96
+ .ns-image { display: block; min-width: 0; min-height: 0; max-width: 100%; object-fit: contain; }
97
+
98
+ /* Switch: iOS's toggle. */
99
+ .ns-switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; cursor: pointer; }
100
+ .ns-switch-input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
101
+ .ns-switch-track { position: absolute; inset: 0; border-radius: 16px; background: var(--ns-fill); transition: background 0.2s; }
102
+ .ns-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
103
+ background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }
104
+ .ns-switch-input:checked + .ns-switch-track { background: #34c759; }
105
+ .ns-switch-input:checked + .ns-switch-track::after { transform: translateX(20px); }
106
+ .ns-switch-input:focus-visible + .ns-switch-track { outline: 2px solid var(--ns-accent); outline-offset: 2px; }
107
+
108
+ .ns-slider { accent-color: var(--ns-accent); margin: 10px 0; }
109
+ .ns-progress { accent-color: var(--ns-accent); width: 100%; height: 4px; }
110
+ .ns-activityIndicator { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ns-fill);
111
+ border-top-color: var(--ns-secondary); animation: ns-spin 0.8s linear infinite; align-self: center; }
112
+ .ns-activityIndicator.ns-busy { display: block; }
113
+ @keyframes ns-spin { to { transform: rotate(360deg); } }
114
+
115
+ .ns-segmentedBar { display: flex; padding: 2px; border-radius: 9px; background: var(--ns-fill); }
116
+ .ns-segmentedBarItem { flex: 1; font: inherit; font-size: 13px; font-weight: 500; color: inherit; background: none; border: 0;
117
+ border-radius: 7px; padding: 6px 8px; cursor: pointer; }
118
+ .ns-segmentedBarItem[aria-selected='true'] { background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }
119
+ .ns-dark .ns-segmentedBarItem[aria-selected='true'] { background: #636366; }
120
+
121
+ /* TabView: the items, and a tab bar under them. */
122
+ .ns-tabView { display: flex; flex-direction: column; min-height: 0; }
123
+ .ns-tabView-items { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
124
+ .ns-tabViewItem { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
125
+ .ns-tabView-bar { flex: none; display: flex; background: var(--ns-bar); border-top: 0.5px solid var(--ns-separator);
126
+ padding-bottom: env(safe-area-inset-bottom); }
127
+ .ns-tabView-tab { flex: 1; font: inherit; font-size: 11px; font-weight: 500; color: var(--ns-secondary); background: none;
128
+ border: 0; padding: 14px 4px; cursor: pointer; }
129
+ .ns-tabView-tab[aria-selected='true'] { color: var(--ns-accent); }
130
+
131
+ /* Lists: a column that scrolls, rows separated by a hairline. */
132
+ .ns-listView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
133
+ .ns-listView-cell { flex: none; cursor: pointer; border-bottom: 0.5px solid var(--ns-separator); }
134
+ .ns-listView-cell:active { background: var(--ns-fill); }
135
+ .ns-webView { border: 0; width: 100%; height: 100%; }
136
+
137
+ /* Modals: a sheet from the bottom over a dimmed screen. */
138
+ .ns-modal-backdrop { position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end;
139
+ background: rgba(0, 0, 0, 0.35); }
140
+ .ns-modal { width: 100%; max-height: 92%; border-radius: 12px 12px 0 0; background: #fff; overflow: auto;
141
+ padding-bottom: env(safe-area-inset-bottom); }
142
+ .ns-modal-fullscreen { position: absolute; inset: 0; background: #fff; overflow: auto; }
143
+ .ns-dark .ns-modal, .ns-dark .ns-modal-fullscreen { background: #1c1c1e; }
144
+ `;
145
+ var installed = false;
146
+ /** Adds the styles to the document, once. */
147
+ function installStyles() {
148
+ if (installed) return;
149
+ installed = true;
150
+ const style = document.createElement("style");
151
+ style.dataset.emberNativescript = "";
152
+ style.textContent = WEB_STYLES;
153
+ document.head.prepend(style);
154
+ }
155
+ export { WEB_STYLES, installStyles };
156
+
157
+ //# sourceMappingURL=web-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-styles.js","names":["WEB_STYLES","installed","installStyles","style","document","createElement","dataset","emberNativescript","textContent","head","prepend"],"sources":["../../src/web-styles.ts"],"sourcesContent":["// The CSS that gives NativeScript's views their layout and look in a browser. Sizes are device-independent pixels,\n// which are CSS pixels. The look is iOS's defaults, since that's where the app was seen first; an app's own CSS\n// (converted by the web Vite config) goes on top.\n\nexport const WEB_STYLES = /* css */ `\n.ns-app {\n position: fixed;\n inset: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n margin: 0 auto;\n max-width: 520px;\n font: 17px/1.3 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;\n color: #000;\n background: #fff;\n -webkit-font-smoothing: antialiased;\n -webkit-tap-highlight-color: transparent;\n --ns-accent: #007aff;\n --ns-separator: rgba(60, 60, 67, 0.18);\n --ns-bar: rgba(249, 249, 249, 0.94);\n --ns-fill: rgba(118, 118, 128, 0.12);\n --ns-secondary: #8a8a8e;\n}\n.ns-app.ns-dark {\n color: #fff;\n background: #000;\n --ns-accent: #0a84ff;\n --ns-separator: rgba(84, 84, 88, 0.6);\n --ns-bar: rgba(29, 29, 31, 0.94);\n --ns-fill: rgba(118, 118, 128, 0.24);\n}\n@media (min-width: 560px) {\n .ns-app { inset: 24px auto; left: 50%; transform: translateX(-50%); width: 420px; border-radius: 28px;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.18); }\n body:has(> * > .ns-app), body:has(> .ns-app) { background: #e9e9ee; }\n}\n.ns-app *, .ns-app *::before, .ns-app *::after { box-sizing: border-box; }\n.ns-app [hidden] { display: none !important; }\n\n/* Frames and pages: the page on top shows, the ones under it wait, as in a UINavigationController. */\n.ns-frame { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }\n.ns-page { position: absolute; inset: 0; display: flex; flex-direction: column; }\n/* :where keeps these below an app's own Page { … } rules. */\n:where(.ns-app) .ns-page { background-color: #fff; }\n:where(.ns-app.ns-dark) .ns-page { background-color: #000; }\n.ns-page:not(.ns-current) { visibility: hidden; }\n.ns-page > :not(.ns-actionBar) { flex: 1 1 auto; min-height: 0; }\n.ns-tabViewItem > .ns-frame, .ns-contentView > * { flex: 1 1 auto; }\n\n/* ActionBar: a title between the back button and the action items. */\n.ns-actionBar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px;\n padding: env(safe-area-inset-top) 8px 0; background: var(--ns-bar); border-bottom: 0.5px solid var(--ns-separator);\n backdrop-filter: blur(20px); }\n.ns-actionBar-title { font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.ns-actionBar-left { justify-self: start; display: flex; }\n.ns-actionBar-right { justify-self: end; display: flex; gap: 4px; }\n.ns-navigationButton, .ns-actionItem { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 8px;\n cursor: pointer; }\n.ns-navigationButton::before { content: '‹'; font-size: 30px; line-height: 0; vertical-align: -3px; margin-right: 4px; }\n\n/* Layouts. Children stretch across, as NativeScript's do, unless aligned. */\n.ns-stackLayout { display: flex; }\n.ns-stackLayout.ns-vertical { flex-direction: column; }\n.ns-stackLayout.ns-vertical > * { align-self: var(--ns-ha, stretch); flex: none; }\n.ns-stackLayout.ns-horizontal { flex-direction: row; }\n.ns-stackLayout.ns-horizontal > * { align-self: var(--ns-va, stretch); flex: none; }\n.ns-gridLayout { display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }\n.ns-gridLayout > * { grid-row: 1; grid-column: 1; justify-self: var(--ns-ha, stretch); align-self: var(--ns-va, stretch);\n min-width: 0; min-height: 0; }\n.ns-flexboxLayout { display: flex; }\n.ns-wrapLayout { display: flex; flex-wrap: wrap; align-content: flex-start; }\n.ns-wrapLayout.ns-vertical { flex-direction: column; }\n.ns-wrapLayout > * { width: var(--ns-item-width, auto); height: var(--ns-item-height, auto); }\n.ns-absoluteLayout { position: relative; }\n.ns-absoluteLayout > * { position: absolute; left: 0; top: 0; }\n.ns-dockLayout { display: flex; }\n.ns-rootLayout { display: grid; }\n.ns-rootLayout > * { grid-area: 1 / 1; }\n.ns-scrollView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }\n.ns-scrollView > * { flex: none; }\n.ns-scrollView.ns-horizontal { flex-direction: row; overflow-y: hidden; overflow-x: auto; }\n.ns-contentView { display: flex; flex-direction: column; }\n\n/* Text. A label is one line, cut with an ellipsis, unless textWrap, and centered vertically in its space. */\n.ns-label { display: flex; align-items: center; min-width: 0; }\n.ns-label-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.ns-label.ns-wrap > .ns-label-text { white-space: normal; overflow-wrap: anywhere; }\n.ns-label > .ns-formattedString { flex: 1 1 auto; min-width: 0; }\n.ns-button { font: inherit; color: var(--ns-accent); background: none; border: 0; padding: 10px 12px; min-height: 44px;\n cursor: pointer; text-align: center; }\n.ns-button:active { opacity: 0.6; }\n.ns-button:disabled, .ns-disabled { opacity: 0.4; cursor: default; }\n.ns-textField, .ns-searchBar, .ns-textView, .ns-listPicker, .ns-datePicker, .ns-timePicker { font: inherit; color: inherit;\n min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 10px 0; outline: none; }\n.ns-textField::placeholder, .ns-textView::placeholder, .ns-searchBar::placeholder { color: var(--ns-secondary); }\n.ns-searchBar { background: var(--ns-fill); border-radius: 10px; padding: 8px 12px; margin: 8px; }\n.ns-textView { resize: none; min-height: 80px; }\n.ns-image { display: block; min-width: 0; min-height: 0; max-width: 100%; object-fit: contain; }\n\n/* Switch: iOS's toggle. */\n.ns-switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; cursor: pointer; }\n.ns-switch-input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }\n.ns-switch-track { position: absolute; inset: 0; border-radius: 16px; background: var(--ns-fill); transition: background 0.2s; }\n.ns-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;\n background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }\n.ns-switch-input:checked + .ns-switch-track { background: #34c759; }\n.ns-switch-input:checked + .ns-switch-track::after { transform: translateX(20px); }\n.ns-switch-input:focus-visible + .ns-switch-track { outline: 2px solid var(--ns-accent); outline-offset: 2px; }\n\n.ns-slider { accent-color: var(--ns-accent); margin: 10px 0; }\n.ns-progress { accent-color: var(--ns-accent); width: 100%; height: 4px; }\n.ns-activityIndicator { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ns-fill);\n border-top-color: var(--ns-secondary); animation: ns-spin 0.8s linear infinite; align-self: center; }\n.ns-activityIndicator.ns-busy { display: block; }\n@keyframes ns-spin { to { transform: rotate(360deg); } }\n\n.ns-segmentedBar { display: flex; padding: 2px; border-radius: 9px; background: var(--ns-fill); }\n.ns-segmentedBarItem { flex: 1; font: inherit; font-size: 13px; font-weight: 500; color: inherit; background: none; border: 0;\n border-radius: 7px; padding: 6px 8px; cursor: pointer; }\n.ns-segmentedBarItem[aria-selected='true'] { background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }\n.ns-dark .ns-segmentedBarItem[aria-selected='true'] { background: #636366; }\n\n/* TabView: the items, and a tab bar under them. */\n.ns-tabView { display: flex; flex-direction: column; min-height: 0; }\n.ns-tabView-items { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }\n.ns-tabViewItem { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }\n.ns-tabView-bar { flex: none; display: flex; background: var(--ns-bar); border-top: 0.5px solid var(--ns-separator);\n padding-bottom: env(safe-area-inset-bottom); }\n.ns-tabView-tab { flex: 1; font: inherit; font-size: 11px; font-weight: 500; color: var(--ns-secondary); background: none;\n border: 0; padding: 14px 4px; cursor: pointer; }\n.ns-tabView-tab[aria-selected='true'] { color: var(--ns-accent); }\n\n/* Lists: a column that scrolls, rows separated by a hairline. */\n.ns-listView { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }\n.ns-listView-cell { flex: none; cursor: pointer; border-bottom: 0.5px solid var(--ns-separator); }\n.ns-listView-cell:active { background: var(--ns-fill); }\n.ns-webView { border: 0; width: 100%; height: 100%; }\n\n/* Modals: a sheet from the bottom over a dimmed screen. */\n.ns-modal-backdrop { position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end;\n background: rgba(0, 0, 0, 0.35); }\n.ns-modal { width: 100%; max-height: 92%; border-radius: 12px 12px 0 0; background: #fff; overflow: auto;\n padding-bottom: env(safe-area-inset-bottom); }\n.ns-modal-fullscreen { position: absolute; inset: 0; background: #fff; overflow: auto; }\n.ns-dark .ns-modal, .ns-dark .ns-modal-fullscreen { background: #1c1c1e; }\n`;\n\nlet installed = false;\n\n/** Adds the styles to the document, once. */\nexport function installStyles(): void {\n if (installed) return;\n installed = true;\n const style = document.createElement('style');\n style.dataset.emberNativescript = '';\n style.textContent = WEB_STYLES;\n document.head.prepend(style);\n}\n"],"mappings":";AAIA,IAAaA,aAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgJpC,IAAIC,YAAY;;AAGhB,SAAgBC,gBAAsB;CACpC,IAAID,WAAW;CACfA,YAAY;CACZ,MAAME,QAAQC,SAASC,cAAc,OAAO;CAC5CF,MAAMG,QAAQC,oBAAoB;CAClCJ,MAAMK,cAAcR;CACpBI,SAASK,KAAKC,QAAQP,KAAK;AAC7B"}
@@ -0,0 +1,7 @@
1
+ export { createWebApp, type WebApp, type WebAppOptions } from './web-app.js';
2
+ export { emit, emitLoaded, WebAdapter } from './web-adapter.js';
3
+ export { WebFrameHost } from './web-host.js';
4
+ export { type RouteDefinition, type RouteParams, type Routes, WebRouter } from './web-router.js';
5
+ export { installStyles, WEB_STYLES } from './web-styles.js';
6
+ export { convertNativeScriptCss } from './web-css.js';
7
+ //# sourceMappingURL=web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { createWebApp } from "./web-app.js";
2
+ import { WebAdapter, emit, emitLoaded } from "./web-adapter.js";
3
+ import { WebFrameHost } from "./web-host.js";
4
+ import { WebRouter } from "./web-router.js";
5
+ import { WEB_STYLES, installStyles } from "./web-styles.js";
6
+ import { convertNativeScriptCss } from "./web-css.js";
7
+ export { WEB_STYLES, WebAdapter, WebFrameHost, WebRouter, convertNativeScriptCss, createWebApp, emit, emitLoaded, installStyles };
@@ -104,7 +104,9 @@ export interface CommonNativeAttributes {
104
104
  flexWrapBefore?: boolean | 'true' | 'false';
105
105
  alignSelf?: NS.AlignSelf;
106
106
  /** Set on one platform only: `ios:text='Tap'`. A dotted name sets a nested property: `ios.position='right'`. */
107
- [platformOnly: `ios:${string}` | `android:${string}` | `ios.${string}` | `android.${string}`]: unknown;
107
+ [
108
+ platformOnly: `ios:${string}` | `android:${string}` | `web:${string}` | `ios.${string}` | `android.${string}`
109
+ ]: unknown;
108
110
  }
109
111
 
110
112
  export type NativeAttributes<View> = {
@@ -120,6 +122,9 @@ type NativeTagAttributes = {
120
122
  };
121
123
 
122
124
  declare global {
125
+ /** True in the web build (`ember-nativescript/vite-web`), false in the NativeScript bundles. */
126
+ const __WEB__: boolean;
127
+
123
128
  // `label`, `button`, `span`, `progress` and `frame` are also HTML tags: their element type stays HTML's, but their
124
129
  // attributes are looked up by name, here first.
125
130
  interface GlintCustomElementTagNameMap extends NativeTags {}