@blocklet/pages-kit-inner-components 0.6.103 → 0.6.105

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 (34) hide show
  1. package/lib/cjs/add-component.js +1 -1
  2. package/lib/cjs/chunks/components-BmFOXvb0.js +57 -0
  3. package/lib/cjs/chunks/{draft-data-CkVvOh60.js → draft-data-e1KnFlxv.js} +1 -1
  4. package/lib/cjs/chunks/{home-DdN3Z-6B.js → home-DHmHyTMb.js} +10 -10
  5. package/lib/cjs/chunks/{index-B-Wh6PRT.js → index-Cu2Jg8OH.js} +24 -24
  6. package/lib/cjs/chunks/{publish-button-BtLFUEny.js → publish-button-Do7oJLSH.js} +1 -1
  7. package/lib/cjs/chunks/site-state-BQySNTiP.js +1 -0
  8. package/lib/cjs/chunks/state-DU3L5Lve.js +1 -0
  9. package/lib/cjs/components.js +1 -1
  10. package/lib/cjs/home.js +1 -1
  11. package/lib/cjs/project-html.js +1 -1
  12. package/lib/cjs/resources.js +1 -1
  13. package/lib/cjs/setting.js +3 -3
  14. package/lib/cjs/site-state.js +1 -1
  15. package/lib/es/add-component.js +2 -2
  16. package/lib/es/chunks/components-DLjI_Xlm.js +615 -0
  17. package/lib/es/chunks/{draft-data-BOoVhbon.js → draft-data-DRdPzuGm.js} +1 -1
  18. package/lib/es/chunks/{home-DVTVPkSm.js → home-DajDpGXA.js} +123 -123
  19. package/lib/es/chunks/{index-DENjTU8O.js → index-BpP1FqET.js} +239 -238
  20. package/lib/es/chunks/{publish-button-BVcMw8Fh.js → publish-button-8kEbdc0k.js} +3 -3
  21. package/lib/es/chunks/site-state-DS7eIMFg.js +1684 -0
  22. package/lib/es/chunks/{state-DNdwHwty.js → state-qDCrgEMQ.js} +114 -113
  23. package/lib/es/components.js +14 -13
  24. package/lib/es/home.js +3 -3
  25. package/lib/es/project-html.js +1 -1
  26. package/lib/es/resources.js +2 -2
  27. package/lib/es/setting.js +415 -413
  28. package/lib/es/site-state.js +2 -2
  29. package/package.json +7 -7
  30. package/lib/cjs/chunks/components-DsHjikTX.js +0 -57
  31. package/lib/cjs/chunks/site-state-DlLhHuIr.js +0 -1
  32. package/lib/cjs/chunks/state-BdtFHk36.js +0 -1
  33. package/lib/es/chunks/components-BIhMGXjB.js +0 -610
  34. package/lib/es/chunks/site-state-CN4Kulgk.js +0 -1671
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as w } from "react/jsx-runtime";
2
- import { i as D, a as G, h as J, j as Z, k as ee, l as oe, m as te, f as re } from "./chunks/state-DNdwHwty.js";
2
+ import { i as D, a as G, h as J, j as Z, k as ee, l as oe, m as te, f as re } from "./chunks/state-qDCrgEMQ.js";
3
3
  import $ from "@arcblock/ux/lib/Empty";
4
4
  import { useLocaleContext as F } from "@arcblock/ux/lib/Locale/context";
5
5
  import { Icon as L } from "@iconify-icon/react";
@@ -7,7 +7,7 @@ import ie from "@mui/icons-material/Check";
7
7
  import { Box as n, styled as H, alpha as ne, Stack as ae, Dialog as se, DialogTitle as le, TextField as pe, IconButton as ce, DialogContent as de, Tabs as me, Tab as ue, Grid as O, Card as fe, CardMedia as be, CardContent as ge, Typography as W, DialogActions as xe, Button as N, Skeleton as he } from "@mui/material";
8
8
  import { useReactive as Q } from "ahooks";
9
9
  import { createContext as _, useMemo as P, useEffect as M, useRef as E } from "react";
