@blocklet/pages-kit-inner-components 0.5.47 → 0.5.48

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 (35) hide show
  1. package/lib/cjs/add-component.js +19 -19
  2. package/lib/cjs/chunks/{array-Cip5uTnI.js → array-BqHuYyfx.js} +1 -1
  3. package/lib/cjs/chunks/{config-string-CEipCOnU.js → config-string-4bVR9Vc8.js} +1 -1
  4. package/lib/cjs/chunks/{draft-data-F0V4PcIs.js → draft-data-CuZfaQ4s.js} +1 -1
  5. package/lib/cjs/chunks/{home-BCFoaIEZ.js → home-CQTuGad2.js} +3 -3
  6. package/lib/cjs/chunks/{publish-button-Bbd4z1_d.js → publish-button-1xmfwN7o.js} +1 -1
  7. package/lib/cjs/chunks/site-state-BtZ8o3J2.js +57 -0
  8. package/lib/cjs/chunks/state-BVdbNJCA.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 +2 -2
  12. package/lib/cjs/project-html.js +1 -1
  13. package/lib/cjs/resources.js +1 -1
  14. package/lib/cjs/setting.js +3 -3
  15. package/lib/cjs/site-state.js +1 -1
  16. package/lib/cjs/theme.js +1 -1
  17. package/lib/es/add-component.js +18 -17
  18. package/lib/es/chunks/{array-DM0x2Sjw.js → array-c6HYTLze.js} +1 -1
  19. package/lib/es/chunks/{config-string-Dw6sJMn_.js → config-string-WMpFf-7V.js} +1 -1
  20. package/lib/es/chunks/{draft-data-sTSk4UTm.js → draft-data-CWM--ooz.js} +1 -1
  21. package/lib/es/chunks/{home-ClxOpmCx.js → home-DQjaiv2F.js} +4 -4
  22. package/lib/es/chunks/{publish-button-CKXdANG9.js → publish-button-wYeS7m-g.js} +3 -3
  23. package/lib/es/chunks/{site-state-BeEHvakk.js → site-state-D-moj9fA.js} +527 -550
  24. package/lib/es/chunks/{state-COB6reM7.js → state-l--dTdHq.js} +87 -88
  25. package/lib/es/components.js +1 -1
  26. package/lib/es/home.js +3 -3
  27. package/lib/es/locales.js +2 -2
  28. package/lib/es/project-html.js +1 -1
  29. package/lib/es/resources.js +1 -1
  30. package/lib/es/setting.js +94 -93
  31. package/lib/es/site-state.js +6 -5
  32. package/lib/es/theme.js +34 -34
  33. package/package.json +3 -3
  34. package/lib/cjs/chunks/site-state-CeQEnrvX.js +0 -57
  35. package/lib/cjs/chunks/state-UwRWAZRe.js +0 -1
@@ -1,51 +1,52 @@
1
1
  var Pt = Object.defineProperty;
2
2
  var Tt = (e, n, t) => n in e ? Pt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var x = (e, n, t) => Tt(e, typeof n != "symbol" ? n + "" : n, t);
3
+ var D = (e, n, t) => Tt(e, typeof n != "symbol" ? n + "" : n, t);
4
4
  import { getComponentMountPoint as vt } from "@blocklet/pages-kit/builtin/utils";
5
5
  import { PreloadComponentScriptModule as ye } from "@blocklet/pages-kit/types";
6
- import { componentUMDName as kt, RenderNestedComponent as ze, mergeComponent as Dt, getComponentDependencies as xt } from "@blocklet/pages-kit/utils/property";
6
+ import { componentUMDName as kt, RenderNestedComponent as Ke, mergeComponent as Dt, getComponentDependencies as xt } from "@blocklet/pages-kit/utils/property";
7
7
  import { memoize as it, Sandbox as ct, BuiltinModules as Rt } from "@blocklet/quickjs";
8
8
  import I from "@blocklet/sdk/lib/config";
9
9
  import { LRUCache as Pe } from "lru-cache";
10
10
  import jt, { Headers as $t } from "node-fetch";
11
- import { joinURL as Q, getQuery as Lt, withQuery as Nt, parseURL as We, withHttps as _t } from "ufo";
12
- import { createHash as ne } from "crypto";
11
+ import { joinURL as Y, getQuery as Lt, withQuery as Nt, parseURL as ze, withHttps as _t } from "ufo";
12
+ import { createHash as se } from "crypto";
13
13
  import Mt from "@blocklet/logger";
14
- import { promises as z, readFileSync as ae, mkdtempSync as Ut, existsSync as K, lstatSync as re, readdirSync as Ft, rmSync as lt, renameSync as Ye, mkdirSync as Y, writeFileSync as we, copyFileSync as Bt, createWriteStream as Gt } from "fs";
15
- import pt, { join as O, dirname as H, basename as J } from "path";
14
+ import { promises as V, readFileSync as re, mkdtempSync as Ut, existsSync as J, lstatSync as oe, readdirSync as Ft, rmSync as pt, renameSync as We, mkdirSync as W, writeFileSync as we, copyFileSync as Bt, createWriteStream as Gt } from "fs";
15
+ import lt, { join as A, dirname as F, basename as B } from "path";
16
16
  import Ht from "lodash/isNil";
17
17
  import { BuiltinModules as Jt } from "@blocklet/pages-kit/utils/builtin";
