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.
Files changed (74) hide show
  1. package/GUIDE.md +149 -0
  2. package/LANGUAGE.md +877 -24
  3. package/README.md +227 -131
  4. package/brand/orvyn-sunset-animated.svg +15 -0
  5. package/package.json +3 -1
  6. package/src/cli/orvyn.js +216 -489
  7. package/src/core/signal.js +104 -6
  8. package/src/devtools/runtime.js +25 -1
  9. package/src/lang/a11y.js +102 -0
  10. package/src/lang/auth.js +239 -0
  11. package/src/lang/bundle-native.js +10 -6
  12. package/src/lang/codegen.js +498 -64
  13. package/src/lang/device.js +41 -0
  14. package/src/lang/doctor.js +60 -0
  15. package/src/lang/env.js +27 -0
  16. package/src/lang/errors.js +513 -0
  17. package/src/lang/form.js +160 -0
  18. package/src/lang/index.js +2 -1
  19. package/src/lang/lexer.js +2 -0
  20. package/src/lang/list.js +44 -0
  21. package/src/lang/native/android/MainActivity.kt +43 -4
  22. package/src/lang/native/android/OrvynDevice.kt +163 -0
  23. package/src/lang/native/android/OrvynEngine.kt +154 -7
  24. package/src/lang/native/android/OrvynRenderer.kt +519 -40
  25. package/src/lang/native/android.js +74 -11
  26. package/src/lang/native/build.js +130 -60
  27. package/src/lang/native/config.js +108 -0
  28. package/src/lang/native/ios/OrvynApp.swift +6 -0
  29. package/src/lang/native/ios/OrvynEngine.swift +268 -4
  30. package/src/lang/native/ios/OrvynViews.swift +429 -31
  31. package/src/lang/native/ios.js +75 -2
  32. package/src/lang/native-runtime.js +423 -57
  33. package/src/lang/page.js +52 -0
  34. package/src/lang/parser.js +243 -15
  35. package/src/lang/prerender.js +300 -0
  36. package/src/lang/read-import.js +11 -0
  37. package/src/lang/router.js +266 -0
  38. package/src/lang/runtime-shared.js +820 -10
  39. package/src/lang/runtime.js +375 -52
  40. package/src/lang/select.js +13 -0
  41. package/src/lang/server-code.js +233 -0
  42. package/src/lang/server-export.js +78 -0
  43. package/src/lang/server-libs.js +53 -0
  44. package/src/lang/server.js +409 -0
  45. package/src/lang/test-runner.js +134 -0
  46. package/src/lang/types.js +312 -0
  47. package/src/lang/validation.js +55 -0
  48. package/src/lang/vite-plugin.js +82 -3
  49. package/src/lang/web-overlay.js +578 -0
  50. package/src/lang/widgets.js +94 -0
  51. package/src/lang/words.js +38 -0
  52. package/src/runtime/mount.js +116 -27
  53. package/src/runtime/patch.js +90 -11
  54. package/src/runtime/style.js +11 -1
  55. package/src/styling/fluid.js +91 -4
  56. package/src/styling/spec.js +306 -0
  57. package/src/core/context.js +0 -19
  58. package/src/core/lifecycle.js +0 -8
  59. package/src/core/resource.js +0 -27
  60. package/src/core/router.js +0 -20
  61. package/src/core/theme.js +0 -10
  62. package/src/devtools/devicePreview/PreviewFrame.js +0 -214
  63. package/src/devtools/devicePreview/index.js +0 -6
  64. package/src/devtools/overlay.js +0 -105
  65. package/src/runtime/createRenderer.js +0 -22
  66. package/src/runtime/h.js +0 -93
  67. package/src/runtime/hydrate.js +0 -59
  68. package/src/runtime/jsx-dev-runtime.js +0 -7
  69. package/src/runtime/jsx-runtime.js +0 -13
  70. package/src/runtime/partialHydration.js +0 -154
  71. package/src/runtime/platform.js +0 -135
  72. package/src/runtime/renderToStream.js +0 -127
  73. package/src/runtime/renderToString.js +0 -121
  74. package/src/runtime/resume.js +0 -62
