okno 1.0.0-alpha.4 → 1.0.0-alpha.5

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { o as a } from "./plugin-rPgNLY_g.js";
1
+ import { o as a } from "./plugin-DvUn7pFQ.js";
2
2
  export {
3
3
  a as okno
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { join as u, extname as R, dirname as E, relative as L, resolve as I } from "node:path";
2
- import { existsSync as $, readFileSync as M, mkdirSync as V, writeFileSync as D } from "node:fs";
3
- import { readdir as y, writeFile as H, readFile as J } from "node:fs/promises";
2
+ import { existsSync as $, readFileSync as M, mkdirSync as H, writeFileSync as V } from "node:fs";
3
+ import { readdir as y, writeFile as D, readFile as J } from "node:fs/promises";
4
4
  import { fileURLToPath as G } from "node:url";
5
5
  import { simpleGit as A } from "simple-git";
6
6
  async function C(a) {
@@ -25,7 +25,7 @@ async function C(a) {
25
25
  " ? { [K in keyof T]: OknoWrapped<T[K]> } & OknoValue<T>",
26
26
  " : OknoValue<T>",
27
27
  ""
28
- ], o = u(a, "pages"), e = await P(o);
28
+ ], o = u(a, "pages"), e = await T(o);
29
29
  if (e.length > 0) {
30
30
  n.push('declare module "okno:pages" {');
31
31
  for (const r of e) {
@@ -40,7 +40,7 @@ async function C(a) {
40
40
  if (r.length > 0) {
41
41
  n.push('declare module "okno:collections" {');
42
42
  for (const t of r) {
43
- const i = await P(u(s, t.name));
43
+ const i = await T(u(s, t.name));
44
44
  if (i.length === 0) continue;
45
45
  const p = i[0];
46
46
  n.push(
@@ -50,7 +50,7 @@ async function C(a) {
50
50
  n.push("}"), n.push("");
51
51
  }
52
52
  }
53
- const l = u(a, "globals"), c = await P(l);
53
+ const l = u(a, "globals"), c = await T(l);
54
54
  if (c.length > 0) {
55
55
  n.push('declare module "okno:globals" {');
56
56
  for (const r of c) {
@@ -59,10 +59,10 @@ async function C(a) {
59
59
  }
60
60
  n.push("}"), n.push("");
61
61
  }
62
- await H(u(a, "modules.d.ts"), n.join(`
62
+ await D(u(a, "modules.d.ts"), n.join(`
63
63
  `));
64
64
  }
65
- async function P(a) {
65
+ async function T(a) {
66
66
  return $(a) ? (await y(a)).filter((o) => o.endsWith(".ts") && o !== "index.ts" && o !== "modules.d.ts").map((o) => o.replace(".ts", "")) : [];
67
67
  }
68
68
  function k(a) {
@@ -114,7 +114,7 @@ function B(a, n) {
114
114
  if ($(i))
115
115
  return e.setHeader("Content-Type", "application/json"), e.end(JSON.stringify({ ok: !0, skipped: !0 }));
116
116
  const p = await K(o);
117
- return V(E(i), { recursive: !0 }), D(i, p), e.setHeader("Content-Type", "application/json"), e.end(JSON.stringify({ ok: !0, written: t, bytes: p.length }));
117
+ return H(E(i), { recursive: !0 }), V(i, p), e.setHeader("Content-Type", "application/json"), e.end(JSON.stringify({ ok: !0, written: t, bytes: p.length }));
118
118
  }
119
119
  if (o.method === "POST" && l === "sync") {
120
120
  const r = await z(o), t = r == null ? void 0 : r.path;
@@ -175,7 +175,7 @@ function F(a, n, o) {
175
175
  });
176
176
  }
177
177
  }
178
- const X = "okno:", T = "\0okno:", Y = E(G(import.meta.url)), Z = I(Y, "../runtime");
178
+ const X = "okno:", P = "\0okno:", Y = E(G(import.meta.url)), Z = I(Y, "../runtime");
179
179
  function lt(a = {}) {
180
180
  const n = a.dir ?? "okno";
181
181
  let o, e;
@@ -208,6 +208,16 @@ function lt(a = {}) {
208
208
  configResolved(s) {
209
209
  o = s.root, e = I(o, n);
210
210
  },
211
+ transformIndexHtml() {
212
+ return [
213
+ {
214
+ tag: "script",
215
+ attrs: { type: "module" },
216
+ children: 'import("okno/editor")',
217
+ injectTo: "body"
218
+ }
219
+ ];
220
+ },
211
221
  async buildStart() {
212
222
  $(e) && await C(e);
213
223
  },
@@ -219,7 +229,7 @@ function lt(a = {}) {
219
229
  if (s.file === l) {
220
230
  await C(e);
221
231
  for (const i of ["pages", "collections", "globals"]) {
222
- const p = s.server.moduleGraph.getModuleById(T + i);
232
+ const p = s.server.moduleGraph.getModuleById(P + i);
223
233
  p && s.server.moduleGraph.invalidateModule(p);
224
234
  }
225
235
  return [];
@@ -232,8 +242,8 @@ function lt(a = {}) {
232
242
  return "\0" + s;
233
243
  },
234
244
  async load(s) {
235
- if (!s.startsWith(T)) return;
236
- const l = s.slice(T.length);
245
+ if (!s.startsWith(P)) return;
246
+ const l = s.slice(P.length);
237
247
  if (l === "runtime")
238
248
  return `export { __oknoWrap } from "${u(Z, "wrap.ts")}"`;
239
249
  if (l === "pages") {
@@ -308,7 +318,7 @@ async function W(a, n) {
308
318
  function N(a) {
309
319
  return a.replace(".ts", "").replace(/-/g, "_");
310
320
  }
311
- function S(a) {
321
+ function b(a) {
312
322
  return a.replace(".ts", "").replace(/-/g, "_");
313
323
  }
314
324
  function O(a) {
@@ -323,7 +333,7 @@ async function tt(a, n = /* @__PURE__ */ new Set()) {
323
333
  if (c.length > 0) {
324
334
  const t = c[0], i = await v(u(o, t));
325
335
  for (const p of i) {
326
- const m = N(p), f = S(p), d = [], h = [];
336
+ const m = N(p), f = b(p), d = [], h = [];
327
337
  for (const g of c) {
328
338
  const w = u(o, g, p);
329
339
  if ($(w)) {
@@ -336,7 +346,7 @@ async function tt(a, n = /* @__PURE__ */ new Set()) {
336
346
  } else {
337
347
  const t = await v(o);
338
348
  for (const i of t) {
339
- const p = N(i), m = S(i), f = O(i), d = u(o, i);
349
+ const p = N(i), m = b(i), f = O(i), d = u(o, i);
340
350
  e.push(`import _${p} from "${d}"`), e.push(`export const ${m} = __oknoWrap(_${p}, "${f}")`), s.add(m);
341
351
  }
342
352
  }
@@ -367,12 +377,12 @@ async function et(a, n = /* @__PURE__ */ new Set()) {
367
377
  if (!$(p)) continue;
368
378
  const m = await v(p), f = [];
369
379
  for (const d of m) {
370
- const h = `_${i}_${N(d)}`, g = S(d), w = [], _ = [];
371
- for (const b of s) {
372
- const j = u(o, b, i, d);
380
+ const h = `_${i}_${N(d)}`, g = b(d), w = [], _ = [];
381
+ for (const x of s) {
382
+ const j = u(o, x, i, d);
373
383
  if ($(j)) {
374
- const x = `${h}_${b}`;
375
- w.push(`import ${x} from "${j}"`), b === t ? _.push(`...${x}`) : _.push(`${b}: { ...${h}_${t}, ...${x} }`);
384
+ const S = `${h}_${x}`;
385
+ w.push(`import ${S} from "${j}"`), x === t ? _.push(`...${S}`) : _.push(`${x}: { ...${h}_${t}, ...${S} }`);
376
386
  }
377
387
  }
378
388
  r.push(...w), r.push(`const ${h} = { ${_.join(", ")} }`), f.push(`__oknoWrap(${h}, "${i}.${g}")`);
@@ -400,7 +410,7 @@ async function ot(a, n = /* @__PURE__ */ new Set()) {
400
410
  if (c.length > 0) {
401
411
  const t = c[0], i = await v(u(o, t));
402
412
  for (const p of i) {
403
- const m = N(p), f = S(p), d = [], h = [];
413
+ const m = N(p), f = b(p), d = [], h = [];
404
414
  for (const g of c) {
405
415
  const w = u(o, g, p);
406
416
  if ($(w)) {
@@ -413,7 +423,7 @@ async function ot(a, n = /* @__PURE__ */ new Set()) {
413
423
  } else {
414
424
  const t = await v(o);
415
425
  for (const i of t) {
416
- const p = N(i), m = S(i), f = O(i), d = u(o, i);
426
+ const p = N(i), m = b(i), f = O(i), d = u(o, i);
417
427
  e.push(`import _${p} from "${d}"`), e.push(`export const ${m} = __oknoWrap(_${p}, "${f}")`), s.add(m);
418
428
  }
419
429
  }
@@ -1,4 +1,4 @@
1
- import { o as a } from "../plugin-rPgNLY_g.js";
1
+ import { o as a } from "../plugin-DvUn7pFQ.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;AAcpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CAyGpD"}
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;AAcpD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CAoHpD"}
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-alpha.4",
5
+ "version": "1.0.0-alpha.5",
6
6
  "homepage": "https://okno.build",
7
7
  "type": "module",
8
8
  "types": "./dist/index.d.ts",