okno 1.0.0-beta.14 → 1.0.0-beta.16
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/index.js +1 -1
- package/dist/next/config.d.ts.map +1 -1
- package/dist/next/index.js +64 -53
- package/dist/{plugin-DmiwHDt_.js → plugin-DrRr35Ph.js} +125 -118
- package/dist/runtime/wrap.d.ts.map +1 -1
- package/dist/runtime/wrap.js +30 -28
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/runtime/wrap.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/next/config.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/next/config.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAapD,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IACvB;;+CAE2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAsBD;8EAC8E;AAC9E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAE,CAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,CAAC,CAuCrF"}
|
package/dist/next/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { join as
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { s as g, b as
|
|
4
|
-
import { mkdir as
|
|
5
|
-
const
|
|
1
|
+
import { join as c, relative as E, sep as w, resolve as h } from "node:path";
|
|
2
|
+
import { existsSync as k, watch as M, mkdirSync as A, cpSync as C } from "node:fs";
|
|
3
|
+
import { s as g, b as R, a as N, c as P, d as F, e as I, g as L, I as T, f as $, h as B, i as D } from "../dispatch-C34WXMSB.js";
|
|
4
|
+
import { mkdir as G, writeFile as u } from "node:fs/promises";
|
|
5
|
+
const U = (o) => o.replaceAll(T, "__oknoSetImages(undefined)"), x = (o) => {
|
|
6
6
|
let n = o;
|
|
7
|
-
for (const [t, e] of Object.entries(
|
|
7
|
+
for (const [t, e] of Object.entries(J))
|
|
8
8
|
n = n.replaceAll(`"${t}"`, `"./${e}"`).replaceAll(`'${t}'`, `'./${e}'`);
|
|
9
9
|
return n;
|
|
10
|
-
},
|
|
10
|
+
}, z = (o, n, t) => {
|
|
11
11
|
const e = E(t, n).split(w).join("/");
|
|
12
12
|
return o.replaceAll(n.split(w).join("/"), e);
|
|
13
|
-
},
|
|
13
|
+
}, J = {
|
|
14
14
|
"okno:pages": "pages.js",
|
|
15
15
|
"okno:collections": "collections.js",
|
|
16
16
|
"okno:globals": "globals.js",
|
|
@@ -19,66 +19,77 @@ const G = (o) => o.replaceAll(I, "__oknoSetImages(undefined)"), U = (o) => {
|
|
|
19
19
|
"okno:content": "content.js",
|
|
20
20
|
"okno:runtime": "runtime.js"
|
|
21
21
|
};
|
|
22
|
-
async function
|
|
23
|
-
const e =
|
|
24
|
-
await
|
|
25
|
-
const [s, r,
|
|
22
|
+
async function H(o, n, t = {}) {
|
|
23
|
+
const e = c(n, t.outDir ?? ".okno"), a = t.isBuild ?? process.env.NODE_ENV === "production";
|
|
24
|
+
await G(e, { recursive: !0 });
|
|
25
|
+
const [s, r, l] = await Promise.all([
|
|
26
26
|
g(n, "pages"),
|
|
27
27
|
g(n, "collections"),
|
|
28
28
|
g(n, "globals")
|
|
29
29
|
]), [i, p, f, m] = await Promise.all([
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]),
|
|
30
|
+
R(o, s),
|
|
31
|
+
N(o, r, a),
|
|
32
|
+
P(o, l),
|
|
33
|
+
F(o)
|
|
34
|
+
]), v = I(o), O = $(), S = L() ?? 'throw new Error("okno: runtime/wrap.js missing — run \\`bun run build:pkg\\`")', d = (_) => z(x(U(_)), o, e);
|
|
35
35
|
await Promise.all([
|
|
36
|
-
u(
|
|
37
|
-
u(
|
|
38
|
-
u(
|
|
39
|
-
u(
|
|
40
|
-
u(
|
|
41
|
-
u(
|
|
42
|
-
u(
|
|
36
|
+
u(c(e, "pages.js"), d(i)),
|
|
37
|
+
u(c(e, "collections.js"), d(p)),
|
|
38
|
+
u(c(e, "globals.js"), d(f)),
|
|
39
|
+
u(c(e, "locales.js"), d(v)),
|
|
40
|
+
u(c(e, "strings.js"), d(m)),
|
|
41
|
+
u(c(e, "content.js"), d(O)),
|
|
42
|
+
u(c(e, "runtime.js"), S)
|
|
43
43
|
]);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function V(o, n) {
|
|
46
|
+
const t = c(o, "files");
|
|
47
|
+
if (!k(t)) return;
|
|
48
|
+
const e = c(n, "public", "okno", "files");
|
|
49
|
+
A(e, { recursive: !0 }), C(t, e, { recursive: !0, filter: (a) => !a.endsWith(".okno-tree.json") });
|
|
50
|
+
}
|
|
51
|
+
function K(o, n) {
|
|
46
52
|
const t = { source: "/__okno/api/:path*", destination: `/${n}/:path*` };
|
|
47
53
|
return async () => {
|
|
48
54
|
const e = typeof o == "function" ? await o() : void 0;
|
|
49
55
|
return e ? Array.isArray(e) ? [t, ...e] : { ...e, beforeFiles: [t, ...e.beforeFiles ?? []] } : [t];
|
|
50
56
|
};
|
|
51
57
|
}
|
|
52
|
-
let
|
|
53
|
-
function
|
|
58
|
+
let y = !1;
|
|
59
|
+
function ee(o = {}, n = {}) {
|
|
54
60
|
const t = n.apiMount ?? "oknoapi", e = o, a = {
|
|
55
61
|
...e,
|
|
56
|
-
rewrites:
|
|
62
|
+
rewrites: K(e.rewrites, t)
|
|
57
63
|
};
|
|
58
|
-
if (!
|
|
59
|
-
|
|
60
|
-
const s = process.cwd(), r =
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
+
if (!y) {
|
|
65
|
+
y = !0;
|
|
66
|
+
const s = process.cwd(), r = h(s, n.dir ?? "okno");
|
|
67
|
+
if (k(r)) {
|
|
68
|
+
const l = () => {
|
|
69
|
+
B(r, s).catch((i) => console.warn("[okno] type codegen failed:", i)), H(r, s).catch((i) => console.warn("[okno] module codegen failed:", i));
|
|
70
|
+
try {
|
|
71
|
+
V(r, s);
|
|
72
|
+
} catch (i) {
|
|
73
|
+
console.warn("[okno] media copy failed:", i);
|
|
74
|
+
}
|
|
64
75
|
};
|
|
65
|
-
if (
|
|
76
|
+
if (l(), process.env.NODE_ENV !== "production")
|
|
66
77
|
try {
|
|
67
|
-
|
|
78
|
+
M(r, { recursive: !0 }, () => l());
|
|
68
79
|
} catch {
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
}
|
|
72
83
|
return a;
|
|
73
84
|
}
|
|
74
|
-
const
|
|
75
|
-
function
|
|
76
|
-
return
|
|
85
|
+
const b = { "Content-Type": "application/json", "Cache-Control": "no-store" };
|
|
86
|
+
function W(o) {
|
|
87
|
+
return h(o?.root ?? process.cwd(), o?.dir ?? "okno");
|
|
77
88
|
}
|
|
78
|
-
function
|
|
79
|
-
return new Response(JSON.stringify({ error: "Not found" }), { status: 404, headers:
|
|
89
|
+
function j() {
|
|
90
|
+
return new Response(JSON.stringify({ error: "Not found" }), { status: 404, headers: b });
|
|
80
91
|
}
|
|
81
|
-
async function
|
|
92
|
+
async function Q(o, n) {
|
|
82
93
|
const t = n?.params ? await n.params : void 0;
|
|
83
94
|
if (t) {
|
|
84
95
|
const s = t.okno ?? Object.values(t)[0];
|
|
@@ -88,17 +99,17 @@ async function V(o, n) {
|
|
|
88
99
|
const e = "/__okno/api/", a = new URL(o.url).pathname.indexOf(e);
|
|
89
100
|
return a === -1 ? null : new URL(o.url).pathname.slice(a + e.length);
|
|
90
101
|
}
|
|
91
|
-
function
|
|
92
|
-
const n =
|
|
93
|
-
const s = await
|
|
94
|
-
if (s == null) return
|
|
95
|
-
let r,
|
|
102
|
+
function oe(o) {
|
|
103
|
+
const n = W(o), t = async (e, a) => {
|
|
104
|
+
const s = await Q(e, a);
|
|
105
|
+
if (s == null) return j();
|
|
106
|
+
let r, l = !1, i;
|
|
96
107
|
const p = {
|
|
97
108
|
method: e.method,
|
|
98
109
|
route: s,
|
|
99
110
|
json: async () => {
|
|
100
|
-
if (!
|
|
101
|
-
|
|
111
|
+
if (!l) {
|
|
112
|
+
l = !0;
|
|
102
113
|
try {
|
|
103
114
|
r = await e.json();
|
|
104
115
|
} catch {
|
|
@@ -109,12 +120,12 @@ function Z(o) {
|
|
|
109
120
|
},
|
|
110
121
|
binary: async () => (i === void 0 && (i = Buffer.from(await e.arrayBuffer())), i),
|
|
111
122
|
header: (m) => e.headers.get(m) ?? void 0
|
|
112
|
-
}, f = await
|
|
113
|
-
return f ? new Response(JSON.stringify(f.body), { status: f.status, headers:
|
|
123
|
+
}, f = await D(n, p);
|
|
124
|
+
return f ? new Response(JSON.stringify(f.body), { status: f.status, headers: b }) : j();
|
|
114
125
|
};
|
|
115
126
|
return { GET: t, POST: t };
|
|
116
127
|
}
|
|
117
128
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
oe as createOknoRouteHandler,
|
|
130
|
+
ee as withOkno
|
|
120
131
|
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { extname as z, join as w, dirname as
|
|
2
|
-
import { existsSync as
|
|
1
|
+
import { extname as z, join as w, dirname as I, relative as N, sep as L, resolve as m } from "node:path";
|
|
2
|
+
import { existsSync as k, readFileSync as U, mkdirSync as M, writeFileSync as R, cpSync as Y } from "node:fs";
|
|
3
3
|
import { execSync as Q } from "node:child_process";
|
|
4
4
|
import { fileURLToPath as Z } from "node:url";
|
|
5
|
-
import { i as x, g as q, s as
|
|
6
|
-
import { simpleGit as
|
|
5
|
+
import { i as x, g as q, s as E, b as tt, a as et, c as ot, e as nt, d as it, f as rt, h as H, j as $, k as st } from "./dispatch-C34WXMSB.js";
|
|
6
|
+
import { simpleGit as P } from "simple-git";
|
|
7
7
|
import "./acorn-CZBJD705.js";
|
|
8
|
-
function A(n,
|
|
9
|
-
n.statusCode =
|
|
8
|
+
function A(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
11
|
function at(n) {
|
|
12
|
-
return new Promise((
|
|
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
23
|
function lt(n) {
|
|
24
|
-
return new Promise((
|
|
24
|
+
return new Promise((r, e) => {
|
|
25
25
|
const t = [];
|
|
26
|
-
n.on("data", (a) => t.push(a)), n.on("end", () =>
|
|
26
|
+
n.on("data", (a) => t.push(a)), n.on("end", () => r(Buffer.concat(t))), n.on("error", e);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function ct(n,
|
|
30
|
-
if (
|
|
31
|
-
for (const e of new Set(
|
|
29
|
+
function ct(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 ut(n,
|
|
39
|
+
function ut(n, r) {
|
|
40
40
|
n.middlewares.use(async (e, t, a) => {
|
|
41
41
|
if (!e.url?.startsWith("/__okno/api/")) return a();
|
|
42
42
|
const h = e.url.slice(12).split("?")[0], o = {
|
|
@@ -44,24 +44,24 @@ function ut(n, i) {
|
|
|
44
44
|
route: h,
|
|
45
45
|
json: () => at(e),
|
|
46
46
|
binary: () => lt(e),
|
|
47
|
-
header: (
|
|
48
|
-
const s = e.headers[
|
|
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
|
-
ct(n,
|
|
56
|
-
} catch (
|
|
57
|
-
A(t, 500, { error:
|
|
53
|
+
const i = await x(r, o);
|
|
54
|
+
if (!i) return a();
|
|
55
|
+
ct(n, i.invalidation), A(t, i.status, i.body);
|
|
56
|
+
} catch (i) {
|
|
57
|
+
A(t, 500, { error: i instanceof Error ? i.message : String(i) });
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
function dt(n,
|
|
61
|
+
function dt(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
|
}
|
|
@@ -69,7 +69,7 @@ function dt(n, i) {
|
|
|
69
69
|
const t = m(n, "files"), a = m(t, e);
|
|
70
70
|
return a === t || !a.startsWith(t + L) ? null : a;
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const B = "okno", ft = {
|
|
73
73
|
".webp": "image/webp",
|
|
74
74
|
".png": "image/png",
|
|
75
75
|
".jpg": "image/jpeg",
|
|
@@ -90,18 +90,18 @@ const P = "okno", ft = {
|
|
|
90
90
|
".ttf": "font/ttf",
|
|
91
91
|
".otf": "font/otf"
|
|
92
92
|
};
|
|
93
|
-
function pt(n,
|
|
94
|
-
ut(n,
|
|
93
|
+
function pt(n, r) {
|
|
94
|
+
ut(n, r), n.middlewares.use((e, t, a) => {
|
|
95
95
|
if (e.method !== "GET" || !e.url?.startsWith("/okno/files/")) return a();
|
|
96
96
|
const h = e.url.slice(12).split("?")[0];
|
|
97
97
|
if (!h) return a();
|
|
98
|
-
const o = dt(
|
|
98
|
+
const o = dt(r, h);
|
|
99
99
|
if (!o)
|
|
100
100
|
return t.statusCode = 403, t.end("Forbidden");
|
|
101
|
-
if (!
|
|
101
|
+
if (!k(o))
|
|
102
102
|
return t.statusCode = 404, t.end("Not found");
|
|
103
|
-
const
|
|
104
|
-
t.setHeader("Content-Type", ft[
|
|
103
|
+
const i = z(o).toLowerCase();
|
|
104
|
+
t.setHeader("Content-Type", ft[i] || "application/octet-stream"), t.setHeader("Cache-Control", "public, max-age=3600"), t.end(U(o));
|
|
105
105
|
}), n.middlewares.use(async (e, t, a) => {
|
|
106
106
|
if (!e.url?.startsWith("/__okno/")) return a();
|
|
107
107
|
const h = e.url.slice(8);
|
|
@@ -110,50 +110,50 @@ function pt(n, i) {
|
|
|
110
110
|
if (e.method === "GET" && h === "repo") {
|
|
111
111
|
t.setHeader("Content-Type", "application/json");
|
|
112
112
|
try {
|
|
113
|
-
const o =
|
|
113
|
+
const o = P(n.config.root), i = (await o.remote(["get-url", "origin"]))?.toString().trim(), s = (await o.revparse(["--abbrev-ref", "HEAD"])).trim(), { owner: p, repo: l } = gt(i);
|
|
114
114
|
return t.end(
|
|
115
|
-
JSON.stringify({ ok: !0, owner: p, repo: l, branch: s || null, remote:
|
|
115
|
+
JSON.stringify({ ok: !0, owner: p, repo: l, 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" && h.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 = w(
|
|
126
|
-
if (
|
|
125
|
+
const s = w(r, i);
|
|
126
|
+
if (k(s))
|
|
127
127
|
return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, skipped: !0 }));
|
|
128
128
|
const p = await mt(e);
|
|
129
|
-
return I(
|
|
129
|
+
return M(I(s), { recursive: !0 }), R(s, p), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, written: i, bytes: p.length }));
|
|
130
130
|
}
|
|
131
131
|
if (e.method === "POST" && h === "sync") {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
if (
|
|
132
|
+
const i = (await ht(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 = w(
|
|
136
|
+
const u = w(r, i);
|
|
137
137
|
try {
|
|
138
|
-
const c =
|
|
139
|
-
await c.fetch("origin",
|
|
140
|
-
const g = (await c.revparse(["--show-toplevel"])).trim(), f = N(g, u).split(L).join("/"), y = await c.show([`origin/${
|
|
141
|
-
I(
|
|
138
|
+
const c = P(r);
|
|
139
|
+
await c.fetch("origin", B);
|
|
140
|
+
const g = (await c.revparse(["--show-toplevel"])).trim(), f = N(g, u).split(L).join("/"), y = await c.show([`origin/${B}:${f}`]);
|
|
141
|
+
M(I(u), { recursive: !0 }), R(u, y);
|
|
142
142
|
} catch (c) {
|
|
143
143
|
const g = c instanceof Error ? c.message : String(c);
|
|
144
144
|
console.warn(
|
|
145
|
-
`[okno] sync: could not materialize ${
|
|
145
|
+
`[okno] sync: could not materialize ${i} from origin/${B} — ${g.split(`
|
|
146
146
|
`)[0]}`
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
|
-
return F(n,
|
|
149
|
+
return F(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 = P(r), p = await s.revparse(["--show-toplevel"]), l = N(p.trim(), r);
|
|
152
152
|
try {
|
|
153
153
|
const u = await s.pull();
|
|
154
154
|
for (const c of u.files)
|
|
155
155
|
if (c.startsWith(`${l}/`)) {
|
|
156
|
-
const g = c.slice(`${l}/`.length), f = w(
|
|
156
|
+
const g = c.slice(`${l}/`.length), f = w(r, g);
|
|
157
157
|
F(n, g, f);
|
|
158
158
|
}
|
|
159
159
|
return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, files: u.files }));
|
|
@@ -171,53 +171,53 @@ function pt(n, i) {
|
|
|
171
171
|
}
|
|
172
172
|
function gt(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
177
|
function mt(n) {
|
|
178
|
-
return new Promise((
|
|
178
|
+
return new Promise((r, e) => {
|
|
179
179
|
const t = [];
|
|
180
|
-
n.on("data", (a) => t.push(a)), n.on("end", () =>
|
|
180
|
+
n.on("data", (a) => t.push(a)), n.on("end", () => r(Buffer.concat(t))), n.on("error", e);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
function ht(n) {
|
|
184
|
-
return new Promise((
|
|
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 F(n,
|
|
197
|
+
function F(n, r, e) {
|
|
198
198
|
const t = "\0okno:";
|
|
199
199
|
let a;
|
|
200
|
-
if (
|
|
200
|
+
if (r.startsWith("pages/") ? a = t + "pages" : r.startsWith("collections/") ? a = t + "collections" : r.startsWith("globals/") && (a = t + "globals"), a) {
|
|
201
201
|
const h = n.moduleGraph.getModuleById(a);
|
|
202
202
|
h && n.moduleGraph.invalidateModule(h);
|
|
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 yt(n,
|
|
210
|
-
const e = (n.split("?")[0] ?? "").replace(/\\/g, "/"), t =
|
|
209
|
+
function yt(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 wt(n,
|
|
214
|
-
for (const [e, t] of Object.entries(
|
|
213
|
+
function wt(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 bt = "okno:", _ = "\0okno:", St = /* @__PURE__ */ new Set(["pages", "collections", "globals", "locales", "strings", "content"]), K =
|
|
220
|
+
const bt = "okno:", _ = "\0okno:", St = /* @__PURE__ */ new Set(["pages", "collections", "globals", "locales", "strings", "content"]), K = I(Z(import.meta.url)), _t = JSON.parse(U(m(K, "../package.json"), "utf-8")).version, D = q(), b = m(K, "../editor"), T = m(b, "index.ts"), kt = k(T), Ot = {
|
|
221
221
|
"@modules": m(b, "modules"),
|
|
222
222
|
"@lib": m(b, "lib"),
|
|
223
223
|
"@logger": m(b, "lib/logger.svelte.ts"),
|
|
@@ -240,14 +240,14 @@ function vt() {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
function It(n = {}) {
|
|
243
|
-
const
|
|
243
|
+
const r = n.dir ?? "okno";
|
|
244
244
|
let e, t, a = !1, h = !1;
|
|
245
245
|
return n.isEditor, {
|
|
246
246
|
name: "okno",
|
|
247
247
|
enforce: "pre",
|
|
248
|
-
config(o,
|
|
249
|
-
const s =
|
|
250
|
-
return h =
|
|
248
|
+
config(o, i) {
|
|
249
|
+
const s = i.command === "serve";
|
|
250
|
+
return h = i.command === "build", a = s && kt, {
|
|
251
251
|
define: {
|
|
252
252
|
__OKNO_API_URL__: JSON.stringify(n.apiUrl ?? "https://api.okno.build"),
|
|
253
253
|
__OKNO_VERSION__: JSON.stringify(_t),
|
|
@@ -286,7 +286,7 @@ function It(n = {}) {
|
|
|
286
286
|
// the backend mirrored saves to disk, causing spurious full
|
|
287
287
|
// reloads. In production-mode the backend never touches local
|
|
288
288
|
// FS so blocking those is pure harm — pulls go unseen.)
|
|
289
|
-
ignored: [`**/${
|
|
289
|
+
ignored: [`**/${r}/files/**`, `**/${r}/.okno-tree.json`]
|
|
290
290
|
},
|
|
291
291
|
// Source mode: the editor loads via a dynamic `import("okno/editor")`
|
|
292
292
|
// from a separate package over `@fs`, so Vite's startup dep scan
|
|
@@ -302,25 +302,32 @@ function It(n = {}) {
|
|
|
302
302
|
};
|
|
303
303
|
},
|
|
304
304
|
configResolved(o) {
|
|
305
|
-
e = o.root, t = m(e,
|
|
305
|
+
e = o.root, t = m(e, r);
|
|
306
306
|
},
|
|
307
307
|
async buildStart() {
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
308
|
+
if (k(t)) {
|
|
309
|
+
if (await H(t, e), h) {
|
|
310
|
+
const o = w(t, "files");
|
|
311
|
+
if (k(o)) {
|
|
312
|
+
const i = w(e, "public");
|
|
313
|
+
k(i) || M(i, { recursive: !0 }), Y(o, w(i, "okno", "files"), {
|
|
314
|
+
recursive: !0,
|
|
315
|
+
filter: (s) => !s.endsWith(".okno-tree.json")
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (n.demo) {
|
|
320
|
+
const o = w(e, "public");
|
|
321
|
+
k(o) || M(o, { recursive: !0 }), R(
|
|
322
|
+
w(o, "okno-demo.json"),
|
|
323
|
+
JSON.stringify(st(t))
|
|
324
|
+
);
|
|
325
|
+
}
|
|
319
326
|
}
|
|
320
327
|
},
|
|
321
328
|
configureServer(o) {
|
|
322
329
|
pt(o, t);
|
|
323
|
-
const
|
|
330
|
+
const i = (p) => {
|
|
324
331
|
const l = N(t, p);
|
|
325
332
|
if (l.startsWith("..") || !l.endsWith(".ts")) return;
|
|
326
333
|
const u = l.split(/[\\/]/)[0];
|
|
@@ -328,13 +335,13 @@ function It(n = {}) {
|
|
|
328
335
|
const c = o.moduleGraph.getModuleById(_ + u);
|
|
329
336
|
c && o.moduleGraph.invalidateModule(c), o.moduleGraph.getModulesByFile(p)?.forEach((g) => o.moduleGraph.invalidateModule(g)), !$(p) && o.ws.send({ type: "full-reload" });
|
|
330
337
|
};
|
|
331
|
-
o.watcher.on("add",
|
|
338
|
+
o.watcher.on("add", i), o.watcher.on("unlink", i), o.middlewares.use("/__okno/imports", async (p, l, u) => {
|
|
332
339
|
if (p.method !== "GET") return u();
|
|
333
340
|
try {
|
|
334
341
|
const [c, g, f] = await Promise.all([
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
342
|
+
E(e, "pages"),
|
|
343
|
+
E(e, "globals"),
|
|
344
|
+
E(e, "collections")
|
|
338
345
|
]);
|
|
339
346
|
l.setHeader("Content-Type", "application/json"), l.setHeader("Cache-Control", "no-store"), l.end(JSON.stringify({
|
|
340
347
|
pages: Array.from(c),
|
|
@@ -359,17 +366,17 @@ function It(n = {}) {
|
|
|
359
366
|
}
|
|
360
367
|
}), o.middlewares.use((p, l, u) => {
|
|
361
368
|
const c = "<script>window.__oknoDev=true<\/script>", g = n.demo ? "<script>window.__oknoDemo=true<\/script>" : "", f = `${c}${g}<script type="module" src="${s}"><\/script>`, y = [];
|
|
362
|
-
let
|
|
369
|
+
let O = null;
|
|
363
370
|
const V = l.write.bind(l), j = l.end.bind(l), X = l.setHeader.bind(l), G = () => {
|
|
364
371
|
const d = l.getHeader("content-type");
|
|
365
372
|
return typeof d == "string" && d.includes("text/html");
|
|
366
373
|
}, 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));
|
|
367
|
-
l.write = (d, S, ...C) => (
|
|
368
|
-
if (
|
|
374
|
+
l.write = (d, S, ...C) => (O === null && (O = G()), O ? (d && y.push(W(d, typeof S == "string" ? S : void 0)), !0) : V(d, S, ...C)), l.end = (d, S, ...C) => {
|
|
375
|
+
if (O === null && (O = G()), !O) return j(d, S, ...C);
|
|
369
376
|
d && y.push(W(d, typeof S == "string" ? S : void 0));
|
|
370
|
-
let
|
|
371
|
-
|
|
372
|
-
const J = Buffer.from(
|
|
377
|
+
let v = Buffer.concat(y).toString("utf-8");
|
|
378
|
+
v.includes(f) || (v = v.includes("</body>") ? v.replace("</body>", `${f}</body>`) : v + f);
|
|
379
|
+
const J = Buffer.from(v, "utf-8");
|
|
373
380
|
if (!l.headersSent)
|
|
374
381
|
try {
|
|
375
382
|
X("content-length", String(J.length));
|
|
@@ -380,9 +387,9 @@ function It(n = {}) {
|
|
|
380
387
|
});
|
|
381
388
|
},
|
|
382
389
|
async handleHotUpdate(o) {
|
|
383
|
-
const
|
|
384
|
-
if (o.file ===
|
|
385
|
-
await
|
|
390
|
+
const i = w(t, "schema.ts"), s = w(t, "users.json"), p = w(t, "permissions.ts"), l = w(t, "modules.d.ts");
|
|
391
|
+
if (o.file === i) {
|
|
392
|
+
await H(t, e);
|
|
386
393
|
for (const f of ["pages", "collections", "globals", "locales", "content", "strings"]) {
|
|
387
394
|
const y = o.server.moduleGraph.getModuleById(_ + f);
|
|
388
395
|
y && o.server.moduleGraph.invalidateModule(y);
|
|
@@ -393,7 +400,7 @@ function It(n = {}) {
|
|
|
393
400
|
return [];
|
|
394
401
|
const u = w(t, "strings.ts"), c = N(w(t, "strings"), o.file);
|
|
395
402
|
if (o.file === u || !c.startsWith("..") && c.endsWith(".ts")) {
|
|
396
|
-
await
|
|
403
|
+
await H(t, e);
|
|
397
404
|
for (const f of ["strings", "content"]) {
|
|
398
405
|
const y = o.server.moduleGraph.getModuleById(_ + f);
|
|
399
406
|
y && o.server.moduleGraph.invalidateModule(y);
|
|
@@ -408,7 +415,7 @@ function It(n = {}) {
|
|
|
408
415
|
}
|
|
409
416
|
}
|
|
410
417
|
},
|
|
411
|
-
async resolveId(o,
|
|
418
|
+
async resolveId(o, i) {
|
|
412
419
|
if (o.startsWith(bt))
|
|
413
420
|
return "\0" + o;
|
|
414
421
|
if (o.startsWith("okno/")) {
|
|
@@ -417,40 +424,40 @@ function It(n = {}) {
|
|
|
417
424
|
}
|
|
418
425
|
if (a && o === "okno/editor")
|
|
419
426
|
return T;
|
|
420
|
-
if (a &&
|
|
427
|
+
if (a && i && yt(i, b)) {
|
|
421
428
|
const s = wt(o, Ot);
|
|
422
429
|
if (s)
|
|
423
|
-
return (await this.resolve(s,
|
|
430
|
+
return (await this.resolve(s, i, { skipSelf: !0 }))?.id;
|
|
424
431
|
}
|
|
425
432
|
},
|
|
426
433
|
async load(o) {
|
|
427
434
|
if (!o.startsWith(_)) return;
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
435
|
+
const i = o.slice(_.length);
|
|
436
|
+
if (i === "runtime") {
|
|
430
437
|
if (!D)
|
|
431
438
|
throw new Error("okno: runtime/wrap.js missing — run `bun run build:pkg`");
|
|
432
439
|
return D;
|
|
433
440
|
}
|
|
434
|
-
if (
|
|
441
|
+
if (i === "bootstrap")
|
|
435
442
|
return 'import("okno/editor")';
|
|
436
|
-
if (
|
|
437
|
-
const s = await
|
|
443
|
+
if (i === "pages") {
|
|
444
|
+
const s = await E(e, "pages");
|
|
438
445
|
return await tt(t, s);
|
|
439
446
|
}
|
|
440
|
-
if (
|
|
441
|
-
const s = await
|
|
447
|
+
if (i === "collections") {
|
|
448
|
+
const s = await E(e, "collections");
|
|
442
449
|
return await et(t, s, h);
|
|
443
450
|
}
|
|
444
|
-
if (
|
|
445
|
-
const s = await
|
|
451
|
+
if (i === "globals") {
|
|
452
|
+
const s = await E(e, "globals");
|
|
446
453
|
return await ot(t, s);
|
|
447
454
|
}
|
|
448
|
-
if (
|
|
455
|
+
if (i === "locales")
|
|
449
456
|
return nt(t);
|
|
450
|
-
if (
|
|
451
|
-
return await
|
|
452
|
-
if (
|
|
453
|
-
return
|
|
457
|
+
if (i === "strings")
|
|
458
|
+
return await it(t);
|
|
459
|
+
if (i === "content")
|
|
460
|
+
return rt();
|
|
454
461
|
}
|
|
455
462
|
};
|
|
456
463
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/runtime/wrap.ts"],"names":[],"mappings":"AAgCA;0DAC0D;AAC1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAElE;AAiHD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAiBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc1E;AAID,mFAAmF;AACnF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;AAE3D;;kFAEkF;AAClF,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAmDD;;;;;uDAKuD;AACvD,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,OAAO,EAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC,EACpD,aAAa,CAAC,EAAE,MAAM,GACpB,GAAG,CASL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,SAAK,EAAE,GAAG,GAAE,UAAsB,GAAG,GAAG,CA8G5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/runtime/wrap.ts"],"names":[],"mappings":"AAgCA;0DAC0D;AAC1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAElE;AAiHD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAiBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc1E;AAID,mFAAmF;AACnF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;AAE3D;;kFAEkF;AAClF,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAmDD;;;;;uDAKuD;AACvD,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,OAAO,EAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC,EACpD,aAAa,CAAC,EAAE,MAAM,GACpB,GAAG,CASL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,SAAK,EAAE,GAAG,GAAE,UAAsB,GAAG,GAAG,CA8G5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAsO5E;AAiED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,GAAE,MAAM,EAAO,GACpB,OAAO,CAgDT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACvC,OAAO,GAAE,MAAM,EAAO,GACpB,OAAO,CA4CT;AAiBD,MAAM,WAAW,mBAAmB;IACnC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACnC,cAAc;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;kFAG8E;IAC9E,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC;;kEAE8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AAyHD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAkDtE;AA6DD;2EAC2E;AAC3E,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C"}
|
package/dist/runtime/wrap.js
CHANGED
|
@@ -32,18 +32,18 @@ const C = /* @__PURE__ */ new Set([
|
|
|
32
32
|
function z(t) {
|
|
33
33
|
return t.replace(/[-_]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim().replace(/^./, (r) => r.toUpperCase());
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function k(t, r = "") {
|
|
36
36
|
if (t == null) {
|
|
37
37
|
if (!r) return "";
|
|
38
38
|
const i = r.split(".").pop() ?? "";
|
|
39
39
|
return !i || C.has(i) ? "" : z(i);
|
|
40
40
|
}
|
|
41
|
-
return typeof t != "object" ? String(t) :
|
|
41
|
+
return typeof t != "object" ? String(t) : j(t) ? t.text ?? "" : J(t) ? t.name ?? "" : "";
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function v(t) {
|
|
44
44
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "src" in t;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function j(t) {
|
|
47
47
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "url" in t && "text" in t && "external" in t;
|
|
48
48
|
}
|
|
49
49
|
function J(t) {
|
|
@@ -123,9 +123,9 @@ function b(t, r = "", i = K) {
|
|
|
123
123
|
get(n, e) {
|
|
124
124
|
if (e === "data-okno") return w + n.__path;
|
|
125
125
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
126
|
-
return () =>
|
|
126
|
+
return () => k(n.__raw, n.__path);
|
|
127
127
|
if (e === Symbol.iterator) {
|
|
128
|
-
const u =
|
|
128
|
+
const u = k(n.__raw, n.__path);
|
|
129
129
|
return function* () {
|
|
130
130
|
yield u;
|
|
131
131
|
};
|
|
@@ -179,7 +179,7 @@ function m(t, r, i) {
|
|
|
179
179
|
if (e === "data-okno") return n.__path;
|
|
180
180
|
if (e === "slot") return { "data-okno-item": n.__slot ?? n.__path };
|
|
181
181
|
if (e === "exists") return n.__raw !== null && n.__raw !== void 0;
|
|
182
|
-
if (e === "image" &&
|
|
182
|
+
if (e === "image" && v(n.__raw)) {
|
|
183
183
|
const s = n.__raw;
|
|
184
184
|
return {
|
|
185
185
|
src: x(s.src),
|
|
@@ -190,9 +190,9 @@ function m(t, r, i) {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
193
|
-
return () =>
|
|
193
|
+
return () => k(n.__raw, n.__path);
|
|
194
194
|
if (e === Symbol.iterator) {
|
|
195
|
-
const s =
|
|
195
|
+
const s = k(n.__raw, n.__path);
|
|
196
196
|
return function* () {
|
|
197
197
|
yield s;
|
|
198
198
|
};
|
|
@@ -216,11 +216,13 @@ function m(t, r, i) {
|
|
|
216
216
|
) : m(u, n.__path);
|
|
217
217
|
};
|
|
218
218
|
const o = n.__raw, f = n.__path ? `${n.__path}.${String(e)}` : String(e);
|
|
219
|
-
if (
|
|
219
|
+
if (j(o) && typeof e == "string") {
|
|
220
220
|
if (e === "href") return o.url ?? "";
|
|
221
221
|
if (e === "target" && o.external) return "_blank";
|
|
222
222
|
if (e === "rel" && o.external) return "noopener noreferrer";
|
|
223
223
|
}
|
|
224
|
+
if (v(o) && typeof e == "string" && e !== "focal" && e in o)
|
|
225
|
+
return o[e];
|
|
224
226
|
if (o != null && typeof o != "object") {
|
|
225
227
|
const s = o[e];
|
|
226
228
|
return s !== void 0 ? typeof s == "function" ? (...u) => s.apply(o, u) : s : m(null, f);
|
|
@@ -234,7 +236,7 @@ function m(t, r, i) {
|
|
|
234
236
|
// For spread: expose data-okno, plus all keys for file objects (src, alt, width, height, etc.)
|
|
235
237
|
ownKeys(n) {
|
|
236
238
|
const e = n.__raw;
|
|
237
|
-
return
|
|
239
|
+
return v(e) ? [...Object.keys(e).filter((o) => o !== "focal"), "data-okno"] : j(e) ? e.external ? ["href", "target", "rel", "data-okno"] : ["href", "data-okno"] : ["data-okno"];
|
|
238
240
|
},
|
|
239
241
|
getOwnPropertyDescriptor(n, e) {
|
|
240
242
|
if (e === "data-okno")
|
|
@@ -244,13 +246,13 @@ function m(t, r, i) {
|
|
|
244
246
|
configurable: !0
|
|
245
247
|
};
|
|
246
248
|
const o = n.__raw;
|
|
247
|
-
if (
|
|
249
|
+
if (v(o) && typeof e == "string" && e in o && e !== "focal")
|
|
248
250
|
return {
|
|
249
251
|
value: o[e],
|
|
250
252
|
enumerable: !0,
|
|
251
253
|
configurable: !0
|
|
252
254
|
};
|
|
253
|
-
if (
|
|
255
|
+
if (j(o) && (e === "href" || o.external && (e === "target" || e === "rel")))
|
|
254
256
|
return { value: void 0, enumerable: !0, configurable: !0 };
|
|
255
257
|
},
|
|
256
258
|
has(n, e) {
|
|
@@ -304,12 +306,12 @@ function ut(t, r, i, c = []) {
|
|
|
304
306
|
const o = (s, u) => {
|
|
305
307
|
const l = { ...s };
|
|
306
308
|
for (const a of n) {
|
|
307
|
-
const h = r[a], y = e[h.collection], O = (
|
|
308
|
-
if (typeof
|
|
309
|
-
const $ = y.get(
|
|
310
|
-
return $ === void 0 ? null : { __oknoRef: { path: `${h.collection}.${
|
|
311
|
-
},
|
|
312
|
-
l[a] = Array.isArray(
|
|
309
|
+
const h = r[a], y = e[h.collection], O = (p) => {
|
|
310
|
+
if (typeof p != "string" || !p) return null;
|
|
311
|
+
const $ = y.get(p);
|
|
312
|
+
return $ === void 0 ? null : { __oknoRef: { path: `${h.collection}.${p}`, data: D($, u) } };
|
|
313
|
+
}, S = s[a];
|
|
314
|
+
l[a] = Array.isArray(S) ? S.map(O).filter(Boolean) : O(S);
|
|
313
315
|
}
|
|
314
316
|
return l;
|
|
315
317
|
}, f = o(t, void 0);
|
|
@@ -350,8 +352,8 @@ function st(t, r, i = []) {
|
|
|
350
352
|
}
|
|
351
353
|
return o;
|
|
352
354
|
}
|
|
353
|
-
const d = "data-okno-item",
|
|
354
|
-
function
|
|
355
|
+
const d = "data-okno-item", A = "data-okno", H = [A, d];
|
|
356
|
+
function g(t, r, i, c = H) {
|
|
355
357
|
if (r === i) return;
|
|
356
358
|
const n = (e) => {
|
|
357
359
|
for (const o of c) {
|
|
@@ -378,8 +380,8 @@ function W(t) {
|
|
|
378
380
|
}));
|
|
379
381
|
}
|
|
380
382
|
function V(t) {
|
|
381
|
-
const r = Array.from(t.querySelectorAll(`[${
|
|
382
|
-
return t.hasAttribute(
|
|
383
|
+
const r = Array.from(t.querySelectorAll(`[${A}]`));
|
|
384
|
+
return t.hasAttribute(A) && r.unshift(t), r;
|
|
383
385
|
}
|
|
384
386
|
function F(t) {
|
|
385
387
|
for (const r of V(t))
|
|
@@ -387,7 +389,7 @@ function F(t) {
|
|
|
387
389
|
}
|
|
388
390
|
function G(t, r) {
|
|
389
391
|
for (const i of V(t)) {
|
|
390
|
-
const c = i.getAttribute(
|
|
392
|
+
const c = i.getAttribute(A);
|
|
391
393
|
c && c in r && i.children.length === 0 && (i.textContent = r[c] ?? "");
|
|
392
394
|
}
|
|
393
395
|
}
|
|
@@ -423,7 +425,7 @@ function Q(t, r, i, c) {
|
|
|
423
425
|
const o = n.slice(), [f] = o.splice(i, 1);
|
|
424
426
|
o.splice(c, 0, f);
|
|
425
427
|
const s = o.map((l) => l.getAttribute(d));
|
|
426
|
-
o.forEach((l, a) =>
|
|
428
|
+
o.forEach((l, a) => g(l, s[a], `${r}.${a}`));
|
|
427
429
|
const u = n[e - 1].nextSibling;
|
|
428
430
|
for (const l of o) t.parent.insertBefore(l, u);
|
|
429
431
|
}
|
|
@@ -431,15 +433,15 @@ function tt(t, r, i) {
|
|
|
431
433
|
const c = t.wrappers;
|
|
432
434
|
if (!(i < 0 || i >= c.length)) {
|
|
433
435
|
c[i].remove();
|
|
434
|
-
for (let n = i + 1; n < c.length; n++)
|
|
436
|
+
for (let n = i + 1; n < c.length; n++) g(c[n], `${r}.${n}`, `${r}.${n - 1}`);
|
|
435
437
|
}
|
|
436
438
|
}
|
|
437
439
|
function et(t, r, i, c) {
|
|
438
440
|
const n = t.wrappers, e = n.length;
|
|
439
441
|
if (e === 0) return;
|
|
440
442
|
const o = Math.max(0, Math.min(i.index ?? e, e)), f = o < e ? o : e - 1, s = n[f].getAttribute(d), u = n[f].cloneNode(!0);
|
|
441
|
-
for (let a = e - 1; a >= o; a--)
|
|
442
|
-
|
|
443
|
+
for (let a = e - 1; a >= o; a--) g(n[a], `${r}.${a}`, `${r}.${a + 1}`);
|
|
444
|
+
g(u, s, `${r}.${o}`), i.remap && g(u, i.remap.from, i.remap.to, [A]), i.values ? G(u, i.values) : F(u), u.style.viewTransitionName = "", c(u);
|
|
443
445
|
const l = o < e ? n[o] : n[e - 1].nextSibling;
|
|
444
446
|
t.parent.insertBefore(u, l);
|
|
445
447
|
}
|
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;AA+EpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,
|
|
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;AA+EpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CAwYpD"}
|
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.16",
|
|
6
6
|
"homepage": "https://okno.build",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
package/src/runtime/wrap.ts
CHANGED
|
@@ -542,6 +542,18 @@ export function __oknoWrap(data: unknown, prefix: string, slot?: string): any {
|
|
|
542
542
|
if (prop === "rel" && raw.external) return "noopener noreferrer"
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
+
// Media object: the spreadable leaf attrs (src/alt/width/height) are
|
|
546
|
+
// terminal HTML attribute values — return them RAW, not a nested proxy, so
|
|
547
|
+
// `{...cover}` read via [[Get]] yields real primitives. Object spread and
|
|
548
|
+
// Vue's `v-bind`/`ssrRenderAttrs` read through Get (not descriptors), so a
|
|
549
|
+
// wrapped-proxy leaf gets dropped as a non-string object and `<img>` loses
|
|
550
|
+
// src/alt/width. Mirrors the getOwnPropertyDescriptor trap below; `.image`
|
|
551
|
+
// (optimized bundle), `.focal`, `.onedit`, `data-okno` are handled above, so
|
|
552
|
+
// only the raw scalar attrs fall here. Media edits as a unit → no per-leaf hook lost.
|
|
553
|
+
if (isMediaObject(raw) && typeof prop === "string" && prop !== "focal" && prop in (raw as object)) {
|
|
554
|
+
return (raw as Record<string, unknown>)[prop]
|
|
555
|
+
}
|
|
556
|
+
|
|
545
557
|
// For primitive values (string, number, boolean), forward native method/property access
|
|
546
558
|
// This makes home.title.length, home.title.includes("x"), etc. work
|
|
547
559
|
if (raw !== null && raw !== undefined && typeof raw !== "object") {
|