@@ -0,0 +1,306 @@
1
+ import { signal } from "../core/signal.js";
2
+ const STYLE_SPEC = {
3
+ // Layout & sizing (all platforms)
4
+ width: { support: "all" },
5
+ height: { support: "all" },
6
+ minWidth: { support: "all" },
7
+ maxWidth: { support: "all" },
8
+ minHeight: { support: "all" },
9
+ maxHeight: { support: "all" },
10
+ padding: { support: "all" },
11
+ paddingX: { support: "all" },
12
+ paddingY: { support: "all" },
13
+ margin: { support: "all" },
14
+ gap: { support: "all" },
15
+ align: { support: "all" },
16
+ justify: { support: "all" },
17
+ center: { support: "all" },
18
+ wrap: { support: "all" },
19
+ scroll: { support: "all" },
20
+ grow: { support: "all" },
21
+ flex: { support: "all" },
22
+ direction: { support: "all" },
23
+ // Visual appearance (all platforms)
24
+ bg: { support: "all" },
25
+ color: { support: "all" },
26
+ radius: { support: "all" },
27
+ border: { support: "all" },
28
+ shadow: { support: "all" },
29
+ opacity: { support: "all" },
30
+ // Typography & direction (all platforms)
31
+ size: { support: "all" },
32
+ weight: { support: "all" },
33
+ fontWeight: { support: "all" },
34
+ font: { support: "all" },
35
+ lineHeight: { support: "all" },
36
+ textAlign: { support: "all" },
37
+ rtl: { support: "all" },
38
+ // Interactive & validation states (all platforms)
39
+ disabled: { support: "all" },
40
+ loading: { support: "all" },
41
+ error: { support: "all" },
42
+ pressed: { support: "all" },
43
+ active: { support: "all" },
44
+ focus: { support: "all" },
45
+ // Web-specific extras (warn cleanly when used in native apps)
46
+ hover: { support: "web", note: "Touch devices have no pointer hover state" },
47
+ grid: { support: "web", note: "CSS Grid layout is web-only; use Row with wrap: true for cross-platform grids" },
48
+ columns: { support: "web", note: "CSS Grid columns are web-only; use Row with wrap: true on phones" },
49
+ rows: { support: "web", note: "CSS Grid rows are web-only" },
50
+ minItemWidth: { support: "web", note: "CSS Grid auto-fit width is web-only" },
51
+ basis: { support: "web", note: "flex-basis is web-only; use width on phones" },
52
+ shrink: { support: "web", note: "flex-shrink is web-only" },
53
+ display: { support: "web" },
54
+ overflow: { support: "web", note: "Use scroll: true for cross-platform scrolling" },
55
+ overflowX: { support: "web", note: 'Use scroll: "horizontal" for cross-platform scrolling' },
56
+ overflowY: { support: "web", note: "Use scroll: true for cross-platform scrolling" },
57
+ objectFit: { support: "web" },
58
+ objectPosition: { support: "web" },
59
+ position: { support: "web", note: "Absolute/fixed CSS positioning is web-only" },
60
+ inset: { support: "web" },
61
+ top: { support: "web" },
62
+ right: { support: "web" },
63
+ bottom: { support: "web" },
64
+ left: { support: "web" },
65
+ zIndex: { support: "web" },
66
+ boxShadow: { support: "web", note: "Use shadow: 1..3 for cross-platform elevation" },
67
+ cursor: { support: "web" },
68
+ userSelect: { support: "web" },
69
+ pointerEvents: { support: "web" },
70
+ transform: { support: "web" },
71
+ transition: { support: "web" },
72
+ whiteSpace: { support: "web" },
73
+ letterSpacing: { support: "web" },
74
+ textDecoration: { support: "web" }
75
+ };
76
+ const NON_STYLE_PROPS = /* @__PURE__ */ new Set([
77
+ "children",
78
+ "key",
79
+ "class",
80
+ "className",
81
+ "hydrate",
82
+ "resume",
83
+ "nativeRole",
84
+ "type",
85
+ "placeholder",
86
+ "value",
87
+ "checked",
88
+ "selected",
89
+ "src",
90
+ "href",
91
+ "alt",
92
+ "id",
93
+ "name",
94
+ "role",
95
+ "noValidate",
96
+ "required",
97
+ "minLength",
98
+ "maxLength",
99
+ "email",
100
+ "label",
101
+ "message",
102
+ "bind"
103
+ ]);
104
+ const LIGHT_COLORS = {
105
+ bg: "#ffffff",
106
+ surface: "#f8fafc",
107
+ card: "#f1f5f9",
108
+ text: "#0f172a",
109
+ muted: "#64748b",
110
+ primary: "#007aff",
111
+ onPrimary: "#ffffff",
112
+ border: "#cbd5e1",
113
+ danger: "#b91c1c",
114
+ success: "#16a34a",
115
+ warning: "#f59e0b"
116
+ };
117
+ const DARK_COLORS = {
118
+ bg: "#0b0f19",
119
+ surface: "#111827",
120
+ card: "#1e293b",
121
+ text: "#f8fafc",
122
+ muted: "#94a3b8",
123
+ primary: "#3b82f6",
124
+ onPrimary: "#ffffff",
125
+ border: "#334155",
126
+ danger: "#f87171",
127
+ success: "#4ade80",
128
+ warning: "#fbbf24"
129
+ };
130
+ const DEFAULT_SPACING = {
131
+ xs: 4,
132
+ sm: 8,
133
+ md: 16,
134
+ lg: 24,
135
+ xl: 32
136
+ };
137
+ const DEFAULT_TEXT_SIZES = {
138
+ caption: 13,
139
+ body: 17,
140
+ subtitle: 20,
141
+ title: 28
142
+ };
143
+ function systemPrefersDark() {
144
+ try {
145
+ return typeof globalThis.matchMedia === "function" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
146
+ } catch {
147
+ return false;
148
+ }
149
+ }
150
+ function buildTheme(mode, overrides = {}) {
151
+ const dark = mode === "dark" || mode === "system" && systemPrefersDark();
152
+ const base = dark ? DARK_COLORS : LIGHT_COLORS;
153
+ return {
154
+ mode,
155
+ dark,
156
+ colors: { ...base, ...overrides },
157
+ spacing: { ...DEFAULT_SPACING },
158
+ textSizes: { ...DEFAULT_TEXT_SIZES }
159
+ };
160
+ }
161
+ const themeState = signal(buildTheme("light"), "__orvyn_theme");
162
+ let themeOverrides = {};
163
+ function setOrReadTheme(input) {
164
+ if (input === void 0) return themeState.get();
165
+ if (typeof input === "string") {
166
+ if (input !== "light" && input !== "dark" && input !== "system") {
167
+ throw new Error(`[Orvyn] theme("${input}") is not valid. Use "light", "dark", or "system".`);
168
+ }
169
+ const next = buildTheme(input, themeOverrides);
170
+ themeState.set(next);
171
+ return next;
172
+ }
173
+ if (input && typeof input === "object") {
174
+ const { mode, dark, ...palette } = input;
175
+ const resolvedMode = mode ?? (dark === true ? "dark" : dark === false ? "light" : themeState.get().mode);
176
+ themeOverrides = { ...themeOverrides, ...palette };
177
+ const next = buildTheme(resolvedMode, themeOverrides);
178
+ themeState.set(next);
179
+ return next;
180
+ }
181
+ return themeState.get();
182
+ }
183
+ const theme = Object.defineProperties(setOrReadTheme, {
184
+ mode: { get: () => themeState.get().mode, enumerable: true },
185
+ dark: { get: () => themeState.get().dark, enumerable: true },
186
+ colors: { get: () => themeState.get().colors, enumerable: true },
187
+ spacing: { get: () => themeState.get().spacing, enumerable: true },
188
+ textSizes: { get: () => themeState.get().textSizes, enumerable: true },
189
+ toggle: {
190
+ value: () => setOrReadTheme(themeState.get().dark ? "light" : "dark"),
191
+ enumerable: true
192
+ }
193
+ });
194
+ const LIGHT_BGS = /* @__PURE__ */ new Set(["white", "#fff", "#ffffff", "surface", "card", "yellow", "transparent", "clear"]);
195
+ function autoButtonColor(bg, currentTheme = themeState.get()) {
196
+ if (typeof bg !== "string") return null;
197
+ const key = bg.trim().toLowerCase();
198
+ if (!key || key === "none") return null;
199
+ if (LIGHT_BGS.has(key) || key === currentTheme.colors.bg.toLowerCase() && !currentTheme.dark) {
200
+ return "#0f172a";
201
+ }
202
+ return "#ffffff";
203
+ }
204
+ function resetTheme() {
205
+ themeOverrides = {};
206
+ themeState.set(buildTheme("light"));
207
+ }
208
+ function subscribeTheme(fn) {
209
+ return themeState.subscribe(fn);
210
+ }
211
+ const COLOR_PROPS = /* @__PURE__ */ new Set(["bg", "color"]);
212
+ const SPACE_PROPS = /* @__PURE__ */ new Set(["padding", "paddingX", "paddingY", "margin", "gap", "radius"]);
213
+ const FONT_ALIASES = {
214
+ sans: '-apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif',
215
+ serif: 'Georgia, Cambria, "Times New Roman", Times, serif',
216
+ mono: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"
217
+ };
218
+ function resolveThemeToken(prop, value, currentTheme = themeState.get()) {
219
+ if (typeof value !== "string") return value;
220
+ const key = value.trim();
221
+ if (COLOR_PROPS.has(prop) && Object.hasOwn(currentTheme.colors, key)) {
222
+ return currentTheme.colors[key];
223
+ }
224
+ if (prop === "border") {
225
+ return key.split(/\s+/).map(
226
+ (part) => Object.hasOwn(currentTheme.colors, part) ? currentTheme.colors[part] : part
227
+ ).join(" ");
228
+ }
229
+ if (SPACE_PROPS.has(prop) && Object.hasOwn(currentTheme.spacing, key)) {
230
+ return currentTheme.spacing[key];
231
+ }
232
+ if (prop === "size" && Object.hasOwn(currentTheme.textSizes, key)) {
233
+ return currentTheme.textSizes[key];
234
+ }
235
+ return value;
236
+ }
237
+ function resolveFontFamily(value, target) {
238
+ if (typeof value !== "string" || !value.trim()) return null;
239
+ const trimmed = value.trim();
240
+ if (target === "web") return FONT_ALIASES[trimmed] ?? trimmed;
241
+ return trimmed;
242
+ }
243
+ const emittedWarnings = /* @__PURE__ */ new Set();
244
+ let warningHandler = null;
245
+ function setStyleWarningHandler(fn) {
246
+ warningHandler = fn;
247
+ emittedWarnings.clear();
248
+ }
249
+ function clearStyleWarnings() {
250
+ emittedWarnings.clear();
251
+ }
252
+ function closestStyleProp(name) {
253
+ const lower = name.toLowerCase();
254
+ const aliases = {
255
+ colour: "color",
256
+ background: "bg",
257
+ backgroundcolor: "bg",
258
+ fontsize: "size",
259
+ fontweight: "weight",
260
+ fontfamily: "font",
261
+ borderradius: "radius",
262
+ textalign: "textAlign",
263
+ lineheight: "lineHeight",
264
+ maxwidth: "maxWidth",
265
+ minwidth: "minWidth",
266
+ maxheight: "maxHeight",
267
+ minheight: "minHeight",
268
+ paddingx: "paddingX",
269
+ paddingy: "paddingY"
270
+ };
271
+ if (aliases[lower]) return aliases[lower];
272
+ for (const candidate of Object.keys(STYLE_SPEC)) {
273
+ if (candidate.toLowerCase() === lower) return candidate;
274
+ }
275
+ return null;
276
+ }
277
+ function warnStyle(key, platform) {
278
+ if (NON_STYLE_PROPS.has(key) || key.startsWith("on") || key.startsWith("aria-")) return;
279
+ const spec = STYLE_SPEC[key];
280
+ let message = null;
281
+ if (!spec) {
282
+ const suggestion = closestStyleProp(key);
283
+ message = suggestion ? `[Orvyn style] Unknown style "${key}". Did you mean "${suggestion}"?` : `[Orvyn style] Unknown style "${key}". Check LANGUAGE.md for supported style props.`;
284
+ } else if (platform === "native" && spec.support === "web") {
285
+ message = spec.note ? `[Orvyn style] "${key}" is web-only (${spec.note}).` : `[Orvyn style] "${key}" is currently web-only and is ignored on iOS/Android.`;
286
+ }
287
+ if (!message) return;
288
+ const dedupeKey = `${platform}:${key}:${message}`;
289
+ if (emittedWarnings.has(dedupeKey)) return;
290
+ emittedWarnings.add(dedupeKey);
291
+ if (warningHandler) warningHandler(message);
292
+ else console.warn(message);
293
+ }
294
+ export {
295
+ NON_STYLE_PROPS,
296
+ STYLE_SPEC,
297
+ autoButtonColor,
298
+ clearStyleWarnings,
299
+ resetTheme,
300
+ resolveFontFamily,
301
+ resolveThemeToken,
302
+ setStyleWarningHandler,
303
+ subscribeTheme,
304
+ theme,
305
+ warnStyle
306
+ };
@@ -1,19 +0,0 @@
1
- const contextStore = /* @__PURE__ */ new Map();
2
- function createContext(defaultValue) {
3
- const id = /* @__PURE__ */ Symbol();
4
- contextStore.set(id, defaultValue);
5
- return {
6
- id,
7
- Provider(props) {
8
- contextStore.set(id, props.value);
9
- return props.children;
10
- }
11
- };
12
- }
13
- function useContext(context) {
14
- return contextStore.get(context.id);
15
- }
16
- export {
17
- createContext,
18
- useContext
19
- };
@@ -1,8 +0,0 @@
1
- function onMount(fn) {
2
- queueMicrotask(() => {
3
- fn();
4
- });
5
- }
6
- export {
7
- onMount
8
- };
@@ -1,27 +0,0 @@
1
- import { signal } from "./signal.js";
2
- function resource(fetcher) {
3
- const data = signal(null);
4
- const loading = signal(true);
5
- const error = signal(null);
6
- async function load() {
7
- loading.set(true);
8
- error.set(null);
9
- try {
10
- const result = await fetcher();
11
- data.set(result);
12
- } catch (err) {
13
- error.set(err);
14
- }
15
- loading.set(false);
16
- }
17
- load();
18
- return {
19
- data,
20
- loading,
21
- error,
22
- reload: load
23
- };
24
- }
25
- export {
26
- resource
27
- };
@@ -1,20 +0,0 @@
1
- import { signal } from "./signal.js";
2
- const currentRoute = signal(
3
- window.location.pathname
4
- );
5
- function navigate(path) {
6
- history.pushState({}, "", path);
7
- currentRoute.set(path);
8
- }
9
- window.addEventListener(
10
- "popstate",
11
- () => {
12
- currentRoute.set(
13
- window.location.pathname
14
- );
15
- }
16
- );
17
- export {
18
- currentRoute,
19
- navigate
20
- };
package/src/core/theme.js DELETED
@@ -1,10 +0,0 @@
1
- import { signal } from "./signal.js";
2
- const theme = signal({
3
- bg: "#000000",
4
- text: "#ffffff",
5
- primary: "#2563eb",
6
- card: "#111111"
7
- });
8
- export {
9
- theme
10
- };
@@ -1,214 +0,0 @@
1
- import {
2
- getDeviceProfiles,
3
- getPlatform,
4
- setPlatform,
5
- subscribePlatform
6
- } from "../../runtime/platform.js";
7
- let installed = false;
8
- const labels = {
9
- desktop: "Desktop",
10
- tablet: "Tablet",
11
- iphone: "iPhone",
12
- android: "Android"
13
- };
14
- function ensureStyles() {
15
- if (document.querySelector("#orvyn-device-preview-styles")) {
16
- return;
17
- }
18
- const style = document.createElement("style");
19
- style.id = "orvyn-device-preview-styles";
20
- style.textContent = `
21
- .orvyn-device-preview-shell {
22
- min-height: 100vh;
23
- padding: 72px 24px 32px;
24
- background: #eef2f7;
25
- box-sizing: border-box;
26
- }
27
-
28
- .orvyn-device-preview-toolbar,
29
- .orvyn-device-preview-panel {
30
- position: fixed;
31
- z-index: 99998;
32
- background: rgba(15, 23, 42, 0.92);
33
- color: white;
34
- border: 1px solid rgba(255,255,255,0.12);
35
- box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
36
- backdrop-filter: blur(12px);
37
- font: 12px system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
38
- }
39
-
40
- .orvyn-device-preview-toolbar {
41
- top: 16px;
42
- left: 50%;
43
- display: flex;
44
- gap: 6px;
45
- padding: 6px;
46
- border-radius: 8px;
47
- transform: translateX(-50%);
48
- }
49
-
50
- .orvyn-device-preview-button {
51
- min-width: 76px;
52
- border: 0;
53
- border-radius: 6px;
54
- padding: 8px 10px;
55
- color: white;
56
- background: transparent;
57
- cursor: pointer;
58
- font: inherit;
59
- }
60
-
61
- .orvyn-device-preview-button[data-active="true"] {
62
- background: white;
63
- color: #0f172a;
64
- }
65
-
66
- .orvyn-device-preview-panel {
67
- right: 16px;
68
- bottom: 16px;
69
- display: grid;
70
- gap: 4px;
71
- min-width: 168px;
72
- padding: 10px 12px;
73
- border-radius: 8px;
74
- }
75
-
76
- .orvyn-device-preview-stage {
77
- display: grid;
78
- justify-items: center;
79
- min-height: calc(100vh - 120px);
80
- overflow: auto;
81
- }
82
-
83
- .orvyn-device-preview-frame {
84
- position: relative;
85
- width: var(--orvyn-preview-width);
86
- height: var(--orvyn-preview-height);
87
- max-width: calc(100vw - 48px);
88
- background: white;
89
- border: 1px solid rgba(15, 23, 42, 0.14);
90
- border-radius: var(--orvyn-preview-radius);
91
- box-shadow: 0 30px 80px rgba(15, 23, 42, 0.18);
92
- overflow: hidden;
93
- transition: width 180ms ease, height 180ms ease, border-radius 180ms ease;
94
- }
95
-
96
- .orvyn-device-preview-viewport {
97
- width: 100%;
98
- height: 100%;
99
- overflow: auto;
100
- background: white;
101
- box-sizing: border-box;
102
- padding: var(--orvyn-safe-area-top) var(--orvyn-safe-area-right) var(--orvyn-safe-area-bottom) var(--orvyn-safe-area-left);
103
- }
104
-
105
- .orvyn-device-preview-notch {
106
- position: absolute;
107
- top: 10px;
108
- left: 50%;
109
- width: 126px;
110
- height: 28px;
111
- border-radius: 0 0 18px 18px;
112
- background: #020617;
113
- transform: translateX(-50%);
114
- display: none;
115
- z-index: 2;
116
- }
117
-
118
- .orvyn-device-preview-frame[data-platform="iphone"] .orvyn-device-preview-notch {
119
- display: block;
120
- }
121
- `;
122
- document.head.appendChild(style);
123
- }
124
- function resolveRoot(root) {
125
- if (typeof root === "string") {
126
- const found = document.querySelector(root);
127
- if (found) return found;
128
- }
129
- if (root instanceof HTMLElement) {
130
- return root;
131
- }
132
- return document.querySelector("#app") || document.body;
133
- }
134
- function frameRadius(platform) {
135
- if (platform === "iphone") return "42px";
136
- if (platform === "android") return "30px";
137
- if (platform === "tablet") return "22px";
138
- return "10px";
139
- }
140
- function installDevicePreview(root) {
141
- if (installed || typeof document === "undefined") {
142
- return;
143
- }
144
- installed = true;
145
- ensureStyles();
146
- const appRoot = resolveRoot(root);
147
- const shell = document.createElement("div");
148
- shell.className = "orvyn-device-preview-shell";
149
- const stage = document.createElement("div");
150
- stage.className = "orvyn-device-preview-stage";
151
- const frame = document.createElement("div");
152
- frame.className = "orvyn-device-preview-frame";
153
- const notch = document.createElement("div");
154
- notch.className = "orvyn-device-preview-notch";
155
- const viewport = document.createElement("div");
156
- viewport.className = "orvyn-device-preview-viewport";
157
- const parent = appRoot.parentElement;
158
- if (parent) {
159
- parent.insertBefore(shell, appRoot);
160
- } else {
161
- document.body.appendChild(shell);
162
- }
163
- viewport.appendChild(appRoot);
164
- frame.appendChild(notch);
165
- frame.appendChild(viewport);
166
- stage.appendChild(frame);
167
- shell.appendChild(stage);
168
- const toolbar = document.createElement("div");
169
- toolbar.className = "orvyn-device-preview-toolbar";
170
- const buttons = /* @__PURE__ */ new Map();
171
- Object.keys(getDeviceProfiles()).forEach((platform) => {
172
- const button = document.createElement("button");
173
- button.className = "orvyn-device-preview-button";
174
- button.type = "button";
175
- button.textContent = labels[platform];
176
- button.addEventListener("click", () => {
177
- setPlatform(platform);
178
- });
179
- buttons.set(platform, button);
180
- toolbar.appendChild(button);
181
- });
182
- const panel = document.createElement("div");
183
- panel.className = "orvyn-device-preview-panel";
184
- document.body.appendChild(toolbar);
185
- document.body.appendChild(panel);
186
- subscribePlatform((profile) => {
187
- frame.dataset.platform = profile.platform;
188
- frame.style.setProperty(
189
- "--orvyn-preview-width",
190
- `${profile.width}px`
191
- );
192
- frame.style.setProperty(
193
- "--orvyn-preview-height",
194
- `${profile.height}px`
195
- );
196
- frame.style.setProperty(
197
- "--orvyn-preview-radius",
198
- frameRadius(profile.platform)
199
- );
200
- buttons.forEach((button, platform) => {
201
- button.dataset.active = String(platform === profile.platform);
202
- });
203
- panel.innerHTML = `
204
- <div>Current Platform: ${labels[profile.platform]}</div>
205
- <div>Current Renderer: ${profile.renderer}</div>
206
- <div>Current Width: ${profile.width}px</div>
207
- <div>Current Height: ${profile.height}px</div>
208
- `;
209
- });
210
- setPlatform(getPlatform());
211
- }
212
- export {
213
- installDevicePreview
214
- };
@@ -1,6 +0,0 @@
1
- import {
2
- installDevicePreview
3
- } from "./PreviewFrame.js";
4
- export {
5
- installDevicePreview
6
- };