10
- import { a as ye, R as ve, B as V, c as Ce, T as ke, I as we } from "./chunks/index-DENjTU8O.js";
10
+ import { a as ye, R as ve, B as V, c as Ce, T as ke, I as we } from "./chunks/index-BpP1FqET.js";
11
11
  import { styled as g } from "@arcblock/ux/lib/Theme";
12
12
  import "@blocklet/pages-kit/builtin/color-picker";
13
13
  import "@blocklet/pages-kit/utils/style";
@@ -0,0 +1,615 @@
1
+ import { memoize as X, BuiltinModules as I } from "@blocklet/quickjs";
2
+ import { createHash as Y } from "crypto";
3
+ import { promises as y } from "fs";
4
+ import J, { join as N } from "path";
5
+ import h from "@blocklet/sdk/lib/config";
6
+ import q from "lodash/isNil";
7
+ import { getComponentMountPoint as tt } from "@blocklet/pages-kit/builtin/utils";
8
+ import { PreloadComponentScriptModule as P } from "@blocklet/pages-kit/types";
9
+ import { BuiltinModules as A } from "@blocklet/pages-kit/utils/builtin";
10
+ import { componentUMDName as et, RenderNestedComponent as L, mergeComponent as ot } from "@blocklet/pages-kit/utils/property";
11
+ import nt from "lodash/isEmpty";
12
+ import { LRUCache as rt } from "lru-cache";
13
+ import st, { Headers as ct } from "node-fetch";
14
+ import $ from "p-limit";
15
+ import { joinURL as O, getQuery as at, withQuery as it, parseURL as k, withHttps as pt } from "ufo";
16
+ import lt from "@blocklet/logger";
17
+ import { isRelativeModule as ut, createBuiltinModuleTransformer as dt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
18
+ import "@blocklet/sdk/lib/component";
19
+ h.env.mode;
20
+ h.env.TRANSLATE_ADDITIONAL_PROMPT || process.env.TRANSLATE_ADDITIONAL_PROMPT;
21
+ h.env.PAGE_CONTENT_ADDITIONAL_PROMPT || process.env.PAGE_CONTENT_ADDITIONAL_PROMPT;
22
+ const ne = "image-bin";
23
+ h.env.INIT_TEMPLATE_PATH;
24
+ const re = process.env.DATABASE_URL || J.join(h.env.dataDir, "db/pages-kit.db"), F = h, se = () => h.env.tenantMode === "multiple", ce = () => (q(F.env.preferences.multiTenantAllProjectAccessPassports) ? [] : F.env.preferences.multiTenantAllProjectAccessPassports?.split(",")) || [], mt = J.join(h.env.dataDir, "fs-memoize-cache"), ft = h.env.FS_MEMOIZE_CACHE_VERSION || "v1.0.0", g = lt("pages-kit"), ht = mt, wt = ft, v = 30 * 24 * 60 * 60 * 1e3, gt = 24 * 60 * 60 * 1e3, K = async (t = "") => {
25
+ const e = N(ht, t);
26
+ try {
27
+ if (!(await y.stat(e)).isDirectory())
28
+ throw new Error(`${e} is not a directory`);
29
+ } catch {
30
+ await y.mkdir(e, { recursive: !0 });
31
+ }
32
+ return e;
33
+ }, U = (t, ...e) => t.keyGenerator ? t.keyGenerator(...e) : JSON.stringify([t.subdir || "", ...e]), yt = (t, e) => {
34
+ const o = Y("md5").update(e).digest("hex");
35
+ return N(t, `${wt}-${o}.json`);
36
+ }, xt = async (t = "") => {
37
+ const e = await K(t), o = Date.now();
38
+ try {
39
+ const n = await y.readdir(e);
40
+ await Promise.all(
41
+ n.filter((s) => s.endsWith(".json")).map(async (s) => {
42
+ const r = N(e, s);
43
+ try {
44
+ const l = await y.readFile(r, "utf-8"), a = JSON.parse(l);
45
+ a.createdAt && o - a.createdAt > v && await y.unlink(r);
46
+ } catch {
47
+ try {
48
+ const a = await y.stat(r);
49
+ o - a.mtimeMs > v && await y.unlink(r);
50
+ } catch {
51
+ }
52
+ }
53
+ })
54
+ );
55
+ } catch (n) {
56
+ console.error(`Failed to cleanup cache in ${e}:`, n);
57
+ }
58
+ }, St = (() => {
59
+ const t = /* @__PURE__ */ new Set();
60
+ return setInterval(async () => {
61
+ await Promise.all(Array.from(t).map((n) => xt(n)));
62
+ }, gt).unref(), (n) => {
63
+ t.add(n);
64
+ };
65
+ })();
66
+ function j(t, e) {
67
+ return e.subdir && St(e.subdir), X(
68
+ async (...n) => {
69
+ const s = await K(e.subdir || ""), r = U(e, ...n), l = yt(s, r);
70
+ try {
71
+ const a = await y.readFile(l, "utf-8"), { value: m, createdAt: i } = JSON.parse(a);
72
+ if (i && Date.now() - i > v)
73
+ throw await y.unlink(l).catch(() => {
74
+ }), new Error("Cache expired");
75
+ return m;
76
+ } catch {
77
+ const m = await t(...n), i = JSON.stringify({ value: m, createdAt: Date.now() });
78
+ return y.writeFile(l, i, "utf-8").catch((f) => {
79
+ console.error("Failed to write fs cache:", f);
80
+ }), m;
81
+ }
82
+ },
83
+ {
84
+ keyGenerator: (...n) => U(e, ...n),
85
+ lruOptions: e.lruOptions || {
86
+ max: 100,
87
+ ttl: v
88
+ }
89
+ }
90
+ );
91
+ }
92
+ const G = async () => await import("typescript"), Ct = async () => await import("esbuild"), Et = async () => (await import("postcss")).default, Pt = async () => (await import("tailwindcss")).default, Tt = async () => (await import("autoprefixer")).default, Mt = !1, bt = async (t, { componentId: e }) => {
93
+ const o = `@tailwind components;
94
+ @tailwind utilities;
95
+ `, n = `.CustomComponent_${e}`, s = await Et(), r = await Pt(), l = await Tt();
96
+ return (await s([
97
+ r({ content: [{ raw: t, extension: "tsx" }] }),
98
+ l({
99
+ overrideBrowserslist: ["> 1%", "last 2 versions"],
100
+ stats: {}
101
+ }),
102
+ (m) => {
103
+ m.walkRules((i) => {
104
+ i.selectors = i.selectors.map((f) => f.replace(/\.(.+)/g, `${n}.$1,${n} .$1`));
105
+ });
106
+ }
107
+ // FIXME: cssnano use browserslist, it is not working with the fs isolation
108
+ // cssnano({ preset: 'default' }),
109
+ ]).process(o)).css;
110
+ }, vt = async (t, { componentId: e }) => {
111
+ const o = await bt(t, { componentId: e });
112
+ return `export const __PagesKit_CSS__ = ${JSON.stringify(o)};
113
+
114
+ ${t}
115
+ `;
116
+ }, H = j(
117
+ async (t, e) => {
118
+ let o = await G();
119
+ try {
120
+ let n = o.transpileModule(t, {
121
+ compilerOptions: {
122
+ jsx: o.JsxEmit.React,
123
+ target: o.ScriptTarget.ES2016,
124
+ module: o.ModuleKind.ESNext
125
+ },
126
+ transformers: {
127
+ before: [dt(o)]
128
+ }
129
+ }).outputText;
130
+ if (e.tailwind && (n = await vt(n, { componentId: e.componentId })), e.module === P.ESM) return n;
131
+ const s = o.transpileModule(n, {
132
+ compilerOptions: {
133
+ jsx: o.JsxEmit.React,
134
+ target: o.ScriptTarget.ES2016,
135
+ module: o.ModuleKind.CommonJS,
136
+ moduleResolution: o.ModuleResolutionKind.Node16
137
+ }
138
+ }).outputText;
139
+ return e.module === P.CJS ? s : W(e.moduleName, s);
140
+ } catch (n) {
141
+ throw new Error(n);
142
+ } finally {
143
+ o = null;
144
+ }
145
+ },
146
+ {
147
+ subdir: "transpileModule"
148
+ }
149
+ ), _t = async (t, e) => {
150
+ let { build: o } = await Ct(), n = null;
151
+ try {
152
+ const r = (await o({
153
+ entryPoints: ["index.tsx"],
154
+ external: Object.keys(A),
155
+ format: "esm",
156
+ target: "esnext",
157
+ bundle: !0,
158
+ write: !1,
159
+ plugins: [
160
+ {
161
+ name: "vfs",
162
+ setup(m) {
163
+ m.onResolve({ filter: /.*/ }, (i) => i.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : i.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : null), m.onLoad({ filter: /.*/, namespace: "vfs" }, async (i) => {
164
+ if (i.path === "index.tsx")
165
+ return { contents: `export { ${e} } from './component'`, loader: "tsx" };
166
+ if (i.path === "component.tsx")
167
+ return { contents: t, loader: "tsx" };
168
+ if (ut(i.path)) {
169
+ const f = i.path.split("/").pop();
170
+ }
171
+ return null;
172
+ });
173
+ }
174
+ }
175
+ ]
176
+ })).outputFiles?.[0]?.contents;
177
+ if (!r) throw new Error("Failed to build server code");
178
+ const l = Buffer.from(r).toString();
179
+ return n = await G(), n.transpileModule(l, {
180
+ compilerOptions: { module: n.ModuleKind.ESNext, target: n.ScriptTarget.ES2020 }
181
+ }).outputText;
182
+ } catch (s) {
183
+ throw new Error(s);
184
+ } finally {
185
+ o = null, n = null;
186
+ }
187
+ }, It = (t, e) => new RegExp(
188
+ `export\\s+\\{[^}]*(?:\\w+\\s+as\\s+${e}\\b|\\b${e}\\b)[^}]*\\}`,
189
+ "m"
190
+ ).test(t) ? t : void 0, V = j(
191
+ async (t, e) => {
192
+ const o = await _t(t, e);
193
+ return It(o, e);
194
+ },
195
+ {
196
+ subdir: "extractExportValueSchema"
197
+ }
198
+ ), W = (t, e) => `// GENERATED FILE. DO NOT EDIT.
199
+ var ${t} = async function () {
200
+
201
+ const exports = {};
202
+ let moduleExports = null;
203
+
204
+ // add commonjs module compatibility layer
205
+ const module = { exports: moduleExports };
206
+
207
+ // execute component code
208
+ ${e}
209
+
210
+ // handle possible module.exports
211
+ if (module.exports && module.exports !== moduleExports) {
212
+ // if module.exports is used, use it first
213
+ return typeof module.exports === 'object' ? module.exports : { default: module.exports };
214
+ }
215
+
216
+ // ensure a default export
217
+ if (!('default' in exports) && Object.keys(exports).length === 0) {
218
+ // module has no exports, return null to indicate invalid
219
+ return null;
220
+ }
221
+
222
+ return exports;
223
+ };
224
+ `, Q = async () => {
225
+ const { Sandbox: t } = await import("@blocklet/quickjs");
226
+ return t;
227
+ };
228
+ function Ot(t) {
229
+ return t?.type === "react-component";
230
+ }
231
+ const E = new rt({
232
+ max: 600,
233
+ ttl: 1e3 * 60 * 60 * 24 * 7
234
+ // default ttl is 7 days
235
+ }), At = 60 * 60, B = 10;
236
+ function z(t) {
237
+ g.info("clear preload components cache", { cacheKey: t }), E.delete(t);
238
+ }
239
+ function ae(t) {
240
+ for (const e of E.keys())
241
+ e.includes(t) && (g.info("clear preload components cache", { cacheKey: e }), z(e));
242
+ }
243
+ function ie(t) {
244
+ for (const e of E.keys())
245
+ e.includes(t) && (g.info("clear preload components cache", { cacheKey: e }), z(e));
246
+ }
247
+ function Nt({
248
+ mode: t,
249
+ instanceId: e,
250
+ componentId: o,
251
+ locale: n
252
+ }) {
253
+ return ["getPreloadComponents", t, e, o, n].join("-");
254
+ }
255
+ async function pe({
256
+ mode: t,
257
+ req: e,
258
+ state: o,
259
+ locale: n,
260
+ instances: s,
261
+ module: r
262
+ }) {
263
+ const {
264
+ supportedLocales: l,
265
+ config: { defaultLocale: a }
266
+ } = o;
267
+ if (!a) return null;
268
+ const m = $(10), i = (await Promise.all(
269
+ s.map(
270
+ (p) => m(async () => {
271
+ try {
272
+ const u = Nt({
273
+ mode: t,
274
+ instanceId: p.id,
275
+ componentId: p.componentId,
276
+ locale: n
277
+ });
278
+ if (t !== "draft" && p.useCache && E.has(u))
279
+ return g.info(`get preload component from cache: ${u}`), E.get(u);
280
+ const d = _({ state: o, componentId: p.componentId });
281
+ if (!d) return null;
282
+ const S = await jt({
283
+ req: e,
284
+ state: o,
285
+ componentId: d.id,
286
+ locale: n,
287
+ defaultLocale: a,
288
+ properties: p.properties
289
+ });
290
+ if (!S) return null;
291
+ const T = { instanceId: p.id, preload: S };
292
+ if (t !== "draft" && p.useCache) {
293
+ let C = At;
294
+ p.cacheDuration && (C = p.cacheDuration), g.info(`set preload component to cache(${C}s): ${u}`), E.set(u, T, {
295
+ ttl: C * 1e3
296
+ });
297
+ }
298
+ return T;
299
+ } catch (u) {
300
+ return g.error(
301
+ "get preload component error",
302
+ { instanceId: p.id, componentId: p.componentId },
303
+ { error: u }
304
+ ), null;
305
+ }
306
+ })
307
+ )
308
+ )).filter((p) => !!p), f = Object.values(
309
+ i.reduce((p, u) => ({ ...p, ...u.preload.components }), {})
310
+ );
311
+ async function x() {
312
+ const p = $(10), u = await Promise.all(
313
+ f.map(
314
+ (d) => p(async () => {
315
+ const S = r === P.ESM, T = r === P.UMD_FN, C = r === P.CJS, M = S ? "" : et({ componentId: d.component.id }), D = $t(d.component);
316
+ let b = {
317
+ module: r,
318
+ script: "",
319
+ moduleName: M
320
+ };
321
+ if (D && d.component.renderer?.type === "react-component" && S && d.component.renderer?.script)
322
+ b.script = d.component.renderer?.script;
323
+ else if (D && d.component.renderer?.type === "react-component" && (C || T) && d.component.renderer?.cjsScript) {
324
+ const R = d.component.renderer.cjsScript;
325
+ b.script = C ? R : W(M, R);
326
+ } else
327
+ b = S ? {
328
+ // ESM
329
+ module: r,
330
+ script: await H(d.script, {
331
+ componentId: d.component.id,
332
+ module: r,
333
+ tailwind: t !== "draft"
334
+ })
335
+ } : {
336
+ // CJS OR UMD
337
+ module: r,
338
+ script: await H(d.script, {
339
+ componentId: d.component.id,
340
+ module: r,
341
+ moduleName: M,
342
+ tailwind: t !== "draft"
343
+ }),
344
+ moduleName: M
345
+ };
346
+ return [d.component.id, { component: d.component, script: b }];
347
+ })
348
+ )
349
+ );
350
+ return Object.fromEntries(u);
351
+ }
352
+ const c = await x();
353
+ return {
354
+ config: { defaultLocale: a, supportedLocales: l },
355
+ components: c,
356
+ instances: i.map((p) => ({
357
+ id: p.instanceId,
358
+ componentId: p.preload.component.id,
359
+ locales: { [p.preload.locale]: { props: p.preload.props } }
360
+ }))
361
+ };
362
+ }
363
+ async function jt({
364
+ req: t,
365
+ state: e,
366
+ componentId: o,
367
+ locale: n,
368
+ defaultLocale: s,
369
+ properties: r
370
+ }) {
371
+ const { supportedLocales: l } = e, a = _({ state: e, componentId: o });
372
+ if (!a) return null;
373
+ const m = l.some((f) => f.locale === n) ? n : s;
374
+ if (!m) return null;
375
+ const i = await Z({ req: t, state: e, componentId: o, locale: m, defaultLocale: s, properties: r });
376
+ return i ? {
377
+ component: a,
378
+ ...i
379
+ } : null;
380
+ }
381
+ const Dt = 20;
382
+ async function Z({
383
+ req: t,
384
+ depth: e = 0,
385
+ state: o,
386
+ componentId: n,
387
+ locale: s,
388
+ defaultLocale: r,
389
+ properties: l
390
+ }) {
391
+ if (e > Dt) throw new RangeError("max component depth exceeded");
392
+ const a = Rt({ state: o, componentId: n, properties: l, locale: s });
393
+ if (!a) return null;
394
+ const { props: m, component: i } = a, f = {
395
+ locale: s || r,
396
+ components: { [a.component.id]: { component: a.component, script: a.script } },
397
+ props: { ...m }
398
+ };
399
+ try {
400
+ const x = Ot(i.renderer) ? i.renderer.getServerSideProps : void 0, c = await Lt({ ...a, req: t, getServerSideProps: x });
401
+ c?.props && Object.assign(f.props, c.props);
402
+ } catch (x) {
403
+ g.error("preload data at server side error", { componentId: n, name: a.component.name }, { error: x });
404
+ }
405
+ return await Promise.all(
406
+ Object.entries(m).map(async ([x, c]) => {
407
+ if (c?.type === L) {
408
+ const w = await Z({
409
+ req: t,
410
+ depth: e + 1,
411
+ state: o,
412
+ componentId: c.componentId,
413
+ locale: s,
414
+ defaultLocale: r,
415
+ properties: c.properties
416
+ });
417
+ w && (Object.assign(f.components, w.components), Object.assign(f.props, {
418
+ [x]: {
419
+ type: L,
420
+ componentId: c.componentId,
421
+ props: w.props
422
+ }
423
+ }));
424
+ }
425
+ })
426
+ ), f;
427
+ }
428
+ function Rt({
429
+ state: t,
430
+ componentId: e,
431
+ locale: o,
432
+ properties: n
433
+ }) {
434
+ const s = _({ state: t, componentId: e });
435
+ if (!s) return null;
436
+ const r = ot({
437
+ componentId: e,
438
+ getComponent: (l) => _({ state: t, componentId: l }),
439
+ locale: o,
440
+ defaultLocale: t.config.defaultLocale,
441
+ properties: n
442
+ });
443
+ return r ? { component: s, script: r.script, props: { locale: o, ...r.props } } : null;
444
+ }
445
+ function _({ state: t, componentId: e }) {
446
+ return t.components[e]?.data ?? t.resources.components?.[e]?.component;
447
+ }
448
+ function le({ state: t, name: e }) {
449
+ const o = e.toLowerCase();
450
+ return Object.values(t.components).find((n) => n.data.name?.toLowerCase() === o)?.data ?? (t.resources.components && Object.values(t.resources.components).find((n) => n.component.name?.toLowerCase() === o))?.component;
451
+ }
452
+ async function Lt({
453
+ component: t,
454
+ script: e,
455
+ props: o,
456
+ req: n,
457
+ getServerSideProps: s
458
+ }) {
459
+ if (!s && !e?.includes("getServerSideProps"))
460
+ return null;
461
+ const r = s ?? await V(e, "getServerSideProps");
462
+ if (!r) return null;
463
+ const a = (r.match(/export\s*{\s*(\w+)\s+as\s+getServerSideProps\s*}/) || r.match(/export\s*{\s*getServerSideProps\s*}/))?.[1] || "getServerSideProps", m = new Promise((c) => {
464
+ setTimeout(() => {
465
+ c({});
466
+ }, B * 1e3);
467
+ });
468
+ let i = await Q();
469
+ const f = {
470
+ componentMountPoints: h.components
471
+ };
472
+ return await Promise.race([
473
+ m,
474
+ i.callFunction({
475
+ code: `${r}
476
+
477
+ export async function getServerSidePropsWrapper(props) {
478
+ const { location, fetch, props: componentProps } = props;
479
+ // 使用局部变量而不是全局变量
480
+ const originalLocation = typeof window !== 'undefined' ? window.location : undefined;
481
+ const originalFetch = globalThis.fetch;
482
+
483
+ try {
484
+ globalThis.location = location;
485
+ globalThis.fetch = fetch;
486
+ return await ${a}(componentProps);
487
+ } finally {
488
+ // 清理全局状态
489
+ if (originalLocation) globalThis.location = originalLocation;
490
+ if (originalFetch) globalThis.fetch = originalFetch;
491
+ }
492
+ }`,
493
+ filename: `${t.name || t.id}.js`,
494
+ moduleLoader: (c) => {
495
+ if (c === "@blocklet/pages-kit/builtin/utils")
496
+ return ` const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
497
+ export { joinURL, withQuery, getQuery, getComponentMountPoint }
498
+ `;
499
+ if (c === "@blocklet/pages-kit/builtin/dayjs")
500
+ return I.dayjs;
501
+ if (c in I)
502
+ return I[c];
503
+ if (c in A) {
504
+ const w = A[c];
505
+ return nt(w) ? void 0 : w;
506
+ }
507
+ },
508
+ global: {
509
+ console: {
510
+ // NOTE: do not return logger.xxx result, it will cause memory leak
511
+ // eslint-disable-next-line prettier/prettier
512
+ log: (...c) => {
513
+ g.info(...c);
514
+ },
515
+ warn: (...c) => {
516
+ g.warn(...c);
517
+ },
518
+ error: (...c) => {
519
+ g.error(...c);
520
+ }
521
+ },
522
+ getComponentMountPoint: tt,
523
+ joinURL: O,
524
+ withQuery: it,
525
+ getQuery: at,
526
+ window: {
527
+ blocklet: f
528
+ },
529
+ blocklet: f
530
+ },
531
+ functionName: "getServerSidePropsWrapper",
532
+ args: [
533
+ {
534
+ // NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
535
+ // because the global is shared between all runtime and just init once
536
+ location: { href: O(pt(n.hostname), n.originalUrl) },
537
+ fetch: (c, { ...w } = {}) => {
538
+ const p = typeof c == "string" && c.startsWith("/") ? O(h.env.appUrl, c) : c;
539
+ if (typeof p == "string" && k(p).host === k(h.env.appUrl).host) {
540
+ const u = n.get("cookie");
541
+ if (u) {
542
+ const d = new ct(w.headers);
543
+ d.set("cookie", u), w.headers = d;
544
+ }
545
+ }
546
+ return st(p, {
547
+ ...w,
548
+ timeout: B * 1e3
549
+ }).then((u) => ({
550
+ ok: u.ok,
551
+ status: u.status,
552
+ statusText: u.statusText,
553
+ headers: Object.fromEntries(u.headers.entries()),
554
+ json: () => u.json()
555
+ }));
556
+ },
557
+ props: o
558
+ }
559
+ ]
560
+ }).finally(() => {
561
+ i = null;
562
+ })
563
+ ]);
564
+ }
565
+ const ue = j(
566
+ async (t, e, o, n) => {
567
+ if (!t?.includes(e) && !n)
568
+ return null;
569
+ const s = n ?? await V(t, e);
570
+ if (s)
571
+ try {
572
+ let r = await Q();
573
+ return await r.callFunction({
574
+ cache: !0,
575
+ code: `
576
+ ${s}
577
+
578
+ export function get${e}SchemaWrapper() {
579
+ return ${e};
580
+ }
581
+ `,
582
+ filename: `${o}.js`,
583
+ functionName: `get${e}SchemaWrapper`
584
+ }).finally(() => {
585
+ r = null;
586
+ });
587
+ } catch (r) {
588
+ return g.error(`获取 ${e} 失败`, { componentId: o, error: r }), null;
589
+ }
590
+ return null;
591
+ },
592
+ {
593
+ subdir: "getExportSchemaValueFromCode"
594
+ }
595
+ ), $t = (t) => !!(t.renderer?.type === "react-component" && t.version && t.version >= 2);
596
+ export {
597
+ At as C,
598
+ B as G,
599
+ ne as I,
600
+ ce as a,
601
+ ue as b,
602
+ ae as c,
603
+ re as d,
604
+ z as e,
605
+ ie as f,
606
+ pe as g,
607
+ Nt as h,
608
+ se as i,
609
+ jt as j,
610
+ _ as k,
611
+ g as l,
612
+ j as m,
613
+ le as n,
614
+ $t as s
615
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { u as a, S as o, g as s, a as n } from "./state-DNdwHwty.js";
2
+ import { u as a, S as o, g as s, a as n } from "./state-qDCrgEMQ.js";
3
3
  function d({ children: t }) {
4
4
  const r = a();
5
5
  return /* @__PURE__ */ e(o, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });