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.
@@ -1,14 +1,14 @@
1
1
  import { join as _, relative as H, sep as U, dirname as N, resolve as ue } from "node:path";
2
- import { readdir as E, readFile as be, writeFile as Se } from "node:fs/promises";
3
- import { existsSync as $, readFileSync as v, readdirSync as se, statSync as Oe, realpathSync as ve, writeFileSync as R, mkdirSync as W, unlinkSync as B, renameSync as je } from "node:fs";
2
+ import { readdir as E, readFile as we, writeFile as be } from "node:fs/promises";
3
+ import { existsSync as $, readFileSync as v, readdirSync as se, statSync as Se, realpathSync as Oe, writeFileSync as R, mkdirSync as W, unlinkSync as B, renameSync as ve } from "node:fs";
4
4
  import { execSync as oe } from "node:child_process";
5
- import { fileURLToPath as Ae } from "node:url";
5
+ import { fileURLToPath as je } from "node:url";
6
6
  import { p as Z } from "./parse-tlTHgSSs.js";
7
- import { o as Te } from "./order-bAkdncZC.js";
7
+ import { o as Ae } from "./order-bAkdncZC.js";
8
8
  import { simpleGit as fe } from "simple-git";
9
- import { b as ee, a as xe, e as Re } from "./encode-BfJY0Xy5.js";
10
- import { applyKeyChanges as me, setStringsSchema as Pe, saveFields as Ee, setLocales as Me, setName as Ne, setUrl as Ie, renameSlug as We, reorderKind as Fe, setLayout as Le, setCollectionOrder as Ue, setDrafts as Ce, deleteSchemaEntry as ze, scaffoldEntry as Je, fieldsToContent as Ve, EngineError as Be } from "./engine/index.js";
11
- const Ge = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), Ke = /* @__PURE__ */ new Set([
9
+ import { b as ee, a as Te, e as xe } from "./encode-BfJY0Xy5.js";
10
+ import { applyKeyChanges as me, setStringsSchema as Re, saveFields as Pe, setLocales as Ee, setName as Me, setUrl as Ne, renameSlug as Ie, reorderKind as We, setLayout as Fe, setCollectionOrder as Le, setDrafts as Ue, deleteSchemaEntry as Ce, scaffoldEntry as ze, fieldsToContent as Je, EngineError as Ve } from "./engine/index.js";
11
+ const Be = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), Ge = /* @__PURE__ */ new Set([
12
12
  "node_modules",
13
13
  ".astro",
14
14
  ".svelte-kit",
@@ -22,16 +22,16 @@ const Ge = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", "
22
22
  ]);
23
23
  async function Y(e, n) {
24
24
  const s = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']okno[:/]${n}["']`, "g"), i = /* @__PURE__ */ new Set();
25
- async function u(l) {
25
+ async function u(c) {
26
26
  let p;
27
27
  try {
28
- p = await E(l, { withFileTypes: !0 });
28
+ p = await E(c, { withFileTypes: !0 });
29
29
  } catch {
30
30
  return;
31
31
  }
32
32
  for (const f of p) {
33
- if (f.name.startsWith(".") && f.name !== "." || Ke.has(f.name)) continue;
34
- const a = _(l, f.name);
33
+ if (f.name.startsWith(".") && f.name !== "." || Ge.has(f.name)) continue;
34
+ const a = _(c, f.name);
35
35
  if (f.isDirectory()) {
36
36
  await u(a);
37
37
  continue;
@@ -39,10 +39,10 @@ async function Y(e, n) {
39
39
  const t = f.name.lastIndexOf(".");
40
40
  if (t === -1) continue;
41
41
  const r = f.name.slice(t);
42
- if (!Ge.has(r)) continue;
42
+ if (!Be.has(r)) continue;
43
43
  let o;
44
44
  try {
45
- o = await be(a, "utf-8");
45
+ o = await we(a, "utf-8");
46
46
  } catch {
47
47
  continue;
48
48
  }
@@ -59,7 +59,7 @@ async function Y(e, n) {
59
59
  return await u(e), i;
60
60
  }
61
61
  async function bt(e, n) {
62
- const s = await tt(e), i = new Map(s.map((c) => [c.name, c.first])), u = De(e), l = [
62
+ const s = await et(e), i = new Map(s.map((l) => [l.name, l.first])), u = Ye(e), c = [
63
63
  "// Auto-generated by okno. Do not edit.",
64
64
  "",
65
65
  "/** A wrapped content value that can be spread onto elements and rendered as text. */",
@@ -120,31 +120,31 @@ async function bt(e, n) {
120
120
  " readonly updated: OknoWrapped<OknoStamp>",
121
121
  "}",
122
122
  ""
123
- ], p = ([, c]) => c?.type === "reference" && typeof c.collection == "string" && i.has(c.collection), f = ([, c]) => c?.type === "enum", a = ([c, g]) => {
123
+ ], p = ([, l]) => l?.type === "reference" && typeof l.collection == "string" && i.has(l.collection), f = ([, l]) => l?.type === "enum", a = ([l, g]) => {
124
124
  const k = (Array.isArray(g?.options) ? g.options : []).map((w) => typeof w == "string" ? w : w?.value).filter((w) => typeof w == "string"), S = `{ name: string; value: ${k.length ? k.map((w) => JSON.stringify(w)).join(" | ") : "string"} }`;
125
- return `${c}: ${g.multiple ? `${S}[]` : S}`;
126
- }, t = (c) => `typeof import("./collections/${c}/${i.get(c)}").default`, r = (c) => {
127
- const g = u?.collections?.[c]?.url;
125
+ return `${l}: ${g.multiple ? `${S}[]` : S}`;
126
+ }, t = (l) => `typeof import("./collections/${l}/${i.get(l)}").default`, r = (l) => {
127
+ const g = u?.collections?.[l]?.url;
128
128
  return typeof g == "string" && g.trim() ? " & { href: string }" : "";
129
- }, o = (c, g) => {
130
- const k = t(c), b = u?.collections?.[c]?.fields, S = b ? Object.entries(b) : [], w = S.filter(p), O = S.filter(f);
131
- if (w.length === 0 && O.length === 0) return `${k}${r(c)}`;
132
- const j = [...w, ...O].map(([P]) => `"${P}"`).join(" | "), A = new Set(g).add(c), C = [
129
+ }, o = (l, g) => {
130
+ const k = t(l), b = u?.collections?.[l]?.fields, S = b ? Object.entries(b) : [], w = S.filter(p), O = S.filter(f);
131
+ if (w.length === 0 && O.length === 0) return `${k}${r(l)}`;
132
+ const j = [...w, ...O].map(([P]) => `"${P}"`).join(" | "), A = new Set(g).add(l), C = [
133
133
  ...w.map(([P, I]) => {
134
134
  const M = I.collection, x = g.has(M) ? t(M) : o(M, A);
135
135
  return `${P}: ${I.multiple ? `(${x})[]` : x}`;
136
136
  }),
137
137
  ...O.map(a)
138
138
  ].join("; ");
139
- return `Omit<${k}, ${j}> & { ${C} }${r(c)}`;
140
- }, m = (c, g, k) => {
141
- const b = `typeof import("${k}").default`, S = u?.[c]?.[g]?.fields, w = S ? Object.entries(S) : [], O = w.filter(p), j = w.filter(f), A = '"created" | "updated"', C = c === "collections" ? r(g) : "";
139
+ return `Omit<${k}, ${j}> & { ${C} }${r(l)}`;
140
+ }, m = (l, g, k) => {
141
+ const b = `typeof import("${k}").default`, S = u?.[l]?.[g]?.fields, w = S ? Object.entries(S) : [], O = w.filter(p), j = w.filter(f), A = '"created" | "updated"', C = l === "collections" ? r(g) : "";
142
142
  if (O.length === 0 && j.length === 0)
143
143
  return `OknoWrapped<Omit<${b}, ${A}>${C}> & OknoMeta`;
144
- const P = c === "collections" ? /* @__PURE__ */ new Set([g]) : /* @__PURE__ */ new Set(), I = `${[...O, ...j].map(([x]) => `"${x}"`).join(" | ")} | ${A}`, M = [
144
+ const P = l === "collections" ? /* @__PURE__ */ new Set([g]) : /* @__PURE__ */ new Set(), I = `${[...O, ...j].map(([x]) => `"${x}"`).join(" | ")} | ${A}`, M = [
145
145
  ...O.map(([x, V]) => {
146
- const z = V.collection, le = P.has(z) ? t(z) : o(z, P);
147
- return `${x}: ${V.multiple ? `(${le})[]` : le}`;
146
+ const z = V.collection, ce = P.has(z) ? t(z) : o(z, P);
147
+ return `${x}: ${V.multiple ? `(${ce})[]` : ce}`;
148
148
  }),
149
149
  ...j.map(a)
150
150
  ].join("; ");
@@ -154,25 +154,25 @@ async function bt(e, n) {
154
154
  Y(n, "globals"),
155
155
  Y(n, "collections")
156
156
  ]);
157
- l.push(
157
+ c.push(
158
158
  ...de("okno:pages", "pages", await te(_(e, "pages")), d, m)
159
- ), l.push(...Ye(s, y, m)), l.push(
159
+ ), c.push(...Qe(s, y, m)), c.push(
160
160
  ...de("okno:globals", "globals", await te(_(e, "globals")), h, m)
161
- ), l.push(...Xe(et(e), Qe(u))), l.push(...He()), l.push(...Ze());
162
- for (const c of ["pages", "collections", "globals", "locales", "strings", "content"])
163
- l.push(`declare module "okno/${c}" {`, ` export * from "okno:${c}";`, "}", "");
164
- await Se(_(e, "modules.d.ts"), l.join(`
161
+ ), c.push(...Ze(De(e), qe(u))), c.push(...Ke()), c.push(...He());
162
+ for (const l of ["pages", "collections", "globals", "locales", "strings", "content"])
163
+ c.push(`declare module "okno/${l}" {`, ` export * from "okno:${l}";`, "}", "");
164
+ await be(_(e, "modules.d.ts"), c.join(`
165
165
  `));
166
166
  }
