okno 1.0.0-beta.11 → 1.0.0-beta.13
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/boot.d.ts +1 -87
- package/dist/boot.d.ts.map +1 -1
- package/dist/dispatch-bnmIdH8E.js +759 -0
- package/dist/editor/index.js +11851 -11356
- package/dist/{core/content-encode.d.ts → engine/encode.d.ts} +7 -6
- package/dist/engine/encode.d.ts.map +1 -0
- package/dist/engine/fields.d.ts +29 -0
- package/dist/engine/fields.d.ts.map +1 -0
- package/dist/engine/index.d.ts +17 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/{core → engine}/order.d.ts +2 -0
- package/dist/engine/order.d.ts.map +1 -0
- package/dist/{core → engine}/parse.d.ts +4 -3
- package/dist/engine/parse.d.ts.map +1 -0
- package/dist/engine/schema.d.ts +69 -0
- package/dist/engine/schema.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/local/disk.d.ts +57 -0
- package/dist/local/disk.d.ts.map +1 -0
- package/dist/local/dispatch.d.ts +27 -0
- package/dist/local/dispatch.d.ts.map +1 -0
- package/dist/local/self-written.d.ts +17 -0
- package/dist/local/self-written.d.ts.map +1 -0
- package/dist/mcp.js +1 -1
- package/dist/next/config.d.ts +13 -0
- package/dist/next/config.d.ts.map +1 -0
- package/dist/next/handler.d.ts +21 -0
- package/dist/next/handler.d.ts.map +1 -0
- package/dist/next/index.d.ts +14 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +79 -0
- package/dist/plugin-DkXOrSVC.js +721 -0
- package/dist/runtime/wrap.d.ts.map +1 -1
- package/dist/runtime/wrap.js +146 -145
- package/dist/vite/index.js +1 -1
- package/dist/vite/local-engine.d.ts +11 -27
- package/dist/vite/local-engine.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/runtime/wrap.ts +36 -28
- package/dist/core/content-encode.d.ts.map +0 -1
- package/dist/core/order.d.ts.map +0 -1
- package/dist/core/parse.d.ts.map +0 -1
- package/dist/plugin-D1AqM8JA.js +0 -1405
- /package/dist/{content-encode-DoojdsVU.js → encode-DoojdsVU.js} +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical serializers: a content/schema object → its `.ts` source module.
|
|
3
3
|
*
|
|
4
|
+
* Part of the framework-agnostic `engine` ring: pure, zero IO, zero bundler.
|
|
5
|
+
* Both local controllers (okno/vite, okno/next) import it.
|
|
6
|
+
*
|
|
4
7
|
* The byte format is a CONTRACT. The same logical content must encode
|
|
5
8
|
* identically on the live path (hosted backend → GitHub commit) and the dev
|
|
6
9
|
* path (local engine → disk write), or a publish round-trip shows phantom
|
|
7
|
-
* diffs. Keep this module dependency-free (pure string/JSON, no node/svelte)
|
|
8
|
-
* either side can import it.
|
|
10
|
+
* diffs. Keep this module dependency-free (pure string/JSON, no node/svelte).
|
|
9
11
|
*
|
|
10
12
|
* SYNC: `backend/src/lib/encode.ts` is a byte-identical copy. The backend is a
|
|
11
13
|
* separate deployable and this monorepo has no cross-package source imports
|
|
12
|
-
* (same controlled-duplication pattern as this package's
|
|
13
|
-
*
|
|
14
|
-
* change here MUST be mirrored there, and vice versa.
|
|
14
|
+
* (same controlled-duplication pattern as this package's `engine/parse.ts` ↔
|
|
15
|
+
* the backend's `lib/parse.ts`). Any change here MUST be mirrored there.
|
|
15
16
|
*/
|
|
16
17
|
export interface Stamp {
|
|
17
18
|
date: string;
|
|
@@ -41,4 +42,4 @@ export declare function encodeSchema(schema: Record<string, unknown>, header?: s
|
|
|
41
42
|
* page/global's default field values, or an empty `[]` collection).
|
|
42
43
|
*/
|
|
43
44
|
export declare function encodeRaw(value: unknown): string;
|
|
44
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/engine/encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,GACpD,MAAM,CAIR;AAED;;;;GAIG;AAGH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,SAA2C,GAC/C,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure field/content helpers — schema-shape ⇄ content-shape transforms used by
|
|
3
|
+
* scaffolding (new page/collection/global/block) and field-key migration
|
|
4
|
+
* (rename/delete field → carry values in existing content).
|
|
5
|
+
*
|
|
6
|
+
* Part of the framework-agnostic `engine` ring: pure, zero IO, zero bundler.
|
|
7
|
+
* Extracted from the local engine so okno/vite and okno/next share one copy.
|
|
8
|
+
*/
|
|
9
|
+
/** A field detected from markup or configured in the editor. `path` is a
|
|
10
|
+
* dot-path (`hero.title`); `type` the field type; `value` an optional seed. */
|
|
11
|
+
export type DetectedField = {
|
|
12
|
+
path: string;
|
|
13
|
+
type: string;
|
|
14
|
+
value?: unknown;
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
/** The empty seed value for a field type (content-shape). */
|
|
18
|
+
export declare function emptyValueFor(type: string): unknown;
|
|
19
|
+
/** Detected fields → a schema `fields` object, nesting dot-paths into groups. */
|
|
20
|
+
export declare function fieldsToSchema(fields: DetectedField[]): Record<string, any>;
|
|
21
|
+
/** Detected fields → a seed content object (nesting dot-paths, empty defaults). */
|
|
22
|
+
export declare function fieldsToContent(fields: DetectedField[]): Record<string, unknown>;
|
|
23
|
+
/** Apply field-key changes to a content object, preserving order: drop deleted
|
|
24
|
+
* keys, rename the rest (skipping a rename whose target already exists). */
|
|
25
|
+
export declare function applyKeyChanges(obj: Record<string, unknown>, renames: Record<string, string>, deletes: Set<string>): {
|
|
26
|
+
out: Record<string, unknown>;
|
|
27
|
+
changed: boolean;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/engine/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;gFACgF;AAChF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAA;AAEjG,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWnD;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkB3E;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAchF;AAED;6EAC6E;AAC7E,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GAClB;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAapD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `engine` — okno's framework-agnostic content engine.
|
|
3
|
+
*
|
|
4
|
+
* Pure parse → mutate → serialize. Zero IO, zero bundler, zero transport.
|
|
5
|
+
* The local controllers (okno/vite, okno/next) and, in time, the hosted backend
|
|
6
|
+
* all drive the SAME transforms from here; only the IO tail (disk vs GitHub) and
|
|
7
|
+
* the transport (Vite middleware vs Next Route Handler) differ per controller.
|
|
8
|
+
*
|
|
9
|
+
* Grow the engine by adding operations here — never by reaching into a bundler
|
|
10
|
+
* or the filesystem from within.
|
|
11
|
+
*/
|
|
12
|
+
export { parseExportDefault } from "./parse.ts";
|
|
13
|
+
export { encodeEntry, encodeSchema, encodeRaw, type Stamp } from "./encode.ts";
|
|
14
|
+
export { orderBySlugs, orderWithInsert, orderWithout } from "./order.ts";
|
|
15
|
+
export { emptyValueFor, fieldsToSchema, fieldsToContent, applyKeyChanges, type DetectedField, } from "./fields.ts";
|
|
16
|
+
export { EngineError, SLUG_RE, type SchemaObj, saveFields, setName, setUrl, renameSlug, reorderKind, setLayout, setCollectionOrder, setDrafts, deleteSchemaEntry, scaffoldEntry, setStringsSchema, setLocales, } from "./schema.ts";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,EACN,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,KAAK,aAAa,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,WAAW,EACX,OAAO,EACP,KAAK,SAAS,EACd,UAAU,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,UAAU,GACV,MAAM,aAAa,CAAA"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* build plugin (`okno:collections` iteration order) and the editor (collection
|
|
4
4
|
* table + reference lists). okno owns ONLY this manual order; any date/field
|
|
5
5
|
* sort is the dev's own `.sort()` in their template, right before `.map()`.
|
|
6
|
+
*
|
|
7
|
+
* Part of the framework-agnostic `engine` ring: pure, zero IO, zero bundler.
|
|
6
8
|
*/
|
|
7
9
|
/**
|
|
8
10
|
* Order `items` by an explicit slug list. Items whose slug appears in `order`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/engine/order.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,EACxC,KAAK,CAAC,EAAE,MAAM,EAAE,GACd,CAAC,EAAE,CAaL;AAED;kFACkF;AAClF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGnF;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhF"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parser for `export default { ... }` TypeScript content/schema files.
|
|
3
3
|
*
|
|
4
|
+
* Part of the framework-agnostic `engine` ring: pure, zero IO, zero bundler.
|
|
5
|
+
* Both local controllers (okno/vite, okno/next) import it.
|
|
6
|
+
*
|
|
4
7
|
* We must NOT execute file content (`new Function` would be an RCE and corrupts
|
|
5
8
|
* any string containing `//`). Instead we parse the `export default` expression
|
|
6
9
|
* with acorn and walk the AST, accepting ONLY literal data; anything that would
|
|
@@ -8,9 +11,7 @@
|
|
|
8
11
|
*
|
|
9
12
|
* PARITY / SYNC: byte-for-byte (parsing logic) with the editor's
|
|
10
13
|
* `editor/lib/parse-export-default.ts` and the backend's `lib/parse.ts` — THREE
|
|
11
|
-
* copies of the parser (local vs hosted), keep all in step.
|
|
12
|
-
* `src/` so the Vite plugin's local engine (which can't import across the editor
|
|
13
|
-
* `rootDir`) can read schema files. See docs/engine-parity.md.
|
|
14
|
+
* copies of the parser (local vs hosted), keep all in step. See docs/engine-parity.md.
|
|
14
15
|
*/
|
|
15
16
|
export declare function parseExportDefault(raw: string): Record<string, unknown>;
|
|
16
17
|
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/engine/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqDH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBvE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure schema transforms — the heart of the framework-agnostic `engine` ring.
|
|
3
|
+
*
|
|
4
|
+
* Each function takes the in-memory schema object (already parsed from disk /
|
|
5
|
+
* GitHub by a controller) plus its arguments, mutates it in place, and returns
|
|
6
|
+
* any info the caller needs to finish the IO tail (move a content file, seed
|
|
7
|
+
* content, etc). Validation failures throw `EngineError` carrying the HTTP
|
|
8
|
+
* status a controller should surface — no `req`/`res`, no `fs`, no bundler.
|
|
9
|
+
*
|
|
10
|
+
* The local controllers (okno/vite, okno/next) call these; the disk read/write
|
|
11
|
+
* lives in their shared IO layer. Zero IO, zero framework: `engine` grows by
|
|
12
|
+
* adding operations here, controllers only grow transport to reach them.
|
|
13
|
+
*/
|
|
14
|
+
import { type DetectedField } from "./fields.ts";
|
|
15
|
+
export type SchemaObj = Record<string, any>;
|
|
16
|
+
/** A validation/precondition failure with the HTTP status a controller maps to. */
|
|
17
|
+
export declare class EngineError extends Error {
|
|
18
|
+
status: number;
|
|
19
|
+
constructor(status: number, message: string);
|
|
20
|
+
}
|
|
21
|
+
export declare const SLUG_RE: RegExp;
|
|
22
|
+
/** Set a schema entry's `fields` object. */
|
|
23
|
+
export declare function saveFields(schema: SchemaObj, kind: string, name: string, fields: SchemaObj): void;
|
|
24
|
+
/** Rename a schema entry's display name (dropping any legacy `label`). */
|
|
25
|
+
export declare function setName(schema: SchemaObj, kind: string, slug: string, name: string): void;
|
|
26
|
+
/** Set (or clear) a schema entry's `url` routing pattern. */
|
|
27
|
+
export declare function setUrl(schema: SchemaObj, kind: string, slug: string, url: string | undefined): void;
|
|
28
|
+
/**
|
|
29
|
+
* Rename a schema entry's slug, preserving insertion order and remapping the
|
|
30
|
+
* sidebar layout (root + folder items). Returns `{ unchanged }` — `true` when
|
|
31
|
+
* from === to (caller should no-op the content-file move). Throws on invalid
|
|
32
|
+
* target, missing source, or a colliding target.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renameSlug(schema: SchemaObj, kind: string, from: string, to: string): {
|
|
35
|
+
unchanged: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Reorder the entries of a kind by an explicit slug list (unknowns kept last). */
|
|
38
|
+
export declare function reorderKind(schema: SchemaObj, kind: string, order: string[]): void;
|
|
39
|
+
/** Persist (or clear) a kind's sidebar layout (order + folders) on schema.layout. */
|
|
40
|
+
export declare function setLayout(schema: SchemaObj, kind: string, layout: unknown[]): void;
|
|
41
|
+
/** Persist a collection's manual item order (slug list) on collections[name].order. */
|
|
42
|
+
export declare function setCollectionOrder(schema: SchemaObj, name: string, order: string[]): void;
|
|
43
|
+
/** Toggle the draft workflow on a collection (collections[name].drafts). */
|
|
44
|
+
export declare function setDrafts(schema: SchemaObj, name: string, drafts: boolean): void;
|
|
45
|
+
/** Remove a schema entry. Throws if it doesn't exist. */
|
|
46
|
+
export declare function deleteSchemaEntry(schema: SchemaObj, kind: string, name: string): void;
|
|
47
|
+
/** Add a schema entry from detected fields (name from `label`, else capitalized slug). */
|
|
48
|
+
export declare function scaffoldEntry(schema: SchemaObj, name: string, kind: string, fields: DetectedField[], label?: string): void;
|
|
49
|
+
/** Set (or clear) the `schema.strings` slot-definition map. */
|
|
50
|
+
export declare function setStringsSchema(schema: SchemaObj, strings: Record<string, unknown> | null | undefined): void;
|
|
51
|
+
type LocalesInput = {
|
|
52
|
+
default?: string;
|
|
53
|
+
supported?: Array<string | {
|
|
54
|
+
id?: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
slug?: string;
|
|
57
|
+
}>;
|
|
58
|
+
} | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Normalize + validate the localization config, applying it to `schema.locales`
|
|
61
|
+
* (or clearing it when empty). Accepts the new `LocaleEntry[]` shape and legacy
|
|
62
|
+
* `string[]`; validates BCP-47 ids, rejects duplicates, and requires the default
|
|
63
|
+
* to be one of the supported locales. Throws EngineError(400) on invalid input.
|
|
64
|
+
*
|
|
65
|
+
* PARITY: mirrors backend/src/routes/api/schema/set-locales/+server.ts.
|
|
66
|
+
*/
|
|
67
|
+
export declare function setLocales(schema: SchemaObj, locales: LocalesInput): void;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/engine/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE3C,mFAAmF;AACnF,qBAAa,WAAY,SAAQ,KAAK;IACrC,MAAM,EAAE,MAAM,CAAA;gBACF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK3C;AAED,eAAO,MAAM,OAAO,QAAsC,CAAA;AAI1D,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAIjG;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAOzF;AAED,6DAA6D;AAC7D,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQnG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAyB5G;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAOlF;AAED,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAKlF;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAKzF;AAED,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAMhF;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIrF;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAG1H;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAG7G;AAED,KAAK,YAAY,GACd;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAC/F,IAAI,GACJ,SAAS,CAAA;AAEZ;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAyBzE"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type SchemaObj } from "../engine/index.ts";
|
|
2
|
+
export declare const CONTENT_KINDS: readonly ["pages", "collections", "globals"];
|
|
3
|
+
/** Resolve a content path (relative to oknoDir) to an absolute file, rejecting
|
|
4
|
+
* traversal. Must stay inside oknoDir and be a `.ts` module. */
|
|
5
|
+
export declare function safeEntryPath(oknoDir: string, rel: string): string | null;
|
|
6
|
+
/** Resolve a path (relative to oknoDir) to an absolute file, rejecting
|
|
7
|
+
* traversal. Allows any file under oknoDir (used for binary media + manifest). */
|
|
8
|
+
export declare function safeUnderOkno(oknoDir: string, rel: string): string | null;
|
|
9
|
+
/** Recursively list okno/files/ (excluding the manifest), keyed like the editor
|
|
10
|
+
* expects: { path: "files/<rel>", filename, size }. */
|
|
11
|
+
export declare function collectFiles(oknoDir: string): Array<{
|
|
12
|
+
path: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
size: number;
|
|
15
|
+
}>;
|
|
16
|
+
/** The full content snapshot the editor's load() consumes: raw `schema.ts`
|
|
17
|
+
* text, raw `users.json` text, and every content `.ts` keyed by relative path.
|
|
18
|
+
* Shared by the dev GET /content handler and the demo-mode build emit so both
|
|
19
|
+
* produce a byte-identical shape (see `docs/demo-mode.md`). */
|
|
20
|
+
export declare function snapshotContent(oknoDir: string): {
|
|
21
|
+
schema: string | null;
|
|
22
|
+
users: string | null;
|
|
23
|
+
settings: string | null;
|
|
24
|
+
origins: string | null;
|
|
25
|
+
content: Record<string, string>;
|
|
26
|
+
files: Array<{
|
|
27
|
+
path: string;
|
|
28
|
+
filename: string;
|
|
29
|
+
size: number;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
export declare const sanitizeName: (f: string) => string;
|
|
33
|
+
export declare const sanitizeDir: (d: string) => string;
|
|
34
|
+
/** Read + parse schema.ts from disk, returning the object plus the file's
|
|
35
|
+
* import/comment header so writes preserve it (mirrors backend writeSchema). */
|
|
36
|
+
export declare function readSchema(oknoDir: string): {
|
|
37
|
+
schema: SchemaObj;
|
|
38
|
+
header: string;
|
|
39
|
+
};
|
|
40
|
+
/** Write schema.ts (header preserved). Invalidation is the controller's job. */
|
|
41
|
+
export declare function writeSchema(oknoDir: string, schema: SchemaObj, header: string): void;
|
|
42
|
+
/** Migrate field-key renames + deletes into every content file for {kind}/{name}
|
|
43
|
+
* (default + locale variants; page/global = object, collection = array of items).
|
|
44
|
+
* Preserves stamps + order (encodeRaw). Returns the changed files (rel + abs) so
|
|
45
|
+
* the controller can invalidate them. */
|
|
46
|
+
export declare function migrateFieldKeys(oknoDir: string, kind: string, name: string, renames: Record<string, string>, deletes: string[]): Array<{
|
|
47
|
+
rel: string;
|
|
48
|
+
abs: string;
|
|
49
|
+
}>;
|
|
50
|
+
export declare function gitRoot(oknoDir: string): string;
|
|
51
|
+
/** Path of oknoDir relative to the git root (POSIX). realpath-normalized so the
|
|
52
|
+
* macOS /var → /private/var symlink doesn't make it look "outside repository". */
|
|
53
|
+
export declare function oknoRelPath(oknoDir: string): string;
|
|
54
|
+
/** Author for created/updated stamps. Prefer the value the editor passes (the
|
|
55
|
+
* logged-in GitHub user in Light mode); fall back to local git config. */
|
|
56
|
+
export declare function gitAuthor(oknoDir: string): string;
|
|
57
|
+
//# sourceMappingURL=disk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk.d.ts","sourceRoot":"","sources":["../../src/local/disk.ts"],"names":[],"mappings":"AAcA,OAAO,EAAgE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGjH,eAAO,MAAM,aAAa,8CAA+C,CAAA;AAEzE;iEACiE;AACjE,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzE;AAED;mFACmF;AACnF,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKzE;AA0BD;wDACwD;AACxD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBrG;AAED;;;gEAGgE;AAChE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG;IACjD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D,CAaA;AAGD,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,WAAuC,CAAA;AAC7E,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,WAKzB,CAAA;AAEZ;iFACiF;AACjF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAejF;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAEpF;AAED;;;0CAG0C;AAC1C,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,EAAE,MAAM,EAAE,GACf,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA+CrC;AAGD,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;mFACmF;AACnF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAGD;2EAC2E;AAC3E,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQjD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What a controller must supply to drive the engine over its transport. */
|
|
2
|
+
export interface LocalCtx {
|
|
3
|
+
method: string;
|
|
4
|
+
/** Route after `/__okno/api/`, query stripped (e.g. "content/save"). */
|
|
5
|
+
route: string;
|
|
6
|
+
/** Parsed JSON request body (`{}` when absent/invalid). */
|
|
7
|
+
json(): Promise<any>;
|
|
8
|
+
/** Raw binary request body. */
|
|
9
|
+
binary(): Promise<Buffer>;
|
|
10
|
+
/** A request header value (lower-case name), or undefined. */
|
|
11
|
+
header(name: string): string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** Which live modules/files a write touched, for the controller to refresh.
|
|
14
|
+
* `modules` are okno virtual-module kinds ("pages" | "collections" | "globals"
|
|
15
|
+
* | "strings" | "content"); `files` are absolute content paths. */
|
|
16
|
+
export interface Invalidation {
|
|
17
|
+
files: string[];
|
|
18
|
+
modules: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface LocalResult {
|
|
21
|
+
status: number;
|
|
22
|
+
body: unknown;
|
|
23
|
+
invalidation?: Invalidation;
|
|
24
|
+
}
|
|
25
|
+
/** Route handled → LocalResult; not an okno route → null (controller next()s). */
|
|
26
|
+
export declare function dispatch(oknoDir: string, ctx: LocalCtx): Promise<LocalResult | null>;
|
|
27
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/local/dispatch.ts"],"names":[],"mappings":"AAqDA,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;IACpB,+BAA+B;IAC/B,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACzB,8DAA8D;IAC9D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACxC;AAED;;oEAEoE;AACpE,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,CAAC,EAAE,YAAY,CAAA;CAC3B;AAED,kFAAkF;AAClF,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAsY1F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-written tracker — paths the local engine just wrote on an editor save.
|
|
3
|
+
*
|
|
4
|
+
* The editor's optimistic binding already shows the change live, so the Vite
|
|
5
|
+
* controller's `handleHotUpdate` suppresses the otherwise-spurious full page
|
|
6
|
+
* reload for these. Genuine external edits (hand-edit, git pull) aren't marked
|
|
7
|
+
* → they HMR normally. A TTL (not delete-on-read) so a duplicate watcher event
|
|
8
|
+
* for the same write is still recognized.
|
|
9
|
+
*
|
|
10
|
+
* Shared by the local IO layer (which marks) and the Vite controller (which
|
|
11
|
+
* consumes). Other controllers (okno/next) simply never consume it.
|
|
12
|
+
*/
|
|
13
|
+
/** Mark `abs` as engine-written just now. */
|
|
14
|
+
export declare function markSelfWritten(abs: string): void;
|
|
15
|
+
/** True if `abs` was engine-written in the last few seconds. */
|
|
16
|
+
export declare function consumeSelfWritten(abs: string): boolean;
|
|
17
|
+
//# sourceMappingURL=self-written.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-written.d.ts","sourceRoot":"","sources":["../../src/local/self-written.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,6CAA6C;AAC7C,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGvD"}
|
package/dist/mcp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync as l, readdirSync as j, readFileSync as y, mkdirSync as D, writeFileSync as S, unlinkSync as C, realpathSync as N } from "node:fs";
|
|
2
2
|
import { join as i, dirname as O, relative as L, sep as E, resolve as T } from "node:path";
|
|
3
3
|
import { execFileSync as F } from "node:child_process";
|
|
4
|
-
import { p as b, e as M, a as $ } from "./
|
|
4
|
+
import { p as b, e as M, a as $ } from "./encode-DoojdsVU.js";
|
|
5
5
|
function I() {
|
|
6
6
|
const f = process.env.OKNO_DIR;
|
|
7
7
|
if (f) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OknoConfig } from "../types/schema.ts";
|
|
2
|
+
export interface WithOknoOptions {
|
|
3
|
+
/** okno content dir name, relative to the project root (default "okno"). */
|
|
4
|
+
dir?: OknoConfig["dir"];
|
|
5
|
+
/** Routable folder the dev API is mounted at — must NOT start with `_`
|
|
6
|
+
* (App Router private folder). Default "oknoapi"; match your route file
|
|
7
|
+
* `app/<apiMount>/[...okno]/route.ts`. */
|
|
8
|
+
apiMount?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Wrap a Next config so okno's dev API is reachable and its codegen runs. The
|
|
11
|
+
* user's config is preserved; okno adds the rewrite + a boot side effect. */
|
|
12
|
+
export declare function withOkno<T>(nextConfig?: T, options?: WithOknoOptions): T;
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/next/config.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IACvB;;+CAE2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAqBD;8EAC8E;AAC9E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAE,CAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,CAAC,CA6BrF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface OknoRouteOptions {
|
|
2
|
+
/** okno content dir name, relative to `root` (default "okno"). */
|
|
3
|
+
dir?: string;
|
|
4
|
+
/** Project root the dir resolves against (default `process.cwd()`). */
|
|
5
|
+
root?: string;
|
|
6
|
+
}
|
|
7
|
+
/** The App-Router context object (Next 15 makes `params` a Promise; 14 doesn't). */
|
|
8
|
+
type RouteContext = {
|
|
9
|
+
params?: Promise<Record<string, string | string[]>> | Record<string, string | string[]>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Build the `{ GET, POST }` handlers for the okno dev API. Mount at a Next
|
|
13
|
+
* App-Router catch-all: `app/oknoapi/[...okno]/route.ts` (paired with the
|
|
14
|
+
* `withOkno` rewrite from `/__okno/api/*`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function createOknoRouteHandler(opts?: OknoRouteOptions): {
|
|
17
|
+
GET: (req: Request, ctx?: RouteContext) => Promise<Response>;
|
|
18
|
+
POST: (req: Request, ctx?: RouteContext) => Promise<Response>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/next/handler.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,gBAAgB;IAChC,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,oFAAoF;AACpF,KAAK,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;CAAE,CAAA;AA6B/G;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG;IAChE,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC5D,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC7D,CAyCA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `okno/next` — the Next.js controller.
|
|
3
|
+
*
|
|
4
|
+
* A thin transport over okno's framework-agnostic engine, mirroring `okno/vite`.
|
|
5
|
+
* Two pieces:
|
|
6
|
+
* - `withOkno(nextConfig)` — wrap your `next.config` (codegen + dev watch).
|
|
7
|
+
* - `createOknoRouteHandler()` — the dev API, mounted at a catch-all route
|
|
8
|
+
* `app/__okno/api/[...okno]/route.ts`.
|
|
9
|
+
*
|
|
10
|
+
* See docs/nextjs-adapter.md for the full setup (and the Phase 3b read path).
|
|
11
|
+
*/
|
|
12
|
+
export { withOkno, type WithOknoOptions } from "./config.ts";
|
|
13
|
+
export { createOknoRouteHandler, type OknoRouteOptions } from "./handler.ts";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { resolve as l } from "node:path";
|
|
2
|
+
import { existsSync as m, watch as w } from "node:fs";
|
|
3
|
+
import { g as k, d as v } from "../dispatch-bnmIdH8E.js";
|
|
4
|
+
function g(r, o) {
|
|
5
|
+
const n = { source: "/__okno/api/:path*", destination: `/${o}/:path*` };
|
|
6
|
+
return async () => {
|
|
7
|
+
const e = typeof r == "function" ? await r() : void 0;
|
|
8
|
+
return e ? Array.isArray(e) ? [n, ...e] : { ...e, beforeFiles: [n, ...e.beforeFiles ?? []] } : [n];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
let f = !1;
|
|
12
|
+
function S(r = {}, o = {}) {
|
|
13
|
+
const n = o.apiMount ?? "oknoapi", e = {
|
|
14
|
+
...r,
|
|
15
|
+
rewrites: g(r.rewrites, n)
|
|
16
|
+
};
|
|
17
|
+
if (!f) {
|
|
18
|
+
f = !0;
|
|
19
|
+
const s = process.cwd(), t = l(s, o.dir ?? "okno");
|
|
20
|
+
if (m(t)) {
|
|
21
|
+
const a = () => {
|
|
22
|
+
k(t, s).catch((i) => console.warn("[okno] codegen failed:", i));
|
|
23
|
+
};
|
|
24
|
+
if (a(), process.env.NODE_ENV !== "production")
|
|
25
|
+
try {
|
|
26
|
+
w(t, { recursive: !0 }, () => a());
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
const p = { "Content-Type": "application/json", "Cache-Control": "no-store" };
|
|
34
|
+
function O(r) {
|
|
35
|
+
return l(r?.root ?? process.cwd(), r?.dir ?? "okno");
|
|
36
|
+
}
|
|
37
|
+
function d() {
|
|
38
|
+
return new Response(JSON.stringify({ error: "Not found" }), { status: 404, headers: p });
|
|
39
|
+
}
|
|
40
|
+
async function R(r, o) {
|
|
41
|
+
const n = o?.params ? await o.params : void 0;
|
|
42
|
+
if (n) {
|
|
43
|
+
const t = n.okno ?? Object.values(n)[0];
|
|
44
|
+
if (Array.isArray(t)) return t.join("/");
|
|
45
|
+
if (typeof t == "string") return t;
|
|
46
|
+
}
|
|
47
|
+
const e = "/__okno/api/", s = new URL(r.url).pathname.indexOf(e);
|
|
48
|
+
return s === -1 ? null : new URL(r.url).pathname.slice(s + e.length);
|
|
49
|
+
}
|
|
50
|
+
function _(r) {
|
|
51
|
+
const o = O(r), n = async (e, s) => {
|
|
52
|
+
const t = await R(e, s);
|
|
53
|
+
if (t == null) return d();
|
|
54
|
+
let a, i = !1, c;
|
|
55
|
+
const h = {
|
|
56
|
+
method: e.method,
|
|
57
|
+
route: t,
|
|
58
|
+
json: async () => {
|
|
59
|
+
if (!i) {
|
|
60
|
+
i = !0;
|
|
61
|
+
try {
|
|
62
|
+
a = await e.json();
|
|
63
|
+
} catch {
|
|
64
|
+
a = {};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return a ?? {};
|
|
68
|
+
},
|
|
69
|
+
binary: async () => (c === void 0 && (c = Buffer.from(await e.arrayBuffer())), c),
|
|
70
|
+
header: (y) => e.headers.get(y) ?? void 0
|
|
71
|
+
}, u = await v(o, h);
|
|
72
|
+
return u ? new Response(JSON.stringify(u.body), { status: u.status, headers: p }) : d();
|
|
73
|
+
};
|
|
74
|
+
return { GET: n, POST: n };
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
_ as createOknoRouteHandler,
|
|
78
|
+
S as withOkno
|
|
79
|
+
};
|