okno 1.0.0-alpha.13 → 1.0.0-alpha.14

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.
Files changed (41) hide show
  1. package/dist/boot.d.ts +38 -0
  2. package/dist/boot.d.ts.map +1 -0
  3. package/dist/codegen/generate.d.ts +10 -0
  4. package/dist/codegen/generate.d.ts.map +1 -0
  5. package/dist/codegen/scan-imports.d.ts +9 -0
  6. package/dist/codegen/scan-imports.d.ts.map +1 -0
  7. package/dist/core/content-encode.d.ts +44 -0
  8. package/dist/core/content-encode.d.ts.map +1 -0
  9. package/dist/core/order.d.ts +18 -0
  10. package/dist/core/order.d.ts.map +1 -0
  11. package/dist/core/parse.d.ts +15 -0
  12. package/dist/core/parse.d.ts.map +1 -0
  13. package/dist/editor/index.js +10355 -9690
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +1 -1
  17. package/dist/{acorn-CZBJD705.js → order-yhUnhmgD.js} +37 -18
  18. package/dist/plugin-FT5yk9FZ.js +1149 -0
  19. package/dist/runtime/wrap.d.ts +58 -0
  20. package/dist/runtime/wrap.d.ts.map +1 -0
  21. package/dist/runtime/wrap.js +220 -89
  22. package/dist/types/fields.d.ts +121 -0
  23. package/dist/types/fields.d.ts.map +1 -0
  24. package/dist/types/index.d.ts +4 -0
  25. package/dist/types/index.d.ts.map +1 -0
  26. package/dist/types/permissions.d.ts +22 -0
  27. package/dist/types/permissions.d.ts.map +1 -0
  28. package/dist/types/schema.d.ts +78 -0
  29. package/dist/types/schema.d.ts.map +1 -0
  30. package/dist/vite/dev-server.d.ts +16 -0
  31. package/dist/vite/dev-server.d.ts.map +1 -0
  32. package/dist/vite/index.d.ts +2 -0
  33. package/dist/vite/index.d.ts.map +1 -0
  34. package/dist/vite/index.js +1 -1
  35. package/dist/vite/local-engine.d.ts +34 -0
  36. package/dist/vite/local-engine.d.ts.map +1 -0
  37. package/dist/vite/plugin.d.ts +4 -0
  38. package/dist/vite/plugin.d.ts.map +1 -0
  39. package/package.json +3 -2
  40. package/src/runtime/wrap.ts +367 -12
  41. package/dist/plugin-Kn5tHtN0.js +0 -1069
