orvyn-lang 0.2.0 → 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/GUIDE.md +149 -0
- package/LANGUAGE.md +744 -27
- package/README.md +211 -250
- package/brand/orvyn-sunset-animated.svg +15 -0
- package/package.json +3 -1
- package/src/cli/orvyn.js +186 -10
- package/src/core/signal.js +104 -6
- package/src/devtools/runtime.js +25 -1
- package/src/lang/a11y.js +102 -0
- package/src/lang/auth.js +239 -0
- package/src/lang/bundle-native.js +10 -6
- package/src/lang/codegen.js +428 -57
- package/src/lang/device.js +41 -0
- package/src/lang/doctor.js +60 -0
- package/src/lang/env.js +27 -0
- package/src/lang/errors.js +513 -0
- package/src/lang/form.js +69 -8
- package/src/lang/index.js +2 -1
- package/src/lang/lexer.js +2 -0
- package/src/lang/list.js +44 -0
- package/src/lang/native/android/MainActivity.kt +43 -4
- package/src/lang/native/android/OrvynDevice.kt +163 -0
- package/src/lang/native/android/OrvynEngine.kt +154 -7
- package/src/lang/native/android/OrvynRenderer.kt +518 -44
- package/src/lang/native/android.js +74 -11
- package/src/lang/native/build.js +130 -60
- package/src/lang/native/config.js +108 -0
- package/src/lang/native/ios/OrvynApp.swift +6 -0
- package/src/lang/native/ios/OrvynEngine.swift +266 -4
- package/src/lang/native/ios/OrvynViews.swift +429 -34
- package/src/lang/native/ios.js +75 -2
- package/src/lang/native-runtime.js +406 -56
- package/src/lang/page.js +52 -0
- package/src/lang/parser.js +243 -15
- package/src/lang/prerender.js +300 -0
- package/src/lang/read-import.js +11 -0
- package/src/lang/router.js +266 -0
- package/src/lang/runtime-shared.js +792 -10
- package/src/lang/runtime.js +362 -52
- package/src/lang/select.js +13 -0
- package/src/lang/server-code.js +233 -0
- package/src/lang/server-export.js +78 -0
- package/src/lang/server-libs.js +53 -0
- package/src/lang/server.js +409 -0
- package/src/lang/test-runner.js +134 -0
- package/src/lang/types.js +312 -0
- package/src/lang/vite-plugin.js +82 -3
- package/src/lang/web-overlay.js +578 -0
- package/src/lang/widgets.js +94 -0
- package/src/lang/words.js +38 -0
- package/src/runtime/mount.js +116 -27
- package/src/runtime/patch.js +90 -11
- package/src/runtime/style.js +11 -1
- package/src/styling/fluid.js +91 -4
- package/src/styling/spec.js +306 -0
package/src/lang/runtime.js
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createOwner, disposeOwner, effect, runWithOwner } from "../core/signal.js";
|
|
2
2
|
import { createVNode } from "../runtime/vnode.js";
|
|
3
|
-
import { mount } from "../runtime/mount.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import { disposeDomTree, mount } from "../runtime/mount.js";
|
|
4
|
+
import { theme } from "../styling/spec.js";
|
|
5
|
+
import { createRouter, parseRouteUrl } from "./router.js";
|
|
6
|
+
import { createAuth } from "./auth.js";
|
|
7
|
+
import { createErrorCenter } from "./errors.js";
|
|
8
|
+
import { createList } from "./list.js";
|
|
9
|
+
import { applyPage } from "./page.js";
|
|
10
|
+
import { askBrowser, createDevice } from "./device.js";
|
|
11
|
+
const { pickPhoto, takePhoto, pickFile, getLocation } = createDevice(askBrowser);
|
|
12
|
+
const setPage = applyPage;
|
|
13
|
+
import { mountWebOverlay } from "./web-overlay.js";
|
|
14
|
+
import {
|
|
15
|
+
createCancelToken,
|
|
16
|
+
createHttp,
|
|
17
|
+
createSavedSignal,
|
|
18
|
+
createSecureStorage,
|
|
19
|
+
createStorageManager,
|
|
20
|
+
allScreens,
|
|
21
|
+
currentCancelToken,
|
|
22
|
+
runAppWork,
|
|
23
|
+
startAppWork
|
|
24
|
+
} from "./runtime-shared.js";
|
|
25
|
+
function webAppId() {
|
|
26
|
+
const explicit = globalThis.__orvynAppId;
|
|
27
|
+
if (explicit) return String(explicit);
|
|
28
|
+
const loc = globalThis.window?.location;
|
|
29
|
+
if (!loc) return "web";
|
|
30
|
+
const search = String(loc.search || "");
|
|
31
|
+
const match = search.match(/[?&]app=([^&#]+)/);
|
|
32
|
+
if (match) return decodeURIComponent(match[1]);
|
|
33
|
+
const path = String(loc.pathname || "/");
|
|
34
|
+
return path === "/" ? "web" : path.replace(/^\/+|\/+$/g, "");
|
|
35
|
+
}
|
|
36
|
+
const { savedSignal, resetState, storage } = createStorageManager({
|
|
37
|
+
get: (key) => globalThis.localStorage?.getItem(key) ?? null,
|
|
38
|
+
set: (key, value) => globalThis.localStorage?.setItem(key, value),
|
|
39
|
+
remove: (key) => globalThis.localStorage?.removeItem(key)
|
|
40
|
+
}, webAppId);
|
|
41
|
+
const secure = createSecureStorage({
|
|
42
|
+
isSecure: false,
|
|
43
|
+
warning: "Browser secure storage uses sessionStorage (cleared on tab close). Use HttpOnly cookies for production web credentials.",
|
|
44
|
+
get: (key) => globalThis.sessionStorage?.getItem(key) ?? null,
|
|
45
|
+
set: (key, value) => globalThis.sessionStorage?.setItem(key, value),
|
|
46
|
+
remove: (key) => globalThis.sessionStorage?.removeItem(key),
|
|
47
|
+
clear: (prefix) => {
|
|
48
|
+
const store = globalThis.sessionStorage;
|
|
49
|
+
if (!store) return;
|
|
50
|
+
for (let i = store.length - 1; i >= 0; i--) {
|
|
51
|
+
const k = store.key(i);
|
|
52
|
+
if (k && k.startsWith(prefix)) store.removeItem(k);
|
|
17
53
|
}
|
|
18
54
|
}
|
|
19
|
-
});
|
|
55
|
+
}, webAppId);
|
|
20
56
|
import {
|
|
21
57
|
readImported,
|
|
22
58
|
bindInput,
|
|
@@ -32,72 +68,175 @@ import {
|
|
|
32
68
|
setField,
|
|
33
69
|
sleep,
|
|
34
70
|
random,
|
|
35
|
-
len
|
|
71
|
+
len,
|
|
72
|
+
track,
|
|
73
|
+
resume,
|
|
74
|
+
componentState,
|
|
75
|
+
errorText,
|
|
76
|
+
isEmptyValue,
|
|
77
|
+
env,
|
|
78
|
+
setEnv,
|
|
79
|
+
registerScreens,
|
|
80
|
+
snapshotLocals,
|
|
81
|
+
carryLocals,
|
|
82
|
+
bindCheck
|
|
36
83
|
} from "./runtime-shared.js";
|
|
37
84
|
import { validate } from "./validation.js";
|
|
85
|
+
import { keyed } from "./list.js";
|
|
86
|
+
import { createSelect } from "./select.js";
|
|
87
|
+
import { createModal, createTabs, createMap } from "./widgets.js";
|
|
88
|
+
import { words } from "./words.js";
|
|
89
|
+
const List = createList(true);
|
|
38
90
|
import { formCache, createForm } from "./form.js";
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
91
|
+
import { theme as theme2, setStyleWarningHandler } from "../styling/spec.js";
|
|
92
|
+
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
93
|
+
async function rawFetchData(url, options = {}) {
|
|
94
|
+
const { timeout, signal: externalSignal, ...rest } = options || {};
|
|
95
|
+
const active = currentCancelToken();
|
|
96
|
+
const token = createCancelToken(externalSignal);
|
|
97
|
+
const unbindActive = active ? active.onAbort((reason) => token.abort(reason)) : () => {
|
|
98
|
+
};
|
|
99
|
+
const timeoutMs = timeout === false || timeout === 0 ? 0 : Number(timeout ?? DEFAULT_TIMEOUT_MS) || 0;
|
|
100
|
+
let timedOut = false;
|
|
101
|
+
let timer = null;
|
|
102
|
+
if (timeoutMs > 0) {
|
|
103
|
+
timer = setTimeout(() => {
|
|
104
|
+
timedOut = true;
|
|
105
|
+
token.abort(new Error(`Timed out after ${timeoutMs}ms`));
|
|
106
|
+
}, timeoutMs);
|
|
107
|
+
}
|
|
108
|
+
const init = { ...rest, ...token.signal ? { signal: token.signal } : {} };
|
|
109
|
+
if (options?.body !== void 0 && typeof options.body === "object") {
|
|
42
110
|
init.body = JSON.stringify(options.body);
|
|
43
111
|
init.headers = { "Content-Type": "application/json", ...options.headers || {} };
|
|
44
112
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
113
|
+
try {
|
|
114
|
+
const response = await fetch(url, init);
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw Object.assign(new Error(`[Orvyn] fetch("${url}") failed with status ${response.status}`), { status: response.status });
|
|
117
|
+
}
|
|
118
|
+
const type = response.headers.get("content-type") || "";
|
|
119
|
+
return type.includes("json") ? response.json() : response.text();
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (timedOut) {
|
|
122
|
+
throw Object.assign(new Error(`[Orvyn] fetch("${url}") timed out after ${timeoutMs}ms`), { name: "TimeoutError" });
|
|
123
|
+
}
|
|
124
|
+
if (token.aborted || error?.name === "AbortError") {
|
|
125
|
+
throw Object.assign(new Error(`[Orvyn] fetch("${url}") was cancelled`), { name: "AbortError" });
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
} finally {
|
|
129
|
+
if (timer !== null) clearTimeout(timer);
|
|
130
|
+
unbindActive();
|
|
131
|
+
token.cleanup();
|
|
56
132
|
}
|
|
57
|
-
route.set(screen);
|
|
58
133
|
}
|
|
134
|
+
const errorCenter = createErrorCenter({
|
|
135
|
+
isDev: () => {
|
|
136
|
+
const env2 = import.meta.env;
|
|
137
|
+
return env2 ? env2.DEV !== false && env2.PROD !== true : true;
|
|
138
|
+
},
|
|
139
|
+
send: (url, body) => typeof fetch === "function" ? fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), keepalive: true }) : void 0
|
|
140
|
+
});
|
|
141
|
+
const at = errorCenter.at;
|
|
142
|
+
const guard = errorCenter.guard;
|
|
143
|
+
const renderError = errorCenter.renderError;
|
|
144
|
+
const registerSource = errorCenter.registerSource;
|
|
145
|
+
const onError = errorCenter.onError;
|
|
146
|
+
const setErrorPage = errorCenter.setErrorPage;
|
|
147
|
+
const reportError = errorCenter.report;
|
|
148
|
+
const log = errorCenter.log;
|
|
149
|
+
const auth = createAuth(secure, { onLogoutReset: () => {
|
|
150
|
+
storage.resetAll();
|
|
151
|
+
storage.clear();
|
|
152
|
+
} });
|
|
153
|
+
const fetchData = auth.__wrapFetch(rawFetchData);
|
|
154
|
+
const { get, post, put, patch, load, task } = createHttp(fetchData);
|
|
155
|
+
const router = createRouter();
|
|
156
|
+
router.setGuard(auth.__guard);
|
|
157
|
+
auth.__attachRouter(router);
|
|
158
|
+
const go = router.go;
|
|
159
|
+
const back = router.back;
|
|
160
|
+
const canGoBack = router.canGoBack;
|
|
161
|
+
const openUrl = router.openUrl;
|
|
59
162
|
const BASE_CSS = `
|
|
60
163
|
:where(.orvyn-app) {
|
|
61
164
|
max-width: 760px;
|
|
62
165
|
margin: 0 auto;
|
|
63
166
|
min-height: 100vh;
|
|
167
|
+
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
|
|
64
168
|
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
|
|
65
|
-
font-size:
|
|
66
|
-
line-height: 1.
|
|
67
|
-
color: #0f172a;
|
|
68
|
-
background: #fff;
|
|
169
|
+
font-size: 1.0625rem;
|
|
170
|
+
line-height: 1.4;
|
|
171
|
+
color: var(--orvyn-text, #0f172a);
|
|
172
|
+
background: var(--orvyn-bg, #fff);
|
|
173
|
+
overflow-wrap: anywhere;
|
|
69
174
|
-webkit-font-smoothing: antialiased;
|
|
70
175
|
}
|
|
71
|
-
:where(.orvyn-app *) { box-sizing: border-box; }
|
|
176
|
+
:where(.orvyn-app *) { box-sizing: border-box; overflow-wrap: anywhere; }
|
|
72
177
|
:where(.orvyn-app button) {
|
|
178
|
+
display: inline-flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
gap: 6px;
|
|
73
182
|
border: none;
|
|
74
183
|
background: none;
|
|
75
184
|
padding: 0;
|
|
76
185
|
margin: 0;
|
|
77
186
|
font: inherit;
|
|
78
187
|
font-weight: 600;
|
|
79
|
-
color: #007aff;
|
|
188
|
+
color: var(--orvyn-primary, #007aff);
|
|
80
189
|
text-align: left;
|
|
81
190
|
cursor: pointer;
|
|
82
191
|
transition: opacity 0.15s, transform 0.1s;
|
|
83
192
|
}
|
|
84
|
-
:where(.orvyn-app button:hover) { opacity: 0.85; }
|
|
85
|
-
:where(.orvyn-app button:active) { opacity: 0.
|
|
193
|
+
:where(.orvyn-app button:hover:not(:disabled)) { opacity: 0.85; }
|
|
194
|
+
:where(.orvyn-app button:active:not(:disabled)) { opacity: 0.65; transform: scale(0.98); }
|
|
195
|
+
:where(.orvyn-app button:focus-visible) { outline: 2px solid var(--orvyn-primary, #007aff); outline-offset: 2px; }
|
|
196
|
+
:where(.orvyn-app button:disabled) { opacity: 0.5; cursor: not-allowed; }
|
|
197
|
+
:where(.orvyn-app button[data-orvyn-loading="true"]) { opacity: 0.75; cursor: progress; }
|
|
198
|
+
:where(.orvyn-app button[data-orvyn-loading="true"])::before {
|
|
199
|
+
content: "";
|
|
200
|
+
width: 0.85em;
|
|
201
|
+
height: 0.85em;
|
|
202
|
+
border: 2px solid currentColor;
|
|
203
|
+
border-right-color: transparent;
|
|
204
|
+
border-radius: 50%;
|
|
205
|
+
animation: orvyn-spin 0.7s linear infinite;
|
|
206
|
+
}
|
|
207
|
+
@keyframes orvyn-spin { to { transform: rotate(360deg); } }
|
|
208
|
+
@media (prefers-reduced-motion: reduce) {
|
|
209
|
+
.orvyn-app, .orvyn-app *, .orvyn-app *::before { transition: none !important; animation: none !important; scroll-behavior: auto !important; transform: none !important; }
|
|
210
|
+
}
|
|
211
|
+
:where(.orvyn-app img) { background: var(--orvyn-surface, #f8fafc); }
|
|
86
212
|
:where(.orvyn-app input) {
|
|
87
213
|
font: inherit;
|
|
88
214
|
color: inherit;
|
|
89
215
|
width: 100%;
|
|
90
216
|
min-width: 0;
|
|
91
217
|
padding: 10px;
|
|
92
|
-
border: 1px solid #cbd5e1;
|
|
218
|
+
border: 1px solid var(--orvyn-border, #cbd5e1);
|
|
93
219
|
border-radius: 8px;
|
|
94
220
|
outline: none;
|
|
95
|
-
background: #fff;
|
|
221
|
+
background: var(--orvyn-bg, #fff);
|
|
222
|
+
}
|
|
223
|
+
:where(.orvyn-app input:focus) { border-color: var(--orvyn-primary, #007aff); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }
|
|
224
|
+
:where(.orvyn-app textarea, .orvyn-app select) {
|
|
225
|
+
font: inherit; color: inherit; width: 100%; padding: 10px;
|
|
226
|
+
border: 1px solid var(--orvyn-border, #cbd5e1); border-radius: 8px; background: var(--orvyn-bg, #fff);
|
|
96
227
|
}
|
|
97
|
-
:where(.orvyn-app input
|
|
98
|
-
:where(.orvyn-app
|
|
228
|
+
:where(.orvyn-app input[type="checkbox"]) { width: 1.15em; height: 1.15em; padding: 0; flex-shrink: 0; accent-color: var(--orvyn-primary, #007aff); }
|
|
229
|
+
:where(.orvyn-app input[role="switch"]) {
|
|
230
|
+
appearance: none; width: 2.6em; height: 1.5em; border-radius: 999px; border: none; cursor: pointer;
|
|
231
|
+
background: var(--orvyn-border, #cbd5e1) radial-gradient(circle, #fff 0.6em, transparent 0.62em) left / 1.5em 100% no-repeat;
|
|
232
|
+
}
|
|
233
|
+
:where(.orvyn-app input[role="switch"]:checked) { background-color: var(--orvyn-primary, #007aff); background-position: right; }
|
|
234
|
+
:where(.orvyn-app input:disabled) { opacity: 0.5; cursor: not-allowed; background: var(--orvyn-surface, #f8fafc); }
|
|
235
|
+
:where(.orvyn-app input[data-orvyn-error="true"]), :where(.orvyn-app input[aria-invalid="true"]) { border-color: var(--orvyn-danger, #ef4444); }
|
|
236
|
+
:where(.orvyn-app input[data-orvyn-error="true"]:focus), :where(.orvyn-app input[aria-invalid="true"]:focus) { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
|
|
237
|
+
:where(.orvyn-app img) { display: block; object-fit: contain; flex-shrink: 0; max-width: 100%; }
|
|
99
238
|
:where(.orvyn-app h1, .orvyn-app h2, .orvyn-app h3) { margin: 0; line-height: 1.15; }
|
|
100
|
-
:where(.orvyn-app a) { color: #007aff; text-decoration: none; font-weight: 600; }
|
|
239
|
+
:where(.orvyn-app a) { color: var(--orvyn-primary, #007aff); text-decoration: none; font-weight: 600; }
|
|
101
240
|
`;
|
|
102
241
|
function injectBaseStyles() {
|
|
103
242
|
if (typeof document === "undefined" || document.getElementById("orvyn-base")) return;
|
|
@@ -107,46 +246,217 @@ function injectBaseStyles() {
|
|
|
107
246
|
document.head.prepend(style);
|
|
108
247
|
}
|
|
109
248
|
function Router() {
|
|
110
|
-
const
|
|
111
|
-
|
|
249
|
+
const current = router.current();
|
|
250
|
+
if (!current) return [];
|
|
251
|
+
return [createVNode(current.screen, { ...current.params, key: current.key }, [])];
|
|
112
252
|
}
|
|
113
|
-
function startApp(target, entry, onStart) {
|
|
253
|
+
function startApp(target, entry, onStart, screens = {}, initialParams = {}) {
|
|
114
254
|
if (typeof entry !== "function") {
|
|
115
255
|
throw new Error("[Orvyn] No screen to show. Add: screen Home { ... }");
|
|
116
256
|
}
|
|
117
|
-
|
|
257
|
+
const endWork = startAppWork();
|
|
258
|
+
screens = { ...allScreens, ...screens };
|
|
259
|
+
const win = globalThis.window;
|
|
260
|
+
const hasHistory = Boolean(
|
|
261
|
+
win && win.location && win.history && typeof win.history.pushState === "function"
|
|
262
|
+
);
|
|
263
|
+
const siteRoot = String(import.meta.env?.BASE_URL || "/").replace(/^\.?\/?/, "/").replace(/\/?$/, "/");
|
|
264
|
+
const clean = hasHistory && !String(win.location.pathname || "/").endsWith(".html") && String(win.location.pathname || "/").startsWith(siteRoot);
|
|
265
|
+
const formatBrowserUrl = (routeUrl) => {
|
|
266
|
+
if (clean) {
|
|
267
|
+
const one = routeUrl.match(/^(\/[^/?]+)\?([^=&]+)=([^&]+)$/);
|
|
268
|
+
const screen = one && Object.entries(screens).find(([name]) => `/${name.toLowerCase()}` === one[1])?.[1];
|
|
269
|
+
const path = one && screen && (screen.__params?.[0] ?? "id") === one[2] ? `${one[1]}/${one[3]}` : routeUrl;
|
|
270
|
+
return siteRoot + path.slice(1);
|
|
271
|
+
}
|
|
272
|
+
const base = `${win.location.pathname || "/"}${win.location.search || ""}`;
|
|
273
|
+
if (routeUrl === "/" && !win.location.hash) return base;
|
|
274
|
+
return `${base}#${routeUrl}`;
|
|
275
|
+
};
|
|
276
|
+
const addressRoute = () => {
|
|
277
|
+
const hash = String(win.location.hash || "");
|
|
278
|
+
const known = (url2) => {
|
|
279
|
+
const parsed = parseRouteUrl(url2, screens, entry);
|
|
280
|
+
return parsed && parsed.screen !== screens.NotFound ? url2 : null;
|
|
281
|
+
};
|
|
282
|
+
if (hash) return hash.startsWith("#/") ? hash : known(hash);
|
|
283
|
+
let path = win.location.pathname || "/";
|
|
284
|
+
if (clean) path = `/${path.slice(siteRoot.length)}`;
|
|
285
|
+
if (path === "/" || path.endsWith(".html")) return null;
|
|
286
|
+
const url = `${path}${win.location.search || ""}`;
|
|
287
|
+
return path.endsWith("/") ? known(url) : url;
|
|
288
|
+
};
|
|
289
|
+
let onPopState = null;
|
|
290
|
+
router.start(entry, screens, initialParams, {
|
|
291
|
+
getInitialUrl: () => hasHistory ? addressRoute() : null,
|
|
292
|
+
pushUrl: (routeUrl, state) => {
|
|
293
|
+
if (hasHistory) win.history.pushState(state, "", formatBrowserUrl(routeUrl));
|
|
294
|
+
},
|
|
295
|
+
replaceUrl: (routeUrl, state) => {
|
|
296
|
+
if (hasHistory && typeof win.history.replaceState === "function") {
|
|
297
|
+
win.history.replaceState(state, "", formatBrowserUrl(routeUrl));
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
goBack: () => {
|
|
301
|
+
if (hasHistory && typeof win.history.back === "function") {
|
|
302
|
+
win.history.back();
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
if (hasHistory && typeof win.addEventListener === "function") {
|
|
309
|
+
onPopState = (event) => {
|
|
310
|
+
router.handlePopState(event?.state, addressRoute() ?? (win.location.hash ? null : "/"));
|
|
311
|
+
};
|
|
312
|
+
win.addEventListener("popstate", onPopState);
|
|
313
|
+
}
|
|
314
|
+
const onWindowError = (event) => errorCenter.report(event?.error ?? event?.message, "", "uncaught");
|
|
315
|
+
const onRejection = (event) => {
|
|
316
|
+
if (event?.reason?.name === "AbortError") return;
|
|
317
|
+
errorCenter.report(event?.reason, "", "async");
|
|
318
|
+
};
|
|
319
|
+
win?.addEventListener?.("error", onWindowError);
|
|
320
|
+
win?.addEventListener?.("unhandledrejection", onRejection);
|
|
321
|
+
const onKey = (event) => {
|
|
322
|
+
if (event?.key === "Escape" && errorCenter.overlay.isOpen) errorCenter.overlay.close();
|
|
323
|
+
};
|
|
324
|
+
win?.addEventListener?.("keydown", onKey);
|
|
118
325
|
injectBaseStyles();
|
|
119
326
|
target.classList.add("orvyn-app");
|
|
120
|
-
target.
|
|
327
|
+
if (target.getAttribute?.("data-orvyn-static") !== null && target.getAttribute?.("data-orvyn-static") !== void 0) {
|
|
328
|
+
target.textContent = "";
|
|
329
|
+
target.removeAttribute("data-orvyn-static");
|
|
330
|
+
}
|
|
331
|
+
const root = createOwner();
|
|
332
|
+
runWithOwner(root, () => {
|
|
333
|
+
effect(() => {
|
|
334
|
+
const current = theme();
|
|
335
|
+
const s = target.style;
|
|
336
|
+
if (s?.setProperty) {
|
|
337
|
+
s.setProperty("--orvyn-bg", current.colors.bg);
|
|
338
|
+
s.setProperty("--orvyn-surface", current.colors.surface);
|
|
339
|
+
s.setProperty("--orvyn-card", current.colors.card);
|
|
340
|
+
s.setProperty("--orvyn-text", current.colors.text);
|
|
341
|
+
s.setProperty("--orvyn-muted", current.colors.muted);
|
|
342
|
+
s.setProperty("--orvyn-primary", current.colors.primary);
|
|
343
|
+
s.setProperty("--orvyn-on-primary", current.colors.onPrimary);
|
|
344
|
+
s.setProperty("--orvyn-border", current.colors.border);
|
|
345
|
+
s.setProperty("--orvyn-danger", current.colors.danger);
|
|
346
|
+
s.setProperty("--orvyn-success", current.colors.success);
|
|
347
|
+
s.setProperty("--orvyn-warning", current.colors.warning);
|
|
348
|
+
s.colorScheme = current.dark ? "dark" : "light";
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
const view = runWithOwner(root, () => mount(createVNode(Router, {}, [])));
|
|
353
|
+
target.appendChild(view);
|
|
354
|
+
const isDevNow = (() => {
|
|
355
|
+
const env2 = import.meta.env;
|
|
356
|
+
return env2 ? env2.DEV !== false && env2.PROD !== true : true;
|
|
357
|
+
})();
|
|
358
|
+
const stopOverlay = isDevNow ? mountWebOverlay(errorCenter.overlay, () => {
|
|
359
|
+
const current = router.current();
|
|
360
|
+
if (!current) return null;
|
|
361
|
+
const hash = win?.location?.hash ? String(win.location.hash).slice(1) : "";
|
|
362
|
+
return {
|
|
363
|
+
screen: current.screen.name || "Screen",
|
|
364
|
+
url: hash || "/",
|
|
365
|
+
params: current.params,
|
|
366
|
+
screens: Object.keys(screens)
|
|
367
|
+
};
|
|
368
|
+
}) : () => {
|
|
369
|
+
};
|
|
121
370
|
if (onStart) {
|
|
122
|
-
Promise.resolve(onStart
|
|
371
|
+
Promise.resolve(runAppWork(onStart)).catch((error) => console.error(error));
|
|
123
372
|
}
|
|
373
|
+
return () => {
|
|
374
|
+
if (onPopState && win?.removeEventListener) {
|
|
375
|
+
win.removeEventListener("popstate", onPopState);
|
|
376
|
+
}
|
|
377
|
+
win?.removeEventListener?.("error", onWindowError);
|
|
378
|
+
win?.removeEventListener?.("unhandledrejection", onRejection);
|
|
379
|
+
win?.removeEventListener?.("keydown", onKey);
|
|
380
|
+
endWork();
|
|
381
|
+
stopOverlay();
|
|
382
|
+
disposeDomTree(view);
|
|
383
|
+
disposeOwner(root);
|
|
384
|
+
router.reset();
|
|
385
|
+
view.remove();
|
|
386
|
+
};
|
|
124
387
|
}
|
|
125
388
|
import { signal as signal2 } from "../core/signal.js";
|
|
126
389
|
import { createVNode as createVNode2 } from "../runtime/vnode.js";
|
|
127
390
|
export {
|
|
391
|
+
List,
|
|
128
392
|
add,
|
|
393
|
+
at,
|
|
394
|
+
auth,
|
|
395
|
+
back,
|
|
396
|
+
bindCheck,
|
|
129
397
|
bindInput,
|
|
398
|
+
canGoBack,
|
|
399
|
+
carryLocals,
|
|
130
400
|
clear,
|
|
401
|
+
componentState,
|
|
131
402
|
createForm,
|
|
403
|
+
createMap,
|
|
404
|
+
createModal,
|
|
405
|
+
createSavedSignal,
|
|
406
|
+
createSelect,
|
|
407
|
+
createTabs,
|
|
132
408
|
createVNode2 as createVNode,
|
|
409
|
+
env,
|
|
410
|
+
errorText,
|
|
133
411
|
fetchData,
|
|
134
412
|
formCache,
|
|
413
|
+
get,
|
|
414
|
+
getLocation,
|
|
135
415
|
go,
|
|
416
|
+
guard,
|
|
136
417
|
importedState,
|
|
418
|
+
isEmptyValue,
|
|
419
|
+
keyed,
|
|
137
420
|
len,
|
|
421
|
+
load,
|
|
422
|
+
log,
|
|
423
|
+
onError,
|
|
424
|
+
openUrl,
|
|
425
|
+
patch,
|
|
426
|
+
pickFile,
|
|
427
|
+
pickPhoto,
|
|
428
|
+
post,
|
|
429
|
+
put,
|
|
138
430
|
random,
|
|
139
431
|
readImported,
|
|
432
|
+
registerScreens,
|
|
433
|
+
registerSource,
|
|
140
434
|
remove,
|
|
141
435
|
removeAt,
|
|
436
|
+
renderError,
|
|
437
|
+
reportError,
|
|
438
|
+
resetState,
|
|
439
|
+
resume,
|
|
142
440
|
savedSignal,
|
|
441
|
+
secure,
|
|
143
442
|
setAt,
|
|
443
|
+
setEnv,
|
|
444
|
+
setErrorPage,
|
|
144
445
|
setField,
|
|
446
|
+
setPage,
|
|
447
|
+
setStyleWarningHandler,
|
|
145
448
|
signal2 as signal,
|
|
146
449
|
sleep,
|
|
450
|
+
snapshotLocals,
|
|
147
451
|
startApp,
|
|
452
|
+
storage,
|
|
148
453
|
str,
|
|
149
454
|
submitHandler,
|
|
455
|
+
takePhoto,
|
|
456
|
+
task,
|
|
457
|
+
theme2 as theme,
|
|
458
|
+
track,
|
|
150
459
|
update,
|
|
151
|
-
validate
|
|
460
|
+
validate,
|
|
461
|
+
words
|
|
152
462
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createVNode } from "../runtime/vnode.js";
|
|
2
|
+
function createSelect(props, options) {
|
|
3
|
+
const { placeholder, value, ...rest } = props;
|
|
4
|
+
const chosen = String(value ?? "");
|
|
5
|
+
const option = (text, shown) => createVNode("option", { value: text, selected: text === chosen }, [shown]);
|
|
6
|
+
return createVNode("select", rest, [
|
|
7
|
+
option("", String(placeholder || "Choose...")),
|
|
8
|
+
...Array.from(options ?? [], (item) => option(String(item), String(item)))
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
createSelect
|
|
13
|
+
};
|