167
167
  function de(e, n, s, i, u) {
168
- const l = /* @__PURE__ */ new Set(), p = [];
168
+ const c = /* @__PURE__ */ new Set(), p = [];
169
169
  for (const f of s)
170
- p.push(` export const ${f}: ${u(n, f, `./${n}/${f}`)}`), l.add(f);
170
+ p.push(` export const ${f}: ${u(n, f, `./${n}/${f}`)}`), c.add(f);
171
171
  for (const f of i)
172
- l.has(f) || p.push(` export const ${f}: OknoUnscaffolded`);
172
+ c.has(f) || p.push(` export const ${f}: OknoUnscaffolded`);
173
173
  return [`declare module "${e}" {`, ...p, "}", ""];
174
174
  }
175
- function He() {
175
+ function Ke() {
176
176
  return [
177
177
  'declare module "okno:locales" {',
178
178
  ' /** A configured language. `id` is the BCP-47 tag (e.g. "zh-Hant"), `name` the display label, `slug` the URL segment you map into routing. `link(url)` returns this page\'s hreflang <link> descriptor — spread onto a <link> (pass Astro.url for an absolute href). Okno owns no routing; you map these. */',
@@ -188,7 +188,7 @@ function He() {
188
188
  ""
189
189
  ];
190
190
  }
191
- function Ze() {
191
+ function He() {
192
192
  return [
193
193
  'declare module "okno:content" {',
194
194
  ' /** Unified content namespace — `import * as okno from "okno:content"` then `okno.pages.home`, `okno.globals.nav`, `okno.collections.articles`, `okno.strings.nav.home`. */',
@@ -200,8 +200,8 @@ function Ze() {
200
200
  ""
201
201
  ];
202
202
  }
203
- function Xe(e, n) {
204
- const s = e.length ? `${qe(e, n)}` : "any", i = e.length ? `
203
+ function Ze(e, n) {
204
+ const s = e.length ? `${Xe(e, n)}` : "any", i = e.length ? `
205
205
  locale(code?: string | null): ${s}` : "";
206
206
  return [
207
207
  'declare module "okno:strings" {',
@@ -212,7 +212,7 @@ function Xe(e, n) {
212
212
  ""
213
213
  ];
214
214
  }
215
- function qe(e, n) {
215
+ function Xe(e, n) {
216
216
  const s = { children: /* @__PURE__ */ new Map() };
217
217
  for (const p of e) {
218
218
  let f = s;
@@ -224,35 +224,35 @@ function qe(e, n) {
224
224
  const i = (p) => p === "text" ? "string" : "number", u = (p) => {
225
225
  const f = n[p];
226
226
  return !f || Object.keys(f).length === 0 ? "OknoValue<string>" : `(p: { ${Object.entries(f).map(([t, r]) => `${JSON.stringify(t)}: ${i(r)}`).join("; ")} }) => OknoValue<string>`;
227
- }, l = (p, f) => p.children.size === 0 ? u(f) : `{ ${[...p.children.entries()].map(
228
- ([t, r]) => `${JSON.stringify(t)}: ${l(r, f ? `${f}.${t}` : t)}`
227
+ }, c = (p, f) => p.children.size === 0 ? u(f) : `{ ${[...p.children.entries()].map(
228
+ ([t, r]) => `${JSON.stringify(t)}: ${c(r, f ? `${f}.${t}` : t)}`
229
229
  ).join("; ")} }`;
230
- return l(s, "");
230
+ return c(s, "");
231
231
  }
232
- function Qe(e) {
232
+ function qe(e) {
233
233
  const n = {}, s = e?.strings;
234
234
  if (!s || typeof s != "object" || Array.isArray(s)) return n;
235
235
  for (const [i, u] of Object.entries(s)) {
236
- const l = u?.slots;
237
- if (!l || typeof l != "object" || Array.isArray(l)) continue;
236
+ const c = u?.slots;
237
+ if (!c || typeof c != "object" || Array.isArray(c)) continue;
238
238
  const p = {};
239
- for (const [f, a] of Object.entries(l))
239
+ for (const [f, a] of Object.entries(c))
240
240
  (a === "text" || a === "number" || a === "count") && (p[f] = a);
241
241
  Object.keys(p).length && (n[i] = p);
242
242
  }
243
243
  return n;
244
244
  }
245
- function Ye(e, n, s) {
245
+ function Qe(e, n, s) {
246
246
  const i = /* @__PURE__ */ new Set(), u = [];
247
- for (const l of e) {
248
- const p = s("collections", l.name, `./collections/${l.name}/${l.first}`);
249
- u.push(` export const ${l.name}: (${p} & OknoDrag)[]`), i.add(l.name);
247
+ for (const c of e) {
248
+ const p = s("collections", c.name, `./collections/${c.name}/${c.first}`);
249
+ u.push(` export const ${c.name}: (${p} & OknoDrag)[]`), i.add(c.name);
250
250
  }
251
- for (const l of n)
252
- i.has(l) || u.push(` export const ${l}: OknoUnscaffolded[]`);
251
+ for (const c of n)
252
+ i.has(c) || u.push(` export const ${c}: OknoUnscaffolded[]`);
253
253
  return ['declare module "okno:collections" {', ...u, "}", ""];
254
254
  }
255
- function De(e) {
255
+ function Ye(e) {
256
256
  const n = _(e, "schema.ts");
257
257
  if (!$(n)) return null;
258
258
  try {
@@ -263,7 +263,7 @@ function De(e) {
263
263
  return null;
264
264
  }
265
265
  }
266
- function et(e) {
266
+ function De(e) {
267
267
  const n = _(e, "strings.ts");
268
268
  if (!$(n)) return [];
269
269
  try {
@@ -277,13 +277,13 @@ function et(e) {
277
277
  return [];
278
278
  }
279
279
  }
280
- async function tt(e) {
280
+ async function et(e) {
281
281
  const n = _(e, "collections");
282
282
  if (!$(n)) return [];
283
283
  const s = (await E(n, { withFileTypes: !0 })).filter((u) => u.isDirectory()), i = [];
284
284
  for (const u of s) {
285
- const l = await te(_(n, u.name));
286
- l.length > 0 && i.push({ name: u.name, first: l[0] });
285
+ const c = await te(_(n, u.name));
286
+ c.length > 0 && i.push({ name: u.name, first: c[0] });
287
287
  }
288
288
  return i;
289
289
  }
@@ -297,7 +297,7 @@ function re(e) {
297
297
  return null;
298
298
  }
299
299
  }
300
- function nt() {
300
+ function tt() {
301
301
  const e = re("git rev-parse --abbrev-ref HEAD");
302
302
  if (e && e !== "HEAD") return e;
303
303
  const n = process.env;
@@ -311,31 +311,24 @@ function St() {
311
311
  const e = re("git remote get-url origin");
312
312
  if (!e) return null;
313
313
  const n = e.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
314
- return n ? `${n[1]}/${n[2]}@${nt()}` : null;
314
+ return n ? `${n[1]}/${n[2]}@${tt()}` : null;
315
315
  }
316
316
  function Ot() {
317
317
  const e = re("git rev-parse --show-toplevel");
318
318
  return e ? H(e, process.cwd()).split(U).join("/") : "";
319
319
  }
320
- const ae = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', pe = N(Ae(import.meta.url)), ye = [
320
+ const ae = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', pe = N(je(import.meta.url)), nt = [
321
321
  ue(pe, "./runtime/wrap.js"),
322
322
  // bundled at dist/ (Vite plugin chunk)
323
323
  ue(pe, "../runtime/wrap.js")
324
324
  // bundled at dist/next/ (Next entry)
325
325
  ];
326
326
  function vt() {
327
- for (const e of ye)
327
+ for (const e of nt)
328
328
  if ($(e)) return v(e, "utf-8");
329
329
  return null;
330
330
  }
331
331
  function jt() {
332
- for (const e of ye) {
333
- const n = e.replace(/wrap\.js$/, "instant.js");
334
- if ($(n)) return v(n, "utf-8");
335
- }
336
- return null;
337
- }
338
- function At() {
339
332
  return [
340
333
  'export * as pages from "okno:pages"',
341
334
  'export * as globals from "okno:globals"',
@@ -350,7 +343,7 @@ function q(e) {
350
343
  try {
351
344
  const i = Z(v(n, "utf-8"))?.locales?.supported;
352
345
  if (!Array.isArray(i) || i.length === 0) return null;
353
- const u = i.map((l) => typeof l == "string" ? l : l?.id).filter((l) => typeof l == "string");
346
+ const u = i.map((c) => typeof c == "string" ? c : c?.id).filter((c) => typeof c == "string");
354
347
  return u.length ? new Set(u) : null;
355
348
  } catch {
356
349
  return null;
@@ -383,22 +376,22 @@ function ot(e) {
383
376
  return { orders: s, draftsOff: i, schedulingOff: u };
384
377
  }
385
378
  const rt = /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|[0-9]{3}))?$/i, Q = (e) => e.replace(/[^a-zA-Z0-9]/g, "_");
386
- function ce(e) {
379
+ function le(e) {
387
380
  return e.replace(".ts", "").replace(/-/g, "_");
388
381
  }
389
- function $e(e) {
382
+ function ye(e) {
390
383
  return e.replace(".ts", "").replace(/-/g, "_");
391
384
  }
392
385
  function X(e) {
393
386
  return e.replace(".ts", "");
394
387
  }
395
- function Tt(e) {
388
+ function At(e) {
396
389
  const n = _(e, "schema.ts");
397
390
  let s = [], i = "";
398
391
  if ($(n))
399
392
  try {
400
- const u = Z(v(n, "utf-8")), l = u?.locales?.supported;
401
- Array.isArray(l) && (s = l.map((p) => typeof p == "string" ? { id: p } : p).filter((p) => !!p && typeof p.id == "string").map((p) => ({
393
+ const u = Z(v(n, "utf-8")), c = u?.locales?.supported;
394
+ Array.isArray(c) && (s = c.map((p) => typeof p == "string" ? { id: p } : p).filter((p) => !!p && typeof p.id == "string").map((p) => ({
402
395
  id: p.id,
403
396
  name: p.name || st(p.id),
404
397
  // Preserve an intentionally empty slug (= no URL prefix for the default).
@@ -434,7 +427,7 @@ function Tt(e) {
434
427
  ].join(`
435
428
  `);
436
429
  }
437
- async function xt(e) {
430
+ async function Tt(e) {
438
431
  const n = _(e, "strings.ts");
439
432
  if (!$(n))
440
433
  return [
@@ -442,9 +435,9 @@ async function xt(e) {
442
435
  'export const strings = __oknoMakeStrings({}, {}, "")'
443
436
  ].join(`
444
437
  `);
445
- const s = _(e, "schema.ts"), i = $(s), u = q(e), l = _(e, "strings"), p = [];
446
- if ($(l)) {
447
- const o = await E(l, { withFileTypes: !0 });
438
+ const s = _(e, "schema.ts"), i = $(s), u = q(e), c = _(e, "strings"), p = [];
439
+ if ($(c)) {
440
+ const o = await E(c, { withFileTypes: !0 });
448
441
  for (const m of o) {
449
442
  if (!m.isFile() || !m.name.endsWith(".ts") || m.name === "index.ts") continue;
450
443
  const d = m.name.replace(/\.ts$/, "");
@@ -463,17 +456,17 @@ async function xt(e) {
463
456
  const r = [];
464
457
  for (const o of p) {
465
458
  const m = Q(o);
466
- f.push(`import _strings_${m} from "${_(l, o + ".ts")}"`), r.push(`"${o}": __oknoExpandStrings(_strings_${m})`);
459
+ f.push(`import _strings_${m} from "${_(c, o + ".ts")}"`), r.push(`"${o}": __oknoExpandStrings(_strings_${m})`);
467
460
  }
468
461
  return f.push("const _strings_base = __oknoExpandStrings(_strings_default)"), f.push(`const _strings_localized = __oknoLocalize(_strings_base, { ${r.join(", ")} })`), f.push(`export const strings = __oknoMakeStrings(_strings_localized, ${a}, ${t})`), f.join(`
469
462
  `);
470
463
  }
471
- async function Rt(e, n = /* @__PURE__ */ new Set()) {
472
- const s = _(e, "pages"), i = _(e, "schema.ts"), u = $(i), l = [
464
+ async function xt(e, n = /* @__PURE__ */ new Set()) {
465
+ const s = _(e, "pages"), i = _(e, "schema.ts"), u = $(i), c = [
473
466
  'import { __oknoWrap, __oknoLocalize, __oknoResolveRefs, __oknoResolveEnums, __oknoSetImages, __oknoSetRoutes } from "okno:runtime"',
474
467
  ae
475
468
  ];
476
- u && (l.push('import * as __collections from "okno:collections"'), l.push(`import __schema from "${i}"`), l.push("__oknoSetRoutes(__schema)"));
469
+ u && (c.push('import * as __collections from "okno:collections"'), c.push(`import __schema from "${i}"`), c.push("__oknoSetRoutes(__schema)"));
477
470
  let p = "[]";
478
471
  const f = (t, r) => {
479
472
  if (!u) return `_${t}`;
@@ -485,9 +478,9 @@ async function Rt(e, n = /* @__PURE__ */ new Set()) {
485
478
  p = JSON.stringify(o);
486
479
  const m = await ie(s);
487
480
  for (const d of m) {
488
- const h = ce(d), y = $e(d), c = X(d), g = _(s, d);
481
+ const h = le(d), y = ye(d), l = X(d), g = _(s, d);
489
482
  if (o.length === 0) {
490
- l.push(`import _${h} from "${g}"`), l.push(`export const ${y} = __oknoWrap(${f(h, c)}, "${c}")`), a.add(y);
483
+ c.push(`import _${h} from "${g}"`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
491
484
  continue;
492
485
  }
493
486
  const k = [`import _${h}_default from "${g}"`], b = [];
@@ -498,31 +491,31 @@ async function Rt(e, n = /* @__PURE__ */ new Set()) {
498
491
  k.push(`import _${h}_${O} from "${w}"`), b.push(`"${S}": _${h}_${O}`);
499
492
  }
500
493
  }
501
- l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), l.push(`export const ${y} = __oknoWrap(${f(h, c)}, "${c}")`), a.add(y);
494
+ c.push(...k), c.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
502
495
  }
503
496
  }
504
497
  for (const t of n)
505
- a.has(t) || l.push(`export const ${t} = __oknoWrap(null, "${t}")`);
506
- return l.join(`
498
+ a.has(t) || c.push(`export const ${t} = __oknoWrap(null, "${t}")`);
499
+ return c.join(`
507
500
  `);
508
501
  }
509
- async function Pt(e, n = /* @__PURE__ */ new Set(), s = !1) {
502
+ async function Rt(e, n = /* @__PURE__ */ new Set(), s = !1) {
510
503
  const i = _(e, "collections");
511
504
  if (!$(i)) {
512
- const c = [];
505
+ const l = [];
513
506
  for (const g of n) {
514
507
  const k = g.replace(/-/g, "_");
515
- c.push(`export const ${k} = []`);
508
+ l.push(`export const ${k} = []`);
516
509
  }
517
- return c.join(`
510
+ return l.join(`
518
511
  `) || "export {}";
519
512
  }
520
- const u = q(e), l = await E(i, { withFileTypes: !0 }), p = l.filter((c) => c.isDirectory() && K(c.name, u)).map((c) => c.name), f = l.filter((c) => c.isDirectory() && !p.includes(c.name)).map((c) => c.name), a = JSON.stringify(p);
521
- for (const c of f) {
522
- const g = await E(_(i, c), { withFileTypes: !0 }).catch(() => []);
513
+ const u = q(e), c = await E(i, { withFileTypes: !0 }), p = c.filter((l) => l.isDirectory() && K(l.name, u)).map((l) => l.name), f = c.filter((l) => l.isDirectory() && !p.includes(l.name)).map((l) => l.name), a = JSON.stringify(p);
514
+ for (const l of f) {
515
+ const g = await E(_(i, l), { withFileTypes: !0 }).catch(() => []);
523
516
  for (const k of g)
524
517
  k.isDirectory() && K(k.name, u) && console.warn(
525
- `[okno] "collections/${c}/${k.name}/" looks like a misplaced locale folder. Collection locale overrides go at "collections/${k.name}/${c}/<slug>.ts" (locale right after "collections/"). This folder will NOT be localized.`
518
+ `[okno] "collections/${l}/${k.name}/" looks like a misplaced locale folder. Collection locale overrides go at "collections/${k.name}/${l}/<slug>.ts" (locale right after "collections/"). This folder will NOT be localized.`
526
519
  );
527
520
  }
528
521
  const { orders: t, draftsOff: r, schedulingOff: o } = ot(e), m = _(e, "schema.ts"), d = $(m), h = [
@@ -531,16 +524,16 @@ async function Pt(e, n = /* @__PURE__ */ new Set(), s = !1) {
531
524
  ];
532
525
  d && (h.push(`import __schema from "${m}"`), h.push("__oknoSetRoutes(__schema)"));
533
526
  const y = [];
534
- for (const c of f) {
535
- const g = _(i, c), k = Te(await ie(g), X, t[c]), b = c.replace(/-/g, "_"), S = s && !r.has(c), w = s && !o.has(c), O = [];
527
+ for (const l of f) {
528
+ const g = _(i, l), k = Ae(await ie(g), X, t[l]), b = l.replace(/-/g, "_"), S = s && !r.has(l), w = s && !o.has(l), O = [];
536
529
  for (const j of k) {
537
- const A = `_${b}_${ce(j)}`, C = X(j), P = _(g, j);
530
+ const A = `_${b}_${le(j)}`, C = X(j), P = _(g, j);
538
531
  if (p.length === 0)
539
532
  h.push(`import ${A} from "${P}"`);
540
533
  else {
541
534
  const I = [`import ${A}_default from "${P}"`], M = [];
542
535
  for (const x of p) {
543
- const V = _(i, x, c, j);
536
+ const V = _(i, x, l, j);
544
537
  if ($(V)) {
545
538
  const z = Q(x);
546
539
  I.push(`import ${A}_${z} from "${V}"`), M.push(`"${x}": ${A}_${z}`);
@@ -550,24 +543,24 @@ async function Pt(e, n = /* @__PURE__ */ new Set(), s = !1) {
550
543
  }
551
544
  O.push({ varName: A, itemName: C });
552
545
  }
553
- h.push(`const __oknoRaw_${b} = [${O.map((j) => j.varName).join(", ")}]`), y.push({ name: c, safe: b, draftsOn: S, schedulingOn: w, items: O });
546
+ h.push(`const __oknoRaw_${b} = [${O.map((j) => j.varName).join(", ")}]`), y.push({ name: l, safe: b, draftsOn: S, schedulingOn: w, items: O });
554
547
  }
555
- d && h.push(`const __oknoNs = { ${y.map((c) => `${c.safe}: __oknoRaw_${c.safe}`).join(", ")} }`);
556
- for (const c of y) {
557
- const g = `__schema?.collections?.["${c.name}"]?.fields`, k = (w) => d ? `__oknoResolveEnums(__oknoResolveRefs(${w.varName}, ${g}, __oknoNs, ${a}), ${g}, ${a})` : w.varName, b = [];
558
- c.draftsOn && b.push('e[0]?.status !== "draft"'), c.schedulingOn && b.push("__oknoVisible(e[0])");
559
- const S = b.length ? `[${c.items.map((w) => `[${w.varName}, ${k(w)}, ${JSON.stringify(w.itemName)}]`).join(", ")}].filter((e) => ${b.join(" && ")}).map((e, __i) => __oknoWrap(e[1], "${c.name}." + e[2], "${c.name}." + __i))` : `[${c.items.map((w, O) => `__oknoWrap(${k(w)}, "${c.name}.${w.itemName}", "${c.name}.${O}")`).join(", ")}]`;
560
- h.push(`export const ${c.safe} = ${S}`);
548
+ d && h.push(`const __oknoNs = { ${y.map((l) => `${l.safe}: __oknoRaw_${l.safe}`).join(", ")} }`);
549
+ for (const l of y) {
550
+ const g = `__schema?.collections?.["${l.name}"]?.fields`, k = (w) => d ? `__oknoResolveEnums(__oknoResolveRefs(${w.varName}, ${g}, __oknoNs, ${a}), ${g}, ${a})` : w.varName, b = [];
551
+ l.draftsOn && b.push('e[0]?.status !== "draft"'), l.schedulingOn && b.push("__oknoVisible(e[0])");
552
+ const S = b.length ? `[${l.items.map((w) => `[${w.varName}, ${k(w)}, ${JSON.stringify(w.itemName)}]`).join(", ")}].filter((e) => ${b.join(" && ")}).map((e, __i) => __oknoWrap(e[1], "${l.name}." + e[2], "${l.name}." + __i))` : `[${l.items.map((w, O) => `__oknoWrap(${k(w)}, "${l.name}.${w.itemName}", "${l.name}.${O}")`).join(", ")}]`;
553
+ h.push(`export const ${l.safe} = ${S}`);
561
554
  }
562
555
  return h.join(`
563
556
  `);
564
557
  }
565
- async function Et(e, n = /* @__PURE__ */ new Set()) {
566
- const s = _(e, "globals"), i = _(e, "schema.ts"), u = $(i), l = [
558
+ async function Pt(e, n = /* @__PURE__ */ new Set()) {
559
+ const s = _(e, "globals"), i = _(e, "schema.ts"), u = $(i), c = [
567
560
  'import { __oknoWrap, __oknoLocalize, __oknoResolveRefs, __oknoResolveEnums, __oknoSetImages, __oknoSetRoutes } from "okno:runtime"',
568
561
  ae
569
562
  ];
570
- u && (l.push('import * as __collections from "okno:collections"'), l.push(`import __schema from "${i}"`), l.push("__oknoSetRoutes(__schema)"));
563
+ u && (c.push('import * as __collections from "okno:collections"'), c.push(`import __schema from "${i}"`), c.push("__oknoSetRoutes(__schema)"));
571
564
  let p = "[]";
572
565
  const f = (t, r) => {
573
566
  if (!u) return `_${t}`;
@@ -579,9 +572,9 @@ async function Et(e, n = /* @__PURE__ */ new Set()) {
579
572
  p = JSON.stringify(o);
580
573
  const m = await ie(s);
581
574
  for (const d of m) {
582
- const h = ce(d), y = $e(d), c = X(d), g = _(s, d);
575
+ const h = le(d), y = ye(d), l = X(d), g = _(s, d);
583
576
  if (o.length === 0) {
584
- l.push(`import _${h} from "${g}"`), l.push(`export const ${y} = __oknoWrap(${f(h, c)}, "${c}")`), a.add(y);
577
+ c.push(`import _${h} from "${g}"`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
585
578
  continue;
586
579
  }
587
580
  const k = [`import _${h}_default from "${g}"`], b = [];
@@ -592,20 +585,20 @@ async function Et(e, n = /* @__PURE__ */ new Set()) {
592
585
  k.push(`import _${h}_${O} from "${w}"`), b.push(`"${S}": _${h}_${O}`);
593
586
  }
594
587
  }
595
- l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), l.push(`export const ${y} = __oknoWrap(${f(h, c)}, "${c}")`), a.add(y);
588
+ c.push(...k), c.push(`const _${h} = __oknoLocalize(_${h}_default, { ${b.join(", ")} })`), c.push(`export const ${y} = __oknoWrap(${f(h, l)}, "${l}")`), a.add(y);
596
589
  }
597
590
  }
598
591
  for (const t of n)
599
- a.has(t) || l.push(`export const ${t} = __oknoWrap(null, "${t}")`);
600
- return l.join(`
592
+ a.has(t) || c.push(`export const ${t} = __oknoWrap(null, "${t}")`);
593
+ return c.join(`
601
594
  `);
602
595
  }
603
- const ke = /* @__PURE__ */ new Map();
596
+ const $e = /* @__PURE__ */ new Map();
604
597
  function L(e) {
605
- ke.set(e, Date.now());
598
+ $e.set(e, Date.now());
606
599
  }
607
- function Mt(e) {
608
- const n = ke.get(e);
600
+ function Et(e) {
601
+ const n = $e.get(e);
609
602
  return n !== void 0 && Date.now() - n < 3e3;
610
603
  }
611
604
  const at = ["pages", "collections", "globals"];
@@ -622,10 +615,10 @@ function J(e, n) {
622
615
  function it(e) {
623
616
  const n = {}, s = (u) => {
624
617
  if ($(u))
625
- for (const l of se(u, { withFileTypes: !0 })) {
626
- const p = _(u, l.name);
627
- if (l.isDirectory()) s(p);
628
- else if (l.name.endsWith(".ts") && l.name !== "index.ts") {
618
+ for (const c of se(u, { withFileTypes: !0 })) {
619
+ const p = _(u, c.name);
620
+ if (c.isDirectory()) s(p);
621
+ else if (c.name.endsWith(".ts") && c.name !== "index.ts") {
629
622
  const f = H(e, p).split(U).join("/");
630
623
  n[f] = v(p, "utf-8");
631
624
  }
@@ -635,28 +628,28 @@ function it(e) {
635
628
  const i = _(e, "strings.ts");
636
629
  return $(i) && (n["strings.ts"] = v(i, "utf-8")), s(_(e, "strings")), n;
637
630
  }
638
- function we(e) {
631
+ function ke(e) {
639
632
  const n = _(e, "files"), s = [], i = (u) => {
640
633
  if ($(u))
641
- for (const l of se(u, { withFileTypes: !0 })) {
642
- const p = _(u, l.name);
643
- if (l.isDirectory()) i(p);
644
- else if (l.name !== ".okno-tree.json") {
634
+ for (const c of se(u, { withFileTypes: !0 })) {
635
+ const p = _(u, c.name);
636
+ if (c.isDirectory()) i(p);
637
+ else if (c.name !== ".okno-tree.json") {
645
638
  const f = H(n, p).split(U).join("/");
646
- s.push({ path: `files/${f}`, filename: l.name, size: Oe(p).size });
639
+ s.push({ path: `files/${f}`, filename: c.name, size: Se(p).size });
647
640
  }
648
641
  }
649
642
  };
650
643
  return i(n), s;
651
644
  }
652
- function ct(e) {
645
+ function lt(e) {
653
646
  const n = _(e, "schema.ts"), s = _(e, "users.json"), i = _(e, "origins.json");
654
647
  return {
655
648
  schema: $(n) ? v(n, "utf-8") : null,
656
649
  users: $(s) ? v(s, "utf-8") : null,
657
650
  origins: $(i) ? v(i, "utf-8") : null,
658
651
  content: it(e),
659
- files: we(e)
652
+ files: ke(e)
660
653
  };
661
654
  }
662
655
  const he = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "-"), ge = (e) => e.split("/").map((n) => n.replace(/[^a-zA-Z0-9._-]/g, "-")).filter((n) => n && n !== "-" && n !== "..").join("/");
@@ -666,8 +659,8 @@ function T(e) {
666
659
 
667
660
  `, i = {};
668
661
  if ($(n)) {
669
- const u = v(n, "utf-8"), l = u.indexOf("export default");
670
- l > 0 && (s = u.slice(0, l));
662
+ const u = v(n, "utf-8"), c = u.indexOf("export default");
663
+ c > 0 && (s = u.slice(0, c));
671
664
  try {
672
665
  i = Z(u) ?? {};
673
666
  } catch {
@@ -676,19 +669,19 @@ function T(e) {
676
669
  }
677
670
  return { schema: i, header: s };
678
671
  }
679
- function lt(e, n, s) {
680
- R(_(e, "schema.ts"), xe(n, s));
672
+ function ct(e, n, s) {
673
+ R(_(e, "schema.ts"), Te(n, s));
681
674
  }
682
675
  function ut(e, n, s, i, u) {
683
- const l = _(e, n), p = new Set(u), f = [];
684
- if (!$(l) || Object.keys(i).length === 0 && p.size === 0) return f;
676
+ const c = _(e, n), p = new Set(u), f = [];
677
+ if (!$(c) || Object.keys(i).length === 0 && p.size === 0) return f;
685
678
  const a = [], t = (r) => {
686
679
  for (const o of se(r, { withFileTypes: !0 })) {
687
680
  const m = _(r, o.name);
688
681
  o.isDirectory() ? t(m) : o.name === `${s}.ts` && a.push(m);
689
682
  }
690
683
  };
691
- t(l);
684
+ t(c);
692
685
  for (const r of a) {
693
686
  let o;
694
687
  try {
@@ -700,8 +693,8 @@ function ut(e, n, s, i, u) {
700
693
  if (Array.isArray(o))
701
694
  m = o.map((y) => {
702
695
  if (y && typeof y == "object" && !Array.isArray(y)) {
703
- const c = me(y, i, p);
704
- return c.changed && (d = !0), c.out;
696
+ const l = me(y, i, p);
697
+ return l.changed && (d = !0), l.out;
705
698
  }
706
699
  return y;
707
700
  });
@@ -722,7 +715,7 @@ function ne(e) {
722
715
  return D || (D = oe("git rev-parse --show-toplevel", { cwd: e, encoding: "utf-8" }).trim()), D;
723
716
  }
724
717
  function _e(e) {
725
- return H(ne(e), ve(e)).split(U).join("/");
718
+ return H(ne(e), Oe(e)).split(U).join("/");
726
719
  }
727
720
  let G;
728
721
  function ft(e) {
@@ -734,28 +727,28 @@ function ft(e) {
734
727
  }
735
728
  return G;
736
729
  }
737
- async function Nt(e, n) {
738
- const { method: s, route: i } = n, u = { files: [], modules: [] }, l = (t, r) => {
730
+ async function Mt(e, n) {
731
+ const { method: s, route: i } = n, u = { files: [], modules: [] }, c = (t, r) => {
739
732
  const o = t.split("/")[0];
740
733
  o !== "pages" && o !== "collections" && o !== "globals" || (u.modules.push(o), u.files.push(r));
741
734
  }, p = () => u.modules.push("pages", "collections", "globals"), f = (t, r) => {
742
- lt(e, t, r), p();
735
+ ct(e, t, r), p();
743
736
  }, a = (t, r) => ({ status: t, body: r, invalidation: u });
744
737
  try {
745
- if (s === "GET" && i === "content") return a(200, ct(e));
738
+ if (s === "GET" && i === "content") return a(200, lt(e));
746
739
  if (s === "POST" && i === "content/save") {
747
740
  const { path: t, content: r, created: o, author: m } = await n.json();
748
741
  if (!t || !r) return a(400, { error: "Missing path or content" });
749
742
  const d = F(e, t);
750
743
  if (!d) return a(400, { error: "Invalid path" });
751
- const h = Re(r, { now: (/* @__PURE__ */ new Date()).toISOString(), author: m || ft(e), created: o });
752
- return W(N(d), { recursive: !0 }), L(d), R(d, h), l(t, d), a(200, { ok: !0, commit: { fileSha: "" } });
744
+ const h = xe(r, { now: (/* @__PURE__ */ new Date()).toISOString(), author: m || ft(e), created: o });
745
+ return W(N(d), { recursive: !0 }), L(d), R(d, h), c(t, d), a(200, { ok: !0, commit: { fileSha: "" } });
753
746
  }
754
747
  if (s === "POST" && i === "content/delete") {
755
748
  const t = (await n.json())?.path;
756
749
  if (!t) return a(400, { error: "Missing path" });
757
750
  const r = F(e, t);
758
- return r ? ($(r) && (B(r), l(t, r)), a(200, { ok: !0 })) : a(400, { error: "Invalid path" });
751
+ return r ? ($(r) && (B(r), c(t, r)), a(200, { ok: !0 })) : a(400, { error: "Invalid path" });
759
752
  }
760
753
  if (s === "POST" && i === "strings/save") {
761
754
  const { path: t, content: r } = await n.json();
@@ -768,11 +761,11 @@ async function Nt(e, n) {
768
761
  const { strings: t } = await n.json();
769
762
  if (t != null && (typeof t != "object" || Array.isArray(t))) return a(400, { error: "Invalid strings" });
770
763
  const { schema: r, header: o } = T(e);
771
- return Pe(r, t), f(r, o), u.modules.push("strings", "content"), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
764
+ return Re(r, t), f(r, o), u.modules.push("strings", "content"), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
772
765
  }
773
766
  if (s === "GET" && i === "publish-state")
774
767
  try {
775
- const t = fe(ne(e)), r = await t.status(), o = _e(e), m = (c) => c.startsWith(o + "/"), d = r.files.map((c) => c.path).filter(m);
768
+ const t = fe(ne(e)), r = await t.status(), o = _e(e), m = (l) => l.startsWith(o + "/"), d = r.files.map((l) => l.path).filter(m);
776
769
  let h = [];
777
770
  if (r.ahead > 0)
778
771
  try {
@@ -794,9 +787,9 @@ async function Nt(e, n) {
794
787
  let h = !1, y = null;
795
788
  try {
796
789
  (d || o.ahead > 0) && (await t.push(), h = !0);
797
- } catch (c) {
798
- y = c instanceof Error ? c.message.split(`
799
- `)[0] : String(c);
790
+ } catch (l) {
791
+ y = l instanceof Error ? l.message.split(`
792
+ `)[0] : String(l);
800
793
  }
801
794
  return a(200, { ok: !0, alreadyUpToDate: !d && o.ahead === 0, committed: d, pushed: h, pushError: y });
802
795
  }
@@ -804,79 +797,79 @@ async function Nt(e, n) {
804
797
  const { kind: t, name: r, fields: o, renames: m, deletes: d } = await n.json();
805
798
  if (!t || !r || !o) return a(400, { error: "Missing kind, name or fields" });
806
799
  const { schema: h, header: y } = T(e);
807
- Ee(h, t, r, o), f(h, y);
808
- const c = m && typeof m == "object" ? m : {}, g = Array.isArray(d) ? d : [];
809
- if (Object.keys(c).length > 0 || g.length > 0)
810
- for (const { rel: k, abs: b } of ut(e, t, r, c, g)) l(k, b);
800
+ Pe(h, t, r, o), f(h, y);
801
+ const l = m && typeof m == "object" ? m : {}, g = Array.isArray(d) ? d : [];
802
+ if (Object.keys(l).length > 0 || g.length > 0)
803
+ for (const { rel: k, abs: b } of ut(e, t, r, l, g)) c(k, b);
811
804
  return a(200, { ok: !0, commit: { fileSha: "" }, schema: h });
812
805
  }
813
806
  if (s === "POST" && i === "schema/set-locales") {
814
807
  const t = (await n.json())?.locales, { schema: r, header: o } = T(e);
815
- return Me(r, t), f(r, o), a(200, { ok: !0, commit: { fileSha: "" } });
808
+ return Ee(r, t), f(r, o), a(200, { ok: !0, commit: { fileSha: "" } });
816
809
  }
817
810
  if (s === "POST" && i === "schema/set-name") {
818
811
  const { kind: t, slug: r, name: o } = await n.json();
819
812
  if (!t || !r || !o) return a(400, { error: "Missing kind, slug or name" });
820
813
  const { schema: m, header: d } = T(e);
821
- return Ne(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
814
+ return Me(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
822
815
  }
823
816
  if (s === "POST" && i === "schema/set-url") {
824
817
  const { kind: t, slug: r, url: o } = await n.json();
825
818
  if (!t || !r) return a(400, { error: "Missing kind or slug" });
826
819
  const { schema: m, header: d } = T(e);
827
- return Ie(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
820
+ return Ne(m, t, r, o), f(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
828
821
  }
829
822
  if (s === "POST" && i === "schema/rename-slug") {
830
823
  const { kind: t, from: r, to: o } = await n.json();
831
824
  if (!t || !r || !o) return a(400, { error: "Missing kind, from or to" });
832
- const { schema: m, header: d } = T(e), { unchanged: h } = We(m, t, r, o);
825
+ const { schema: m, header: d } = T(e), { unchanged: h } = Ie(m, t, r, o);
833
826
  if (h) return a(200, { ok: !0, unchanged: !0 });
834
827
  f(m, d);
835
- const y = `${t}/${r}.ts`, c = `${t}/${o}.ts`, g = F(e, y), k = F(e, c);
836
- return g && k && $(g) && (W(N(k), { recursive: !0 }), L(g), L(k), R(k, v(g)), B(g), l(y, g), l(c, k)), a(200, { ok: !0, commit: { fileSha: "" }, schema: m, from: r, to: o, kind: t });
828
+ const y = `${t}/${r}.ts`, l = `${t}/${o}.ts`, g = F(e, y), k = F(e, l);
829
+ return g && k && $(g) && (W(N(k), { recursive: !0 }), L(g), L(k), R(k, v(g)), B(g), c(y, g), c(l, k)), a(200, { ok: !0, commit: { fileSha: "" }, schema: m, from: r, to: o, kind: t });
837
830
  }
838
831
  if (s === "POST" && i === "schema/reorder") {
839
832
  const { kind: t, order: r } = await n.json();
840
833
  if (!t || !Array.isArray(r)) return a(400, { error: "Missing kind or order" });
841
834
  const { schema: o, header: m } = T(e);
842
- return Fe(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
835
+ return We(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
843
836
  }
844
837
  if (s === "POST" && i === "schema/set-layout") {
845
838
  const { kind: t, layout: r } = await n.json();
846
839
  if (!t || !Array.isArray(r)) return a(400, { error: "Missing kind or layout" });
847
840
  const { schema: o, header: m } = T(e);
848
- return Le(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
841
+ return Fe(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
849
842
  }
850
843
  if (s === "POST" && i === "collections/set-order") {
851
844
  const { name: t, order: r } = await n.json();
852
845
  if (!t || !Array.isArray(r)) return a(400, { error: "Missing name or order" });
853
846
  const { schema: o, header: m } = T(e);
854
- return Ue(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
847
+ return Le(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
855
848
  }
856
849
  if (s === "POST" && i === "collections/set-drafts") {
857
850
  const { name: t, drafts: r } = await n.json();
858
851
  if (!t || typeof r != "boolean") return a(400, { error: "Missing name or drafts" });
859
852
  const { schema: o, header: m } = T(e);
860
- return Ce(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
853
+ return Ue(o, t, r), f(o, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
861
854
  }
862
855
  if (s === "POST" && i === "schema/delete-entry") {
863
856
  const { kind: t, name: r } = await n.json();
864
857
  if (!t || !r) return a(400, { error: "Missing kind or name" });
865
858
  const { schema: o, header: m } = T(e);
866
- ze(o, t, r), f(o, m);
859
+ Ce(o, t, r), f(o, m);
867
860
  const d = `${t}/${r}.ts`, h = F(e, d);
868
- return h && $(h) && (L(h), B(h), l(d, h)), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
861
+ return h && $(h) && (L(h), B(h), c(d, h)), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
869
862
  }
870
863
  if (s === "POST" && i === "setup/scaffold-page") {
871
864
  const { name: t, kind: r, fields: o, label: m } = await n.json();
872
865
  if (!t || !r) return a(400, { error: "Missing name or kind" });
873
866
  const d = o ?? [], { schema: h, header: y } = T(e);
874
- if (Je(h, t, r, d, m), f(h, y), r !== "blocks") {
875
- const c = `${r}/${t}.ts`, g = F(e, c);
867
+ if (ze(h, t, r, d, m), f(h, y), r !== "blocks") {
868
+ const l = `${r}/${t}.ts`, g = F(e, l);
876
869
  if (g) {
877
870
  const k = r === "collections" ? `export default []
878
- ` : ee(Ve(d));
879
- W(N(g), { recursive: !0 }), L(g), R(g, k), l(c, g);
871
+ ` : ee(Je(d));
872
+ W(N(g), { recursive: !0 }), L(g), R(g, k), c(l, g);
880
873
  }
881
874
  }
882
875
  return a(200, { ok: !0 });
@@ -884,7 +877,7 @@ async function Nt(e, n) {
884
877
  if (s === "GET" && i === "files") {
885
878
  const t = _(e, "files", ".okno-tree.json");
886
879
  return a(200, {
887
- files: we(e),
880
+ files: ke(e),
888
881
  manifest: $(t) ? v(t, "utf-8") : null
889
882
  });
890
883
  }
@@ -924,7 +917,7 @@ async function Nt(e, n) {
924
917
  const { from: t, to: r } = await n.json();
925
918
  if (!t || !r) return a(400, { error: "Missing from or to" });
926
919
  const o = J(e, t), m = J(e, r);
927
- return !o || !m ? a(400, { error: "Invalid path" }) : $(o) ? (W(N(m), { recursive: !0 }), je(o, m), a(200, { ok: !0, commit: { fileSha: "" } })) : a(404, { error: "Source not found" });
920
+ return !o || !m ? a(400, { error: "Invalid path" }) : $(o) ? (W(N(m), { recursive: !0 }), ve(o, m), a(200, { ok: !0, commit: { fileSha: "" } })) : a(404, { error: "Source not found" });
928
921
  }
929
922
  if (s === "POST" && i === "users/save") {
930
923
  const t = (await n.json())?.users;
@@ -940,28 +933,23 @@ async function Nt(e, n) {
940
933
  }
941
934
  return null;
942
935
  } catch (t) {
943
- return t instanceof Be ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
936
+ return t instanceof Ve ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
944
937
  }
945
938
  }
946
939
  export {
947
940
  ae as I,
948
- Pt as a,
949
- Rt as b,
950
- Et as c,
951
- xt as d,
952
- Tt as e,
953
- At as f,
941
+ Rt as a,
942
+ xt as b,
943
+ Pt as c,
944
+ Tt as d,
945
+ At as e,
946
+ jt as f,
954
947
  vt as g,
955
948
  Ot as h,
956
949
  St as i,
957
950
  bt as j,
958
- Nt as k,
959
- ie as l,
960
- $e as m,
961
- jt as n,
962
- Mt as o,
963
- ct as p,
964
- ot as r,
965
- Y as s,
966
- X as t
951
+ Mt as k,
952
+ Et as l,
953
+ lt as m,
954
+ Y as s
967
955
  };