okno 1.0.0-beta.21 → 1.0.0-beta.23

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.
@@ -1,10 +1,10 @@
1
1
  import { extname as z, join as h, dirname as T, relative as N, sep as D, resolve as g } from "node:path";
2
2
  import { existsSync as O, readFileSync as U, mkdirSync as M, writeFileSync as B, cpSync as Y } from "node:fs";
3
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";
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-Ce0p8-Vu.js";
5
5
  import { simpleGit as R } from "simple-git";
6
6
  import "node:child_process";
7
- import "./acorn-CZBJD705.js";
7
+ import "./parse-tlTHgSSs.js";
8
8
  function F(n, r, e) {
9
9
  n.statusCode = r, n.setHeader("Content-Type", "application/json"), n.setHeader("Cache-Control", "no-store"), n.end(JSON.stringify(e));
10
10
  }
@@ -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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A;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"}
@@ -32,21 +32,21 @@ 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 k(t, r = "") {
35
+ function j(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) : j(t) ? t.text ?? "" : J(t) ? t.name ?? "" : "";
41
+ return typeof t != "object" ? String(t) : k(t) ? t.text ?? "" : K(t) ? t.name ?? "" : "";
42
42
  }
43
43
  function v(t) {
44
44
  return typeof t == "object" && t !== null && !Array.isArray(t) && "src" in t;
45
45
  }
