@blocklet/pages-kit-inner-components 0.5.30 → 0.5.32

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 (37) hide show
  1. package/lib/cjs/add-component.js +47 -23
  2. package/lib/cjs/chunks/array-DxhrK2d5.js +475 -0
  3. package/lib/cjs/chunks/{config-string-C4Q0hgG0.js → config-string-DqWgB7yO.js} +1 -1
  4. package/lib/cjs/chunks/{draft-data-Cu9gua-P.js → draft-data-DzN2u_NT.js} +1 -1
  5. package/lib/cjs/chunks/home-0fezWT4S.js +38 -0
  6. package/lib/cjs/chunks/{publish-button-DvwoFH1F.js → publish-button-D2jaaXXn.js} +1 -1
  7. package/lib/cjs/chunks/site-state-D5jk8eJT.js +57 -0
  8. package/lib/cjs/chunks/state-DoGBMTzI.js +1 -0
  9. package/lib/cjs/components.js +1 -1
  10. package/lib/cjs/home.js +1 -1
  11. package/lib/cjs/locales.js +3 -1
  12. package/lib/cjs/project-html.js +2 -2
  13. package/lib/cjs/resources.js +1 -1
  14. package/lib/cjs/setting.js +1 -1
  15. package/lib/cjs/site-state.js +1 -1
  16. package/lib/es/add-component.js +795 -749
  17. package/lib/es/chunks/array-D6qyZucY.js +2224 -0
  18. package/lib/es/chunks/{config-string-CNLg1EYu.js → config-string-Btybe5Rd.js} +1 -1
  19. package/lib/es/chunks/{draft-data-hSHLdxKp.js → draft-data-DQ7_JyJX.js} +1 -1
  20. package/lib/es/chunks/{home-CNk6U8FU.js → home-Dox9JwvF.js} +112 -96
  21. package/lib/es/chunks/{publish-button-BftBlabj.js → publish-button-T2YJBoty.js} +3 -3
  22. package/lib/es/chunks/{site-state-DJ3JcBMm.js → site-state-DEduMTrY.js} +505 -473
  23. package/lib/es/chunks/state-NhsHvaKm.js +605 -0
  24. package/lib/es/components.js +1 -1
  25. package/lib/es/home.js +3 -3
  26. package/lib/es/locales.js +46 -6
  27. package/lib/es/project-html.js +43 -42
  28. package/lib/es/resources.js +1 -1
  29. package/lib/es/setting.js +2 -2
  30. package/lib/es/site-state.js +1 -1
  31. package/package.json +10 -10
  32. package/lib/cjs/chunks/array-CJC7ex3i.js +0 -467
  33. package/lib/cjs/chunks/home-CimGvyT9.js +0 -38
  34. package/lib/cjs/chunks/site-state-DvIWP0pO.js +0 -57
  35. package/lib/cjs/chunks/state-jCG5gSUJ.js +0 -1
  36. package/lib/es/chunks/array-9j8tOSbO.js +0 -1993
  37. package/lib/es/chunks/state-D5BnGunt.js +0 -483
