okno 1.0.0-beta.16 → 1.0.0-beta.17
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/codegen/scan-imports.d.ts +7 -4
- package/dist/codegen/scan-imports.d.ts.map +1 -1
- package/dist/{dispatch-C34WXMSB.js → dispatch-DFdYV0q0.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/next/config.d.ts +3 -0
- package/dist/next/config.d.ts.map +1 -1
- package/dist/next/index.js +116 -90
- package/dist/plugin-CPJpdY5k.js +466 -0
- package/dist/runtime/wrap.d.ts.map +1 -1
- package/dist/runtime/wrap.js +16 -15
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/runtime/wrap.ts +7 -0
- package/dist/plugin-DrRr35Ph.js +0 -466
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Walk the project root looking for `import { foo, bar } from "okno:<kind>"`
|
|
3
|
-
* statements and return the union of
|
|
4
|
-
* virtual modules and the type codegen
|
|
5
|
-
* that doesn't exist yet, so a project
|
|
6
|
-
* for it) before any schema is
|
|
3
|
+
* (or the colon-free `okno/<kind>` token) statements and return the union of
|
|
4
|
+
* imported names. Used by both the runtime virtual modules and the type codegen
|
|
5
|
+
* to emit placeholder exports for content that doesn't exist yet, so a project
|
|
6
|
+
* can refer to `home.title` (and get types for it) before any schema is
|
|
7
|
+
* scaffolded — including for an optional/unscaffolded name (e.g. a `theme`
|
|
8
|
+
* global). Matches BOTH the `okno:` (Vite virtual) and `okno/` (Next/tsconfig
|
|
9
|
+
* paths) forms so the placeholder emits regardless of which token a page uses.
|
|
7
10
|
*/
|
|
8
11
|
export declare function scanImports(root: string, kind: "pages" | "collections" | "globals"): Promise<Set<string>>;
|
|
9
12
|
//# sourceMappingURL=scan-imports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-imports.d.ts","sourceRoot":"","sources":["../../src/codegen/scan-imports.ts"],"names":[],"mappings":"AAiBA
|
|
1
|
+
{"version":3,"file":"scan-imports.d.ts","sourceRoot":"","sources":["../../src/codegen/scan-imports.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,GACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CA0CtB"}
|
|
@@ -20,7 +20,7 @@ const Te = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", "
|
|
|
20
20
|
".turbo"
|
|
21
21
|
]);
|
|
22
22
|
async function X(e, n) {
|
|
23
|
-
const t = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']okno
|
|
23
|
+
const t = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']okno[:/]${n}["']`, "g"), s = /* @__PURE__ */ new Set();
|
|
24
24
|
async function a(r) {
|
|
25
25
|
let l;
|
|
26
26
|
try {
|
|
@@ -45,7 +45,7 @@ async function X(e, n) {
|
|
|
45
45
|
} catch {
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
|
-
if (c.includes(`okno:${n}`))
|
|
48
|
+
if (!(!c.includes(`okno:${n}`) && !c.includes(`okno/${n}`)))
|
|
49
49
|
for (const m of c.matchAll(t)) {
|
|
50
50
|
const d = m[1] ?? "";
|
|
51
51
|
for (const h of d.split(",")) {
|
package/dist/index.js
CHANGED
package/dist/next/config.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface WithOknoOptions {
|
|
|
6
6
|
* (App Router private folder). Default "oknoapi"; match your route file
|
|
7
7
|
* `app/<apiMount>/[...okno]/route.ts`. */
|
|
8
8
|
apiMount?: string;
|
|
9
|
+
/** The okno backend the editor talks to (`__OKNO_API_URL__`). Defaults to
|
|
10
|
+
* `https://api.okno.build`; point at staging for a test deploy. */
|
|
11
|
+
apiUrl?: string;
|
|
9
12
|
}
|
|
10
13
|
/** Wrap a Next config so okno's dev API is reachable and its codegen runs. The
|
|
11
14
|
* user's config is preserved; okno adds the rewrite + a boot side effect. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/next/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/next/config.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AA4BpD,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IACvB;;+CAE2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;wEACoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAiDD;8EAC8E;AAC9E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAE,CAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,CAAC,CA4CrF"}
|
package/dist/next/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { join as c, relative as
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { join as c, relative as N, sep as y, resolve as _, dirname as E } from "node:path";
|
|
2
|
+
import { existsSync as w, watch as R, readFileSync as M, mkdirSync as A, cpSync as P } from "node:fs";
|
|
3
|
+
import { fileURLToPath as C } from "node:url";
|
|
4
|
+
import { s as g, b as J, a as D, c as I, d as U, e as L, g as F, I as K, f as T, h as V, i as $ } from "../dispatch-DFdYV0q0.js";
|
|
5
|
+
import { mkdir as B, writeFile as f } from "node:fs/promises";
|
|
6
|
+
const G = (n) => n.replaceAll(K, "__oknoSetImages(undefined)"), z = (n) => {
|
|
7
|
+
let t = n;
|
|
8
|
+
for (const [o, e] of Object.entries(W))
|
|
9
|
+
t = t.replaceAll(`"${o}"`, `"./${e}"`).replaceAll(`'${o}'`, `'./${e}'`);
|
|
10
|
+
return t;
|
|
11
|
+
}, H = (n, t, o) => {
|
|
12
|
+
const e = N(o, t).split(y).join("/");
|
|
13
|
+
return n.replaceAll(t.split(y).join("/"), e);
|
|
14
|
+
}, W = {
|
|
14
15
|
"okno:pages": "pages.js",
|
|
15
16
|
"okno:collections": "collections.js",
|
|
16
17
|
"okno:globals": "globals.js",
|
|
@@ -19,113 +20,138 @@ const U = (o) => o.replaceAll(T, "__oknoSetImages(undefined)"), x = (o) => {
|
|
|
19
20
|
"okno:content": "content.js",
|
|
20
21
|
"okno:runtime": "runtime.js"
|
|
21
22
|
};
|
|
22
|
-
async function
|
|
23
|
-
const e = c(
|
|
24
|
-
await
|
|
25
|
-
const [
|
|
26
|
-
g(
|
|
27
|
-
g(
|
|
28
|
-
g(
|
|
29
|
-
]), [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]),
|
|
23
|
+
async function x(n, t, o = {}) {
|
|
24
|
+
const e = c(t, o.outDir ?? ".okno"), s = o.isBuild ?? process.env.NODE_ENV === "production";
|
|
25
|
+
await B(e, { recursive: !0 });
|
|
26
|
+
const [r, i, a] = await Promise.all([
|
|
27
|
+
g(t, "pages"),
|
|
28
|
+
g(t, "collections"),
|
|
29
|
+
g(t, "globals")
|
|
30
|
+
]), [u, l, d, m] = await Promise.all([
|
|
31
|
+
J(n, r),
|
|
32
|
+
D(n, i, s),
|
|
33
|
+
I(n, a),
|
|
34
|
+
U(n)
|
|
35
|
+
]), b = L(n), j = T(), S = F() ?? 'throw new Error("okno: runtime/wrap.js missing — run \\`bun run build:pkg\\`")', p = (v) => H(z(G(v)), n, e);
|
|
35
36
|
await Promise.all([
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
f(c(e, "pages.js"), p(u)),
|
|
38
|
+
f(c(e, "collections.js"), p(l)),
|
|
39
|
+
f(c(e, "globals.js"), p(d)),
|
|
40
|
+
f(c(e, "locales.js"), p(b)),
|
|
41
|
+
f(c(e, "strings.js"), p(m)),
|
|
42
|
+
f(c(e, "content.js"), p(j)),
|
|
43
|
+
f(c(e, "runtime.js"), S)
|
|
43
44
|
]);
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
function Q() {
|
|
47
|
+
const n = E(C(import.meta.url));
|
|
48
|
+
for (const t of ["../package.json", "../../package.json"])
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(M(_(n, t), "utf-8")).version ?? "0.0.0";
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
return "0.0.0";
|
|
54
|
+
}
|
|
55
|
+
function X(n, t) {
|
|
56
|
+
const o = c(n, "files");
|
|
57
|
+
if (!w(o)) return;
|
|
58
|
+
const e = c(t, "public", "okno", "files");
|
|
59
|
+
A(e, { recursive: !0 }), P(o, e, { recursive: !0, filter: (s) => !s.endsWith(".okno-tree.json") });
|
|
60
|
+
}
|
|
61
|
+
function Y(n) {
|
|
62
|
+
return {
|
|
63
|
+
__OKNO_API_URL__: JSON.stringify(n),
|
|
64
|
+
__OKNO_VERSION__: JSON.stringify(Q()),
|
|
65
|
+
__OKNO_IS_DEV__: JSON.stringify(!1),
|
|
66
|
+
__OKNO_DEMO__: JSON.stringify(!1),
|
|
67
|
+
__OKNO_REPO__: JSON.stringify(null)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function Z(n, t) {
|
|
71
|
+
return (o, e) => (o.plugins = o.plugins ?? [], o.plugins.push(new e.webpack.DefinePlugin(t)), typeof n == "function" ? n(o, e) : o);
|
|
50
72
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
73
|
+
function q(n, t) {
|
|
74
|
+
const o = { source: "/__okno/api/:path*", destination: `/${t}/:path*` };
|
|
53
75
|
return async () => {
|
|
54
|
-
const e = typeof
|
|
55
|
-
return e ? Array.isArray(e) ? [
|
|
76
|
+
const e = typeof n == "function" ? await n() : void 0;
|
|
77
|
+
return e ? Array.isArray(e) ? [o, ...e] : { ...e, beforeFiles: [o, ...e.beforeFiles ?? []] } : [o];
|
|
56
78
|
};
|
|
57
79
|
}
|
|
58
|
-
let
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
...
|
|
62
|
-
rewrites:
|
|
80
|
+
let O = !1;
|
|
81
|
+
function ae(n = {}, t = {}) {
|
|
82
|
+
const o = t.apiMount ?? "oknoapi", e = t.apiUrl ?? "https://api.okno.build", s = n, r = {
|
|
83
|
+
...s,
|
|
84
|
+
rewrites: q(s.rewrites, o),
|
|
85
|
+
// Bake the editor's compile-time globals (webpack `next build`) so it doesn't
|
|
86
|
+
// throw `__OKNO_API_URL__ is not defined` on boot. (Turbopack dev has no
|
|
87
|
+
// DefinePlugin equivalent yet — the deployed demo is a webpack build.)
|
|
88
|
+
webpack: Z(s.webpack, Y(e))
|
|
63
89
|
};
|
|
64
|
-
if (!
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
90
|
+
if (!O) {
|
|
91
|
+
O = !0;
|
|
92
|
+
const i = process.cwd(), a = _(i, t.dir ?? "okno");
|
|
93
|
+
if (w(a)) {
|
|
94
|
+
const u = () => {
|
|
95
|
+
V(a, i).catch((l) => console.warn("[okno] type codegen failed:", l)), x(a, i).catch((l) => console.warn("[okno] module codegen failed:", l));
|
|
70
96
|
try {
|
|
71
|
-
|
|
72
|
-
} catch (
|
|
73
|
-
console.warn("[okno] media copy failed:",
|
|
97
|
+
X(a, i);
|
|
98
|
+
} catch (l) {
|
|
99
|
+
console.warn("[okno] media copy failed:", l);
|
|
74
100
|
}
|
|
75
101
|
};
|
|
76
|
-
if (
|
|
102
|
+
if (u(), process.env.NODE_ENV !== "production")
|
|
77
103
|
try {
|
|
78
|
-
|
|
104
|
+
R(a, { recursive: !0 }, () => u());
|
|
79
105
|
} catch {
|
|
80
106
|
}
|
|
81
107
|
}
|
|
82
108
|
}
|
|
83
|
-
return
|
|
109
|
+
return r;
|
|
84
110
|
}
|
|
85
|
-
const
|
|
86
|
-
function
|
|
87
|
-
return
|
|
111
|
+
const h = { "Content-Type": "application/json", "Cache-Control": "no-store" };
|
|
112
|
+
function ee(n) {
|
|
113
|
+
return _(n?.root ?? process.cwd(), n?.dir ?? "okno");
|
|
88
114
|
}
|
|
89
|
-
function
|
|
90
|
-
return new Response(JSON.stringify({ error: "Not found" }), { status: 404, headers:
|
|
115
|
+
function k() {
|
|
116
|
+
return new Response(JSON.stringify({ error: "Not found" }), { status: 404, headers: h });
|
|
91
117
|
}
|
|
92
|
-
async function
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (Array.isArray(
|
|
97
|
-
if (typeof
|
|
118
|
+
async function ne(n, t) {
|
|
119
|
+
const o = t?.params ? await t.params : void 0;
|
|
120
|
+
if (o) {
|
|
121
|
+
const r = o.okno ?? Object.values(o)[0];
|
|
122
|
+
if (Array.isArray(r)) return r.join("/");
|
|
123
|
+
if (typeof r == "string") return r;
|
|
98
124
|
}
|
|
99
|
-
const e = "/__okno/api/",
|
|
100
|
-
return
|
|
125
|
+
const e = "/__okno/api/", s = new URL(n.url).pathname.indexOf(e);
|
|
126
|
+
return s === -1 ? null : new URL(n.url).pathname.slice(s + e.length);
|
|
101
127
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
let
|
|
107
|
-
const
|
|
128
|
+
function ce(n) {
|
|
129
|
+
const t = ee(n), o = async (e, s) => {
|
|
130
|
+
const r = await ne(e, s);
|
|
131
|
+
if (r == null) return k();
|
|
132
|
+
let i, a = !1, u;
|
|
133
|
+
const l = {
|
|
108
134
|
method: e.method,
|
|
109
|
-
route:
|
|
135
|
+
route: r,
|
|
110
136
|
json: async () => {
|
|
111
|
-
if (!
|
|
112
|
-
|
|
137
|
+
if (!a) {
|
|
138
|
+
a = !0;
|
|
113
139
|
try {
|
|
114
|
-
|
|
140
|
+
i = await e.json();
|
|
115
141
|
} catch {
|
|
116
|
-
|
|
142
|
+
i = {};
|
|
117
143
|
}
|
|
118
144
|
}
|
|
119
|
-
return
|
|
145
|
+
return i ?? {};
|
|
120
146
|
},
|
|
121
|
-
binary: async () => (
|
|
147
|
+
binary: async () => (u === void 0 && (u = Buffer.from(await e.arrayBuffer())), u),
|
|
122
148
|
header: (m) => e.headers.get(m) ?? void 0
|
|
123
|
-
},
|
|
124
|
-
return
|
|
149
|
+
}, d = await $(t, l);
|
|
150
|
+
return d ? new Response(JSON.stringify(d.body), { status: d.status, headers: h }) : k();
|
|
125
151
|
};
|
|
126
|
-
return { GET:
|
|
152
|
+
return { GET: o, POST: o };
|
|
127
153
|
}
|
|
128
154
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
155
|
+
ce as createOknoRouteHandler,
|
|
156
|
+
ae as withOkno
|
|
131
157
|
};
|