okno 1.0.0-beta.22 → 1.0.0-beta.24

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/cli.d.ts CHANGED
@@ -1,3 +1,8 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ /**
3
+ * `okno` CLI. The canonical command is BARE `npx okno` — the context-aware
4
+ * installer (adds the plugin, scaffolds, offers MCP). `okno mcp` runs the MCP
5
+ * server. Each path lazy-imports its deps so neither pays for the other's.
6
+ */
7
+ declare function main(): Promise<void>;
3
8
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA6BA,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAIH,iBAAe,IAAI,kBAuBlB"}
package/dist/cli.js CHANGED
@@ -1,22 +1,25 @@
1
1
  #!/usr/bin/env node
2
- const [n] = process.argv.slice(2);
3
- switch (n) {
4
- case "mcp": {
5
- const { runMcp: o } = await import("./mcp.js");
6
- await o();
7
- break;
8
- }
9
- case "help":
10
- case "--help":
11
- case "-h": {
12
- console.log(
13
- ["", " npx okno Add okno to this project", " npx okno mcp Run the okno MCP server (for your AI client)", ""].join(`
2
+ async function c() {
3
+ const [n] = process.argv.slice(2);
4
+ switch (n) {
5
+ case "mcp": {
6
+ const { runMcp: o } = await import("./mcp.js");
7
+ await o();
8
+ break;
9
+ }
10
+ case "help":
11
+ case "--help":
12
+ case "-h": {
13
+ console.log(
14
+ ["", " npx okno Add okno to this project", " npx okno mcp Run the okno MCP server (for your AI client)", ""].join(`
14
15
  `)
15
- );
16
- break;
17
- }
18
- default: {
19
- const { runInit: o } = await import("./init.js");
20
- await o();
16
+ );
17
+ break;
18
+ }
19
+ default: {
20
+ const { runInit: o } = await import("./init.js");
21
+ await o();
22
+ }
21
23
  }
22
24
  }
25
+ c();
@@ -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,iBAyHhE"}
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,iBAoIhE"}
@@ -1,14 +1,14 @@
1
- import { join as g, relative as U, sep as I, dirname as P, resolve as ie } from "node:path";
1
+ import { join as g, relative as z, sep as I, dirname as P, resolve as ie } from "node:path";
2
2
  import { readdir as x, readFile as _e, writeFile as $e } from "node:fs/promises";
3
- import { existsSync as _, readFileSync as b, readdirSync as D, statSync as ke, realpathSync as we, writeFileSync as T, mkdirSync as M, unlinkSync as L, renameSync as Se } from "node:fs";
3
+ import { existsSync as _, readFileSync as S, readdirSync as D, statSync as ke, realpathSync as we, writeFileSync as T, mkdirSync as M, unlinkSync as F, renameSync as be } from "node:fs";
4
4
  import { execSync as ee } from "node:child_process";
5
- import { fileURLToPath as be } from "node:url";
5
+ import { fileURLToPath as Se } from "node:url";
6
6
  import { p as J } from "./parse-tlTHgSSs.js";
7
- import { o as ve } from "./order-bAkdncZC.js";
7
+ import { o as Oe } from "./order-bAkdncZC.js";
8
8
  import { simpleGit as le } from "simple-git";
9
- import { b as q, a as Oe, e as je } from "./encode-BfJY0Xy5.js";
10
- import { applyKeyChanges as ce, setStringsSchema as Te, saveFields as Ae, setLocales as xe, setName as Pe, setUrl as Re, renameSlug as Me, reorderKind as Ee, setLayout as Ne, setCollectionOrder as Ie, setDrafts as We, deleteSchemaEntry as Fe, scaffoldEntry as Le, fieldsToContent as ze, EngineError as Ce } from "./engine/index.js";
11
- const Ue = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), Je = /* @__PURE__ */ new Set([
9
+ import { b as q, a as ve, e as je } from "./encode-BfJY0Xy5.js";
10
+ import { applyKeyChanges as ce, setStringsSchema as Te, saveFields as Ae, setLocales as xe, setName as Pe, setUrl as Re, renameSlug as Me, reorderKind as Ee, setLayout as Ne, setCollectionOrder as Ie, setDrafts as We, deleteSchemaEntry as Le, scaffoldEntry as Fe, fieldsToContent as Ce, EngineError as Ue } from "./engine/index.js";
11
+ const ze = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), Je = /* @__PURE__ */ new Set([
12
12
  "node_modules",
13
13
  ".astro",
14
14
  ".svelte-kit",
@@ -39,7 +39,7 @@ async function Z(e, n) {
39
39
  const t = u.name.lastIndexOf(".");
40
40
  if (t === -1) continue;
41
41
  const o = u.name.slice(t);
42
- if (!Ue.has(o)) continue;
42
+ if (!ze.has(o)) continue;
43
43
  let r;
44
44
  try {
45
45
  r = await _e(i, "utf-8");
@@ -79,18 +79,29 @@ async function $t(e, n) {
79
79
  " readonly exists: boolean",
80
80
  "}",
81
81
  "",
82
- "/** Array-membership boundary — only on array items (never on a scalar `{...field}` spread, so it can't collide with HTML attributes). Spread onto the item wrapper: `<article {...item.slot}>` data-okno-item=\"<list>.<i>\". `slot` is a reserved field key so content can't shadow it. */",
82
+ "/** Array-membership boundary — only on array items (never on a scalar `{...field}` spread, so it can't collide with HTML attributes). BLOCK wrappers spread `.slot` explicitly (`<article {...item.slot}>`); a LEAF multiple (media/link/text) gets `data-okno-item` straight off `{...item}` (see OknoSlotItem), so one spread = edit + reorder. `slot` is a reserved field key so content can't shadow it. */",
83
83
  'type OknoSlot = { readonly slot: { readonly "data-okno-item": string } }',
84
+ "/** The reorder hook carried directly on an array item's spread (`{...item}`), so a leaf multiple needs no separate `{...item.slot}`. */",
85
+ 'type OknoSlotItem = { readonly "data-okno-item": string }',
86
+ "/** One array member. A LEAF (media/link/text) is spread bare — `{...item}` — so it carries `data-okno-item` but NOT the object-valued `.slot` (spreading that onto an element sets the HTML `slot` attr to an object → type error). A BLOCK/reference member has inner fields and is spread via its wrapper's `.slot`, so it keeps `OknoSlot`. */",
87
+ "type OknoArrayItem<U> =",
88
+ " U extends string | number | boolean",
89
+ " ? OknoWrapped<U> & OknoSlotItem",
90
+ " : U extends { src: string }",
91
+ " ? OknoWrapped<U> & OknoSlotItem",
92
+ " : U extends { url: string; text: string }",
93
+ " ? OknoWrapped<U> & OknoSlotItem",
94
+ " : OknoWrapped<U> & OknoSlot",
84
95
  "",
85
96
  "/** A media value's `.image` handle — a spreadable bundle for a framework image component (Astro `<Image {...cover.image}>`): build-optimized `src` (from `okno/files`), plus alt/dimensions and the edit hook. Use `<img {...cover}>` for the raw/universal path. `src` is loose (framework's shape, e.g. Astro `ImageMetadata`) so okno stays framework-agnostic. */",
86
97
  'type OknoImage = { src: any; alt: string; width?: number; height?: number; readonly "data-okno": string }',
87
98
  "",
88
- "/** Recursively wraps content types so values are spreadable/renderable. Media (`{src}`) and link (`{url,text}`) objects keep RAW attribute values so `<img {...media}>` / `<a {...link}>` type-check; media also exposes `.image`; other objects expose wrapped fields + the data-okno hook. Array items also carry `.slot`. */",
99
+ "/** Recursively wraps content types so values are spreadable/renderable. Media (`{src}`) and link (`{url,text}`) objects keep RAW attribute values so `<img {...media}>` / `<a {...link}>` type-check; media also exposes `.image`; other objects expose wrapped fields + the data-okno hook. Array items also carry `.slot` (block wrappers) AND `data-okno-item` on the bare spread (leaf multiples). */",
89
100
  "type OknoWrapped<T> =",
90
101
  " T extends string | number | boolean",
91
102
  " ? OknoValue<T>",
92
103
  " : T extends ReadonlyArray<infer U>",
93
- " ? (OknoWrapped<U> & OknoSlot)[]",
104
+ " ? OknoArrayItem<U>[]",
94
105
  " : T extends { src: string }",
95
106
  ' ? Omit<T, "focal"> & OknoValue<T> & { readonly image: OknoImage } & (T extends { focal: infer F } ? { readonly focal: OknoWrapped<F> } : {})',
96
107
  " : T extends { url: string; text: string }",
@@ -114,17 +125,17 @@ async function $t(e, n) {
114
125
  ([, w]) => w?.type === "reference" && typeof w.collection == "string" && a.has(w.collection)
115
126
  ), $ = d.filter(([, w]) => w?.type === "enum"), k = '"created" | "updated"';
116
127
  if (y.length === 0 && $.length === 0) return `OknoWrapped<Omit<${c}, ${k}>> & OknoMeta`;
117
- const v = `${[...y, ...$].map(([w]) => `"${w}"`).join(" | ")} | ${k}`, O = [
118
- ...y.map(([w, S]) => {
119
- const R = `typeof import("./collections/${S.collection}/${a.get(S.collection)}").default`;
120
- return `${w}: ${S.multiple ? `${R}[]` : R}`;
128
+ const O = `${[...y, ...$].map(([w]) => `"${w}"`).join(" | ")} | ${k}`, v = [
129
+ ...y.map(([w, b]) => {
130
+ const R = `typeof import("./collections/${b.collection}/${a.get(b.collection)}").default`;
131
+ return `${w}: ${b.multiple ? `${R}[]` : R}`;
121
132
  }),
122
- ...$.map(([w, S]) => {
123
- const R = (Array.isArray(S.options) ? S.options : []).map((A) => typeof A == "string" ? A : A?.value).filter((A) => typeof A == "string"), F = `{ name: string; value: ${R.length ? R.map((A) => JSON.stringify(A)).join(" | ") : "string"} }`;
124
- return `${w}: ${S.multiple ? `${F}[]` : F}`;
133
+ ...$.map(([w, b]) => {
134
+ const R = (Array.isArray(b.options) ? b.options : []).map((A) => typeof A == "string" ? A : A?.value).filter((A) => typeof A == "string"), L = `{ name: string; value: ${R.length ? R.map((A) => JSON.stringify(A)).join(" | ") : "string"} }`;
135
+ return `${w}: ${b.multiple ? `${L}[]` : L}`;
125
136
  })
126
137
  ].join("; ");
127
- return `OknoWrapped<Omit<${c}, ${v}> & { ${O} }> & OknoMeta`;
138
+ return `OknoWrapped<Omit<${c}, ${O}> & { ${v} }> & OknoMeta`;
128
139
  }, [u, i, t] = await Promise.all([
129
140
  Z(n, "pages"),
130
141
  Z(n, "globals"),
@@ -134,7 +145,7 @@ async function $t(e, n) {
134
145
  ...ue("okno:pages", "pages", await Q(g(e, "pages")), u, m)
135
146
  ), l.push(...Ze(s, t, m)), l.push(
136
147
  ...ue("okno:globals", "globals", await Q(g(e, "globals")), i, m)
137
- ), l.push(...Ge(qe(e), He(f))), l.push(...Ve()), l.push(...Be());
148
+ ), l.push(...Ge(qe(e), He(f))), l.push(...Be()), l.push(...Ve());
138
149
  for (const o of ["pages", "collections", "globals", "locales", "strings", "content"])
139
150
  l.push(`declare module "okno/${o}" {`, ` export * from "okno:${o}";`, "}", "");
140
151
  await $e(g(e, "modules.d.ts"), l.join(`
@@ -148,7 +159,7 @@ function ue(e, n, s, a, f) {
148
159
  l.has(u) || m.push(` export const ${u}: OknoUnscaffolded`);
149
160
  return [`declare module "${e}" {`, ...m, "}", ""];
150
161
  }
151
- function Ve() {
162
+ function Be() {
152
163
  return [
153
164
  'declare module "okno:locales" {',
154
165
  ' /** 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. */',
@@ -164,7 +175,7 @@ function Ve() {
164
175
  ""
165
176
  ];
166
177
  }
167
- function Be() {
178
+ function Ve() {
168
179
  return [
169
180
  'declare module "okno:content" {',
170
181
  ' /** Unified content namespace — `import * as okno from "okno:content"` then `okno.pages.home`, `okno.globals.nav`, `okno.collections.articles`, `okno.strings.nav.home`. */',
@@ -232,7 +243,7 @@ function Xe(e) {
232
243
  const n = g(e, "schema.ts");
233
244
  if (!_(n)) return null;
234
245
  try {
235
- let s = b(n, "utf8");
246
+ let s = S(n, "utf8");
236
247
  const a = s.indexOf("export default");
237
248
  return a === -1 ? null : (s = s.slice(a + 14).replace(/\bas const\b/g, "").replace(/\bsatisfies\s+[A-Za-z0-9_.]+/g, "").trim(), s.endsWith(";") && (s = s.slice(0, -1).trim()), JSON.parse(s));
238
249
  } catch {
@@ -243,7 +254,7 @@ function qe(e) {
243
254
  const n = g(e, "strings.ts");
244
255
  if (!_(n)) return [];
245
256
  try {
246
- let s = b(n, "utf8");
257
+ let s = S(n, "utf8");
247
258
  const a = s.indexOf("export default");
248
259
  if (a === -1) return [];
249
260
  s = s.slice(a + 14).replace(/\bas const\b/g, "").replace(/\bsatisfies\s+[A-Za-z0-9_.]+/g, "").trim(), s.endsWith(";") && (s = s.slice(0, -1).trim());
@@ -291,20 +302,20 @@ function kt() {
291
302
  }
292
303
  function wt() {
293
304
  const e = te("git rev-parse --show-toplevel");
294
- return e ? U(e, process.cwd()).split(I).join("/") : "";
305
+ return e ? z(e, process.cwd()).split(I).join("/") : "";
295
306
  }
296
- const ne = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', fe = P(be(import.meta.url)), De = [
307
+ const ne = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))', fe = P(Se(import.meta.url)), De = [
297
308
  ie(fe, "./runtime/wrap.js"),
298
309
  // bundled at dist/ (Vite plugin chunk)
299
310
  ie(fe, "../runtime/wrap.js")
300
311
  // bundled at dist/next/ (Next entry)
301
312
  ];
302
- function St() {
313
+ function bt() {
303
314
  for (const e of De)
304
- if (_(e)) return b(e, "utf-8");
315
+ if (_(e)) return S(e, "utf-8");
305
316
  return null;
306
317
  }
307
- function bt() {
318
+ function St() {
308
319
  return [
309
320
  'export * as pages from "okno:pages"',
310
321
  'export * as globals from "okno:globals"',
@@ -313,11 +324,11 @@ function bt() {
313
324
  ].join(`
314
325
  `);
315
326
  }
316
- function B(e) {
327
+ function V(e) {
317
328
  const n = g(e, "schema.ts");
318
329
  if (!_(n)) return null;
319
330
  try {
320
- const a = J(b(n, "utf-8"))?.locales?.supported;
331
+ const a = J(S(n, "utf-8"))?.locales?.supported;
321
332
  if (!Array.isArray(a) || a.length === 0) return null;
322
333
  const f = a.map((l) => typeof l == "string" ? l : l?.id).filter((l) => typeof l == "string");
323
334
  return f.length ? new Set(f) : null;
@@ -325,7 +336,7 @@ function B(e) {
325
336
  return null;
326
337
  }
327
338
  }
328
- function C(e, n) {
339
+ function U(e, n) {
329
340
  return n ? n.has(e) : nt.test(e);
330
341
  }
331
342
  function et(e) {
@@ -344,7 +355,7 @@ function tt(e) {
344
355
  const n = g(e, "schema.ts"), s = {}, a = /* @__PURE__ */ new Set();
345
356
  if (!_(n)) return { orders: s, drafts: a };
346
357
  try {
347
- const l = J(b(n, "utf-8"))?.collections ?? {};
358
+ const l = J(S(n, "utf-8"))?.collections ?? {};
348
359
  for (const [m, u] of Object.entries(l))
349
360
  Array.isArray(u?.order) && (s[m] = u.order.filter((i) => typeof i == "string")), u?.drafts === !0 && a.add(m);
350
361
  } catch {
@@ -358,15 +369,15 @@ function oe(e) {
358
369
  function he(e) {
359
370
  return e.replace(".ts", "").replace(/-/g, "_");
360
371
  }
361
- function V(e) {
372
+ function B(e) {
362
373
  return e.replace(".ts", "");
363
374
  }
364
- function vt(e) {
375
+ function Ot(e) {
365
376
  const n = g(e, "schema.ts");
366
377
  let s = [], a = "";
367
378
  if (_(n))
368
379
  try {
369
- const f = J(b(n, "utf-8")), l = f?.locales?.supported;
380
+ const f = J(S(n, "utf-8")), l = f?.locales?.supported;
370
381
  Array.isArray(l) && (s = l.map((m) => typeof m == "string" ? { id: m } : m).filter((m) => !!m && typeof m.id == "string").map((m) => ({
371
382
  id: m.id,
372
383
  name: m.name || et(m.id),
@@ -403,7 +414,7 @@ function vt(e) {
403
414
  ].join(`
404
415
  `);
405
416
  }
406
- async function Ot(e) {
417
+ async function vt(e) {
407
418
  const n = g(e, "strings.ts");
408
419
  if (!_(n))
409
420
  return [
@@ -411,13 +422,13 @@ async function Ot(e) {
411
422
  'export const strings = __oknoMakeStrings({}, {}, "")'
412
423
  ].join(`
413
424
  `);
414
- const s = g(e, "schema.ts"), a = _(s), f = B(e), l = g(e, "strings"), m = [];
425
+ const s = g(e, "schema.ts"), a = _(s), f = V(e), l = g(e, "strings"), m = [];
415
426
  if (_(l)) {
416
427
  const r = await x(l, { withFileTypes: !0 });
417
428
  for (const p of r) {
418
429
  if (!p.isFile() || !p.name.endsWith(".ts") || p.name === "index.ts") continue;
419
430
  const c = p.name.replace(/\.ts$/, "");
420
- C(c, f) && m.push(c);
431
+ U(c, f) && m.push(c);
421
432
  }
422
433
  }
423
434
  const u = [
@@ -450,24 +461,24 @@ async function jt(e, n = /* @__PURE__ */ new Set()) {
450
461
  return `__oknoResolveEnums(__oknoResolveRefs(_${t}, ${r}, __collections, ${m}), ${r}, ${m})`;
451
462
  }, i = /* @__PURE__ */ new Set();
452
463
  if (_(s)) {
453
- const t = B(e), r = (await x(s, { withFileTypes: !0 })).filter((c) => c.isDirectory() && C(c.name, t)).map((c) => c.name);
464
+ const t = V(e), r = (await x(s, { withFileTypes: !0 })).filter((c) => c.isDirectory() && U(c.name, t)).map((c) => c.name);
454
465
  m = JSON.stringify(r);
455
466
  const p = await se(s);
456
467
  for (const c of p) {
457
- const h = oe(c), d = he(c), y = V(c), $ = g(s, c);
468
+ const h = oe(c), d = he(c), y = B(c), $ = g(s, c);
458
469
  if (r.length === 0) {
459
470
  l.push(`import _${h} from "${$}"`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
460
471
  continue;
461
472
  }
462
- const k = [`import _${h}_default from "${$}"`], v = [];
463
- for (const O of r) {
464
- const w = g(s, O, c);
473
+ const k = [`import _${h}_default from "${$}"`], O = [];
474
+ for (const v of r) {
475
+ const w = g(s, v, c);
465
476
  if (_(w)) {
466
- const S = G(O);
467
- k.push(`import _${h}_${S} from "${w}"`), v.push(`"${O}": _${h}_${S}`);
477
+ const b = G(v);
478
+ k.push(`import _${h}_${b} from "${w}"`), O.push(`"${v}": _${h}_${b}`);
468
479
  }
469
480
  }
470
- l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${v.join(", ")} })`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
481
+ l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${O.join(", ")} })`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
471
482
  }
472
483
  }
473
484
  for (const t of n)
@@ -486,11 +497,11 @@ async function Tt(e, n = /* @__PURE__ */ new Set(), s = !1) {
486
497
  return d.join(`
487
498
  `) || "export {}";
488
499
  }
489
- const f = B(e), l = await x(a, { withFileTypes: !0 }), m = l.filter((d) => d.isDirectory() && C(d.name, f)).map((d) => d.name), u = l.filter((d) => d.isDirectory() && !m.includes(d.name)).map((d) => d.name), i = JSON.stringify(m);
500
+ const f = V(e), l = await x(a, { withFileTypes: !0 }), m = l.filter((d) => d.isDirectory() && U(d.name, f)).map((d) => d.name), u = l.filter((d) => d.isDirectory() && !m.includes(d.name)).map((d) => d.name), i = JSON.stringify(m);
490
501
  for (const d of u) {
491
502
  const y = await x(g(a, d), { withFileTypes: !0 }).catch(() => []);
492
503
  for (const $ of y)
493
- $.isDirectory() && C($.name, f) && console.warn(
504
+ $.isDirectory() && U($.name, f) && console.warn(
494
505
  `[okno] "collections/${d}/${$.name}/" looks like a misplaced locale folder. Collection locale overrides go at "collections/${$.name}/${d}/<slug>.ts" (locale right after "collections/"). This folder will NOT be localized.`
495
506
  );
496
507
  }
@@ -501,31 +512,31 @@ async function Tt(e, n = /* @__PURE__ */ new Set(), s = !1) {
501
512
  p && c.push(`import __schema from "${r}"`);
502
513
  const h = [];
503
514
  for (const d of u) {
504
- const y = g(a, d), $ = ve(await se(y), V, t[d]), k = d.replace(/-/g, "_"), v = s && o.has(d), O = [];
515
+ const y = g(a, d), $ = Oe(await se(y), B, t[d]), k = d.replace(/-/g, "_"), O = s && o.has(d), v = [];
505
516
  for (const w of $) {
506
- const S = `_${k}_${oe(w)}`, R = V(w), K = g(y, w);
517
+ const b = `_${k}_${oe(w)}`, R = B(w), K = g(y, w);
507
518
  if (m.length === 0)
508
- c.push(`import ${S} from "${K}"`);
519
+ c.push(`import ${b} from "${K}"`);
509
520
  else {
510
- const F = [`import ${S}_default from "${K}"`], A = [];
521
+ const L = [`import ${b}_default from "${K}"`], A = [];
511
522
  for (const H of m) {
512
523
  const re = g(a, H, d, w);
513
524
  if (_(re)) {
514
525
  const ae = G(H);
515
- F.push(`import ${S}_${ae} from "${re}"`), A.push(`"${H}": ${S}_${ae}`);
526
+ L.push(`import ${b}_${ae} from "${re}"`), A.push(`"${H}": ${b}_${ae}`);
516
527
  }
517
528
  }
518
- c.push(...F), c.push(`const ${S} = __oknoLocalize(${S}_default, { ${A.join(", ")} })`);
529
+ c.push(...L), c.push(`const ${b} = __oknoLocalize(${b}_default, { ${A.join(", ")} })`);
519
530
  }
520
- O.push({ varName: S, itemName: R });
531
+ v.push({ varName: b, itemName: R });
521
532
  }
522
- c.push(`const __oknoRaw_${k} = [${O.map((w) => w.varName).join(", ")}]`), h.push({ name: d, safe: k, draftsOn: v, items: O });
533
+ c.push(`const __oknoRaw_${k} = [${v.map((w) => w.varName).join(", ")}]`), h.push({ name: d, safe: k, draftsOn: O, items: v });
523
534
  }
524
535
  p && c.push(`const __oknoNs = { ${h.map((d) => `${d.safe}: __oknoRaw_${d.safe}`).join(", ")} }`);
525
536
  for (const d of h) {
526
537
  const y = (k) => {
527
- const v = `__schema?.collections?.["${d.name}"]?.fields`;
528
- return `__oknoWrap(${p ? `__oknoResolveEnums(__oknoResolveRefs(${k.varName}, ${v}, __oknoNs, ${i}), ${v}, ${i})` : k.varName}, "${d.name}.${k.itemName}")`;
538
+ const O = `__schema?.collections?.["${d.name}"]?.fields`;
539
+ return `__oknoWrap(${p ? `__oknoResolveEnums(__oknoResolveRefs(${k.varName}, ${O}, __oknoNs, ${i}), ${O}, ${i})` : k.varName}, "${d.name}.${k.itemName}")`;
529
540
  }, $ = d.draftsOn ? `[${d.items.map((k) => `[${k.varName}, ${y(k)}]`).join(", ")}].filter((e) => e[0]?.status !== "draft").map((e) => e[1])` : `[${d.items.map(y).join(", ")}]`;
530
541
  c.push(`export const ${d.safe} = ${$}`);
531
542
  }
@@ -545,24 +556,24 @@ async function At(e, n = /* @__PURE__ */ new Set()) {
545
556
  return `__oknoResolveEnums(__oknoResolveRefs(_${t}, ${r}, __collections, ${m}), ${r}, ${m})`;
546
557
  }, i = /* @__PURE__ */ new Set();
547
558
  if (_(s)) {
548
- const t = B(e), r = (await x(s, { withFileTypes: !0 })).filter((c) => c.isDirectory() && C(c.name, t)).map((c) => c.name);
559
+ const t = V(e), r = (await x(s, { withFileTypes: !0 })).filter((c) => c.isDirectory() && U(c.name, t)).map((c) => c.name);
549
560
  m = JSON.stringify(r);
550
561
  const p = await se(s);
551
562
  for (const c of p) {
552
- const h = oe(c), d = he(c), y = V(c), $ = g(s, c);
563
+ const h = oe(c), d = he(c), y = B(c), $ = g(s, c);
553
564
  if (r.length === 0) {
554
565
  l.push(`import _${h} from "${$}"`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
555
566
  continue;
556
567
  }
557
- const k = [`import _${h}_default from "${$}"`], v = [];
558
- for (const O of r) {
559
- const w = g(s, O, c);
568
+ const k = [`import _${h}_default from "${$}"`], O = [];
569
+ for (const v of r) {
570
+ const w = g(s, v, c);
560
571
  if (_(w)) {
561
- const S = G(O);
562
- k.push(`import _${h}_${S} from "${w}"`), v.push(`"${O}": _${h}_${S}`);
572
+ const b = G(v);
573
+ k.push(`import _${h}_${b} from "${w}"`), O.push(`"${v}": _${h}_${b}`);
563
574
  }
564
575
  }
565
- l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${v.join(", ")} })`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
576
+ l.push(...k), l.push(`const _${h} = __oknoLocalize(_${h}_default, { ${O.join(", ")} })`), l.push(`export const ${d} = __oknoWrap(${u(h, y)}, "${y}")`), i.add(d);
566
577
  }
567
578
  }
568
579
  for (const t of n)
@@ -596,14 +607,14 @@ function ot(e) {
596
607
  const m = g(f, l.name);
597
608
  if (l.isDirectory()) s(m);
598
609
  else if (l.name.endsWith(".ts") && l.name !== "index.ts") {
599
- const u = U(e, m).split(I).join("/");
600
- n[u] = b(m, "utf-8");
610
+ const u = z(e, m).split(I).join("/");
611
+ n[u] = S(m, "utf-8");
601
612
  }
602
613
  }
603
614
  };
604
615
  for (const f of st) s(g(e, f));
605
616
  const a = g(e, "strings.ts");
606
- return _(a) && (n["strings.ts"] = b(a, "utf-8")), s(g(e, "strings")), n;
617
+ return _(a) && (n["strings.ts"] = S(a, "utf-8")), s(g(e, "strings")), n;
607
618
  }
608
619
  function ye(e) {
609
620
  const n = g(e, "files"), s = [], a = (f) => {
@@ -612,7 +623,7 @@ function ye(e) {
612
623
  const m = g(f, l.name);
613
624
  if (l.isDirectory()) a(m);
614
625
  else if (l.name !== ".okno-tree.json") {
615
- const u = U(n, m).split(I).join("/");
626
+ const u = z(n, m).split(I).join("/");
616
627
  s.push({ path: `files/${u}`, filename: l.name, size: ke(m).size });
617
628
  }
618
629
  }
@@ -622,10 +633,10 @@ function ye(e) {
622
633
  function rt(e) {
623
634
  const n = g(e, "schema.ts"), s = g(e, "users.json"), a = g(e, "settings.json"), f = g(e, "origins.json");
624
635
  return {
625
- schema: _(n) ? b(n, "utf-8") : null,
626
- users: _(s) ? b(s, "utf-8") : null,
627
- settings: _(a) ? b(a, "utf-8") : null,
628
- origins: _(f) ? b(f, "utf-8") : null,
636
+ schema: _(n) ? S(n, "utf-8") : null,
637
+ users: _(s) ? S(s, "utf-8") : null,
638
+ settings: _(a) ? S(a, "utf-8") : null,
639
+ origins: _(f) ? S(f, "utf-8") : null,
629
640
  content: ot(e),
630
641
  files: ye(e)
631
642
  };
@@ -637,7 +648,7 @@ function j(e) {
637
648
 
638
649
  `, a = {};
639
650
  if (_(n)) {
640
- const f = b(n, "utf-8"), l = f.indexOf("export default");
651
+ const f = S(n, "utf-8"), l = f.indexOf("export default");
641
652
  l > 0 && (s = f.slice(0, l));
642
653
  try {
643
654
  a = J(f) ?? {};
@@ -648,7 +659,7 @@ function j(e) {
648
659
  return { schema: a, header: s };
649
660
  }
650
661
  function at(e, n, s) {
651
- T(g(e, "schema.ts"), Oe(n, s));
662
+ T(g(e, "schema.ts"), ve(n, s));
652
663
  }
653
664
  function it(e, n, s, a, f) {
654
665
  const l = g(e, n), m = new Set(f), u = [];
@@ -663,7 +674,7 @@ function it(e, n, s, a, f) {
663
674
  for (const o of i) {
664
675
  let r;
665
676
  try {
666
- r = J(b(o, "utf-8"));
677
+ r = J(S(o, "utf-8"));
667
678
  } catch {
668
679
  continue;
669
680
  }
@@ -683,7 +694,7 @@ function it(e, n, s, a, f) {
683
694
  continue;
684
695
  if (!c) continue;
685
696
  N(o), T(o, q(p));
686
- const h = U(e, o).split(I).join("/");
697
+ const h = z(e, o).split(I).join("/");
687
698
  u.push({ rel: h, abs: o }), console.log(`[okno] field-change migrated content: ${h}`, { renames: a, deletes: f });
688
699
  }
689
700
  return u;
@@ -693,17 +704,17 @@ function Y(e) {
693
704
  return X || (X = ee("git rev-parse --show-toplevel", { cwd: e, encoding: "utf-8" }).trim()), X;
694
705
  }
695
706
  function pe(e) {
696
- return U(Y(e), we(e)).split(I).join("/");
707
+ return z(Y(e), we(e)).split(I).join("/");
697
708
  }
698
- let z;
709
+ let C;
699
710
  function lt(e) {
700
- if (z !== void 0) return z;
711
+ if (C !== void 0) return C;
701
712
  try {
702
- z = ee("git config user.name", { cwd: e, encoding: "utf-8" }).trim() || "local";
713
+ C = ee("git config user.name", { cwd: e, encoding: "utf-8" }).trim() || "local";
703
714
  } catch {
704
- z = "local";
715
+ C = "local";
705
716
  }
706
- return z;
717
+ return C;
707
718
  }
708
719
  async function Pt(e, n) {
709
720
  const { method: s, route: a } = n, f = { files: [], modules: [] }, l = (t, o) => {
@@ -726,7 +737,7 @@ async function Pt(e, n) {
726
737
  const t = (await n.json())?.path;
727
738
  if (!t) return i(400, { error: "Missing path" });
728
739
  const o = E(e, t);
729
- return o ? (_(o) && (L(o), l(t, o)), i(200, { ok: !0 })) : i(400, { error: "Invalid path" });
740
+ return o ? (_(o) && (F(o), l(t, o)), i(200, { ok: !0 })) : i(400, { error: "Invalid path" });
730
741
  }
731
742
  if (s === "POST" && a === "strings/save") {
732
743
  const { path: t, content: o } = await n.json();
@@ -770,7 +781,7 @@ async function Pt(e, n) {
770
781
  Ae(h, t, o, r), u(h, d);
771
782
  const y = p && typeof p == "object" ? p : {}, $ = Array.isArray(c) ? c : [];
772
783
  if (Object.keys(y).length > 0 || $.length > 0)
773
- for (const { rel: k, abs: v } of it(e, t, o, y, $)) l(k, v);
784
+ for (const { rel: k, abs: O } of it(e, t, o, y, $)) l(k, O);
774
785
  return i(200, { ok: !0, commit: { fileSha: "" }, schema: h });
775
786
  }
776
787
  if (s === "POST" && a === "schema/set-locales") {
@@ -796,7 +807,7 @@ async function Pt(e, n) {
796
807
  if (h) return i(200, { ok: !0, unchanged: !0 });
797
808
  u(p, c);
798
809
  const d = `${t}/${o}.ts`, y = `${t}/${r}.ts`, $ = E(e, d), k = E(e, y);
799
- return $ && k && _($) && (M(P(k), { recursive: !0 }), N($), N(k), T(k, b($)), L($), l(d, $), l(y, k)), i(200, { ok: !0, commit: { fileSha: "" }, schema: p, from: o, to: r, kind: t });
810
+ return $ && k && _($) && (M(P(k), { recursive: !0 }), N($), N(k), T(k, S($)), F($), l(d, $), l(y, k)), i(200, { ok: !0, commit: { fileSha: "" }, schema: p, from: o, to: r, kind: t });
800
811
  }
801
812
  if (s === "POST" && a === "schema/reorder") {
802
813
  const { kind: t, order: o } = await n.json();
@@ -826,19 +837,19 @@ async function Pt(e, n) {
826
837
  const { kind: t, name: o } = await n.json();
827
838
  if (!t || !o) return i(400, { error: "Missing kind or name" });
828
839
  const { schema: r, header: p } = j(e);
829
- Fe(r, t, o), u(r, p);
840
+ Le(r, t, o), u(r, p);
830
841
  const c = `${t}/${o}.ts`, h = E(e, c);
831
- return h && _(h) && (N(h), L(h), l(c, h)), i(200, { ok: !0, commit: { fileSha: "" }, schema: r });
842
+ return h && _(h) && (N(h), F(h), l(c, h)), i(200, { ok: !0, commit: { fileSha: "" }, schema: r });
832
843
  }
833
844
  if (s === "POST" && a === "setup/scaffold-page") {
834
845
  const { name: t, kind: o, fields: r, label: p } = await n.json();
835
846
  if (!t || !o) return i(400, { error: "Missing name or kind" });
836
847
  const c = r ?? [], { schema: h, header: d } = j(e);
837
- if (Le(h, t, o, c, p), u(h, d), o !== "blocks") {
848
+ if (Fe(h, t, o, c, p), u(h, d), o !== "blocks") {
838
849
  const y = `${o}/${t}.ts`, $ = E(e, y);
839
850
  if ($) {
840
851
  const k = o === "collections" ? `export default []
841
- ` : q(ze(c));
852
+ ` : q(Ce(c));
842
853
  M(P($), { recursive: !0 }), N($), T($, k), l(y, $);
843
854
  }
844
855
  }
@@ -848,7 +859,7 @@ async function Pt(e, n) {
848
859
  const t = g(e, "files", ".okno-tree.json");
849
860
  return i(200, {
850
861
  files: ye(e),
851
- manifest: _(t) ? b(t, "utf-8") : null
862
+ manifest: _(t) ? S(t, "utf-8") : null
852
863
  });
853
864
  }
854
865
  if (s === "POST" && a === "files/blob") {
@@ -872,14 +883,14 @@ async function Pt(e, n) {
872
883
  const t = (await n.json())?.path;
873
884
  if (!t) return i(400, { error: "Missing path" });
874
885
  const o = W(e, t);
875
- return o ? (_(o) && L(o), i(200, { ok: !0 })) : i(400, { error: "Invalid path" });
886
+ return o ? (_(o) && F(o), i(200, { ok: !0 })) : i(400, { error: "Invalid path" });
876
887
  }
877
888
  if (s === "POST" && a === "files/delete-many") {
878
889
  const t = (await n.json())?.paths;
879
890
  if (!Array.isArray(t)) return i(400, { error: "Missing paths" });
880
891
  for (const o of t) {
881
892
  const r = W(e, String(o));
882
- r && _(r) && L(r);
893
+ r && _(r) && F(r);
883
894
  }
884
895
  return i(200, { ok: !0 });
885
896
  }
@@ -887,7 +898,7 @@ async function Pt(e, n) {
887
898
  const { from: t, to: o } = await n.json();
888
899
  if (!t || !o) return i(400, { error: "Missing from or to" });
889
900
  const r = W(e, t), p = W(e, o);
890
- return !r || !p ? i(400, { error: "Invalid path" }) : _(r) ? (M(P(p), { recursive: !0 }), Se(r, p), i(200, { ok: !0, commit: { fileSha: "" } })) : i(404, { error: "Source not found" });
901
+ return !r || !p ? i(400, { error: "Invalid path" }) : _(r) ? (M(P(p), { recursive: !0 }), be(r, p), i(200, { ok: !0, commit: { fileSha: "" } })) : i(404, { error: "Source not found" });
891
902
  }
892
903
  if (s === "POST" && a === "users/save") {
893
904
  const t = (await n.json())?.users;
@@ -908,7 +919,7 @@ async function Pt(e, n) {
908
919
  }
909
920
  return null;
910
921
  } catch (t) {
911
- return t instanceof Ce ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
922
+ return t instanceof Ue ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
912
923
  }
913
924
  }
914
925
  export {
@@ -916,10 +927,10 @@ export {
916
927
  Tt as a,
917
928
  jt as b,
918
929
  At as c,
919
- Ot as d,
920
- vt as e,
921
- bt as f,
922
- St as g,
930
+ vt as d,
931
+ Ot as e,
932
+ St as f,
933
+ bt as g,
923
934
  wt as h,
924
935
  kt as i,
925
936
  $t as j,