okno 1.0.0-beta.38 → 1.0.0-beta.39

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.
@@ -453,9 +453,20 @@ let k5 = class extends Et {
453
453
  setProductionBranch(t) {
454
454
  this.currentRepo && this.currentRepo.productionBranch !== t && this.setCurrentRepo({ ...this.currentRepo, productionBranch: t });
455
455
  }
456
- /** Header value sent on every backend request that targets a repo. */
456
+ /** Header value sent on every backend request that targets a repo.
457
+ *
458
+ * Falls back to the BAKED identity when nothing is selected yet. That gap is
459
+ * real and it deadlocked sign-in on a deployed site: `setup.start()` returns
460
+ * immediately while anonymous (no token), so `currentRepo` is still null at
461
+ * login — the popup went out with no `repo`, the callback had no project to
462
+ * look up, and it answered "This project has no allowed domains yet". The repo
463
+ * can't be resolved after login when login itself needs it.
464
+ *
465
+ * The baked value is safe to use here precisely because it's a build-time
466
+ * constant: a deployed site IS one repo, and setup adopts the same value a
467
+ * moment later anyway. */
457
468
  get repoHeader() {
458
- const t = this.currentRepo;
469
+ const t = this.currentRepo ?? this.bakedRepo;
459
470
  return t ? `${t.owner}/${t.repo}@${t.branch}` : null;
460
471
  }
461
472
  /** X-Okno-Path header — the monorepo subdir. The baked path describes the
@@ -467,7 +478,7 @@ let k5 = class extends Et {
467
478
  * omitted → backend treats it as the repo root. */
468
479
  get rootHeader() {
469
480
  if (!this.bakedRoot) return null;
470
- const t = this.bakedRepo, r = this.currentRepo;
481
+ const t = this.bakedRepo, r = this.currentRepo ?? t;
471
482
  return !t || !r ? null : t.owner === r.owner && t.repo === r.repo ? this.bakedRoot : null;
472
483
  }
473
484
  /** Base URL for CONTENT-engine calls (content/schema/files/publish). In dev
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { o as a } from "./plugin-Bgk7L4b7.js";
1
+ import { o as a } from "./plugin-BdiBIiAv.js";
2
2
  export {
3
3
  a as okno
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { join as c, relative as v, sep as O, resolve as g, dirname as R } from "node:path";
2
2
  import { existsSync as w, watch as E, readFileSync as M, mkdirSync as P, cpSync as A } from "node:fs";
3
3
  import { fileURLToPath as C } from "node:url";
4
- import { s as m, b as J, a as I, c as D, d as U, e as K, g as L, I as T, f as F, h as V, i as $, j as B, k as G } from "../dispatch-oBWbJ5Pl.js";
4
+ import { s as m, b as J, a as I, c as D, d as U, e as K, g as L, I as T, f as F, h as V, i as $, j as B, k as G } from "../dispatch-BifB_3GO.js";
5
5
  import { mkdir as z, writeFile as f } from "node:fs/promises";
6
6
  const H = (n) => n.replaceAll(T, "__oknoSetImages(undefined)"), W = (n) => {
7
7
  let t = n;
@@ -0,0 +1,489 @@
1
+ import { extname as z, join as y, 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 I, 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-BifB_3GO.js";
5
+ import { simpleGit as R } from "simple-git";
6
+ import "node:child_process";
7
+ import "./parse-tlTHgSSs.js";
8
+ function F(n, r, o) {
9
+ n.statusCode = r, n.setHeader("Content-Type", "application/json"), n.setHeader("Cache-Control", "no-store"), n.end(JSON.stringify(o));
10
+ }
11
+ function lt(n) {
12
+ return new Promise((r) => {
13
+ let o = "";
14
+ n.on("data", (t) => o += t), n.on("end", () => {
15
+ try {
16
+ r(o ? JSON.parse(o) : {});
17
+ } catch {
18
+ r({});
19
+ }
20
+ }), n.on("error", () => r({}));
21
+ });
22
+ }
23
+ function ct(n) {
24
+ return new Promise((r, o) => {
25
+ const t = [];
26
+ n.on("data", (c) => t.push(c)), n.on("end", () => r(Buffer.concat(t))), n.on("error", o);
27
+ });
28
+ }
29
+ function ut(n, r) {
30
+ if (r) {
31
+ for (const o of new Set(r.modules)) {
32
+ const t = n.moduleGraph.getModuleById("\0okno:" + o);
33
+ t && n.moduleGraph.invalidateModule(t);
34
+ }
35
+ for (const o of new Set(r.files))
36
+ n.moduleGraph.getModulesByFile(o)?.forEach((t) => n.moduleGraph.invalidateModule(t));
37
+ }
38
+ }
39
+ function dt(n, r) {
40
+ n.middlewares.use(async (o, t, c) => {
41
+ if (!o.url?.startsWith("/__okno/api/")) return c();
42
+ const m = o.url.slice(12).split("?")[0], e = {
43
+ method: o.method || "GET",
44
+ route: m,
45
+ json: () => lt(o),
46
+ binary: () => ct(o),
47
+ header: (i) => {
48
+ const s = o.headers[i];
49
+ return Array.isArray(s) ? s[0] : s;
50
+ }
51
+ };
52
+ try {
53
+ const i = await Z(r, e);
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
+ }
59
+ });
60
+ }
61
+ function ft(n, r) {
62
+ let o;
63
+ try {
64
+ o = decodeURIComponent(r);
65
+ } catch {
66
+ return null;
67
+ }
68
+ if (!o || o.includes("\0")) return null;
69
+ const t = g(n, "files"), c = g(t, o);
70
+ return c === t || !c.startsWith(t + D) ? null : c;
71
+ }
72
+ const H = "okno", pt = {
73
+ ".webp": "image/webp",
74
+ ".png": "image/png",
75
+ ".jpg": "image/jpeg",
76
+ ".jpeg": "image/jpeg",
77
+ ".gif": "image/gif",
78
+ ".svg": "image/svg+xml",
79
+ ".avif": "image/avif",
80
+ ".ico": "image/x-icon",
81
+ ".mp4": "video/mp4",
82
+ ".webm": "video/webm",
83
+ ".ogg": "video/ogg",
84
+ ".mp3": "audio/mpeg",
85
+ ".wav": "audio/wav",
86
+ ".flac": "audio/flac",
87
+ ".pdf": "application/pdf",
88
+ ".woff2": "font/woff2",
89
+ ".woff": "font/woff",
90
+ ".ttf": "font/ttf",
91
+ ".otf": "font/otf"
92
+ };
93
+ function gt(n, r) {
94
+ dt(n, r), n.middlewares.use((o, t, c) => {
95
+ if (o.method !== "GET" || !o.url?.startsWith("/okno/files/")) return c();
96
+ const m = o.url.slice(12).split("?")[0];
97
+ if (!m) return c();
98
+ const e = ft(r, m);
99
+ if (!e)
100
+ return t.statusCode = 403, t.end("Forbidden");
101
+ if (!O(e))
102
+ return t.statusCode = 404, t.end("Not found");
103
+ const i = z(e).toLowerCase();
104
+ t.setHeader("Content-Type", pt[i] || "application/octet-stream"), t.setHeader("Cache-Control", "public, max-age=3600"), t.end(U(e));
105
+ }), n.middlewares.use(async (o, t, c) => {
106
+ if (!o.url?.startsWith("/__okno/")) return c();
107
+ const m = o.url.slice(8);
108
+ t.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate"), t.setHeader("Pragma", "no-cache"), t.setHeader("Expires", "0");
109
+ try {
110
+ if (o.method === "GET" && m === "repo") {
111
+ t.setHeader("Content-Type", "application/json");
112
+ try {
113
+ const e = R(n.config.root), i = (await e.remote(["get-url", "origin"]))?.toString().trim(), s = (await e.revparse(["--abbrev-ref", "HEAD"])).trim(), { owner: f, repo: a } = mt(i);
114
+ return t.end(
115
+ JSON.stringify({ ok: !0, owner: f, repo: a, branch: s || null, remote: i || null })
116
+ );
117
+ } catch (e) {
118
+ return t.end(JSON.stringify({ ok: !1, error: String(e) }));
119
+ }
120
+ }
121
+ if (o.method === "POST" && m.startsWith("mirror")) {
122
+ const i = new URL(o.url, "http://localhost").searchParams.get("path");
123
+ if (!i || i.includes("..") || !i.startsWith("files/"))
124
+ return t.statusCode = 400, t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ error: "Invalid path" }));
125
+ const s = y(r, i);
126
+ if (O(s))
127
+ return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, skipped: !0 }));
128
+ const f = await ht(o);
129
+ return M(T(s), { recursive: !0 }), I(s, f), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, written: i, bytes: f.length }));
130
+ }
131
+ if (o.method === "POST" && m === "sync") {
132
+ const i = (await yt(o))?.path;
133
+ if (i) {
134
+ if (i.includes("..") || i.includes("\0"))
135
+ return t.statusCode = 400, t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ error: "Invalid path" }));
136
+ const u = y(r, i);
137
+ try {
138
+ const l = R(r);
139
+ await l.fetch("origin", H);
140
+ const h = (await l.revparse(["--show-toplevel"])).trim(), p = N(h, u).split(D).join("/"), w = await l.show([`origin/${H}:${p}`]);
141
+ M(T(u), { recursive: !0 }), I(u, w);
142
+ } catch (l) {
143
+ const h = l instanceof Error ? l.message : String(l);
144
+ console.warn(
145
+ `[okno] sync: could not materialize ${i} from origin/${H} — ${h.split(`
146
+ `)[0]}`
147
+ );
148
+ }
149
+ return A(n, i, u), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, invalidated: i }));
150
+ }
151
+ const s = R(r), f = await s.revparse(["--show-toplevel"]), a = N(f.trim(), r);
152
+ try {
153
+ const u = await s.pull();
154
+ for (const l of u.files)
155
+ if (l.startsWith(`${a}/`)) {
156
+ const h = l.slice(`${a}/`.length), p = y(r, h);
157
+ A(n, h, p);
158
+ }
159
+ return t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, files: u.files }));
160
+ } catch (u) {
161
+ const l = u instanceof Error ? u.message : String(u);
162
+ return console.warn(`[okno] sync: git pull skipped — ${l.split(`
163
+ `)[0]}`), t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify({ ok: !0, pullSkipped: !0, reason: l }));
164
+ }
165
+ }
166
+ c();
167
+ } catch (e) {
168
+ t.statusCode = 500, t.end(JSON.stringify({ error: String(e) }));
169
+ }
170
+ });
171
+ }
172
+ function mt(n) {
173
+ if (!n) return { owner: null, repo: null };
174
+ const r = n.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
175
+ return r ? { owner: r[1], repo: r[2] } : { owner: null, repo: null };
176
+ }
177
+ function ht(n) {
178
+ return new Promise((r, o) => {
179
+ const t = [];
180
+ n.on("data", (c) => t.push(c)), n.on("end", () => r(Buffer.concat(t))), n.on("error", o);
181
+ });
182
+ }
183
+ function yt(n) {
184
+ return new Promise((r) => {
185
+ let o = "";
186
+ n.on("data", (t) => {
187
+ o += t;
188
+ }), n.on("end", () => {
189
+ try {
190
+ r(o ? JSON.parse(o) : null);
191
+ } catch {
192
+ r(null);
193
+ }
194
+ }), n.on("error", () => r(null));
195
+ });
196
+ }
197
+ function A(n, r, o) {
198
+ const t = "\0okno:";
199
+ let c;
200
+ if (r.startsWith("pages/") ? c = t + "pages" : r.startsWith("collections/") ? c = t + "collections" : r.startsWith("globals/") && (c = t + "globals"), c) {
201
+ const m = n.moduleGraph.getModuleById(c);
202
+ m && n.moduleGraph.invalidateModule(m);
203
+ const e = n.moduleGraph.getModulesByFile(o);
204
+ e && e.forEach((i) => {
205
+ n.moduleGraph.invalidateModule(i);
206
+ });
207
+ }
208
+ }
209
+ function wt(n, r) {
210
+ const o = (n.split("?")[0] ?? "").replace(/\\/g, "/"), t = r.replace(/\\/g, "/");
211
+ return o === t || o.startsWith(t + "/");
212
+ }
213
+ function bt(n, r) {
214
+ for (const [o, t] of Object.entries(r)) {
215
+ if (n === o) return t;
216
+ if (n.startsWith(o + "/")) return t + n.slice(o.length);
217
+ }
218
+ return null;
219
+ }
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"), j = g(b, "index.ts"), kt = O(j), vt = {
221
+ "@modules": g(b, "modules"),
222
+ "@lib": g(b, "lib"),
223
+ "@logger": g(b, "lib/logger.svelte.ts"),
224
+ "@utils": g(b, "lib/utils.ts"),
225
+ "@/types": g(b, "lib/types.ts"),
226
+ "@styles": g(b, "styles"),
227
+ "@components": g(b, "components"),
228
+ "@assets": g(b, "assets"),
229
+ "@pages": g(b, "pages"),
230
+ "@controllers": g(b, "controllers")
231
+ };
232
+ function Tt(n = {}) {
233
+ const r = n.dir ?? "okno";
234
+ let o, t, c = !1, m = !1;
235
+ return n.isEditor, {
236
+ name: "okno",
237
+ enforce: "pre",
238
+ config(e, i) {
239
+ const s = i.command === "serve";
240
+ return m = i.command === "build", c = s && kt && !n.builtEditor, {
241
+ define: {
242
+ __OKNO_API_URL__: JSON.stringify(n.apiUrl ?? "https://api.okno.build"),
243
+ __OKNO_VERSION__: JSON.stringify(Ot),
244
+ // True when the consumer is running `vite dev` / `astro dev` /
245
+ // `sveltekit dev` — anything that serves locally. Replaced at
246
+ // consumer build time so the prebuilt editor bundle can honor
247
+ // the consumer's actual environment.
248
+ __OKNO_IS_DEV__: JSON.stringify(s),
249
+ // Public demo build: editor boots login-less, reads a static
250
+ // `okno-demo.json` snapshot, no-ops writes. See docs/demo-mode.md.
251
+ __OKNO_DEMO__: JSON.stringify(n.demo ?? !1),
252
+ // Repo identity (`owner/repo@branch`) baked from the app's git
253
+ // origin at the consumer's build time, so the deployed editor
254
+ // auto-targets its repo with no picker. null outside a git
255
+ // checkout → editor falls back to the picker. Dev ignores it
256
+ // (runtime /__okno/repo derivation is more current).
257
+ __OKNO_REPO__: JSON.stringify(at()),
258
+ // Monorepo root path: the build dir relative to the git root (e.g.
259
+ // "apps/site", or "" at the repo root). Sent as X-Okno-Path so the
260
+ // hosted backend reads/writes content under `<root>/okno` instead of
261
+ // the repo-root `okno` — one repo, many okno projects keyed (repo, path).
262
+ __OKNO_ROOT__: JSON.stringify(st())
263
+ },
264
+ // Source mode (monorepo dev only): skip prebundling so saves to
265
+ // `package/editor/**` propagate via HMR instead of needing
266
+ // `bun run build:pkg`. The editor's internal @-aliases are NOT exposed
267
+ // as a global `resolve.alias` here — that shadowed a consumer's own
268
+ // identically-named tsconfig aliases (`@components`, `@lib`, …). They
269
+ // are instead resolved per-importer in `resolveId`, scoped to imports
270
+ // originating inside the editor source tree. See editor-aliases.ts.
271
+ ...c && {
272
+ optimizeDeps: { exclude: ["okno", "okno/editor"] }
273
+ },
274
+ server: {
275
+ watch: {
276
+ // Only ignore binary assets and editor-only metadata. Page/
277
+ // collection/global .ts files SHOULD trigger Vite HMR — that's
278
+ // how users see updates when they `git pull` content from the
279
+ // drafts branch into their working tree. (Previously this list
280
+ // also blocked pages/collections/globals because in DEV_MODE
281
+ // the backend mirrored saves to disk, causing spurious full
282
+ // reloads. In production-mode the backend never touches local
283
+ // FS so blocking those is pure harm — pulls go unseen.)
284
+ ignored: [`**/${r}/files/**`, `**/${r}/.okno-tree.json`]
285
+ },
286
+ // Source mode: the editor loads via a dynamic `import("okno/editor")`
287
+ // from a separate package over `@fs`, so Vite's startup dep scan
288
+ // never crawls it — its transitive deps (bits-ui, tiptap, runed…)
289
+ // are discovered lazily on first import, triggering a mid-session
290
+ // re-optimize that 404s the now-stale prebundled chunks. Warming the
291
+ // editor entry forces that crawl at startup, so those deps land in
292
+ // the first optimize pass and never re-bundle under the user.
293
+ ...c && {
294
+ warmup: { clientFiles: [j] }
295
+ }
296
+ }
297
+ };
298
+ },
299
+ configResolved(e) {
300
+ o = e.root, t = g(o, r);
301
+ },
302
+ async buildStart() {
303
+ if (O(t)) {
304
+ if (await P(t, o), m) {
305
+ const e = y(t, "files");
306
+ if (O(e)) {
307
+ const i = O(y(o, "static")) ? y(o, "static") : y(o, "public"), s = y(i, "okno", "files");
308
+ g(s) !== g(e) && (M(s, { recursive: !0 }), Y(e, s, {
309
+ recursive: !0,
310
+ filter: (f) => !f.endsWith(".okno-tree.json")
311
+ }));
312
+ }
313
+ }
314
+ if (n.demo) {
315
+ const e = y(o, "public");
316
+ O(e) || M(e, { recursive: !0 }), I(
317
+ y(e, "okno-demo.json"),
318
+ JSON.stringify(rt(t))
319
+ );
320
+ }
321
+ }
322
+ },
323
+ configureServer(e) {
324
+ gt(e, t);
325
+ const i = (f) => {
326
+ const a = N(t, f);
327
+ if (a.startsWith("..") || !a.endsWith(".ts")) return;
328
+ const u = a.split(/[\\/]/)[0];
329
+ if (u !== "pages" && u !== "collections" && u !== "globals") return;
330
+ const l = e.moduleGraph.getModuleById(_ + u);
331
+ l && e.moduleGraph.invalidateModule(l), e.moduleGraph.getModulesByFile(f)?.forEach((h) => e.moduleGraph.invalidateModule(h)), !$(f) && e.ws.send({ type: "full-reload" });
332
+ };
333
+ e.watcher.on("add", i), e.watcher.on("unlink", i), e.middlewares.use("/__okno/imports", async (f, a, u) => {
334
+ if (f.method !== "GET") return u();
335
+ try {
336
+ const [l, h, p] = await Promise.all([
337
+ E(o, "pages"),
338
+ E(o, "globals"),
339
+ E(o, "collections")
340
+ ]);
341
+ a.setHeader("Content-Type", "application/json"), a.setHeader("Cache-Control", "no-store"), a.end(JSON.stringify({
342
+ pages: Array.from(l),
343
+ globals: Array.from(h),
344
+ collections: Array.from(p)
345
+ }));
346
+ } catch (l) {
347
+ u(l);
348
+ }
349
+ });
350
+ const s = "/__okno_bootstrap.js";
351
+ e.middlewares.use(s, async (f, a, u) => {
352
+ try {
353
+ const l = await e.transformRequest("\0okno:bootstrap");
354
+ if (!l) {
355
+ a.statusCode = 500, a.end("okno bootstrap transform failed");
356
+ return;
357
+ }
358
+ a.setHeader("content-type", "text/javascript"), a.end(l.code);
359
+ } catch (l) {
360
+ u(l);
361
+ }
362
+ }), e.middlewares.use((f, a, u) => {
363
+ const l = "<script>window.__oknoDev=true<\/script>", h = n.demo ? "<script>window.__oknoDemo=true<\/script>" : "", p = `${l}${h}<script type="module" src="${s}"><\/script>`, w = [];
364
+ let k = null;
365
+ const V = a.write.bind(a), B = a.end.bind(a), X = a.setHeader.bind(a), G = () => {
366
+ const d = a.getHeader("content-type");
367
+ return typeof d == "string" && d.includes("text/html");
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 B(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");
375
+ if (!a.headersSent)
376
+ try {
377
+ X("content-length", String(J.length));
378
+ } catch {
379
+ }
380
+ return B(J, ...C);
381
+ }, u();
382
+ });
383
+ },
384
+ async handleHotUpdate(e) {
385
+ const i = y(t, "schema.ts"), s = y(t, "users.json"), f = y(t, "permissions.ts"), a = y(t, "modules.d.ts");
386
+ if (e.file === i) {
387
+ await P(t, o);
388
+ for (const p of ["pages", "collections", "globals", "locales", "content", "strings"]) {
389
+ const w = e.server.moduleGraph.getModuleById(_ + p);
390
+ w && e.server.moduleGraph.invalidateModule(w);
391
+ }
392
+ return [];
393
+ }
394
+ if (e.file === s || e.file === f || e.file === a)
395
+ return [];
396
+ const u = y(t, "strings.ts"), l = N(y(t, "strings"), e.file);
397
+ if (e.file === u || !l.startsWith("..") && l.endsWith(".ts")) {
398
+ await P(t, o);
399
+ for (const p of ["strings", "content"]) {
400
+ const w = e.server.moduleGraph.getModuleById(_ + p);
401
+ w && e.server.moduleGraph.invalidateModule(w);
402
+ }
403
+ }
404
+ const h = N(t, e.file);
405
+ if (!h.startsWith("..") && h.endsWith(".ts")) {
406
+ const p = h.split(/[\\/]/)[0];
407
+ if ((p === "pages" || p === "collections" || p === "globals") && $(e.file)) {
408
+ const w = e.server.moduleGraph.getModuleById(_ + p);
409
+ return w && e.server.moduleGraph.invalidateModule(w), [];
410
+ }
411
+ }
412
+ },
413
+ // PRODUCTION boot for index.html frameworks (plain Vite, Solid, …). In dev
414
+ // the `configureServer` middleware injects the editor; that middleware never
415
+ // runs in a build, so a deployed page would ship no editor. `transformIndexHtml`
416
+ // fires only for frameworks whose HTML goes through Vite's index.html pipeline
417
+ // — Astro/SvelteKit/Nuxt own their HTML and bypass this hook, so they wire boot
418
+ // their own way (an Astro integration, a +layout import, a Nuxt client plugin).
419
+ // The inline `import "okno/boot"` is a real module script, so Vite bundles it +
420
+ // code-splits the editor behind boot's press-`e`/`?okno` gate.
421
+ transformIndexHtml: {
422
+ // `pre`, so the inline module script is present BEFORE Vite's core HTML
423
+ // plugin collects + bundles page scripts — otherwise the bare
424
+ // `import "okno/boot"` survives unbundled and 404s in the browser.
425
+ order: "pre",
426
+ handler(e) {
427
+ if (m)
428
+ return {
429
+ html: e,
430
+ tags: [
431
+ {
432
+ tag: "script",
433
+ attrs: { type: "module" },
434
+ children: 'import "okno/boot"',
435
+ injectTo: "body"
436
+ }
437
+ ]
438
+ };
439
+ }
440
+ },
441
+ async resolveId(e, i) {
442
+ if (e.startsWith(St))
443
+ return "\0" + e;
444
+ if (e.startsWith("okno/")) {
445
+ const s = e.slice(5);
446
+ if (_t.has(s)) return _ + s;
447
+ }
448
+ if (c && e === "okno/editor")
449
+ return j;
450
+ if (c && i && wt(i, b)) {
451
+ const s = bt(e, vt);
452
+ if (s)
453
+ return (await this.resolve(s, i, { skipSelf: !0 }))?.id;
454
+ }
455
+ },
456
+ async load(e) {
457
+ if (!e.startsWith(_)) return;
458
+ const i = e.slice(_.length);
459
+ if (i === "runtime") {
460
+ if (!L)
461
+ throw new Error("okno: runtime/wrap.js missing — run `bun run build:pkg`");
462
+ return L;
463
+ }
464
+ if (i === "bootstrap")
465
+ return 'import("okno/editor")';
466
+ if (i === "pages") {
467
+ const s = await E(o, "pages");
468
+ return await q(t, s);
469
+ }
470
+ if (i === "collections") {
471
+ const s = await E(o, "collections");
472
+ return await tt(t, s, m);
473
+ }
474
+ if (i === "globals") {
475
+ const s = await E(o, "globals");
476
+ return await et(t, s);
477
+ }
478
+ if (i === "locales")
479
+ return ot(t);
480
+ if (i === "strings")
481
+ return await nt(t);
482
+ if (i === "content")
483
+ return it();
484
+ }
485
+ };
486
+ }
487
+ export {
488
+ Tt as o
489
+ };
@@ -161,11 +161,6 @@ export interface OknoConfig {
161
161
  * persisted; a reload resets). For showcasing okno on a marketing site —
162
162
  * see `docs/demo-mode.md`. A demo build never reaches the backend. */
163
163
  demo?: boolean;
164
- /** Base URL the instant-mode snapshot is served from (default:
165
- * "https://snap.okno.build"). Only read when okno/project.json has
166
- * `"instant": true` — see docs/instant.md. Override for self-hosted or
167
- * local testing of the hot layer. */
168
- instantUrl?: string;
169
164
  /** Localization configuration */
170
165
  locales?: {
171
166
  /** Default/base locale code (e.g. "en") */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEtD,iEAAiE;AACjE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAE7C,iDAAiD;AACjD,MAAM,WAAW,OAAO;IACvB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;+EAC2E;IAC3E,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACd;AAED,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;kFAI8E;IAC9E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;;;;;mDAM+C;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;;qFAQiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;sDAEkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG;QAChB,IAAI,EAAE,SAAS,CAAA;KACf,CAAA;CACD;AAED;;oEAEoE;AACpE,MAAM,WAAW,SAAS;IACzB,IAAI,CAAC,EAAE,MAAM,C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AA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;;gFAM4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;2EAGuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,iCAAiC;IACjC,OAAO,CAAC,EAAE;QACT,2CAA2C;QAC3C,OAAO,EAAE,MAAM,CAAA;QACf,uDAAuD;QACvD,SAAS,EAAE,MAAM,EAAE,CAAA;KACnB,CAAA;CACD"}
@@ -1,4 +1,4 @@
1
- import { o as a } from "../plugin-Bgk7L4b7.js";
1
+ import { o as a } from "../plugin-BdiBIiAv.js";
2
2
  export {
3
3
  a as okno
4
4
  };
@@ -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;AAsEpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CA8dpD"}
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,CAqbpD"}
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.38",
5
+ "version": "1.0.0-beta.39",
6
6
  "homepage": "https://okno.build",
7
7
  "type": "module",
8
8
  "types": "./dist/index.d.ts",
@@ -1,21 +0,0 @@
1
- /**
2
- * Instant-mode variants of the `okno:*` content module generators.
3
- *
4
- * Same import surface as the baked modules (modules.ts) — same export names,
5
- * same wrapped shapes — but content comes from the CURRENT request's snapshot
6
- * (via the `okno:instant` runtime) instead of build-time imports. What stays
7
- * build-time: the export NAME sets (pages/globals/collections are structure —
8
- * adding one is a schema change and rebuilds anyway), the schema import (field
9
- * defs drive ref/enum hydration and routes), and the image map (built assets).
10
- * What turns dynamic: every content VALUE.
11
- *
12
- * VITE-FREE by contract, like modules.ts.
13
- */
14
- export declare function buildInstantPagesModule(oknoDir: string, used?: Set<string>): Promise<string>;
15
- export declare function buildInstantGlobalsModule(oknoDir: string, used?: Set<string>): Promise<string>;
16
- export declare function buildInstantCollectionsModule(oknoDir: string, used?: Set<string>): Promise<string>;
17
- export declare function buildInstantStringsModule(oknoDir: string): string;
18
- /** The `okno:instant-middleware` module — Astro middleware that fetches the
19
- * snapshot and runs the request inside its AsyncLocalStorage context. */
20
- export declare function buildInstantMiddlewareModule(snapshotUrl: string): string;
21
- //# sourceMappingURL=modules-instant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules-instant.d.ts","sourceRoot":"","sources":["../../src/codegen/modules-instant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA8BH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7G;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/G;AA4BD,wBAAsB,6BAA6B,CAClD,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAajE;AAED;0EAC0E;AAC1E,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMxE"}