46
- function j(t) {
46
+ function k(t) {
47
47
  return typeof t == "object" && t !== null && !Array.isArray(t) && "url" in t && "text" in t && "external" in t;
48
48
  }
49
- function J(t) {
49
+ function K(t) {
50
50
  return typeof t != "object" || t === null || Array.isArray(t) ? !1 : Object.keys(t).length === 2 && "name" in t && "value" in t;
51
51
  }
52
52
  function P(t, r) {
@@ -78,7 +78,7 @@ function ot(t) {
78
78
  }
79
79
  return r;
80
80
  }
81
- const w = "string:", K = { slots: {} };
81
+ const w = "string:", J = { slots: {} };
82
82
  function q(t, r) {
83
83
  try {
84
84
  return new Intl.PluralRules(t || void 0).select(r);
@@ -117,15 +117,15 @@ function it(t, r, i) {
117
117
  }
118
118
  return b(t, "", { slots: c, locale: i, defaultLocale: i });
119
119
  }
120
- function b(t, r = "", i = K) {
120
+ function b(t, r = "", i = J) {
121
121
  const c = { __raw: t, __path: r };
122
122
  return new Proxy(c, {
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 () => k(n.__raw, n.__path);
126
+ return () => j(n.__raw, n.__path);
127
127
  if (e === Symbol.iterator) {
128
- const u = k(n.__raw, n.__path);
128
+ const u = j(n.__raw, n.__path);
129
129
  return function* () {
130
130
  yield u;
131
131
  };
@@ -179,6 +179,7 @@ function d(t, r, i) {
179
179
  if (e === "data-okno") return n.__path;
180
180
  if (e === "children") return;
181
181
  if (e === "slot") return { "data-okno-item": n.__slot ?? n.__path };
182
+ if (e === "data-okno-item") return n.__slot ?? void 0;
182
183
  if (e === "exists") return n.__raw !== null && n.__raw !== void 0;
183
184
  if (e === "image" && v(n.__raw)) {
184
185
  const s = n.__raw;
@@ -191,9 +192,9 @@ function d(t, r, i) {
191
192
  };
192
193
  }
193
194
  if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
194
- return () => k(n.__raw, n.__path);
195
+ return () => j(n.__raw, n.__path);
195
196
  if (e === Symbol.iterator) {
196
- const s = k(n.__raw, n.__path);
197
+ const s = j(n.__raw, n.__path);
197
198
  return function* () {
198
199
  yield s;
199
200
  };
@@ -217,7 +218,7 @@ function d(t, r, i) {
217
218
  ) : d(u, n.__path);
218
219
  };
219
220
  const o = n.__raw, f = n.__path ? `${n.__path}.${String(e)}` : String(e);
220
- if (j(o) && typeof e == "string") {
221
+ if (k(o) && typeof e == "string") {
221
222
  if (e === "href") return o.url ?? "";
222
223
  if (e === "target" && o.external) return "_blank";
223
224
  if (e === "rel" && o.external) return "noopener noreferrer";
@@ -236,8 +237,8 @@ function d(t, r, i) {
236
237
  },
237
238
  // For spread: expose data-okno, plus all keys for file objects (src, alt, width, height, etc.)
238
239
  ownKeys(n) {
239
- const e = n.__raw;
240
- 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"];
240
+ const e = n.__raw, o = n.__slot != null ? ["data-okno-item"] : [];
241
+ return v(e) ? [...Object.keys(e).filter((f) => f !== "focal"), "data-okno", ...o] : k(e) ? e.external ? ["href", "target", "rel", "data-okno", ...o] : ["href", "data-okno", ...o] : ["data-okno", ...o];
241
242
  },
242
243
  getOwnPropertyDescriptor(n, e) {
243
244
  if (e === "data-okno")
@@ -246,6 +247,8 @@ function d(t, r, i) {
246
247
  enumerable: !0,
247
248
  configurable: !0
248
249
  };
250
+ if (e === "data-okno-item")
251
+ return n.__slot == null ? void 0 : { value: n.__slot, enumerable: !0, configurable: !0 };
249
252
  const o = n.__raw;
250
253
  if (v(o) && typeof e == "string" && e in o && e !== "focal")
251
254
  return {
@@ -253,7 +256,7 @@ function d(t, r, i) {
253
256
  enumerable: !0,
254
257
  configurable: !0
255
258
  };
256
- if (j(o) && (e === "href" || o.external && (e === "target" || e === "rel")))
259
+ if (k(o) && (e === "href" || o.external && (e === "target" || e === "rel")))
257
260
  return { value: void 0, enumerable: !0, configurable: !0 };
258
261
  },
259
262
  has(n, e) {
@@ -353,8 +356,8 @@ function st(t, r, i = []) {
353
356
  }
354
357
  return o;
355
358
  }
356
- const m = "data-okno-item", A = "data-okno", H = [A, m];
357
- function g(t, r, i, c = H) {
359
+ const m = "data-okno-item", g = "data-okno", H = [g, m];
360
+ function A(t, r, i, c = H) {
358
361
  if (r === i) return;
359
362
  const n = (e) => {
360
363
  for (const o of c) {
@@ -381,8 +384,8 @@ function W(t) {
381
384
  }));
382
385
  }
383
386
  function V(t) {
384
- const r = Array.from(t.querySelectorAll(`[${A}]`));
385
- return t.hasAttribute(A) && r.unshift(t), r;
387
+ const r = Array.from(t.querySelectorAll(`[${g}]`));
388
+ return t.hasAttribute(g) && r.unshift(t), r;
386
389
  }
387
390
  function F(t) {
388
391
  for (const r of V(t))
@@ -390,7 +393,7 @@ function F(t) {
390
393
  }
391
394
  function G(t, r) {
392
395
  for (const i of V(t)) {
393
- const c = i.getAttribute(A);
396
+ const c = i.getAttribute(g);
394
397
  c && c in r && i.children.length === 0 && (i.textContent = r[c] ?? "");
395
398
  }
396
399
  }
@@ -426,7 +429,7 @@ function Q(t, r, i, c) {
426
429
  const o = n.slice(), [f] = o.splice(i, 1);
427
430
  o.splice(c, 0, f);
428
431
  const s = o.map((l) => l.getAttribute(m));
429
- o.forEach((l, a) => g(l, s[a], `${r}.${a}`));
432
+ o.forEach((l, a) => A(l, s[a], `${r}.${a}`));
430
433
  const u = n[e - 1].nextSibling;
431
434
  for (const l of o) t.parent.insertBefore(l, u);
432
435
  }
@@ -434,15 +437,15 @@ function tt(t, r, i) {
434
437
  const c = t.wrappers;
435
438
  if (!(i < 0 || i >= c.length)) {
436
439
  c[i].remove();
437
- for (let n = i + 1; n < c.length; n++) g(c[n], `${r}.${n}`, `${r}.${n - 1}`);
440
+ for (let n = i + 1; n < c.length; n++) A(c[n], `${r}.${n}`, `${r}.${n - 1}`);
438
441
  }
439
442
  }
440
443
  function et(t, r, i, c) {
441
444
  const n = t.wrappers, e = n.length;
442
445
  if (e === 0) return;
443
446
  const o = Math.max(0, Math.min(i.index ?? e, e)), f = o < e ? o : e - 1, s = n[f].getAttribute(m), u = n[f].cloneNode(!0);
444
- for (let a = e - 1; a >= o; a--) g(n[a], `${r}.${a}`, `${r}.${a + 1}`);
445
- 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);
447
+ for (let a = e - 1; a >= o; a--) A(n[a], `${r}.${a}`, `${r}.${a + 1}`);
448
+ A(u, s, `${r}.${o}`), i.remap && A(u, i.remap.from, i.remap.to, [g]), i.values ? G(u, i.values) : F(u), u.style.viewTransitionName = "", c(u);
446
449
  const l = o < e ? n[o] : n[e - 1].nextSibling;
447
450
  t.parent.insertBefore(u, l);
448
451
  }
@@ -1,4 +1,4 @@
1
- import { o as a } from "../plugin-DcdYJY8n.js";
1
+ import { o as a } from "../plugin-TY1948ID.js";
2
2
  export {
3
3
  a as okno
4
4
  };
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.21",
5
+ "version": "1.0.0-beta.23",
6
6
  "homepage": "https://okno.build",
7
7
  "type": "module",
8
8
  "types": "./dist/index.d.ts",
@@ -440,6 +440,14 @@ export function __oknoWrap(data: unknown, prefix: string, slot?: string): any {
440
440
  // field array position, so structural edits (reorder/add/remove) hit the right list.
441
441
  if (prop === "slot") return { "data-okno-item": target.__slot ?? target.__path }
442
442
 
443
+ // `{...item}` on an ARRAY member carries the reorder slot too — so a LEAF
444
+ // multiple (media / link / text) needs no separate `{...item.slot}`: one
445
+ // spread = edit hook + reorder. Only present on array items (`__slot` set);
446
+ // a scalar / single field omits it, so it never lands on a non-list
447
+ // element or collides with HTML attrs. Block wrappers still use `.slot`
448
+ // explicitly (their `{...item}` isn't spread — it'd dump field keys).
449
+ if (prop === "data-okno-item") return target.__slot ?? undefined
450
+
443
451
  // `.exists` — true when this field/reference actually holds a value.
444
452
  // Every field read returns a (truthy) proxy, so `entry.parent ? … : …`
445
453
  // and `String(entry.parent.slug)` can't tell "unset" from "set" — an unset
@@ -603,18 +611,22 @@ export function __oknoWrap(data: unknown, prefix: string, slot?: string): any {
603
611
  // For spread: expose data-okno, plus all keys for file objects (src, alt, width, height, etc.)
604
612
  ownKeys(target) {
605
613
  const raw = target.__raw
614
+ // Array members also spread `data-okno-item` (the reorder slot), so a leaf
615
+ // `{...item}` gives edit + reorder in one spread. `__slot` is unset on
616
+ // scalars / single fields, so they never carry it.
617
+ const slotKey = target.__slot != null ? ["data-okno-item"] : []
606
618
  if (isMediaObject(raw)) {
607
619
  // `focal` ({x,y}%) is editor metadata, not an HTML attribute — keep it
608
620
  // OFF the spread so `<img {...cover}>` stays clean (it's still readable
609
621
  // as `cover.focal`). Everything else (src/alt/width/height) spreads.
610
- return [...Object.keys(raw).filter((k) => k !== "focal"), "data-okno"]
622
+ return [...Object.keys(raw).filter((k) => k !== "focal"), "data-okno", ...slotKey]
611
623
  }
612
624
  if (isLinkObject(raw)) {
613
625
  return raw.external
614
- ? ["href", "target", "rel", "data-okno"]
615
- : ["href", "data-okno"]
626
+ ? ["href", "target", "rel", "data-okno", ...slotKey]
627
+ : ["href", "data-okno", ...slotKey]
616
628
  }
617
- return ["data-okno"]
629
+ return ["data-okno", ...slotKey]
618
630
  },
619
631
 
620
632
  getOwnPropertyDescriptor(target, prop) {
@@ -625,6 +637,11 @@ export function __oknoWrap(data: unknown, prefix: string, slot?: string): any {
625
637
  configurable: true,
626
638
  }
627
639
  }
640
+ // Reorder slot — enumerable ONLY on array members (mirrors ownKeys).
641
+ if (prop === "data-okno-item") {
642
+ if (target.__slot == null) return undefined
643
+ return { value: target.__slot, enumerable: true, configurable: true }
644
+ }
628
645
  const raw = target.__raw
629
646
  if (isMediaObject(raw) && typeof prop === "string" && prop in raw && prop !== "focal") {
630
647
  return {
@@ -1,80 +0,0 @@
1
- import { p as s } from "./acorn-CZBJD705.js";
2
- function a(o) {
3
- const e = o;
4
- switch (e.type) {
5
- case "Literal": {
6
- if (e.regex) throw new Error("regex literals are not allowed");
7
- return e.value;
8
- }
9
- case "TemplateLiteral": {
10
- if (e.expressions.length > 0) throw new Error("template expressions are not allowed");
11
- return e.quasis.map((r) => r.value.cooked).join("");
12
- }
13
- case "UnaryExpression": {
14
- if ((e.operator === "-" || e.operator === "+") && e.argument?.type === "Literal" && typeof e.argument.value == "number")
15
- return e.operator === "-" ? -e.argument.value : +e.argument.value;
16
- throw new Error(`unary operator ${e.operator} is not allowed`);
17
- }
18
- case "Identifier": {
19
- if (e.name === "undefined") return;
20
- throw new Error(`identifier ${e.name} is not allowed`);
21
- }
22
- case "ArrayExpression":
23
- return e.elements.map((r) => {
24
- if (r === null) throw new Error("array holes are not allowed");
25
- if (r.type === "SpreadElement") throw new Error("spread is not allowed");
26
- return a(r);
27
- });
28
- case "ObjectExpression": {
29
- const r = {};
30
- for (const t of e.properties) {
31
- if (t.type !== "Property") throw new Error("spread is not allowed");
32
- if (t.computed) throw new Error("computed keys are not allowed");
33
- if (t.kind !== "init") throw new Error("getters/setters are not allowed");
34
- if (t.method) throw new Error("methods are not allowed");
35
- let n;
36
- if (t.key.type === "Identifier") n = t.key.name;
37
- else if (t.key.type === "Literal") n = String(t.key.value);
38
- else throw new Error("unsupported object key");
39
- r[n] = a(t.value);
40
- }
41
- return r;
42
- }
43
- default:
44
- throw new Error(`unsupported node: ${e.type}`);
45
- }
46
- }
47
- function l(o) {
48
- try {
49
- let e = o.trim();
50
- const r = e.match(/export\s+default\s+([\s\S]+)/);
51
- if (!r)
52
- return console.warn("Could not find export default"), {};
53
- e = r[1].trim(), e.endsWith(";") && (e = e.slice(0, -1)), e = e.replace(/\s+satisfies\s+\w+\s*$/, ""), e = e.replace(/\s+as\s+\w+\s*$/, "");
54
- const t = s(`(${e})`, 0, { ecmaVersion: "latest" });
55
- return a(t);
56
- } catch (e) {
57
- return console.error("Failed to parse TypeScript export:", e), {};
58
- }
59
- }
60
- function p(o, e) {
61
- const r = { date: e.now, author: e.author }, t = { ...o, created: e.created ?? r, updated: r };
62
- return `export default ${JSON.stringify(t, null, " ")}
63
- `;
64
- }
65
- function u(o, e = `import type { Schema } from "okno"
66
-
67
- `) {
68
- return `${e}export default ${JSON.stringify(o, null, " ")} satisfies Schema
69
- `;
70
- }
71
- function d(o) {
72
- return `export default ${JSON.stringify(o, null, " ")}
73
- `;
74
- }
75
- export {
76
- u as a,
77
- d as b,
78
- p as e,
79
- l as p
80
- };