@demiurgejs/core 0.2.0-beta.4 → 0.2.0-beta.6
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/README.md +37 -0
- package/bin/demiurge.mjs +23 -1
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/browser/file-router.d.ts +1 -1
- package/dist/chunks/{document-shell-CpJnFtSC.js → document-shell-C0aPrkhd.js} +2 -2
- package/dist/chunks/{document-shell-CpJnFtSC.js.map → document-shell-C0aPrkhd.js.map} +1 -1
- package/dist/chunks/image-CRerJ5BY.js +145 -0
- package/dist/chunks/image-CRerJ5BY.js.map +1 -0
- package/dist/chunks/{image-codec-BmzWnH6W.js → image-codec-CQ8Cwxwb.js} +2 -2
- package/dist/chunks/{image-codec-BmzWnH6W.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
- package/dist/chunks/{images-BQ80950B.js → images-QgdmLyQ3.js} +11 -11
- package/dist/chunks/{images-BQ80950B.js.map → images-QgdmLyQ3.js.map} +1 -1
- package/dist/chunks/{index-BVk9zWbe.js → index-LYve1rQp.js} +287 -351
- package/dist/chunks/index-LYve1rQp.js.map +1 -0
- package/dist/chunks/links-iU22QkCE.js +68 -0
- package/dist/chunks/links-iU22QkCE.js.map +1 -0
- package/dist/chunks/plugin-bkP6WwrS.js +2311 -0
- package/dist/chunks/plugin-bkP6WwrS.js.map +1 -0
- package/dist/chunks/runtime-BH519j2t.js +294 -0
- package/dist/chunks/runtime-BH519j2t.js.map +1 -0
- package/dist/chunks/streaming-BlKlC3nw.js +427 -0
- package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
- package/dist/chunks/{testing-DueXbMo4.js → testing-BEW1nchS.js} +2161 -1562
- package/dist/chunks/testing-BEW1nchS.js.map +1 -0
- package/dist/chunks/{vite-DO70kZA6.js → vite-BADZA8Fl.js} +90 -87
- package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
- package/dist/cli.d.ts +10 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +277 -87
- package/dist/cli.js.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/types.d.ts +14 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/data/cache.d.ts +5 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/testing.d.ts.map +1 -1
- package/dist/data/testing.js +101 -67
- package/dist/data/testing.js.map +1 -1
- package/dist/data/tiered.d.ts.map +1 -1
- package/dist/edge/index.js +27 -26
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/stores.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -135
- package/dist/index.js.map +1 -1
- package/dist/inspect/command.d.ts +28 -0
- package/dist/inspect/command.d.ts.map +1 -0
- package/dist/inspect/index.d.ts +9 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/redact.d.ts +35 -0
- package/dist/inspect/redact.d.ts.map +1 -0
- package/dist/inspect/report.d.ts +24 -0
- package/dist/inspect/report.d.ts.map +1 -0
- package/dist/inspect/types.d.ts +102 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/internal/testing.js +12 -12
- package/dist/kv/index.js +7 -6
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/store.d.ts.map +1 -1
- package/dist/node/http.d.ts +7 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +31 -28
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +4 -0
- package/dist/node/serve.d.ts.map +1 -1
- package/dist/redis/index.js +29 -28
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/store.d.ts.map +1 -1
- package/dist/route/index.d.ts +1 -0
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts.map +1 -1
- package/dist/route/serialization.d.ts +24 -0
- package/dist/route/serialization.d.ts.map +1 -0
- package/dist/route/webhook.d.ts +6 -1
- package/dist/route/webhook.d.ts.map +1 -1
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/security/audit.d.ts +2 -1
- package/dist/security/audit.d.ts.map +1 -1
- package/dist/security/authorization.d.ts +36 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +0 -2
- package/dist/security/env-startup.d.ts.map +1 -1
- package/dist/security/env.d.ts +27 -8
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/exceptions.d.ts +29 -0
- package/dist/security/exceptions.d.ts.map +1 -0
- package/dist/security/finding-codes.d.ts +56 -0
- package/dist/security/finding-codes.d.ts.map +1 -0
- package/dist/security/index.d.ts +5 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts +2 -5
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/report.d.ts +2 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts +1 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/types.d.ts +138 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/upload.d.ts +3 -3
- package/dist/security/upload.d.ts.map +1 -1
- package/dist/security/verification.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +3 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server-only/browser.d.ts +2 -0
- package/dist/server-only/browser.d.ts.map +1 -0
- package/dist/server-only/browser.js +4 -0
- package/dist/server-only/browser.js.map +1 -0
- package/dist/server-only/index.d.ts +2 -0
- package/dist/server-only/index.d.ts.map +1 -0
- package/dist/server-only/index.js +2 -0
- package/dist/server-only/index.js.map +1 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +255 -255
- package/dist/static/index.js.map +1 -1
- package/dist/static/testing.d.ts +26 -0
- package/dist/static/testing.d.ts.map +1 -0
- package/dist/static/testing.js +76 -0
- package/dist/static/testing.js.map +1 -0
- package/dist/testing/index.d.ts +47 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +99 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/vercel/build.d.ts +31 -0
- package/dist/vercel/build.d.ts.map +1 -0
- package/dist/vercel/config.d.ts +15 -0
- package/dist/vercel/config.d.ts.map +1 -0
- package/dist/vercel/index.d.ts +7 -0
- package/dist/vercel/index.d.ts.map +1 -0
- package/dist/vercel/index.js +11 -0
- package/dist/vercel/index.js.map +1 -0
- package/dist/vercel/runtime.d.ts +29 -0
- package/dist/vercel/runtime.d.ts.map +1 -0
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +28 -21
- package/dist/vite/plugin.d.ts +18 -2
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts +33 -2
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +14 -2
- package/dist/vite/route-audit.d.ts.map +1 -1
- package/dist/vite/server-only-boundary.d.ts +8 -0
- package/dist/vite/server-only-boundary.d.ts.map +1 -0
- package/package.json +18 -1
- package/dist/chunks/env-startup-DOBYWlZD.js +0 -257
- package/dist/chunks/env-startup-DOBYWlZD.js.map +0 -1
- package/dist/chunks/index-BVk9zWbe.js.map +0 -1
- package/dist/chunks/plugin-BQgMiHxa.js +0 -1827
- package/dist/chunks/plugin-BQgMiHxa.js.map +0 -1
- package/dist/chunks/streaming-BEbPN7Uk.js +0 -469
- package/dist/chunks/streaming-BEbPN7Uk.js.map +0 -1
- package/dist/chunks/testing-DueXbMo4.js.map +0 -1
- package/dist/chunks/vite-DO70kZA6.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
class
|
|
1
|
+
import { k as b } from "./plugin-bkP6WwrS.js";
|
|
2
|
+
class y extends Error {
|
|
3
3
|
constructor(i, t) {
|
|
4
4
|
super(i, t), this.name = "DemiurgeConfigError";
|
|
5
5
|
}
|
|
@@ -12,12 +12,12 @@ const w = [
|
|
|
12
12
|
"rendering",
|
|
13
13
|
"routing",
|
|
14
14
|
"security",
|
|
15
|
-
"
|
|
15
|
+
"unsafe_unstable_viteConfig",
|
|
16
16
|
"vite"
|
|
17
17
|
], D = {
|
|
18
18
|
assets: ["fonts", "images"],
|
|
19
19
|
deployment: ["outDir", "server", "static"],
|
|
20
|
-
"deployment.server": ["entry", "outDir"],
|
|
20
|
+
"deployment.server": ["entry", "outDir", "provider"],
|
|
21
21
|
"deployment.static": ["origin", "provider"],
|
|
22
22
|
rendering: ["document", "styles"],
|
|
23
23
|
"rendering.document": ["lang", "title"],
|
|
@@ -26,59 +26,59 @@ const w = [
|
|
|
26
26
|
vite: ["define", "optimizeDeps", "plugins", "resolve"],
|
|
27
27
|
"vite.resolve": ["alias"]
|
|
28
28
|
};
|
|
29
|
-
function
|
|
29
|
+
function k(e, i) {
|
|
30
30
|
const t = { configFile: i };
|
|
31
|
-
|
|
31
|
+
g(t, "", e, "a configuration object");
|
|
32
32
|
const n = e;
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
throw a(t, "rendering.styles", "false or a string",
|
|
33
|
+
h(t, "", n, w);
|
|
34
|
+
const r = u(t, n, "routing");
|
|
35
|
+
r && (f(t, "routing.routesDir", r.routesDir), p(t, "routing.locales", r.locales), j(t, r.typedRoutes));
|
|
36
|
+
const s = u(t, n, "rendering");
|
|
37
|
+
if (s) {
|
|
38
|
+
const o = u(t, s, "document", "rendering.");
|
|
39
|
+
if (o && (f(t, "rendering.document.lang", o.lang), f(t, "rendering.document.title", o.title)), s.styles !== void 0 && s.styles !== !1 && typeof s.styles != "string")
|
|
40
|
+
throw a(t, "rendering.styles", "false or a string", s.styles);
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
42
|
+
const l = u(t, n, "security");
|
|
43
|
+
if (l && l.staticFileHeaders !== void 0 && !Array.isArray(l.staticFileHeaders))
|
|
44
44
|
throw a(
|
|
45
45
|
t,
|
|
46
46
|
"security.staticFileHeaders",
|
|
47
47
|
"an array of header rules",
|
|
48
|
-
|
|
48
|
+
l.staticFileHeaders
|
|
49
49
|
);
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
if (
|
|
50
|
+
const d = u(t, n, "assets");
|
|
51
|
+
if (d) {
|
|
52
|
+
if (d.fonts !== void 0 && !Array.isArray(d.fonts))
|
|
53
53
|
throw a(
|
|
54
54
|
t,
|
|
55
55
|
"assets.fonts",
|
|
56
56
|
"an array of font declarations from defineFonts()",
|
|
57
|
-
|
|
57
|
+
d.fonts
|
|
58
58
|
);
|
|
59
|
-
p(t, "assets.images",
|
|
59
|
+
p(t, "assets.images", d.images);
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
f(t, "deployment.outDir",
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
if (typeof
|
|
61
|
+
const v = u(t, n, "deployment");
|
|
62
|
+
if (v) {
|
|
63
|
+
f(t, "deployment.outDir", v.outDir);
|
|
64
|
+
const o = u(t, v, "server", "deployment.");
|
|
65
|
+
if (o) {
|
|
66
|
+
if (o.entry !== void 0 && (typeof o.entry != "string" || !o.entry))
|
|
67
67
|
throw a(
|
|
68
68
|
t,
|
|
69
69
|
"deployment.server.entry",
|
|
70
70
|
"a path to the application server entry",
|
|
71
|
-
|
|
71
|
+
o.entry
|
|
72
72
|
);
|
|
73
|
-
f(t, "deployment.server.outDir",
|
|
73
|
+
f(t, "deployment.server.outDir", o.outDir), p(t, "deployment.server.provider", o.provider);
|
|
74
74
|
}
|
|
75
|
-
const m =
|
|
75
|
+
const m = u(
|
|
76
76
|
t,
|
|
77
|
-
|
|
77
|
+
v,
|
|
78
78
|
"static",
|
|
79
79
|
"deployment."
|
|
80
80
|
);
|
|
81
|
-
m && (f(
|
|
81
|
+
if (m && (f(
|
|
82
82
|
t,
|
|
83
83
|
"deployment.static.origin",
|
|
84
84
|
m.origin
|
|
@@ -86,57 +86,60 @@ function E(e, i) {
|
|
|
86
86
|
t,
|
|
87
87
|
"deployment.static.provider",
|
|
88
88
|
m.provider
|
|
89
|
-
))
|
|
89
|
+
)), o?.provider !== void 0 && m !== void 0)
|
|
90
|
+
throw new y(
|
|
91
|
+
`${i} config field "deployment" cannot declare both a runtime provider and static output.`
|
|
92
|
+
);
|
|
90
93
|
}
|
|
91
94
|
if (n.devtools !== void 0 && typeof n.devtools != "boolean")
|
|
92
95
|
throw a(t, "devtools", "a boolean", n.devtools);
|
|
93
|
-
|
|
94
|
-
const c =
|
|
96
|
+
_(t, n.env);
|
|
97
|
+
const c = u(t, n, "vite");
|
|
95
98
|
if (c) {
|
|
96
99
|
if (c.plugins !== void 0 && !Array.isArray(c.plugins))
|
|
97
100
|
throw a(t, "vite.plugins", "an array of Vite plugins", c.plugins);
|
|
98
101
|
p(t, "vite.define", c.define), p(t, "vite.optimizeDeps", c.optimizeDeps);
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
102
|
+
const o = u(t, c, "resolve", "vite.");
|
|
103
|
+
if (o?.alias !== void 0 && !Array.isArray(o.alias) && (typeof o.alias != "object" || o.alias === null))
|
|
101
104
|
throw a(
|
|
102
105
|
t,
|
|
103
106
|
"vite.resolve.alias",
|
|
104
107
|
"an object of aliases or an array of alias entries",
|
|
105
|
-
|
|
108
|
+
o.alias
|
|
106
109
|
);
|
|
107
110
|
}
|
|
108
|
-
if (n.
|
|
111
|
+
if (n.unsafe_unstable_viteConfig !== void 0 && typeof n.unsafe_unstable_viteConfig != "function")
|
|
109
112
|
throw a(
|
|
110
113
|
t,
|
|
111
|
-
"
|
|
114
|
+
"unsafe_unstable_viteConfig",
|
|
112
115
|
"a function",
|
|
113
|
-
n.
|
|
116
|
+
n.unsafe_unstable_viteConfig
|
|
114
117
|
);
|
|
115
118
|
return n;
|
|
116
119
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
return
|
|
120
|
+
function u(e, i, t, n = "") {
|
|
121
|
+
const r = i[t];
|
|
122
|
+
if (r === void 0) return;
|
|
123
|
+
const s = `${n}${t}`;
|
|
124
|
+
g(e, s, r, "an object");
|
|
125
|
+
const l = r, d = D[s];
|
|
126
|
+
return d && h(e, s, l, d), l;
|
|
124
127
|
}
|
|
125
|
-
function
|
|
126
|
-
for (const
|
|
127
|
-
if (!n.includes(
|
|
128
|
-
throw new
|
|
128
|
+
function h(e, i, t, n) {
|
|
129
|
+
for (const r of Object.keys(t))
|
|
130
|
+
if (!n.includes(r))
|
|
131
|
+
throw new y(
|
|
129
132
|
[
|
|
130
133
|
"Demiurge configuration is invalid.",
|
|
131
134
|
` file: ${e.configFile}`,
|
|
132
|
-
` field: ${i ? `${i}.${
|
|
135
|
+
` field: ${i ? `${i}.${r}` : r}`,
|
|
133
136
|
" problem: this option does not exist",
|
|
134
137
|
` known options: ${n.join(", ")}`
|
|
135
138
|
].join(`
|
|
136
139
|
`)
|
|
137
140
|
);
|
|
138
141
|
}
|
|
139
|
-
function
|
|
142
|
+
function g(e, i, t, n) {
|
|
140
143
|
if (!t || typeof t != "object" || Array.isArray(t))
|
|
141
144
|
throw a(e, i, n, t);
|
|
142
145
|
}
|
|
@@ -145,29 +148,29 @@ function f(e, i, t) {
|
|
|
145
148
|
throw a(e, i, "a string", t);
|
|
146
149
|
}
|
|
147
150
|
function p(e, i, t) {
|
|
148
|
-
t !== void 0 &&
|
|
151
|
+
t !== void 0 && g(e, i, t, "an object");
|
|
149
152
|
}
|
|
150
153
|
function j(e, i) {
|
|
151
154
|
if (i === void 0 || typeof i == "boolean") return;
|
|
152
|
-
|
|
155
|
+
g(e, "routing.typedRoutes", i, "a boolean or an object");
|
|
153
156
|
const t = i;
|
|
154
|
-
|
|
157
|
+
h(e, "routing.typedRoutes", t, ["outputFile"]), f(e, "routing.typedRoutes.outputFile", t.outputFile);
|
|
155
158
|
}
|
|
156
|
-
function
|
|
159
|
+
function _(e, i) {
|
|
157
160
|
if (i === void 0) return;
|
|
158
|
-
|
|
161
|
+
g(e, "env", i, "an environment schema");
|
|
159
162
|
const t = i;
|
|
160
|
-
for (const [n,
|
|
161
|
-
if (!(
|
|
163
|
+
for (const [n, r] of Object.entries(t))
|
|
164
|
+
if (!(r && typeof r == "object" && "parse" in r && typeof r.parse == "function"))
|
|
162
165
|
throw a(
|
|
163
166
|
e,
|
|
164
167
|
`env.${n}`,
|
|
165
168
|
"a variable from the env builders, such as env.string()",
|
|
166
|
-
|
|
169
|
+
r
|
|
167
170
|
);
|
|
168
171
|
}
|
|
169
172
|
function a(e, i, t, n) {
|
|
170
|
-
return new
|
|
173
|
+
return new y(
|
|
171
174
|
[
|
|
172
175
|
"Demiurge configuration is invalid.",
|
|
173
176
|
` file: ${e.configFile}`,
|
|
@@ -179,16 +182,16 @@ function a(e, i, t, n) {
|
|
|
179
182
|
);
|
|
180
183
|
}
|
|
181
184
|
function $(e) {
|
|
182
|
-
return e === void 0 ? "undefined" : e === null ? "null" : typeof e == "function" ? "a function" : typeof e == "string" ? JSON.stringify(
|
|
185
|
+
return e === void 0 ? "undefined" : e === null ? "null" : typeof e == "function" ? "a function" : typeof e == "string" ? JSON.stringify(F(e)) : typeof e == "object" ? Array.isArray(e) ? `an array with ${e.length} items` : `an object with these keys: ${Object.keys(e).join(", ") || "(none)"}` : String(e);
|
|
183
186
|
}
|
|
184
|
-
function
|
|
187
|
+
function F(e) {
|
|
185
188
|
return e.length > 60 ? `${e.slice(0, 57)}...` : e;
|
|
186
189
|
}
|
|
187
|
-
async function
|
|
188
|
-
const { config: i } = e, t = await
|
|
190
|
+
async function E(e) {
|
|
191
|
+
const { config: i } = e, t = await R(e.loadReactPlugin), n = {
|
|
189
192
|
configFile: !1,
|
|
190
193
|
plugins: [
|
|
191
|
-
|
|
194
|
+
b(C(i)),
|
|
192
195
|
t(),
|
|
193
196
|
...i.vite?.plugins ?? []
|
|
194
197
|
],
|
|
@@ -196,20 +199,20 @@ async function S(e) {
|
|
|
196
199
|
...i.vite?.define ? { define: { ...i.vite.define } } : {},
|
|
197
200
|
...i.vite?.optimizeDeps ? { optimizeDeps: i.vite.optimizeDeps } : {},
|
|
198
201
|
...i.vite?.resolve?.alias ? { resolve: { alias: i.vite.resolve.alias } } : {}
|
|
199
|
-
},
|
|
200
|
-
if (!i.
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
203
|
-
throw new
|
|
202
|
+
}, r = e.overrides ? await A(n, e.overrides) : n;
|
|
203
|
+
if (!i.unsafe_unstable_viteConfig) return r;
|
|
204
|
+
const s = await i.unsafe_unstable_viteConfig(r);
|
|
205
|
+
if (!s || typeof s != "object" || Array.isArray(s))
|
|
206
|
+
throw new y(
|
|
204
207
|
[
|
|
205
|
-
"The
|
|
208
|
+
"The unsafe_unstable_viteConfig callback must return a Vite configuration object.",
|
|
206
209
|
` file: ${i.configFile}`
|
|
207
210
|
].join(`
|
|
208
211
|
`)
|
|
209
212
|
);
|
|
210
|
-
return
|
|
213
|
+
return s;
|
|
211
214
|
}
|
|
212
|
-
function
|
|
215
|
+
function C(e) {
|
|
213
216
|
return {
|
|
214
217
|
...e.devtools === void 0 ? {} : { devtools: e.devtools },
|
|
215
218
|
...e.rendering?.document ? { document: e.rendering.document } : {},
|
|
@@ -228,15 +231,15 @@ function A(e) {
|
|
|
228
231
|
...e.routing?.typedRoutes === void 0 ? {} : { typedRoutes: e.routing.typedRoutes }
|
|
229
232
|
};
|
|
230
233
|
}
|
|
231
|
-
async function
|
|
234
|
+
async function A(e, i) {
|
|
232
235
|
const { mergeConfig: t } = await import("vite");
|
|
233
236
|
return t(e, i);
|
|
234
237
|
}
|
|
235
|
-
async function
|
|
238
|
+
async function R(e) {
|
|
236
239
|
try {
|
|
237
|
-
return await (e ??
|
|
240
|
+
return await (e ?? O)();
|
|
238
241
|
} catch (i) {
|
|
239
|
-
throw new
|
|
242
|
+
throw new y(
|
|
240
243
|
[
|
|
241
244
|
"Demiurge did not find @vitejs/plugin-react.",
|
|
242
245
|
" Demiurge generates the Vite configuration and needs the React plugin.",
|
|
@@ -247,13 +250,13 @@ async function O(e) {
|
|
|
247
250
|
);
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
|
-
async function
|
|
253
|
+
async function O() {
|
|
251
254
|
return (await import("@vitejs/plugin-react")).default;
|
|
252
255
|
}
|
|
253
256
|
export {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
y as D,
|
|
258
|
+
E as c,
|
|
259
|
+
C as t,
|
|
260
|
+
k as v
|
|
258
261
|
};
|
|
259
|
-
//# sourceMappingURL=vite-
|
|
262
|
+
//# sourceMappingURL=vite-BADZA8Fl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-BADZA8Fl.js","sources":["../../src/config/validate.ts","../../src/config/vite.ts"],"sourcesContent":["import type { DemiurgeConfig } from \"./types\";\n\nexport class DemiurgeConfigError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = \"DemiurgeConfigError\";\n }\n}\n\nconst CONFIG_KEYS = [\n \"assets\",\n \"deployment\",\n \"devtools\",\n \"env\",\n \"rendering\",\n \"routing\",\n \"security\",\n \"unsafe_unstable_viteConfig\",\n \"vite\",\n] as const;\n\nconst SECTION_KEYS: Record<string, readonly string[]> = {\n assets: [\"fonts\", \"images\"],\n deployment: [\"outDir\", \"server\", \"static\"],\n \"deployment.server\": [\"entry\", \"outDir\", \"provider\"],\n \"deployment.static\": [\"origin\", \"provider\"],\n rendering: [\"document\", \"styles\"],\n \"rendering.document\": [\"lang\", \"title\"],\n routing: [\"locales\", \"routesDir\", \"typedRoutes\"],\n security: [\"staticFileHeaders\"],\n vite: [\"define\", \"optimizeDeps\", \"plugins\", \"resolve\"],\n \"vite.resolve\": [\"alias\"],\n};\n\nexport function validateDemiurgeConfig(\n value: unknown,\n configFile: string,\n): DemiurgeConfig {\n const context = { configFile };\n assertPlainObject(context, \"\", value, \"a configuration object\");\n // TYPE-EVIDENCE: assertPlainObject threw unless the value is a non-array object. The cast reads its keys.\n const config = value as Record<string, unknown>;\n assertKnownKeys(context, \"\", config, CONFIG_KEYS);\n\n const routing = section(context, config, \"routing\");\n if (routing) {\n assertOptionalString(context, \"routing.routesDir\", routing.routesDir);\n assertOptionalObject(context, \"routing.locales\", routing.locales);\n assertTypedRoutes(context, routing.typedRoutes);\n }\n\n const rendering = section(context, config, \"rendering\");\n if (rendering) {\n const document = section(context, rendering, \"document\", \"rendering.\");\n if (document) {\n assertOptionalString(context, \"rendering.document.lang\", document.lang);\n assertOptionalString(context, \"rendering.document.title\", document.title);\n }\n if (\n rendering.styles !== undefined &&\n rendering.styles !== false &&\n typeof rendering.styles !== \"string\"\n ) {\n throw invalid(context, \"rendering.styles\", \"false or a string\", rendering.styles);\n }\n }\n\n const security = section(context, config, \"security\");\n if (security && security.staticFileHeaders !== undefined) {\n if (!Array.isArray(security.staticFileHeaders)) {\n throw invalid(\n context,\n \"security.staticFileHeaders\",\n \"an array of header rules\",\n security.staticFileHeaders,\n );\n }\n }\n\n const assets = section(context, config, \"assets\");\n if (assets) {\n if (assets.fonts !== undefined && !Array.isArray(assets.fonts)) {\n throw invalid(\n context,\n \"assets.fonts\",\n \"an array of font declarations from defineFonts()\",\n assets.fonts,\n );\n }\n assertOptionalObject(context, \"assets.images\", assets.images);\n }\n\n const deployment = section(context, config, \"deployment\");\n if (deployment) {\n assertOptionalString(context, \"deployment.outDir\", deployment.outDir);\n const server = section(context, deployment, \"server\", \"deployment.\");\n if (server) {\n if (\n server.entry !== undefined &&\n (typeof server.entry !== \"string\" || !server.entry)\n ) {\n throw invalid(\n context,\n \"deployment.server.entry\",\n \"a path to the application server entry\",\n server.entry,\n );\n }\n assertOptionalString(context, \"deployment.server.outDir\", server.outDir);\n assertOptionalObject(context, \"deployment.server.provider\", server.provider);\n }\n const staticDeployment = section(\n context,\n deployment,\n \"static\",\n \"deployment.\",\n );\n if (staticDeployment) {\n assertOptionalString(\n context,\n \"deployment.static.origin\",\n staticDeployment.origin,\n );\n assertOptionalObject(\n context,\n \"deployment.static.provider\",\n staticDeployment.provider,\n );\n }\n if (server?.provider !== undefined && staticDeployment !== undefined) {\n throw new DemiurgeConfigError(\n `${configFile} config field \"deployment\" cannot declare both a runtime provider and static output.`,\n );\n }\n }\n\n if (config.devtools !== undefined && typeof config.devtools !== \"boolean\") {\n throw invalid(context, \"devtools\", \"a boolean\", config.devtools);\n }\n\n assertEnvSchema(context, config.env);\n\n const vite = section(context, config, \"vite\");\n if (vite) {\n if (vite.plugins !== undefined && !Array.isArray(vite.plugins)) {\n throw invalid(context, \"vite.plugins\", \"an array of Vite plugins\", vite.plugins);\n }\n assertOptionalObject(context, \"vite.define\", vite.define);\n assertOptionalObject(context, \"vite.optimizeDeps\", vite.optimizeDeps);\n const resolve = section(context, vite, \"resolve\", \"vite.\");\n if (\n resolve?.alias !== undefined &&\n !Array.isArray(resolve.alias) &&\n (typeof resolve.alias !== \"object\" || resolve.alias === null)\n ) {\n throw invalid(\n context,\n \"vite.resolve.alias\",\n \"an object of aliases or an array of alias entries\",\n resolve.alias,\n );\n }\n }\n\n if (\n config.unsafe_unstable_viteConfig !== undefined &&\n typeof config.unsafe_unstable_viteConfig !== \"function\"\n ) {\n throw invalid(\n context,\n \"unsafe_unstable_viteConfig\",\n \"a function\",\n config.unsafe_unstable_viteConfig,\n );\n }\n\n // TYPE-EVIDENCE: each field above matches the declared type or throws. The cast records that result.\n return config as DemiurgeConfig;\n}\n\ntype ValidationContext = {\n configFile: string;\n};\n\nfunction section(\n context: ValidationContext,\n parent: Record<string, unknown>,\n key: string,\n prefix = \"\",\n) {\n const value = parent[key];\n if (value === undefined) return undefined;\n const field = `${prefix}${key}`;\n assertPlainObject(context, field, value, \"an object\");\n // TYPE-EVIDENCE: assertPlainObject threw unless the value is a non-array object. The cast reads its keys.\n const record = value as Record<string, unknown>;\n const known = SECTION_KEYS[field];\n if (known) assertKnownKeys(context, field, record, known);\n return record;\n}\n\nfunction assertKnownKeys(\n context: ValidationContext,\n field: string,\n value: Record<string, unknown>,\n known: readonly string[],\n) {\n for (const key of Object.keys(value)) {\n if (known.includes(key)) continue;\n throw new DemiurgeConfigError(\n [\n \"Demiurge configuration is invalid.\",\n ` file: ${context.configFile}`,\n ` field: ${field ? `${field}.${key}` : key}`,\n \" problem: this option does not exist\",\n ` known options: ${known.join(\", \")}`,\n ].join(\"\\n\"),\n );\n }\n}\n\nfunction assertPlainObject(\n context: ValidationContext,\n field: string,\n value: unknown,\n expected: string,\n) {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw invalid(context, field, expected, value);\n }\n}\n\nfunction assertOptionalString(\n context: ValidationContext,\n field: string,\n value: unknown,\n) {\n if (value !== undefined && typeof value !== \"string\") {\n throw invalid(context, field, \"a string\", value);\n }\n}\n\nfunction assertOptionalObject(\n context: ValidationContext,\n field: string,\n value: unknown,\n) {\n if (value === undefined) return;\n assertPlainObject(context, field, value, \"an object\");\n}\n\nfunction assertTypedRoutes(context: ValidationContext, value: unknown) {\n if (value === undefined || typeof value === \"boolean\") return;\n assertPlainObject(context, \"routing.typedRoutes\", value, \"a boolean or an object\");\n // TYPE-EVIDENCE: assertPlainObject threw unless the value is a non-array object. The cast reads its keys.\n const record = value as Record<string, unknown>;\n assertKnownKeys(context, \"routing.typedRoutes\", record, [\"outputFile\"]);\n assertOptionalString(context, \"routing.typedRoutes.outputFile\", record.outputFile);\n}\n\nfunction assertEnvSchema(context: ValidationContext, value: unknown) {\n if (value === undefined) return;\n assertPlainObject(context, \"env\", value, \"an environment schema\");\n // TYPE-EVIDENCE: assertPlainObject threw unless the value is a non-array object. The cast reads its entries.\n const schema = value as Record<string, unknown>;\n for (const [key, variable] of Object.entries(schema)) {\n if (\n variable &&\n typeof variable === \"object\" &&\n \"parse\" in variable &&\n typeof variable.parse === \"function\"\n ) {\n continue;\n }\n throw invalid(\n context,\n `env.${key}`,\n \"a variable from the env builders, such as env.string()\",\n variable,\n );\n }\n}\n\nfunction invalid(\n context: ValidationContext,\n field: string,\n expected: string,\n value: unknown,\n) {\n return new DemiurgeConfigError(\n [\n \"Demiurge configuration is invalid.\",\n ` file: ${context.configFile}`,\n ` field: ${field || \"(the default export)\"}`,\n field\n ? ` problem: this option must be ${expected}`\n : ` problem: the default export must be ${expected}`,\n ` received: ${describeValue(value)}`,\n ].join(\"\\n\"),\n );\n}\n\nexport function describeValue(value: unknown) {\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"function\") return \"a function\";\n if (typeof value === \"string\") return JSON.stringify(truncate(value));\n if (typeof value === \"object\") {\n return Array.isArray(value)\n ? `an array with ${value.length} items`\n : `an object with these keys: ${Object.keys(value).join(\", \") || \"(none)\"}`;\n }\n return String(value);\n}\n\nfunction truncate(value: string) {\n return value.length > 60 ? `${value.slice(0, 57)}...` : value;\n}\n","import type { InlineConfig, PluginOption, UserConfig } from \"vite\";\nimport { demiurge, type DemiurgeVitePluginOptions } from \"../vite/plugin\";\nimport type { DemiurgeConfig, ResolvedDemiurgeConfig } from \"./types\";\nimport { DemiurgeConfigError } from \"./validate\";\n\nexport type ReactPluginLoader = () => Promise<(...args: never[]) => PluginOption>;\n\nexport type CreateDemiurgeViteConfigOptions = {\n config: ResolvedDemiurgeConfig;\n loadReactPlugin?: ReactPluginLoader;\n overrides?: InlineConfig;\n};\n\n// The framework generates the Vite configuration from the application\n// configuration. Applications do not author a Vite configuration file.\nexport async function createDemiurgeViteConfig(\n options: CreateDemiurgeViteConfigOptions,\n): Promise<InlineConfig> {\n const { config } = options;\n const react = await loadReactPluginOrFail(options.loadReactPlugin);\n\n const generated: InlineConfig = {\n configFile: false,\n plugins: [\n demiurge(toPluginOptions(config)),\n react(),\n ...(config.vite?.plugins ?? []),\n ],\n root: config.root,\n ...(config.vite?.define ? { define: { ...config.vite.define } } : {}),\n ...(config.vite?.optimizeDeps\n ? { optimizeDeps: config.vite.optimizeDeps }\n : {}),\n ...(config.vite?.resolve?.alias\n ? { resolve: { alias: config.vite.resolve.alias } }\n : {}),\n };\n\n const merged = options.overrides\n ? await mergeViteConfig(generated, options.overrides)\n : generated;\n\n if (!config.unsafe_unstable_viteConfig) return merged;\n\n // TYPE-EVIDENCE: InlineConfig extends UserConfig with command options only. The callback reads the same fields.\n const extended = await config.unsafe_unstable_viteConfig(merged as UserConfig);\n if (!extended || typeof extended !== \"object\" || Array.isArray(extended)) {\n throw new DemiurgeConfigError(\n [\n \"The unsafe_unstable_viteConfig callback must return a Vite configuration object.\",\n ` file: ${config.configFile}`,\n ].join(\"\\n\"),\n );\n }\n\n // TYPE-EVIDENCE: the check above rejected every value that is not a configuration object. The cast records that result.\n return extended as InlineConfig;\n}\n\n// The plugin keeps the flat option shape. The configuration boundaries map\n// onto it here, so the boundaries stay the application-facing contract.\nexport function toPluginOptions(\n config: DemiurgeConfig,\n): DemiurgeVitePluginOptions {\n return {\n ...(config.devtools === undefined ? {} : { devtools: config.devtools }),\n ...(config.rendering?.document\n ? { document: config.rendering.document }\n : {}),\n ...(config.env ? { env: config.env } : {}),\n ...(config.assets?.fonts ? { fonts: config.assets.fonts } : {}),\n ...(config.assets?.images ? { images: config.assets.images } : {}),\n ...(config.routing?.locales ? { locales: config.routing.locales } : {}),\n ...(config.routing?.routesDir\n ? { routesDir: config.routing.routesDir }\n : {}),\n ...(config.deployment?.static?.provider || config.security?.staticFileHeaders\n ? {\n static: {\n ...(config.deployment?.static?.provider\n ? { deployment: config.deployment.static.provider }\n : {}),\n ...(config.security?.staticFileHeaders\n ? { headers: config.security.staticFileHeaders }\n : {}),\n },\n }\n : {}),\n ...(config.rendering?.styles === undefined\n ? {}\n : { styles: config.rendering.styles }),\n ...(config.routing?.typedRoutes === undefined\n ? {}\n : { typedRoutes: config.routing.typedRoutes }),\n };\n}\n\nasync function mergeViteConfig(base: InlineConfig, overrides: InlineConfig) {\n const { mergeConfig } = await import(\"vite\");\n // TYPE-EVIDENCE: mergeConfig returns the merge of two InlineConfig values. The cast restores that type from its Record signature.\n return mergeConfig(base, overrides) as InlineConfig;\n}\n\nasync function loadReactPluginOrFail(loader?: ReactPluginLoader) {\n try {\n return await (loader ?? loadReactPlugin)();\n } catch (error) {\n throw new DemiurgeConfigError(\n [\n \"Demiurge did not find @vitejs/plugin-react.\",\n \" Demiurge generates the Vite configuration and needs the React plugin.\",\n \" Add @vitejs/plugin-react to the development dependencies of the application.\",\n ].join(\"\\n\"),\n { cause: error },\n );\n }\n}\n\nasync function loadReactPlugin(): Promise<(...args: never[]) => PluginOption> {\n const module: { default: (...args: never[]) => PluginOption } = await import(\n \"@vitejs/plugin-react\"\n );\n return module.default;\n}\n"],"names":["DemiurgeConfigError","message","options","CONFIG_KEYS","SECTION_KEYS","validateDemiurgeConfig","value","configFile","context","assertPlainObject","config","assertKnownKeys","routing","section","assertOptionalString","assertOptionalObject","assertTypedRoutes","rendering","document","invalid","security","assets","deployment","server","staticDeployment","assertEnvSchema","vite","resolve","parent","key","prefix","field","record","known","expected","schema","variable","describeValue","truncate","createDemiurgeViteConfig","react","loadReactPluginOrFail","generated","demiurge","toPluginOptions","merged","mergeViteConfig","extended","base","overrides","mergeConfig","loader","loadReactPlugin","error"],"mappings":";AAEO,MAAMA,UAA4B,MAAM;AAAA,EAC7C,YAAYC,GAAiBC,GAA+B;AAC1D,UAAMD,GAASC,CAAO,GACtB,KAAK,OAAO;AAAA,EACd;AACF;AAEA,MAAMC,IAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAkD;AAAA,EACtD,QAAQ,CAAC,SAAS,QA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EAAO,WAAW,OAAO,SAAA,IACvC,CAAA;AAAA,QACJ,GAAIA,EAAO,UAAU,oBACjB,EAAE,SAASA,EAAO,SAAS,sBAC3B,CAAA;AAAA,MAAC;AAAA,IACP,IAEA,CAAA;AAAA,IACJ,GAAIA,EAAO,WAAW,WAAW,SAC7B,KACA,EAAE,QAAQA,EAAO,UAAU,OAAA;AAAA,IAC/B,GAAIA,EAAO,SAAS,gBAAgB,SAChC,CAAA,IACA,EAAE,aAAaA,EAAO,QAAQ,YAAA;AAAA,EAAY;AAElD;AAEA,eAAeoC,EAAgBE,GAAoBC,GAAyB;AAC1E,QAAM,EAAE,aAAAC,EAAA,IAAgB,MAAM,OAAO,MAAM;AAE3C,SAAOA,EAAYF,GAAMC,CAAS;AACpC;AAEA,eAAeR,EAAsBU,GAA4B;AAC/D,MAAI;AACF,WAAO,OAAOA,KAAUC,GAAA;AAAA,EAC1B,SAASC,GAAO;AACd,UAAM,IAAIrD;AAAA,MACR;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,MAAA,EACA,KAAK;AAAA,CAAI;AAAA,MACX,EAAE,OAAOqD,EAAA;AAAA,IAAM;AAAA,EAEnB;AACF;AAEA,eAAeD,IAA+D;AAI5E,UAHgE,MAAM,OACpE,sBACF,GACc;AAChB;"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { InlineConfig } from "vite";
|
|
2
2
|
import type { ResolvedDemiurgeConfig } from "./config/types";
|
|
3
|
+
import type { ServeNodeBuildOptions } from "./node";
|
|
3
4
|
import { type GenerateStaticOutputOptions, type StaticOutputManifest } from "./static";
|
|
4
5
|
export { parseClientManifest } from "./manifest";
|
|
5
6
|
export type { ClientBuildManifest } from "./manifest";
|
|
7
|
+
export { INSPECT_EXIT_FINDINGS, INSPECT_EXIT_INVALID, INSPECT_EXIT_OK, runInspectCommand, } from "./inspect";
|
|
8
|
+
export type { InspectCommandResult } from "./inspect";
|
|
6
9
|
type CliEnvironment = Record<string, string | undefined>;
|
|
7
10
|
export type CliOptions = {
|
|
8
|
-
command: "build" | "dev" | "help" | "preview";
|
|
11
|
+
command: "build" | "dev" | "help" | "inspect" | "preview" | "start";
|
|
9
12
|
host: string;
|
|
10
13
|
origin?: string;
|
|
11
14
|
outDir?: string;
|
|
@@ -25,10 +28,15 @@ export type BuildResult = {
|
|
|
25
28
|
outDir: string;
|
|
26
29
|
serverOutDir?: string;
|
|
27
30
|
};
|
|
31
|
+
export type StartRuntime = {
|
|
32
|
+
importModule: (specifier: string) => Promise<Record<string, unknown>>;
|
|
33
|
+
serve: (options: ServeNodeBuildOptions) => Promise<unknown>;
|
|
34
|
+
};
|
|
28
35
|
export declare function parseCliArguments(arguments_: string[], environment?: CliEnvironment): CliOptions;
|
|
29
|
-
export declare const helpText = "Usage: demiurge <command> [options]\n\nCommands:\n dev Start the development server\n build Build production output\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the server host (
|
|
36
|
+
export declare const helpText = "Usage: demiurge <command> [options]\n\nCommands:\n dev Start the development server\n build Build production output\n start Run built Node production output\n inspect Write the static inspection report as JSON\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the server host (start: HOST or 127.0.0.1; otherwise: localhost)\n --origin <origin> Set the build origin (default: SITE_ORIGIN)\n --out-dir <directory> Set the client output directory (default: dist)\n --port <port> Set the server port (dev: 5173, preview: 4173)\n -h, --help Show this help\n\nThe inspect command writes JSON to standard output and a summary to standard\nerror. It exits with 0 for no error finding, 1 for at least one error finding,\nand 2 for an invalid argument or an unreadable configuration.\n\nDemiurge reads demiurge.config.ts from the project root.";
|
|
30
37
|
export declare function runDev(options: CliOptions, config: ResolvedDemiurgeConfig): Promise<import("vite").ViteDevServer>;
|
|
31
38
|
export declare function runBuild(options: CliOptions, config: ResolvedDemiurgeConfig, runtime?: BuildRuntime): Promise<BuildResult>;
|
|
39
|
+
export declare function runStart(options: CliOptions, config: ResolvedDemiurgeConfig, environment?: CliEnvironment, runtime?: StartRuntime): Promise<unknown>;
|
|
32
40
|
export declare function resolvePreviewOutputDirectory(root: string, outDir: string | undefined, configuredOutDir?: string): string;
|
|
33
41
|
export declare function validateBuildOutputDirectory(root: string, outDir: string, publicDir: false | string, serverOutDir: string): Promise<void>;
|
|
34
42
|
//# 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":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAoB,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAEtE,OAAO,EAGL,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAUzD,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACpE,IAAI,EAAE,MAA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