@@ -1,40 +1,40 @@
1
- var Ot = Object.defineProperty;
2
- var Ct = (e, n, t) => n in e ? Ot(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var x = (e, n, t) => Ct(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { getComponentMountPoint as Tt } from "@blocklet/pages-kit/builtin/utils";
1
+ var Ct = Object.defineProperty;
2
+ var Tt = (e, n, t) => n in e ? Ct(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var k = (e, n, t) => Tt(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { getComponentMountPoint as Pt } from "@blocklet/pages-kit/builtin/utils";
5
5
  import { PreloadComponentScriptModule as ye } from "@blocklet/pages-kit/types";
6
- import { componentUMDName as Pt, RenderNestedComponent as ze, mergeComponent as vt, getComponentDependencies as Dt } from "@blocklet/pages-kit/utils/property";
7
- import { memoize as at, Sandbox as it, BuiltinModules as kt } from "@blocklet/quickjs";
6
+ import { componentUMDName as vt, RenderNestedComponent as ze, mergeComponent as Dt, getComponentDependencies as kt } from "@blocklet/pages-kit/utils/property";
7
+ import { memoize as at, Sandbox as it, BuiltinModules as jt } from "@blocklet/quickjs";
8
8
  import I from "@blocklet/sdk/lib/config";
9
- import { LRUCache as Me } from "lru-cache";
10
- import xt, { Headers as jt } from "node-fetch";
11
- import { joinURL as K, getQuery as Rt, withQuery as Nt, parseURL as Ke, withHttps as Lt } from "ufo";
12
- import { createHash as Z } from "crypto";
13
- import _t from "@blocklet/logger";
14
- import { promises as B, readFileSync as ne, mkdtempSync as $t, existsSync as F, lstatSync as se, readdirSync as Mt, rmSync as ct, renameSync as Ye, mkdirSync as J, writeFileSync as we, copyFileSync as Ut, createWriteStream as Ft } from "fs";
15
- import lt, { join as A, dirname as $, basename as G } from "path";
16
- import Bt from "lodash/isNil";
17
- import { BuiltinModules as Gt } from "@blocklet/pages-kit/utils/builtin";
18
- import { isRelativeModule as Ht, createBuiltinModuleTransformer as Vt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
19
- import { getResources as Jt, getComponentWebEndpoint as zt, call as Kt } from "@blocklet/sdk/lib/component";
20
- import Yt from "autoprefixer";
21
- import * as Wt from "esbuild";
22
- import qt from "postcss";
23
- import Qt from "tailwindcss";
24
- import L from "typescript";
25
- import { getYjsValue as ae, syncedStore as Xt } from "@syncedstore/core";
26
- import * as H from "yjs";
27
- import { setPageDataSource as Zt } from "@blocklet/pages-kit/utils/data-source";
28
- import { getRouteMetaDataByOptionIds as es, generateParamCombinations as Ue } from "@blocklet/pages-kit/utils/route";
29
- import { cloneDeep as ts } from "lodash";
30
- import { reactive as ss } from "@reactivedata/reactive";
9
+ import { LRUCache as $e } from "lru-cache";
10
+ import xt, { Headers as Rt } from "node-fetch";
11
+ import { joinURL as W, getQuery as Nt, withQuery as Lt, parseURL as Ke, withHttps as _t } from "ufo";
12
+ import { createHash as te } from "crypto";
13
+ import Mt from "@blocklet/logger";
14
+ import { promises as V, readFileSync as re, mkdtempSync as $t, existsSync as H, lstatSync as oe, readdirSync as Ut, rmSync as ct, renameSync as Ye, mkdirSync as Y, writeFileSync as we, copyFileSync as Ft, createWriteStream as Bt } from "fs";
15
+ import lt, { join as O, dirname as U, basename as J } from "path";
16
+ import Gt from "lodash/isNil";
17
+ import { BuiltinModules as Ht } from "@blocklet/pages-kit/utils/builtin";
18
+ import { isRelativeModule as Vt, createBuiltinModuleTransformer as Jt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
19
+ import { getResources as zt, getComponentWebEndpoint as Kt, call as Yt } from "@blocklet/sdk/lib/component";
20
+ import Wt from "autoprefixer";
21
+ import * as qt from "esbuild";
22
+ import Qt from "postcss";
23
+ import Xt from "tailwindcss";
24
+ import M from "typescript";
25
+ import { getYjsValue as ce, syncedStore as Zt } from "@syncedstore/core";
26
+ import * as z from "yjs";
27
+ import { setPageDataSource as es } from "@blocklet/pages-kit/utils/data-source";
28
+ import { getRouteMetaDataByOptionIds as ts, generateParamCombinations as Ue } from "@blocklet/pages-kit/utils/route";
29
+ import { cloneDeep as ss } from "lodash";
30
+ import { reactive as ns } from "@reactivedata/reactive";
31
31
  import { globSync as Ne } from "glob";
32
32
  import * as ke from "lib0/decoding";
33
33
  import * as R from "lib0/encoding";
34
- import ns from "lodash/cloneDeep";
34
+ import os from "lodash/cloneDeep";
35
35
  import pt from "lodash/debounce";
36
36
  import Fe from "lodash/get";
37
- import os from "lodash/isEmpty";
37
+ import dt from "lodash/isEmpty";
38
38
  import rs from "lodash/pick";
39
39
  import We from "lodash/set";
40
40
  import as from "lodash/union";
@@ -45,8 +45,8 @@ import { x as ps } from "tar";
45
45
  import ds from "wait-on";
46
46
  import { Awareness as us, encodeAwarenessUpdate as qe, removeAwarenessStates as fs, applyAwarenessUpdate as ms } from "y-protocols/awareness";
47
47
  import { writeUpdate as hs, writeSyncStep1 as gs, readSyncMessage as ys } from "y-protocols/sync";
48
- import * as oe from "yaml";
49
- import { DataTypes as j, Sequelize as Ss, Model as dt, Op as ws } from "sequelize";
48
+ import * as ae from "yaml";
49
+ import { DataTypes as x, Sequelize as Ss, Model as ut, Op as ws } from "sequelize";
50
50
  import "sqlite3";
51
51
  import "@blocklet/pages-kit/types/state";
52
52
  I.env.mode;
@@ -58,10 +58,10 @@ const Es = "image-bin";
58
58
  I.env.INIT_TEMPLATE_PATH;
59
59
  const Is = process.env.DATABASE_URL || lt.join(I.env.dataDir, "db/pages-kit.db"), Qe = I, Qn = () => I.env.tenantMode === "multiple", Xn = () => {
60
60
  var e;
61
- return (Bt(Qe.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (e = Qe.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : e.split(",")) || [];
62
- }, bs = lt.join(I.env.dataDir, "fs-memoize-cache"), As = I.env.FS_MEMOIZE_CACHE_VERSION || "v1.0.0", S = _t("pages-kit"), Os = j.sqlite.DATE.parse;
63
- j.sqlite.DATE.parse = (e, n) => typeof e == "number" ? new Date(e) : Os(e, n);
64
- const ue = new Ss({
61
+ return (Gt(Qe.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (e = Qe.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : e.split(",")) || [];
62
+ }, bs = lt.join(I.env.dataDir, "fs-memoize-cache"), As = I.env.FS_MEMOIZE_CACHE_VERSION || "v1.0.0", S = Mt("pages-kit"), Os = x.sqlite.DATE.parse;
63
+ x.sqlite.DATE.parse = (e, n) => typeof e == "number" ? new Date(e) : Os(e, n);
64
+ const me = new Ss({
65
65
  dialect: "sqlite",
66
66
  storage: Is,
67
67
  benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
@@ -74,69 +74,69 @@ const ue = new Ss({
74
74
  logging: process.env.ENABLE_SEQUELIZE_LOGGING === "true" ? console.log : !1
75
75
  // logQueryParameters: true,
76
76
  });
77
- ue.query("pragma journal_mode = WAL;");
78
- ue.query("pragma synchronous = normal;");
79
- ue.query("pragma journal_size_limit = 67108864;");
80
- class Ce extends dt {
77
+ me.query("pragma journal_mode = WAL;");
78
+ me.query("pragma synchronous = normal;");
79
+ me.query("pragma journal_size_limit = 67108864;");
80
+ class Ce extends ut {
81
81
  // Foreign key to Component
82
82
  }
83
83
  Ce.init(
84
84
  {
85
85
  id: {
86
- type: j.UUID,
86
+ type: x.UUID,
87
87
  allowNull: !1,
88
88
  primaryKey: !0,
89
- defaultValue: j.UUIDV4
89
+ defaultValue: x.UUIDV4
90
90
  },
91
91
  projectId: {
92
- type: j.UUID,
92
+ type: x.UUID,
93
93
  allowNull: !1
94
94
  },
95
95
  componentId: {
96
- type: j.STRING,
96
+ type: x.STRING,
97
97
  allowNull: !1
98
98
  }
99
99
  },
100
- { sequelize: ue, tableName: "ProjectComponents", timestamps: !1 }
100
+ { sequelize: me, tableName: "ProjectComponents", timestamps: !1 }
101
101
  );
102
- class ee extends dt {
102
+ class se extends ut {
103
103
  static async getProjectByIdOrSlug(n) {
104
- return ee.findOne({
104
+ return se.findOne({
105
105
  where: {
106
106
  [ws.or]: [{ id: n }, { slug: n }]
107
107
  }
108
108
  });
109
109
  }
110
110
  }
111
- ee.init(
111
+ se.init(
112
112
  {
113
113
  id: {
114
- type: j.UUID,
115
- defaultValue: j.UUIDV4,
114
+ type: x.UUID,
115
+ defaultValue: x.UUIDV4,
116
116
  primaryKey: !0
117
117
  },
118
118
  name: {
119
- type: j.STRING,
119
+ type: x.STRING,
120
120
  allowNull: !1
121
121
  },
122
- description: j.TEXT,
123
- createdAt: j.DATE,
124
- updatedAt: j.DATE,
122
+ description: x.TEXT,
123
+ createdAt: x.DATE,
124
+ updatedAt: x.DATE,
125
125
  createdBy: {
126
- type: j.STRING,
126
+ type: x.STRING,
127
127
  allowNull: !1
128
128
  },
129
129
  updatedBy: {
130
- type: j.STRING,
130
+ type: x.STRING,
131
131
  allowNull: !1
132
132
  },
133
- slug: j.STRING,
134
- icon: j.STRING,
135
- pinnedAt: j.DATE,
136
- useAllResources: j.BOOLEAN,
137
- npmSecret: j.STRING,
133
+ slug: x.STRING,
134
+ icon: x.STRING,
135
+ pinnedAt: x.DATE,
136
+ useAllResources: x.BOOLEAN,
137
+ npmSecret: x.STRING,
138
138
  relatedBlocklets: {
139
- type: j.JSON,
139
+ type: x.JSON,
140
140
  allowNull: !1,
141
141
  defaultValue: {},
142
142
  get() {
@@ -147,38 +147,38 @@ ee.init(
147
147
  }
148
148
  }
149
149
  },
150
- { sequelize: ue, paranoid: !0 }
150
+ { sequelize: me, paranoid: !0 }
151
151
  );
152
- ee.hasMany(Ce, {
152
+ se.hasMany(Ce, {
153
153
  foreignKey: "projectId",
154
154
  as: "components"
155
155
  });
156
- const Cs = bs, Ts = As, Le = 7 * 24 * 60 * 60 * 1e3, Ps = 24 * 60 * 60 * 1e3, ut = async (e = "") => {
157
- const n = A(Cs, e);
156
+ const Cs = bs, Ts = As, Le = 7 * 24 * 60 * 60 * 1e3, Ps = 24 * 60 * 60 * 1e3, ft = async (e = "") => {
157
+ const n = O(Cs, e);
158
158
  try {
159
- if (!(await B.stat(n)).isDirectory())
159
+ if (!(await V.stat(n)).isDirectory())
160
160
  throw new Error(`${n} is not a directory`);
161
161
  } catch {
162
- await B.mkdir(n, { recursive: !0 });
162
+ await V.mkdir(n, { recursive: !0 });
163
163
  }
164
164
  return n;
165
165
  }, vs = (e, n) => {
166
- const t = Z("md5").update(n).digest("hex");
167
- return A(e, `${Ts}-${t}.json`);
166
+ const t = te("md5").update(n).digest("hex");
167
+ return O(e, `${Ts}-${t}.json`);
168
168
  }, Ds = async (e = "") => {
169
- const n = await ut(e), t = Date.now();
169
+ const n = await ft(e), t = Date.now();
170
170
  try {
171
- const s = await B.readdir(n);
171
+ const s = await V.readdir(n);
172
172
  await Promise.all(
173
173
  s.filter((o) => o.endsWith(".json")).map(async (o) => {
174
- const r = A(n, o);
174
+ const r = O(n, o);
175
175
  try {
176
- const a = await B.readFile(r, "utf-8"), i = JSON.parse(a);
177
- i.createdAt && t - i.createdAt > Le && await B.unlink(r);
176
+ const a = await V.readFile(r, "utf-8"), i = JSON.parse(a);
177
+ i.createdAt && t - i.createdAt > Le && await V.unlink(r);
178
178
  } catch {
179
179
  try {
180
- const i = await B.stat(r);
181
- t - i.mtimeMs > Le && await B.unlink(r);
180
+ const i = await V.stat(r);
181
+ t - i.mtimeMs > Le && await V.unlink(r);
182
182
  } catch {
183
183
  }
184
184
  }
@@ -198,16 +198,16 @@ const Cs = bs, Ts = As, Le = 7 * 24 * 60 * 60 * 1e3, Ps = 24 * 60 * 60 * 1e3, ut
198
198
  function Be(e, n) {
199
199
  return n.subdir && ks(n.subdir), at(
200
200
  async (...s) => {
201
- const o = await ut(n.subdir || ""), r = n.keyGenerator ? n.keyGenerator(...s) : JSON.stringify(s), a = vs(o, r);
201
+ const o = await ft(n.subdir || ""), r = n.keyGenerator ? n.keyGenerator(...s) : JSON.stringify(s), a = vs(o, r);
202
202
  try {
203
- const i = await B.readFile(a, "utf-8"), { value: p, createdAt: c } = JSON.parse(i);
203
+ const i = await V.readFile(a, "utf-8"), { value: p, createdAt: c } = JSON.parse(i);
204
204
  if (c && Date.now() - c > Le)
205
- throw await B.unlink(a).catch(() => {
205
+ throw await V.unlink(a).catch(() => {
206
206
  }), new Error("Cache expired");
207
207
  return p;
208
208
  } catch {
209
209
  const p = await e(...s), c = JSON.stringify({ value: p, createdAt: Date.now() });
210
- return B.writeFile(a, c, "utf-8").catch((u) => {
210
+ return V.writeFile(a, c, "utf-8").catch((u) => {
211
211
  console.error("Failed to write fs cache:", u);
212
212
  }), p;
213
213
  }
@@ -218,13 +218,13 @@ function Be(e, n) {
218
218
  }
219
219
  );
220
220
  }
221
- const xs = async (e, { componentId: n }) => {
221
+ const js = async (e, { componentId: n }) => {
222
222
  const t = `@tailwind components;
223
223
  @tailwind utilities;
224
224
  `, s = `.CustomComponent_${n}`;
225
- return (await qt([
226
- Qt({ content: [{ raw: e, extension: "tsx" }] }),
227
- Yt({
225
+ return (await Qt([
226
+ Xt({ content: [{ raw: e, extension: "tsx" }] }),
227
+ Wt({
228
228
  overrideBrowserslist: ["> 1%", "last 2 versions"],
229
229
  stats: {}
230
230
  }),
@@ -236,38 +236,38 @@ const xs = async (e, { componentId: n }) => {
236
236
  // FIXME: cssnano use browserslist, it is not working with the fs isolation
237
237
  // cssnano({ preset: 'default' }),
238
238
  ]).process(t)).css;
239
- }, js = async (e, { componentId: n }) => {
240
- const t = await xs(e, { componentId: n });
239
+ }, xs = async (e, { componentId: n }) => {
240
+ const t = await js(e, { componentId: n });
241
241
  return `export const __PagesKit_CSS__ = ${JSON.stringify(t)};
242
242
 
243
243
  ${e}
244
244
  `;
245
245
  }, Xe = Be(
246
246
  async (e, n) => {
247
- let t = L.transpileModule(e, {
247
+ let t = M.transpileModule(e, {
248
248
  compilerOptions: {
249
- jsx: L.JsxEmit.React,
250
- target: L.ScriptTarget.ES2016,
251
- module: L.ModuleKind.ESNext
249
+ jsx: M.JsxEmit.React,
250
+ target: M.ScriptTarget.ES2016,
251
+ module: M.ModuleKind.ESNext
252
252
  },
253
253
  transformers: {
254
- before: [Vt(L)]
254
+ before: [Jt(M)]
255
255
  }
256
256
  }).outputText;
257
- if (n.tailwind && (t = await js(t, { componentId: n.componentId })), n.module === ye.ESM) return t;
258
- const s = L.transpileModule(t, {
257
+ if (n.tailwind && (t = await xs(t, { componentId: n.componentId })), n.module === ye.ESM) return t;
258
+ const s = M.transpileModule(t, {
259
259
  compilerOptions: {
260
- jsx: L.JsxEmit.React,
261
- target: L.ScriptTarget.ES2016,
262
- module: L.ModuleKind.CommonJS,
263
- moduleResolution: L.ModuleResolutionKind.Node16
260
+ jsx: M.JsxEmit.React,
261
+ target: M.ScriptTarget.ES2016,
262
+ module: M.ModuleKind.CommonJS,
263
+ moduleResolution: M.ModuleResolutionKind.Node16
264
264
  }
265
265
  }).outputText;
266
266
  return n.module === ye.CJS ? s : Ns(n.moduleName, s);
267
267
  },
268
268
  {
269
269
  keyGenerator: (e, n) => {
270
- const t = Z("md5").update(e).digest("hex"), s = {
270
+ const t = te("md5").update(e).digest("hex"), s = {
271
271
  ...n,
272
272
  componentId: n.componentId,
273
273
  module: n.module,
@@ -286,9 +286,9 @@ ${e}
286
286
  }
287
287
  ), Rs = async (e, n) => {
288
288
  var a, i;
289
- const s = (i = (a = (await Wt.build({
289
+ const s = (i = (a = (await qt.build({
290
290
  entryPoints: ["index.tsx"],
291
- external: Object.keys(Gt),
291
+ external: Object.keys(Ht),
292
292
  format: "esm",
293
293
  target: "esnext",
294
294
  bundle: !0,
@@ -304,11 +304,11 @@ ${e}
304
304
  return { contents: `export { ${n} } from './component'`, loader: "tsx" };
305
305
  if (u.path === "component.tsx")
306
306
  return { contents: e, loader: "tsx" };
307
- if (Ht(u.path)) {
307
+ if (Vt(u.path)) {
308
308
  const m = u.path.split("/").pop();
309
309
  if (c || (c = await Ve({ ensureLoaded: !1 })), (y = c == null ? void 0 : c.chunks) != null && y[m])
310
310
  try {
311
- const d = ne(c.chunks[m], "utf-8");
311
+ const d = re(c.chunks[m], "utf-8");
312
312
  return S.info("get chunk from local file system", m), { contents: d, loader: "tsx" };
313
313
  } catch {
314
314
  }
@@ -321,17 +321,17 @@ ${e}
321
321
  })).outputFiles) == null ? void 0 : a[0]) == null ? void 0 : i.contents;
322
322
  if (!s) throw new Error("Failed to build server code");
323
323
  const o = Buffer.from(s).toString();
324
- return L.transpileModule(o, {
325
- compilerOptions: { module: L.ModuleKind.ESNext, target: L.ScriptTarget.ES2020 }
324
+ return M.transpileModule(o, {
325
+ compilerOptions: { module: M.ModuleKind.ESNext, target: M.ScriptTarget.ES2020 }
326
326
  }).outputText;
327
- }, ft = Be(
327
+ }, mt = Be(
328
328
  async (e, n) => {
329
329
  const t = await Rs(e, n);
330
330
  return new RegExp(`export\\s+\\{\\s+${n}\\s+\\}`, "m").test(t) ? t : void 0;
331
331
  },
332
332
  {
333
333
  keyGenerator: (e, n) => {
334
- const t = Z("md5").update(e).digest("hex");
334
+ const t = te("md5").update(e).digest("hex");
335
335
  return JSON.stringify(["extractExportValueSchema", t, n]);
336
336
  },
337
337
  lruOptions: {
@@ -367,17 +367,17 @@ var ${e} = async function () {
367
367
 
368
368
  return exports;
369
369
  };
370
- `, pe = new Me({
370
+ `, ue = new $e({
371
371
  max: 100
372
372
  }), Ls = 60 * 60, Ze = 60;
373
373
  function _s(e) {
374
- S.info("clear preload components cache", { cacheKey: e }), pe.delete(e);
374
+ S.info("clear preload components cache", { cacheKey: e }), ue.delete(e);
375
375
  }
376
- function $s(e) {
377
- for (const n of pe.keys())
376
+ function Ms(e) {
377
+ for (const n of ue.keys())
378
378
  n.includes(e) && (S.info("clear preload components cache", { cacheKey: n }), _s(n));
379
379
  }
380
- function Ms({
380
+ function $s({
381
381
  mode: e,
382
382
  instanceId: n,
383
383
  componentId: t,
@@ -401,14 +401,14 @@ async function Zn({
401
401
  const p = (await Promise.all(
402
402
  o.map(async (d) => {
403
403
  try {
404
- const l = Ms({
404
+ const l = $s({
405
405
  mode: e,
406
406
  instanceId: d.id,
407
407
  componentId: d.componentId,
408
408
  locale: s
409
409
  });
410
- if (e !== "draft" && d.useCache && pe.has(l))
411
- return S.info(`get preload component from cache: ${l}`), pe.get(l);
410
+ if (e !== "draft" && d.useCache && ue.has(l))
411
+ return S.info(`get preload component from cache: ${l}`), ue.get(l);
412
412
  const f = Ee({ state: t, componentId: d.componentId });
413
413
  if (!f) return null;
414
414
  const w = await Us({
@@ -422,9 +422,9 @@ async function Zn({
422
422
  if (!w) return null;
423
423
  const D = { instanceId: d.id, preload: w };
424
424
  if (e !== "draft" && d.useCache) {
425
- let O = Ls;
426
- d.cacheDuration && (O = d.cacheDuration), S.info(`set preload component to cache(${O}s): ${l}`), pe.set(l, D, {
427
- ttl: O * 1e3
425
+ let C = Ls;
426
+ d.cacheDuration && (C = d.cacheDuration), S.info(`set preload component to cache(${C}s): ${l}`), ue.set(l, D, {
427
+ ttl: C * 1e3
428
428
  });
429
429
  }
430
430
  return D;
@@ -438,7 +438,7 @@ async function Zn({
438
438
  async function u() {
439
439
  const d = await Promise.all(
440
440
  c.map(async (l) => {
441
- const f = Pt({ componentId: l.component.id }), w = r === ye.ESM ? {
441
+ const f = vt({ componentId: l.component.id }), w = r === ye.ESM ? {
442
442
  module: r,
443
443
  script: await Xe(l.script, {
444
444
  componentId: l.component.id,
@@ -483,14 +483,14 @@ async function Us({
483
483
  if (!i) return null;
484
484
  const p = a.some((u) => u.locale === s) ? s : o;
485
485
  if (!p) return null;
486
- const c = await mt({ req: e, state: n, componentId: t, locale: p, defaultLocale: o, properties: r });
486
+ const c = await ht({ req: e, state: n, componentId: t, locale: p, defaultLocale: o, properties: r });
487
487
  return c ? {
488
488
  component: i,
489
489
  ...c
490
490
  } : null;
491
491
  }
492
492
  const Fs = 20;
493
- async function mt({
493
+ async function ht({
494
494
  req: e,
495
495
  depth: n = 0,
496
496
  state: t,
@@ -516,7 +516,7 @@ async function mt({
516
516
  return await Promise.all(
517
517
  Object.entries(p).map(async ([u, y]) => {
518
518
  if ((y == null ? void 0 : y.type) === ze) {
519
- const m = await mt({
519
+ const m = await ht({
520
520
  req: e,
521
521
  depth: n + 1,
522
522
  state: t,
@@ -544,7 +544,7 @@ function Bs({
544
544
  }) {
545
545
  const o = Ee({ state: e, componentId: n });
546
546
  if (!o) return null;
547
- const r = vt({
547
+ const r = Dt({
548
548
  componentId: n,
549
549
  getComponent: (a) => Ee({ state: e, componentId: a }),
550
550
  locale: t,
@@ -576,7 +576,7 @@ async function Gs({
576
576
  }) {
577
577
  if (!(n != null && n.includes("getServerSideProps")))
578
578
  return null;
579
- const o = await ft(n, "getServerSideProps");
579
+ const o = await mt(n, "getServerSideProps");
580
580
  if (!o) return null;
581
581
  const r = new Promise((i) => {
582
582
  setTimeout(() => {
@@ -611,7 +611,7 @@ export async function getServerSidePropsWrapper(props) {
611
611
  export { joinURL, withQuery, getQuery, getComponentMountPoint }
612
612
  `;
613
613
  if (i === "@blocklet/pages-kit/builtin/dayjs")
614
- return kt.dayjs;
614
+ return jt.dayjs;
615
615
  },
616
616
  global: {
617
617
  console: {
@@ -627,23 +627,23 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
627
627
  S.error(...i);
628
628
  }
629
629
  },
630
- getComponentMountPoint: Tt,
631
- joinURL: K,
632
- withQuery: Nt,
633
- getQuery: Rt
630
+ getComponentMountPoint: Pt,
631
+ joinURL: W,
632
+ withQuery: Lt,
633
+ getQuery: Nt
634
634
  },
635
635
  functionName: "getServerSidePropsWrapper",
636
636
  args: [
637
637
  {
638
638
  // NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
639
639
  // because the global is shared between all runtime and just init once
640
- location: { href: K(Lt(s.hostname), s.originalUrl) },
640
+ location: { href: W(_t(s.hostname), s.originalUrl) },
641
641
  fetch: (i, { ...p } = {}) => {
642
- const c = typeof i == "string" && i.startsWith("/") ? K(I.env.appUrl, i) : i;
642
+ const c = typeof i == "string" && i.startsWith("/") ? W(I.env.appUrl, i) : i;
643
643
  if (typeof c == "string" && Ke(c).host === Ke(I.env.appUrl).host) {
644
644
  const u = s.get("cookie");
645
645
  if (u) {
646
- const y = new jt(p.headers);
646
+ const y = new Rt(p.headers);
647
647
  y.set("cookie", u), p.headers = y;
648
648
  }
649
649
  }
@@ -668,7 +668,7 @@ const Hs = at(
668
668
  async (e, n, t) => {
669
669
  if (!(e != null && e.includes(n)))
670
670
  return null;
671
- const s = await ft(e, n);
671
+ const s = await mt(e, n);
672
672
  if (s)
673
673
  try {
674
674
  return await it.callFunction({
@@ -689,7 +689,7 @@ const Hs = at(
689
689
  },
690
690
  {
691
691
  keyGenerator: (e, n, t) => {
692
- const s = Z("md5").update(e).digest("hex");
692
+ const s = te("md5").update(e).digest("hex");
693
693
  return JSON.stringify(["getExportSchemaValueFromCode", s, n, t]);
694
694
  },
695
695
  lruOptions: {
@@ -697,32 +697,32 @@ const Hs = at(
697
697
  ttl: 1e3 * 60 * 60
698
698
  }
699
699
  }
700
- ), Vs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", et = "page", _e = "trigger-reload-project-resource", ht = Vs, Js = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
700
+ ), Vs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", et = "page", _e = "trigger-reload-project-resource", gt = Vs, Js = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
701
701
  function Ie(e) {
702
702
  e.observeDeep((n) => {
703
703
  n.some((t) => t.changes.keys.has("updatedAt") || t.changes.keys.has("publishedAt")) || e.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
704
704
  });
705
705
  }
706
- function gt() {
707
- return $t(A(I.env.dataDir, "tmp-"));
706
+ function yt() {
707
+ return $t(O(I.env.dataDir, "tmp-"));
708
708
  }
709
709
  function be(e, n, t = []) {
710
710
  return Array.isArray(e) ? e.flatMap((s, o) => be(s, n, [...t, o])) : typeof e == "object" ? e === null ? [] : Object.entries(e).flatMap(([s, o]) => be(o, n, [...t, s])) : n(e) ? [t] : [];
711
711
  }
712
- function _(e) {
712
+ function $(e) {
713
713
  return e.filter((n) => n != null);
714
714
  }
715
715
  function zs(e) {
716
716
  e.pages && Object.keys(e.pages).forEach((t) => {
717
- const s = ae(e.pages[t]);
718
- s && s instanceof H.Map && Ie(s);
717
+ const s = ce(e.pages[t]);
718
+ s && s instanceof z.Map && Ie(s);
719
719
  });
720
- const n = ae(e.pages);
721
- n && n instanceof H.Map && n.observe((t) => {
720
+ const n = ce(e.pages);
721
+ n && n instanceof z.Map && n.observe((t) => {
722
722
  t.changes.keys.forEach((s, o) => {
723
723
  if (s.action === "add") {
724
- const r = ae(e.pages[o]);
725
- r && r instanceof H.Map && Ie(r);
724
+ const r = ce(e.pages[o]);
725
+ r && r instanceof z.Map && Ie(r);
726
726
  }
727
727
  });
728
728
  });
@@ -730,16 +730,16 @@ function zs(e) {
730
730
  function Ks(e) {
731
731
  e.routes && Object.keys(e.routes).forEach((t) => {
732
732
  var o;
733
- const s = ae((o = e.routes) == null ? void 0 : o[t]);
734
- s && s instanceof H.Map && Ie(s);
733
+ const s = ce((o = e.routes) == null ? void 0 : o[t]);
734
+ s && s instanceof z.Map && Ie(s);
735
735
  });
736
- const n = ae(e.routes);
737
- n && n instanceof H.Map && n.observe((t) => {
736
+ const n = ce(e.routes);
737
+ n && n instanceof z.Map && n.observe((t) => {
738
738
  t.changes.keys.forEach((s, o) => {
739
739
  var r;
740
740
  if (s.action === "add") {
741
- const a = ae((r = e.routes) == null ? void 0 : r[o]);
742
- a && a instanceof H.Map && Ie(a);
741
+ const a = ce((r = e.routes) == null ? void 0 : r[o]);
742
+ a && a instanceof z.Map && Ie(a);
743
743
  }
744
744
  });
745
745
  });
@@ -758,7 +758,7 @@ function Ys(e, n) {
758
758
  if (!a || !a.params || a.params.length === 0)
759
759
  continue;
760
760
  if (s.includes("-") && r.length > 0) {
761
- const i = es(r, a);
761
+ const i = ts(r, a);
762
762
  i && (i.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
763
763
  }
764
764
  if (!n) {
@@ -778,7 +778,7 @@ function Ys(e, n) {
778
778
  }
779
779
  }
780
780
  }
781
- function xe({
781
+ function je({
782
782
  page: e,
783
783
  route: n,
784
784
  state: t,
@@ -790,7 +790,7 @@ function xe({
790
790
  `Executing datasource data assembly, routeId: ${s}, routePathInfo: ${JSON.stringify(o)}`
791
791
  );
792
792
  const r = {
793
- ...ts(e),
793
+ ...ss(e),
794
794
  id: s,
795
795
  slug: (o == null ? void 0 : o.path) ?? n.path,
796
796
  createdAt: n.createdAt,
@@ -805,19 +805,19 @@ function xe({
805
805
  const D = ((y = (u = (c = n.dataSource.pathDataMappings) == null ? void 0 : c[w]) == null ? void 0 : u.dataCache) == null ? void 0 : y[f.locale]) ?? ((l = (d = (m = n.dataSource.pathDataMappings) == null ? void 0 : m[w]) == null ? void 0 : d.dataCache) == null ? void 0 : l[t.config.defaultLocale || "en"]);
806
806
  if (!D)
807
807
  continue;
808
- Zt(r, t, f.locale, D);
808
+ es(r, t, f.locale, D);
809
809
  }
810
810
  o && o.routeMetaData && (o.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
811
811
  }
812
812
  return r;
813
813
  }
814
- const { uploadToMediaKit: Ws } = require("@blocklet/uploader-server"), je = is("abcdefghijklmnopqrstuvwxyz0123456789", 16), Ge = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, de = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, tt = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, qs = 1e4, Qs = 3e4, he = 0, Re = 1, Xs = 0, Zs = 1, $e = I, le = A(process.env.BLOCKLET_DATA_DIR, "site-state"), to = ["production", "draft"], so = ["production"];
814
+ const { uploadToMediaKit: Ws } = require("@blocklet/uploader-server"), xe = is("abcdefghijklmnopqrstuvwxyz0123456789", 16), Ge = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, fe = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, tt = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, qs = 1e4, Qs = 3e4, he = 0, Re = 1, Xs = 0, Zs = 1, Me = I, de = O(process.env.BLOCKLET_DATA_DIR, "site-state"), to = ["production", "draft"], so = ["production"];
815
815
  function Ae(e) {
816
816
  return (e == null ? void 0 : e.replace(/\//g, "|")) || "";
817
817
  }
818
818
  function en() {
819
819
  var t;
820
- const e = $e.env.languages.map((s) => ({ locale: s.code, name: s.name })), n = (t = e[0]) == null ? void 0 : t.locale;
820
+ const e = Me.env.languages.map((s) => ({ locale: s.code, name: s.name })), n = (t = e[0]) == null ? void 0 : t.locale;
821
821
  return {
822
822
  pageIds: [],
823
823
  pages: {},
@@ -831,15 +831,15 @@ function en() {
831
831
  resources: {}
832
832
  };
833
833
  }
834
- const T = class T extends H.Doc {
834
+ const P = class P extends z.Doc {
835
835
  constructor(t) {
836
836
  super();
837
- x(this, "syncedStore");
838
- x(this, "conns", /* @__PURE__ */ new Map());
839
- x(this, "awareness");
837
+ k(this, "syncedStore");
838
+ k(this, "conns", /* @__PURE__ */ new Map());
839
+ k(this, "awareness");
840
840
  // 延迟释放定时器
841
- x(this, "releaseTimer");
842
- x(this, "awarenessChangeHandler", ({ added: t, updated: s, removed: o }, r) => {
841
+ k(this, "releaseTimer");
842
+ k(this, "awarenessChangeHandler", ({ added: t, updated: s, removed: o }, r) => {
843
843
  const a = t.concat(s, o);
844
844
  if (r !== null) {
845
845
  const c = this.conns.get(r);
@@ -854,13 +854,13 @@ const T = class T extends H.Doc {
854
854
  const p = R.toUint8Array(i);
855
855
  this.conns.forEach((c, u) => this.send(u, p));
856
856
  });
857
- x(this, "updateHandler", (t) => {
857
+ k(this, "updateHandler", (t) => {
858
858
  const s = R.createEncoder();
859
859
  R.writeVarUint(s, he), hs(s, t);
860
860
  const o = R.toUint8Array(s);
861
861
  this.conns.forEach((r, a) => this.send(a, o));
862
862
  });
863
- x(this, "ensureDataStructure", () => {
863
+ k(this, "ensureDataStructure", () => {
864
864
  var p;
865
865
  const { supportedLocales: t, pages: s, pageIds: o, config: r, routes: a, routeIds: i } = this.syncedStore;
866
866
  {
@@ -879,7 +879,7 @@ const T = class T extends H.Doc {
879
879
  c.has(y) ? (c.delete(y), u++) : i.splice(u, 1);
880
880
  }
881
881
  }
882
- t.splice(0, t.length), t.push(...$e.env.languages.map((c) => ({ locale: c.code, name: c.name }))), r.defaultLocale = (p = t[0]) == null ? void 0 : p.locale;
882
+ t.splice(0, t.length), t.push(...Me.env.languages.map((c) => ({ locale: c.code, name: c.name }))), r.defaultLocale = (p = t[0]) == null ? void 0 : p.locale;
883
883
  {
884
884
  let c = 0;
885
885
  const u = /* @__PURE__ */ new Set();
@@ -889,7 +889,7 @@ const T = class T extends H.Doc {
889
889
  }
890
890
  }
891
891
  });
892
- x(this, "send", (t, s) => {
892
+ k(this, "send", (t, s) => {
893
893
  t.readyState !== Xs && t.readyState !== Zs && this.closeConn(t);
894
894
  try {
895
895
  t.send(s, (o) => {
@@ -899,24 +899,24 @@ const T = class T extends H.Doc {
899
899
  this.closeConn(t);
900
900
  }
901
901
  });
902
- x(this, "closeConn", (t) => {
902
+ k(this, "closeConn", (t) => {
903
903
  if (t.removeAllListeners(), this.conns.has(t)) {
904
904
  const s = this.conns.get(t);
905
905
  this.conns.delete(t), s && fs(this.awareness, Array.from(s), null);
906
906
  }
907
907
  t.close(), this.checkAndScheduleRelease();
908
908
  });
909
- x(this, "autoSave", pt(() => {
910
- J($(this.draftYjsFilePath), { recursive: !0 }), we(this.draftYjsFilePath, H.encodeStateAsUpdate(this));
909
+ k(this, "autoSave", pt(() => {
910
+ Y(U(this.draftYjsFilePath), { recursive: !0 }), we(this.draftYjsFilePath, z.encodeStateAsUpdate(this));
911
911
  }, qs));
912
- x(this, "save", ({ flush: t = !1 } = {}) => {
912
+ k(this, "save", ({ flush: t = !1 } = {}) => {
913
913
  this.autoSave(), t && this.autoSave.flush();
914
914
  });
915
- x(this, "publish", async ({ mode: t, routes: s }) => {
915
+ k(this, "publish", async ({ mode: t, routes: s }) => {
916
916
  const o = await this.getState("draft"), r = await this.getState("production");
917
917
  await ot(o, r, { routes: s, mergeMode: "replace", deleteRoutes: !0, publishMode: t }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Ys(this.syncedStore, s), await this.setState(t, r);
918
918
  });
919
- x(this, "mergeState", async (t, s) => {
919
+ k(this, "mergeState", async (t, s) => {
920
920
  var i, p, c;
921
921
  const o = JSON.parse(JSON.stringify(s));
922
922
  (i = t.config).fontFamily ?? (i.fontFamily = {});
@@ -932,7 +932,7 @@ const T = class T extends H.Doc {
932
932
  });
933
933
  });
934
934
  });
935
- x(this, "addConnection", (t) => {
935
+ k(this, "addConnection", (t) => {
936
936
  if (this.conns.has(t))
937
937
  return;
938
938
  this.cancelRelease(), t.binaryType = "arraybuffer", this.conns.set(t, /* @__PURE__ */ new Set()), t.on("message", (r) => this.messageListener(t, new Uint8Array(r)));
@@ -964,7 +964,7 @@ const T = class T extends H.Doc {
964
964
  }
965
965
  }
966
966
  });
967
- x(this, "messageListener", (t, s) => {
967
+ k(this, "messageListener", (t, s) => {
968
968
  try {
969
969
  const o = R.createEncoder(), r = ke.createDecoder(s), a = ke.readVarUint(r);
970
970
  switch (a) {
@@ -983,8 +983,8 @@ const T = class T extends H.Doc {
983
983
  }
984
984
  this.save();
985
985
  });
986
- this.options = t, F(this.draftYjsFilePath) && H.applyUpdate(this, ne(this.draftYjsFilePath)), this.syncedStore = ss(
987
- Xt(
986
+ this.options = t, H(this.draftYjsFilePath) && z.applyUpdate(this, re(this.draftYjsFilePath)), this.syncedStore = ns(
987
+ Zt(
988
988
  {
989
989
  pages: {},
990
990
  pageIds: [],
@@ -1006,7 +1006,7 @@ const T = class T extends H.Doc {
1006
1006
  if (!t)
1007
1007
  throw new Error("Should provide project context");
1008
1008
  try {
1009
- const s = A(le, t), o = A(le, `@del-${t}`);
1009
+ const s = O(de, t), o = O(de, `@del-${t}`);
1010
1010
  Ye(s, o);
1011
1011
  } catch (s) {
1012
1012
  S.error("Failed to safe delete project state dir:", s);
@@ -1014,21 +1014,21 @@ const T = class T extends H.Doc {
1014
1014
  }
1015
1015
  static get projectIds() {
1016
1016
  return Ne("*/", {
1017
- cwd: le,
1017
+ cwd: de,
1018
1018
  ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
1019
1019
  // Ignore temp directories and hidden files
1020
1020
  });
1021
1021
  }
1022
1022
  static get allShared() {
1023
- return this.projectIds.map((t) => T.shared(t));
1023
+ return this.projectIds.map((t) => P.shared(t));
1024
1024
  }
1025
1025
  static shared(t) {
1026
1026
  if (!t)
1027
1027
  throw new Error("Should provide project context");
1028
- let s = T.sharedInstances[t];
1029
- return s || (s = new T({
1030
- path: A(le, t)
1031
- }), T.sharedInstances[t] = s, bt({
1028
+ let s = P.sharedInstances[t];
1029
+ return s || (s = new P({
1030
+ path: O(de, t)
1031
+ }), P.sharedInstances[t] = s, At({
1032
1032
  projectId: t,
1033
1033
  pages: Te,
1034
1034
  components: Pe
@@ -1037,15 +1037,15 @@ const T = class T extends H.Doc {
1037
1037
  // 轻量级 production 状态获取,不加载 draft 数据
1038
1038
  static async getProductionState(t) {
1039
1039
  var o, r;
1040
- let s = T.productionStates.get(t);
1040
+ let s = P.productionStates.get(t);
1041
1041
  if (!s) {
1042
- const a = A(le, t, "production");
1043
- if (s = await St(a, { includeResources: !0 }) ?? en(), !((o = s == null ? void 0 : s.config) != null && o.defaultLocale)) {
1042
+ const a = O(de, t, "production");
1043
+ if (s = await wt(a, { includeResources: !0 }) ?? en(), !((o = s == null ? void 0 : s.config) != null && o.defaultLocale)) {
1044
1044
  s.config ?? (s.config = {});
1045
- const i = $e.env.languages.map((p) => ({ locale: p.code, name: p.name }));
1045
+ const i = Me.env.languages.map((p) => ({ locale: p.code, name: p.name }));
1046
1046
  s.config.defaultLocale = (r = i[0]) == null ? void 0 : r.locale;
1047
1047
  }
1048
- T.productionStates.set(t, s);
1048
+ P.productionStates.set(t, s);
1049
1049
  }
1050
1050
  return {
1051
1051
  ...s,
@@ -1053,7 +1053,7 @@ const T = class T extends H.Doc {
1053
1053
  var y, m;
1054
1054
  const { pages: i, components: p } = rs(a, "pages", "components");
1055
1055
  let c = p;
1056
- const u = await ee.findByPk(t);
1056
+ const u = await se.findByPk(t);
1057
1057
  if (u != null && u.useAllResources)
1058
1058
  c = p;
1059
1059
  else {
@@ -1071,37 +1071,37 @@ const T = class T extends H.Doc {
1071
1071
  }
1072
1072
  destroy() {
1073
1073
  this.cancelRelease(), this.save({ flush: !0 }), this.conns.forEach((s, o) => this.closeConn(o)), this.awareness.destroy();
1074
- const t = G(this.options.path);
1075
- delete T.sharedInstances[t], super.destroy();
1074
+ const t = J(this.options.path);
1075
+ delete P.sharedInstances[t], super.destroy();
1076
1076
  }
1077
1077
  initObserver() {
1078
1078
  zs(this.syncedStore), Ks(this.syncedStore);
1079
1079
  }
1080
1080
  get draftYjsFilePath() {
1081
- return A(this.options.path, "draft.yjs");
1081
+ return O(this.options.path, "draft.yjs");
1082
1082
  }
1083
1083
  static async getStateByProjectId(t, s) {
1084
1084
  if (s === "draft") {
1085
- const o = T.shared(t);
1085
+ const o = P.shared(t);
1086
1086
  return JSON.parse(JSON.stringify(o.syncedStore));
1087
1087
  }
1088
- return T.getProductionState(t);
1088
+ return P.getProductionState(t);
1089
1089
  }
1090
1090
  async getState(t) {
1091
1091
  if (t === "draft")
1092
1092
  return JSON.parse(JSON.stringify(this.syncedStore));
1093
- const s = G(this.options.path);
1094
- return T.getProductionState(s);
1093
+ const s = J(this.options.path);
1094
+ return P.getProductionState(s);
1095
1095
  }
1096
1096
  async setState(t, s) {
1097
1097
  const o = await on(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(t);
1098
- if (J($(r), { recursive: !0 }), ct(r, { force: !0, recursive: !0 }), Ye(o, r), t === "production") {
1099
- const a = G(this.options.path);
1100
- T.productionStates.set(a, s);
1098
+ if (Y(U(r), { recursive: !0 }), ct(r, { force: !0, recursive: !0 }), Ye(o, r), t === "production") {
1099
+ const a = J(this.options.path);
1100
+ P.productionStates.set(a, s);
1101
1101
  }
1102
1102
  }
1103
1103
  getPublishDir(t) {
1104
- return A(this.options.path, t);
1104
+ return O(this.options.path, t);
1105
1105
  }
1106
1106
  // 检查并调度延迟释放
1107
1107
  checkAndScheduleRelease() {
@@ -1110,16 +1110,16 @@ const T = class T extends H.Doc {
1110
1110
  // 调度延迟释放
1111
1111
  scheduleRelease() {
1112
1112
  this.cancelRelease();
1113
- const t = G(this.options.path);
1113
+ const t = J(this.options.path);
1114
1114
  this.releaseTimer = setTimeout(() => {
1115
1115
  S.info(`[SiteState] releasing instance due to no active connections: ${t}`), this.conns.size === 0 && (this.releaseTimer = void 0, this.destroy());
1116
- }, T.RELEASE_DELAY), S.info(`[SiteState] scheduled release for project ${t} in ${T.RELEASE_DELAY / 1e3}s`);
1116
+ }, P.RELEASE_DELAY), S.info(`[SiteState] scheduled release for project ${t} in ${P.RELEASE_DELAY / 1e3}s`);
1117
1117
  }
1118
1118
  // 取消延迟释放
1119
1119
  cancelRelease() {
1120
1120
  if (this.releaseTimer) {
1121
1121
  clearTimeout(this.releaseTimer), this.releaseTimer = void 0;
1122
- const t = G(this.options.path);
1122
+ const t = J(this.options.path);
1123
1123
  S.info(`[SiteState] cancelled scheduled release for project ${t}`);
1124
1124
  }
1125
1125
  }
@@ -1129,24 +1129,24 @@ const T = class T extends H.Doc {
1129
1129
  s && (o = [s]);
1130
1130
  const r = {};
1131
1131
  for (const p of o) {
1132
- const c = await ee.findByPk(p);
1132
+ const c = await se.findByPk(p);
1133
1133
  if (!c) continue;
1134
- const u = await T.getStateByProjectId(p, t), y = c.slug || p, m = as(
1134
+ const u = await P.getStateByProjectId(p, t), y = c.slug || p, m = as(
1135
1135
  I.env.languages.map((l) => l.code),
1136
1136
  u.supportedLocales.map((l) => l.locale)
1137
1137
  ), d = (l, f) => {
1138
- y && (r[K("/", y, l)] = {
1138
+ y && (r[W("/", y, l)] = {
1139
1139
  ...f,
1140
1140
  shouldRedirect: !0,
1141
1141
  mainPage: !0
1142
- }), r[K("/", p, l)] = {
1142
+ }), r[W("/", p, l)] = {
1143
1143
  ...f,
1144
1144
  shouldRedirect: !0,
1145
1145
  mainPage: !0
1146
1146
  };
1147
1147
  for (const w of m) {
1148
1148
  const D = { ...f, locale: w };
1149
- r[K("/", w, p, l)] = D, y && (r[K("/", w, y, l)] = D);
1149
+ r[W("/", w, p, l)] = D, y && (r[W("/", w, y, l)] = D);
1150
1150
  }
1151
1151
  };
1152
1152
  if (t === "draft")
@@ -1154,7 +1154,7 @@ const T = class T extends H.Doc {
1154
1154
  const f = (a = u == null ? void 0 : u.routes) == null ? void 0 : a[l];
1155
1155
  if (!f) continue;
1156
1156
  if (f.params && f.params.length > 0) {
1157
- const O = Ue({
1157
+ const C = Ue({
1158
1158
  basePath: f.path,
1159
1159
  params: f.params,
1160
1160
  routeId: f.id,
@@ -1164,20 +1164,20 @@ const T = class T extends H.Doc {
1164
1164
  currentOptionIds: [],
1165
1165
  result: []
1166
1166
  });
1167
- for (const N of O) {
1168
- const W = N.path, te = {
1167
+ for (const L of C) {
1168
+ const Q = L.path, ne = {
1169
1169
  projectId: p,
1170
1170
  projectSlug: y,
1171
- pageSlug: W,
1171
+ pageSlug: Q,
1172
1172
  pageId: f.displayTemplateId || "",
1173
1173
  routeId: l,
1174
1174
  // default locale
1175
1175
  defaultLocale: m == null ? void 0 : m[0],
1176
1176
  locales: m,
1177
1177
  publishedAt: u.config.publishedAt,
1178
- isPublic: f.isPublic && ((i = N == null ? void 0 : N.routeMetaData) == null ? void 0 : i.isPublic)
1178
+ isPublic: f.isPublic && ((i = L == null ? void 0 : L.routeMetaData) == null ? void 0 : i.isPublic)
1179
1179
  };
1180
- d(W, te);
1180
+ d(Q, ne);
1181
1181
  }
1182
1182
  }
1183
1183
  const w = f.path, D = {
@@ -1198,7 +1198,7 @@ const T = class T extends H.Doc {
1198
1198
  const f = u.pages[l];
1199
1199
  if (!f || t === "production" && !f.isPublic)
1200
1200
  continue;
1201
- const w = f.slug, D = c.slug || p, O = {
1201
+ const w = f.slug, D = c.slug || p, C = {
1202
1202
  projectId: p,
1203
1203
  projectSlug: D,
1204
1204
  pageSlug: w,
@@ -1210,17 +1210,17 @@ const T = class T extends H.Doc {
1210
1210
  isPublic: f.isPublic,
1211
1211
  templateConfig: f.templateConfig
1212
1212
  };
1213
- d(w, O);
1213
+ d(w, C);
1214
1214
  }
1215
1215
  }
1216
1216
  return r;
1217
1217
  }
1218
1218
  getDocumentSize() {
1219
- return H.encodeStateAsUpdate(this).byteLength;
1219
+ return z.encodeStateAsUpdate(this).byteLength;
1220
1220
  }
1221
1221
  static getInstancesSizeInfo() {
1222
1222
  const t = [];
1223
- for (const [s, o] of Object.entries(T.sharedInstances)) {
1223
+ for (const [s, o] of Object.entries(P.sharedInstances)) {
1224
1224
  const r = o.getDocumentSize();
1225
1225
  t.push({
1226
1226
  projectId: s,
@@ -1245,8 +1245,8 @@ const T = class T extends H.Doc {
1245
1245
  }
1246
1246
  // 执行定期检查
1247
1247
  static performPeriodicCheck() {
1248
- const t = Object.keys(T.sharedInstances).length, s = [], o = [];
1249
- for (const [r, a] of Object.entries(T.sharedInstances))
1248
+ const t = Object.keys(P.sharedInstances).length, s = [], o = [];
1249
+ for (const [r, a] of Object.entries(P.sharedInstances))
1250
1250
  a.conns.size === 0 ? s.push({ projectId: r, instance: a }) : o.push({ projectId: r, connections: a.conns.size });
1251
1251
  if (S.info(
1252
1252
  `[SiteState] periodic check summary: total instances: ${t}, with connections: ${o.length}, without connections: ${s.length}`
@@ -1268,18 +1268,18 @@ const T = class T extends H.Doc {
1268
1268
  } else t > 0 ? S.debug("[SiteState] periodic check: all instances have active connections") : S.debug("[SiteState] periodic check: no instances exist");
1269
1269
  }
1270
1270
  };
1271
- x(T, "PRODUCTION_CACHE_TTL", 7 * 24 * 60 * 60 * 1e3), // 7 days
1271
+ k(P, "PRODUCTION_CACHE_TTL", 7 * 24 * 60 * 60 * 1e3), // 7 days
1272
1272
  // 延迟释放时间:5分钟
1273
- x(T, "RELEASE_DELAY", 5 * 60 * 1e3), // 定期检查间隔:2 小时
1274
- x(T, "PERIODIC_CHECK_INTERVAL", 2 * 60 * 60 * 1e3), // 2 hours
1275
- x(T, "sharedInstances", {}), x(T, "productionStates", new Me({
1273
+ k(P, "RELEASE_DELAY", 5 * 60 * 1e3), // 定期检查间隔:2 小时
1274
+ k(P, "PERIODIC_CHECK_INTERVAL", 2 * 60 * 60 * 1e3), // 2 hours
1275
+ k(P, "sharedInstances", {}), k(P, "productionStates", new $e({
1276
1276
  max: 100,
1277
- ttl: T.PRODUCTION_CACHE_TTL
1277
+ ttl: P.PRODUCTION_CACHE_TTL
1278
1278
  })), // 定期检查定时器
1279
- x(T, "periodicCheckTimer");
1280
- let Y = T;
1279
+ k(P, "periodicCheckTimer");
1280
+ let q = P;
1281
1281
  async function tn(e, n, t) {
1282
- if (!e || !F(e) || !se(e).isFile())
1282
+ if (!e || !H(e) || !oe(e).isFile())
1283
1283
  return null;
1284
1284
  let s = t[e];
1285
1285
  return s || (s = (async () => {
@@ -1296,14 +1296,14 @@ async function tn(e, n, t) {
1296
1296
  })(), t[e] = s), s;
1297
1297
  }
1298
1298
  const sn = async (e, n) => {
1299
- const t = G(e), s = await Kt({
1300
- name: ht,
1301
- path: K("/uploads", t),
1299
+ const t = J(e), s = await Yt({
1300
+ name: gt,
1301
+ path: W("/uploads", t),
1302
1302
  responseType: "stream",
1303
1303
  method: "GET"
1304
1304
  });
1305
1305
  if (s.status >= 200 && s.status < 400) {
1306
- const o = Ft(n);
1306
+ const o = Bt(n);
1307
1307
  await ls(s.data, o);
1308
1308
  } else
1309
1309
  throw new Error(`download asset failed ${s.status}`);
@@ -1311,30 +1311,30 @@ const sn = async (e, n) => {
1311
1311
  await Promise.all(
1312
1312
  e.map(async (t) => {
1313
1313
  try {
1314
- await sn(t, A(n, G(t)));
1314
+ await sn(t, O(n, J(t)));
1315
1315
  } catch (s) {
1316
1316
  S.error(`Failed to export assets: ${t}, ${s}`);
1317
1317
  }
1318
1318
  })
1319
1319
  );
1320
1320
  };
1321
- function yt(e) {
1322
- return Ge.test(e) ? [e] : de.test(e) ? (tt.lastIndex = 0, Array.from(e.matchAll(tt)).map((t) => t[1]).filter((t) => !!t)) : [];
1321
+ function St(e) {
1322
+ return Ge.test(e) ? [e] : fe.test(e) ? (tt.lastIndex = 0, Array.from(e.matchAll(tt)).map((t) => t[1]).filter((t) => !!t)) : [];
1323
1323
  }
1324
1324
  async function ge(e, n, t) {
1325
- const { getFilename: s, exportAssets: o } = t, r = A(n, s(e));
1326
- if (J($(r), { recursive: !0 }), we(r, oe.stringify(e)), o) {
1325
+ const { getFilename: s, exportAssets: o } = t, r = O(n, s(e));
1326
+ if (Y(U(r), { recursive: !0 }), we(r, ae.stringify(e)), o) {
1327
1327
  const i = be(
1328
1328
  e,
1329
- (p) => typeof p == "string" && (Ge.test(p) || de.test(p))
1329
+ (p) => typeof p == "string" && (Ge.test(p) || fe.test(p))
1330
1330
  ).map((p) => {
1331
1331
  const c = Fe(e, p);
1332
- return yt(c);
1332
+ return St(c);
1333
1333
  }).flat().filter(Boolean);
1334
- await nn(i, $(r));
1334
+ await nn(i, U(r));
1335
1335
  }
1336
1336
  }
1337
- const st = new Me({
1337
+ const st = new $e({
1338
1338
  max: 20,
1339
1339
  ttl: 30 * 24 * 60 * 60 * 1e3
1340
1340
  });
@@ -1342,19 +1342,19 @@ async function nt(e, n, t) {
1342
1342
  var i;
1343
1343
  const s = be(
1344
1344
  e,
1345
- (p) => typeof p == "string" && (Ge.test(p) || de.test(p))
1345
+ (p) => typeof p == "string" && (Ge.test(p) || fe.test(p))
1346
1346
  ), o = cs(2), r = s.map(
1347
1347
  (p) => o(async () => {
1348
1348
  try {
1349
- const c = Fe(e, p), u = yt(c);
1349
+ const c = Fe(e, p), u = St(c);
1350
1350
  for (const y of u) {
1351
- const m = G(y), d = t.getFilePath(y, p), l = d ? `${d}:${m}` : m, f = st.get(l);
1351
+ const m = J(y), d = t.getFilePath(y, p), l = d ? `${d}:${m}` : m, f = st.get(l);
1352
1352
  if (f) {
1353
- de.test(c) || We(e, p, f);
1353
+ fe.test(c) || We(e, p, f);
1354
1354
  return;
1355
1355
  }
1356
1356
  const w = await tn(d, m, n);
1357
- w && (de.test(c) || We(e, p, w), st.set(l, w));
1357
+ w && (fe.test(c) || We(e, p, w), st.set(l, w));
1358
1358
  }
1359
1359
  } catch (c) {
1360
1360
  S.error(`Failed to process upload for path ${p.join(".")}:`, c.message || c.reason);
@@ -1371,26 +1371,26 @@ async function on(e, {
1371
1371
  includeResources: r = !1,
1372
1372
  routeIds: a = "all"
1373
1373
  } = {}) {
1374
- var ie, E, h, b, P, q, v, M, Q, fe, ce, me;
1375
- const i = t === "all" ? e.pageIds : t, p = Dt({
1374
+ var le, E, h, A, v, X, b, N, F, Z, K, pe;
1375
+ const i = t === "all" ? e.pageIds : t, p = kt({
1376
1376
  state: e,
1377
1377
  pageIds: i,
1378
1378
  componentIds: s === "all" ? Object.keys(e.components) : s
1379
- }), c = a === "all" ? e.routeIds : a, u = (g, C) => {
1380
- var k;
1381
- return {
1382
- id: g.id,
1383
- name: g.name,
1384
- isTemplateSection: g.isTemplateSection ?? !1,
1385
- templateDescription: g.templateDescription,
1386
- llmConfig: g.llmConfig,
1387
- component: g.component,
1388
- config: g.config,
1389
- visibility: g.visibility,
1390
- properties: ((k = g.locales) == null ? void 0 : k[C]) ?? {}
1391
- };
1392
- }, y = (g, C) => {
1393
- var k;
1379
+ }), c = a === "all" ? e.routeIds : a, u = (g) => ({
1380
+ id: g.id,
1381
+ name: g.name,
1382
+ isTemplateSection: g.isTemplateSection ?? !1,
1383
+ templateDescription: g.templateDescription,
1384
+ llmConfig: g.llmConfig,
1385
+ component: g.component,
1386
+ config: g.config,
1387
+ visibility: g.visibility,
1388
+ sections: g.sections,
1389
+ sectionIds: g.sectionIds
1390
+ // 已经废弃,数据在 page.dataSource 中管理
1391
+ // properties: section.locales?.[locale] ?? {},
1392
+ }), y = (g, T) => {
1393
+ var j;
1394
1394
  return {
1395
1395
  id: g.id,
1396
1396
  createdAt: g.createdAt,
@@ -1398,12 +1398,16 @@ async function on(e, {
1398
1398
  publishedAt: g.publishedAt,
1399
1399
  isPublic: g.isPublic ?? !0,
1400
1400
  templateConfig: g.templateConfig,
1401
- meta: ((k = g.locales) == null ? void 0 : k[C]) ?? {},
1402
- sections: _(
1403
- g.sectionIds.map((z) => {
1404
- const V = g.sections[z];
1405
- return V && u(V, C);
1401
+ meta: ((j = g.locales) == null ? void 0 : j[T]) ?? {},
1402
+ sections: $(
1403
+ g.sectionIds.map((B) => {
1404
+ const _ = g.sections[B];
1405
+ return _ && u(_);
1406
1406
  })
1407
+ ),
1408
+ // 将 dataSource.sectionId.locale 转换为 dataSource.sectionId
1409
+ dataSource: Object.fromEntries(
1410
+ Object.entries(g.dataSource || {}).map(([B, _]) => [B, (_ == null ? void 0 : _[T]) ?? {}])
1407
1411
  )
1408
1412
  };
1409
1413
  }, m = (g) => ({
@@ -1418,79 +1422,79 @@ async function on(e, {
1418
1422
  enabledGenerate: g.enabledGenerate ?? !1,
1419
1423
  displayTemplateId: g.displayTemplateId,
1420
1424
  dataSource: g.dataSource
1421
- }), d = _(
1425
+ }), d = $(
1422
1426
  c.map((g) => {
1423
- const C = e.routes[g];
1424
- return C && m(C);
1427
+ const T = e.routes[g];
1428
+ return T && m(T);
1425
1429
  })
1426
- ), l = _(
1430
+ ), l = $(
1427
1431
  e.supportedLocales.map((g) => g.locale).flatMap(
1428
- (g) => i.map((C) => {
1429
- const k = e.pages[C];
1430
- return k && {
1432
+ (g) => i.map((T) => {
1433
+ const j = e.pages[T];
1434
+ return j && {
1431
1435
  locale: g,
1432
- slug: k.slug,
1433
- page: y(k, g)
1436
+ slug: j.slug,
1437
+ page: y(j, g)
1434
1438
  };
1435
1439
  })
1436
1440
  )
1437
- ), f = gt(), w = A(f, "pages");
1438
- J(w, { recursive: !0 });
1439
- const D = A(f, "components");
1440
- J(D, { recursive: !0 });
1441
- const O = A(f, "routes");
1442
- J(O, { recursive: !0 });
1443
- for (const { locale: g, slug: C, page: k } of l)
1444
- await ge(k, w, {
1445
- getFilename: () => `${Ae(C) || "index"}.${g}.yml`,
1441
+ ), f = yt(), w = O(f, "pages");
1442
+ Y(w, { recursive: !0 });
1443
+ const D = O(f, "components");
1444
+ Y(D, { recursive: !0 });
1445
+ const C = O(f, "routes");
1446
+ Y(C, { recursive: !0 });
1447
+ for (const { locale: g, slug: T, page: j } of l)
1448
+ await ge(j, w, {
1449
+ getFilename: () => `${Ae(T) || "index"}.${g}.yml`,
1446
1450
  exportAssets: n
1447
1451
  });
1448
1452
  for (const g of d)
1449
- await ge(g, O, {
1453
+ await ge(g, C, {
1450
1454
  // getFilename: () => `${sanitizeSlug(route.path)}.yml`,
1451
1455
  getFilename: () => `${Ae(g.path) || "index"}.yml`,
1452
1456
  exportAssets: n
1453
1457
  });
1454
1458
  for (const g of p) {
1455
- const C = (ie = e.components[g]) == null ? void 0 : ie.data;
1456
- C && await ge(C, D, {
1457
- getFilename: (k) => `${k.name || "unnamed"}.${k.id}.yml`,
1459
+ const T = (le = e.components[g]) == null ? void 0 : le.data;
1460
+ T && await ge(T, D, {
1461
+ getFilename: (j) => `${j.name || "unnamed"}.${j.id}.yml`,
1458
1462
  exportAssets: n
1459
1463
  });
1460
1464
  }
1461
- const N = A(f, ".blocklet/pages/pages.config.yml");
1462
- J($(N), { recursive: !0 });
1463
- const W = {
1464
- pages: _(
1465
+ const L = O(f, ".blocklet/pages/pages.config.yml");
1466
+ Y(U(L), { recursive: !0 });
1467
+ const Q = {
1468
+ pages: $(
1465
1469
  i.map((g) => {
1466
- const C = e.pages[g];
1467
- return C && { id: g, slug: C.slug };
1470
+ const T = e.pages[g];
1471
+ return T && { id: g, slug: T.slug };
1468
1472
  })
1469
1473
  ),
1470
- routes: _(
1474
+ routes: $(
1471
1475
  c.map((g) => {
1472
- const C = e.routes[g];
1473
- return C && { id: g, path: C.path };
1476
+ const T = e.routes[g];
1477
+ return T && { id: g, path: T.path };
1474
1478
  })
1475
1479
  ),
1476
- components: _(
1480
+ components: $(
1477
1481
  p.map((g) => {
1478
- var k;
1479
- const C = (k = e.components[g]) == null ? void 0 : k.data;
1480
- return C && {
1482
+ var j;
1483
+ const T = (j = e.components[g]) == null ? void 0 : j.data;
1484
+ return T && {
1481
1485
  id: g,
1482
- name: C.name
1486
+ name: T.name
1483
1487
  };
1484
1488
  })
1485
1489
  ),
1486
1490
  ...r ? {
1487
1491
  resources: {
1488
- components: _(
1492
+ components: $(
1489
1493
  Object.keys(((E = e.resources) == null ? void 0 : E.components) || {}).filter((g) => p.includes(g)).map((g) => {
1490
- var C, k, z, V;
1494
+ var T, j, B, _;
1491
1495
  return {
1492
1496
  id: g,
1493
- name: (V = (z = (k = (C = e.resources) == null ? void 0 : C.components) == null ? void 0 : k[g]) == null ? void 0 : z.component) == null ? void 0 : V.name
1497
+ name: (_ = (B = (j = (T = e.resources) == null ? void 0 : T.components) == null ? void 0 : j[g]) == null ? void 0 : B.component) == null ? void 0 : _.name
1494
1498
  };
1495
1499
  })
1496
1500
  )
@@ -1499,36 +1503,36 @@ async function on(e, {
1499
1503
  supportedLocales: e.supportedLocales,
1500
1504
  config: e.config
1501
1505
  };
1502
- we(N, oe.stringify(W));
1503
- const te = A(f, "config.source.json");
1504
- if (o && we(te, JSON.stringify(o)), r) {
1505
- const g = A(f, "resources"), C = A(g, "components");
1506
- J(C, { recursive: !0 });
1507
- for (const V of Object.keys(((h = e == null ? void 0 : e.resources) == null ? void 0 : h.components) ?? {}).filter(
1508
- (U) => p.includes(U)
1506
+ we(L, ae.stringify(Q));
1507
+ const ne = O(f, "config.source.json");
1508
+ if (o && we(ne, JSON.stringify(o)), r) {
1509
+ const g = O(f, "resources"), T = O(g, "components");
1510
+ Y(T, { recursive: !0 });
1511
+ for (const _ of Object.keys(((h = e == null ? void 0 : e.resources) == null ? void 0 : h.components) ?? {}).filter(
1512
+ (G) => p.includes(G)
1509
1513
  )) {
1510
- const U = (q = (P = (b = e.resources) == null ? void 0 : b.components) == null ? void 0 : P[V]) == null ? void 0 : q.component;
1511
- U && await ge(U, C, {
1512
- getFilename: (X) => `${X.name || "unnamed"}.${X.id}.yml`,
1514
+ const G = (X = (v = (A = e.resources) == null ? void 0 : A.components) == null ? void 0 : v[_]) == null ? void 0 : X.component;
1515
+ G && await ge(G, T, {
1516
+ getFilename: (ee) => `${ee.name || "unnamed"}.${ee.id}.yml`,
1513
1517
  exportAssets: n
1514
1518
  });
1515
1519
  }
1516
- const k = A(f, "chunks");
1517
- J(k, { recursive: !0 });
1518
- const { chunks: z } = await Ve();
1519
- for (const V of Object.keys(((v = e == null ? void 0 : e.resources) == null ? void 0 : v.components) ?? {}).filter(
1520
- (U) => p.includes(U)
1520
+ const j = O(f, "chunks");
1521
+ Y(j, { recursive: !0 });
1522
+ const { chunks: B } = await Ve();
1523
+ for (const _ of Object.keys(((b = e == null ? void 0 : e.resources) == null ? void 0 : b.components) ?? {}).filter(
1524
+ (G) => p.includes(G)
1521
1525
  )) {
1522
- const U = (fe = (Q = (M = e.resources) == null ? void 0 : M.components) == null ? void 0 : Q[V]) == null ? void 0 : fe.component;
1523
- if (U && ((ce = U.renderer) == null ? void 0 : ce.type) === "react-component") {
1524
- const X = ((me = U.renderer) == null ? void 0 : me.chunks) ?? [];
1525
- if ((X == null ? void 0 : X.length) > 0)
1526
- for (const ve of X) {
1527
- const Je = A(k, ve), De = z == null ? void 0 : z[ve];
1526
+ const G = (Z = (F = (N = e.resources) == null ? void 0 : N.components) == null ? void 0 : F[_]) == null ? void 0 : Z.component;
1527
+ if (G && ((K = G.renderer) == null ? void 0 : K.type) === "react-component") {
1528
+ const ee = ((pe = G.renderer) == null ? void 0 : pe.chunks) ?? [];
1529
+ if ((ee == null ? void 0 : ee.length) > 0)
1530
+ for (const ve of ee) {
1531
+ const Je = O(j, ve), De = B == null ? void 0 : B[ve];
1528
1532
  try {
1529
- De && F(De) && !F(Je) && Ut(De, Je);
1530
- } catch (At) {
1531
- S.error(`copy chunk ${ve} error`, At.message);
1533
+ De && H(De) && !H(Je) && Ft(De, Je);
1534
+ } catch (Ot) {
1535
+ S.error(`copy chunk ${ve} error`, Ot.message);
1532
1536
  }
1533
1537
  }
1534
1538
  }
@@ -1536,84 +1540,112 @@ async function on(e, {
1536
1540
  }
1537
1541
  return f;
1538
1542
  }
1539
- async function St(e, { importAssets: n, includeResources: t } = {}) {
1543
+ async function wt(e, { importAssets: n, includeResources: t } = {}) {
1540
1544
  var r, a, i, p;
1541
- if (!F(e))
1545
+ if (!H(e))
1542
1546
  return null;
1543
1547
  let s, o = !1;
1544
1548
  try {
1545
- se(e).isDirectory() ? s = e : /\.(tgz|gz|tar)$/.test(e) && (o = !0, s = gt(), await ps({ file: e, C: s }));
1546
- const c = Ne("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), u = c && A($(c), "../../pages"), y = c && A($(c), "../../components"), m = c && A($(c), "../../chunks"), d = c && A($(c), "../../routes");
1549
+ oe(e).isDirectory() ? s = e : /\.(tgz|gz|tar)$/.test(e) && (o = !0, s = yt(), await ps({ file: e, C: s }));
1550
+ const c = Ne("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), u = c && O(U(c), "../../pages"), y = c && O(U(c), "../../components"), m = c && O(U(c), "../../chunks"), d = c && O(U(c), "../../routes");
1547
1551
  if (!c)
1548
1552
  return null;
1549
- const l = oe.parse(ne(c).toString()), f = (E, h, b) => {
1550
- let P = A(E, `${h}${b ? `.${b}` : ""}.yml`);
1551
- return (!F(P) || !se(P).isFile()) && (P = A(E, h, `index${b ? `.${b}` : ""}.yml`), !F(P) || !se(P)) ? null : oe.parse(ne(P).toString());
1553
+ const l = ae.parse(re(c).toString()), f = (E, h, A) => {
1554
+ let v = O(E, `${h}${A ? `.${A}` : ""}.yml`);
1555
+ return (!H(v) || !oe(v).isFile()) && (v = O(E, h, `index${A ? `.${A}` : ""}.yml`), !H(v) || !oe(v)) ? null : ae.parse(re(v).toString());
1552
1556
  }, w = (E, h) => {
1553
1557
  try {
1554
- const b = Ne(`*.${h}.yml`, { cwd: E, absolute: !0 })[0];
1555
- return b ? oe.parse(ne(b).toString()) : null;
1556
- } catch (b) {
1557
- S.error("parse component error", b);
1558
+ const A = Ne(`*.${h}.yml`, { cwd: E, absolute: !0 })[0];
1559
+ return A ? ae.parse(re(A).toString()) : null;
1560
+ } catch (A) {
1561
+ S.error("parse component error", A);
1558
1562
  }
1559
1563
  return null;
1560
1564
  }, D = (E, h) => {
1561
- let b = A(E, `${h}.yml`);
1562
- return (!F(b) || !se(b).isFile()) && (b = A(E, h, "index.yml"), !F(b) || !se(b)) ? null : oe.parse(ne(b).toString());
1563
- }, O = _(
1565
+ let A = O(E, `${h}.yml`);
1566
+ return (!H(A) || !oe(A).isFile()) && (A = O(E, h, "index.yml"), !H(A) || !oe(A)) ? null : ae.parse(re(A).toString());
1567
+ }, C = $(
1564
1568
  l.pages.map(({ slug: E }) => {
1565
- var q;
1566
- const h = _(
1567
- l.supportedLocales.map(({ locale: v }) => {
1568
- const M = u ? f(u, Ae(E), v) : void 0;
1569
- if (M)
1570
- return { locale: v, page: M };
1571
- const Q = u ? f(u, E, v) : void 0;
1572
- return Q && { locale: v, page: Q };
1569
+ var X;
1570
+ const h = $(
1571
+ l.supportedLocales.map(({ locale: b }) => {
1572
+ const N = u ? f(u, Ae(E), b) : void 0;
1573
+ if (N)
1574
+ return { locale: b, page: N };
1575
+ const F = u ? f(u, E, b) : void 0;
1576
+ return F && { locale: b, page: F };
1573
1577
  })
1574
- ), b = (q = h[0]) == null ? void 0 : q.page;
1575
- if (!b)
1578
+ ), A = (X = h[0]) == null ? void 0 : X.page;
1579
+ if (!A)
1576
1580
  return null;
1577
- const P = b.sections.map((v) => {
1578
- const M = v.id || je();
1579
- return {
1580
- id: M,
1581
- component: v.component,
1582
- config: v.config,
1583
- name: v.name,
1584
- isTemplateSection: v.isTemplateSection ?? !1,
1585
- templateDescription: v.templateDescription,
1586
- llmConfig: v.llmConfig,
1587
- visibility: v.visibility,
1588
- locales: Object.fromEntries(
1589
- _(
1590
- h.map(({ locale: Q, page: fe }) => {
1591
- const ce = fe.sections.find((me) => me.id === M);
1592
- return ce && [Q, ce.properties];
1593
- })
1594
- )
1595
- )
1596
- };
1597
- });
1581
+ const v = A.sections.map((b) => ({
1582
+ id: b.id || xe(),
1583
+ component: b.component,
1584
+ config: b.config,
1585
+ name: b.name,
1586
+ isTemplateSection: b.isTemplateSection ?? !1,
1587
+ templateDescription: b.templateDescription,
1588
+ llmConfig: b.llmConfig,
1589
+ visibility: b.visibility,
1590
+ sections: b.sections,
1591
+ sectionIds: b.sectionIds
1592
+ // 不再需要 locales, 数据在 page.dataSource 中管理
1593
+ // locales: Object.fromEntries(
1594
+ // filterNone(
1595
+ // locales.map(({ locale, page }) => {
1596
+ // const section = page.sections.find((s) => s.id === sectionId);
1597
+ // return section && [locale, section.properties];
1598
+ // })
1599
+ // )
1600
+ // ),
1601
+ }));
1598
1602
  return {
1599
- id: b.id || je(),
1600
- createdAt: b.createdAt,
1601
- updatedAt: b.updatedAt,
1602
- publishedAt: b.publishedAt,
1603
- isPublic: b.isPublic ?? !0,
1604
- templateConfig: b.templateConfig,
1603
+ id: A.id || xe(),
1604
+ createdAt: A.createdAt,
1605
+ updatedAt: A.updatedAt,
1606
+ publishedAt: A.publishedAt,
1607
+ isPublic: A.isPublic ?? !0,
1608
+ templateConfig: A.templateConfig,
1605
1609
  slug: E,
1606
- sections: Object.fromEntries(P.map((v) => [v.id, v])),
1607
- sectionIds: P.map((v) => v.id),
1608
- locales: Object.fromEntries(h.map(({ locale: v, page: M }) => [v, M.meta]))
1610
+ sections: Object.fromEntries(v.map((b) => [b.id, b])),
1611
+ sectionIds: v.map((b) => b.id),
1612
+ locales: Object.fromEntries(h.map(({ locale: b, page: N }) => [b, N.meta])),
1613
+ dataSource: A.dataSource ? Object.fromEntries(
1614
+ // 获取 dataSource 中所有 section ID
1615
+ [...new Set(h.flatMap(({ page: b }) => Object.keys(b.dataSource ?? {})))].map((b) => [
1616
+ b,
1617
+ Object.fromEntries(
1618
+ h.map(({ locale: N, page: F }) => {
1619
+ var K;
1620
+ const Z = (K = F.dataSource) == null ? void 0 : K[b];
1621
+ return [N, Z || {}];
1622
+ })
1623
+ )
1624
+ ])
1625
+ ) : Object.fromEntries(
1626
+ // 获取所有 section ID
1627
+ [...new Set(h.flatMap(({ page: b }) => b.sections.map((N) => N.id)))].map((b) => [
1628
+ b,
1629
+ Object.fromEntries(
1630
+ h.map(({ locale: N, page: F }) => {
1631
+ var pe;
1632
+ const Z = (pe = F.dataSource) == null ? void 0 : pe[b];
1633
+ if (Z)
1634
+ return [N, Z];
1635
+ const K = F.sections.find((g) => g.id === b);
1636
+ return [N, (K == null ? void 0 : K.properties) || {}];
1637
+ })
1638
+ )
1639
+ ])
1640
+ )
1609
1641
  };
1610
1642
  })
1611
- ), N = _(
1643
+ ), L = $(
1612
1644
  ((r = l == null ? void 0 : l.routes) == null ? void 0 : r.map(({ path: E }) => {
1613
1645
  const h = d ? D(d, Ae(E)) : void 0;
1614
1646
  return {
1615
1647
  ...h,
1616
- id: (h == null ? void 0 : h.id) || je(),
1648
+ id: (h == null ? void 0 : h.id) || xe(),
1617
1649
  createdAt: (h == null ? void 0 : h.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
1618
1650
  updatedAt: (h == null ? void 0 : h.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
1619
1651
  publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
@@ -1626,31 +1658,31 @@ async function St(e, { importAssets: n, includeResources: t } = {}) {
1626
1658
  dataSource: (h == null ? void 0 : h.dataSource) ?? {}
1627
1659
  };
1628
1660
  })) ?? []
1629
- ), W = y ? _(((a = l.components) == null ? void 0 : a.map(({ id: E }) => w(y, E))) ?? []) : [];
1661
+ ), Q = y ? $(((a = l.components) == null ? void 0 : a.map(({ id: E }) => w(y, E))) ?? []) : [];
1630
1662
  if (n) {
1631
1663
  const E = (...h) => {
1632
- S.info(`[${o ? G(e) : G(A(e, "../../../../"))}] importAssets:`, ...h);
1664
+ S.info(`[${o ? J(e) : J(O(e, "../../../../"))}] importAssets:`, ...h);
1633
1665
  };
1634
1666
  try {
1635
1667
  E("wait image-bin api ready"), await ds({
1636
- resources: [`${zt(Es)}/api/sdk/uploads`],
1637
- validateStatus: (P) => P >= 200 && P <= 500
1668
+ resources: [`${Kt(Es)}/api/sdk/uploads`],
1669
+ validateStatus: (v) => v >= 200 && v <= 500
1638
1670
  }), E("image-bin api is ready");
1639
- const h = {}, b = {};
1671
+ const h = {}, A = {};
1640
1672
  E("start to upload assets"), await Promise.allSettled([
1641
- nt(W, h, {
1642
- getFilePath: (P) => y && A(y, P),
1643
- onFinish: (P) => {
1644
- E(`upload ${P.length} component assets`);
1673
+ nt(Q, h, {
1674
+ getFilePath: (v) => y && O(y, v),
1675
+ onFinish: (v) => {
1676
+ E(`upload ${v.length} component assets`);
1645
1677
  }
1646
1678
  }),
1647
- nt(O, b, {
1648
- getFilePath: (P, q) => {
1649
- const v = Fe(O, q.slice(0, 1));
1650
- return u && A(u, $(v.slug), P);
1679
+ nt(C, A, {
1680
+ getFilePath: (v, X) => {
1681
+ const b = Fe(C, X.slice(0, 1));
1682
+ return u && O(u, U(b.slug), v);
1651
1683
  },
1652
- onFinish: (P) => {
1653
- E(`upload ${P.length} page assets`);
1684
+ onFinish: (v) => {
1685
+ E(`upload ${v.length} page assets`);
1654
1686
  }
1655
1687
  })
1656
1688
  ]), E("upload assets done"), global.gc && global.gc();
@@ -1658,31 +1690,31 @@ async function St(e, { importAssets: n, includeResources: t } = {}) {
1658
1690
  E("Error during asset import:", h);
1659
1691
  }
1660
1692
  }
1661
- const te = {};
1693
+ const ne = {};
1662
1694
  if (t) {
1663
- const E = c && A($(c), "../../resources/components"), h = _(
1664
- ((p = (i = l.resources) == null ? void 0 : i.components) == null ? void 0 : p.map(({ id: b }) => w(E, b))) ?? []
1695
+ const E = c && O(U(c), "../../resources/components"), h = $(
1696
+ ((p = (i = l.resources) == null ? void 0 : i.components) == null ? void 0 : p.map(({ id: A }) => w(E, A))) ?? []
1665
1697
  );
1666
- h.length > 0 && (te.components = Object.fromEntries(
1667
- h.map((b, P) => [b.id, { index: P, component: b }])
1698
+ h.length > 0 && (ne.components = Object.fromEntries(
1699
+ h.map((A, v) => [A.id, { index: v, component: A }])
1668
1700
  ));
1669
1701
  }
1670
- const ie = {};
1671
- if (m && F(m)) {
1672
- const E = Mt(m);
1702
+ const le = {};
1703
+ if (m && H(m)) {
1704
+ const E = Ut(m);
1673
1705
  for (const h of E)
1674
- ie[h] = A(m, h);
1706
+ le[h] = O(m, h);
1675
1707
  }
1676
1708
  return {
1677
1709
  supportedLocales: l.supportedLocales,
1678
- pageIds: O.map((E) => E.id),
1679
- components: Object.fromEntries(W.map((E, h) => [E.id, { index: h, data: E }])),
1680
- pages: Object.fromEntries(O.map((E) => [E.id, E])),
1710
+ pageIds: C.map((E) => E.id),
1711
+ components: Object.fromEntries(Q.map((E, h) => [E.id, { index: h, data: E }])),
1712
+ pages: Object.fromEntries(C.map((E) => [E.id, E])),
1681
1713
  config: l.config || {},
1682
- resources: te,
1683
- chunks: ie,
1684
- routeIds: N.map((E) => E.id),
1685
- routes: Object.fromEntries(N.map((E) => [E.id, E])),
1714
+ resources: ne,
1715
+ chunks: le,
1716
+ routeIds: L.map((E) => E.id),
1717
+ routes: Object.fromEntries(L.map((E) => [E.id, E])),
1686
1718
  dataSourceIds: [],
1687
1719
  dataSources: {}
1688
1720
  };
@@ -1697,7 +1729,7 @@ async function ot(e, n, {
1697
1729
  publishMode: r = void 0
1698
1730
  } = {}) {
1699
1731
  try {
1700
- r && $s(r);
1732
+ r && Ms(r);
1701
1733
  } catch (m) {
1702
1734
  S.error("clear preload page cache error", { error: m });
1703
1735
  }
@@ -1716,29 +1748,29 @@ async function ot(e, n, {
1716
1748
  currentParams: [],
1717
1749
  currentOptionIds: [],
1718
1750
  result: []
1719
- }), D = Object.fromEntries(w.map((O) => [`${l}-${O.paramOptionIds.join("-")}`, O]));
1720
- d = { ...d || {}, ...D }, t || (m = [...m, ...w.map((O) => `${l}-${O.paramOptionIds.join("-")}`)]);
1751
+ }), D = Object.fromEntries(w.map((C) => [`${l}-${C.paramOptionIds.join("-")}`, C]));
1752
+ d = { ...d || {}, ...D }, t || (m = [...m, ...w.map((C) => `${l}-${C.paramOptionIds.join("-")}`)]);
1721
1753
  } else t || m.push(l);
1722
1754
  }
1723
1755
  S.info("routeIds to be published: ", m);
1724
1756
  for (const l of m) {
1725
1757
  let f = l;
1726
1758
  if (f.includes("-")) {
1727
- const [O] = f.split("-");
1728
- f = O;
1759
+ const [C] = f.split("-");
1760
+ f = C;
1729
1761
  }
1730
1762
  const w = c == null ? void 0 : c[f];
1731
1763
  if (!w) {
1732
- const O = n.pageIds.indexOf(f);
1733
- O !== -1 && o && (n.pageIds.splice(O, 1), delete n.pages[f]);
1734
- for (const N of n.pageIds)
1735
- N.includes(`${f}-`) && (n.pageIds.splice(n.pageIds.indexOf(N), 1), delete n.pages[N]);
1764
+ const C = n.pageIds.indexOf(f);
1765
+ C !== -1 && o && (n.pageIds.splice(C, 1), delete n.pages[f]);
1766
+ for (const L of n.pageIds)
1767
+ L.includes(`${f}-`) && (n.pageIds.splice(n.pageIds.indexOf(L), 1), delete n.pages[L]);
1736
1768
  S.info("delete main route page", f);
1737
1769
  continue;
1738
1770
  }
1739
1771
  if (l.includes("-") && !(d != null && d[l])) {
1740
- const O = n.pageIds.indexOf(l);
1741
- O !== -1 && o && (n.pageIds.splice(O, 1), delete n.pages[l]), S.info("delete page", l);
1772
+ const C = n.pageIds.indexOf(l);
1773
+ C !== -1 && o && (n.pageIds.splice(C, 1), delete n.pages[l]), S.info("delete page", l);
1742
1774
  continue;
1743
1775
  }
1744
1776
  if (!w.displayTemplateId) {
@@ -1752,7 +1784,7 @@ async function ot(e, n, {
1752
1784
  }
1753
1785
  if (n.pageIds.includes(l)) {
1754
1786
  if (S.info("has need update page", l), s === "replace")
1755
- n.pages[l] = xe({
1787
+ n.pages[l] = je({
1756
1788
  page: D,
1757
1789
  route: w,
1758
1790
  state: e,
@@ -1760,8 +1792,8 @@ async function ot(e, n, {
1760
1792
  routePathInfo: d == null ? void 0 : d[l]
1761
1793
  }), S.info("replace page", l);
1762
1794
  else if (s === "byUpdateTime") {
1763
- const O = n.pages[w.id];
1764
- (!O || w.updatedAt && w.updatedAt > O.updatedAt) && (n.pages[l] = xe({
1795
+ const C = n.pages[w.id];
1796
+ (!C || w.updatedAt && w.updatedAt > C.updatedAt) && (n.pages[l] = je({
1765
1797
  page: D,
1766
1798
  route: w,
1767
1799
  state: e,
@@ -1770,7 +1802,7 @@ async function ot(e, n, {
1770
1802
  }), S.info("replace page by update time", l));
1771
1803
  }
1772
1804
  } else
1773
- n.pageIds.push(l), n.pages[l] = xe({
1805
+ n.pageIds.push(l), n.pages[l] = je({
1774
1806
  page: D,
1775
1807
  route: w,
1776
1808
  state: e,
@@ -1809,14 +1841,14 @@ async function ot(e, n, {
1809
1841
  n.routeIds.push(d.id), n.routes[d.id] = d;
1810
1842
  }
1811
1843
  }
1812
- if (n.supportedLocales.splice(0, n.supportedLocales.length), n.supportedLocales.push(...ns(u)), o)
1844
+ if (n.supportedLocales.splice(0, n.supportedLocales.length), n.supportedLocales.push(...os(u)), o)
1813
1845
  for (const m of Object.keys(n.components))
1814
1846
  delete n.components[m];
1815
1847
  let y = JSON.parse(JSON.stringify(e.components));
1816
1848
  y = Object.fromEntries(
1817
1849
  await Promise.all(
1818
1850
  Object.entries(y).map(async ([m, d]) => {
1819
- const l = await wt(d == null ? void 0 : d.data);
1851
+ const l = await Et(d == null ? void 0 : d.data);
1820
1852
  return [
1821
1853
  m,
1822
1854
  {
@@ -1826,12 +1858,12 @@ async function ot(e, n, {
1826
1858
  ];
1827
1859
  })
1828
1860
  )
1829
- ), Object.assign(n.components, y), Object.assign(n.config, JSON.parse(JSON.stringify(e.config))), n.resources.components = JSON.parse(JSON.stringify(e.resources.components || {}));
1861
+ ), Object.assign(n.components, y), Object.assign(n.config, JSON.parse(JSON.stringify(e.config))), dt(e.resources.components) || (n.resources.components = JSON.parse(JSON.stringify(e.resources.components || {})));
1830
1862
  }
1831
- const wt = Be(
1863
+ const Et = Be(
1832
1864
  async (e) => {
1833
1865
  var n;
1834
- if (!os(e == null ? void 0 : e.properties))
1866
+ if (!dt(e == null ? void 0 : e.properties))
1835
1867
  return e;
1836
1868
  if (((n = e == null ? void 0 : e.renderer) == null ? void 0 : n.type) === "react-component") {
1837
1869
  const { script: t } = (e == null ? void 0 : e.renderer) || {};
@@ -1853,9 +1885,9 @@ const wt = Be(
1853
1885
  {
1854
1886
  keyGenerator: (e) => {
1855
1887
  var c, u, y, m;
1856
- const n = (e == null ? void 0 : e.id) || "", t = (e == null ? void 0 : e.name) || "", s = ((c = e == null ? void 0 : e.renderer) == null ? void 0 : c.type) || "", o = (e == null ? void 0 : e.properties) || {}, r = (e == null ? void 0 : e.updatedAt) || "", a = Z("md5").update(JSON.stringify(o)).digest("hex");
1888
+ const n = (e == null ? void 0 : e.id) || "", t = (e == null ? void 0 : e.name) || "", s = ((c = e == null ? void 0 : e.renderer) == null ? void 0 : c.type) || "", o = (e == null ? void 0 : e.properties) || {}, r = (e == null ? void 0 : e.updatedAt) || "", a = te("md5").update(JSON.stringify(o)).digest("hex");
1857
1889
  let i = "", p = "";
1858
- return ((u = e == null ? void 0 : e.renderer) == null ? void 0 : u.type) === "react-component" && (i = Z("md5").update(((y = e == null ? void 0 : e.renderer) == null ? void 0 : y.script) || "").digest("hex"), p = Z("md5").update(((m = e == null ? void 0 : e.renderer) == null ? void 0 : m.editComponent) || "").digest("hex")), JSON.stringify([
1890
+ return ((u = e == null ? void 0 : e.renderer) == null ? void 0 : u.type) === "react-component" && (i = te("md5").update(((y = e == null ? void 0 : e.renderer) == null ? void 0 : y.script) || "").digest("hex"), p = te("md5").update(((m = e == null ? void 0 : e.renderer) == null ? void 0 : m.editComponent) || "").digest("hex")), JSON.stringify([
1859
1891
  "checkPropertiesFromCode",
1860
1892
  n,
1861
1893
  t,
@@ -1873,21 +1905,21 @@ const wt = Be(
1873
1905
  subdir: "checkPropertiesFromCode"
1874
1906
  }
1875
1907
  );
1876
- let Oe, re, Te, Pe, He;
1877
- function Et() {
1908
+ let Oe, ie, Te, Pe, He;
1909
+ function It() {
1878
1910
  return Oe = (async () => {
1879
- const e = Jt({
1911
+ const e = zt({
1880
1912
  types: [
1881
- { did: ht, type: et },
1913
+ { did: gt, type: et },
1882
1914
  { did: Js, type: et }
1883
1915
  ]
1884
1916
  });
1885
- re = (await Promise.all(
1917
+ ie = (await Promise.all(
1886
1918
  e.map(async (t) => {
1887
- const s = t.path ? await St(t.path, { importAssets: !1 }) : void 0;
1919
+ const s = t.path ? await wt(t.path, { importAssets: !1 }) : void 0;
1888
1920
  return s ? { blockletId: t.did, state: s, blockletTitle: t.title } : void 0;
1889
1921
  })
1890
- )).filter((t) => !!t), Te = re.reduce(
1922
+ )).filter((t) => !!t), Te = ie.reduce(
1891
1923
  (t, s) => Object.assign(
1892
1924
  t,
1893
1925
  Object.fromEntries(
@@ -1896,7 +1928,7 @@ function Et() {
1896
1928
  ),
1897
1929
  {}
1898
1930
  );
1899
- const n = re.reduce(
1931
+ const n = ie.reduce(
1900
1932
  (t, s) => Object.assign(
1901
1933
  t,
1902
1934
  Object.fromEntries(
@@ -1908,7 +1940,7 @@ function Et() {
1908
1940
  Pe = Object.fromEntries(
1909
1941
  await Promise.all(
1910
1942
  Object.entries(n).map(async ([t, s]) => {
1911
- const o = await wt(s.component);
1943
+ const o = await Et(s.component);
1912
1944
  return [
1913
1945
  t,
1914
1946
  {
@@ -1918,16 +1950,16 @@ function Et() {
1918
1950
  ];
1919
1951
  })
1920
1952
  )
1921
- ), He = re.reduce((t, s) => Object.assign(t, s.state.chunks), {});
1953
+ ), He = ie.reduce((t, s) => Object.assign(t, s.state.chunks), {});
1922
1954
  })(), Oe;
1923
1955
  }
1924
1956
  function rn(e) {
1925
1957
  const n = pt(
1926
1958
  async () => {
1927
- await Et().catch((t) => {
1959
+ await It().catch((t) => {
1928
1960
  S.error("load resource states error", { error: t });
1929
1961
  }), await (e == null ? void 0 : e({
1930
- states: re,
1962
+ states: ie,
1931
1963
  pages: Te,
1932
1964
  components: Pe,
1933
1965
  chunks: He
@@ -1941,11 +1973,11 @@ function rn(e) {
1941
1973
  I.events.off(I.Events.componentAdded, n), I.events.off(I.Events.componentRemoved, n), I.events.off(I.Events.componentStarted, n), I.events.off(I.Events.componentStopped, n), I.events.off(I.Events.componentUpdated, n), I.events.off(_e, n);
1942
1974
  };
1943
1975
  }
1944
- const It = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), Se = globalThis;
1976
+ const bt = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), Se = globalThis;
1945
1977
  var rt;
1946
- (rt = Se[It]) == null || rt.call(Se);
1947
- Se[It] = rn(async ({ pages: e, components: n }) => {
1948
- const { projectIds: t } = Y;
1978
+ (rt = Se[bt]) == null || rt.call(Se);
1979
+ Se[bt] = rn(async ({ pages: e, components: n }) => {
1980
+ const { projectIds: t } = q;
1949
1981
  S.info(`start update resource states projects(${t.length})`, t), await Promise.race([
1950
1982
  new Promise((s) => {
1951
1983
  setTimeout(() => {
@@ -1954,7 +1986,7 @@ Se[It] = rn(async ({ pages: e, components: n }) => {
1954
1986
  }),
1955
1987
  Promise.all(
1956
1988
  t.map(async (s) => {
1957
- bt({
1989
+ At({
1958
1990
  projectId: s,
1959
1991
  pages: e,
1960
1992
  components: n
@@ -1965,28 +1997,28 @@ Se[It] = rn(async ({ pages: e, components: n }) => {
1965
1997
  S.error("update resource states failed:", s);
1966
1998
  });
1967
1999
  });
1968
- Y.startPeriodicCheck();
2000
+ q.startPeriodicCheck();
1969
2001
  process.on("beforeExit", () => {
1970
- Y.stopPeriodicCheck();
2002
+ q.stopPeriodicCheck();
1971
2003
  });
1972
2004
  process.on("SIGINT", () => {
1973
- Y.stopPeriodicCheck(), process.exit(0);
2005
+ q.stopPeriodicCheck(), process.exit(0);
1974
2006
  });
1975
2007
  process.on("SIGTERM", () => {
1976
- Y.stopPeriodicCheck(), process.exit(0);
2008
+ q.stopPeriodicCheck(), process.exit(0);
1977
2009
  });
1978
- async function bt({
2010
+ async function At({
1979
2011
  projectId: e,
1980
2012
  pages: n,
1981
2013
  components: t
1982
2014
  }) {
1983
- const s = Y.sharedInstances[e];
2015
+ const s = q.sharedInstances[e];
1984
2016
  if (!s) {
1985
2017
  S.info(`projectId: ${e} not found in sharedInstances`);
1986
2018
  return;
1987
2019
  }
1988
2020
  s.syncedStore.resources.pages = n;
1989
- const o = await ee.findByPk(e);
2021
+ const o = await se.findByPk(e);
1990
2022
  if (o != null && o.useAllResources)
1991
2023
  s.syncedStore.resources.components = t;
1992
2024
  else {
@@ -2006,20 +2038,20 @@ async function no() {
2006
2038
  async function Ve({
2007
2039
  ensureLoaded: e = !0
2008
2040
  } = {}) {
2009
- return e && (Oe ?? (Oe = Et()), await Oe), { states: re, pages: Te, components: Pe, chunks: He };
2041
+ return e && (Oe ?? (Oe = It()), await Oe), { states: ie, pages: Te, components: Pe, chunks: He };
2010
2042
  }
2011
2043
  export {
2012
- ht as C,
2044
+ gt as C,
2013
2045
  Ze as G,
2014
- ee as P,
2046
+ se as P,
2015
2047
  et as R,
2016
- Y as S,
2048
+ q as S,
2017
2049
  Xn as a,
2018
2050
  Ve as b,
2019
2051
  Ls as c,
2020
2052
  _s as d,
2021
- $s as e,
2022
- Ms as f,
2053
+ Ms as e,
2054
+ $s as f,
2023
2055
  Zn as g,
2024
2056
  Us as h,
2025
2057
  Qn as i,
@@ -2027,14 +2059,14 @@ export {
2027
2059
  eo as k,
2028
2060
  S as l,
2029
2061
  Hs as m,
2030
- je as n,
2031
- le as o,
2062
+ xe as n,
2063
+ de as o,
2032
2064
  to as p,
2033
2065
  so as q,
2034
2066
  sn as r,
2035
2067
  nn as s,
2036
2068
  on as t,
2037
- St as u,
2069
+ wt as u,
2038
2070
  ot as v,
2039
2071
  rn as w,
2040
2072
  no as x