18
18
  import { isRelativeModule as Vt, createBuiltinModuleTransformer as Kt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
19
19
  import { getResources as zt, getComponentWebEndpoint as Wt, call as Yt } from "@blocklet/sdk/lib/component";
20
- import qt from "autoprefixer";
21
- import * as Qt from "esbuild";
20
+ import Qt from "autoprefixer";
21
+ import * as qt from "esbuild";
22
22
  import Xt from "postcss";
23
23
  import Zt from "tailwindcss";
24
- import U from "typescript";
25
- import { getYjsValue as le, syncedStore as es } from "@syncedstore/core";
26
- import * as W from "yjs";
24
+ import M from "typescript";
25
+ import { getYjsValue as ce, syncedStore as es } from "@syncedstore/core";
26
+ import * as K from "yjs";
27
27
  import { setPageDataSource as ts } from "@blocklet/pages-kit/utils/data-source";
28
- import { getRouteMetaDataByOptionIds as ss, generateParamCombinations as Fe } from "@blocklet/pages-kit/utils/route";
28
+ import { getRouteMetaDataByOptionIds as ss, generateParamCombinations as Ue } from "@blocklet/pages-kit/utils/route";
29
29
  import { cloneDeep as ns } from "lodash";
30
- import { reactive as os } from "@reactivedata/reactive";
31
- import { globSync as Ne } from "glob";
30
+ import { nextId as Ye } from "@blocklet/pages-kit/utils/common";
31
+ import { unzipSection as os } from "@blocklet/pages-kit/utils/page-model";
32
+ import { reactive as rs } from "@reactivedata/reactive";
33
+ import { globSync as Le } from "glob";
32
34
  import * as Re from "lib0/decoding";
33
35
  import * as j from "lib0/encoding";
34
- import rs from "lodash/cloneDeep";
36
+ import as from "lodash/cloneDeep";
35
37
  import dt from "lodash/debounce";
36
- import Be from "lodash/get";
38
+ import Fe from "lodash/get";
37
39
  import ut from "lodash/isEmpty";
38
- import as from "lodash/pick";
39
- import qe from "lodash/set";
40
- import is from "lodash/union";
41
- import { customAlphabet as cs } from "nanoid";
42
- import ls from "p-limit";
43
- import { pipeline as ps } from "stream/promises";
40
+ import is from "lodash/pick";
41
+ import Qe from "lodash/set";
42
+ import cs from "lodash/union";
43
+ import ps from "p-limit";
44
+ import { pipeline as ls } from "stream/promises";
44
45
  import { x as ds } from "tar";
45
46
  import us from "wait-on";
46
- import { Awareness as fs, encodeAwarenessUpdate as Qe, removeAwarenessStates as ms, applyAwarenessUpdate as hs } from "y-protocols/awareness";
47
+ import { Awareness as fs, encodeAwarenessUpdate as qe, removeAwarenessStates as ms, applyAwarenessUpdate as hs } from "y-protocols/awareness";
47
48
  import { writeUpdate as gs, writeSyncStep1 as ys, readSyncMessage as Ss } from "y-protocols/sync";
48
- import * as ie from "yaml";
49
+ import * as ae from "yaml";
49
50
  import { DataTypes as R, Sequelize as ws, Model as ft, Op as Es } from "sequelize";
50
51
  import "sqlite3";
51
52
  import "@blocklet/pages-kit/types/state";
@@ -54,16 +55,16 @@ I.env.OPENAI_API_KEY || process.env.OPENAI_API_KEY;
54
55
  I.env.OPENAI_BASE_URL || process.env.OPENAI_BASE_URL;
55
56
  I.env.TRANSLATE_ADDITIONAL_PROMPT || process.env.TRANSLATE_ADDITIONAL_PROMPT;
56
57
  I.env.PAGE_CONTENT_ADDITIONAL_PROMPT || process.env.PAGE_CONTENT_ADDITIONAL_PROMPT;
57
- const bs = "image-bin";
58
+ const Is = "image-bin";
58
59
  I.env.INIT_TEMPLATE_PATH;
59
- const Is = process.env.DATABASE_URL || pt.join(I.env.dataDir, "db/pages-kit.db"), Xe = I, eo = () => I.env.tenantMode === "multiple", to = () => {
60
+ const bs = process.env.DATABASE_URL || lt.join(I.env.dataDir, "db/pages-kit.db"), Xe = I, to = () => I.env.tenantMode === "multiple", so = () => {
60
61
  var e;
61
62
  return (Ht(Xe.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (e = Xe.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : e.split(",")) || [];
62
- }, As = pt.join(I.env.dataDir, "fs-memoize-cache"), Os = I.env.FS_MEMOIZE_CACHE_VERSION || "v1.0.0", y = Mt("pages-kit"), Cs = R.sqlite.DATE.parse;
63
+ }, As = lt.join(I.env.dataDir, "fs-memoize-cache"), Os = I.env.FS_MEMOIZE_CACHE_VERSION || "v1.0.0", y = Mt("pages-kit"), Cs = R.sqlite.DATE.parse;
63
64
  R.sqlite.DATE.parse = (e, n) => typeof e == "number" ? new Date(e) : Cs(e, n);
64
65
  const me = new ws({
65
66
  dialect: "sqlite",
66
- storage: Is,
67
+ storage: bs,
67
68
  benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
68
69
  retry: {
69
70
  match: [/SQLITE_BUSY/],
@@ -99,16 +100,16 @@ Te.init(
99
100
  },
100
101
  { sequelize: me, tableName: "ProjectComponents", timestamps: !1 }
101
102
  );
102
- class X extends ft {
103
+ class Q extends ft {
103
104
  static async getProjectByIdOrSlug(n) {
104
- return X.findOne({
105
+ return Q.findOne({
105
106
  where: {
106
107
  [Es.or]: [{ id: n }, { slug: n }]
107
108
  }
108
109
  });
109
110
  }
110
111
  }
111
- X.init(
112
+ Q.init(
112
113
  {
113
114
  id: {
114
115
  type: R.UUID,
@@ -149,36 +150,36 @@ X.init(
149
150
  },
150
151
  { sequelize: me, paranoid: !0 }
151
152
  );
152
- X.hasMany(Te, {
153
+ Q.hasMany(Te, {
153
154
  foreignKey: "projectId",
154
155
  as: "components"
155
156
  });
156
- const Ps = As, Ts = Os, _e = 7 * 24 * 60 * 60 * 1e3, vs = 24 * 60 * 60 * 1e3, mt = async (e = "") => {
157
- const n = O(Ps, e);
157
+ const Ps = As, Ts = Os, Ne = 7 * 24 * 60 * 60 * 1e3, vs = 24 * 60 * 60 * 1e3, mt = async (e = "") => {
158
+ const n = A(Ps, e);
158
159
  try {
159
- if (!(await z.stat(n)).isDirectory())
160
+ if (!(await V.stat(n)).isDirectory())
160
161
  throw new Error(`${n} is not a directory`);
161
162
  } catch {
162
- await z.mkdir(n, { recursive: !0 });
163
+ await V.mkdir(n, { recursive: !0 });
163
164
  }
164
165
  return n;
165
166
  }, ks = (e, n) => {
166
- const t = ne("md5").update(n).digest("hex");
167
- return O(e, `${Ts}-${t}.json`);
167
+ const t = se("md5").update(n).digest("hex");
168
+ return A(e, `${Ts}-${t}.json`);
168
169
  }, Ds = async (e = "") => {
169
170
  const n = await mt(e), t = Date.now();
170
171
  try {
171
- const s = await z.readdir(n);
172
+ const s = await V.readdir(n);
172
173
  await Promise.all(
173
174
  s.filter((o) => o.endsWith(".json")).map(async (o) => {
174
- const r = O(n, o);
175
+ const r = A(n, o);
175
176
  try {
176
- const a = await z.readFile(r, "utf-8"), u = JSON.parse(a);
177
- u.createdAt && t - u.createdAt > _e && await z.unlink(r);
177
+ const a = await V.readFile(r, "utf-8"), u = JSON.parse(a);
178
+ u.createdAt && t - u.createdAt > Ne && await V.unlink(r);
178
179
  } catch {
179
180
  try {
180
- const u = await z.stat(r);
181
- t - u.mtimeMs > _e && await z.unlink(r);
181
+ const u = await V.stat(r);
182
+ t - u.mtimeMs > Ne && await V.unlink(r);
182
183
  } catch {
183
184
  }
184
185
  }
@@ -195,20 +196,20 @@ const Ps = As, Ts = Os, _e = 7 * 24 * 60 * 60 * 1e3, vs = 24 * 60 * 60 * 1e3, mt
195
196
  e.add(s);
196
197
  };
197
198
  })();
198
- function Ge(e, n) {
199
+ function Be(e, n) {
199
200
  return n.subdir && xs(n.subdir), it(
200
201
  async (...s) => {
201
202
  const o = await mt(n.subdir || ""), r = n.keyGenerator ? n.keyGenerator(...s) : JSON.stringify(s), a = ks(o, r);
202
203
  try {
203
- const u = await z.readFile(a, "utf-8"), { value: c, createdAt: i } = JSON.parse(u);
204
- if (i && Date.now() - i > _e)
205
- throw await z.unlink(a).catch(() => {
204
+ const u = await V.readFile(a, "utf-8"), { value: c, createdAt: i } = JSON.parse(u);
205
+ if (i && Date.now() - i > Ne)
206
+ throw await V.unlink(a).catch(() => {
206
207
  }), new Error("Cache expired");
207
208
  return c;
208
209
  } catch {
209
210
  const c = await e(...s), i = JSON.stringify({ value: c, createdAt: Date.now() });
210
- return z.writeFile(a, i, "utf-8").catch((p) => {
211
- console.error("Failed to write fs cache:", p);
211
+ return V.writeFile(a, i, "utf-8").catch((l) => {
212
+ console.error("Failed to write fs cache:", l);
212
213
  }), c;
213
214
  }
214
215
  },
@@ -224,7 +225,7 @@ const Rs = async (e, { componentId: n }) => {
224
225
  `, s = `.CustomComponent_${n}`;
225
226
  return (await Xt([
226
227
  Zt({ content: [{ raw: e, extension: "tsx" }] }),
227
- qt({
228
+ Qt({
228
229
  overrideBrowserslist: ["> 1%", "last 2 versions"],
229
230
  stats: {}
230
231
  }),
@@ -242,32 +243,32 @@ const Rs = async (e, { componentId: n }) => {
242
243
 
243
244
  ${e}
244
245
  `;
245
- }, Ze = Ge(
246
+ }, Ze = Be(
246
247
  async (e, n) => {
247
- let t = U.transpileModule(e, {
248
+ let t = M.transpileModule(e, {
248
249
  compilerOptions: {
249
- jsx: U.JsxEmit.React,
250
- target: U.ScriptTarget.ES2016,
251
- module: U.ModuleKind.ESNext
250
+ jsx: M.JsxEmit.React,
251
+ target: M.ScriptTarget.ES2016,
252
+ module: M.ModuleKind.ESNext
252
253
  },
253
254
  transformers: {
254
- before: [Kt(U)]
255
+ before: [Kt(M)]
255
256
  }
256
257
  }).outputText;
257
258
  if (n.tailwind && (t = await js(t, { componentId: n.componentId })), n.module === ye.ESM) return t;
258
- const s = U.transpileModule(t, {
259
+ const s = M.transpileModule(t, {
259
260
  compilerOptions: {
260
- jsx: U.JsxEmit.React,
261
- target: U.ScriptTarget.ES2016,
262
- module: U.ModuleKind.CommonJS,
263
- moduleResolution: U.ModuleResolutionKind.Node16
261
+ jsx: M.JsxEmit.React,
262
+ target: M.ScriptTarget.ES2016,
263
+ module: M.ModuleKind.CommonJS,
264
+ moduleResolution: M.ModuleResolutionKind.Node16
264
265
  }
265
266
  }).outputText;
266
267
  return n.module === ye.CJS ? s : Ls(n.moduleName, s);
267
268
  },
268
269
  {
269
270
  keyGenerator: (e, n) => {
270
- const t = ne("md5").update(e).digest("hex"), s = {
271
+ const t = se("md5").update(e).digest("hex"), s = {
271
272
  ...n,
272
273
  componentId: n.componentId,
273
274
  module: n.module,
@@ -286,7 +287,7 @@ ${e}
286
287
  }
287
288
  ), $s = async (e, n) => {
288
289
  var a, u;
289
- const s = (u = (a = (await Qt.build({
290
+ const s = (u = (a = (await qt.build({
290
291
  entryPoints: ["index.tsx"],
291
292
  external: Object.keys(Jt),
292
293
  format: "esm",
@@ -298,17 +299,17 @@ ${e}
298
299
  name: "vfs",
299
300
  setup(c) {
300
301
  let i = null;
301
- c.onResolve({ filter: /.*/ }, (p) => p.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : p.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : null), c.onLoad({ filter: /.*/, namespace: "vfs" }, async (p) => {
302
+ c.onResolve({ filter: /.*/ }, (l) => l.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : l.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : null), c.onLoad({ filter: /.*/, namespace: "vfs" }, async (l) => {
302
303
  var S;
303
- if (p.path === "index.tsx")
304
+ if (l.path === "index.tsx")
304
305
  return { contents: `export { ${n} } from './component'`, loader: "tsx" };
305
- if (p.path === "component.tsx")
306
+ if (l.path === "component.tsx")
306
307
  return { contents: e, loader: "tsx" };
307
- if (Vt(p.path)) {
308
- const f = p.path.split("/").pop();
309
- if (i || (i = await Ve({ ensureLoaded: !1 })), (S = i == null ? void 0 : i.chunks) != null && S[f])
308
+ if (Vt(l.path)) {
309
+ const f = l.path.split("/").pop();
310
+ if (i || (i = await Je({ ensureLoaded: !1 })), (S = i == null ? void 0 : i.chunks) != null && S[f])
310
311
  try {
311
- const d = ae(i.chunks[f], "utf-8");
312
+ const d = re(i.chunks[f], "utf-8");
312
313
  return y.info("get chunk from local file system", f), { contents: d, loader: "tsx" };
313
314
  } catch {
314
315
  }
@@ -321,10 +322,10 @@ ${e}
321
322
  })).outputFiles) == null ? void 0 : a[0]) == null ? void 0 : u.contents;
322
323
  if (!s) throw new Error("Failed to build server code");
323
324
  const o = Buffer.from(s).toString();
324
- return U.transpileModule(o, {
325
- compilerOptions: { module: U.ModuleKind.ESNext, target: U.ScriptTarget.ES2020 }
325
+ return M.transpileModule(o, {
326
+ compilerOptions: { module: M.ModuleKind.ESNext, target: M.ScriptTarget.ES2020 }
326
327
  }).outputText;
327
- }, ht = Ge(
328
+ }, ht = Be(
328
329
  async (e, n) => {
329
330
  const t = await $s(e, n);
330
331
  return new RegExp(
@@ -334,7 +335,7 @@ ${e}
334
335
  },
335
336
  {
336
337
  keyGenerator: (e, n) => {
337
- const t = ne("md5").update(e).digest("hex");
338
+ const t = se("md5").update(e).digest("hex");
338
339
  return JSON.stringify(["extractExportValueSchema", t, n]);
339
340
  },
340
341
  lruOptions: {
@@ -388,7 +389,7 @@ function Us({
388
389
  }) {
389
390
  return ["getPreloadComponents", e, n, t, s].join("-");
390
391
  }
391
- async function so({
392
+ async function no({
392
393
  mode: e,
393
394
  req: n,
394
395
  state: t,
@@ -404,14 +405,14 @@ async function so({
404
405
  const c = (await Promise.all(
405
406
  o.map(async (d) => {
406
407
  try {
407
- const l = Us({
408
+ const p = Us({
408
409
  mode: e,
409
410
  instanceId: d.id,
410
411
  componentId: d.componentId,
411
412
  locale: s
412
413
  });
413
- if (e !== "draft" && d.useCache && ue.has(l))
414
- return y.info(`get preload component from cache: ${l}`), ue.get(l);
414
+ if (e !== "draft" && d.useCache && ue.has(p))
415
+ return y.info(`get preload component from cache: ${p}`), ue.get(p);
415
416
  const m = Ee({ state: t, componentId: d.componentId });
416
417
  if (!m) return null;
417
418
  const w = await Fs({
@@ -423,47 +424,47 @@ async function so({
423
424
  properties: d.properties
424
425
  });
425
426
  if (!w) return null;
426
- const D = { instanceId: d.id, preload: w };
427
+ const k = { instanceId: d.id, preload: w };
427
428
  if (e !== "draft" && d.useCache) {
428
- let P = Ns;
429
- d.cacheDuration && (P = d.cacheDuration), y.info(`set preload component to cache(${P}s): ${l}`), ue.set(l, D, {
430
- ttl: P * 1e3
429
+ let O = Ns;
430
+ d.cacheDuration && (O = d.cacheDuration), y.info(`set preload component to cache(${O}s): ${p}`), ue.set(p, k, {
431
+ ttl: O * 1e3
431
432
  });
432
433
  }
433
- return D;
434
- } catch (l) {
435
- return y.error("get preload component error", { instanceId: d.id, componentId: d.componentId }, { error: l }), null;
434
+ return k;
435
+ } catch (p) {
436
+ return y.error("get preload component error", { instanceId: d.id, componentId: d.componentId }, { error: p }), null;
436
437
  }
437
438
  })
438
439
  )).filter((d) => !!d), i = Object.values(
439
- c.reduce((d, l) => ({ ...d, ...l.preload.components }), {})
440
+ c.reduce((d, p) => ({ ...d, ...p.preload.components }), {})
440
441
  );
441
- async function p() {
442
+ async function l() {
442
443
  const d = await Promise.all(
443
- i.map(async (l) => {
444
- const m = kt({ componentId: l.component.id }), w = r === ye.ESM ? {
444
+ i.map(async (p) => {
445
+ const m = kt({ componentId: p.component.id }), w = r === ye.ESM ? {
445
446
  module: r,
446
- script: await Ze(l.script, {
447
- componentId: l.component.id,
447
+ script: await Ze(p.script, {
448
+ componentId: p.component.id,
448
449
  module: r,
449
450
  tailwind: e !== "draft"
450
451
  })
451
452
  } : {
452
453
  module: r,
453
- script: await Ze(l.script, {
454
- componentId: l.component.id,
454
+ script: await Ze(p.script, {
455
+ componentId: p.component.id,
455
456
  module: r,
456
457
  moduleName: m,
457
458
  tailwind: e !== "draft"
458
459
  }),
459
460
  moduleName: m
460
461
  };
461
- return [l.component.id, { component: l.component, script: w }];
462
+ return [p.component.id, { component: p.component, script: w }];
462
463
  })
463
464
  );
464
465
  return Object.fromEntries(d);
465
466
  }
466
- const S = await p();
467
+ const S = await l();
467
468
  return {
468
469
  config: { defaultLocale: u, supportedLocales: a },
469
470
  components: S,
@@ -484,7 +485,7 @@ async function Fs({
484
485
  }) {
485
486
  const { supportedLocales: a } = n, u = Ee({ state: n, componentId: t });
486
487
  if (!u) return null;
487
- const c = a.some((p) => p.locale === s) ? s : o;
488
+ const c = a.some((l) => l.locale === s) ? s : o;
488
489
  if (!c) return null;
489
490
  const i = await gt({ req: e, state: n, componentId: t, locale: c, defaultLocale: o, properties: r });
490
491
  return i ? {
@@ -511,14 +512,14 @@ async function gt({
511
512
  props: { ...c }
512
513
  };
513
514
  try {
514
- const p = await Hs({ ...u, req: e });
515
- p != null && p.props && Object.assign(i.props, p.props);
516
- } catch (p) {
517
- y.error("preload data at server side error", { componentId: s, name: u.component.name }, { error: p });
515
+ const l = await Hs({ ...u, req: e });
516
+ l != null && l.props && Object.assign(i.props, l.props);
517
+ } catch (l) {
518
+ y.error("preload data at server side error", { componentId: s, name: u.component.name }, { error: l });
518
519
  }
519
520
  return await Promise.all(
520
- Object.entries(c).map(async ([p, S]) => {
521
- if ((S == null ? void 0 : S.type) === ze) {
521
+ Object.entries(c).map(async ([l, S]) => {
522
+ if ((S == null ? void 0 : S.type) === Ke) {
522
523
  const f = await gt({
523
524
  req: e,
524
525
  depth: n + 1,
@@ -529,8 +530,8 @@ async function gt({
529
530
  properties: S.properties
530
531
  });
531
532
  f && (Object.assign(i.components, f.components), Object.assign(i.props, {
532
- [p]: {
533
- type: ze,
533
+ [l]: {
534
+ type: Ke,
534
535
  componentId: S.componentId,
535
536
  props: f.props
536
537
  }
@@ -560,7 +561,7 @@ function Ee({ state: e, componentId: n }) {
560
561
  var t, s, o;
561
562
  return ((t = e.components[n]) == null ? void 0 : t.data) ?? ((o = (s = e.resources.components) == null ? void 0 : s[n]) == null ? void 0 : o.component);
562
563
  }
563
- function no({ state: e, name: n }) {
564
+ function oo({ state: e, name: n }) {
564
565
  var s, o;
565
566
  const t = n.toLowerCase();
566
567
  return ((s = Object.values(e.components).find((r) => {
@@ -631,7 +632,7 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
631
632
  }
632
633
  },
633
634
  getComponentMountPoint: vt,
634
- joinURL: Q,
635
+ joinURL: Y,
635
636
  withQuery: Nt,
636
637
  getQuery: Lt
637
638
  },
@@ -640,18 +641,18 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
640
641
  {
641
642
  // NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
642
643
  // because the global is shared between all runtime and just init once
643
- location: { href: Q(_t(s.hostname), s.originalUrl) },
644
- fetch: (i, { ...p } = {}) => {
645
- const S = typeof i == "string" && i.startsWith("/") ? Q(I.env.appUrl, i) : i;
646
- if (typeof S == "string" && We(S).host === We(I.env.appUrl).host) {
644
+ location: { href: Y(_t(s.hostname), s.originalUrl) },
645
+ fetch: (i, { ...l } = {}) => {
646
+ const S = typeof i == "string" && i.startsWith("/") ? Y(I.env.appUrl, i) : i;
647
+ if (typeof S == "string" && ze(S).host === ze(I.env.appUrl).host) {
647
648
  const f = s.get("cookie");
648
649
  if (f) {
649
- const d = new $t(p.headers);
650
- d.set("cookie", f), p.headers = d;
650
+ const d = new $t(l.headers);
651
+ d.set("cookie", f), l.headers = d;
651
652
  }
652
653
  }
653
654
  return jt(S, {
654
- ...p,
655
+ ...l,
655
656
  timeout: et * 1e3
656
657
  }).then((f) => ({
657
658
  ok: f.ok,
@@ -692,7 +693,7 @@ const Js = it(
692
693
  },
693
694
  {
694
695
  keyGenerator: (e, n, t) => {
695
- const s = ne("md5").update(e).digest("hex");
696
+ const s = se("md5").update(e).digest("hex");
696
697
  return JSON.stringify(["getExportSchemaValueFromCode", s, n, t]);
697
698
  },
698
699
  lruOptions: {
@@ -700,32 +701,32 @@ const Js = it(
700
701
  ttl: 1e3 * 60 * 60
701
702
  }
702
703
  }
703
- ), Vs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", tt = "page", Me = "trigger-reload-project-resource", yt = Vs, Ks = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
704
- function be(e) {
704
+ ), Vs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", tt = "page", _e = "trigger-reload-project-resource", yt = Vs, Ks = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
705
+ function Ie(e) {
705
706
  e.observeDeep((n) => {
706
707
  n.some((t) => t.changes.keys.has("updatedAt") || t.changes.keys.has("publishedAt")) || e.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
707
708
  });
708
709
  }
709
710
  function St() {
710
- return Ut(O(I.env.dataDir, "tmp-"));
711
+ return Ut(A(I.env.dataDir, "tmp-"));
711
712
  }
712
- function Ie(e, n, t = []) {
713
- return Array.isArray(e) ? e.flatMap((s, o) => Ie(s, n, [...t, o])) : typeof e == "object" ? e === null ? [] : Object.entries(e).flatMap(([s, o]) => Ie(o, n, [...t, s])) : n(e) ? [t] : [];
713
+ function be(e, n, t = []) {
714
+ 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] : [];
714
715
  }
715
- function F(e) {
716
+ function U(e) {
716
717
  return e.filter((n) => n != null);
717
718
  }
718
719
  function zs(e) {
719
720
  e.pages && Object.keys(e.pages).forEach((t) => {
720
- const s = le(e.pages[t]);
721
- s && s instanceof W.Map && be(s);
721
+ const s = ce(e.pages[t]);
722
+ s && s instanceof K.Map && Ie(s);
722
723
  });
723
- const n = le(e.pages);
724
- n && n instanceof W.Map && n.observe((t) => {
724
+ const n = ce(e.pages);
725
+ n && n instanceof K.Map && n.observe((t) => {
725
726
  t.changes.keys.forEach((s, o) => {
726
727
  if (s.action === "add") {
727
- const r = le(e.pages[o]);
728
- r && r instanceof W.Map && be(r);
728
+ const r = ce(e.pages[o]);
729
+ r && r instanceof K.Map && Ie(r);
729
730
  }
730
731
  });
731
732
  });
@@ -733,16 +734,16 @@ function zs(e) {
733
734
  function Ws(e) {
734
735
  e.routes && Object.keys(e.routes).forEach((t) => {
735
736
  var o;
736
- const s = le((o = e.routes) == null ? void 0 : o[t]);
737
- s && s instanceof W.Map && be(s);
737
+ const s = ce((o = e.routes) == null ? void 0 : o[t]);
738
+ s && s instanceof K.Map && Ie(s);
738
739
  });
739
- const n = le(e.routes);
740
- n && n instanceof W.Map && n.observe((t) => {
740
+ const n = ce(e.routes);
741
+ n && n instanceof K.Map && n.observe((t) => {
741
742
  t.changes.keys.forEach((s, o) => {
742
743
  var r;
743
744
  if (s.action === "add") {
744
- const a = le((r = e.routes) == null ? void 0 : r[o]);
745
- a && a instanceof W.Map && be(a);
745
+ const a = ce((r = e.routes) == null ? void 0 : r[o]);
746
+ a && a instanceof K.Map && Ie(a);
746
747
  }
747
748
  });
748
749
  });
@@ -765,7 +766,7 @@ function Ys(e, n) {
765
766
  u && (u.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
766
767
  }
767
768
  if (!n) {
768
- const u = Fe({
769
+ const u = Ue({
769
770
  basePath: a.path,
770
771
  params: a.params,
771
772
  routeId: a.id,
@@ -788,7 +789,7 @@ function je({
788
789
  routeId: s,
789
790
  routePathInfo: o
790
791
  }) {
791
- var a, u, c, i, p, S, f, d, l;
792
+ var a, u, c, i, l, S, f, d, p;
792
793
  y.info(
793
794
  `Executing datasource data assembly, routeId: ${s}, routePathInfo: ${JSON.stringify(o)}`
794
795
  );
@@ -805,10 +806,10 @@ function je({
805
806
  if (n.dataSource) {
806
807
  let w = n.id;
807
808
  o && (w = o.paramOptionIds.join("-"));
808
- const D = ((S = (p = (i = n.dataSource.pathDataMappings) == null ? void 0 : i[w]) == null ? void 0 : p.dataCache) == null ? void 0 : S[m.locale]) ?? ((l = (d = (f = n.dataSource.pathDataMappings) == null ? void 0 : f[w]) == null ? void 0 : d.dataCache) == null ? void 0 : l[t.config.defaultLocale || "en"]);
809
- if (!D)
809
+ const k = ((S = (l = (i = n.dataSource.pathDataMappings) == null ? void 0 : i[w]) == null ? void 0 : l.dataCache) == null ? void 0 : S[m.locale]) ?? ((p = (d = (f = n.dataSource.pathDataMappings) == null ? void 0 : f[w]) == null ? void 0 : d.dataCache) == null ? void 0 : p[t.config.defaultLocale || "en"]);
810
+ if (!k)
810
811
  continue;
811
- ts(r, t, m.locale, D);
812
+ ts(r, t, m.locale, k);
812
813
  }
813
814
  o && o.routeMetaData && (o.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
814
815
  }
@@ -819,7 +820,7 @@ const Ae = new Pe({
819
820
  ttl: 10 * 60 * 1e3
820
821
  // 10 minutes
821
822
  });
822
- function qs(e, n = []) {
823
+ function Qs(e, n = []) {
823
824
  let t = 0;
824
825
  const s = Array.from(Ae.keys()), o = [];
825
826
  for (const r of e) {
@@ -839,7 +840,7 @@ function qs(e, n = []) {
839
840
  }
840
841
  return y.info(`[Cache CLEAR] cleared ${t} entries for patterns:`, o), t;
841
842
  }
842
- function Qs({
843
+ function qs({
843
844
  projectId: e,
844
845
  projectSlug: n,
845
846
  supportedLocales: t = []
@@ -859,13 +860,13 @@ function Qs({
859
860
  `[Cache CLEAR PROJECT] cleared ${s} entries for project ${e}${n ? ` (slug: ${n})` : ""}`
860
861
  ), s;
861
862
  }
862
- const { uploadToMediaKit: Xs } = require("@blocklet/uploader-server"), $e = cs("abcdefghijklmnopqrstuvwxyz0123456789", 16), He = /^\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, st = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Zs = 1e4, en = 3e4, he = 0, Le = 1, tn = 0, sn = 1, Ue = I, de = O(process.env.BLOCKLET_DATA_DIR, "site-state"), oo = ["production", "draft"], ro = ["production"];
863
+ const { uploadToMediaKit: Xs } = require("@blocklet/uploader-server"), 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, st = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Zs = 1e4, en = 3e4, he = 0, $e = 1, tn = 0, sn = 1, Me = I, de = A(process.env.BLOCKLET_DATA_DIR, "site-state"), ro = ["production", "draft"], ao = ["production"];
863
864
  function Oe(e) {
864
865
  return (e == null ? void 0 : e.replace(/\//g, "|")) || "";
865
866
  }
866
867
  function nn() {
867
868
  var t;
868
- const e = Ue.env.languages.map((s) => ({ locale: s.code, name: s.name })), n = (t = e[0]) == null ? void 0 : t.locale;
869
+ const e = Me.env.languages.map((s) => ({ locale: s.code, name: s.name })), n = (t = e[0]) == null ? void 0 : t.locale;
869
870
  return {
870
871
  pageIds: [],
871
872
  pages: {},
@@ -879,65 +880,65 @@ function nn() {
879
880
  resources: {}
880
881
  };
881
882
  }
882
- const v = class v extends W.Doc {
883
+ const T = class T extends K.Doc {
883
884
  constructor(t) {
884
885
  super();
885
- x(this, "syncedStore");
886
- x(this, "conns", /* @__PURE__ */ new Map());
887
- x(this, "awareness");
886
+ D(this, "syncedStore");
887
+ D(this, "conns", /* @__PURE__ */ new Map());
888
+ D(this, "awareness");
888
889
  // 延迟释放定时器
889
- x(this, "releaseTimer");
890
- x(this, "awarenessChangeHandler", ({ added: t, updated: s, removed: o }, r) => {
890
+ D(this, "releaseTimer");
891
+ D(this, "awarenessChangeHandler", ({ added: t, updated: s, removed: o }, r) => {
891
892
  const a = t.concat(s, o);
892
893
  if (r !== null) {
893
894
  const i = this.conns.get(r);
894
- i && (t.forEach((p) => {
895
- i.add(p);
896
- }), o.forEach((p) => {
897
- i.delete(p);
895
+ i && (t.forEach((l) => {
896
+ i.add(l);
897
+ }), o.forEach((l) => {
898
+ i.delete(l);
898
899
  }));
899
900
  }
900
901
  const u = j.createEncoder();
901
- j.writeVarUint(u, Le), j.writeVarUint8Array(u, Qe(this.awareness, a));
902
+ j.writeVarUint(u, $e), j.writeVarUint8Array(u, qe(this.awareness, a));
902
903
  const c = j.toUint8Array(u);
903
- this.conns.forEach((i, p) => this.send(p, c));
904
+ this.conns.forEach((i, l) => this.send(l, c));
904
905
  });
905
- x(this, "updateHandler", (t) => {
906
+ D(this, "updateHandler", (t) => {
906
907
  const s = j.createEncoder();
907
908
  j.writeVarUint(s, he), gs(s, t);
908
909
  const o = j.toUint8Array(s);
909
910
  this.conns.forEach((r, a) => this.send(a, o));
910
911
  });
911
- x(this, "ensureDataStructure", () => {
912
+ D(this, "ensureDataStructure", () => {
912
913
  var c;
913
914
  const { supportedLocales: t, pages: s, pageIds: o, config: r, routes: a, routeIds: u } = this.syncedStore;
914
915
  {
915
916
  const i = new Set(Object.keys(s));
916
- let p = 0;
917
- for (; p < o.length; ) {
918
- const S = o[p];
919
- i.has(S) ? (i.delete(S), p++) : o.splice(p, 1);
917
+ let l = 0;
918
+ for (; l < o.length; ) {
919
+ const S = o[l];
920
+ i.has(S) ? (i.delete(S), l++) : o.splice(l, 1);
920
921
  }
921
922
  }
922
923
  {
923
924
  const i = new Set(Object.keys(a));
924
- let p = 0;
925
- for (; p < u.length; ) {
926
- const S = u[p];
927
- i.has(S) ? (i.delete(S), p++) : u.splice(p, 1);
925
+ let l = 0;
926
+ for (; l < u.length; ) {
927
+ const S = u[l];
928
+ i.has(S) ? (i.delete(S), l++) : u.splice(l, 1);
928
929
  }
929
930
  }
930
- t.splice(0, t.length), t.push(...Ue.env.languages.map((i) => ({ locale: i.code, name: i.name }))), r.defaultLocale = (c = t[0]) == null ? void 0 : c.locale;
931
+ t.splice(0, t.length), t.push(...Me.env.languages.map((i) => ({ locale: i.code, name: i.name }))), r.defaultLocale = (c = t[0]) == null ? void 0 : c.locale;
931
932
  {
932
933
  let i = 0;
933
- const p = /* @__PURE__ */ new Set();
934
+ const l = /* @__PURE__ */ new Set();
934
935
  for (; i < t.length; ) {
935
936
  const { locale: S } = t[i];
936
- p.has(S) ? t.splice(i, 1) : (i++, p.add(S));
937
+ l.has(S) ? t.splice(i, 1) : (i++, l.add(S));
937
938
  }
938
939
  }
939
940
  });
940
- x(this, "send", (t, s) => {
941
+ D(this, "send", (t, s) => {
941
942
  t.readyState !== tn && t.readyState !== sn && this.closeConn(t);
942
943
  try {
943
944
  t.send(s, (o) => {
@@ -947,56 +948,56 @@ const v = class v extends W.Doc {
947
948
  this.closeConn(t);
948
949
  }
949
950
  });
950
- x(this, "closeConn", (t) => {
951
+ D(this, "closeConn", (t) => {
951
952
  if (t.removeAllListeners(), this.conns.has(t)) {
952
953
  const s = this.conns.get(t);
953
954
  this.conns.delete(t), s && ms(this.awareness, Array.from(s), null);
954
955
  }
955
956
  t.close(), this.checkAndScheduleRelease();
956
957
  });
957
- x(this, "autoSave", dt(() => {
958
- Y(H(this.draftYjsFilePath), { recursive: !0 }), we(this.draftYjsFilePath, W.encodeStateAsUpdate(this));
958
+ D(this, "autoSave", dt(() => {
959
+ W(F(this.draftYjsFilePath), { recursive: !0 }), we(this.draftYjsFilePath, K.encodeStateAsUpdate(this));
959
960
  }, Zs));
960
- x(this, "save", ({ flush: t = !1 } = {}) => {
961
+ D(this, "save", ({ flush: t = !1 } = {}) => {
961
962
  this.autoSave(), t && this.autoSave.flush();
962
963
  });
963
- x(this, "publish", async ({ mode: t, routes: s }) => {
964
+ D(this, "publish", async ({ mode: t, routes: s }) => {
964
965
  const o = await this.getState("draft"), r = await this.getState("production");
965
966
  await rt(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), await this.clearPageCacheForRoutes(s, r);
966
967
  });
967
- x(this, "mergeState", async (t, s) => {
968
+ D(this, "mergeState", async (t, s) => {
968
969
  var u, c, i;
969
970
  const o = JSON.parse(JSON.stringify(s));
970
971
  (u = t.config).fontFamily ?? (u.fontFamily = {});
971
972
  const r = (c = o.config) == null ? void 0 : c.fontFamily, a = (i = t.config) == null ? void 0 : i.fontFamily;
972
- t.config.fontFamily.title = (r == null ? void 0 : r.title) || (a == null ? void 0 : a.title), t.config.fontFamily.description = (r == null ? void 0 : r.description) || (a == null ? void 0 : a.description), await new Promise((p, S) => {
973
+ t.config.fontFamily.title = (r == null ? void 0 : r.title) || (a == null ? void 0 : a.title), t.config.fontFamily.description = (r == null ? void 0 : r.description) || (a == null ? void 0 : a.description), await new Promise((l, S) => {
973
974
  this.transact(async () => {
974
975
  try {
975
976
  const f = await rt(t, s);
976
- p(f);
977
+ l(f);
977
978
  } catch (f) {
978
979
  S(f);
979
980
  }
980
981
  });
981
982
  });
982
983
  });
983
- x(this, "clearPageCacheForRoutes", async (t, s) => {
984
- const o = J(this.options.path), r = await X.findByPk(o), a = (r == null ? void 0 : r.slug) || o;
984
+ D(this, "clearPageCacheForRoutes", async (t, s) => {
985
+ const o = B(this.options.path), r = await Q.findByPk(o), a = (r == null ? void 0 : r.slug) || o;
985
986
  if (y.info(`[SiteState] clearing page cache for project ${o}, routes:`, t || []), !t || t.length === 0) {
986
- Qs({ projectId: o, projectSlug: a, supportedLocales: s.supportedLocales.map((p) => p.locale) });
987
+ qs({ projectId: o, projectSlug: a, supportedLocales: s.supportedLocales.map((l) => l.locale) });
987
988
  return;
988
989
  }
989
- const u = s.supportedLocales.map((p) => p.locale), c = [], i = t.filter((p) => s.pages[p]);
990
- for (const p of i) {
991
- const f = s.pages[p].slug;
990
+ const u = s.supportedLocales.map((l) => l.locale), c = [], i = t.filter((l) => s.pages[l]);
991
+ for (const l of i) {
992
+ const f = s.pages[l].slug;
992
993
  a && a !== o && (a === "/" ? c.push(f) : c.push(`/${a}${f}`)), c.push(`/${o}${f}`);
993
994
  }
994
995
  if (y.info(`[SiteState] clearing page cache for project ${o}, pathPatterns:`, c), c.length > 0) {
995
- const p = qs(c, u);
996
- y.info(`[SiteState] cleared ${p} page cache entries for project ${o}, routes:`, t);
996
+ const l = Qs(c, u);
997
+ y.info(`[SiteState] cleared ${l} page cache entries for project ${o}, routes:`, t);
997
998
  }
998
999
  });
999
- x(this, "addConnection", (t) => {
1000
+ D(this, "addConnection", (t) => {
1000
1001
  if (this.conns.has(t))
1001
1002
  return;
1002
1003
  this.cancelRelease(), t.binaryType = "arraybuffer", this.conns.set(t, /* @__PURE__ */ new Set()), t.on("message", (r) => this.messageListener(t, new Uint8Array(r)));
@@ -1024,18 +1025,18 @@ const v = class v extends W.Doc {
1024
1025
  const a = this.awareness.getStates();
1025
1026
  if (a.size > 0) {
1026
1027
  const u = j.createEncoder();
1027
- j.writeVarUint(u, Le), j.writeVarUint8Array(u, Qe(this.awareness, Array.from(a.keys()))), this.send(t, j.toUint8Array(u));
1028
+ j.writeVarUint(u, $e), j.writeVarUint8Array(u, qe(this.awareness, Array.from(a.keys()))), this.send(t, j.toUint8Array(u));
1028
1029
  }
1029
1030
  }
1030
1031
  });
1031
- x(this, "messageListener", (t, s) => {
1032
+ D(this, "messageListener", (t, s) => {
1032
1033
  try {
1033
1034
  const o = j.createEncoder(), r = Re.createDecoder(s), a = Re.readVarUint(r);
1034
1035
  switch (a) {
1035
1036
  case he:
1036
1037
  j.writeVarUint(o, he), Ss(r, o, this, null), j.length(o) > 1 && (this.ensureDataStructure(), this.send(t, j.toUint8Array(o)));
1037
1038
  break;
1038
- case Le: {
1039
+ case $e: {
1039
1040
  hs(this.awareness, Re.readVarUint8Array(r), t);
1040
1041
  break;
1041
1042
  }
@@ -1047,7 +1048,7 @@ const v = class v extends W.Doc {
1047
1048
  }
1048
1049
  this.save();
1049
1050
  });
1050
- this.options = t, K(this.draftYjsFilePath) && W.applyUpdate(this, ae(this.draftYjsFilePath)), this.syncedStore = os(
1051
+ this.options = t, J(this.draftYjsFilePath) && K.applyUpdate(this, re(this.draftYjsFilePath)), this.syncedStore = rs(
1051
1052
  es(
1052
1053
  {
1053
1054
  pages: {},
@@ -1070,29 +1071,29 @@ const v = class v extends W.Doc {
1070
1071
  if (!t)
1071
1072
  throw new Error("Should provide project context");
1072
1073
  try {
1073
- const s = O(de, t), o = O(de, `@del-${t}`);
1074
- Ye(s, o);
1074
+ const s = A(de, t), o = A(de, `@del-${t}`);
1075
+ We(s, o);
1075
1076
  } catch (s) {
1076
1077
  y.error("Failed to safe delete project state dir:", s);
1077
1078
  }
1078
1079
  }
1079
1080
  static get projectIds() {
1080
- return Ne("*/", {
1081
+ return Le("*/", {
1081
1082
  cwd: de,
1082
1083
  ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
1083
1084
  // Ignore temp directories and hidden files
1084
1085
  });
1085
1086
  }
1086
1087
  static get allShared() {
1087
- return this.projectIds.map((t) => v.shared(t));
1088
+ return this.projectIds.map((t) => T.shared(t));
1088
1089
  }
1089
1090
  static shared(t) {
1090
1091
  if (!t)
1091
1092
  throw new Error("Should provide project context");
1092
- let s = v.sharedInstances[t];
1093
- return s || (s = new v({
1094
- path: O(de, t)
1095
- }), v.sharedInstances[t] = s, Ot({
1093
+ let s = T.sharedInstances[t];
1094
+ return s || (s = new T({
1095
+ path: A(de, t)
1096
+ }), T.sharedInstances[t] = s, Ot({
1096
1097
  projectId: t,
1097
1098
  pages: ve,
1098
1099
  components: ke
@@ -1101,29 +1102,29 @@ const v = class v extends W.Doc {
1101
1102
  // 轻量级 production 状态获取,不加载 draft 数据
1102
1103
  static async getProductionState(t) {
1103
1104
  var o, r;
1104
- let s = v.productionStates.get(t);
1105
+ let s = T.productionStates.get(t);
1105
1106
  if (!s) {
1106
- const a = O(de, t, "production");
1107
+ const a = A(de, t, "production");
1107
1108
  if (s = await Et(a, { includeResources: !0 }) ?? nn(), !((o = s == null ? void 0 : s.config) != null && o.defaultLocale)) {
1108
1109
  s.config ?? (s.config = {});
1109
- const u = Ue.env.languages.map((c) => ({ locale: c.code, name: c.name }));
1110
+ const u = Me.env.languages.map((c) => ({ locale: c.code, name: c.name }));
1110
1111
  s.config.defaultLocale = (r = u[0]) == null ? void 0 : r.locale;
1111
1112
  }
1112
- v.productionStates.set(t, s);
1113
+ T.productionStates.set(t, s);
1113
1114
  }
1114
1115
  return {
1115
1116
  ...s,
1116
- resources: await Ve().then(async (a) => {
1117
+ resources: await Je().then(async (a) => {
1117
1118
  var S, f;
1118
- const { pages: u, components: c } = as(a, "pages", "components");
1119
+ const { pages: u, components: c } = is(a, "pages", "components");
1119
1120
  let i = c;
1120
- const p = await X.findByPk(t);
1121
- if (p != null && p.useAllResources)
1121
+ const l = await Q.findByPk(t);
1122
+ if (l != null && l.useAllResources)
1122
1123
  i = c;
1123
1124
  else {
1124
- const l = (await Te.findAll({ where: { projectId: t } })).map((w) => w.componentId);
1125
+ const p = (await Te.findAll({ where: { projectId: t } })).map((w) => w.componentId);
1125
1126
  i = Object.fromEntries(
1126
- Object.entries(c || {}).filter(([w]) => l.includes(w))
1127
+ Object.entries(c || {}).filter(([w]) => p.includes(w))
1127
1128
  );
1128
1129
  }
1129
1130
  return Object.keys(((S = s == null ? void 0 : s.resources) == null ? void 0 : S.components) || {}).length > 0 && (i = {
@@ -1135,37 +1136,37 @@ const v = class v extends W.Doc {
1135
1136
  }
1136
1137
  destroy() {
1137
1138
  this.cancelRelease(), this.save({ flush: !0 }), this.conns.forEach((s, o) => this.closeConn(o)), this.awareness.destroy();
1138
- const t = J(this.options.path);
1139
- delete v.sharedInstances[t], super.destroy();
1139
+ const t = B(this.options.path);
1140
+ delete T.sharedInstances[t], super.destroy();
1140
1141
  }
1141
1142
  initObserver() {
1142
1143
  zs(this.syncedStore), Ws(this.syncedStore);
1143
1144
  }
1144
1145
  get draftYjsFilePath() {
1145
- return O(this.options.path, "draft.yjs");
1146
+ return A(this.options.path, "draft.yjs");
1146
1147
  }
1147
1148
  static async getStateByProjectId(t, s) {
1148
1149
  if (s === "draft") {
1149
- const o = v.shared(t);
1150
+ const o = T.shared(t);
1150
1151
  return JSON.parse(JSON.stringify(o.syncedStore));
1151
1152
  }
1152
- return v.getProductionState(t);
1153
+ return T.getProductionState(t);
1153
1154
  }
1154
1155
  async getState(t) {
1155
1156
  if (t === "draft")
1156
1157
  return JSON.parse(JSON.stringify(this.syncedStore));
1157
- const s = J(this.options.path);
1158
- return v.getProductionState(s);
1158
+ const s = B(this.options.path);
1159
+ return T.getProductionState(s);
1159
1160
  }
1160
1161
  async setState(t, s) {
1161
1162
  const o = await cn(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(t);
1162
- if (Y(H(r), { recursive: !0 }), lt(r, { force: !0, recursive: !0 }), Ye(o, r), t === "production") {
1163
- const a = J(this.options.path);
1164
- v.productionStates.set(a, s);
1163
+ if (W(F(r), { recursive: !0 }), pt(r, { force: !0, recursive: !0 }), We(o, r), t === "production") {
1164
+ const a = B(this.options.path);
1165
+ T.productionStates.set(a, s);
1165
1166
  }
1166
1167
  }
1167
1168
  getPublishDir(t) {
1168
- return O(this.options.path, t);
1169
+ return A(this.options.path, t);
1169
1170
  }
1170
1171
  // 检查并调度延迟释放
1171
1172
  checkAndScheduleRelease() {
@@ -1174,16 +1175,16 @@ const v = class v extends W.Doc {
1174
1175
  // 调度延迟释放
1175
1176
  scheduleRelease() {
1176
1177
  this.cancelRelease();
1177
- const t = J(this.options.path);
1178
+ const t = B(this.options.path);
1178
1179
  this.releaseTimer = setTimeout(() => {
1179
1180
  y.info(`[SiteState] releasing instance due to no active connections: ${t}`), this.conns.size === 0 && (this.releaseTimer = void 0, this.destroy());
1180
- }, v.RELEASE_DELAY), y.info(`[SiteState] scheduled release for project ${t} in ${v.RELEASE_DELAY / 1e3}s`);
1181
+ }, T.RELEASE_DELAY), y.info(`[SiteState] scheduled release for project ${t} in ${T.RELEASE_DELAY / 1e3}s`);
1181
1182
  }
1182
1183
  // 取消延迟释放
1183
1184
  cancelRelease() {
1184
1185
  if (this.releaseTimer) {
1185
1186
  clearTimeout(this.releaseTimer), this.releaseTimer = void 0;
1186
- const t = J(this.options.path);
1187
+ const t = B(this.options.path);
1187
1188
  y.info(`[SiteState] cancelled scheduled release for project ${t}`);
1188
1189
  }
1189
1190
  }
@@ -1193,32 +1194,32 @@ const v = class v extends W.Doc {
1193
1194
  s && (o = [s]);
1194
1195
  const r = {};
1195
1196
  for (const c of o) {
1196
- const i = await X.findByPk(c);
1197
+ const i = await Q.findByPk(c);
1197
1198
  if (!i) continue;
1198
- const p = await v.getStateByProjectId(c, t), S = i.slug || c, f = is(
1199
- I.env.languages.map((l) => l.code),
1200
- p.supportedLocales.map((l) => l.locale)
1201
- ), d = (l, m) => {
1202
- S && (r[Q("/", S, l)] = {
1199
+ const l = await T.getStateByProjectId(c, t), S = i.slug || c, f = cs(
1200
+ I.env.languages.map((p) => p.code),
1201
+ l.supportedLocales.map((p) => p.locale)
1202
+ ), d = (p, m) => {
1203
+ S && (r[Y("/", S, p)] = {
1203
1204
  ...m,
1204
1205
  shouldRedirect: !0,
1205
1206
  mainPage: !0
1206
- }), r[Q("/", c, l)] = {
1207
+ }), r[Y("/", c, p)] = {
1207
1208
  ...m,
1208
1209
  shouldRedirect: !0,
1209
1210
  mainPage: !0
1210
1211
  };
1211
1212
  for (const w of f) {
1212
- const D = { ...m, locale: w };
1213
- r[Q("/", w, c, l)] = D, S && (r[Q("/", w, S, l)] = D);
1213
+ const k = { ...m, locale: w };
1214
+ r[Y("/", w, c, p)] = k, S && (r[Y("/", w, S, p)] = k);
1214
1215
  }
1215
1216
  };
1216
1217
  if (t === "draft")
1217
- for (const l of p.routeIds || []) {
1218
- const m = (a = p == null ? void 0 : p.routes) == null ? void 0 : a[l];
1218
+ for (const p of l.routeIds || []) {
1219
+ const m = (a = l == null ? void 0 : l.routes) == null ? void 0 : a[p];
1219
1220
  if (!m) continue;
1220
1221
  if (m.params && m.params.length > 0) {
1221
- const P = Fe({
1222
+ const O = Ue({
1222
1223
  basePath: m.path,
1223
1224
  params: m.params,
1224
1225
  routeId: m.id,
@@ -1228,63 +1229,63 @@ const v = class v extends W.Doc {
1228
1229
  currentOptionIds: [],
1229
1230
  result: []
1230
1231
  });
1231
- for (const N of P) {
1232
- const ee = N.path, oe = {
1232
+ for (const L of O) {
1233
+ const X = L.path, ne = {
1233
1234
  projectId: c,
1234
1235
  projectSlug: S,
1235
- pageSlug: ee,
1236
+ pageSlug: X,
1236
1237
  pageId: m.displayTemplateId || "",
1237
- routeId: l,
1238
+ routeId: p,
1238
1239
  // default locale
1239
1240
  defaultLocale: f == null ? void 0 : f[0],
1240
1241
  locales: f,
1241
- publishedAt: p.config.publishedAt,
1242
- isPublic: m.isPublic && ((u = N == null ? void 0 : N.routeMetaData) == null ? void 0 : u.isPublic)
1242
+ publishedAt: l.config.publishedAt,
1243
+ isPublic: m.isPublic && ((u = L == null ? void 0 : L.routeMetaData) == null ? void 0 : u.isPublic)
1243
1244
  };
1244
- d(ee, oe);
1245
+ d(X, ne);
1245
1246
  }
1246
1247
  }
1247
- const w = m.path, D = {
1248
+ const w = m.path, k = {
1248
1249
  projectId: c,
1249
1250
  projectSlug: S,
1250
1251
  pageSlug: w,
1251
1252
  pageId: m.displayTemplateId || "",
1252
- routeId: l,
1253
+ routeId: p,
1253
1254
  // default locale
1254
1255
  defaultLocale: f == null ? void 0 : f[0],
1255
1256
  locales: f,
1256
- publishedAt: p.config.publishedAt,
1257
+ publishedAt: l.config.publishedAt,
1257
1258
  isPublic: m.isPublic
1258
1259
  };
1259
- d(w, D);
1260
+ d(w, k);
1260
1261
  }
1261
- for (const l of p.pageIds) {
1262
- const m = p.pages[l];
1262
+ for (const p of l.pageIds) {
1263
+ const m = l.pages[p];
1263
1264
  if (!m || t === "production" && !m.isPublic)
1264
1265
  continue;
1265
- const w = m.slug, D = i.slug || c, P = {
1266
+ const w = m.slug, k = i.slug || c, O = {
1266
1267
  projectId: c,
1267
- projectSlug: D,
1268
+ projectSlug: k,
1268
1269
  pageSlug: w,
1269
- pageId: l,
1270
+ pageId: p,
1270
1271
  // default locale
1271
1272
  defaultLocale: f == null ? void 0 : f[0],
1272
1273
  locales: f,
1273
- publishedAt: p.config.publishedAt,
1274
+ publishedAt: l.config.publishedAt,
1274
1275
  isPublic: m.isPublic,
1275
1276
  templateConfig: m.templateConfig
1276
1277
  };
1277
- d(w, P);
1278
+ d(w, O);
1278
1279
  }
1279
1280
  }
1280
1281
  return r;
1281
1282
  }
1282
1283
  getDocumentSize() {
1283
- return W.encodeStateAsUpdate(this).byteLength;
1284
+ return K.encodeStateAsUpdate(this).byteLength;
1284
1285
  }
1285
1286
  static getInstancesSizeInfo() {
1286
1287
  const t = [];
1287
- for (const [s, o] of Object.entries(v.sharedInstances)) {
1288
+ for (const [s, o] of Object.entries(T.sharedInstances)) {
1288
1289
  const r = o.getDocumentSize();
1289
1290
  t.push({
1290
1291
  projectId: s,
@@ -1309,8 +1310,8 @@ const v = class v extends W.Doc {
1309
1310
  }
1310
1311
  // 执行定期检查
1311
1312
  static performPeriodicCheck() {
1312
- const t = Object.keys(v.sharedInstances).length, s = [], o = [];
1313
- for (const [r, a] of Object.entries(v.sharedInstances))
1313
+ const t = Object.keys(T.sharedInstances).length, s = [], o = [];
1314
+ for (const [r, a] of Object.entries(T.sharedInstances))
1314
1315
  a.conns.size === 0 ? s.push({ projectId: r, instance: a }) : o.push({ projectId: r, connections: a.conns.size });
1315
1316
  if (y.info(
1316
1317
  `[SiteState] periodic check summary: total instances: ${t}, with connections: ${o.length}, without connections: ${s.length}`
@@ -1332,18 +1333,18 @@ const v = class v extends W.Doc {
1332
1333
  } else t > 0 ? y.debug("[SiteState] periodic check: all instances have active connections") : y.debug("[SiteState] periodic check: no instances exist");
1333
1334
  }
1334
1335
  };
1335
- x(v, "PRODUCTION_CACHE_TTL", 7 * 24 * 60 * 60 * 1e3), // 7 days
1336
+ D(T, "PRODUCTION_CACHE_TTL", 7 * 24 * 60 * 60 * 1e3), // 7 days
1336
1337
  // 延迟释放时间:5分钟
1337
- x(v, "RELEASE_DELAY", 5 * 60 * 1e3), // 定期检查间隔:2 小时
1338
- x(v, "PERIODIC_CHECK_INTERVAL", 2 * 60 * 60 * 1e3), // 2 hours
1339
- x(v, "sharedInstances", {}), x(v, "productionStates", new Pe({
1338
+ D(T, "RELEASE_DELAY", 5 * 60 * 1e3), // 定期检查间隔:2 小时
1339
+ D(T, "PERIODIC_CHECK_INTERVAL", 2 * 60 * 60 * 1e3), // 2 hours
1340
+ D(T, "sharedInstances", {}), D(T, "productionStates", new Pe({
1340
1341
  max: 100,
1341
- ttl: v.PRODUCTION_CACHE_TTL
1342
+ ttl: T.PRODUCTION_CACHE_TTL
1342
1343
  })), // 定期检查定时器
1343
- x(v, "periodicCheckTimer");
1344
- let Z = v;
1344
+ D(T, "periodicCheckTimer");
1345
+ let q = T;
1345
1346
  async function on(e, n, t) {
1346
- if (!e || !K(e) || !re(e).isFile())
1347
+ if (!e || !J(e) || !oe(e).isFile())
1347
1348
  return null;
1348
1349
  let s = t[e];
1349
1350
  return s || (s = (async () => {
@@ -1360,22 +1361,22 @@ async function on(e, n, t) {
1360
1361
  })(), t[e] = s), s;
1361
1362
  }
1362
1363
  const rn = async (e, n) => {
1363
- const t = J(e), s = await Yt({
1364
+ const t = B(e), s = await Yt({
1364
1365
  name: yt,
1365
- path: Q("/uploads", t),
1366
+ path: Y("/uploads", t),
1366
1367
  responseType: "stream",
1367
1368
  method: "GET"
1368
1369
  });
1369
1370
  if (s.status >= 200 && s.status < 400) {
1370
1371
  const o = Gt(n);
1371
- await ps(s.data, o);
1372
+ await ls(s.data, o);
1372
1373
  } else
1373
1374
  throw new Error(`download asset failed ${s.status}`);
1374
1375
  }, an = async (e, n) => {
1375
1376
  await Promise.all(
1376
1377
  e.map(async (t) => {
1377
1378
  try {
1378
- await rn(t, O(n, J(t)));
1379
+ await rn(t, A(n, B(t)));
1379
1380
  } catch (s) {
1380
1381
  y.error(`Failed to export assets: ${t}, ${s}`);
1381
1382
  }
@@ -1383,19 +1384,19 @@ const rn = async (e, n) => {
1383
1384
  );
1384
1385
  };
1385
1386
  function wt(e) {
1386
- return He.test(e) ? [e] : fe.test(e) ? (st.lastIndex = 0, Array.from(e.matchAll(st)).map((t) => t[1]).filter((t) => !!t)) : [];
1387
+ return Ge.test(e) ? [e] : fe.test(e) ? (st.lastIndex = 0, Array.from(e.matchAll(st)).map((t) => t[1]).filter((t) => !!t)) : [];
1387
1388
  }
1388
1389
  async function ge(e, n, t) {
1389
- const { getFilename: s, exportAssets: o } = t, r = O(n, s(e));
1390
- if (Y(H(r), { recursive: !0 }), we(r, ie.stringify(e)), o) {
1391
- const u = Ie(
1390
+ const { getFilename: s, exportAssets: o } = t, r = A(n, s(e));
1391
+ if (W(F(r), { recursive: !0 }), we(r, ae.stringify(e)), o) {
1392
+ const u = be(
1392
1393
  e,
1393
- (c) => typeof c == "string" && (He.test(c) || fe.test(c))
1394
+ (c) => typeof c == "string" && (Ge.test(c) || fe.test(c))
1394
1395
  ).map((c) => {
1395
- const i = Be(e, c);
1396
+ const i = Fe(e, c);
1396
1397
  return wt(i);
1397
1398
  }).flat().filter(Boolean);
1398
- await an(u, H(r));
1399
+ await an(u, F(r));
1399
1400
  }
1400
1401
  }
1401
1402
  const nt = new Pe({
@@ -1404,21 +1405,21 @@ const nt = new Pe({
1404
1405
  });
1405
1406
  async function ot(e, n, t) {
1406
1407
  var u;
1407
- const s = Ie(
1408
+ const s = be(
1408
1409
  e,
1409
- (c) => typeof c == "string" && (He.test(c) || fe.test(c))
1410
- ), o = ls(2), r = s.map(
1410
+ (c) => typeof c == "string" && (Ge.test(c) || fe.test(c))
1411
+ ), o = ps(2), r = s.map(
1411
1412
  (c) => o(async () => {
1412
1413
  try {
1413
- const i = Be(e, c), p = wt(i);
1414
- for (const S of p) {
1415
- const f = J(S), d = t.getFilePath(S, c), l = d ? `${d}:${f}` : f, m = nt.get(l);
1414
+ const i = Fe(e, c), l = wt(i);
1415
+ for (const S of l) {
1416
+ const f = B(S), d = t.getFilePath(S, c), p = d ? `${d}:${f}` : f, m = nt.get(p);
1416
1417
  if (m) {
1417
- fe.test(i) || qe(e, c, m);
1418
+ fe.test(i) || Qe(e, c, m);
1418
1419
  return;
1419
1420
  }
1420
1421
  const w = await on(d, f, n);
1421
- w && (fe.test(i) || qe(e, c, w), nt.set(l, w));
1422
+ w && (fe.test(i) || Qe(e, c, w), nt.set(p, w));
1422
1423
  }
1423
1424
  } catch (i) {
1424
1425
  y.error(`Failed to process upload for path ${c.join(".")}:`, i.message || i.reason);
@@ -1435,12 +1436,12 @@ async function cn(e, {
1435
1436
  includeResources: r = !1,
1436
1437
  routeIds: a = "all"
1437
1438
  } = {}) {
1438
- var pe, E, g, A, k, te, b, $, B, G, _, q;
1439
+ var pe, E, g, b, v, Z, P, N, G, ee, z, le;
1439
1440
  const u = t === "all" ? e.pageIds : t, c = xt({
1440
1441
  state: e,
1441
1442
  pageIds: u,
1442
1443
  componentIds: s === "all" ? Object.keys(e.components) : s
1443
- }), i = a === "all" ? e.routeIds : a, p = (h) => {
1444
+ }), i = a === "all" ? e.routeIds : a, l = (h) => {
1444
1445
  var C;
1445
1446
  return {
1446
1447
  id: h.id,
@@ -1451,18 +1452,18 @@ async function cn(e, {
1451
1452
  component: h.component,
1452
1453
  config: h.config,
1453
1454
  visibility: h.visibility,
1454
- sections: h != null && h.sectionIds ? F(
1455
- (C = h == null ? void 0 : h.sectionIds) == null ? void 0 : C.map((T) => {
1456
- var L;
1457
- const M = (L = h.sections) == null ? void 0 : L[T];
1458
- return M && p(M);
1455
+ sections: h != null && h.sectionIds ? U(
1456
+ (C = h == null ? void 0 : h.sectionIds) == null ? void 0 : C.map((x) => {
1457
+ var $;
1458
+ const _ = ($ = h.sections) == null ? void 0 : $[x];
1459
+ return _ && l(_);
1459
1460
  })
1460
1461
  ) : void 0
1461
1462
  // 已经废弃,数据在 page.dataSource 中管理
1462
1463
  // properties: section.locales?.[locale] ?? {},
1463
1464
  };
1464
1465
  }, S = (h, C) => {
1465
- var T;
1466
+ var x;
1466
1467
  return {
1467
1468
  id: h.id,
1468
1469
  createdAt: h.createdAt,
@@ -1470,16 +1471,16 @@ async function cn(e, {
1470
1471
  publishedAt: h.publishedAt,
1471
1472
  isPublic: h.isPublic ?? !0,
1472
1473
  templateConfig: h.templateConfig,
1473
- meta: ((T = h.locales) == null ? void 0 : T[C]) ?? {},
1474
- sections: F(
1475
- h.sectionIds.map((M) => {
1476
- const L = h.sections[M];
1477
- return L && p(L);
1474
+ meta: ((x = h.locales) == null ? void 0 : x[C]) ?? {},
1475
+ sections: U(
1476
+ h.sectionIds.map((_) => {
1477
+ const $ = h.sections[_];
1478
+ return $ && l($);
1478
1479
  })
1479
1480
  ),
1480
1481
  // 将 dataSource.sectionId.locale 转换为 dataSource.sectionId
1481
1482
  dataSource: Object.fromEntries(
1482
- Object.entries(h.dataSource || {}).map(([M, L]) => [M, (L == null ? void 0 : L[C]) ?? {}])
1483
+ Object.entries(h.dataSource || {}).map(([_, $]) => [_, ($ == null ? void 0 : $[C]) ?? {}])
1483
1484
  )
1484
1485
  };
1485
1486
  }, f = (h) => ({
@@ -1494,65 +1495,65 @@ async function cn(e, {
1494
1495
  enabledGenerate: h.enabledGenerate ?? !1,
1495
1496
  displayTemplateId: h.displayTemplateId,
1496
1497
  dataSource: h.dataSource
1497
- }), d = F(
1498
+ }), d = U(
1498
1499
  i.map((h) => {
1499
1500
  const C = e.routes[h];
1500
1501
  return C && f(C);
1501
1502
  })
1502
- ), l = F(
1503
+ ), p = U(
1503
1504
  e.supportedLocales.map((h) => h.locale).flatMap(
1504
1505
  (h) => u.map((C) => {
1505
- const T = e.pages[C];
1506
- return T && {
1506
+ const x = e.pages[C];
1507
+ return x && {
1507
1508
  locale: h,
1508
- slug: T.slug,
1509
- page: S(T, h)
1509
+ slug: x.slug,
1510
+ page: S(x, h)
1510
1511
  };
1511
1512
  })
1512
1513
  )
1513
- ), m = St(), w = O(m, "pages");
1514
- Y(w, { recursive: !0 });
1515
- const D = O(m, "components");
1516
- Y(D, { recursive: !0 });
1517
- const P = O(m, "routes");
1518
- Y(P, { recursive: !0 });
1519
- for (const { locale: h, slug: C, page: T } of l)
1520
- await ge(T, w, {
1514
+ ), m = St(), w = A(m, "pages");
1515
+ W(w, { recursive: !0 });
1516
+ const k = A(m, "components");
1517
+ W(k, { recursive: !0 });
1518
+ const O = A(m, "routes");
1519
+ W(O, { recursive: !0 });
1520
+ for (const { locale: h, slug: C, page: x } of p)
1521
+ await ge(x, w, {
1521
1522
  getFilename: () => `${Oe(C) || "index"}.${h}.yml`,
1522
1523
  exportAssets: n
1523
1524
  });
1524
1525
  for (const h of d)
1525
- await ge(h, P, {
1526
+ await ge(h, O, {
1526
1527
  // getFilename: () => `${sanitizeSlug(route.path)}.yml`,
1527
1528
  getFilename: () => `${Oe(h.path) || "index"}.yml`,
1528
1529
  exportAssets: n
1529
1530
  });
1530
1531
  for (const h of c) {
1531
1532
  const C = (pe = e.components[h]) == null ? void 0 : pe.data;
1532
- C && await ge(C, D, {
1533
- getFilename: (T) => `${T.name || "unnamed"}.${T.id}.yml`,
1533
+ C && await ge(C, k, {
1534
+ getFilename: (x) => `${x.name || "unnamed"}.${x.id}.yml`,
1534
1535
  exportAssets: n
1535
1536
  });
1536
1537
  }
1537
- const N = O(m, ".blocklet/pages/pages.config.yml");
1538
- Y(H(N), { recursive: !0 });
1539
- const ee = {
1540
- pages: F(
1538
+ const L = A(m, ".blocklet/pages/pages.config.yml");
1539
+ W(F(L), { recursive: !0 });
1540
+ const X = {
1541
+ pages: U(
1541
1542
  u.map((h) => {
1542
1543
  const C = e.pages[h];
1543
1544
  return C && { id: h, slug: C.slug };
1544
1545
  })
1545
1546
  ),
1546
- routes: F(
1547
+ routes: U(
1547
1548
  i.map((h) => {
1548
1549
  const C = e.routes[h];
1549
1550
  return C && { id: h, path: C.path };
1550
1551
  })
1551
1552
  ),
1552
- components: F(
1553
+ components: U(
1553
1554
  c.map((h) => {
1554
- var T;
1555
- const C = (T = e.components[h]) == null ? void 0 : T.data;
1555
+ var x;
1556
+ const C = (x = e.components[h]) == null ? void 0 : x.data;
1556
1557
  return C && {
1557
1558
  id: h,
1558
1559
  name: C.name
@@ -1561,12 +1562,12 @@ async function cn(e, {
1561
1562
  ),
1562
1563
  ...r ? {
1563
1564
  resources: {
1564
- components: F(
1565
+ components: U(
1565
1566
  Object.keys(((E = e.resources) == null ? void 0 : E.components) || {}).filter((h) => c.includes(h)).map((h) => {
1566
- var C, T, M, L;
1567
+ var C, x, _, $;
1567
1568
  return {
1568
1569
  id: h,
1569
- name: (L = (M = (T = (C = e.resources) == null ? void 0 : C.components) == null ? void 0 : T[h]) == null ? void 0 : M.component) == null ? void 0 : L.name
1570
+ name: ($ = (_ = (x = (C = e.resources) == null ? void 0 : C.components) == null ? void 0 : x[h]) == null ? void 0 : _.component) == null ? void 0 : $.name
1570
1571
  };
1571
1572
  })
1572
1573
  )
@@ -1575,34 +1576,34 @@ async function cn(e, {
1575
1576
  supportedLocales: e.supportedLocales,
1576
1577
  config: e.config
1577
1578
  };
1578
- we(N, ie.stringify(ee));
1579
- const oe = O(m, "config.source.json");
1580
- if (o && we(oe, JSON.stringify(o)), r) {
1581
- const h = O(m, "resources"), C = O(h, "components");
1582
- Y(C, { recursive: !0 });
1583
- for (const L of Object.keys(((g = e == null ? void 0 : e.resources) == null ? void 0 : g.components) ?? {}).filter(
1584
- (V) => c.includes(V)
1579
+ we(L, ae.stringify(X));
1580
+ const ne = A(m, "config.source.json");
1581
+ if (o && we(ne, JSON.stringify(o)), r) {
1582
+ const h = A(m, "resources"), C = A(h, "components");
1583
+ W(C, { recursive: !0 });
1584
+ for (const $ of Object.keys(((g = e == null ? void 0 : e.resources) == null ? void 0 : g.components) ?? {}).filter(
1585
+ (H) => c.includes(H)
1585
1586
  )) {
1586
- const V = (te = (k = (A = e.resources) == null ? void 0 : A.components) == null ? void 0 : k[L]) == null ? void 0 : te.component;
1587
- V && await ge(V, C, {
1588
- getFilename: (se) => `${se.name || "unnamed"}.${se.id}.yml`,
1587
+ const H = (Z = (v = (b = e.resources) == null ? void 0 : b.components) == null ? void 0 : v[$]) == null ? void 0 : Z.component;
1588
+ H && await ge(H, C, {
1589
+ getFilename: (te) => `${te.name || "unnamed"}.${te.id}.yml`,
1589
1590
  exportAssets: n
1590
1591
  });
1591
1592
  }
1592
- const T = O(m, "chunks");
1593
- Y(T, { recursive: !0 });
1594
- const { chunks: M } = await Ve();
1595
- for (const L of Object.keys(((b = e == null ? void 0 : e.resources) == null ? void 0 : b.components) ?? {}).filter(
1596
- (V) => c.includes(V)
1593
+ const x = A(m, "chunks");
1594
+ W(x, { recursive: !0 });
1595
+ const { chunks: _ } = await Je();
1596
+ for (const $ of Object.keys(((P = e == null ? void 0 : e.resources) == null ? void 0 : P.components) ?? {}).filter(
1597
+ (H) => c.includes(H)
1597
1598
  )) {
1598
- const V = (G = (B = ($ = e.resources) == null ? void 0 : $.components) == null ? void 0 : B[L]) == null ? void 0 : G.component;
1599
- if (V && ((_ = V.renderer) == null ? void 0 : _.type) === "react-component") {
1600
- const se = ((q = V.renderer) == null ? void 0 : q.chunks) ?? [];
1601
- if ((se == null ? void 0 : se.length) > 0)
1602
- for (const De of se) {
1603
- const Ke = O(T, De), xe = M == null ? void 0 : M[De];
1599
+ const H = (ee = (G = (N = e.resources) == null ? void 0 : N.components) == null ? void 0 : G[$]) == null ? void 0 : ee.component;
1600
+ if (H && ((z = H.renderer) == null ? void 0 : z.type) === "react-component") {
1601
+ const te = ((le = H.renderer) == null ? void 0 : le.chunks) ?? [];
1602
+ if ((te == null ? void 0 : te.length) > 0)
1603
+ for (const De of te) {
1604
+ const Ve = A(x, De), xe = _ == null ? void 0 : _[De];
1604
1605
  try {
1605
- xe && K(xe) && !K(Ke) && Bt(xe, Ke);
1606
+ xe && J(xe) && !J(Ve) && Bt(xe, Ve);
1606
1607
  } catch (Ct) {
1607
1608
  y.error(`copy chunk ${De} error`, Ct.message);
1608
1609
  }
@@ -1614,113 +1615,90 @@ async function cn(e, {
1614
1615
  }
1615
1616
  async function Et(e, { importAssets: n, includeResources: t } = {}) {
1616
1617
  var r, a, u, c;
1617
- if (!K(e))
1618
+ if (!J(e))
1618
1619
  return null;
1619
1620
  let s, o = !1;
1620
1621
  try {
1621
- re(e).isDirectory() ? s = e : /\.(tgz|gz|tar)$/.test(e) && (o = !0, s = St(), await ds({ file: e, C: s }));
1622
- const i = Ne("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), p = i && O(H(i), "../../pages"), S = i && O(H(i), "../../components"), f = i && O(H(i), "../../chunks"), d = i && O(H(i), "../../routes");
1622
+ oe(e).isDirectory() ? s = e : /\.(tgz|gz|tar)$/.test(e) && (o = !0, s = St(), await ds({ file: e, C: s }));
1623
+ const i = Le("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), l = i && A(F(i), "../../pages"), S = i && A(F(i), "../../components"), f = i && A(F(i), "../../chunks"), d = i && A(F(i), "../../routes");
1623
1624
  if (!i)
1624
1625
  return null;
1625
- const l = ie.parse(ae(i).toString()), m = (E, g, A) => {
1626
- let k = O(E, `${g}${A ? `.${A}` : ""}.yml`);
1627
- return (!K(k) || !re(k).isFile()) && (k = O(E, g, `index${A ? `.${A}` : ""}.yml`), !K(k) || !re(k)) ? null : ie.parse(ae(k).toString());
1626
+ const p = ae.parse(re(i).toString()), m = (E, g, b) => {
1627
+ let v = A(E, `${g}${b ? `.${b}` : ""}.yml`);
1628
+ return (!J(v) || !oe(v).isFile()) && (v = A(E, g, `index${b ? `.${b}` : ""}.yml`), !J(v) || !oe(v)) ? null : ae.parse(re(v).toString());
1628
1629
  }, w = (E, g) => {
1629
1630
  try {
1630
- const A = Ne(`*.${g}.yml`, { cwd: E, absolute: !0 })[0];
1631
- return A ? ie.parse(ae(A).toString()) : null;
1632
- } catch (A) {
1633
- y.error("parse component error", A);
1631
+ const b = Le(`*.${g}.yml`, { cwd: E, absolute: !0 })[0];
1632
+ return b ? ae.parse(re(b).toString()) : null;
1633
+ } catch (b) {
1634
+ y.error("parse component error", b);
1634
1635
  }
1635
1636
  return null;
1636
- }, D = (E, g) => {
1637
- let A = O(E, `${g}.yml`);
1638
- return (!K(A) || !re(A).isFile()) && (A = O(E, g, "index.yml"), !K(A) || !re(A)) ? null : ie.parse(ae(A).toString());
1639
- }, P = F(
1640
- l.pages.map(({ slug: E }) => {
1641
- var te;
1642
- const g = F(
1643
- l.supportedLocales.map(({ locale: b }) => {
1644
- const $ = p ? m(p, Oe(E), b) : void 0;
1645
- if ($)
1646
- return { locale: b, page: $ };
1647
- const B = p ? m(p, E, b) : void 0;
1648
- return B && { locale: b, page: B };
1637
+ }, k = (E, g) => {
1638
+ let b = A(E, `${g}.yml`);
1639
+ return (!J(b) || !oe(b).isFile()) && (b = A(E, g, "index.yml"), !J(b) || !oe(b)) ? null : ae.parse(re(b).toString());
1640
+ }, O = U(
1641
+ p.pages.map(({ slug: E }) => {
1642
+ var Z;
1643
+ const g = U(
1644
+ p.supportedLocales.map(({ locale: P }) => {
1645
+ const N = l ? m(l, Oe(E), P) : void 0;
1646
+ if (N)
1647
+ return { locale: P, page: N };
1648
+ const G = l ? m(l, E, P) : void 0;
1649
+ return G && { locale: P, page: G };
1649
1650
  })
1650
- ), A = (te = g[0]) == null ? void 0 : te.page;
1651
- if (!A)
1651
+ ), b = (Z = g[0]) == null ? void 0 : Z.page;
1652
+ if (!b)
1652
1653
  return null;
1653
- const k = A.sections.map((b) => {
1654
- var _, q, h, C;
1655
- const $ = b.id || $e(), B = b.sections && Object.keys(b.sections).length > 0, G = {};
1656
- return B && (G.sections = Object.fromEntries(((q = (_ = b.sections) == null ? void 0 : _.map) == null ? void 0 : q.call(_, (T) => [T.id, T])) ?? []) || {}, G.sectionIds = ((C = (h = b.sections) == null ? void 0 : h.map) == null ? void 0 : C.call(h, (T) => T.id)) ?? []), {
1657
- id: $,
1658
- component: b.component,
1659
- config: b.config,
1660
- name: b.name,
1661
- isTemplateSection: b.isTemplateSection ?? !1,
1662
- templateDescription: b.templateDescription,
1663
- llmConfig: b.llmConfig,
1664
- visibility: b.visibility,
1665
- ...G
1666
- // 不再需要 locales, 数据在 page.dataSource 中管理
1667
- // locales: Object.fromEntries(
1668
- // filterNone(
1669
- // locales.map(({ locale, page }) => {
1670
- // const section = page.sections.find((s) => s.id === sectionId);
1671
- // return section && [locale, section.properties];
1672
- // })
1673
- // )
1674
- // ),
1675
- };
1676
- });
1654
+ const v = b.sections.map(os);
1677
1655
  return {
1678
- id: A.id || $e(),
1679
- createdAt: A.createdAt,
1680
- updatedAt: A.updatedAt,
1681
- publishedAt: A.publishedAt,
1682
- isPublic: A.isPublic ?? !0,
1683
- templateConfig: A.templateConfig,
1656
+ id: b.id || Ye(),
1657
+ createdAt: b.createdAt,
1658
+ updatedAt: b.updatedAt,
1659
+ publishedAt: b.publishedAt,
1660
+ isPublic: b.isPublic ?? !0,
1661
+ templateConfig: b.templateConfig,
1684
1662
  slug: E,
1685
- sections: Object.fromEntries(k.map((b) => [b.id, b])),
1686
- sectionIds: k.map((b) => b.id),
1687
- locales: Object.fromEntries(g.map(({ locale: b, page: $ }) => [b, $.meta])),
1688
- dataSource: A.dataSource ? Object.fromEntries(
1663
+ sections: Object.fromEntries(v.map((P) => [P.id, P])),
1664
+ sectionIds: v.map((P) => P.id),
1665
+ locales: Object.fromEntries(g.map(({ locale: P, page: N }) => [P, N.meta])),
1666
+ dataSource: b.dataSource ? Object.fromEntries(
1689
1667
  // 获取 dataSource 中所有 section ID
1690
- [...new Set(g.flatMap(({ page: b }) => Object.keys(b.dataSource ?? {})))].map((b) => [
1691
- b,
1668
+ [...new Set(g.flatMap(({ page: P }) => Object.keys(P.dataSource ?? {})))].map((P) => [
1669
+ P,
1692
1670
  Object.fromEntries(
1693
- g.map(({ locale: $, page: B }) => {
1694
- var _;
1695
- const G = (_ = B.dataSource) == null ? void 0 : _[b];
1696
- return [$, G || {}];
1671
+ g.map(({ locale: N, page: G }) => {
1672
+ var z;
1673
+ const ee = (z = G.dataSource) == null ? void 0 : z[P];
1674
+ return [N, ee || {}];
1697
1675
  })
1698
1676
  )
1699
1677
  ])
1700
1678
  ) : Object.fromEntries(
1701
1679
  // 获取所有 section ID
1702
- [...new Set(g.flatMap(({ page: b }) => b.sections.map(($) => $.id)))].map((b) => [
1703
- b,
1680
+ [...new Set(g.flatMap(({ page: P }) => P.sections.map((N) => N.id)))].map((P) => [
1681
+ P,
1704
1682
  Object.fromEntries(
1705
- g.map(({ locale: $, page: B }) => {
1706
- var q;
1707
- const G = (q = B.dataSource) == null ? void 0 : q[b];
1708
- if (G)
1709
- return [$, G];
1710
- const _ = B.sections.find((h) => h.id === b);
1711
- return [$, (_ == null ? void 0 : _.properties) || {}];
1683
+ g.map(({ locale: N, page: G }) => {
1684
+ var le;
1685
+ const ee = (le = G.dataSource) == null ? void 0 : le[P];
1686
+ if (ee)
1687
+ return [N, ee];
1688
+ const z = G.sections.find((h) => h.id === P);
1689
+ return [N, (z == null ? void 0 : z.properties) || {}];
1712
1690
  })
1713
1691
  )
1714
1692
  ])
1715
1693
  )
1716
1694
  };
1717
1695
  })
1718
- ), N = F(
1719
- ((r = l == null ? void 0 : l.routes) == null ? void 0 : r.map(({ path: E }) => {
1720
- const g = d ? D(d, Oe(E)) : void 0;
1696
+ ), L = U(
1697
+ ((r = p == null ? void 0 : p.routes) == null ? void 0 : r.map(({ path: E }) => {
1698
+ const g = d ? k(d, Oe(E)) : void 0;
1721
1699
  return {
1722
1700
  ...g,
1723
- id: (g == null ? void 0 : g.id) || $e(),
1701
+ id: (g == null ? void 0 : g.id) || Ye(),
1724
1702
  createdAt: (g == null ? void 0 : g.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
1725
1703
  updatedAt: (g == null ? void 0 : g.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
1726
1704
  publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
@@ -1733,31 +1711,31 @@ async function Et(e, { importAssets: n, includeResources: t } = {}) {
1733
1711
  dataSource: (g == null ? void 0 : g.dataSource) ?? {}
1734
1712
  };
1735
1713
  })) ?? []
1736
- ), ee = S ? F(((a = l.components) == null ? void 0 : a.map(({ id: E }) => w(S, E))) ?? []) : [];
1714
+ ), X = S ? U(((a = p.components) == null ? void 0 : a.map(({ id: E }) => w(S, E))) ?? []) : [];
1737
1715
  if (n) {
1738
1716
  const E = (...g) => {
1739
- y.info(`[${o ? J(e) : J(O(e, "../../../../"))}] importAssets:`, ...g);
1717
+ y.info(`[${o ? B(e) : B(A(e, "../../../../"))}] importAssets:`, ...g);
1740
1718
  };
1741
1719
  try {
1742
1720
  E("wait image-bin api ready"), await us({
1743
- resources: [`${Wt(bs)}/api/sdk/uploads`],
1744
- validateStatus: (k) => k >= 200 && k <= 500
1721
+ resources: [`${Wt(Is)}/api/sdk/uploads`],
1722
+ validateStatus: (v) => v >= 200 && v <= 500
1745
1723
  }), E("image-bin api is ready");
1746
- const g = {}, A = {};
1724
+ const g = {}, b = {};
1747
1725
  E("start to upload assets"), await Promise.allSettled([
1748
- ot(ee, g, {
1749
- getFilePath: (k) => S && O(S, k),
1750
- onFinish: (k) => {
1751
- E(`upload ${k.length} component assets`);
1726
+ ot(X, g, {
1727
+ getFilePath: (v) => S && A(S, v),
1728
+ onFinish: (v) => {
1729
+ E(`upload ${v.length} component assets`);
1752
1730
  }
1753
1731
  }),
1754
- ot(P, A, {
1755
- getFilePath: (k, te) => {
1756
- const b = Be(P, te.slice(0, 1));
1757
- return p && O(p, H(b.slug), k);
1732
+ ot(O, b, {
1733
+ getFilePath: (v, Z) => {
1734
+ const P = Fe(O, Z.slice(0, 1));
1735
+ return l && A(l, F(P.slug), v);
1758
1736
  },
1759
- onFinish: (k) => {
1760
- E(`upload ${k.length} page assets`);
1737
+ onFinish: (v) => {
1738
+ E(`upload ${v.length} page assets`);
1761
1739
  }
1762
1740
  })
1763
1741
  ]), E("upload assets done"), global.gc && global.gc();
@@ -1765,36 +1743,36 @@ async function Et(e, { importAssets: n, includeResources: t } = {}) {
1765
1743
  E("Error during asset import:", g);
1766
1744
  }
1767
1745
  }
1768
- const oe = {};
1746
+ const ne = {};
1769
1747
  if (t) {
1770
- const E = i && O(H(i), "../../resources/components"), g = F(
1771
- ((c = (u = l.resources) == null ? void 0 : u.components) == null ? void 0 : c.map(({ id: A }) => w(E, A))) ?? []
1748
+ const E = i && A(F(i), "../../resources/components"), g = U(
1749
+ ((c = (u = p.resources) == null ? void 0 : u.components) == null ? void 0 : c.map(({ id: b }) => w(E, b))) ?? []
1772
1750
  );
1773
- g.length > 0 && (oe.components = Object.fromEntries(
1774
- g.map((A, k) => [A.id, { index: k, component: A }])
1751
+ g.length > 0 && (ne.components = Object.fromEntries(
1752
+ g.map((b, v) => [b.id, { index: v, component: b }])
1775
1753
  ));
1776
1754
  }
1777
1755
  const pe = {};
1778
- if (f && K(f)) {
1756
+ if (f && J(f)) {
1779
1757
  const E = Ft(f);
1780
1758
  for (const g of E)
1781
- pe[g] = O(f, g);
1759
+ pe[g] = A(f, g);
1782
1760
  }
1783
1761
  return {
1784
- supportedLocales: l.supportedLocales,
1785
- pageIds: P.map((E) => E.id),
1786
- components: Object.fromEntries(ee.map((E, g) => [E.id, { index: g, data: E }])),
1787
- pages: Object.fromEntries(P.map((E) => [E.id, E])),
1788
- config: l.config || {},
1789
- resources: oe,
1762
+ supportedLocales: p.supportedLocales,
1763
+ pageIds: O.map((E) => E.id),
1764
+ components: Object.fromEntries(X.map((E, g) => [E.id, { index: g, data: E }])),
1765
+ pages: Object.fromEntries(O.map((E) => [E.id, E])),
1766
+ config: p.config || {},
1767
+ resources: ne,
1790
1768
  chunks: pe,
1791
- routeIds: N.map((E) => E.id),
1792
- routes: Object.fromEntries(N.map((E) => [E.id, E])),
1769
+ routeIds: L.map((E) => E.id),
1770
+ routes: Object.fromEntries(L.map((E) => [E.id, E])),
1793
1771
  dataSourceIds: [],
1794
1772
  dataSources: {}
1795
1773
  };
1796
1774
  } finally {
1797
- o && s && lt(s, { force: !0, recursive: !0 });
1775
+ o && s && pt(s, { force: !0, recursive: !0 });
1798
1776
  }
1799
1777
  }
1800
1778
  async function rt(e, n, {
@@ -1808,13 +1786,13 @@ async function rt(e, n, {
1808
1786
  } catch (f) {
1809
1787
  y.error("clear preload page cache error", { error: f });
1810
1788
  }
1811
- const { pages: a, pageIds: u, routeIds: c, routes: i, supportedLocales: p } = e;
1789
+ const { pages: a, pageIds: u, routeIds: c, routes: i, supportedLocales: l } = e;
1812
1790
  if (r === "production") {
1813
1791
  let f = t ?? [], d = null;
1814
- for (const l of c ?? []) {
1815
- const m = i == null ? void 0 : i[l];
1792
+ for (const p of c ?? []) {
1793
+ const m = i == null ? void 0 : i[p];
1816
1794
  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) {
1817
- const w = Fe({
1795
+ const w = Ue({
1818
1796
  basePath: m.path,
1819
1797
  params: m.params,
1820
1798
  routeId: m.id,
@@ -1823,71 +1801,71 @@ async function rt(e, n, {
1823
1801
  currentParams: [],
1824
1802
  currentOptionIds: [],
1825
1803
  result: []
1826
- }), D = Object.fromEntries(w.map((P) => [`${l}-${P.paramOptionIds.join("-")}`, P]));
1827
- d = { ...d || {}, ...D }, t || (f = [...f, ...w.map((P) => `${l}-${P.paramOptionIds.join("-")}`)]);
1828
- } else t || f.push(l);
1804
+ }), k = Object.fromEntries(w.map((O) => [`${p}-${O.paramOptionIds.join("-")}`, O]));
1805
+ d = { ...d || {}, ...k }, t || (f = [...f, ...w.map((O) => `${p}-${O.paramOptionIds.join("-")}`)]);
1806
+ } else t || f.push(p);
1829
1807
  }
1830
1808
  y.info("routeIds to be published: ", f);
1831
- for (const l of f) {
1832
- let m = l;
1809
+ for (const p of f) {
1810
+ let m = p;
1833
1811
  if (m.includes("-")) {
1834
- const [P] = m.split("-");
1835
- m = P;
1812
+ const [O] = m.split("-");
1813
+ m = O;
1836
1814
  }
1837
1815
  const w = i == null ? void 0 : i[m];
1838
1816
  if (!w) {
1839
- const P = n.pageIds.indexOf(m);
1840
- P !== -1 && o && (n.pageIds.splice(P, 1), delete n.pages[m]);
1841
- for (const N of n.pageIds)
1842
- N.includes(`${m}-`) && (n.pageIds.splice(n.pageIds.indexOf(N), 1), delete n.pages[N]);
1817
+ const O = n.pageIds.indexOf(m);
1818
+ O !== -1 && o && (n.pageIds.splice(O, 1), delete n.pages[m]);
1819
+ for (const L of n.pageIds)
1820
+ L.includes(`${m}-`) && (n.pageIds.splice(n.pageIds.indexOf(L), 1), delete n.pages[L]);
1843
1821
  y.info("delete main route page", m);
1844
1822
  continue;
1845
1823
  }
1846
- if (l.includes("-") && !(d != null && d[l])) {
1847
- const P = n.pageIds.indexOf(l);
1848
- P !== -1 && o && (n.pageIds.splice(P, 1), delete n.pages[l]), y.info("delete page", l);
1824
+ if (p.includes("-") && !(d != null && d[p])) {
1825
+ const O = n.pageIds.indexOf(p);
1826
+ O !== -1 && o && (n.pageIds.splice(O, 1), delete n.pages[p]), y.info("delete page", p);
1849
1827
  continue;
1850
1828
  }
1851
1829
  if (!w.displayTemplateId) {
1852
- y.info("no display template", l);
1830
+ y.info("no display template", p);
1853
1831
  continue;
1854
1832
  }
1855
- const D = a[w.displayTemplateId];
1856
- if (!D) {
1857
- y.info("no template page", l);
1833
+ const k = a[w.displayTemplateId];
1834
+ if (!k) {
1835
+ y.info("no template page", p);
1858
1836
  continue;
1859
1837
  }
1860
- if (n.pageIds.includes(l)) {
1861
- if (y.info("has need update page", l), s === "replace")
1862
- n.pages[l] = je({
1863
- page: D,
1838
+ if (n.pageIds.includes(p)) {
1839
+ if (y.info("has need update page", p), s === "replace")
1840
+ n.pages[p] = je({
1841
+ page: k,
1864
1842
  route: w,
1865
1843
  state: e,
1866
- routeId: l,
1867
- routePathInfo: d == null ? void 0 : d[l]
1868
- }), y.info("replace page", l);
1844
+ routeId: p,
1845
+ routePathInfo: d == null ? void 0 : d[p]
1846
+ }), y.info("replace page", p);
1869
1847
  else if (s === "byUpdateTime") {
1870
- const P = n.pages[w.id];
1871
- (!P || w.updatedAt && w.updatedAt > P.updatedAt) && (n.pages[l] = je({
1872
- page: D,
1848
+ const O = n.pages[w.id];
1849
+ (!O || w.updatedAt && w.updatedAt > O.updatedAt) && (n.pages[p] = je({
1850
+ page: k,
1873
1851
  route: w,
1874
1852
  state: e,
1875
- routeId: l,
1876
- routePathInfo: d == null ? void 0 : d[l]
1877
- }), y.info("replace page by update time", l));
1853
+ routeId: p,
1854
+ routePathInfo: d == null ? void 0 : d[p]
1855
+ }), y.info("replace page by update time", p));
1878
1856
  }
1879
1857
  } else
1880
- n.pageIds.push(l), n.pages[l] = je({
1881
- page: D,
1858
+ n.pageIds.push(p), n.pages[p] = je({
1859
+ page: k,
1882
1860
  route: w,
1883
1861
  state: e,
1884
- routeId: l,
1885
- routePathInfo: d == null ? void 0 : d[l]
1886
- }), y.info("add page", l);
1862
+ routeId: p,
1863
+ routePathInfo: d == null ? void 0 : d[p]
1864
+ }), y.info("add page", p);
1887
1865
  }
1888
1866
  if (o && !t)
1889
- for (const l of n.pageIds)
1890
- f != null && f.includes(l) || (delete n.pages[l], y.info("delete page", l)), n.pageIds = [...n.pageIds].filter((m) => f == null ? void 0 : f.includes(m));
1867
+ for (const p of n.pageIds)
1868
+ f != null && f.includes(p) || (delete n.pages[p], y.info("delete page", p)), n.pageIds = [...n.pageIds].filter((m) => f == null ? void 0 : f.includes(m));
1891
1869
  } else {
1892
1870
  for (const f of u) {
1893
1871
  const d = a[f];
@@ -1896,8 +1874,8 @@ async function rt(e, n, {
1896
1874
  if (s === "replace")
1897
1875
  n.pages[d.id] = d;
1898
1876
  else if (s === "byUpdateTime") {
1899
- const l = n.pages[d.id];
1900
- (!l || d.updatedAt && d.updatedAt > l.updatedAt) && (n.pages[d.id] = d);
1877
+ const p = n.pages[d.id];
1878
+ (!p || d.updatedAt && d.updatedAt > p.updatedAt) && (n.pages[d.id] = d);
1901
1879
  }
1902
1880
  } else
1903
1881
  n.pageIds.push(d.id), n.pages[d.id] = d;
@@ -1909,33 +1887,33 @@ async function rt(e, n, {
1909
1887
  if (s === "replace")
1910
1888
  n.routes[d.id] = d;
1911
1889
  else if (s === "byUpdateTime") {
1912
- const l = n.routes[d.id];
1913
- (!l || d.updatedAt && d.updatedAt > l.updatedAt) && (n.routes[d.id] = d);
1890
+ const p = n.routes[d.id];
1891
+ (!p || d.updatedAt && d.updatedAt > p.updatedAt) && (n.routes[d.id] = d);
1914
1892
  }
1915
1893
  } else
1916
1894
  n.routeIds.push(d.id), n.routes[d.id] = d;
1917
1895
  }
1918
1896
  }
1919
- if (n.supportedLocales.splice(0, n.supportedLocales.length), n.supportedLocales.push(...rs(p)), o)
1897
+ if (n.supportedLocales.splice(0, n.supportedLocales.length), n.supportedLocales.push(...as(l)), o)
1920
1898
  for (const f of Object.keys(n.components))
1921
1899
  delete n.components[f];
1922
1900
  let S = JSON.parse(JSON.stringify(e.components));
1923
1901
  S = Object.fromEntries(
1924
1902
  await Promise.all(
1925
1903
  Object.entries(S).map(async ([f, d]) => {
1926
- const l = await bt(d == null ? void 0 : d.data);
1904
+ const p = await It(d == null ? void 0 : d.data);
1927
1905
  return [
1928
1906
  f,
1929
1907
  {
1930
1908
  ...d,
1931
- data: l
1909
+ data: p
1932
1910
  }
1933
1911
  ];
1934
1912
  })
1935
1913
  )
1936
1914
  ), Object.assign(n.components, S), Object.assign(n.config, JSON.parse(JSON.stringify(e.config))), ut(e.resources.components) || (n.resources.components = JSON.parse(JSON.stringify(e.resources.components || {})));
1937
1915
  }
1938
- const bt = Ge(
1916
+ const It = Be(
1939
1917
  async (e) => {
1940
1918
  var n;
1941
1919
  if (!ut(e == null ? void 0 : e.properties))
@@ -1959,10 +1937,10 @@ const bt = Ge(
1959
1937
  },
1960
1938
  {
1961
1939
  keyGenerator: (e) => {
1962
- var i, p, S, f;
1963
- const n = (e == null ? void 0 : e.id) || "", t = (e == null ? void 0 : e.name) || "", s = ((i = e == null ? void 0 : e.renderer) == null ? void 0 : i.type) || "", o = (e == null ? void 0 : e.properties) || {}, r = (e == null ? void 0 : e.updatedAt) || "", a = ne("md5").update(JSON.stringify(o)).digest("hex");
1940
+ var i, l, S, f;
1941
+ const n = (e == null ? void 0 : e.id) || "", t = (e == null ? void 0 : e.name) || "", s = ((i = e == null ? void 0 : e.renderer) == null ? void 0 : i.type) || "", o = (e == null ? void 0 : e.properties) || {}, r = (e == null ? void 0 : e.updatedAt) || "", a = se("md5").update(JSON.stringify(o)).digest("hex");
1964
1942
  let u = "", c = "";
1965
- return ((p = e == null ? void 0 : e.renderer) == null ? void 0 : p.type) === "react-component" && (u = ne("md5").update(((S = e == null ? void 0 : e.renderer) == null ? void 0 : S.script) || "").digest("hex"), c = ne("md5").update(((f = e == null ? void 0 : e.renderer) == null ? void 0 : f.editComponent) || "").digest("hex")), JSON.stringify([
1943
+ return ((l = e == null ? void 0 : e.renderer) == null ? void 0 : l.type) === "react-component" && (u = se("md5").update(((S = e == null ? void 0 : e.renderer) == null ? void 0 : S.script) || "").digest("hex"), c = se("md5").update(((f = e == null ? void 0 : e.renderer) == null ? void 0 : f.editComponent) || "").digest("hex")), JSON.stringify([
1966
1944
  "checkPropertiesFromCode",
1967
1945
  n,
1968
1946
  t,
@@ -1980,8 +1958,8 @@ const bt = Ge(
1980
1958
  subdir: "checkPropertiesFromCode"
1981
1959
  }
1982
1960
  );
1983
- let Ce, ce, ve, ke, Je;
1984
- function It() {
1961
+ let Ce, ie, ve, ke, He;
1962
+ function bt() {
1985
1963
  return Ce = (async () => {
1986
1964
  const e = zt({
1987
1965
  types: [
@@ -1989,12 +1967,12 @@ function It() {
1989
1967
  { did: Ks, type: tt }
1990
1968
  ]
1991
1969
  });
1992
- ce = (await Promise.all(
1970
+ ie = (await Promise.all(
1993
1971
  e.map(async (t) => {
1994
1972
  const s = t.path ? await Et(t.path, { importAssets: !1 }) : void 0;
1995
1973
  return s ? { blockletId: t.did, state: s, blockletTitle: t.title } : void 0;
1996
1974
  })
1997
- )).filter((t) => !!t), ve = ce.reduce(
1975
+ )).filter((t) => !!t), ve = ie.reduce(
1998
1976
  (t, s) => Object.assign(
1999
1977
  t,
2000
1978
  Object.fromEntries(
@@ -2003,7 +1981,7 @@ function It() {
2003
1981
  ),
2004
1982
  {}
2005
1983
  );
2006
- const n = ce.reduce(
1984
+ const n = ie.reduce(
2007
1985
  (t, s) => Object.assign(
2008
1986
  t,
2009
1987
  Object.fromEntries(
@@ -2015,7 +1993,7 @@ function It() {
2015
1993
  ke = Object.fromEntries(
2016
1994
  await Promise.all(
2017
1995
  Object.entries(n).map(async ([t, s]) => {
2018
- const o = await bt(s.component);
1996
+ const o = await It(s.component);
2019
1997
  return [
2020
1998
  t,
2021
1999
  {
@@ -2025,34 +2003,34 @@ function It() {
2025
2003
  ];
2026
2004
  })
2027
2005
  )
2028
- ), Je = ce.reduce((t, s) => Object.assign(t, s.state.chunks), {});
2006
+ ), He = ie.reduce((t, s) => Object.assign(t, s.state.chunks), {});
2029
2007
  })(), Ce;
2030
2008
  }
2031
- function ln(e) {
2009
+ function pn(e) {
2032
2010
  const n = dt(
2033
2011
  async () => {
2034
- await It().catch((t) => {
2012
+ await bt().catch((t) => {
2035
2013
  y.error("load resource states error", { error: t });
2036
2014
  }), await (e == null ? void 0 : e({
2037
- states: ce,
2015
+ states: ie,
2038
2016
  pages: ve,
2039
2017
  components: ke,
2040
- chunks: Je
2018
+ chunks: He
2041
2019
  }));
2042
2020
  },
2043
2021
  3e3,
2044
2022
  // 3s
2045
2023
  { leading: !1, trailing: !0 }
2046
2024
  );
2047
- return n(), I.events.on(I.Events.componentAdded, n), I.events.on(I.Events.componentRemoved, n), I.events.on(I.Events.componentStarted, n), I.events.on(I.Events.componentStopped, n), I.events.on(I.Events.componentUpdated, n), I.events.on(Me, n), () => {
2048
- 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(Me, n);
2025
+ return n(), I.events.on(I.Events.componentAdded, n), I.events.on(I.Events.componentRemoved, n), I.events.on(I.Events.componentStarted, n), I.events.on(I.Events.componentStopped, n), I.events.on(I.Events.componentUpdated, n), I.events.on(_e, n), () => {
2026
+ 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);
2049
2027
  };
2050
2028
  }
2051
2029
  const At = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), Se = globalThis;
2052
2030
  var at;
2053
2031
  (at = Se[At]) == null || at.call(Se);
2054
- Se[At] = ln(async ({ pages: e, components: n }) => {
2055
- const { projectIds: t } = Z;
2032
+ Se[At] = pn(async ({ pages: e, components: n }) => {
2033
+ const { projectIds: t } = q;
2056
2034
  y.info(`start update resource states projects(${t.length})`, t), await Promise.race([
2057
2035
  new Promise((s) => {
2058
2036
  setTimeout(() => {
@@ -2072,28 +2050,28 @@ Se[At] = ln(async ({ pages: e, components: n }) => {
2072
2050
  y.error("update resource states failed:", s);
2073
2051
  });
2074
2052
  });
2075
- Z.startPeriodicCheck();
2053
+ q.startPeriodicCheck();
2076
2054
  process.on("beforeExit", () => {
2077
- Z.stopPeriodicCheck();
2055
+ q.stopPeriodicCheck();
2078
2056
  });
2079
2057
  process.on("SIGINT", () => {
2080
- Z.stopPeriodicCheck(), process.exit(0);
2058
+ q.stopPeriodicCheck(), process.exit(0);
2081
2059
  });
2082
2060
  process.on("SIGTERM", () => {
2083
- Z.stopPeriodicCheck(), process.exit(0);
2061
+ q.stopPeriodicCheck(), process.exit(0);
2084
2062
  });
2085
2063
  async function Ot({
2086
2064
  projectId: e,
2087
2065
  pages: n,
2088
2066
  components: t
2089
2067
  }) {
2090
- const s = Z.sharedInstances[e];
2068
+ const s = q.sharedInstances[e];
2091
2069
  if (!s) {
2092
2070
  y.info(`projectId: ${e} not found in sharedInstances`);
2093
2071
  return;
2094
2072
  }
2095
2073
  s.syncedStore.resources.pages = n;
2096
- const o = await X.findByPk(e);
2074
+ const o = await Q.findByPk(e);
2097
2075
  if (o != null && o.useAllResources)
2098
2076
  s.syncedStore.resources.components = t;
2099
2077
  else {
@@ -2107,42 +2085,41 @@ async function Ot({
2107
2085
  components: Object.keys(s.syncedStore.resources.components || {}).length
2108
2086
  });
2109
2087
  }
2110
- async function ao() {
2111
- y.info("trigger reload all project resource"), I.events.emit(Me);
2088
+ async function io() {
2089
+ y.info("trigger reload all project resource"), I.events.emit(_e);
2112
2090
  }
2113
- async function Ve({
2091
+ async function Je({
2114
2092
  ensureLoaded: e = !0
2115
2093
  } = {}) {
2116
- return e && (Ce ?? (Ce = It()), await Ce), { states: ce, pages: ve, components: ke, chunks: Je };
2094
+ return e && (Ce ?? (Ce = bt()), await Ce), { states: ie, pages: ve, components: ke, chunks: He };
2117
2095
  }
2118
2096
  export {
2119
2097
  yt as C,
2120
2098
  et as G,
2121
- X as P,
2099
+ Q as P,
2122
2100
  tt as R,
2123
- Z as S,
2124
- to as a,
2125
- Ve as b,
2101
+ q as S,
2102
+ so as a,
2103
+ Je as b,
2126
2104
  Ns as c,
2127
2105
  _s as d,
2128
2106
  Ms as e,
2129
2107
  Us as f,
2130
- so as g,
2108
+ no as g,
2131
2109
  Fs as h,
2132
- eo as i,
2110
+ to as i,
2133
2111
  Ee as j,
2134
- no as k,
2112
+ oo as k,
2135
2113
  y as l,
2136
2114
  Js as m,
2137
- $e as n,
2138
- de as o,
2139
- oo as p,
2140
- ro as q,
2141
- rn as r,
2142
- an as s,
2115
+ de as n,
2116
+ ro as o,
2117
+ ao as p,
2118
+ rn as q,
2119
+ an as r,
2120
+ Et as s,
2143
2121
  cn as t,
2144
- Et as u,
2145
- rt as v,
2146
- ln as w,
2147
- ao as x
2122
+ rt as u,
2123
+ pn as v,
2124
+ io as w
2148
2125
  };