okno 1.0.0-beta.39 → 1.0.0-beta.40

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.
@@ -5,6 +5,14 @@ interface AstroIntegrationLike {
5
5
  "astro:config:setup"(opts: {
6
6
  updateConfig(config: Record<string, unknown>): void;
7
7
  injectScript(stage: "page" | "before-hydration" | "page-ssr" | "head-inline", code: string): void;
8
+ addMiddleware(opts: {
9
+ entrypoint: string;
10
+ order: "pre" | "post";
11
+ }): void;
12
+ command: "dev" | "build" | "preview" | "sync";
13
+ config: {
14
+ adapter?: unknown;
15
+ };
8
16
  }): void;
9
17
  };
10
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/astro/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAGpD,UAAU,oBAAoB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QACN,oBAAoB,CAAC,IAAI,EAAE;YAC1B,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;YACnD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;SACjG,GAAG,IAAI,CAAA;KACR,CAAA;CACD;AAED,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,oBAAoB,CAUlE;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/astro/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAKpD,UAAU,oBAAoB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QACN,oBAAoB,CAAC,IAAI,EAAE;YAC1B,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;YACnD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;YACjG,aAAa,CAAC,IAAI,EAAE;gBAAE,UAAU,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAA;aAAE,GAAG,IAAI,CAAA;YACxE,OAAO,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;YAC7C,MAAM,EAAE;gBAAE,OAAO,CAAC,EAAE,OAAO,CAAA;aAAE,CAAA;SAC7B,GAAG,IAAI,CAAA;KACR,CAAA;CACD;AAcD,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,oBAAoB,CA+BlE;AAED,eAAe,IAAI,CAAA"}
@@ -1,15 +1,27 @@
1
- import { o as e } from "../plugin-BdiBIiAv.js";
2
- function a(o = {}) {
1
+ import { o as i } from "../plugin-sAwHmkG8.js";
2
+ import { join as d } from "node:path";
3
+ import { readFileSync as p } from "node:fs";
4
+ function c(o) {
5
+ try {
6
+ return JSON.parse(p(d(process.cwd(), o, "project.json"), "utf-8"))?.instant === !0;
7
+ } catch {
8
+ return !1;
9
+ }
10
+ }
11
+ function k(o = {}) {
3
12
  return {
4
13
  name: "okno",
5
14
  hooks: {
6
- "astro:config:setup"({ updateConfig: n, injectScript: t }) {
7
- n({ vite: { plugins: [e(o)] } }), t("page", 'import "okno/boot"');
15
+ "astro:config:setup"({ updateConfig: e, injectScript: r, addMiddleware: a, command: s, config: n }) {
16
+ const t = s === "build" && c(o.dir ?? "okno");
17
+ t && !n.adapter && console.warn(
18
+ "[okno] instant is on in okno/project.json, but this Astro project has no adapter — falling back to the baked build. Add one (e.g. `npx astro add cloudflare`) and set `export const prerender = false` on okno-driven pages. See docs/instant.md."
19
+ ), process.env.OKNO_INSTANT = t && n.adapter ? "1" : "0", e({ vite: { plugins: [i(o)] } }), r("page", 'import "okno/boot"'), t && n.adapter && a({ entrypoint: "okno:instant-middleware", order: "pre" });
8
20
  }
9
21
  }
10
22
  };
11
23
  }
12
24
  export {
13
- a as default,
14
- a as okno
25
+ k as default,
26
+ k as okno
15
27
  };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Instant-mode variants of the `okno:*` content module generators.
3
+ *
4
+ * Same import surface as the baked modules (modules.ts) — same export names,
5
+ * same wrapped shapes — but content comes from the CURRENT request's snapshot
6
+ * (via the `okno:instant` runtime) instead of build-time imports. What stays
7
+ * build-time: the export NAME sets (pages/globals/collections are structure —
8
+ * adding one is a schema change and rebuilds anyway), the schema import (field
9
+ * defs drive ref/enum hydration and routes), and the image map (built assets).
10
+ * What turns dynamic: every content VALUE.
11
+ *
12
+ * VITE-FREE by contract, like modules.ts.
13
+ */
14
+ export declare function buildInstantPagesModule(oknoDir: string, used?: Set<string>): Promise<string>;
15
+ export declare function buildInstantGlobalsModule(oknoDir: string, used?: Set<string>): Promise<string>;
16
+ export declare function buildInstantCollectionsModule(oknoDir: string, used?: Set<string>): Promise<string>;
17
+ export declare function buildInstantStringsModule(oknoDir: string): string;
18
+ /** The `okno:instant-middleware` module — Astro middleware that fetches the
19
+ * snapshot and serves it as ISR-like SSR (version-keyed edge cache + HTTP
20
+ * validators + AsyncLocalStorage scope). All logic lives in the tested,
21
+ * self-contained `__oknoInstantMiddleware` runtime helper; this only binds the
22
+ * project's snapshot URL. */
23
+ export declare function buildInstantMiddlewareModule(snapshotUrl: string, apiUrl: string): string;
24
+ //# sourceMappingURL=modules-instant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules-instant.d.ts","sourceRoot":"","sources":["../../src/codegen/modules-instant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA8BH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7G;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/G;AA4BD,wBAAsB,6BAA6B,CAClD,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAajE;AAED;;;;8BAI8B;AAC9B,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASxF"}
@@ -2,11 +2,27 @@ export declare const IMAGE_MAP_SETUP = "__oknoSetImages(import.meta.glob(\"/okno
2
2
  /** The `okno:runtime` module body (the built `dist/runtime/wrap.js`), or null
3
3
  * when it's missing (unbuilt tree — run `bun run build:pkg`). */
4
4
  export declare function getRuntimeSource(): string | null;
5
+ /** The `okno:instant` module body (the built `dist/runtime/instant.js`) —
6
+ * same resolution dance as the wrap runtime above. */
7
+ export declare function getInstantRuntimeSource(): string | null;
5
8
  /** The umbrella `okno:content` module: one import, all kinds namespaced
6
9
  * (`import * as okno from "okno:content"` → okno.pages / .globals /
7
10
  * .collections) + the UI-strings store (okno.strings). Pure re-export — the
8
11
  * per-kind modules still work. */
9
12
  export declare function buildContentModule(): string;
13
+ export declare function listContentFiles(dir: string): Promise<string[]>;
14
+ /** Read per-collection build config from schema.ts: manual `order` (slug list)
15
+ * and the `drafts` opt-in flag. Best-effort — a missing/unparseable schema
16
+ * yields empty (file order, no draft filtering). */
17
+ export declare function readCollectionConfig(oknoDir: string): {
18
+ orders: Record<string, string[]>;
19
+ /** Collections that OPTED OUT (`drafts: false`) — the workflow is on by default. */
20
+ draftsOff: Set<string>;
21
+ /** Collections that OPTED OUT (`scheduling: false`) — on by default. */
22
+ schedulingOff: Set<string>;
23
+ };
24
+ export declare function toExportName(filename: string): string;
25
+ export declare function toContentName(filename: string): string;
10
26
  /** Build the framework-agnostic `okno:locales` module: ONE export, `locales` —
11
27
  * an array of the configured languages (`{ id, name, slug, link(url) }`) with a
12
28
  * `.default` property pointing at the base-locale entry. `link(url)` emits the
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/codegen/modules.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,eAAe,oHACoF,CAAA;AAoBhH;kEACkE;AAClE,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAKhD;AAED;;;mCAGmC;AACnC,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C;AAuHD;;;;;+EAK+E;AAC/E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAoD1D;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDzE;AAED,0CAA0C;AAC1C,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAqFtG;AAED,2FAA2F;AAC3F,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAiJ7H;AAED,4CAA4C;AAC5C,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAyExG"}
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/codegen/modules.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,eAAe,oHACoF,CAAA;AAoBhH;kE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