package/dist/boot.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * okno client boot — production editor delivery.
3
+ *
4
+ * In dev the okno Vite plugin injects the editor through dev-server middleware
5
+ * (`configureServer` in src/vite/plugin.ts). That middleware does not run in a
6
+ * production build, and on SSG frameworks (Astro et al.) the okno runtime is
7
+ * server-only — so a deployed page ships no editor at all. This module is the
8
+ * client-side entry that closes that gap: a page pulls it in (via a framework
9
+ * integration or a `<script>` in the layout) and it lazily boots the editor on
10
+ * demand.
11
+ *
12
+ * The ~1 MB editor bundle is loaded only when an editor signals intent —
13
+ * pressing `e`, or visiting with `?okno` / `#okno`. Public visitors download
14
+ * only this tiny gate. `import("okno/editor")` is a bare specifier the
15
+ * *consumer's* bundler resolves and code-splits at their build time (okno's own
16
+ * build keeps it external via rollup `external`), so the editor lands as its own
17
+ * chunk rather than inside this file.
18
+ */
19
+ declare const __OKNO_IS_DEV__: boolean;
20
+ declare const GATE_KEY = "e";
21
+ declare const g: {
22
+ document?: Document;
23
+ location?: Location;
24
+ __okno_loaded?: boolean;
25
+ __okno_gate_installed?: boolean;
26
+ __okno_autostart?: "key" | "url" | false;
27
+ };
28
+ declare let loading: boolean;
29
+ /** The editor sets `window.__okno_loaded` at the top of its entry module, so
30
+ * this flips true the moment the bundle starts evaluating. */
31
+ declare function editorPresent(): boolean;
32
+ /** Don't hijack `e` while the visitor is typing in the host page. Mirrors the
33
+ * editor's own focus check (modules/keys.svelte.ts), shadow DOM included. */
34
+ declare function isTyping(): boolean;
35
+ declare function bootEditor(reason: "key" | "url"): void;
36
+ declare function urlRequestsEditor(): boolean;
37
+ declare function install(): void;
38
+ //# sourceMappingURL=boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,CAAA;AAEtC,QAAA,MAAM,QAAQ,MAAM,CAAA;AAEpB,QAAA,MAAM,CAAC,EAA4B;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,gBAAgB,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;CACxC,CAAA;AAED,QAAA,IAAI,OAAO,SAAQ,CAAA;AAEnB;+DAC+D;AAC/D,iBAAS,aAAa,IAAI,OAAO,CAEhC;AAED;8EAC8E;AAC9E,iBAAS,QAAQ,IAAI,OAAO,CAO3B;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAa/C;AAED,iBAAS,iBAAiB,IAAI,OAAO,CASpC;AAED,iBAAS,OAAO,IAAI,IAAI,CAgBvB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Read the schema, scan content directories, and generate:
3
+ * - modules.d.ts (type declarations for okno:* virtual modules)
4
+ *
5
+ * `root` is the project root (parent of the okno dir) — we scan it for
6
+ * `import { x } from "okno:<kind>"` so names referenced before scaffolding
7
+ * still get a (placeholder) type, mirroring the runtime virtual modules.
8
+ */
9
+ export declare function generateTypes(oknoDir: string, root: string): Promise<void>;
10
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +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,iBAwGhE"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Walk the project root looking for `import { foo, bar } from "okno:<kind>"`
3
+ * statements and return the union of imported names. Used by both the runtime
4
+ * virtual modules and the type codegen to emit placeholder exports for content
5
+ * that doesn't exist yet, so a project can refer to `home.title` (and get types
6
+ * for it) before any schema is scaffolded.
7
+ */
8
+ export declare function scanImports(root: string, kind: "pages" | "collections" | "globals"): Promise<Set<string>>;
9
+ //# sourceMappingURL=scan-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-imports.d.ts","sourceRoot":"","sources":["../../src/codegen/scan-imports.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,GACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CA0CtB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Canonical serializers: a content/schema object → its `.ts` source module.
3
+ *
4
+ * The byte format is a CONTRACT. The same logical content must encode
5
+ * identically on the live path (hosted backend → GitHub commit) and the dev
6
+ * 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) so
8
+ * either side can import it.
9
+ *
10
+ * SYNC: `backend/src/lib/encode.ts` is a byte-identical copy. The backend is a
11
+ * separate deployable and this monorepo has no cross-package source imports
12
+ * (same controlled-duplication pattern as this package's
13
+ * `editor/lib/parse-export-default.ts` ↔ the backend's `lib/parse.ts`). Any
14
+ * change here MUST be mirrored there, and vice versa.
15
+ */
16
+ export interface Stamp {
17
+ date: string;
18
+ author: string;
19
+ }
20
+ /**
21
+ * A content entry (page / collection item / global) → `export default {...}`.
22
+ * Stamps `updated` from `now`/`author`, and `created` from the same stamp unless
23
+ * a prior `created` is passed through (preserved across edits).
24
+ *
25
+ * Key order — content fields, then `created`, then `updated` — is part of the
26
+ * byte contract. Do not reorder.
27
+ */
28
+ export declare function encodeEntry(content: Record<string, unknown>, opts: {
29
+ now: string;
30
+ author: string;
31
+ created?: Stamp;
32
+ }): string;
33
+ /**
34
+ * The schema → `<header>export default {...} satisfies Schema`. `header`
35
+ * preserves the file's existing import/comment prelude (default: the canonical
36
+ * `import type { Schema } from "okno"`).
37
+ */
38
+ export declare function encodeSchema(schema: Record<string, unknown>, header?: string): string;
39
+ /**
40
+ * Bare `export default <json>` with no metadata — for scaffold seeds (a fresh
41
+ * page/global's default field values, or an empty `[]` collection).
42
+ */
43
+ export declare function encodeRaw(value: unknown): string;
44
+ //# sourceMappingURL=content-encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-encode.d.ts","sourceRoot":"","sources":["../../src/core/content-encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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;AACH,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,18 @@
1
+ /**
2
+ * okno's manual collection ordering — the single source of truth shared by the
3
+ * build plugin (`okno:collections` iteration order) and the editor (collection
4
+ * table + reference lists). okno owns ONLY this manual order; any date/field
5
+ * sort is the dev's own `.sort()` in their template, right before `.map()`.
6
+ */
7
+ /**
8
+ * Order `items` by an explicit slug list. Items whose slug appears in `order`
9
+ * come first, in that order; everything else keeps its original relative order
10
+ * after them (so items added outside the editor — not yet in `order` — still
11
+ * show up, just unsorted at the end). Pure and stable; never drops items.
12
+ */
13
+ export declare function orderBySlugs<T>(items: T[], getSlug: (item: T) => string | undefined, order?: string[]): T[];
14
+ /** Apply a create/delete to a slug-order list. Create prepends (newest-first);
15
+ * delete drops the slug. Returns a new array; both are no-ops when redundant. */
16
+ export declare function orderWithInsert(order: string[] | undefined, slug: string): string[];
17
+ export declare function orderWithout(order: string[] | undefined, slug: string): string[];
18
+ //# sourceMappingURL=order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/core/order.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Parser for `export default { ... }` TypeScript content/schema files.
3
+ *
4
+ * We must NOT execute file content (`new Function` would be an RCE and corrupts
5
+ * any string containing `//`). Instead we parse the `export default` expression
6
+ * with acorn and walk the AST, accepting ONLY literal data; anything that would
7
+ * *evaluate* is rejected.
8
+ *
9
+ * SYNC: byte-for-byte the editor's `editor/lib/parse-export-default.ts` and the
10
+ * backend's `lib/parse.ts`. This copy lives under `src/` so the Vite plugin's
11
+ * local engine (which can't import across the editor `rootDir`) can read schema
12
+ * files. Keep all three in step.
13
+ */
14
+ export declare function parseExportDefault(raw: string): Record<string, unknown>;
15
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/core/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqDH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBvE"}