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