@blocklet/pages-kit-inner-components 0.6.7 → 0.6.9

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