okno 1.0.0-beta.17 → 1.0.0-beta.18
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/codegen/generate.d.ts.map +1 -1
- package/dist/{dispatch-DFdYV0q0.js → dispatch-DKZB5I61.js} +33 -28
- package/dist/editor/index.js +4560 -4511
- package/dist/index.js +1 -1
- package/dist/init.d.ts +14 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +162 -131
- package/dist/next/config.d.ts.map +1 -1
- package/dist/next/index.js +22 -19
- package/dist/plugin-HRVyik1g.js +482 -0
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/plugin-CPJpdY5k.js +0 -466
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAyHhE"}
|
|
@@ -2,7 +2,7 @@ import { join as g, dirname as M, resolve as ae, relative as G, sep as W } from
|
|
|
2
2
|
import { readdir as P, readFile as _e, writeFile as $e } from "node:fs/promises";
|
|
3
3
|
import { existsSync as _, readFileSync as S, readdirSync as ee, statSync as we, realpathSync as ke, writeFileSync as A, mkdirSync as E, unlinkSync as F, renameSync as be } from "node:fs";
|
|
4
4
|
import { fileURLToPath as Se } from "node:url";
|
|
5
|
-
import { p as J, b as Q, a as
|
|
5
|
+
import { p as J, b as Q, a as Oe, e as ve } from "./encode-DoojdsVU.js";
|
|
6
6
|
import { o as je } from "./order-bAkdncZC.js";
|
|
7
7
|
import { simpleGit as ie } from "simple-git";
|
|
8
8
|
import "./acorn-CZBJD705.js";
|
|
@@ -65,7 +65,12 @@ async function kt(e, n) {
|
|
|
65
65
|
"type OknoValue<T = unknown> = {",
|
|
66
66
|
' readonly "data-okno": string',
|
|
67
67
|
" toString(): string",
|
|
68
|
-
|
|
68
|
+
// NB: NO `[Symbol.toPrimitive]` in the TYPE. Svelte 5's element-attribute type
|
|
69
|
+
// carries a symbol index signature for attachments (`[key: symbol]: Attachment`),
|
|
70
|
+
// and a `(hint: string) => string` toPrimitive isn't assignable to it — so a
|
|
71
|
+
// `{...field}` spread would fail type-check on every element. The runtime keeps
|
|
72
|
+
// Symbol.toPrimitive (see runtime/wrap.ts) so `{field}` / String(field) still
|
|
73
|
+
// coerce; `toString()` covers the static string-coercion the type needs.
|
|
69
74
|
" onedit(callback: (value: T) => void): () => void",
|
|
70
75
|
" /** Re-root reads at a locale; no-op when unset or on the default locale. Returns the SAME wrapped shape (not `this`, which would drop array element types). */",
|
|
71
76
|
" locale(code?: string | null): OknoWrapped<T>",
|
|
@@ -108,7 +113,7 @@ async function kt(e, n) {
|
|
|
108
113
|
([, k]) => k?.type === "reference" && typeof k.collection == "string" && s.has(k.collection)
|
|
109
114
|
), $ = p.filter(([, k]) => k?.type === "enum"), w = '"created" | "updated"';
|
|
110
115
|
if (y.length === 0 && $.length === 0) return `OknoWrapped<Omit<${d}, ${w}>> & OknoMeta`;
|
|
111
|
-
const
|
|
116
|
+
const O = `${[...y, ...$].map(([k]) => `"${k}"`).join(" | ")} | ${w}`, v = [
|
|
112
117
|
...y.map(([k, b]) => {
|
|
113
118
|
const R = `typeof import("./collections/${b.collection}/${s.get(b.collection)}").default`;
|
|
114
119
|
return `${k}: ${b.multiple ? `${R}[]` : R}`;
|
|
@@ -118,7 +123,7 @@ async function kt(e, n) {
|
|
|
118
123
|
return `${k}: ${b.multiple ? `${L}[]` : L}`;
|
|
119
124
|
})
|
|
120
125
|
].join("; ");
|
|
121
|
-
return `OknoWrapped<Omit<${d}, ${
|
|
126
|
+
return `OknoWrapped<Omit<${d}, ${O}> & { ${v} }> & OknoMeta`;
|
|
122
127
|
}, [u, f, o] = await Promise.all([
|
|
123
128
|
X(n, "pages"),
|
|
124
129
|
X(n, "globals"),
|
|
@@ -328,7 +333,7 @@ function he(e) {
|
|
|
328
333
|
function V(e) {
|
|
329
334
|
return e.replace(".ts", "");
|
|
330
335
|
}
|
|
331
|
-
function
|
|
336
|
+
function Ot(e) {
|
|
332
337
|
const n = g(e, "schema.ts");
|
|
333
338
|
let t = [], s = "";
|
|
334
339
|
if (_(n))
|
|
@@ -370,7 +375,7 @@ function vt(e) {
|
|
|
370
375
|
].join(`
|
|
371
376
|
`);
|
|
372
377
|
}
|
|
373
|
-
async function
|
|
378
|
+
async function vt(e) {
|
|
374
379
|
const n = g(e, "strings.ts");
|
|
375
380
|
if (!_(n))
|
|
376
381
|
return [
|
|
@@ -426,15 +431,15 @@ async function jt(e, n = /* @__PURE__ */ new Set()) {
|
|
|
426
431
|
r.push(`import _${h} from "${$}"`), r.push(`export const ${p} = __oknoWrap(${u(h, y)}, "${y}")`), f.add(p);
|
|
427
432
|
continue;
|
|
428
433
|
}
|
|
429
|
-
const w = [`import _${h}_default from "${$}"`],
|
|
430
|
-
for (const
|
|
431
|
-
const k = g(t,
|
|
434
|
+
const w = [`import _${h}_default from "${$}"`], O = [];
|
|
435
|
+
for (const v of c) {
|
|
436
|
+
const k = g(t, v, d);
|
|
432
437
|
if (_(k)) {
|
|
433
|
-
const b = Z(
|
|
434
|
-
w.push(`import _${h}_${b} from "${k}"`),
|
|
438
|
+
const b = Z(v);
|
|
439
|
+
w.push(`import _${h}_${b} from "${k}"`), O.push(`"${v}": _${h}_${b}`);
|
|
435
440
|
}
|
|
436
441
|
}
|
|
437
|
-
r.push(...w), r.push(`const _${h} = __oknoLocalize(_${h}_default, { ${
|
|
442
|
+
r.push(...w), r.push(`const _${h} = __oknoLocalize(_${h}_default, { ${O.join(", ")} })`), r.push(`export const ${p} = __oknoWrap(${u(h, y)}, "${y}")`), f.add(p);
|
|
438
443
|
}
|
|
439
444
|
}
|
|
440
445
|
for (const o of n)
|
|
@@ -468,7 +473,7 @@ async function Tt(e, n = /* @__PURE__ */ new Set(), t = !1) {
|
|
|
468
473
|
m && d.push(`import __schema from "${c}"`);
|
|
469
474
|
const h = [];
|
|
470
475
|
for (const p of u) {
|
|
471
|
-
const y = g(s, p), $ = je(await ne(y), V, o[p]), w = p.replace(/-/g, "_"),
|
|
476
|
+
const y = g(s, p), $ = je(await ne(y), V, o[p]), w = p.replace(/-/g, "_"), O = t && i.has(p), v = [];
|
|
472
477
|
for (const k of $) {
|
|
473
478
|
const b = `_${w}_${se(k)}`, R = V(k), B = g(y, k);
|
|
474
479
|
if (l.length === 0)
|
|
@@ -484,15 +489,15 @@ async function Tt(e, n = /* @__PURE__ */ new Set(), t = !1) {
|
|
|
484
489
|
}
|
|
485
490
|
d.push(...L), d.push(`const ${b} = __oknoLocalize(${b}_default, { ${x.join(", ")} })`);
|
|
486
491
|
}
|
|
487
|
-
|
|
492
|
+
v.push({ varName: b, itemName: R });
|
|
488
493
|
}
|
|
489
|
-
d.push(`const __oknoRaw_${w} = [${
|
|
494
|
+
d.push(`const __oknoRaw_${w} = [${v.map((k) => k.varName).join(", ")}]`), h.push({ name: p, safe: w, draftsOn: O, items: v });
|
|
490
495
|
}
|
|
491
496
|
m && d.push(`const __oknoNs = { ${h.map((p) => `${p.safe}: __oknoRaw_${p.safe}`).join(", ")} }`);
|
|
492
497
|
for (const p of h) {
|
|
493
498
|
const y = (w) => {
|
|
494
|
-
const
|
|
495
|
-
return `__oknoWrap(${m ? `__oknoResolveEnums(__oknoResolveRefs(${w.varName}, ${
|
|
499
|
+
const O = `__schema?.collections?.["${p.name}"]?.fields`;
|
|
500
|
+
return `__oknoWrap(${m ? `__oknoResolveEnums(__oknoResolveRefs(${w.varName}, ${O}, __oknoNs, ${f}), ${O}, ${f})` : w.varName}, "${p.name}.${w.itemName}")`;
|
|
496
501
|
}, $ = p.draftsOn ? `[${p.items.map((w) => `[${w.varName}, ${y(w)}]`).join(", ")}].filter((e) => e[0]?.status !== "draft").map((e) => e[1])` : `[${p.items.map(y).join(", ")}]`;
|
|
497
502
|
d.push(`export const ${p.safe} = ${$}`);
|
|
498
503
|
}
|
|
@@ -521,15 +526,15 @@ async function At(e, n = /* @__PURE__ */ new Set()) {
|
|
|
521
526
|
r.push(`import _${h} from "${$}"`), r.push(`export const ${p} = __oknoWrap(${u(h, y)}, "${y}")`), f.add(p);
|
|
522
527
|
continue;
|
|
523
528
|
}
|
|
524
|
-
const w = [`import _${h}_default from "${$}"`],
|
|
525
|
-
for (const
|
|
526
|
-
const k = g(t,
|
|
529
|
+
const w = [`import _${h}_default from "${$}"`], O = [];
|
|
530
|
+
for (const v of c) {
|
|
531
|
+
const k = g(t, v, d);
|
|
527
532
|
if (_(k)) {
|
|
528
|
-
const b = Z(
|
|
529
|
-
w.push(`import _${h}_${b} from "${k}"`),
|
|
533
|
+
const b = Z(v);
|
|
534
|
+
w.push(`import _${h}_${b} from "${k}"`), O.push(`"${v}": _${h}_${b}`);
|
|
530
535
|
}
|
|
531
536
|
}
|
|
532
|
-
r.push(...w), r.push(`const _${h} = __oknoLocalize(_${h}_default, { ${
|
|
537
|
+
r.push(...w), r.push(`const _${h} = __oknoLocalize(_${h}_default, { ${O.join(", ")} })`), r.push(`export const ${p} = __oknoWrap(${u(h, y)}, "${y}")`), f.add(p);
|
|
533
538
|
}
|
|
534
539
|
}
|
|
535
540
|
for (const o of n)
|
|
@@ -769,7 +774,7 @@ function T(e) {
|
|
|
769
774
|
return { schema: s, header: t };
|
|
770
775
|
}
|
|
771
776
|
function ct(e, n, t) {
|
|
772
|
-
A(g(e, "schema.ts"),
|
|
777
|
+
A(g(e, "schema.ts"), Oe(n, t));
|
|
773
778
|
}
|
|
774
779
|
function ft(e, n, t, s, a) {
|
|
775
780
|
const r = g(e, n), l = new Set(a), u = [];
|
|
@@ -840,7 +845,7 @@ async function Pt(e, n) {
|
|
|
840
845
|
if (!o || !i) return f(400, { error: "Missing path or content" });
|
|
841
846
|
const d = N(e, o);
|
|
842
847
|
if (!d) return f(400, { error: "Invalid path" });
|
|
843
|
-
const h =
|
|
848
|
+
const h = ve(i, { now: (/* @__PURE__ */ new Date()).toISOString(), author: m || ut(e), created: c });
|
|
844
849
|
return E(M(d), { recursive: !0 }), z(d), A(d, h), r(o, d), f(200, { ok: !0, commit: { fileSha: "" } });
|
|
845
850
|
}
|
|
846
851
|
if (t === "POST" && s === "content/delete") {
|
|
@@ -891,7 +896,7 @@ async function Pt(e, n) {
|
|
|
891
896
|
He(h, o, i, c), u(h, p);
|
|
892
897
|
const y = m && typeof m == "object" ? m : {}, $ = Array.isArray(d) ? d : [];
|
|
893
898
|
if (Object.keys(y).length > 0 || $.length > 0)
|
|
894
|
-
for (const { rel: w, abs:
|
|
899
|
+
for (const { rel: w, abs: O } of ft(e, o, i, y, $)) r(w, O);
|
|
895
900
|
return f(200, { ok: !0, commit: { fileSha: "" }, schema: h });
|
|
896
901
|
}
|
|
897
902
|
if (t === "POST" && s === "schema/set-locales") {
|
|
@@ -1037,8 +1042,8 @@ export {
|
|
|
1037
1042
|
Tt as a,
|
|
1038
1043
|
jt as b,
|
|
1039
1044
|
At as c,
|
|
1040
|
-
|
|
1041
|
-
|
|
1045
|
+
vt as d,
|
|
1046
|
+
Ot as e,
|
|
1042
1047
|
St as f,
|
|
1043
1048
|
bt as g,
|
|
1044
1049
|
kt as h,
|