orvyn-lang 0.1.1 → 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 +877 -24
- package/README.md +227 -131
- package/brand/orvyn-sunset-animated.svg +15 -0
- package/package.json +3 -1
- package/src/cli/orvyn.js +216 -489
- 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 +498 -64
- 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 +160 -0
- 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 +519 -40
- 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 +268 -4
- package/src/lang/native/ios/OrvynViews.swift +429 -31
- package/src/lang/native/ios.js +75 -2
- package/src/lang/native-runtime.js +423 -57
- 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 +820 -10
- package/src/lang/runtime.js +375 -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/validation.js +55 -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/core/context.js +0 -19
- package/src/core/lifecycle.js +0 -8
- package/src/core/resource.js +0 -27
- package/src/core/router.js +0 -20
- package/src/core/theme.js +0 -10
- package/src/devtools/devicePreview/PreviewFrame.js +0 -214
- package/src/devtools/devicePreview/index.js +0 -6
- package/src/devtools/overlay.js +0 -105
- package/src/runtime/createRenderer.js +0 -22
- package/src/runtime/h.js +0 -93
- package/src/runtime/hydrate.js +0 -59
- package/src/runtime/jsx-dev-runtime.js +0 -7
- package/src/runtime/jsx-runtime.js +0 -13
- package/src/runtime/partialHydration.js +0 -154
- package/src/runtime/platform.js +0 -135
- package/src/runtime/renderToStream.js +0 -127
- package/src/runtime/renderToString.js +0 -121
- package/src/runtime/resume.js +0 -62
package/src/lang/runtime.js
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
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 {
|
|
57
|
+
readImported,
|
|
58
|
+
bindInput,
|
|
59
|
+
submitHandler,
|
|
60
|
+
importedState,
|
|
21
61
|
str,
|
|
22
62
|
add,
|
|
23
63
|
remove,
|
|
@@ -28,70 +68,175 @@ import {
|
|
|
28
68
|
setField,
|
|
29
69
|
sleep,
|
|
30
70
|
random,
|
|
31
|
-
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
|
|
32
83
|
} from "./runtime-shared.js";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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);
|
|
90
|
+
import { formCache, createForm } from "./form.js";
|
|
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") {
|
|
36
110
|
init.body = JSON.stringify(options.body);
|
|
37
111
|
init.headers = { "Content-Type": "application/json", ...options.headers || {} };
|
|
38
112
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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();
|
|
50
132
|
}
|
|
51
|
-
route.set(screen);
|
|
52
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;
|
|
53
162
|
const BASE_CSS = `
|
|
54
163
|
:where(.orvyn-app) {
|
|
55
164
|
max-width: 760px;
|
|
56
165
|
margin: 0 auto;
|
|
57
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);
|
|
58
168
|
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
|
|
59
|
-
font-size:
|
|
60
|
-
line-height: 1.
|
|
61
|
-
color: #0f172a;
|
|
62
|
-
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;
|
|
63
174
|
-webkit-font-smoothing: antialiased;
|
|
64
175
|
}
|
|
65
|
-
:where(.orvyn-app *) { box-sizing: border-box; }
|
|
176
|
+
:where(.orvyn-app *) { box-sizing: border-box; overflow-wrap: anywhere; }
|
|
66
177
|
:where(.orvyn-app button) {
|
|
178
|
+
display: inline-flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
gap: 6px;
|
|
67
182
|
border: none;
|
|
68
183
|
background: none;
|
|
69
184
|
padding: 0;
|
|
70
185
|
margin: 0;
|
|
71
186
|
font: inherit;
|
|
72
187
|
font-weight: 600;
|
|
73
|
-
color: #007aff;
|
|
188
|
+
color: var(--orvyn-primary, #007aff);
|
|
74
189
|
text-align: left;
|
|
75
190
|
cursor: pointer;
|
|
76
191
|
transition: opacity 0.15s, transform 0.1s;
|
|
77
192
|
}
|
|
78
|
-
:where(.orvyn-app button:hover) { opacity: 0.85; }
|
|
79
|
-
: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); }
|
|
80
212
|
:where(.orvyn-app input) {
|
|
81
213
|
font: inherit;
|
|
82
214
|
color: inherit;
|
|
83
215
|
width: 100%;
|
|
84
216
|
min-width: 0;
|
|
85
217
|
padding: 10px;
|
|
86
|
-
border: 1px solid #cbd5e1;
|
|
218
|
+
border: 1px solid var(--orvyn-border, #cbd5e1);
|
|
87
219
|
border-radius: 8px;
|
|
88
220
|
outline: none;
|
|
89
|
-
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);
|
|
227
|
+
}
|
|
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;
|
|
90
232
|
}
|
|
91
|
-
:where(.orvyn-app input:
|
|
92
|
-
:where(.orvyn-app
|
|
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%; }
|
|
93
238
|
:where(.orvyn-app h1, .orvyn-app h2, .orvyn-app h3) { margin: 0; line-height: 1.15; }
|
|
94
|
-
: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; }
|
|
95
240
|
`;
|
|
96
241
|
function injectBaseStyles() {
|
|
97
242
|
if (typeof document === "undefined" || document.getElementById("orvyn-base")) return;
|
|
@@ -101,39 +246,217 @@ function injectBaseStyles() {
|
|
|
101
246
|
document.head.prepend(style);
|
|
102
247
|
}
|
|
103
248
|
function Router() {
|
|
104
|
-
const
|
|
105
|
-
|
|
249
|
+
const current = router.current();
|
|
250
|
+
if (!current) return [];
|
|
251
|
+
return [createVNode(current.screen, { ...current.params, key: current.key }, [])];
|
|
106
252
|
}
|
|
107
|
-
function startApp(target, entry, onStart) {
|
|
253
|
+
function startApp(target, entry, onStart, screens = {}, initialParams = {}) {
|
|
108
254
|
if (typeof entry !== "function") {
|
|
109
255
|
throw new Error("[Orvyn] No screen to show. Add: screen Home { ... }");
|
|
110
256
|
}
|
|
111
|
-
|
|
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);
|
|
112
325
|
injectBaseStyles();
|
|
113
326
|
target.classList.add("orvyn-app");
|
|
114
|
-
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
|
+
};
|
|
115
370
|
if (onStart) {
|
|
116
|
-
Promise.resolve(onStart
|
|
371
|
+
Promise.resolve(runAppWork(onStart)).catch((error) => console.error(error));
|
|
117
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
|
+
};
|
|
118
387
|
}
|
|
119
388
|
import { signal as signal2 } from "../core/signal.js";
|
|
120
389
|
import { createVNode as createVNode2 } from "../runtime/vnode.js";
|
|
121
390
|
export {
|
|
391
|
+
List,
|
|
122
392
|
add,
|
|
393
|
+
at,
|
|
394
|
+
auth,
|
|
395
|
+
back,
|
|
396
|
+
bindCheck,
|
|
397
|
+
bindInput,
|
|
398
|
+
canGoBack,
|
|
399
|
+
carryLocals,
|
|
123
400
|
clear,
|
|
401
|
+
componentState,
|
|
402
|
+
createForm,
|
|
403
|
+
createMap,
|
|
404
|
+
createModal,
|
|
405
|
+
createSavedSignal,
|
|
406
|
+
createSelect,
|
|
407
|
+
createTabs,
|
|
124
408
|
createVNode2 as createVNode,
|
|
409
|
+
env,
|
|
410
|
+
errorText,
|
|
125
411
|
fetchData,
|
|
412
|
+
formCache,
|
|
413
|
+
get,
|
|
414
|
+
getLocation,
|
|
126
415
|
go,
|
|
416
|
+
guard,
|
|
417
|
+
importedState,
|
|
418
|
+
isEmptyValue,
|
|
419
|
+
keyed,
|
|
127
420
|
len,
|
|
421
|
+
load,
|
|
422
|
+
log,
|
|
423
|
+
onError,
|
|
424
|
+
openUrl,
|
|
425
|
+
patch,
|
|
426
|
+
pickFile,
|
|
427
|
+
pickPhoto,
|
|
428
|
+
post,
|
|
429
|
+
put,
|
|
128
430
|
random,
|
|
431
|
+
readImported,
|
|
432
|
+
registerScreens,
|
|
433
|
+
registerSource,
|
|
129
434
|
remove,
|
|
130
435
|
removeAt,
|
|
436
|
+
renderError,
|
|
437
|
+
reportError,
|
|
438
|
+
resetState,
|
|
439
|
+
resume,
|
|
131
440
|
savedSignal,
|
|
441
|
+
secure,
|
|
132
442
|
setAt,
|
|
443
|
+
setEnv,
|
|
444
|
+
setErrorPage,
|
|
133
445
|
setField,
|
|
446
|
+
setPage,
|
|
447
|
+
setStyleWarningHandler,
|
|
134
448
|
signal2 as signal,
|
|
135
449
|
sleep,
|
|
450
|
+
snapshotLocals,
|
|
136
451
|
startApp,
|
|
452
|
+
storage,
|
|
137
453
|
str,
|
|
138
|
-
|
|
454
|
+
submitHandler,
|
|
455
|
+
takePhoto,
|
|
456
|
+
task,
|
|
457
|
+
theme2 as theme,
|
|
458
|
+
track,
|
|
459
|
+
update,
|
|
460
|
+
validate,
|
|
461
|
+
words
|
|
139
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
|
+
};
|