@blocklet/pages-kit-inner-components 0.4.155 → 0.4.157

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.
@@ -1,28 +1,28 @@
1
1
  var St = Object.defineProperty;
2
- var wt = (t, s, e) => s in t ? St(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
3
- var j = (t, s, e) => wt(t, typeof s != "symbol" ? s + "" : s, e);
2
+ var wt = (e, s, t) => s in e ? St(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var j = (e, s, t) => wt(e, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { getComponentMountPoint as bt } from "@blocklet/pages-kit/builtin/utils";
5
- import { PreloadComponentScriptModule as fe } from "@blocklet/pages-kit/types";
6
- import { componentUMDName as It, RenderNestedComponent as Ve, mergeComponent as Et, getComponentDependencies as At } from "@blocklet/pages-kit/utils/property";
7
- import { memoize as Ae, Sandbox as ot, BuiltinModules as Ot } from "@blocklet/quickjs";
5
+ import { PreloadComponentScriptModule as ge } from "@blocklet/pages-kit/types";
6
+ import { componentUMDName as It, RenderNestedComponent as Je, mergeComponent as Et, getComponentDependencies as At } from "@blocklet/pages-kit/utils/property";
7
+ import { memoize as Oe, Sandbox as ot, BuiltinModules as Ot } from "@blocklet/quickjs";
8
8
  import I from "@blocklet/sdk/lib/config";
9
9
  import { LRUCache as Re } from "lru-cache";
10
10
  import Tt, { Headers as vt } from "node-fetch";
11
- import { joinURL as K, getQuery as Pt, withQuery as Ct, parseURL as He, withHttps as Dt } from "ufo";
12
- import { createHash as Oe } from "crypto";
11
+ import { joinURL as K, getQuery as Pt, withQuery as Ct, parseURL as Ve, withHttps as Dt } from "ufo";
12
+ import { createHash as te } from "crypto";
13
13
  import xt from "@blocklet/logger";
14
14
  import { BuiltinModules as jt } from "@blocklet/pages-kit/utils/builtin";
15
15
  import { createBuiltinModuleTransformer as kt, isRelativeModule as Nt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
16
16
  import { getResources as Lt, getComponentWebEndpoint as Rt, call as _t } from "@blocklet/sdk/lib/component";
17
17
  import Mt from "autoprefixer";
18
18
  import * as Ut from "esbuild";
19
- import { readFileSync as X, mkdtempSync as $t, existsSync as F, lstatSync as Q, readdirSync as Ft, rmSync as rt, renameSync as Ke, mkdirSync as J, writeFileSync as he, copyFileSync as Bt, createWriteStream as Gt } from "fs";
20
- import Jt from "postcss";
21
- import Vt from "tailwindcss";
19
+ import { readFileSync as X, mkdtempSync as $t, existsSync as F, lstatSync as Q, readdirSync as Ft, rmSync as rt, renameSync as Ke, mkdirSync as H, writeFileSync as ye, copyFileSync as Bt, createWriteStream as Gt } from "fs";
20
+ import Ht from "postcss";
21
+ import Jt from "tailwindcss";
22
22
  import L from "typescript";
23
- import { getYjsValue as te, syncedStore as Ht } from "@syncedstore/core";
23
+ import { getYjsValue as se, syncedStore as Vt } from "@syncedstore/core";
24
24
  import * as B from "yjs";
25
- import Kt, { join as O, dirname as _, basename as se } from "path";
25
+ import Kt, { join as O, dirname as _, basename as ne } from "path";
26
26
  import { setPageDataSource as zt } from "@blocklet/pages-kit/utils/data-source";
27
27
  import { getRouteMetaDataByOptionIds as Yt, generateParamCombinations as _e } from "@blocklet/pages-kit/utils/route";
28
28
  import { cloneDeep as Wt } from "lodash";
@@ -57,11 +57,11 @@ I.env.PAGE_CONTENT_ADDITIONAL_PROMPT || process.env.PAGE_CONTENT_ADDITIONAL_PROM
57
57
  const gs = "image-bin";
58
58
  I.env.INIT_TEMPLATE_PATH;
59
59
  const hs = process.env.DATABASE_URL || Kt.join(I.env.dataDir, "db/pages-kit.db"), We = I, Un = () => I.env.tenantMode === "multiple", $n = () => {
60
- var t;
61
- return (us(We.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = We.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
60
+ var e;
61
+ return (us(We.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (e = We.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : e.split(",")) || [];
62
62
  }, b = xt("pages-kit"), ys = x.sqlite.DATE.parse;
63
- x.sqlite.DATE.parse = (t, s) => typeof t == "number" ? new Date(t) : ys(t, s);
64
- const ie = new ms({
63
+ x.sqlite.DATE.parse = (e, s) => typeof e == "number" ? new Date(e) : ys(e, s);
64
+ const ce = new ms({
65
65
  dialect: "sqlite",
66
66
  storage: hs,
67
67
  benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
@@ -74,9 +74,9 @@ const ie = new ms({
74
74
  logging: process.env.ENABLE_SEQUELIZE_LOGGING === "true" ? console.log : !1
75
75
  // logQueryParameters: true,
76
76
  });
77
- ie.query("pragma journal_mode = WAL;");
78
- ie.query("pragma synchronous = normal;");
79
- ie.query("pragma journal_size_limit = 67108864;");
77
+ ce.query("pragma journal_mode = WAL;");
78
+ ce.query("pragma synchronous = normal;");
79
+ ce.query("pragma journal_size_limit = 67108864;");
80
80
  class Te extends it {
81
81
  // Foreign key to Component
82
82
  }
@@ -97,7 +97,7 @@ Te.init(
97
97
  allowNull: !1
98
98
  }
99
99
  },
100
- { sequelize: ie, tableName: "ProjectComponents", timestamps: !1 }
100
+ { sequelize: ce, tableName: "ProjectComponents", timestamps: !1 }
101
101
  );
102
102
  class q extends it {
103
103
  static async getProjectByIdOrSlug(s) {
@@ -142,23 +142,23 @@ q.init(
142
142
  get() {
143
143
  return this.getDataValue("relatedBlocklets") || {};
144
144
  },
145
- set(t) {
146
- this.setDataValue("relatedBlocklets", JSON.stringify(t || {}));
145
+ set(e) {
146
+ this.setDataValue("relatedBlocklets", JSON.stringify(e || {}));
147
147
  }
148
148
  }
149
149
  },
150
- { sequelize: ie, paranoid: !0 }
150
+ { sequelize: ce, paranoid: !0 }
151
151
  );
152
152
  q.hasMany(Te, {
153
153
  foreignKey: "projectId",
154
154
  as: "components"
155
155
  });
156
- const Ss = async (t, { componentId: s }) => {
157
- const e = `@tailwind components;
156
+ const Ss = async (e, { componentId: s }) => {
157
+ const t = `@tailwind components;
158
158
  @tailwind utilities;
159
159
  `, n = `.CustomComponent_${s}`;
160
- return (await Jt([
161
- Vt({ content: [{ raw: t, extension: "tsx" }] }),
160
+ return (await Ht([
161
+ Jt({ content: [{ raw: e, extension: "tsx" }] }),
162
162
  Mt({
163
163
  overrideBrowserslist: ["> 1%", "last 2 versions"],
164
164
  stats: {}
@@ -170,16 +170,16 @@ const Ss = async (t, { componentId: s }) => {
170
170
  }
171
171
  // FIXME: cssnano use browserslist, it is not working with the fs isolation
172
172
  // cssnano({ preset: 'default' }),
173
- ]).process(e)).css;
174
- }, ws = async (t, { componentId: s }) => {
175
- const e = await Ss(t, { componentId: s });
176
- return `export const __PagesKit_CSS__ = ${JSON.stringify(e)};
173
+ ]).process(t)).css;
174
+ }, ws = async (e, { componentId: s }) => {
175
+ const t = await Ss(e, { componentId: s });
176
+ return `export const __PagesKit_CSS__ = ${JSON.stringify(t)};
177
177
 
178
- ${t}
178
+ ${e}
179
179
  `;
180
- }, qe = Ae(
181
- async (t, s) => {
182
- let e = L.transpileModule(t, {
180
+ }, qe = Oe(
181
+ async (e, s) => {
182
+ let t = L.transpileModule(e, {
183
183
  compilerOptions: {
184
184
  jsx: L.JsxEmit.React,
185
185
  target: L.ScriptTarget.ES2016,
@@ -189,8 +189,8 @@ ${t}
189
189
  before: [kt(L)]
190
190
  }
191
191
  }).outputText;
192
- if (s.tailwind && (e = await ws(e, { componentId: s.componentId })), s.module === fe.ESM) return e;
193
- const n = L.transpileModule(e, {
192
+ if (s.tailwind && (t = await ws(t, { componentId: s.componentId })), s.module === ge.ESM) return t;
193
+ const n = L.transpileModule(t, {
194
194
  compilerOptions: {
195
195
  jsx: L.JsxEmit.React,
196
196
  target: L.ScriptTarget.ES2016,
@@ -198,18 +198,18 @@ ${t}
198
198
  moduleResolution: L.ModuleResolutionKind.Node16
199
199
  }
200
200
  }).outputText;
201
- return s.module === fe.CJS ? n : Is(s.moduleName, n);
201
+ return s.module === ge.CJS ? n : Is(s.moduleName, n);
202
202
  },
203
203
  {
204
- keyGenerator: (t, s) => {
205
- const e = Oe("md5").update(t).digest("hex"), n = {
204
+ keyGenerator: (e, s) => {
205
+ const t = te("md5").update(e).digest("hex"), n = {
206
206
  ...s,
207
207
  componentId: s.componentId,
208
208
  module: s.module,
209
- ...s.module !== fe.ESM ? { moduleName: s.moduleName } : {},
209
+ ...s.module !== ge.ESM ? { moduleName: s.moduleName } : {},
210
210
  tailwind: s.tailwind
211
211
  };
212
- return JSON.stringify(["transpileModule", e, n]);
212
+ return JSON.stringify(["transpileModule", t, n]);
213
213
  },
214
214
  lruOptions: {
215
215
  max: 100,
@@ -218,7 +218,7 @@ ${t}
218
218
  // 1小时过期时间
219
219
  }
220
220
  }
221
- ), bs = async (t, s) => {
221
+ ), bs = async (e, s) => {
222
222
  var l, c;
223
223
  const n = (c = (l = (await Ut.build({
224
224
  entryPoints: ["index.tsx"],
@@ -237,7 +237,7 @@ ${t}
237
237
  if (u.path === "index.tsx")
238
238
  return { contents: `export { ${s} } from './component'`, loader: "tsx" };
239
239
  if (u.path === "component.tsx")
240
- return { contents: t, loader: "tsx" };
240
+ return { contents: e, loader: "tsx" };
241
241
  if (Nt(u.path)) {
242
242
  const h = u.path.split("/").pop();
243
243
  if (p || (p = await Ge({ ensureLoaded: !1 })), (y = p == null ? void 0 : p.chunks) != null && y[h])
@@ -258,23 +258,23 @@ ${t}
258
258
  return L.transpileModule(o, {
259
259
  compilerOptions: { module: L.ModuleKind.ESNext, target: L.ScriptTarget.ES2020 }
260
260
  }).outputText;
261
- }, ct = Ae(
262
- async (t, s) => {
263
- const e = await bs(t, s);
264
- return new RegExp(`export\\s+\\{\\s+${s}\\s+\\}`, "m").test(e) ? e : void 0;
261
+ }, ct = Oe(
262
+ async (e, s) => {
263
+ const t = await bs(e, s);
264
+ return new RegExp(`export\\s+\\{\\s+${s}\\s+\\}`, "m").test(t) ? t : void 0;
265
265
  },
266
266
  {
267
- keyGenerator: (t, s) => {
268
- const e = Oe("md5").update(t).digest("hex");
269
- return JSON.stringify(["extractExportValueSchema", e, s]);
267
+ keyGenerator: (e, s) => {
268
+ const t = te("md5").update(e).digest("hex");
269
+ return JSON.stringify(["extractExportValueSchema", t, s]);
270
270
  },
271
271
  lruOptions: {
272
272
  max: 100,
273
273
  ttl: 1e3 * 60 * 60
274
274
  }
275
275
  }
276
- ), Is = (t, s) => `// GENERATED FILE. DO NOT EDIT.
277
- var ${t} = function () {
276
+ ), Is = (e, s) => `// GENERATED FILE. DO NOT EDIT.
277
+ var ${e} = function () {
278
278
 
279
279
  const exports = {};
280
280
  let moduleExports = null;
@@ -299,28 +299,28 @@ var ${t} = function () {
299
299
 
300
300
  return exports;
301
301
  };
302
- `, re = new Re({
302
+ `, ae = new Re({
303
303
  max: 100
304
304
  }), Es = 60 * 60, Qe = 60;
305
- function As(t) {
306
- b.info("clear preload components cache", { cacheKey: t }), re.delete(t);
305
+ function As(e) {
306
+ b.info("clear preload components cache", { cacheKey: e }), ae.delete(e);
307
307
  }
308
- function Os(t) {
309
- for (const s of re.keys())
310
- s.includes(t) && (b.info("clear preload components cache", { cacheKey: s }), As(s));
308
+ function Os(e) {
309
+ for (const s of ae.keys())
310
+ s.includes(e) && (b.info("clear preload components cache", { cacheKey: s }), As(s));
311
311
  }
312
312
  function Ts({
313
- mode: t,
313
+ mode: e,
314
314
  instanceId: s,
315
- componentId: e,
315
+ componentId: t,
316
316
  locale: n
317
317
  }) {
318
- return ["getPreloadComponents", t, s, e, n].join("-");
318
+ return ["getPreloadComponents", e, s, t, n].join("-");
319
319
  }
320
320
  async function Fn({
321
- mode: t,
321
+ mode: e,
322
322
  req: s,
323
- state: e,
323
+ state: t,
324
324
  locale: n,
325
325
  instances: o,
326
326
  module: r
@@ -328,24 +328,24 @@ async function Fn({
328
328
  const {
329
329
  supportedLocales: l,
330
330
  config: { defaultLocale: c }
331
- } = e;
331
+ } = t;
332
332
  if (!c) return null;
333
333
  const d = (await Promise.all(
334
334
  o.map(async (a) => {
335
335
  try {
336
336
  const i = Ts({
337
- mode: t,
337
+ mode: e,
338
338
  instanceId: a.id,
339
339
  componentId: a.componentId,
340
340
  locale: n
341
341
  });
342
- if (t !== "draft" && a.useCache && re.has(i))
343
- return b.info(`get preload component from cache: ${i}`), re.get(i);
344
- const m = ye({ state: e, componentId: a.componentId });
342
+ if (e !== "draft" && a.useCache && ae.has(i))
343
+ return b.info(`get preload component from cache: ${i}`), ae.get(i);
344
+ const m = Se({ state: t, componentId: a.componentId });
345
345
  if (!m) return null;
346
346
  const w = await vs({
347
347
  req: s,
348
- state: e,
348
+ state: t,
349
349
  componentId: m.id,
350
350
  locale: n,
351
351
  defaultLocale: c,
@@ -353,9 +353,9 @@ async function Fn({
353
353
  });
354
354
  if (!w) return null;
355
355
  const D = { instanceId: a.id, preload: w };
356
- if (t !== "draft" && a.useCache) {
356
+ if (e !== "draft" && a.useCache) {
357
357
  let A = Es;
358
- a.cacheDuration && (A = a.cacheDuration), b.info(`set preload component to cache(${A}s): ${i}`), re.set(i, D, {
358
+ a.cacheDuration && (A = a.cacheDuration), b.info(`set preload component to cache(${A}s): ${i}`), ae.set(i, D, {
359
359
  ttl: A * 1e3
360
360
  });
361
361
  }
@@ -370,12 +370,12 @@ async function Fn({
370
370
  async function u() {
371
371
  const a = await Promise.all(
372
372
  p.map(async (i) => {
373
- const m = It({ componentId: i.component.id }), w = r === fe.ESM ? {
373
+ const m = It({ componentId: i.component.id }), w = r === ge.ESM ? {
374
374
  module: r,
375
375
  script: await qe(i.script, {
376
376
  componentId: i.component.id,
377
377
  module: r,
378
- tailwind: t !== "draft"
378
+ tailwind: e !== "draft"
379
379
  })
380
380
  } : {
381
381
  module: r,
@@ -383,7 +383,7 @@ async function Fn({
383
383
  componentId: i.component.id,
384
384
  module: r,
385
385
  moduleName: m,
386
- tailwind: t !== "draft"
386
+ tailwind: e !== "draft"
387
387
  }),
388
388
  moduleName: m
389
389
  };
@@ -404,18 +404,18 @@ async function Fn({
404
404
  };
405
405
  }
406
406
  async function vs({
407
- req: t,
407
+ req: e,
408
408
  state: s,
409
- componentId: e,
409
+ componentId: t,
410
410
  locale: n,
411
411
  defaultLocale: o,
412
412
  properties: r
413
413
  }) {
414
- const { supportedLocales: l } = s, c = ye({ state: s, componentId: e });
414
+ const { supportedLocales: l } = s, c = Se({ state: s, componentId: t });
415
415
  if (!c) return null;
416
416
  const d = l.some((u) => u.locale === n) ? n : o;
417
417
  if (!d) return null;
418
- const p = await pt({ req: t, state: s, componentId: e, locale: d, defaultLocale: o, properties: r });
418
+ const p = await pt({ req: e, state: s, componentId: t, locale: d, defaultLocale: o, properties: r });
419
419
  return p ? {
420
420
  component: c,
421
421
  ...p
@@ -423,16 +423,16 @@ async function vs({
423
423
  }
424
424
  const Ps = 20;
425
425
  async function pt({
426
- req: t,
426
+ req: e,
427
427
  depth: s = 0,
428
- state: e,
428
+ state: t,
429
429
  componentId: n,
430
430
  locale: o,
431
431
  defaultLocale: r,
432
432
  properties: l
433
433
  }) {
434
434
  if (s > Ps) throw new RangeError("max component depth exceeded");
435
- const c = Cs({ state: e, componentId: n, properties: l, locale: o });
435
+ const c = Cs({ state: t, componentId: n, properties: l, locale: o });
436
436
  if (!c) return null;
437
437
  const { props: d } = c, p = {
438
438
  locale: o || r,
@@ -440,18 +440,18 @@ async function pt({
440
440
  props: { ...d }
441
441
  };
442
442
  try {
443
- const u = await Ds({ ...c, req: t });
443
+ const u = await Ds({ ...c, req: e });
444
444
  u != null && u.props && Object.assign(p.props, u.props);
445
445
  } catch (u) {
446
446
  b.error("preload data at server side error", { componentId: n, name: c.component.name }, { error: u });
447
447
  }
448
448
  return await Promise.all(
449
449
  Object.entries(d).map(async ([u, y]) => {
450
- if ((y == null ? void 0 : y.type) === Ve) {
450
+ if ((y == null ? void 0 : y.type) === Je) {
451
451
  const h = await pt({
452
- req: t,
452
+ req: e,
453
453
  depth: s + 1,
454
- state: e,
454
+ state: t,
455
455
  componentId: y.componentId,
456
456
  locale: o,
457
457
  defaultLocale: r,
@@ -459,7 +459,7 @@ async function pt({
459
459
  });
460
460
  h && (Object.assign(p.components, h.components), Object.assign(p.props, {
461
461
  [u]: {
462
- type: Ve,
462
+ type: Je,
463
463
  componentId: y.componentId,
464
464
  props: h.props
465
465
  }
@@ -469,41 +469,41 @@ async function pt({
469
469
  ), p;
470
470
  }
471
471
  function Cs({
472
- state: t,
472
+ state: e,
473
473
  componentId: s,
474
- locale: e,
474
+ locale: t,
475
475
  properties: n
476
476
  }) {
477
- const o = ye({ state: t, componentId: s });
477
+ const o = Se({ state: e, componentId: s });
478
478
  if (!o) return null;
479
479
  const r = Et({
480
480
  componentId: s,
481
- getComponent: (l) => ye({ state: t, componentId: l }),
482
- locale: e,
483
- defaultLocale: t.config.defaultLocale,
481
+ getComponent: (l) => Se({ state: e, componentId: l }),
482
+ locale: t,
483
+ defaultLocale: e.config.defaultLocale,
484
484
  properties: n
485
485
  });
486
- return r ? { component: o, script: r.script, props: { locale: e, ...r.props } } : null;
486
+ return r ? { component: o, script: r.script, props: { locale: t, ...r.props } } : null;
487
487
  }
488
- function ye({ state: t, componentId: s }) {
489
- var e, n, o;
490
- return ((e = t.components[s]) == null ? void 0 : e.data) ?? ((o = (n = t.resources.components) == null ? void 0 : n[s]) == null ? void 0 : o.component);
488
+ function Se({ state: e, componentId: s }) {
489
+ var t, n, o;
490
+ return ((t = e.components[s]) == null ? void 0 : t.data) ?? ((o = (n = e.resources.components) == null ? void 0 : n[s]) == null ? void 0 : o.component);
491
491
  }
492
- function Bn({ state: t, name: s }) {
492
+ function Bn({ state: e, name: s }) {
493
493
  var n, o;
494
- const e = s.toLowerCase();
495
- return ((n = Object.values(t.components).find((r) => {
494
+ const t = s.toLowerCase();
495
+ return ((n = Object.values(e.components).find((r) => {
496
496
  var l;
497
- return ((l = r.data.name) == null ? void 0 : l.toLowerCase()) === e;
498
- })) == null ? void 0 : n.data) ?? ((o = t.resources.components && Object.values(t.resources.components).find((r) => {
497
+ return ((l = r.data.name) == null ? void 0 : l.toLowerCase()) === t;
498
+ })) == null ? void 0 : n.data) ?? ((o = e.resources.components && Object.values(e.resources.components).find((r) => {
499
499
  var l;
500
- return ((l = r.component.name) == null ? void 0 : l.toLowerCase()) === e;
500
+ return ((l = r.component.name) == null ? void 0 : l.toLowerCase()) === t;
501
501
  })) == null ? void 0 : o.component);
502
502
  }
503
503
  async function Ds({
504
- component: t,
504
+ component: e,
505
505
  script: s,
506
- props: e,
506
+ props: t,
507
507
  req: n
508
508
  }) {
509
509
  if (!(s != null && s.includes("getServerSideProps")))
@@ -536,7 +536,7 @@ export async function getServerSidePropsWrapper(props) {
536
536
  if (originalFetch) globalThis.fetch = originalFetch;
537
537
  }
538
538
  }`,
539
- filename: `${t.name || t.id}.js`,
539
+ filename: `${e.name || e.id}.js`,
540
540
  moduleLoader: (c) => {
541
541
  if (c === "@blocklet/pages-kit/builtin/utils")
542
542
  return `const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
@@ -572,7 +572,7 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
572
572
  location: { href: K(Dt(n.hostname), n.originalUrl) },
573
573
  fetch: (c, { ...d } = {}) => {
574
574
  const p = typeof c == "string" && c.startsWith("/") ? K(I.env.appUrl, c) : c;
575
- if (typeof p == "string" && He(p).host === He(I.env.appUrl).host) {
575
+ if (typeof p == "string" && Ve(p).host === Ve(I.env.appUrl).host) {
576
576
  const u = n.get("cookie");
577
577
  if (u) {
578
578
  const y = new vt(d.headers);
@@ -590,17 +590,17 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
590
590
  json: () => u.json()
591
591
  }));
592
592
  },
593
- props: e
593
+ props: t
594
594
  }
595
595
  ]
596
596
  })
597
597
  ]);
598
598
  }
599
- const xs = Ae(
600
- async (t, s, e) => {
601
- if (!(t != null && t.includes(s)))
599
+ const xs = Oe(
600
+ async (e, s, t) => {
601
+ if (!(e != null && e.includes(s)))
602
602
  return null;
603
- const n = await ct(t, s);
603
+ const n = await ct(e, s);
604
604
  if (n)
605
605
  try {
606
606
  return await ot.callFunction({
@@ -611,18 +611,18 @@ const xs = Ae(
611
611
  return ${s};
612
612
  }
613
613
  `,
614
- filename: `${e}.js`,
614
+ filename: `${t}.js`,
615
615
  functionName: `get${s}SchemaWrapper`
616
616
  });
617
617
  } catch (o) {
618
- return b.error(`获取 ${s} 失败`, { componentId: e, error: o }), null;
618
+ return b.error(`获取 ${s} 失败`, { componentId: t, error: o }), null;
619
619
  }
620
620
  return null;
621
621
  },
622
622
  {
623
- keyGenerator: (t, s, e) => {
624
- const n = Oe("md5").update(t).digest("hex");
625
- return JSON.stringify(["getExportSchemaValueFromCode", n, s, e]);
623
+ keyGenerator: (e, s, t) => {
624
+ const n = te("md5").update(e).digest("hex");
625
+ return JSON.stringify(["getExportSchemaValueFromCode", n, s, t]);
626
626
  },
627
627
  lruOptions: {
628
628
  max: 100,
@@ -630,63 +630,63 @@ const xs = Ae(
630
630
  }
631
631
  }
632
632
  ), js = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", Xe = "page", Ne = "trigger-reload-project-resource", lt = js, ks = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
633
- function Se(t) {
634
- t.observeDeep((s) => {
635
- s.some((e) => e.changes.keys.has("updatedAt") || e.changes.keys.has("publishedAt")) || t.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
633
+ function we(e) {
634
+ e.observeDeep((s) => {
635
+ s.some((t) => t.changes.keys.has("updatedAt") || t.changes.keys.has("publishedAt")) || e.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
636
636
  });
637
637
  }
638
638
  function dt() {
639
639
  return $t(O(I.env.dataDir, "tmp-"));
640
640
  }
641
- function we(t, s, e = []) {
642
- return Array.isArray(t) ? t.flatMap((n, o) => we(n, s, [...e, o])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([n, o]) => we(o, s, [...e, n])) : s(t) ? [e] : [];
641
+ function be(e, s, t = []) {
642
+ return Array.isArray(e) ? e.flatMap((n, o) => be(n, s, [...t, o])) : typeof e == "object" ? e === null ? [] : Object.entries(e).flatMap(([n, o]) => be(o, s, [...t, n])) : s(e) ? [t] : [];
643
643
  }
644
- function R(t) {
645
- return t.filter((s) => s != null);
644
+ function R(e) {
645
+ return e.filter((s) => s != null);
646
646
  }
647
- function Ns(t) {
648
- t.pages && Object.keys(t.pages).forEach((e) => {
649
- const n = te(t.pages[e]);
650
- n && n instanceof B.Map && Se(n);
647
+ function Ns(e) {
648
+ e.pages && Object.keys(e.pages).forEach((t) => {
649
+ const n = se(e.pages[t]);
650
+ n && n instanceof B.Map && we(n);
651
651
  });
652
- const s = te(t.pages);
653
- s && s instanceof B.Map && s.observe((e) => {
654
- e.changes.keys.forEach((n, o) => {
652
+ const s = se(e.pages);
653
+ s && s instanceof B.Map && s.observe((t) => {
654
+ t.changes.keys.forEach((n, o) => {
655
655
  if (n.action === "add") {
656
- const r = te(t.pages[o]);
657
- r && r instanceof B.Map && Se(r);
656
+ const r = se(e.pages[o]);
657
+ r && r instanceof B.Map && we(r);
658
658
  }
659
659
  });
660
660
  });
661
661
  }
662
- function Ls(t) {
663
- t.routes && Object.keys(t.routes).forEach((e) => {
662
+ function Ls(e) {
663
+ e.routes && Object.keys(e.routes).forEach((t) => {
664
664
  var o;
665
- const n = te((o = t.routes) == null ? void 0 : o[e]);
666
- n && n instanceof B.Map && Se(n);
665
+ const n = se((o = e.routes) == null ? void 0 : o[t]);
666
+ n && n instanceof B.Map && we(n);
667
667
  });
668
- const s = te(t.routes);
669
- s && s instanceof B.Map && s.observe((e) => {
670
- e.changes.keys.forEach((n, o) => {
668
+ const s = se(e.routes);
669
+ s && s instanceof B.Map && s.observe((t) => {
670
+ t.changes.keys.forEach((n, o) => {
671
671
  var r;
672
672
  if (n.action === "add") {
673
- const l = te((r = t.routes) == null ? void 0 : r[o]);
674
- l && l instanceof B.Map && Se(l);
673
+ const l = se((r = e.routes) == null ? void 0 : r[o]);
674
+ l && l instanceof B.Map && we(l);
675
675
  }
676
676
  });
677
677
  });
678
678
  }
679
- function Rs(t, s) {
680
- var e;
681
- for (const n of s || Object.keys(t.routes || {})) {
679
+ function Rs(e, s) {
680
+ var t;
681
+ for (const n of s || Object.keys(e.routes || {})) {
682
682
  let o = n, r = [];
683
683
  if (n.includes("-")) {
684
684
  const [l, ...c] = n.split("-");
685
685
  o = l, r = c || [];
686
686
  }
687
- if (((e = t.routes) == null ? void 0 : e[o]) !== void 0) {
688
- t.routes[o].publishedAt = (/* @__PURE__ */ new Date()).toISOString();
689
- const l = t.routes[o];
687
+ if (((t = e.routes) == null ? void 0 : t[o]) !== void 0) {
688
+ e.routes[o].publishedAt = (/* @__PURE__ */ new Date()).toISOString();
689
+ const l = e.routes[o];
690
690
  if (!l || !l.params || l.params.length === 0)
691
691
  continue;
692
692
  if (n.includes("-") && r.length > 0) {
@@ -711,9 +711,9 @@ function Rs(t, s) {
711
711
  }
712
712
  }
713
713
  function De({
714
- page: t,
714
+ page: e,
715
715
  route: s,
716
- state: e,
716
+ state: t,
717
717
  routeId: n,
718
718
  routePathInfo: o
719
719
  }) {
@@ -722,7 +722,7 @@ function De({
722
722
  `Executing datasource data assembly, routeId: ${n}, routePathInfo: ${JSON.stringify(o)}`
723
723
  );
724
724
  const r = {
725
- ...Wt(t),
725
+ ...Wt(e),
726
726
  id: n,
727
727
  slug: (o == null ? void 0 : o.path) ?? s.path,
728
728
  createdAt: s.createdAt,
@@ -730,26 +730,26 @@ function De({
730
730
  publishedAt: ((c = o == null ? void 0 : o.routeMetaData) == null ? void 0 : c.publishedAt) ?? s.publishedAt,
731
731
  isPublic: (((d = o == null ? void 0 : o.routeMetaData) == null ? void 0 : d.isPublic) ?? s.isPublic) && s.isPublic
732
732
  };
733
- for (const m of e.supportedLocales) {
733
+ for (const m of t.supportedLocales) {
734
734
  if (s.dataSource) {
735
735
  let w = s.id;
736
736
  o && (w = o.paramOptionIds.join("-"));
737
- const D = ((y = (u = (p = s.dataSource.pathDataMappings) == null ? void 0 : p[w]) == null ? void 0 : u.dataCache) == null ? void 0 : y[m.locale]) ?? ((i = (a = (h = s.dataSource.pathDataMappings) == null ? void 0 : h[w]) == null ? void 0 : a.dataCache) == null ? void 0 : i[e.config.defaultLocale || "en"]);
737
+ const D = ((y = (u = (p = s.dataSource.pathDataMappings) == null ? void 0 : p[w]) == null ? void 0 : u.dataCache) == null ? void 0 : y[m.locale]) ?? ((i = (a = (h = s.dataSource.pathDataMappings) == null ? void 0 : h[w]) == null ? void 0 : a.dataCache) == null ? void 0 : i[t.config.defaultLocale || "en"]);
738
738
  if (!D)
739
739
  continue;
740
- zt(r, e, m.locale, D);
740
+ zt(r, t, m.locale, D);
741
741
  }
742
742
  o && o.routeMetaData && (o.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
743
743
  }
744
744
  return r;
745
745
  }
746
- const { uploadToMediaKit: _s } = require("@blocklet/uploader-server"), xe = ts("abcdefghijklmnopqrstuvwxyz0123456789", 16), Ue = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, ae = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Ze = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Ms = 1e4, Us = 3e4, de = 0, je = 1, $s = 0, Fs = 1, Le = I, ue = O(process.env.BLOCKLET_DATA_DIR, "site-state"), Gn = ["production", "draft"], Jn = ["production"];
747
- function be(t) {
748
- return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
746
+ const { uploadToMediaKit: _s } = require("@blocklet/uploader-server"), xe = ts("abcdefghijklmnopqrstuvwxyz0123456789", 16), Ue = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, ie = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Ze = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Ms = 1e4, Us = 3e4, ue = 0, je = 1, $s = 0, Fs = 1, Le = I, me = O(process.env.BLOCKLET_DATA_DIR, "site-state"), Gn = ["production", "draft"], Hn = ["production"];
747
+ function Ie(e) {
748
+ return (e == null ? void 0 : e.replace(/\//g, "|")) || "";
749
749
  }
750
750
  function Bs() {
751
- var e;
752
- const t = Le.env.languages.map((n) => ({ locale: n.code, name: n.name })), s = (e = t[0]) == null ? void 0 : e.locale;
751
+ var t;
752
+ const e = Le.env.languages.map((n) => ({ locale: n.code, name: n.name })), s = (t = e[0]) == null ? void 0 : t.locale;
753
753
  return {
754
754
  pageIds: [],
755
755
  pages: {},
@@ -758,23 +758,23 @@ function Bs() {
758
758
  dataSourceIds: [],
759
759
  dataSources: {},
760
760
  components: {},
761
- supportedLocales: t,
761
+ supportedLocales: e,
762
762
  config: { defaultLocale: s },
763
763
  resources: {}
764
764
  };
765
765
  }
766
- const H = class H extends B.Doc {
767
- constructor(e) {
766
+ const V = class V extends B.Doc {
767
+ constructor(t) {
768
768
  super();
769
769
  j(this, "states", {});
770
770
  j(this, "syncedStore");
771
771
  j(this, "conns", /* @__PURE__ */ new Map());
772
772
  j(this, "awareness");
773
- j(this, "awarenessChangeHandler", ({ added: e, updated: n, removed: o }, r) => {
774
- const l = e.concat(n, o);
773
+ j(this, "awarenessChangeHandler", ({ added: t, updated: n, removed: o }, r) => {
774
+ const l = t.concat(n, o);
775
775
  if (r !== null) {
776
776
  const p = this.conns.get(r);
777
- p && (e.forEach((u) => {
777
+ p && (t.forEach((u) => {
778
778
  p.add(u);
779
779
  }), o.forEach((u) => {
780
780
  p.delete(u);
@@ -785,15 +785,15 @@ const H = class H extends B.Doc {
785
785
  const d = k.toUint8Array(c);
786
786
  this.conns.forEach((p, u) => this.send(u, d));
787
787
  });
788
- j(this, "updateHandler", (e) => {
788
+ j(this, "updateHandler", (t) => {
789
789
  const n = k.createEncoder();
790
- k.writeVarUint(n, de), ps(n, e);
790
+ k.writeVarUint(n, ue), ps(n, t);
791
791
  const o = k.toUint8Array(n);
792
792
  this.conns.forEach((r, l) => this.send(l, o));
793
793
  });
794
794
  j(this, "ensureDataStructure", () => {
795
795
  var l;
796
- const { supportedLocales: e, pages: n, pageIds: o, config: r } = this.syncedStore;
796
+ const { supportedLocales: t, pages: n, pageIds: o, config: r } = this.syncedStore;
797
797
  {
798
798
  const c = new Set(Object.keys(n));
799
799
  let d = 0;
@@ -802,52 +802,52 @@ const H = class H extends B.Doc {
802
802
  c.has(p) ? (c.delete(p), d++) : o.splice(d, 1);
803
803
  }
804
804
  }
805
- e.splice(0, e.length), e.push(...Le.env.languages.map((c) => ({ locale: c.code, name: c.name }))), r.defaultLocale = (l = e[0]) == null ? void 0 : l.locale;
805
+ t.splice(0, t.length), t.push(...Le.env.languages.map((c) => ({ locale: c.code, name: c.name }))), r.defaultLocale = (l = t[0]) == null ? void 0 : l.locale;
806
806
  {
807
807
  let c = 0;
808
808
  const d = /* @__PURE__ */ new Set();
809
- for (; c < e.length; ) {
810
- const { locale: p } = e[c];
811
- d.has(p) ? e.splice(c, 1) : (c++, d.add(p));
809
+ for (; c < t.length; ) {
810
+ const { locale: p } = t[c];
811
+ d.has(p) ? t.splice(c, 1) : (c++, d.add(p));
812
812
  }
813
813
  }
814
814
  });
815
- j(this, "send", (e, n) => {
816
- e.readyState !== $s && e.readyState !== Fs && this.closeConn(e);
815
+ j(this, "send", (t, n) => {
816
+ t.readyState !== $s && t.readyState !== Fs && this.closeConn(t);
817
817
  try {
818
- e.send(n, (o) => {
819
- o && this.closeConn(e);
818
+ t.send(n, (o) => {
819
+ o && this.closeConn(t);
820
820
  });
821
821
  } catch {
822
- this.closeConn(e);
822
+ this.closeConn(t);
823
823
  }
824
824
  });
825
- j(this, "closeConn", (e) => {
826
- if (e.removeAllListeners(), this.conns.has(e)) {
827
- const n = this.conns.get(e);
828
- this.conns.delete(e), n && is(this.awareness, Array.from(n), null);
825
+ j(this, "closeConn", (t) => {
826
+ if (t.removeAllListeners(), this.conns.has(t)) {
827
+ const n = this.conns.get(t);
828
+ this.conns.delete(t), n && is(this.awareness, Array.from(n), null);
829
829
  }
830
- e.close();
830
+ t.close();
831
831
  });
832
832
  j(this, "autoSave", at(() => {
833
- J(_(this.draftYjsFilePath), { recursive: !0 }), he(this.draftYjsFilePath, B.encodeStateAsUpdate(this));
833
+ H(_(this.draftYjsFilePath), { recursive: !0 }), ye(this.draftYjsFilePath, B.encodeStateAsUpdate(this));
834
834
  }, Ms));
835
- j(this, "save", ({ flush: e = !1 } = {}) => {
836
- this.autoSave(), e && this.autoSave.flush();
835
+ j(this, "save", ({ flush: t = !1 } = {}) => {
836
+ this.autoSave(), t && this.autoSave.flush();
837
837
  });
838
- j(this, "publish", async ({ mode: e, routes: n }) => {
838
+ j(this, "publish", async ({ mode: t, routes: n }) => {
839
839
  const o = await this.getState("draft"), r = await this.getState("production");
840
- await st(o, r, { routes: n, mergeMode: "replace", deleteRoutes: !0, publishMode: e }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Rs(this.syncedStore, n), await this.setState(e, r);
840
+ await st(o, r, { routes: n, mergeMode: "replace", deleteRoutes: !0, publishMode: t }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Rs(this.syncedStore, n), await this.setState(t, r);
841
841
  });
842
- j(this, "mergeState", async (e, n) => {
842
+ j(this, "mergeState", async (t, n) => {
843
843
  var c, d, p;
844
844
  const o = JSON.parse(JSON.stringify(n));
845
- (c = e.config).fontFamily ?? (c.fontFamily = {});
846
- const r = (d = o.config) == null ? void 0 : d.fontFamily, l = (p = e.config) == null ? void 0 : p.fontFamily;
847
- e.config.fontFamily.title = (r == null ? void 0 : r.title) || (l == null ? void 0 : l.title), e.config.fontFamily.description = (r == null ? void 0 : r.description) || (l == null ? void 0 : l.description), await new Promise((u, y) => {
845
+ (c = t.config).fontFamily ?? (c.fontFamily = {});
846
+ const r = (d = o.config) == null ? void 0 : d.fontFamily, l = (p = t.config) == null ? void 0 : p.fontFamily;
847
+ t.config.fontFamily.title = (r == null ? void 0 : r.title) || (l == null ? void 0 : l.title), t.config.fontFamily.description = (r == null ? void 0 : r.description) || (l == null ? void 0 : l.description), await new Promise((u, y) => {
848
848
  this.transact(async () => {
849
849
  try {
850
- const h = await st(e, n);
850
+ const h = await st(t, n);
851
851
  u(h);
852
852
  } catch (h) {
853
853
  y(h);
@@ -855,47 +855,47 @@ const H = class H extends B.Doc {
855
855
  });
856
856
  });
857
857
  });
858
- j(this, "addConnection", (e) => {
859
- if (this.conns.has(e))
858
+ j(this, "addConnection", (t) => {
859
+ if (this.conns.has(t))
860
860
  return;
861
- e.binaryType = "arraybuffer", this.conns.set(e, /* @__PURE__ */ new Set()), e.on("message", (r) => this.messageListener(e, new Uint8Array(r)));
861
+ t.binaryType = "arraybuffer", this.conns.set(t, /* @__PURE__ */ new Set()), t.on("message", (r) => this.messageListener(t, new Uint8Array(r)));
862
862
  let n = !0;
863
863
  const o = setInterval(() => {
864
864
  if (!n)
865
- this.conns.has(e) && this.closeConn(e), clearInterval(o);
866
- else if (this.conns.has(e)) {
865
+ this.conns.has(t) && this.closeConn(t), clearInterval(o);
866
+ else if (this.conns.has(t)) {
867
867
  n = !1;
868
868
  try {
869
- e.ping();
869
+ t.ping();
870
870
  } catch {
871
- this.closeConn(e), clearInterval(o);
871
+ this.closeConn(t), clearInterval(o);
872
872
  }
873
873
  }
874
874
  }, Us);
875
- e.on("close", () => {
876
- this.closeConn(e), clearInterval(o);
877
- }), e.on("pong", () => {
875
+ t.on("close", () => {
876
+ this.closeConn(t), clearInterval(o);
877
+ }), t.on("pong", () => {
878
878
  n = !0;
879
879
  });
880
880
  {
881
881
  const r = k.createEncoder();
882
- k.writeVarUint(r, de), ls(r, this), this.send(e, k.toUint8Array(r));
882
+ k.writeVarUint(r, ue), ls(r, this), this.send(t, k.toUint8Array(r));
883
883
  const l = this.awareness.getStates();
884
884
  if (l.size > 0) {
885
885
  const c = k.createEncoder();
886
- k.writeVarUint(c, je), k.writeVarUint8Array(c, Ye(this.awareness, Array.from(l.keys()))), this.send(e, k.toUint8Array(c));
886
+ k.writeVarUint(c, je), k.writeVarUint8Array(c, Ye(this.awareness, Array.from(l.keys()))), this.send(t, k.toUint8Array(c));
887
887
  }
888
888
  }
889
889
  });
890
- j(this, "messageListener", (e, n) => {
890
+ j(this, "messageListener", (t, n) => {
891
891
  try {
892
892
  const o = k.createEncoder(), r = Ce.createDecoder(n), l = Ce.readVarUint(r);
893
893
  switch (l) {
894
- case de:
895
- k.writeVarUint(o, de), ds(r, o, this, null), k.length(o) > 1 && (this.ensureDataStructure(), this.send(e, k.toUint8Array(o)));
894
+ case ue:
895
+ k.writeVarUint(o, ue), ds(r, o, this, null), k.length(o) > 1 && (this.ensureDataStructure(), this.send(t, k.toUint8Array(o)));
896
896
  break;
897
897
  case je: {
898
- cs(this.awareness, Ce.readVarUint8Array(r), e);
898
+ cs(this.awareness, Ce.readVarUint8Array(r), t);
899
899
  break;
900
900
  }
901
901
  default:
@@ -906,8 +906,8 @@ const H = class H extends B.Doc {
906
906
  }
907
907
  this.save();
908
908
  });
909
- this.options = e, F(this.draftYjsFilePath) && B.applyUpdate(this, X(this.draftYjsFilePath)), this.syncedStore = qt(
910
- Ht(
909
+ this.options = t, F(this.draftYjsFilePath) && B.applyUpdate(this, X(this.draftYjsFilePath)), this.syncedStore = qt(
910
+ Vt(
911
911
  {
912
912
  pages: {},
913
913
  pageIds: [],
@@ -925,11 +925,11 @@ const H = class H extends B.Doc {
925
925
  ), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new as(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
926
926
  }
927
927
  // safe delete project state dir
928
- static safeDeleteProjectStateDir(e) {
929
- if (!e)
928
+ static safeDeleteProjectStateDir(t) {
929
+ if (!t)
930
930
  throw new Error("Should provide project context");
931
931
  try {
932
- const n = O(ue, e), o = O(ue, `@del-${e}`);
932
+ const n = O(me, t), o = O(me, `@del-${t}`);
933
933
  Ke(n, o);
934
934
  } catch (n) {
935
935
  b.error("Failed to safe delete project state dir:", n);
@@ -937,24 +937,24 @@ const H = class H extends B.Doc {
937
937
  }
938
938
  static get projectIds() {
939
939
  return ke("*/", {
940
- cwd: ue,
940
+ cwd: me,
941
941
  ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
942
942
  // Ignore temp directories and hidden files
943
943
  });
944
944
  }
945
945
  static get allShared() {
946
- return this.projectIds.map((e) => H.shared(e));
946
+ return this.projectIds.map((t) => V.shared(t));
947
947
  }
948
- static shared(e) {
949
- if (!e)
948
+ static shared(t) {
949
+ if (!t)
950
950
  throw new Error("Should provide project context");
951
- let n = this.sharedInstances.get(e);
952
- return n || (n = new H({
953
- path: O(ue, e)
954
- }), this.sharedInstances.set(e, n), n);
951
+ let n = this.sharedInstances.get(t);
952
+ return n || (n = new V({
953
+ path: O(me, t)
954
+ }), this.sharedInstances.set(t, n), n);
955
955
  }
956
956
  destroy() {
957
- this.conns.forEach((e, n) => this.closeConn(n)), this.awareness.destroy(), super.destroy();
957
+ this.conns.forEach((t, n) => this.closeConn(n)), this.awareness.destroy(), super.destroy();
958
958
  }
959
959
  initObserver() {
960
960
  Ns(this.syncedStore), Ls(this.syncedStore);
@@ -962,22 +962,22 @@ const H = class H extends B.Doc {
962
962
  get draftYjsFilePath() {
963
963
  return O(this.options.path, "draft.yjs");
964
964
  }
965
- async getState(e) {
965
+ async getState(t) {
966
966
  var n, o, r, l;
967
- if (e === "draft")
967
+ if (t === "draft")
968
968
  return JSON.parse(JSON.stringify(this.syncedStore));
969
- if (!this.states[e] && (this.states[e] = await mt(this.getPublishDir(e), { includeResources: !0 }) ?? Bs(), !((o = (n = this.states[e]) == null ? void 0 : n.config) != null && o.defaultLocale))) {
970
- (r = this.states[e]).config ?? (r.config = {});
969
+ if (!this.states[t] && (this.states[t] = await mt(this.getPublishDir(t), { includeResources: !0 }) ?? Bs(), !((o = (n = this.states[t]) == null ? void 0 : n.config) != null && o.defaultLocale))) {
970
+ (r = this.states[t]).config ?? (r.config = {});
971
971
  const c = Le.env.languages.map((d) => ({ locale: d.code, name: d.name }));
972
- this.states[e].config.defaultLocale = (l = c[0]) == null ? void 0 : l.locale;
972
+ this.states[t].config.defaultLocale = (l = c[0]) == null ? void 0 : l.locale;
973
973
  }
974
974
  return {
975
- ...this.states[e],
975
+ ...this.states[t],
976
976
  resources: await Ge().then(async (c) => {
977
977
  var a, i, m, w;
978
978
  const { pages: d, components: p } = Zt(c, "pages", "components");
979
979
  let u = p;
980
- const y = se(this.options.path), h = await q.findByPk(y);
980
+ const y = ne(this.options.path), h = await q.findByPk(y);
981
981
  if (h != null && h.useAllResources)
982
982
  u = p;
983
983
  else {
@@ -986,27 +986,27 @@ const H = class H extends B.Doc {
986
986
  Object.entries(p || {}).filter(([M]) => A.includes(M))
987
987
  );
988
988
  }
989
- return Object.keys(((i = (a = this.states[e]) == null ? void 0 : a.resources) == null ? void 0 : i.components) || {}).length > 0 && (u = {
989
+ return Object.keys(((i = (a = this.states[t]) == null ? void 0 : a.resources) == null ? void 0 : i.components) || {}).length > 0 && (u = {
990
990
  ...u,
991
- ...(w = (m = this.states[e]) == null ? void 0 : m.resources) == null ? void 0 : w.components
991
+ ...(w = (m = this.states[t]) == null ? void 0 : m.resources) == null ? void 0 : w.components
992
992
  }), { pages: d, components: u };
993
993
  }).catch(() => ({}))
994
994
  };
995
995
  }
996
- async setState(e, n) {
997
- const o = await Hs(n, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
998
- J(_(r), { recursive: !0 }), rt(r, { force: !0, recursive: !0 }), Ke(o, r), this.states[e] = n;
996
+ async setState(t, n) {
997
+ const o = await Vs(n, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(t);
998
+ H(_(r), { recursive: !0 }), rt(r, { force: !0, recursive: !0 }), Ke(o, r), this.states[t] = n;
999
999
  }
1000
- getPublishDir(e) {
1001
- return O(this.options.path, e);
1000
+ getPublishDir(t) {
1001
+ return O(this.options.path, t);
1002
1002
  }
1003
- static async pageUrlMap(e) {
1003
+ static async pageUrlMap(t) {
1004
1004
  var r, l;
1005
1005
  const { projectIds: n } = this, o = {};
1006
1006
  for (const c of n) {
1007
1007
  const d = await q.findByPk(c);
1008
1008
  if (!d) continue;
1009
- const p = await H.shared(c).getState(e), u = d.slug || c, y = es(
1009
+ const p = await V.shared(c).getState(t), u = d.slug || c, y = es(
1010
1010
  I.env.languages.map((a) => a.code),
1011
1011
  p.supportedLocales.map((a) => a.locale)
1012
1012
  ), h = (a, i) => {
@@ -1024,7 +1024,7 @@ const H = class H extends B.Doc {
1024
1024
  o[K("/", m, c, a)] = w, u && (o[K("/", m, u, a)] = w);
1025
1025
  }
1026
1026
  };
1027
- if (e === "draft")
1027
+ if (t === "draft")
1028
1028
  for (const a of p.routeIds || []) {
1029
1029
  const i = (r = p == null ? void 0 : p.routes) == null ? void 0 : r[a];
1030
1030
  if (!i) continue;
@@ -1071,7 +1071,7 @@ const H = class H extends B.Doc {
1071
1071
  }
1072
1072
  for (const a of p.pageIds) {
1073
1073
  const i = p.pages[a];
1074
- if (!i || e === "production" && !i.isPublic)
1074
+ if (!i || t === "production" && !i.isPublic)
1075
1075
  continue;
1076
1076
  const m = i.slug, w = d.slug || c, D = {
1077
1077
  projectId: c,
@@ -1094,50 +1094,50 @@ const H = class H extends B.Doc {
1094
1094
  return B.encodeStateAsUpdate(this).byteLength;
1095
1095
  }
1096
1096
  static getInstancesSizeInfo() {
1097
- const e = [];
1097
+ const t = [];
1098
1098
  for (const [n, o] of this.sharedInstances.entries()) {
1099
1099
  const r = o.getDocumentSize();
1100
- e.push({
1100
+ t.push({
1101
1101
  projectId: n,
1102
1102
  sizeInBytes: r,
1103
1103
  sizeInMB: `${(r / (1024 * 1024)).toFixed(2)} MB`,
1104
1104
  activeConnections: o.conns.size
1105
1105
  });
1106
1106
  }
1107
- return e;
1107
+ return t;
1108
1108
  }
1109
1109
  };
1110
- j(H, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
1111
- j(H, "sharedInstances", new Re({
1110
+ j(V, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
1111
+ j(V, "sharedInstances", new Re({
1112
1112
  max: 100,
1113
1113
  // Maximum number of instances to store
1114
- ttl: H.INSTANCE_TTL,
1115
- dispose: (e) => {
1116
- e.destroy();
1114
+ ttl: V.INSTANCE_TTL,
1115
+ dispose: (t) => {
1116
+ t.destroy();
1117
1117
  }
1118
1118
  }));
1119
- let Ie = H;
1120
- async function Gs(t, s, e) {
1121
- if (!t || !F(t) || !Q(t).isFile())
1119
+ let Ee = V;
1120
+ async function Gs(e, s, t) {
1121
+ if (!e || !F(e) || !Q(e).isFile())
1122
1122
  return null;
1123
- let n = e[t];
1123
+ let n = t[e];
1124
1124
  return n || (n = (async () => {
1125
1125
  var o;
1126
1126
  try {
1127
1127
  const r = (o = await _s({
1128
- filePath: t,
1128
+ filePath: e,
1129
1129
  fileName: s
1130
1130
  })) == null ? void 0 : o.data;
1131
1131
  return r == null ? void 0 : r.filename;
1132
1132
  } catch (r) {
1133
- return b.error(`Failed to upload asset ${t}:`, r), null;
1133
+ return b.error(`Failed to upload asset ${e}:`, r), null;
1134
1134
  }
1135
- })(), e[t] = n), n;
1135
+ })(), t[e] = n), n;
1136
1136
  }
1137
- const Js = async (t, s) => {
1138
- const e = se(t), n = await _t({
1137
+ const Hs = async (e, s) => {
1138
+ const t = ne(e), n = await _t({
1139
1139
  name: lt,
1140
- path: K("/uploads", e),
1140
+ path: K("/uploads", t),
1141
1141
  responseType: "stream",
1142
1142
  method: "GET"
1143
1143
  });
@@ -1146,76 +1146,76 @@ const Js = async (t, s) => {
1146
1146
  await ns(n.data, o);
1147
1147
  } else
1148
1148
  throw new Error(`download asset failed ${n.status}`);
1149
- }, Vs = async (t, s) => {
1149
+ }, Js = async (e, s) => {
1150
1150
  await Promise.all(
1151
- t.map(async (e) => {
1151
+ e.map(async (t) => {
1152
1152
  try {
1153
- await Js(e, O(s, se(e)));
1153
+ await Hs(t, O(s, ne(t)));
1154
1154
  } catch (n) {
1155
- b.error(`Failed to export assets: ${e}, ${n}`);
1155
+ b.error(`Failed to export assets: ${t}, ${n}`);
1156
1156
  }
1157
1157
  })
1158
1158
  );
1159
1159
  };
1160
- function ut(t) {
1161
- return Ue.test(t) ? [t] : ae.test(t) ? (Ze.lastIndex = 0, Array.from(t.matchAll(Ze)).map((e) => e[1]).filter((e) => !!e)) : [];
1160
+ function ut(e) {
1161
+ return Ue.test(e) ? [e] : ie.test(e) ? (Ze.lastIndex = 0, Array.from(e.matchAll(Ze)).map((t) => t[1]).filter((t) => !!t)) : [];
1162
1162
  }
1163
- async function me(t, s, e) {
1164
- const { getFilename: n, exportAssets: o } = e, r = O(s, n(t));
1165
- if (J(_(r), { recursive: !0 }), he(r, Z.stringify(t)), o) {
1166
- const c = we(
1167
- t,
1168
- (d) => typeof d == "string" && (Ue.test(d) || ae.test(d))
1163
+ async function fe(e, s, t) {
1164
+ const { getFilename: n, exportAssets: o } = t, r = O(s, n(e));
1165
+ if (H(_(r), { recursive: !0 }), ye(r, Z.stringify(e)), o) {
1166
+ const c = be(
1167
+ e,
1168
+ (d) => typeof d == "string" && (Ue.test(d) || ie.test(d))
1169
1169
  ).map((d) => {
1170
- const p = Me(t, d);
1170
+ const p = Me(e, d);
1171
1171
  return ut(p);
1172
1172
  }).flat().filter(Boolean);
1173
- await Vs(c, _(r));
1173
+ await Js(c, _(r));
1174
1174
  }
1175
1175
  }
1176
1176
  const et = new Re({
1177
1177
  max: 1e3,
1178
1178
  ttl: 30 * 24 * 60 * 60 * 1e3
1179
1179
  });
1180
- async function tt(t, s, e) {
1180
+ async function tt(e, s, t) {
1181
1181
  var c;
1182
- const n = we(
1183
- t,
1184
- (d) => typeof d == "string" && (Ue.test(d) || ae.test(d))
1182
+ const n = be(
1183
+ e,
1184
+ (d) => typeof d == "string" && (Ue.test(d) || ie.test(d))
1185
1185
  ), o = ss(2), r = n.map(
1186
1186
  (d) => o(async () => {
1187
1187
  try {
1188
- const p = Me(t, d), u = ut(p);
1188
+ const p = Me(e, d), u = ut(p);
1189
1189
  for (const y of u) {
1190
- const h = se(y), a = e.getFilePath(y, d), i = a ? `${a}:${h}` : h, m = et.get(i);
1190
+ const h = ne(y), a = t.getFilePath(y, d), i = a ? `${a}:${h}` : h, m = et.get(i);
1191
1191
  if (m) {
1192
- ae.test(p) || ze(t, d, m);
1192
+ ie.test(p) || ze(e, d, m);
1193
1193
  return;
1194
1194
  }
1195
1195
  const w = await Gs(a, h, s);
1196
- w && (ae.test(p) || ze(t, d, w), et.set(i, w));
1196
+ w && (ie.test(p) || ze(e, d, w), et.set(i, w));
1197
1197
  }
1198
1198
  } catch (p) {
1199
1199
  b.error(`Failed to process upload for path ${d.join(".")}:`, p.message || p.reason);
1200
1200
  }
1201
1201
  })
1202
1202
  ), l = await Promise.allSettled(r);
1203
- (c = e.onFinish) == null || c.call(e, l);
1203
+ (c = t.onFinish) == null || c.call(t, l);
1204
1204
  }
1205
- async function Hs(t, {
1205
+ async function Vs(e, {
1206
1206
  exportAssets: s,
1207
- pageIds: e = "all",
1207
+ pageIds: t = "all",
1208
1208
  componentIds: n = "all",
1209
1209
  rawConfig: o,
1210
1210
  includeResources: r = !1,
1211
1211
  routeIds: l = "all"
1212
1212
  } = {}) {
1213
- var ne, S, f, E, v, z, P, U, Y, pe, oe, le;
1214
- const c = e === "all" ? t.pageIds : e, d = At({
1215
- state: t,
1213
+ var oe, S, f, E, v, z, P, U, Y, le, re, de;
1214
+ const c = t === "all" ? e.pageIds : t, d = At({
1215
+ state: e,
1216
1216
  pageIds: c,
1217
- componentIds: n === "all" ? Object.keys(t.components) : n
1218
- }), p = l === "all" ? t.routeIds : l, u = (g, T) => {
1217
+ componentIds: n === "all" ? Object.keys(e.components) : n
1218
+ }), p = l === "all" ? e.routeIds : l, u = (g, T) => {
1219
1219
  var C;
1220
1220
  return {
1221
1221
  id: g.id,
@@ -1239,8 +1239,8 @@ async function Hs(t, {
1239
1239
  templateConfig: g.templateConfig,
1240
1240
  meta: ((C = g.locales) == null ? void 0 : C[T]) ?? {},
1241
1241
  sections: R(
1242
- g.sectionIds.map((V) => {
1243
- const G = g.sections[V];
1242
+ g.sectionIds.map((J) => {
1243
+ const G = g.sections[J];
1244
1244
  return G && u(G, T);
1245
1245
  })
1246
1246
  )
@@ -1259,13 +1259,13 @@ async function Hs(t, {
1259
1259
  dataSource: g.dataSource
1260
1260
  }), a = R(
1261
1261
  p.map((g) => {
1262
- const T = t.routes[g];
1262
+ const T = e.routes[g];
1263
1263
  return T && h(T);
1264
1264
  })
1265
1265
  ), i = R(
1266
- t.supportedLocales.map((g) => g.locale).flatMap(
1266
+ e.supportedLocales.map((g) => g.locale).flatMap(
1267
1267
  (g) => c.map((T) => {
1268
- const C = t.pages[T];
1268
+ const C = e.pages[T];
1269
1269
  return C && {
1270
1270
  locale: g,
1271
1271
  slug: C.slug,
@@ -1274,48 +1274,48 @@ async function Hs(t, {
1274
1274
  })
1275
1275
  )
1276
1276
  ), m = dt(), w = O(m, "pages");
1277
- J(w, { recursive: !0 });
1277
+ H(w, { recursive: !0 });
1278
1278
  const D = O(m, "components");
1279
- J(D, { recursive: !0 });
1279
+ H(D, { recursive: !0 });
1280
1280
  const A = O(m, "routes");
1281
- J(A, { recursive: !0 });
1281
+ H(A, { recursive: !0 });
1282
1282
  for (const { locale: g, slug: T, page: C } of i)
1283
- await me(C, w, {
1284
- getFilename: () => `${be(T) || "index"}.${g}.yml`,
1283
+ await fe(C, w, {
1284
+ getFilename: () => `${Ie(T) || "index"}.${g}.yml`,
1285
1285
  exportAssets: s
1286
1286
  });
1287
1287
  for (const g of a)
1288
- await me(g, A, {
1288
+ await fe(g, A, {
1289
1289
  // getFilename: () => `${sanitizeSlug(route.path)}.yml`,
1290
- getFilename: () => `${be(g.path) || "index"}.yml`,
1290
+ getFilename: () => `${Ie(g.path) || "index"}.yml`,
1291
1291
  exportAssets: s
1292
1292
  });
1293
1293
  for (const g of d) {
1294
- const T = (ne = t.components[g]) == null ? void 0 : ne.data;
1295
- T && await me(T, D, {
1294
+ const T = (oe = e.components[g]) == null ? void 0 : oe.data;
1295
+ T && await fe(T, D, {
1296
1296
  getFilename: (C) => `${C.name || "unnamed"}.${C.id}.yml`,
1297
1297
  exportAssets: s
1298
1298
  });
1299
1299
  }
1300
1300
  const N = O(m, ".blocklet/pages/pages.config.yml");
1301
- J(_(N), { recursive: !0 });
1301
+ H(_(N), { recursive: !0 });
1302
1302
  const M = {
1303
1303
  pages: R(
1304
1304
  c.map((g) => {
1305
- const T = t.pages[g];
1305
+ const T = e.pages[g];
1306
1306
  return T && { id: g, slug: T.slug };
1307
1307
  })
1308
1308
  ),
1309
1309
  routes: R(
1310
1310
  p.map((g) => {
1311
- const T = t.routes[g];
1311
+ const T = e.routes[g];
1312
1312
  return T && { id: g, path: T.path };
1313
1313
  })
1314
1314
  ),
1315
1315
  components: R(
1316
1316
  d.map((g) => {
1317
1317
  var C;
1318
- const T = (C = t.components[g]) == null ? void 0 : C.data;
1318
+ const T = (C = e.components[g]) == null ? void 0 : C.data;
1319
1319
  return T && {
1320
1320
  id: g,
1321
1321
  name: T.name
@@ -1325,47 +1325,47 @@ async function Hs(t, {
1325
1325
  ...r ? {
1326
1326
  resources: {
1327
1327
  components: R(
1328
- Object.keys(((S = t.resources) == null ? void 0 : S.components) || {}).filter((g) => d.includes(g)).map((g) => {
1329
- var T, C, V, G;
1328
+ Object.keys(((S = e.resources) == null ? void 0 : S.components) || {}).filter((g) => d.includes(g)).map((g) => {
1329
+ var T, C, J, G;
1330
1330
  return {
1331
1331
  id: g,
1332
- name: (G = (V = (C = (T = t.resources) == null ? void 0 : T.components) == null ? void 0 : C[g]) == null ? void 0 : V.component) == null ? void 0 : G.name
1332
+ name: (G = (J = (C = (T = e.resources) == null ? void 0 : T.components) == null ? void 0 : C[g]) == null ? void 0 : J.component) == null ? void 0 : G.name
1333
1333
  };
1334
1334
  })
1335
1335
  )
1336
1336
  }
1337
1337
  } : {},
1338
- supportedLocales: t.supportedLocales,
1339
- config: t.config
1338
+ supportedLocales: e.supportedLocales,
1339
+ config: e.config
1340
1340
  };
1341
- he(N, Z.stringify(M));
1342
- const ce = O(m, "config.source.json");
1343
- if (o && he(ce, JSON.stringify(o)), r) {
1341
+ ye(N, Z.stringify(M));
1342
+ const pe = O(m, "config.source.json");
1343
+ if (o && ye(pe, JSON.stringify(o)), r) {
1344
1344
  const g = O(m, "resources"), T = O(g, "components");
1345
- J(T, { recursive: !0 });
1346
- for (const G of Object.keys(((f = t == null ? void 0 : t.resources) == null ? void 0 : f.components) ?? {}).filter(
1345
+ H(T, { recursive: !0 });
1346
+ for (const G of Object.keys(((f = e == null ? void 0 : e.resources) == null ? void 0 : f.components) ?? {}).filter(
1347
1347
  ($) => d.includes($)
1348
1348
  )) {
1349
- const $ = (z = (v = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : v[G]) == null ? void 0 : z.component;
1350
- $ && await me($, T, {
1349
+ const $ = (z = (v = (E = e.resources) == null ? void 0 : E.components) == null ? void 0 : v[G]) == null ? void 0 : z.component;
1350
+ $ && await fe($, T, {
1351
1351
  getFilename: (W) => `${W.name || "unnamed"}.${W.id}.yml`,
1352
1352
  exportAssets: s
1353
1353
  });
1354
1354
  }
1355
1355
  const C = O(m, "chunks");
1356
- J(C, { recursive: !0 });
1357
- const { chunks: V } = await Ge();
1358
- for (const G of Object.keys(((P = t == null ? void 0 : t.resources) == null ? void 0 : P.components) ?? {}).filter(
1356
+ H(C, { recursive: !0 });
1357
+ const { chunks: J } = await Ge();
1358
+ for (const G of Object.keys(((P = e == null ? void 0 : e.resources) == null ? void 0 : P.components) ?? {}).filter(
1359
1359
  ($) => d.includes($)
1360
1360
  )) {
1361
- const $ = (pe = (Y = (U = t.resources) == null ? void 0 : U.components) == null ? void 0 : Y[G]) == null ? void 0 : pe.component;
1362
- if ($ && ((oe = $.renderer) == null ? void 0 : oe.type) === "react-component") {
1363
- const W = ((le = $.renderer) == null ? void 0 : le.chunks) ?? [];
1361
+ const $ = (le = (Y = (U = e.resources) == null ? void 0 : U.components) == null ? void 0 : Y[G]) == null ? void 0 : le.component;
1362
+ if ($ && ((re = $.renderer) == null ? void 0 : re.type) === "react-component") {
1363
+ const W = ((de = $.renderer) == null ? void 0 : de.chunks) ?? [];
1364
1364
  if ((W == null ? void 0 : W.length) > 0)
1365
1365
  for (const ve of W) {
1366
- const Je = O(C, ve), Pe = V == null ? void 0 : V[ve];
1366
+ const He = O(C, ve), Pe = J == null ? void 0 : J[ve];
1367
1367
  try {
1368
- Pe && F(Pe) && !F(Je) && Bt(Pe, Je);
1368
+ Pe && F(Pe) && !F(He) && Bt(Pe, He);
1369
1369
  } catch (yt) {
1370
1370
  b.error(`copy chunk ${ve} error`, yt.message);
1371
1371
  }
@@ -1375,13 +1375,13 @@ async function Hs(t, {
1375
1375
  }
1376
1376
  return m;
1377
1377
  }
1378
- async function mt(t, { importAssets: s, includeResources: e } = {}) {
1378
+ async function mt(e, { importAssets: s, includeResources: t } = {}) {
1379
1379
  var r, l, c, d;
1380
- if (!F(t))
1380
+ if (!F(e))
1381
1381
  return null;
1382
1382
  let n, o = !1;
1383
1383
  try {
1384
- Q(t).isDirectory() ? n = t : /\.(tgz|gz|tar)$/.test(t) && (o = !0, n = dt(), await os({ file: t, C: n }));
1384
+ Q(e).isDirectory() ? n = e : /\.(tgz|gz|tar)$/.test(e) && (o = !0, n = dt(), await os({ file: e, C: n }));
1385
1385
  const p = ke("**/.blocklet/pages/pages.config.yml", { cwd: n, absolute: !0 }).at(0), u = p && O(_(p), "../../pages"), y = p && O(_(p), "../../components"), h = p && O(_(p), "../../chunks"), a = p && O(_(p), "../../routes");
1386
1386
  if (!p)
1387
1387
  return null;
@@ -1404,7 +1404,7 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1404
1404
  var z;
1405
1405
  const f = R(
1406
1406
  i.supportedLocales.map(({ locale: P }) => {
1407
- const U = u ? m(u, be(S), P) : void 0;
1407
+ const U = u ? m(u, Ie(S), P) : void 0;
1408
1408
  if (U)
1409
1409
  return { locale: P, page: U };
1410
1410
  const Y = u ? m(u, S, P) : void 0;
@@ -1426,9 +1426,9 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1426
1426
  visibility: P.visibility,
1427
1427
  locales: Object.fromEntries(
1428
1428
  R(
1429
- f.map(({ locale: Y, page: pe }) => {
1430
- const oe = pe.sections.find((le) => le.id === U);
1431
- return oe && [Y, oe.properties];
1429
+ f.map(({ locale: Y, page: le }) => {
1430
+ const re = le.sections.find((de) => de.id === U);
1431
+ return re && [Y, re.properties];
1432
1432
  })
1433
1433
  )
1434
1434
  )
@@ -1449,7 +1449,7 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1449
1449
  })
1450
1450
  ), N = R(
1451
1451
  ((r = i == null ? void 0 : i.routes) == null ? void 0 : r.map(({ path: S }) => {
1452
- const f = a ? D(a, be(S)) : void 0;
1452
+ const f = a ? D(a, Ie(S)) : void 0;
1453
1453
  return {
1454
1454
  ...f,
1455
1455
  id: (f == null ? void 0 : f.id) || xe(),
@@ -1468,7 +1468,7 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1468
1468
  ), M = y ? R(((l = i.components) == null ? void 0 : l.map(({ id: S }) => w(y, S))) ?? []) : [];
1469
1469
  if (s) {
1470
1470
  const S = (...f) => {
1471
- b.info(`[${o ? se(t) : se(O(t, "../../../../"))}] importAssets:`, ...f);
1471
+ b.info(`[${o ? ne(e) : ne(O(e, "../../../../"))}] importAssets:`, ...f);
1472
1472
  };
1473
1473
  try {
1474
1474
  S("wait image-bin api ready"), await rs({
@@ -1497,20 +1497,20 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1497
1497
  S("Error during asset import:", f);
1498
1498
  }
1499
1499
  }
1500
- const ce = {};
1501
- if (e) {
1500
+ const pe = {};
1501
+ if (t) {
1502
1502
  const S = p && O(_(p), "../../resources/components"), f = R(
1503
1503
  ((d = (c = i.resources) == null ? void 0 : c.components) == null ? void 0 : d.map(({ id: E }) => w(S, E))) ?? []
1504
1504
  );
1505
- f.length > 0 && (ce.components = Object.fromEntries(
1505
+ f.length > 0 && (pe.components = Object.fromEntries(
1506
1506
  f.map((E, v) => [E.id, { index: v, component: E }])
1507
1507
  ));
1508
1508
  }
1509
- const ne = {};
1509
+ const oe = {};
1510
1510
  if (h && F(h)) {
1511
1511
  const S = Ft(h);
1512
1512
  for (const f of S)
1513
- ne[f] = O(h, f);
1513
+ oe[f] = O(h, f);
1514
1514
  }
1515
1515
  return {
1516
1516
  supportedLocales: i.supportedLocales,
@@ -1518,8 +1518,8 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1518
1518
  components: Object.fromEntries(M.map((S, f) => [S.id, { index: f, data: S }])),
1519
1519
  pages: Object.fromEntries(A.map((S) => [S.id, S])),
1520
1520
  config: i.config || {},
1521
- resources: ce,
1522
- chunks: ne,
1521
+ resources: pe,
1522
+ chunks: oe,
1523
1523
  routeIds: N.map((S) => S.id),
1524
1524
  routes: Object.fromEntries(N.map((S) => [S.id, S])),
1525
1525
  dataSourceIds: [],
@@ -1529,8 +1529,8 @@ async function mt(t, { importAssets: s, includeResources: e } = {}) {
1529
1529
  o && n && rt(n, { force: !0, recursive: !0 });
1530
1530
  }
1531
1531
  }
1532
- async function st(t, s, {
1533
- routes: e,
1532
+ async function st(e, s, {
1533
+ routes: t,
1534
1534
  mergeMode: n = "byUpdateTime",
1535
1535
  deleteRoutes: o = !1,
1536
1536
  publishMode: r = void 0
@@ -1540,9 +1540,9 @@ async function st(t, s, {
1540
1540
  } catch (h) {
1541
1541
  b.error("clear preload page cache error", { error: h });
1542
1542
  }
1543
- const { pages: l, pageIds: c, routeIds: d, routes: p, supportedLocales: u } = t;
1543
+ const { pages: l, pageIds: c, routeIds: d, routes: p, supportedLocales: u } = e;
1544
1544
  if (r === "production") {
1545
- let h = e ?? [], a = null;
1545
+ let h = t ?? [], a = null;
1546
1546
  for (const i of d ?? []) {
1547
1547
  const m = p == null ? void 0 : p[i];
1548
1548
  if (m != null && m.params && (m == null ? void 0 : m.params.length) > 0 && (m != null && m.paramsOptions) && (m == null ? void 0 : m.paramsOptions.length) > 0) {
@@ -1556,8 +1556,8 @@ async function st(t, s, {
1556
1556
  currentOptionIds: [],
1557
1557
  result: []
1558
1558
  }), D = Object.fromEntries(w.map((A) => [`${i}-${A.paramOptionIds.join("-")}`, A]));
1559
- a = { ...a || {}, ...D }, e || (h = [...h, ...w.map((A) => `${i}-${A.paramOptionIds.join("-")}`)]);
1560
- } else e || h.push(i);
1559
+ a = { ...a || {}, ...D }, t || (h = [...h, ...w.map((A) => `${i}-${A.paramOptionIds.join("-")}`)]);
1560
+ } else t || h.push(i);
1561
1561
  }
1562
1562
  b.info("routeIds to be published: ", h);
1563
1563
  for (const i of h) {
@@ -1594,7 +1594,7 @@ async function st(t, s, {
1594
1594
  s.pages[i] = De({
1595
1595
  page: D,
1596
1596
  route: w,
1597
- state: t,
1597
+ state: e,
1598
1598
  routeId: i,
1599
1599
  routePathInfo: a == null ? void 0 : a[i]
1600
1600
  }), b.info("replace page", i);
@@ -1603,7 +1603,7 @@ async function st(t, s, {
1603
1603
  (!A || w.updatedAt && w.updatedAt > A.updatedAt) && (s.pages[i] = De({
1604
1604
  page: D,
1605
1605
  route: w,
1606
- state: t,
1606
+ state: e,
1607
1607
  routeId: i,
1608
1608
  routePathInfo: a == null ? void 0 : a[i]
1609
1609
  }), b.info("replace page by update time", i));
@@ -1612,12 +1612,12 @@ async function st(t, s, {
1612
1612
  s.pageIds.push(i), s.pages[i] = De({
1613
1613
  page: D,
1614
1614
  route: w,
1615
- state: t,
1615
+ state: e,
1616
1616
  routeId: i,
1617
1617
  routePathInfo: a == null ? void 0 : a[i]
1618
1618
  }), b.info("add page", i);
1619
1619
  }
1620
- if (o && !e)
1620
+ if (o && !t)
1621
1621
  for (const i of s.pageIds)
1622
1622
  h != null && h.includes(i) || (delete s.pages[i], b.info("delete page", i)), s.pageIds = [...s.pageIds].filter((m) => h == null ? void 0 : h.includes(m));
1623
1623
  } else {
@@ -1651,7 +1651,7 @@ async function st(t, s, {
1651
1651
  if (s.supportedLocales.splice(0, s.supportedLocales.length), s.supportedLocales.push(...Qt(u)), o)
1652
1652
  for (const h of Object.keys(s.components))
1653
1653
  delete s.components[h];
1654
- let y = JSON.parse(JSON.stringify(t.components));
1654
+ let y = JSON.parse(JSON.stringify(e.components));
1655
1655
  y = Object.fromEntries(
1656
1656
  await Promise.all(
1657
1657
  Object.entries(y).map(async ([h, a]) => {
@@ -1665,35 +1665,45 @@ async function st(t, s, {
1665
1665
  ];
1666
1666
  })
1667
1667
  )
1668
- ), Object.assign(s.components, y), Object.assign(s.config, JSON.parse(JSON.stringify(t.config))), s.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
1668
+ ), Object.assign(s.components, y), Object.assign(s.config, JSON.parse(JSON.stringify(e.config))), s.resources.components = JSON.parse(JSON.stringify(e.resources.components || {}));
1669
1669
  }
1670
- const ft = Ae(
1671
- async (t) => {
1670
+ const ft = Oe(
1671
+ async (e) => {
1672
1672
  var s;
1673
- if (!Xt(t == null ? void 0 : t.properties))
1674
- return t;
1675
- if (((s = t == null ? void 0 : t.renderer) == null ? void 0 : s.type) === "react-component") {
1676
- const { script: e } = (t == null ? void 0 : t.renderer) || {};
1677
- if (e && e.includes("PROPERTIES_SCHEMA"))
1673
+ if (!Xt(e == null ? void 0 : e.properties))
1674
+ return e;
1675
+ if (((s = e == null ? void 0 : e.renderer) == null ? void 0 : s.type) === "react-component") {
1676
+ const { script: t } = (e == null ? void 0 : e.renderer) || {};
1677
+ if (t && t.includes("PROPERTIES_SCHEMA"))
1678
1678
  try {
1679
- const n = await xs(e, "PROPERTIES_SCHEMA", t.id);
1680
- n && n.length > 0 && t && (t.properties = {}, n.forEach((o, r) => {
1681
- t != null && t.properties && (t.properties[o.id] = {
1679
+ const n = await xs(t, "PROPERTIES_SCHEMA", e.id);
1680
+ n && n.length > 0 && e && (e.properties = {}, n.forEach((o, r) => {
1681
+ e != null && e.properties && (e.properties[o.id] = {
1682
1682
  index: r,
1683
1683
  data: o
1684
1684
  });
1685
1685
  }));
1686
1686
  } catch (n) {
1687
- b.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: n });
1687
+ b.error("checkPropertiesFromCode error", { componentId: e.id, name: e.name }, { error: n });
1688
1688
  }
1689
1689
  }
1690
- return t;
1690
+ return e;
1691
1691
  },
1692
1692
  {
1693
- keyGenerator: (t) => {
1694
- var l;
1695
- const s = (t == null ? void 0 : t.id) || "", e = (t == null ? void 0 : t.name) || "", n = ((l = t == null ? void 0 : t.renderer) == null ? void 0 : l.type) || "", o = (t == null ? void 0 : t.properties) || {}, r = Oe("md5").update(JSON.stringify(o)).digest("hex");
1696
- return JSON.stringify(["checkPropertiesFromCode", s, e, n, r]);
1693
+ keyGenerator: (e) => {
1694
+ var p, u, y, h;
1695
+ const s = (e == null ? void 0 : e.id) || "", t = (e == null ? void 0 : e.name) || "", n = ((p = e == null ? void 0 : e.renderer) == null ? void 0 : p.type) || "", o = (e == null ? void 0 : e.properties) || {}, r = (e == null ? void 0 : e.updatedAt) || "", l = te("md5").update(JSON.stringify(o)).digest("hex");
1696
+ let c = "", d = "";
1697
+ return ((u = e == null ? void 0 : e.renderer) == null ? void 0 : u.type) === "react-component" && (c = te("md5").update(((y = e == null ? void 0 : e.renderer) == null ? void 0 : y.script) || "").digest("hex"), d = te("md5").update(((h = e == null ? void 0 : e.renderer) == null ? void 0 : h.editComponent) || "").digest("hex")), JSON.stringify([
1698
+ "checkPropertiesFromCode",
1699
+ s,
1700
+ t,
1701
+ n,
1702
+ l,
1703
+ r,
1704
+ c,
1705
+ d
1706
+ ]);
1697
1707
  },
1698
1708
  lruOptions: {
1699
1709
  max: 100,
@@ -1701,23 +1711,23 @@ const ft = Ae(
1701
1711
  }
1702
1712
  }
1703
1713
  );
1704
- let Ee, ee, $e, Fe, Be;
1714
+ let Ae, ee, $e, Fe, Be;
1705
1715
  function gt() {
1706
- return Ee = (async () => {
1707
- const t = Lt({
1716
+ return Ae = (async () => {
1717
+ const e = Lt({
1708
1718
  types: [
1709
1719
  { did: lt, type: Xe },
1710
1720
  { did: ks, type: Xe }
1711
1721
  ]
1712
1722
  });
1713
1723
  ee = (await Promise.all(
1714
- t.map(async (e) => {
1715
- const n = e.path ? await mt(e.path, { importAssets: !1 }) : void 0;
1716
- return n ? { blockletId: e.did, state: n, blockletTitle: e.title } : void 0;
1724
+ e.map(async (t) => {
1725
+ const n = t.path ? await mt(t.path, { importAssets: !1 }) : void 0;
1726
+ return n ? { blockletId: t.did, state: n, blockletTitle: t.title } : void 0;
1717
1727
  })
1718
- )).filter((e) => !!e), $e = ee.reduce(
1719
- (e, n) => Object.assign(
1720
- e,
1728
+ )).filter((t) => !!t), $e = ee.reduce(
1729
+ (t, n) => Object.assign(
1730
+ t,
1721
1731
  Object.fromEntries(
1722
1732
  Object.values(n.state.pages).map((o) => o ? [o == null ? void 0 : o.id, { page: o, blockletId: n.blockletId }] : [])
1723
1733
  )
@@ -1725,8 +1735,8 @@ function gt() {
1725
1735
  {}
1726
1736
  );
1727
1737
  const s = ee.reduce(
1728
- (e, n) => Object.assign(
1729
- e,
1738
+ (t, n) => Object.assign(
1739
+ t,
1730
1740
  Object.fromEntries(
1731
1741
  Object.values(n.state.components).map((o) => [o.data.id, { blockletId: n.blockletId, component: o.data }])
1732
1742
  )
@@ -1735,10 +1745,10 @@ function gt() {
1735
1745
  );
1736
1746
  Fe = Object.fromEntries(
1737
1747
  await Promise.all(
1738
- Object.entries(s).map(async ([e, n]) => {
1748
+ Object.entries(s).map(async ([t, n]) => {
1739
1749
  const o = await ft(n.component);
1740
1750
  return [
1741
- e,
1751
+ t,
1742
1752
  {
1743
1753
  ...n,
1744
1754
  component: o
@@ -1746,15 +1756,15 @@ function gt() {
1746
1756
  ];
1747
1757
  })
1748
1758
  )
1749
- ), Be = ee.reduce((e, n) => Object.assign(e, n.state.chunks), {});
1750
- })(), Ee;
1759
+ ), Be = ee.reduce((t, n) => Object.assign(t, n.state.chunks), {});
1760
+ })(), Ae;
1751
1761
  }
1752
- function Ks(t) {
1762
+ function Ks(e) {
1753
1763
  const s = at(
1754
1764
  async () => {
1755
- await gt().catch((e) => {
1756
- b.error("load resource states error", { error: e });
1757
- }), await (t == null ? void 0 : t({
1765
+ await gt().catch((t) => {
1766
+ b.error("load resource states error", { error: t });
1767
+ }), await (e == null ? void 0 : e({
1758
1768
  states: ee,
1759
1769
  pages: $e,
1760
1770
  components: Fe,
@@ -1769,21 +1779,21 @@ function Ks(t) {
1769
1779
  I.events.off(I.Events.componentAdded, s), I.events.off(I.Events.componentRemoved, s), I.events.off(I.Events.componentStarted, s), I.events.off(I.Events.componentStopped, s), I.events.off(I.Events.componentUpdated, s), I.events.off(Ne, s);
1770
1780
  };
1771
1781
  }
1772
- const ht = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ge = globalThis;
1782
+ const ht = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), he = globalThis;
1773
1783
  var nt;
1774
- (nt = ge[ht]) == null || nt.call(ge);
1775
- ge[ht] = Ks(async ({ pages: t, components: s }) => {
1776
- const { projectIds: e } = Ie;
1777
- b.info(`start update resource states projects(${e.length})`, e), await Promise.race([
1784
+ (nt = he[ht]) == null || nt.call(he);
1785
+ he[ht] = Ks(async ({ pages: e, components: s }) => {
1786
+ const { projectIds: t } = Ee;
1787
+ b.info(`start update resource states projects(${t.length})`, t), await Promise.race([
1778
1788
  new Promise((n) => {
1779
1789
  setTimeout(() => {
1780
1790
  n({});
1781
1791
  }, 30 * 1e3);
1782
1792
  }),
1783
1793
  Promise.all(
1784
- e.map(async (n) => {
1785
- const o = Ie.shared(n);
1786
- o.syncedStore.resources.pages = t;
1794
+ t.map(async (n) => {
1795
+ const o = Ee.shared(n);
1796
+ o.syncedStore.resources.pages = e;
1787
1797
  const r = await q.findByPk(n);
1788
1798
  if (r != null && r.useAllResources)
1789
1799
  o.syncedStore.resources.components = s;
@@ -1803,20 +1813,20 @@ ge[ht] = Ks(async ({ pages: t, components: s }) => {
1803
1813
  b.error("update resource states failed:", n);
1804
1814
  });
1805
1815
  });
1806
- async function Vn() {
1816
+ async function Jn() {
1807
1817
  b.info("trigger reload all project resource"), I.events.emit(Ne);
1808
1818
  }
1809
1819
  async function Ge({
1810
- ensureLoaded: t = !0
1820
+ ensureLoaded: e = !0
1811
1821
  } = {}) {
1812
- return t && (Ee ?? (Ee = gt()), await Ee), { states: ee, pages: $e, components: Fe, chunks: Be };
1822
+ return e && (Ae ?? (Ae = gt()), await Ae), { states: ee, pages: $e, components: Fe, chunks: Be };
1813
1823
  }
1814
1824
  export {
1815
1825
  lt as C,
1816
1826
  Qe as G,
1817
1827
  q as P,
1818
1828
  Xe as R,
1819
- Ie as S,
1829
+ Ee as S,
1820
1830
  $n as a,
1821
1831
  Ge as b,
1822
1832
  Es as c,
@@ -1826,19 +1836,19 @@ export {
1826
1836
  Fn as g,
1827
1837
  vs as h,
1828
1838
  Un as i,
1829
- ye as j,
1839
+ Se as j,
1830
1840
  Bn as k,
1831
1841
  b as l,
1832
1842
  xs as m,
1833
1843
  xe as n,
1834
- ue as o,
1844
+ me as o,
1835
1845
  Gn as p,
1836
- Jn as q,
1837
- Js as r,
1838
- Vs as s,
1839
- Hs as t,
1846
+ Hn as q,
1847
+ Hs as r,
1848
+ Js as s,
1849
+ Vs as t,
1840
1850
  mt as u,
1841
1851
  st as v,
1842
1852
  Ks as w,
1843
- Vn as x
1853
+ Jn as x
1844
1854
  };