@orunelle/theme-runtime 0.0.0-stage → 2.0.0-alpha.13
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/dist/application.d.ts +7 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +58 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +429 -0
- package/dist/commerce.d.ts +235 -0
- package/dist/commerce.d.ts.map +1 -0
- package/dist/commerce.js +316 -0
- package/dist/credentials.d.ts +11 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +79 -0
- package/dist/fixtures.d.ts +23 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +131 -0
- package/dist/host/package.json +1 -0
- package/dist/host/preview/editor.css +116 -0
- package/dist/host/preview/editor.tsx +193 -0
- package/dist/host/preview/src/bridge.tsx +371 -0
- package/dist/host/preview/src/client.tsx +15 -0
- package/dist/host/preview/src/env.d.ts +5 -0
- package/dist/host/preview/src/preview.css +40 -0
- package/dist/host/preview/src/server.tsx +95 -0
- package/dist/host/preview/src/surface.tsx +264 -0
- package/dist/host/serve-node.mjs +133 -0
- package/dist/host/storefront/public/fonts/9da48a48bf6500f8-s.p.woff2 +0 -0
- package/dist/host/storefront/public/fonts/e4af272ccee01ff0-s.p.woff2 +0 -0
- package/dist/host/storefront/public/fonts/e4efb0298547fad0-s.p.woff2 +0 -0
- package/dist/host/storefront/public/fonts/f022b1629605b85c-s.p.woff2 +0 -0
- package/dist/host/storefront/public/fonts/fb66eb17bf011c3b-s.p.woff2 +0 -0
- package/dist/host/storefront/public/fonts.css +7 -0
- package/dist/host/storefront/public/samples/pouch-navy.svg +4 -0
- package/dist/host/storefront/public/samples/throw-oat.svg +2 -0
- package/dist/host/storefront/public/samples/throw-sage.svg +2 -0
- package/dist/host/storefront/public/samples/tote-charcoal.svg +5 -0
- package/dist/host/storefront/public/samples/tote-detail.svg +1 -0
- package/dist/host/storefront/public/samples/tote-sand.svg +5 -0
- package/dist/host/storefront/src/binding.server.ts +1 -0
- package/dist/host/storefront/src/data.ts +2 -0
- package/dist/host/storefront/src/env.d.ts +5 -0
- package/dist/host/storefront/src/queries.ts +1 -0
- package/dist/host/storefront/src/routeTree.gen.ts +155 -0
- package/dist/host/storefront/src/router.tsx +31 -0
- package/dist/host/storefront/src/routes/$locale.$.tsx +135 -0
- package/dist/host/storefront/src/routes/$locale.index.tsx +19 -0
- package/dist/host/storefront/src/routes/$locale.products.$handle.tsx +57 -0
- package/dist/host/storefront/src/routes/$locale.tsx +36 -0
- package/dist/host/storefront/src/routes/__root.tsx +103 -0
- package/dist/host/storefront/src/routes/index.tsx +6 -0
- package/dist/host/storefront/src/server.ts +1 -0
- package/dist/host.d.ts +45 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +380 -0
- package/dist/local-editor.d.ts +2 -0
- package/dist/local-editor.d.ts.map +1 -0
- package/dist/local-editor.js +111 -0
- package/dist/managed-worker.d.ts +2 -0
- package/dist/managed-worker.d.ts.map +1 -0
- package/dist/managed-worker.js +22 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +98 -0
- package/dist/source.d.ts +19 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +131 -0
- package/dist/tanstack/binding.server.d.ts +4 -0
- package/dist/tanstack/binding.server.d.ts.map +1 -0
- package/dist/tanstack/binding.server.js +9 -0
- package/dist/tanstack/data.d.ts +44 -0
- package/dist/tanstack/data.d.ts.map +1 -0
- package/dist/tanstack/data.js +320 -0
- package/dist/tanstack/index.d.ts +4 -0
- package/dist/tanstack/index.d.ts.map +1 -0
- package/dist/tanstack/index.js +2 -0
- package/dist/tanstack/queries.d.ts +6 -0
- package/dist/tanstack/queries.d.ts.map +1 -0
- package/dist/tanstack/queries.js +5 -0
- package/dist/template/app/client.tsx +3 -0
- package/dist/template/app/env.d.ts +1 -0
- package/dist/template/app/router.tsx +40 -0
- package/dist/template/app/routes/$locale.$.tsx +135 -0
- package/dist/template/app/routes/$locale.index.tsx +19 -0
- package/dist/template/app/routes/$locale.products.$handle.tsx +57 -0
- package/dist/template/app/routes/$locale.tsx +46 -0
- package/dist/template/app/routes/__root.tsx +103 -0
- package/dist/template/app/routes/index.tsx +6 -0
- package/dist/template/app/server.ts +1 -0
- package/dist/template/app/start.ts +2 -0
- package/dist/template/app/theme.ts +12 -0
- package/dist/template/tests/router-isolation.test.ts +14 -0
- package/dist/template/vite.config.ts +5 -0
- package/dist/template/vitest.config.ts +9 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +22 -0
- package/package.json +88 -3
- package/README.md +0 -3
package/dist/fixtures.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** Local proof bindings only. Production tenant resolution belongs to Go. */
|
|
2
|
+
const stores = {
|
|
3
|
+
"127.0.0.1": {
|
|
4
|
+
id: "fixture-studio",
|
|
5
|
+
slug: "studio",
|
|
6
|
+
name: { en: "Orunelle Studio", ar: "أورونيل ستوديو" },
|
|
7
|
+
mode: "public",
|
|
8
|
+
},
|
|
9
|
+
localhost: {
|
|
10
|
+
id: "fixture-atelier",
|
|
11
|
+
slug: "atelier",
|
|
12
|
+
name: { en: "Orunelle Atelier", ar: "أورونيل أتيليه" },
|
|
13
|
+
mode: "public",
|
|
14
|
+
},
|
|
15
|
+
"preview.localhost": {
|
|
16
|
+
id: "fixture-studio",
|
|
17
|
+
slug: "studio",
|
|
18
|
+
name: { en: "Orunelle Studio", ar: "أورونيل ستوديو" },
|
|
19
|
+
mode: "preview",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export function resolveFixtureContext(request, previewToken) {
|
|
23
|
+
const url = new URL(request.url);
|
|
24
|
+
if (!Object.hasOwn(stores, url.hostname))
|
|
25
|
+
return null;
|
|
26
|
+
const store = stores[url.hostname];
|
|
27
|
+
if (store.mode === "preview" &&
|
|
28
|
+
(!previewToken ||
|
|
29
|
+
request.headers.get("authorization") !== `Bearer ${previewToken}`))
|
|
30
|
+
return null;
|
|
31
|
+
return {
|
|
32
|
+
store: { id: store.id, slug: store.slug, name: { ...store.name } },
|
|
33
|
+
origin: url.origin,
|
|
34
|
+
locale: "en",
|
|
35
|
+
mode: store.mode,
|
|
36
|
+
release: "fixture-release-v2-1",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const sampleImages = {
|
|
40
|
+
"everyday-tote": [
|
|
41
|
+
{ url: "/samples/tote-sand.svg", alt: "Sand tote", variantId: "sand-m" },
|
|
42
|
+
{
|
|
43
|
+
url: "/samples/tote-charcoal.svg",
|
|
44
|
+
alt: "Charcoal tote",
|
|
45
|
+
variantId: "charcoal-m",
|
|
46
|
+
},
|
|
47
|
+
{ url: "/samples/tote-detail.svg", alt: "Woven canvas detail" },
|
|
48
|
+
],
|
|
49
|
+
"cotton-throw": [
|
|
50
|
+
{
|
|
51
|
+
url: "/samples/throw-oat.svg",
|
|
52
|
+
alt: "Oat throw",
|
|
53
|
+
variantId: "oat-single",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
url: "/samples/throw-sage.svg",
|
|
57
|
+
alt: "Sage throw",
|
|
58
|
+
variantId: "sage-single",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
"canvas-pouch": [{ url: "/samples/pouch-navy.svg", alt: "Navy pouch" }],
|
|
62
|
+
};
|
|
63
|
+
export function fixtureProducts(context) {
|
|
64
|
+
// Create fresh values. Neither runtime stores a mutable current tenant/catalog.
|
|
65
|
+
const prefix = context.store.id === "fixture-atelier" ? "atelier" : "studio";
|
|
66
|
+
const items = prefix === "atelier"
|
|
67
|
+
? [
|
|
68
|
+
["linen-notebook", "Linen notebook", "دفتر كتان", 18000, 0],
|
|
69
|
+
["paper-set", "Paper set", "مجموعة ورق", 24000, 0],
|
|
70
|
+
]
|
|
71
|
+
: [
|
|
72
|
+
["everyday-tote", "Everyday tote", "حقيبة يومية", 32000, 40000],
|
|
73
|
+
["cotton-throw", "Cotton throw", "غطاء قطني", 45000, 0],
|
|
74
|
+
["canvas-pouch", "Canvas pouch", "حقيبة قماش صغيرة", 16000, 0],
|
|
75
|
+
];
|
|
76
|
+
return items.map(([handle, en, ar, amountMinor, compareAt]) => {
|
|
77
|
+
const id = `${prefix}-${handle}`;
|
|
78
|
+
const images = (sampleImages[handle] ?? []).map(({ variantId, ...image }) => variantId ? { ...image, variantId: `${id}-${variantId}` } : image);
|
|
79
|
+
return {
|
|
80
|
+
id,
|
|
81
|
+
handle,
|
|
82
|
+
name: { en, ar },
|
|
83
|
+
description: {
|
|
84
|
+
en: `${en} is sample catalog content for ${context.store.name.en}.\n\nMade from durable natural materials and finished by hand.`,
|
|
85
|
+
ar: `${ar} من بيانات المنتجات التجريبية في ${context.store.name.ar}.\n\nمصنوع من خامات طبيعية متينة ومُشطَّب يدويًا.`,
|
|
86
|
+
},
|
|
87
|
+
price: { amountMinor, currency: "EGP" },
|
|
88
|
+
...(compareAt
|
|
89
|
+
? { compareAtPrice: { amountMinor: compareAt, currency: "EGP" } }
|
|
90
|
+
: {}),
|
|
91
|
+
...(images[0] ? { image: images[0], images } : {}),
|
|
92
|
+
categoryId: `${prefix}-everyday`,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** Sample variants with colors, sizes and one sold-out combination. */
|
|
97
|
+
export function fixtureVariants(product) {
|
|
98
|
+
const variant = (key, options, stock) => ({
|
|
99
|
+
id: `${product.id}-${key}`,
|
|
100
|
+
productId: product.id,
|
|
101
|
+
sku: `${product.handle}-${key}`.toUpperCase(),
|
|
102
|
+
size: "",
|
|
103
|
+
color: "",
|
|
104
|
+
options,
|
|
105
|
+
priceOverrideMinor: null,
|
|
106
|
+
availableQuantity: stock,
|
|
107
|
+
isActive: true,
|
|
108
|
+
});
|
|
109
|
+
if (product.handle === "everyday-tote")
|
|
110
|
+
return [
|
|
111
|
+
variant("sand-m", { Color: "Sand", Size: "M" }, 12),
|
|
112
|
+
variant("sand-l", { Color: "Sand", Size: "L" }, 3),
|
|
113
|
+
variant("charcoal-m", { Color: "Charcoal", Size: "M" }, 6),
|
|
114
|
+
variant("charcoal-l", { Color: "Charcoal", Size: "L" }, 0),
|
|
115
|
+
];
|
|
116
|
+
if (product.handle === "cotton-throw")
|
|
117
|
+
return [
|
|
118
|
+
variant("oat-single", { Color: "Oat", Size: "Single" }, 8),
|
|
119
|
+
variant("oat-double", { Color: "Oat", Size: "Double" }, 2),
|
|
120
|
+
variant("sage-single", { Color: "Sage", Size: "Single" }, 5),
|
|
121
|
+
];
|
|
122
|
+
return [variant("default", {}, 20)];
|
|
123
|
+
}
|
|
124
|
+
export const fixtureOptionVisuals = {
|
|
125
|
+
Color: {
|
|
126
|
+
Sand: { color: "#d8c3a0" },
|
|
127
|
+
Charcoal: { color: "#3b3d42" },
|
|
128
|
+
Oat: { color: "#e3d6bf" },
|
|
129
|
+
Sage: { color: "#a9b8a0" },
|
|
130
|
+
},
|
|
131
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module","private":true}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
@import url("/fonts.css");
|
|
2
|
+
:root {
|
|
3
|
+
font-family: Inter, "IBM Plex Sans Arabic", system-ui, sans-serif;
|
|
4
|
+
color: #262523;
|
|
5
|
+
background: #f7f7f5;
|
|
6
|
+
}
|
|
7
|
+
body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
}
|
|
10
|
+
main {
|
|
11
|
+
padding: 24px;
|
|
12
|
+
}
|
|
13
|
+
header,
|
|
14
|
+
nav {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 20px;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
margin-bottom: 20px;
|
|
20
|
+
}
|
|
21
|
+
h1 {
|
|
22
|
+
font-size: 24px;
|
|
23
|
+
margin: 0 0 8px;
|
|
24
|
+
}
|
|
25
|
+
h2 {
|
|
26
|
+
font-size: 18px;
|
|
27
|
+
}
|
|
28
|
+
p {
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
color: #5d5c57;
|
|
31
|
+
}
|
|
32
|
+
a {
|
|
33
|
+
color: #175c47;
|
|
34
|
+
}
|
|
35
|
+
button,
|
|
36
|
+
select {
|
|
37
|
+
border: 1px solid #c7c9c2;
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
background: white;
|
|
40
|
+
color: inherit;
|
|
41
|
+
padding: 10px;
|
|
42
|
+
font: inherit;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
button:hover {
|
|
46
|
+
background: #e7efe9;
|
|
47
|
+
}
|
|
48
|
+
button[aria-pressed="true"] {
|
|
49
|
+
background: #d6e9de;
|
|
50
|
+
}
|
|
51
|
+
button:focus-visible,
|
|
52
|
+
select:focus-visible,
|
|
53
|
+
textarea:focus-visible {
|
|
54
|
+
outline: 2px solid #175c47;
|
|
55
|
+
outline-offset: 3px;
|
|
56
|
+
}
|
|
57
|
+
label {
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: 6px;
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
}
|
|
62
|
+
.layout {
|
|
63
|
+
display: grid;
|
|
64
|
+
grid-template-columns: 340px minmax(0, 1fr);
|
|
65
|
+
gap: 20px;
|
|
66
|
+
}
|
|
67
|
+
aside {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 8px;
|
|
71
|
+
min-width: 0;
|
|
72
|
+
}
|
|
73
|
+
aside button {
|
|
74
|
+
text-align: start;
|
|
75
|
+
overflow-wrap: anywhere;
|
|
76
|
+
}
|
|
77
|
+
textarea {
|
|
78
|
+
font: 12px/1.5 monospace;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
min-height: 320px;
|
|
81
|
+
max-width: 100%;
|
|
82
|
+
resize: vertical;
|
|
83
|
+
border: 1px solid #b7bbb4;
|
|
84
|
+
border-radius: 8px;
|
|
85
|
+
padding: 12px;
|
|
86
|
+
}
|
|
87
|
+
iframe {
|
|
88
|
+
border: 1px solid #d8dbd4;
|
|
89
|
+
border-radius: 10px;
|
|
90
|
+
background: white;
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 78vh;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
}
|
|
95
|
+
nav {
|
|
96
|
+
justify-content: start;
|
|
97
|
+
flex-wrap: wrap;
|
|
98
|
+
}
|
|
99
|
+
@media (max-width: 700px) {
|
|
100
|
+
main {
|
|
101
|
+
padding: 14px;
|
|
102
|
+
}
|
|
103
|
+
header {
|
|
104
|
+
align-items: start;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
}
|
|
107
|
+
.layout {
|
|
108
|
+
grid-template-columns: 1fr;
|
|
109
|
+
}
|
|
110
|
+
iframe {
|
|
111
|
+
height: 65vh;
|
|
112
|
+
}
|
|
113
|
+
textarea {
|
|
114
|
+
min-height: 180px;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { validateConfiguration } from "@orunelle/theme-contract";
|
|
4
|
+
import {
|
|
5
|
+
connectEditorFrame,
|
|
6
|
+
type EditorFrameConnection,
|
|
7
|
+
} from "@orunelle/theme-editor";
|
|
8
|
+
import bootstrap from "./bootstrap.json";
|
|
9
|
+
import "./editor.css";
|
|
10
|
+
|
|
11
|
+
// This development inspector uses the same opaque-frame protocol as the
|
|
12
|
+
// merchant editor. It exports defaults; it has no merchant write authority.
|
|
13
|
+
function LocalEditor() {
|
|
14
|
+
const frame = useRef<HTMLIFrameElement>(null),
|
|
15
|
+
connection = useRef<EditorFrameConnection | null>(null);
|
|
16
|
+
const storageKey = `orunelle:local-author-draft:${bootstrap.identity.sessionId}`;
|
|
17
|
+
const [configuration, setConfiguration] = useState(() => {
|
|
18
|
+
try {
|
|
19
|
+
const raw = sessionStorage.getItem(storageKey);
|
|
20
|
+
if (raw) {
|
|
21
|
+
const value = JSON.parse(raw);
|
|
22
|
+
if (
|
|
23
|
+
!validateConfiguration(
|
|
24
|
+
bootstrap.manifest,
|
|
25
|
+
value,
|
|
26
|
+
bootstrap.identity.installationId,
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
return value as typeof bootstrap.configuration;
|
|
30
|
+
}
|
|
31
|
+
} catch {}
|
|
32
|
+
return bootstrap.configuration;
|
|
33
|
+
}),
|
|
34
|
+
[text, setText] = useState(() => JSON.stringify(configuration, null, 2)),
|
|
35
|
+
[error, setError] = useState(""),
|
|
36
|
+
[status, setStatus] = useState("connecting"),
|
|
37
|
+
[selected, setSelected] = useState<string | null>(null),
|
|
38
|
+
[locale, setLocale] = useState<"en" | "ar">("en"),
|
|
39
|
+
[template, setTemplate] = useState(
|
|
40
|
+
Object.keys(bootstrap.manifest.editor?.templates ?? {})[0] ?? "home",
|
|
41
|
+
);
|
|
42
|
+
const sequence = useRef(0),
|
|
43
|
+
snapshot = useRef({ configuration, locale, template });
|
|
44
|
+
snapshot.current = { configuration, locale, template };
|
|
45
|
+
const send = () => {
|
|
46
|
+
const s = snapshot.current;
|
|
47
|
+
connection.current?.send(
|
|
48
|
+
{
|
|
49
|
+
type: "snapshot",
|
|
50
|
+
configuration: s.configuration,
|
|
51
|
+
view: { locale: s.locale, template: s.template, path: `/${s.locale}` },
|
|
52
|
+
inspect: true,
|
|
53
|
+
},
|
|
54
|
+
++sequence.current,
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
connection.current = connectEditorFrame(
|
|
59
|
+
frame.current!,
|
|
60
|
+
bootstrap.identity as never,
|
|
61
|
+
(message) => {
|
|
62
|
+
if (message.type === "ready") {
|
|
63
|
+
setStatus("live");
|
|
64
|
+
send();
|
|
65
|
+
}
|
|
66
|
+
if (message.type === "select") setSelected(message.nodeId);
|
|
67
|
+
if (message.type === "error") setError(message.code);
|
|
68
|
+
},
|
|
69
|
+
setStatus,
|
|
70
|
+
);
|
|
71
|
+
return () => connection.current?.close();
|
|
72
|
+
}, []);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
try {
|
|
75
|
+
sessionStorage.setItem(storageKey, JSON.stringify(configuration));
|
|
76
|
+
} catch {
|
|
77
|
+
setError(
|
|
78
|
+
"Local recovery storage is unavailable. Download defaults.json to retain your changes.",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
send();
|
|
82
|
+
}, [configuration, locale, template]);
|
|
83
|
+
function apply() {
|
|
84
|
+
try {
|
|
85
|
+
const next = JSON.parse(text);
|
|
86
|
+
const issue = validateConfiguration(
|
|
87
|
+
bootstrap.manifest,
|
|
88
|
+
next,
|
|
89
|
+
bootstrap.identity.installationId,
|
|
90
|
+
);
|
|
91
|
+
if (issue) throw new Error(`${issue.code}: ${issue.path}`);
|
|
92
|
+
setConfiguration(next);
|
|
93
|
+
setError("");
|
|
94
|
+
} catch (e) {
|
|
95
|
+
setError(e instanceof Error ? e.message : "Invalid configuration");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function download() {
|
|
99
|
+
const { installationId, ...defaults } = configuration;
|
|
100
|
+
const url = URL.createObjectURL(
|
|
101
|
+
new Blob([JSON.stringify(defaults, null, 2) + "\n"], {
|
|
102
|
+
type: "application/json",
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
const a = document.createElement("a");
|
|
106
|
+
a.href = url;
|
|
107
|
+
a.download = "defaults.json";
|
|
108
|
+
a.click();
|
|
109
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
110
|
+
}
|
|
111
|
+
return (
|
|
112
|
+
<main>
|
|
113
|
+
<header>
|
|
114
|
+
<div>
|
|
115
|
+
<h1>Local composition editor</h1>
|
|
116
|
+
<p>
|
|
117
|
+
Sample shopping only. Session expires in five minutes; restart the
|
|
118
|
+
command to reconnect.
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
<a href={`http://127.0.0.1:${Number(location.port) - 1}/en`}>
|
|
122
|
+
Open storefront
|
|
123
|
+
</a>
|
|
124
|
+
</header>
|
|
125
|
+
<nav aria-label="Preview options">
|
|
126
|
+
<label>
|
|
127
|
+
Language
|
|
128
|
+
<select
|
|
129
|
+
value={locale}
|
|
130
|
+
onChange={(e) => setLocale(e.target.value as "en" | "ar")}
|
|
131
|
+
>
|
|
132
|
+
<option value="en">English</option>
|
|
133
|
+
<option value="ar">العربية</option>
|
|
134
|
+
</select>
|
|
135
|
+
</label>
|
|
136
|
+
<label>
|
|
137
|
+
Template
|
|
138
|
+
<select
|
|
139
|
+
value={template}
|
|
140
|
+
onChange={(e) => setTemplate(e.target.value)}
|
|
141
|
+
>
|
|
142
|
+
{Object.keys(
|
|
143
|
+
bootstrap.manifest.editor?.templates ?? { home: {} },
|
|
144
|
+
).map((name) => (
|
|
145
|
+
<option key={name}>{name}</option>
|
|
146
|
+
))}
|
|
147
|
+
</select>
|
|
148
|
+
</label>
|
|
149
|
+
<span role="status">{status}</span>
|
|
150
|
+
<button onClick={download}>Download defaults.json</button>
|
|
151
|
+
</nav>
|
|
152
|
+
<div className="layout">
|
|
153
|
+
<aside>
|
|
154
|
+
<h2>Structure</h2>
|
|
155
|
+
{Object.values(configuration.nodes).map((node) => (
|
|
156
|
+
<button
|
|
157
|
+
key={node.id}
|
|
158
|
+
aria-pressed={selected === node.id}
|
|
159
|
+
onClick={() => {
|
|
160
|
+
setSelected(node.id);
|
|
161
|
+
connection.current?.send(
|
|
162
|
+
{ type: "selection", nodeId: node.id, scroll: true },
|
|
163
|
+
sequence.current,
|
|
164
|
+
);
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
{node.type} · {node.id}
|
|
168
|
+
</button>
|
|
169
|
+
))}
|
|
170
|
+
<p>Selected: {selected ?? "none"}</p>
|
|
171
|
+
<label>
|
|
172
|
+
Configuration JSON
|
|
173
|
+
<textarea
|
|
174
|
+
aria-label="Configuration JSON"
|
|
175
|
+
value={text}
|
|
176
|
+
onChange={(e) => setText(e.target.value)}
|
|
177
|
+
spellCheck={false}
|
|
178
|
+
/>
|
|
179
|
+
</label>
|
|
180
|
+
<button onClick={apply}>Apply to preview</button>
|
|
181
|
+
{error && <p role="alert">{error}</p>}
|
|
182
|
+
</aside>
|
|
183
|
+
<iframe
|
|
184
|
+
ref={frame}
|
|
185
|
+
title="Author theme preview"
|
|
186
|
+
sandbox="allow-scripts"
|
|
187
|
+
src="/frame"
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
</main>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
createRoot(document.getElementById("root")!).render(<LocalEditor />);
|