okno 1.0.0-beta.19 → 1.0.0-beta.21
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/bake.d.ts +19 -0
- package/dist/bake.d.ts.map +1 -0
- package/dist/dispatch-CmTJLIKc.js +930 -0
- package/dist/editor/index.js +2884 -2767
- package/dist/engine/index.js +183 -0
- package/dist/index.js +1 -1
- package/dist/next/config.d.ts.map +1 -1
- package/dist/next/index.js +37 -39
- package/dist/{plugin-jvqdZWC0.js → plugin-DcdYJY8n.js} +143 -176
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/dispatch-DKZB5I61.js +0 -1054
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { extname as
|
|
2
|
-
import { existsSync as O, readFileSync as U, mkdirSync as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import { extname as z, join as h, dirname as T, relative as N, sep as D, resolve as g } from "node:path";
|
|
2
|
+
import { existsSync as O, readFileSync as U, mkdirSync as M, writeFileSync as B, cpSync as Y } from "node:fs";
|
|
3
|
+
import { fileURLToPath as Q } from "node:url";
|
|
4
|
+
import { k as Z, g as x, s as E, b as q, a as tt, c as et, e as ot, d as nt, f as it, j as P, l as $, m as rt, h as st, i as at } from "./dispatch-CmTJLIKc.js";
|
|
5
|
+
import { simpleGit as R } from "simple-git";
|
|
6
|
+
import "node:child_process";
|
|
7
7
|
import "./acorn-CZBJD705.js";
|
|
8
|
-
function F(n,
|
|
9
|
-
n.statusCode =
|
|
8
|
+
function F(n, r, e) {
|
|
9
|
+
n.statusCode = r, n.setHeader("Content-Type", "application/json"), n.setHeader("Cache-Control", "no-store"), n.end(JSON.stringify(e));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return new Promise((
|
|
11
|
+
function lt(n) {
|
|
12
|
+
return new Promise((r) => {
|
|
13
13
|
let e = "";
|
|
14
14
|
n.on("data", (t) => e += t), n.on("end", () => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
r(e ? JSON.parse(e) : {});
|
|
17
17
|
} catch {
|
|
18
|
-
|
|
18
|
+
r({});
|
|
19
19
|
}
|
|
20
|
-
}), n.on("error", () =>
|
|
20
|
+
}), n.on("error", () => r({}));
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return new Promise((
|
|
23
|
+
function ct(n) {
|
|
24
|
+
return new Promise((r, e) => {
|
|
25
25
|
const t = [];
|
|
26
|
-
n.on("data", (c) => t.push(c)), n.on("end", () =>
|
|
26
|
+
n.on("data", (c) => t.push(c)), n.on("end", () => r(Buffer.concat(t))), n.on("error", e);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
if (
|
|
31
|
-
for (const e of new Set(
|
|
29
|
+
function ut(n, r) {
|
|
30
|
+
if (r) {
|
|
31
|
+
for (const e of new Set(r.modules)) {
|
|
32
32
|
const t = n.moduleGraph.getModuleById("\0okno:" + e);
|
|
33
33
|
t && n.moduleGraph.invalidateModule(t);
|
|
34
34
|
}
|
|
35
|
-
for (const e of new Set(
|
|
35
|
+
for (const e of new Set(r.files))
|
|
36
36
|
n.moduleGraph.getModulesByFile(e)?.forEach((t) => n.moduleGraph.invalidateModule(t));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function dt(n, r) {
|
|
40
40
|
n.middlewares.use(async (e, t, c) => {
|
|
41
41
|
if (!e.url?.startsWith("/__okno/api/")) return c();
|
|
42
42
|
const y = e.url.slice(12).split("?")[0], o = {
|
|
43
43
|
method: e.method || "GET",
|
|
44
44
|
route: y,
|
|
45
|
-
json: () =>
|
|
46
|
-
binary: () =>
|
|
47
|
-
header: (
|
|
48
|
-
const s = e.headers[
|
|
45
|
+
json: () => lt(e),
|
|
46
|
+
binary: () => ct(e),
|
|
47
|
+
header: (i) => {
|
|
48
|
+
const s = e.headers[i];
|
|
49
49
|
return Array.isArray(s) ? s[0] : s;
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
|
|
56
|
-
} catch (
|
|
57
|
-
F(t, 500, { error:
|
|
53
|
+
const i = await Z(r, o);
|
|
54
|
+
if (!i) return c();
|
|
55
|
+
ut(n, i.invalidation), F(t, i.status, i.body);
|
|
56
|
+
} catch (i) {
|
|
57
|
+
F(t, 500, { error: i instanceof Error ? i.message : String(i) });
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function ft(n, r) {
|
|
62
62
|
let e;
|
|
63
63
|
try {
|
|
64
|
-
e = decodeURIComponent(
|
|
64
|
+
e = decodeURIComponent(r);
|
|
65
65
|
} catch {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
if (!e || e.includes("\0")) return null;
|
|
69
69
|
const t = g(n, "files"), c = g(t, e);
|
|
70
|
-
return c === t || !c.startsWith(t +
|
|
70
|
+
return c === t || !c.startsWith(t + D) ? null : c;
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const H = "okno", pt = {
|
|
73
73
|
".webp": "image/webp",
|
|
74
74
|
".png": "image/png",
|
|
75
75
|
".jpg": "image/jpeg",
|
|
@@ -90,18 +90,18 @@ const B = "okno", ft = {
|
|
|
90
90
|
".ttf": "font/ttf",
|
|
91
91
|
".otf": "font/otf"
|
|
92
92
|
};
|
|
93
|
-
function
|
|
94
|
-
|
|
93
|
+
function gt(n, r) {
|
|
94
|
+
dt(n, r), n.middlewares.use((e, t, c) => {
|
|
95
95
|
if (e.method !== "GET" || !e.url?.startsWith("/okno/files/")) return c();
|
|
96
96
|
const y = e.url.slice(12).split("?")[0];
|
|
97
97
|
if (!y) return c();
|
|
98
|
-
const o =
|
|
98
|
+
const o = ft(r, y);
|
|
99
99
|
if (!o)
|
|
100
100
|
return t.statusCode = 403, t.end("Forbidden");
|
|
101
101
|
if (!O(o))
|
|
102
102
|
return t.statusCode = 404, t.end("Not found");
|
|
103
|
-
const
|
|
104
|
-
t.setHeader("Content-Type",
|
|
103
|
+
const i = z(o).toLowerCase();
|
|
104
|
+
t.setHeader("Content-Type", pt[i] || "application/octet-stream"), t.setHeader("Cache-Control", "public, max-age=3600"), t.end(U(o));
|
|
105
105
|
}), n.middlewares.use(async (e, t, c) => {
|
|
106
106
|
if (!e.url?.startsWith("/__okno/")) return c();
|
|
107
107
|
const y = e.url.slice(8);
|
|
@@ -110,51 +110,51 @@ function pt(n, i) {
|
|
|
110
110
|
if (e.method === "GET" && y === "repo") {
|
|
111
111
|
t.setHeader("Content-Type", "application/json");
|
|
112
112
|
try {
|
|
113
|
-
const o =
|
|
113
|
+
const o = R(n.config.root), i = (await o.remote(["get-url", "origin"]))?.toString().trim(), s = (await o.revparse(["--abbrev-ref", "HEAD"])).trim(), { owner: f, repo: a } = mt(i);
|
|
114
114
|
return t.end(
|
|
115
|
-
JSON.stringify({ ok: !0, owner: f, repo: a, branch: s || null, remote:
|
|
115
|
+
JSON.stringify({ ok: !0, owner: f, repo: a, branch: s || null, remote: i || null })
|
|
116
116
|
);
|
|
117
117
|
} catch (o) {
|
|
118
118
|
return t.end(JSON.stringify({ ok: !1, error: String(o) }));
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
if (e.method === "POST" && y.startsWith("mirror")) {
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
122
|
+
const i = new URL(e.url, "http://localhost").searchParams.get("path");
|
|
123
|
+
if (!i || i.includes("..") || !i.startsWith("files/"))
|
|
124
124
|
return t.statusCode = 400, t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ error: "Invalid path" }));
|
|
125
|
-
const s = h(
|
|
125
|
+
const s = h(r, i);
|
|
126
126
|
if (O(s))
|
|
127
127
|
return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, skipped: !0 }));
|
|
128
|
-
const f = await
|
|
129
|
-
return
|
|
128
|
+
const f = await ht(e);
|
|
129
|
+
return M(T(s), { recursive: !0 }), B(s, f), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, written: i, bytes: f.length }));
|
|
130
130
|
}
|
|
131
131
|
if (e.method === "POST" && y === "sync") {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
if (
|
|
132
|
+
const i = (await yt(e))?.path;
|
|
133
|
+
if (i) {
|
|
134
|
+
if (i.includes("..") || i.includes("\0"))
|
|
135
135
|
return t.statusCode = 400, t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ error: "Invalid path" }));
|
|
136
|
-
const u = h(
|
|
136
|
+
const u = h(r, i);
|
|
137
137
|
try {
|
|
138
|
-
const l =
|
|
139
|
-
await l.fetch("origin",
|
|
140
|
-
const m = (await l.revparse(["--show-toplevel"])).trim(), p = N(m, u).split(
|
|
141
|
-
|
|
138
|
+
const l = R(r);
|
|
139
|
+
await l.fetch("origin", H);
|
|
140
|
+
const m = (await l.revparse(["--show-toplevel"])).trim(), p = N(m, u).split(D).join("/"), w = await l.show([`origin/${H}:${p}`]);
|
|
141
|
+
M(T(u), { recursive: !0 }), B(u, w);
|
|
142
142
|
} catch (l) {
|
|
143
143
|
const m = l instanceof Error ? l.message : String(l);
|
|
144
144
|
console.warn(
|
|
145
|
-
`[okno] sync: could not materialize ${
|
|
145
|
+
`[okno] sync: could not materialize ${i} from origin/${H} — ${m.split(`
|
|
146
146
|
`)[0]}`
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
|
-
return
|
|
149
|
+
return A(n, i, u), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, invalidated: i }));
|
|
150
150
|
}
|
|
151
|
-
const s =
|
|
151
|
+
const s = R(r), f = await s.revparse(["--show-toplevel"]), a = N(f.trim(), r);
|
|
152
152
|
try {
|
|
153
153
|
const u = await s.pull();
|
|
154
154
|
for (const l of u.files)
|
|
155
155
|
if (l.startsWith(`${a}/`)) {
|
|
156
|
-
const m = l.slice(`${a}/`.length), p = h(
|
|
157
|
-
|
|
156
|
+
const m = l.slice(`${a}/`.length), p = h(r, m);
|
|
157
|
+
A(n, m, p);
|
|
158
158
|
}
|
|
159
159
|
return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, files: u.files }));
|
|
160
160
|
} catch (u) {
|
|
@@ -169,55 +169,55 @@ function pt(n, i) {
|
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function mt(n) {
|
|
173
173
|
if (!n) return { owner: null, repo: null };
|
|
174
|
-
const
|
|
175
|
-
return
|
|
174
|
+
const r = n.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
175
|
+
return r ? { owner: r[1], repo: r[2] } : { owner: null, repo: null };
|
|
176
176
|
}
|
|
177
|
-
function
|
|
178
|
-
return new Promise((
|
|
177
|
+
function ht(n) {
|
|
178
|
+
return new Promise((r, e) => {
|
|
179
179
|
const t = [];
|
|
180
|
-
n.on("data", (c) => t.push(c)), n.on("end", () =>
|
|
180
|
+
n.on("data", (c) => t.push(c)), n.on("end", () => r(Buffer.concat(t))), n.on("error", e);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
return new Promise((
|
|
183
|
+
function yt(n) {
|
|
184
|
+
return new Promise((r) => {
|
|
185
185
|
let e = "";
|
|
186
186
|
n.on("data", (t) => {
|
|
187
187
|
e += t;
|
|
188
188
|
}), n.on("end", () => {
|
|
189
189
|
try {
|
|
190
|
-
|
|
190
|
+
r(e ? JSON.parse(e) : null);
|
|
191
191
|
} catch {
|
|
192
|
-
|
|
192
|
+
r(null);
|
|
193
193
|
}
|
|
194
|
-
}), n.on("error", () =>
|
|
194
|
+
}), n.on("error", () => r(null));
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function A(n, r, e) {
|
|
198
198
|
const t = "\0okno:";
|
|
199
199
|
let c;
|
|
200
|
-
if (
|
|
200
|
+
if (r.startsWith("pages/") ? c = t + "pages" : r.startsWith("collections/") ? c = t + "collections" : r.startsWith("globals/") && (c = t + "globals"), c) {
|
|
201
201
|
const y = n.moduleGraph.getModuleById(c);
|
|
202
202
|
y && n.moduleGraph.invalidateModule(y);
|
|
203
203
|
const o = n.moduleGraph.getModulesByFile(e);
|
|
204
|
-
o && o.forEach((
|
|
205
|
-
n.moduleGraph.invalidateModule(
|
|
204
|
+
o && o.forEach((i) => {
|
|
205
|
+
n.moduleGraph.invalidateModule(i);
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const e = (n.split("?")[0] ?? "").replace(/\\/g, "/"), t =
|
|
209
|
+
function wt(n, r) {
|
|
210
|
+
const e = (n.split("?")[0] ?? "").replace(/\\/g, "/"), t = r.replace(/\\/g, "/");
|
|
211
211
|
return e === t || e.startsWith(t + "/");
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
for (const [e, t] of Object.entries(
|
|
213
|
+
function bt(n, r) {
|
|
214
|
+
for (const [e, t] of Object.entries(r)) {
|
|
215
215
|
if (n === e) return t;
|
|
216
216
|
if (n.startsWith(e + "/")) return t + n.slice(e.length);
|
|
217
217
|
}
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const St = "okno:", _ = "\0okno:", _t = /* @__PURE__ */ new Set(["pages", "collections", "globals", "locales", "strings", "content"]), K = T(Q(import.meta.url)), Ot = JSON.parse(U(g(K, "../package.json"), "utf-8")).version, L = x(), b = g(K, "../editor"), I = g(b, "index.ts"), kt = O(I), vt = {
|
|
221
221
|
"@modules": g(b, "modules"),
|
|
222
222
|
"@lib": g(b, "lib"),
|
|
223
223
|
"@logger": g(b, "lib/logger.svelte.ts"),
|
|
@@ -229,51 +229,18 @@ const bt = "okno:", S = "\0okno:", _t = /* @__PURE__ */ new Set(["pages", "colle
|
|
|
229
229
|
"@pages": g(b, "pages"),
|
|
230
230
|
"@controllers": g(b, "controllers")
|
|
231
231
|
};
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
const n = (t) => K(t, { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim(), e = n("git remote get-url origin").match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
235
|
-
return e ? `${e[1]}/${e[2]}@${vt(n)}` : null;
|
|
236
|
-
} catch {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function vt(n) {
|
|
241
|
-
let i = "";
|
|
242
|
-
try {
|
|
243
|
-
i = n("git rev-parse --abbrev-ref HEAD");
|
|
244
|
-
} catch {
|
|
245
|
-
}
|
|
246
|
-
if (i && i !== "HEAD") return i;
|
|
247
|
-
const e = process.env;
|
|
248
|
-
return e.CF_PAGES_BRANCH || // Cloudflare Pages
|
|
249
|
-
e.VERCEL_GIT_COMMIT_REF || // Vercel
|
|
250
|
-
e.BRANCH || // Netlify
|
|
251
|
-
e.GITHUB_REF_NAME || // GitHub Actions
|
|
252
|
-
"main";
|
|
253
|
-
}
|
|
254
|
-
function Nt() {
|
|
255
|
-
try {
|
|
256
|
-
const n = K("git rev-parse --show-toplevel", {
|
|
257
|
-
encoding: "utf-8",
|
|
258
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
259
|
-
}).trim();
|
|
260
|
-
return N(n, process.cwd()).split(G).join("/");
|
|
261
|
-
} catch {
|
|
262
|
-
return "";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function It(n = {}) {
|
|
266
|
-
const i = n.dir ?? "okno";
|
|
232
|
+
function Tt(n = {}) {
|
|
233
|
+
const r = n.dir ?? "okno";
|
|
267
234
|
let e, t, c = !1, y = !1;
|
|
268
235
|
return n.isEditor, {
|
|
269
236
|
name: "okno",
|
|
270
237
|
enforce: "pre",
|
|
271
|
-
config(o,
|
|
272
|
-
const s =
|
|
273
|
-
return y =
|
|
238
|
+
config(o, i) {
|
|
239
|
+
const s = i.command === "serve";
|
|
240
|
+
return y = i.command === "build", c = s && kt, {
|
|
274
241
|
define: {
|
|
275
242
|
__OKNO_API_URL__: JSON.stringify(n.apiUrl ?? "https://api.okno.build"),
|
|
276
|
-
__OKNO_VERSION__: JSON.stringify(
|
|
243
|
+
__OKNO_VERSION__: JSON.stringify(Ot),
|
|
277
244
|
// True when the consumer is running `vite dev` / `astro dev` /
|
|
278
245
|
// `sveltekit dev` — anything that serves locally. Replaced at
|
|
279
246
|
// consumer build time so the prebuilt editor bundle can honor
|
|
@@ -287,12 +254,12 @@ function It(n = {}) {
|
|
|
287
254
|
// auto-targets its repo with no picker. null outside a git
|
|
288
255
|
// checkout → editor falls back to the picker. Dev ignores it
|
|
289
256
|
// (runtime /__okno/repo derivation is more current).
|
|
290
|
-
__OKNO_REPO__: JSON.stringify(
|
|
257
|
+
__OKNO_REPO__: JSON.stringify(at()),
|
|
291
258
|
// Monorepo root path: the build dir relative to the git root (e.g.
|
|
292
259
|
// "apps/site", or "" at the repo root). Sent as X-Okno-Path so the
|
|
293
260
|
// hosted backend reads/writes content under `<root>/okno` instead of
|
|
294
261
|
// the repo-root `okno` — one repo, many okno projects keyed (repo, path).
|
|
295
|
-
__OKNO_ROOT__: JSON.stringify(
|
|
262
|
+
__OKNO_ROOT__: JSON.stringify(st())
|
|
296
263
|
},
|
|
297
264
|
// Source mode (monorepo dev only): skip prebundling so saves to
|
|
298
265
|
// `package/editor/**` propagate via HMR instead of needing
|
|
@@ -314,7 +281,7 @@ function It(n = {}) {
|
|
|
314
281
|
// the backend mirrored saves to disk, causing spurious full
|
|
315
282
|
// reloads. In production-mode the backend never touches local
|
|
316
283
|
// FS so blocking those is pure harm — pulls go unseen.)
|
|
317
|
-
ignored: [`**/${
|
|
284
|
+
ignored: [`**/${r}/files/**`, `**/${r}/.okno-tree.json`]
|
|
318
285
|
},
|
|
319
286
|
// Source mode: the editor loads via a dynamic `import("okno/editor")`
|
|
320
287
|
// from a separate package over `@fs`, so Vite's startup dep scan
|
|
@@ -330,15 +297,15 @@ function It(n = {}) {
|
|
|
330
297
|
};
|
|
331
298
|
},
|
|
332
299
|
configResolved(o) {
|
|
333
|
-
e = o.root, t = g(e,
|
|
300
|
+
e = o.root, t = g(e, r);
|
|
334
301
|
},
|
|
335
302
|
async buildStart() {
|
|
336
303
|
if (O(t)) {
|
|
337
|
-
if (await
|
|
304
|
+
if (await P(t, e), y) {
|
|
338
305
|
const o = h(t, "files");
|
|
339
306
|
if (O(o)) {
|
|
340
|
-
const
|
|
341
|
-
g(s) !== g(o) && (
|
|
307
|
+
const i = O(h(e, "static")) ? h(e, "static") : h(e, "public"), s = h(i, "okno", "files");
|
|
308
|
+
g(s) !== g(o) && (M(s, { recursive: !0 }), Y(o, s, {
|
|
342
309
|
recursive: !0,
|
|
343
310
|
filter: (f) => !f.endsWith(".okno-tree.json")
|
|
344
311
|
}));
|
|
@@ -346,30 +313,30 @@ function It(n = {}) {
|
|
|
346
313
|
}
|
|
347
314
|
if (n.demo) {
|
|
348
315
|
const o = h(e, "public");
|
|
349
|
-
O(o) ||
|
|
316
|
+
O(o) || M(o, { recursive: !0 }), B(
|
|
350
317
|
h(o, "okno-demo.json"),
|
|
351
|
-
JSON.stringify(
|
|
318
|
+
JSON.stringify(rt(t))
|
|
352
319
|
);
|
|
353
320
|
}
|
|
354
321
|
}
|
|
355
322
|
},
|
|
356
323
|
configureServer(o) {
|
|
357
|
-
|
|
358
|
-
const
|
|
324
|
+
gt(o, t);
|
|
325
|
+
const i = (f) => {
|
|
359
326
|
const a = N(t, f);
|
|
360
327
|
if (a.startsWith("..") || !a.endsWith(".ts")) return;
|
|
361
328
|
const u = a.split(/[\\/]/)[0];
|
|
362
329
|
if (u !== "pages" && u !== "collections" && u !== "globals") return;
|
|
363
|
-
const l = o.moduleGraph.getModuleById(
|
|
330
|
+
const l = o.moduleGraph.getModuleById(_ + u);
|
|
364
331
|
l && o.moduleGraph.invalidateModule(l), o.moduleGraph.getModulesByFile(f)?.forEach((m) => o.moduleGraph.invalidateModule(m)), !$(f) && o.ws.send({ type: "full-reload" });
|
|
365
332
|
};
|
|
366
|
-
o.watcher.on("add",
|
|
333
|
+
o.watcher.on("add", i), o.watcher.on("unlink", i), o.middlewares.use("/__okno/imports", async (f, a, u) => {
|
|
367
334
|
if (f.method !== "GET") return u();
|
|
368
335
|
try {
|
|
369
336
|
const [l, m, p] = await Promise.all([
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
337
|
+
E(e, "pages"),
|
|
338
|
+
E(e, "globals"),
|
|
339
|
+
E(e, "collections")
|
|
373
340
|
]);
|
|
374
341
|
a.setHeader("Content-Type", "application/json"), a.setHeader("Cache-Control", "no-store"), a.end(JSON.stringify({
|
|
375
342
|
pages: Array.from(l),
|
|
@@ -395,31 +362,31 @@ function It(n = {}) {
|
|
|
395
362
|
}), o.middlewares.use((f, a, u) => {
|
|
396
363
|
const l = "<script>window.__oknoDev=true<\/script>", m = n.demo ? "<script>window.__oknoDemo=true<\/script>" : "", p = `${l}${m}<script type="module" src="${s}"><\/script>`, w = [];
|
|
397
364
|
let k = null;
|
|
398
|
-
const
|
|
365
|
+
const V = a.write.bind(a), j = a.end.bind(a), X = a.setHeader.bind(a), G = () => {
|
|
399
366
|
const d = a.getHeader("content-type");
|
|
400
367
|
return typeof d == "string" && d.includes("text/html");
|
|
401
|
-
},
|
|
402
|
-
a.write = (d,
|
|
403
|
-
if (k === null && (k =
|
|
404
|
-
d && w.push(
|
|
405
|
-
let
|
|
406
|
-
|
|
407
|
-
const
|
|
368
|
+
}, W = (d, S) => Buffer.isBuffer(d) ? d : d instanceof Uint8Array ? Buffer.from(d.buffer, d.byteOffset, d.byteLength) : typeof d == "string" ? Buffer.from(d, S || "utf-8") : Buffer.from(String(d));
|
|
369
|
+
a.write = (d, S, ...C) => (k === null && (k = G()), k ? (d && w.push(W(d, typeof S == "string" ? S : void 0)), !0) : V(d, S, ...C)), a.end = (d, S, ...C) => {
|
|
370
|
+
if (k === null && (k = G()), !k) return j(d, S, ...C);
|
|
371
|
+
d && w.push(W(d, typeof S == "string" ? S : void 0));
|
|
372
|
+
let v = Buffer.concat(w).toString("utf-8");
|
|
373
|
+
v.includes(p) || (v = v.includes("</body>") ? v.replace("</body>", `${p}</body>`) : v + p);
|
|
374
|
+
const J = Buffer.from(v, "utf-8");
|
|
408
375
|
if (!a.headersSent)
|
|
409
376
|
try {
|
|
410
|
-
|
|
377
|
+
X("content-length", String(J.length));
|
|
411
378
|
} catch {
|
|
412
379
|
}
|
|
413
|
-
return j(
|
|
380
|
+
return j(J, ...C);
|
|
414
381
|
}, u();
|
|
415
382
|
});
|
|
416
383
|
},
|
|
417
384
|
async handleHotUpdate(o) {
|
|
418
|
-
const
|
|
419
|
-
if (o.file ===
|
|
420
|
-
await
|
|
385
|
+
const i = h(t, "schema.ts"), s = h(t, "users.json"), f = h(t, "permissions.ts"), a = h(t, "modules.d.ts");
|
|
386
|
+
if (o.file === i) {
|
|
387
|
+
await P(t, e);
|
|
421
388
|
for (const p of ["pages", "collections", "globals", "locales", "content", "strings"]) {
|
|
422
|
-
const w = o.server.moduleGraph.getModuleById(
|
|
389
|
+
const w = o.server.moduleGraph.getModuleById(_ + p);
|
|
423
390
|
w && o.server.moduleGraph.invalidateModule(w);
|
|
424
391
|
}
|
|
425
392
|
return [];
|
|
@@ -428,9 +395,9 @@ function It(n = {}) {
|
|
|
428
395
|
return [];
|
|
429
396
|
const u = h(t, "strings.ts"), l = N(h(t, "strings"), o.file);
|
|
430
397
|
if (o.file === u || !l.startsWith("..") && l.endsWith(".ts")) {
|
|
431
|
-
await
|
|
398
|
+
await P(t, e);
|
|
432
399
|
for (const p of ["strings", "content"]) {
|
|
433
|
-
const w = o.server.moduleGraph.getModuleById(
|
|
400
|
+
const w = o.server.moduleGraph.getModuleById(_ + p);
|
|
434
401
|
w && o.server.moduleGraph.invalidateModule(w);
|
|
435
402
|
}
|
|
436
403
|
}
|
|
@@ -438,57 +405,57 @@ function It(n = {}) {
|
|
|
438
405
|
if (!m.startsWith("..") && m.endsWith(".ts")) {
|
|
439
406
|
const p = m.split(/[\\/]/)[0];
|
|
440
407
|
if ((p === "pages" || p === "collections" || p === "globals") && $(o.file)) {
|
|
441
|
-
const w = o.server.moduleGraph.getModuleById(
|
|
408
|
+
const w = o.server.moduleGraph.getModuleById(_ + p);
|
|
442
409
|
return w && o.server.moduleGraph.invalidateModule(w), [];
|
|
443
410
|
}
|
|
444
411
|
}
|
|
445
412
|
},
|
|
446
|
-
async resolveId(o,
|
|
447
|
-
if (o.startsWith(
|
|
413
|
+
async resolveId(o, i) {
|
|
414
|
+
if (o.startsWith(St))
|
|
448
415
|
return "\0" + o;
|
|
449
416
|
if (o.startsWith("okno/")) {
|
|
450
417
|
const s = o.slice(5);
|
|
451
|
-
if (_t.has(s)) return
|
|
418
|
+
if (_t.has(s)) return _ + s;
|
|
452
419
|
}
|
|
453
420
|
if (c && o === "okno/editor")
|
|
454
421
|
return I;
|
|
455
|
-
if (c &&
|
|
456
|
-
const s =
|
|
422
|
+
if (c && i && wt(i, b)) {
|
|
423
|
+
const s = bt(o, vt);
|
|
457
424
|
if (s)
|
|
458
|
-
return (await this.resolve(s,
|
|
425
|
+
return (await this.resolve(s, i, { skipSelf: !0 }))?.id;
|
|
459
426
|
}
|
|
460
427
|
},
|
|
461
428
|
async load(o) {
|
|
462
|
-
if (!o.startsWith(
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
429
|
+
if (!o.startsWith(_)) return;
|
|
430
|
+
const i = o.slice(_.length);
|
|
431
|
+
if (i === "runtime") {
|
|
465
432
|
if (!L)
|
|
466
433
|
throw new Error("okno: runtime/wrap.js missing — run `bun run build:pkg`");
|
|
467
434
|
return L;
|
|
468
435
|
}
|
|
469
|
-
if (
|
|
436
|
+
if (i === "bootstrap")
|
|
470
437
|
return 'import("okno/editor")';
|
|
471
|
-
if (
|
|
472
|
-
const s = await
|
|
473
|
-
return await
|
|
438
|
+
if (i === "pages") {
|
|
439
|
+
const s = await E(e, "pages");
|
|
440
|
+
return await q(t, s);
|
|
474
441
|
}
|
|
475
|
-
if (
|
|
476
|
-
const s = await
|
|
477
|
-
return await
|
|
442
|
+
if (i === "collections") {
|
|
443
|
+
const s = await E(e, "collections");
|
|
444
|
+
return await tt(t, s, y);
|
|
478
445
|
}
|
|
479
|
-
if (
|
|
480
|
-
const s = await
|
|
481
|
-
return await
|
|
446
|
+
if (i === "globals") {
|
|
447
|
+
const s = await E(e, "globals");
|
|
448
|
+
return await et(t, s);
|
|
482
449
|
}
|
|
483
|
-
if (
|
|
484
|
-
return
|
|
485
|
-
if (
|
|
486
|
-
return await
|
|
487
|
-
if (
|
|
450
|
+
if (i === "locales")
|
|
451
|
+
return ot(t);
|
|
452
|
+
if (i === "strings")
|
|
453
|
+
return await nt(t);
|
|
454
|
+
if (i === "content")
|
|
488
455
|
return it();
|
|
489
456
|
}
|
|
490
457
|
};
|
|
491
458
|
}
|
|
492
459
|
export {
|
|
493
|
-
|
|
460
|
+
Tt as o
|
|
494
461
|
};
|
package/dist/vite/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AA8DpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CAsZpD"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "okno",
|
|
3
3
|
"description": "Git-backed CMS with live editing for any Vite framework",
|
|
4
4
|
"author": "Gabriel Uhlíř",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.21",
|
|
6
6
|
"homepage": "https://okno.build",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"types": "./dist/editor/index.d.ts",
|
|
29
29
|
"default": "./dist/editor/index.js"
|
|
30
30
|
},
|
|
31
|
+
"./engine": {
|
|
32
|
+
"types": "./dist/engine/index.d.ts",
|
|
33
|
+
"default": "./dist/engine/index.js"
|
|
34
|
+
},
|
|
31
35
|
"./boot": {
|
|
32
36
|
"types": "./dist/boot.d.ts",
|
|
33
37
|
"default": "./dist/boot.js"
|