@blocklet/pages-kit-inner-components 0.6.76 → 0.6.78

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 (32) hide show
  1. package/lib/cjs/add-component.js +1 -1
  2. package/lib/cjs/chunks/{draft-data-1hI-ev3X.js → draft-data-CkVvOh60.js} +1 -1
  3. package/lib/cjs/chunks/{home-BEBAcHLJ.js → home-CjhOAEa7.js} +2 -2
  4. package/lib/cjs/chunks/html-xfTPTsl5.js +1 -0
  5. package/lib/cjs/chunks/{index-DC4XWhpO.js → index-CiYwdeK9.js} +1 -1
  6. package/lib/cjs/chunks/{publish-button-Brxy74Ql.js → publish-button-DV23sfgB.js} +1 -1
  7. package/lib/cjs/chunks/site-state-CtiXHtSX.js +1 -0
  8. package/lib/cjs/chunks/state-BdtFHk36.js +1 -0
  9. package/lib/cjs/home.js +1 -1
  10. package/lib/cjs/locales.js +2 -2
  11. package/lib/cjs/project-html.js +1 -1
  12. package/lib/cjs/resources.js +1 -1
  13. package/lib/cjs/setting.js +2 -2
  14. package/lib/cjs/site-state.js +1 -1
  15. package/lib/es/add-component.js +2 -2
  16. package/lib/es/chunks/{draft-data--WtLtXxy.js → draft-data-BOoVhbon.js} +1 -1
  17. package/lib/es/chunks/{home-iBLOByRu.js → home-BZB9zOlO.js} +3 -3
  18. package/lib/es/chunks/{html-DfzaaIYa.js → html-DOgzvdOd.js} +11 -10
  19. package/lib/es/chunks/{index-BlZcgfTW.js → index-Bggolyu_.js} +2 -2
  20. package/lib/es/chunks/{publish-button-CHmiGlT7.js → publish-button-Dm2Nce-b.js} +3 -3
  21. package/lib/es/chunks/{site-state-BXM-5tZw.js → site-state-D4wvb7PN.js} +300 -300
  22. package/lib/es/chunks/{state-DS2djQbR.js → state-DNdwHwty.js} +173 -165
  23. package/lib/es/home.js +3 -3
  24. package/lib/es/locales.js +2 -0
  25. package/lib/es/project-html.js +1 -1
  26. package/lib/es/resources.js +1 -1
  27. package/lib/es/setting.js +680 -670
  28. package/lib/es/site-state.js +1 -1
  29. package/package.json +3 -3
  30. package/lib/cjs/chunks/html-JOhPskS4.js +0 -1
  31. package/lib/cjs/chunks/site-state-CcYU6tKv.js +0 -1
  32. package/lib/cjs/chunks/state-BAjDjwwp.js +0 -1
@@ -1,11 +1,11 @@
1
- import { d as $e, l as f, I as Qe, c as Xe, m as Ze, b as et } from "./components-DLwSTd_N.js";
1
+ import { d as Ue, l as f, I as Qe, c as Xe, m as Ze, b as et } from "./components-DLwSTd_N.js";
2
2
  import { getYjsValue as V, syncedStore as tt } from "@syncedstore/core";
3
3
  import * as N from "yjs";
4
4
  import { setPageDataSource as st } from "@blocklet/pages-kit/utils/data-source";
5
5
  import { getRouteMetaDataByOptionIds as at, generateParamCombinations as Se } from "@blocklet/pages-kit/utils/route";
6
- import Ue from "lodash/cloneDeep";
6
+ import $e from "lodash/cloneDeep";
7
7
  import E from "@blocklet/sdk/lib/config";
8
- import { mkdtempSync as ot, existsSync as U, readFileSync as q, renameSync as Ce, mkdirSync as _, rmSync as Me, writeFileSync as ee, copyFileSync as rt, lstatSync as B, readdirSync as nt, createWriteStream as it } from "fs";
8
+ import { mkdtempSync as ot, existsSync as $, readFileSync as q, renameSync as Ce, mkdirSync as _, rmSync as Me, writeFileSync as ee, copyFileSync as rt, lstatSync as B, readdirSync as nt, createWriteStream as it } from "fs";
9
9
  import { join as b, basename as R, dirname as L } from "path";
10
10
  import { nextId as Oe } from "@blocklet/pages-kit/utils/common";
11
11
  import { unzipSection as ct } from "@blocklet/pages-kit/utils/page-model";
@@ -14,7 +14,7 @@ import { getComponentWebEndpoint as lt, getResources as ut, call as dt } from "@
14
14
  import { reactive as ft } from "@reactivedata/reactive";
15
15
  import { globSync as te } from "glob";
16
16
  import * as ue from "lib0/decoding";
17
- import * as T from "lib0/encoding";
17
+ import * as k from "lib0/encoding";
18
18
  import Ne from "lodash/debounce";
19
19
  import Ie from "lodash/get";
20
20
  import Ee from "lodash/isEmpty";
@@ -22,22 +22,22 @@ import ve from "lodash/set";
22
22
  import mt from "lodash/union";
23
23
  import { LRUCache as be } from "lru-cache";
24
24
  import gt from "p-limit";
25
- import { DataTypes as k, Sequelize as ht, Model as Fe, Op as _e } from "sequelize";
25
+ import { DataTypes as j, Sequelize as ht, Model as Fe, Op as _e } from "sequelize";
26
26
  import { pipeline as yt } from "stream/promises";
27
27
  import { x as St } from "tar";
28
- import { joinURL as H } from "ufo";
29
- import It from "wait-on";
30
- import { Awareness as Et, encodeAwarenessUpdate as je, removeAwarenessStates as bt, applyAwarenessUpdate as wt } from "y-protocols/awareness";
31
- import { writeUpdate as At, writeSyncStep1 as Pt, readSyncMessage as Ct } from "y-protocols/sync";
28
+ import { withoutTrailingSlash as It, joinURL as H } from "ufo";
29
+ import Et from "wait-on";
30
+ import { Awareness as bt, encodeAwarenessUpdate as Te, removeAwarenessStates as wt, applyAwarenessUpdate as At } from "y-protocols/awareness";
31
+ import { writeUpdate as Pt, writeSyncStep1 as Ct, readSyncMessage as Ot } from "y-protocols/sync";
32
32
  import * as G from "yaml";
33
- import { m as ke } from "./html-DfzaaIYa.js";
33
+ import { m as je } from "./html-DOgzvdOd.js";
34
34
  import "sqlite3";
35
35
  import "@blocklet/pages-kit/types/state";
36
- const Ot = k.sqlite.DATE.parse;
37
- k.sqlite.DATE.parse = (t, e) => typeof t == "number" ? new Date(t) : Ot(t, e);
36
+ const vt = j.sqlite.DATE.parse;
37
+ j.sqlite.DATE.parse = (t, e) => typeof t == "number" ? new Date(t) : vt(t, e);
38
38
  const F = new ht({
39
39
  dialect: "sqlite",
40
- storage: $e,
40
+ storage: Ue,
41
41
  benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
42
42
  retry: {
43
43
  match: [/SQLITE_BUSY/],
@@ -59,7 +59,7 @@ process.on("SIGINT", async () => {
59
59
  process.on("SIGTERM", async () => {
60
60
  await F.close(), process.exit(0);
61
61
  });
62
- async function vt(t, e) {
62
+ async function Tt(t, e) {
63
63
  try {
64
64
  if (t.getDialect() !== "sqlite")
65
65
  return;
@@ -77,7 +77,7 @@ let me = null;
77
77
  me && clearInterval(me);
78
78
  me = setInterval(
79
79
  async () => {
80
- f.info("Start cleanupSqliteMemory"), await vt(F, $e), f.info("End cleanupSqliteMemory");
80
+ f.info("Start cleanupSqliteMemory"), await Tt(F, Ue), f.info("End cleanupSqliteMemory");
81
81
  },
82
82
  60 * 1e3 * 10
83
83
  // 10 minutes
@@ -88,17 +88,17 @@ class we extends Fe {
88
88
  we.init(
89
89
  {
90
90
  id: {
91
- type: k.UUID,
91
+ type: j.UUID,
92
92
  allowNull: !1,
93
93
  primaryKey: !0,
94
- defaultValue: k.UUIDV4
94
+ defaultValue: j.UUIDV4
95
95
  },
96
96
  projectId: {
97
- type: k.UUID,
97
+ type: j.UUID,
98
98
  allowNull: !1
99
99
  },
100
100
  componentId: {
101
- type: k.STRING,
101
+ type: j.STRING,
102
102
  allowNull: !1
103
103
  }
104
104
  },
@@ -116,32 +116,32 @@ class M extends Fe {
116
116
  M.init(
117
117
  {
118
118
  id: {
119
- type: k.UUID,
120
- defaultValue: k.UUIDV4,
119
+ type: j.UUID,
120
+ defaultValue: j.UUIDV4,
121
121
  primaryKey: !0
122
122
  },
123
123
  name: {
124
- type: k.STRING,
124
+ type: j.STRING,
125
125
  allowNull: !1
126
126
  },
127
- description: k.TEXT,
128
- createdAt: k.DATE,
129
- updatedAt: k.DATE,
127
+ description: j.TEXT,
128
+ createdAt: j.DATE,
129
+ updatedAt: j.DATE,
130
130
  createdBy: {
131
- type: k.STRING,
131
+ type: j.STRING,
132
132
  allowNull: !1
133
133
  },
134
134
  updatedBy: {
135
- type: k.STRING,
135
+ type: j.STRING,
136
136
  allowNull: !1
137
137
  },
138
- slug: k.STRING,
139
- icon: k.STRING,
140
- pinnedAt: k.DATE,
141
- useAllResources: k.BOOLEAN,
142
- npmSecret: k.STRING,
138
+ slug: j.STRING,
139
+ icon: j.STRING,
140
+ pinnedAt: j.DATE,
141
+ useAllResources: j.BOOLEAN,
142
+ npmSecret: j.STRING,
143
143
  relatedBlocklets: {
144
- type: k.JSON,
144
+ type: j.JSON,
145
145
  allowNull: !1,
146
146
  defaultValue: {},
147
147
  get() {
@@ -163,7 +163,7 @@ M.init(
163
163
  }
164
164
  },
165
165
  productionState: {
166
- type: k.JSON,
166
+ type: j.JSON,
167
167
  allowNull: !1,
168
168
  defaultValue: {},
169
169
  get() {
@@ -191,7 +191,7 @@ M.hasMany(we, {
191
191
  foreignKey: "projectId",
192
192
  as: "components"
193
193
  });
194
- const jt = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", Te = "page", ge = "trigger-reload-project-resource", xe = jt, kt = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
194
+ const jt = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", ke = "page", ge = "trigger-reload-project-resource", xe = jt, kt = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
195
195
  function se(t) {
196
196
  t.observeDeep((e) => {
197
197
  e.some((s) => s.changes.keys.has("updatedAt") || s.changes.keys.has("publishedAt")) || t.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
@@ -206,7 +206,7 @@ function ae(t, e, s = []) {
206
206
  function D(t) {
207
207
  return t.filter((e) => e != null);
208
208
  }
209
- function Tt(t) {
209
+ function Dt(t) {
210
210
  t.pages && Object.keys(t.pages).forEach((s) => {
211
211
  const a = V(t.pages[s]);
212
212
  a && a instanceof N.Map && se(a);
@@ -221,7 +221,7 @@ function Tt(t) {
221
221
  });
222
222
  });
223
223
  }
224
- function Dt(t) {
224
+ function Rt(t) {
225
225
  t.routes && Object.keys(t.routes).forEach((s) => {
226
226
  const a = V(t.routes?.[s]);
227
227
  a && a instanceof N.Map && se(a);
@@ -236,12 +236,12 @@ function Dt(t) {
236
236
  });
237
237
  });
238
238
  }
239
- function Rt(t, e) {
239
+ function Lt(t, e) {
240
240
  for (const s of e || Object.keys(t.routes || {})) {
241
241
  let a = s, o = [];
242
242
  if (s.includes("-")) {
243
- const [r, ...c] = s.split("-");
244
- a = r, o = c || [];
243
+ const [r, ...i] = s.split("-");
244
+ a = r, o = i || [];
245
245
  }
246
246
  if (t.routes?.[a] !== void 0) {
247
247
  t.routes[a].publishedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -249,11 +249,11 @@ function Rt(t, e) {
249
249
  if (!r || !r.params || r.params.length === 0)
250
250
  continue;
251
251
  if (s.includes("-") && o.length > 0) {
252
- const c = at(o, r);
253
- c && (c.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
252
+ const i = at(o, r);
253
+ i && (i.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
254
254
  }
255
255
  if (!e) {
256
- const c = Se({
256
+ const i = Se({
257
257
  basePath: r.path,
258
258
  params: r.params,
259
259
  routeId: r.id,
@@ -263,8 +263,8 @@ function Rt(t, e) {
263
263
  currentOptionIds: [],
264
264
  result: []
265
265
  });
266
- for (const l of c)
267
- l.routeMetaData ??= {}, l.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString();
266
+ for (const p of i)
267
+ p.routeMetaData ??= {}, p.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString();
268
268
  }
269
269
  }
270
270
  }
@@ -280,7 +280,7 @@ function de({
280
280
  `Executing datasource data assembly, routeId: ${a}, routePathInfo: ${JSON.stringify(o)}`
281
281
  );
282
282
  const r = {
283
- ...Ue(t),
283
+ ...$e(t),
284
284
  id: a,
285
285
  slug: o?.path ?? e.path,
286
286
  createdAt: e.createdAt,
@@ -288,54 +288,54 @@ function de({
288
288
  publishedAt: o?.routeMetaData?.publishedAt ?? e.publishedAt,
289
289
  isPublic: (o?.routeMetaData?.isPublic ?? e.isPublic) && e.isPublic
290
290
  };
291
- for (const c of s.supportedLocales) {
291
+ for (const i of s.supportedLocales) {
292
292
  if (e.dataSource) {
293
- let l = e.id;
294
- o && (l = o.paramOptionIds.join("-"));
295
- const p = e.dataSource.pathDataMappings?.[l]?.dataCache?.[c.locale] ?? e.dataSource.pathDataMappings?.[l]?.dataCache?.[s.config.defaultLocale || "en"];
296
- if (!p)
293
+ let p = e.id;
294
+ o && (p = o.paramOptionIds.join("-"));
295
+ const l = e.dataSource.pathDataMappings?.[p]?.dataCache?.[i.locale] ?? e.dataSource.pathDataMappings?.[p]?.dataCache?.[s.config.defaultLocale || "en"];
296
+ if (!l)
297
297
  continue;
298
- st(r, s, c.locale, p);
298
+ st(r, s, i.locale, l);
299
299
  }
300
300
  o && o.routeMetaData && (o.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
301
301
  }
302
302
  return r;
303
303
  }
304
304
  ["true", "1", "yes", "y"].includes(process.env.USE_FS_CACHE_HTML ?? "");
305
- const Lt = 60 * 60 * 1e3, Y = new be({
305
+ const Ut = 60 * 60 * 1e3, Y = new be({
306
306
  max: 100,
307
- ttl: Lt,
307
+ ttl: Ut,
308
308
  ttlResolution: 10 * 1e3,
309
309
  // 10 seconds
310
310
  allowStale: !0
311
311
  });
312
312
  function $t(t, e = []) {
313
313
  let s = 0;
314
- const a = Array.from(Y.keys());
315
- for (const o of a)
316
- for (const r of t) {
317
- if (ke(o, { currentPath: r })) {
318
- Y.delete(o), s++, f.info(`[Cache CLEAR] key: ${o}`);
314
+ const a = Array.from(Y.keys()), o = t.map((r) => It(r));
315
+ for (const r of a)
316
+ for (const i of o) {
317
+ if (je(r, { currentPath: i })) {
318
+ Y.delete(r), s++, f.info(`[Cache CLEAR] key: ${r}`);
319
319
  break;
320
320
  }
321
- for (const c of e)
322
- if (ke(o, { currentPath: `/${c}${r}` })) {
323
- Y.delete(o), s++, f.info(`[Cache CLEAR] key: ${o}`);
321
+ for (const p of e)
322
+ if (je(r, { currentPath: `/${p}${i}` })) {
323
+ Y.delete(r), s++, f.info(`[Cache CLEAR] key: ${r}`);
324
324
  break;
325
325
  }
326
326
  }
327
- return f.info(`[Cache CLEAR] cleared ${s} entries for paths:`, t), s;
327
+ return f.info(`[Cache CLEAR] cleared ${s} entries for paths:`, o), s;
328
328
  }
329
- function Ut() {
329
+ function Mt() {
330
330
  const t = Y.size;
331
331
  return Y.clear(), f.info(`[Cache CLEAR ALL] cleared ${t} entries`), t;
332
332
  }
333
- E.events.on(E.Events.envUpdate, Ut);
334
- const { uploadToMediaKit: Mt } = require("@blocklet/uploader-server"), Ae = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, W = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, De = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Nt = 1e4, Ft = 3e4, X = 0, fe = 1, _t = 0, xt = 1, he = E, K = b(process.env.BLOCKLET_DATA_DIR, "site-state"), Cs = ["production", "draft"], Os = ["production"];
333
+ E.events.on(E.Events.envUpdate, Mt);
334
+ const { uploadToMediaKit: Nt } = require("@blocklet/uploader-server"), Ae = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, W = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, De = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Ft = 1e4, _t = 3e4, X = 0, fe = 1, xt = 0, Bt = 1, he = E, K = b(process.env.BLOCKLET_DATA_DIR, "site-state"), Os = ["production", "draft"], vs = ["production"];
335
335
  function oe(t) {
336
336
  return t?.replace(/\//g, "|") || "";
337
337
  }
338
- function Bt() {
338
+ function Gt() {
339
339
  const t = he.env.languages?.map((s) => ({ locale: s.code, name: s.name })) || [], e = t[0]?.locale || "en";
340
340
  return {
341
341
  pageIds: [],
@@ -352,7 +352,7 @@ function Bt() {
352
352
  }
353
353
  class O extends N.Doc {
354
354
  constructor(e) {
355
- super(), this.options = e, U(this.draftYjsFilePath) && N.applyUpdate(this, q(this.draftYjsFilePath)), this.syncedStore = ft(
355
+ super(), this.options = e, $(this.draftYjsFilePath) && N.applyUpdate(this, q(this.draftYjsFilePath)), this.syncedStore = ft(
356
356
  tt(
357
357
  {
358
358
  pages: {},
@@ -368,7 +368,7 @@ class O extends N.Doc {
368
368
  },
369
369
  this
370
370
  )
371
- ), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new Et(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
371
+ ), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new bt(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
372
372
  }
373
373
  // 延迟释放时间:5 分钟
374
374
  static RELEASE_DELAY = 5 * 60 * 1e3;
@@ -423,10 +423,10 @@ class O extends N.Doc {
423
423
  attributes: ["productionState"]
424
424
  });
425
425
  if (Ee(s?.productionState)) {
426
- const a = b(K, e, "production"), o = await Ve(a, { includeResources: !0 }) ?? Bt();
426
+ const a = b(K, e, "production"), o = await Ve(a, { includeResources: !0 }) ?? Gt();
427
427
  if (!o?.config?.defaultLocale) {
428
428
  o.config ??= {};
429
- const r = he.env.languages?.map((c) => ({ locale: c.code, name: c.name })) || [];
429
+ const r = he.env.languages?.map((i) => ({ locale: i.code, name: i.name })) || [];
430
430
  o.config.defaultLocale = r[0]?.locale;
431
431
  }
432
432
  return o;
@@ -439,7 +439,7 @@ class O extends N.Doc {
439
439
  delete O.sharedInstances[e], super.destroy();
440
440
  }
441
441
  initObserver() {
442
- Tt(this.syncedStore), Dt(this.syncedStore);
442
+ Dt(this.syncedStore), Rt(this.syncedStore);
443
443
  }
444
444
  get draftYjsFilePath() {
445
445
  return b(this.options.path, "draft.yjs");
@@ -458,7 +458,7 @@ class O extends N.Doc {
458
458
  return O.getProductionState(s);
459
459
  }
460
460
  async setState(e, s) {
461
- const a = await Jt(s, { exportAssets: !1, includeResources: !0 }), o = this.getPublishDir(e);
461
+ const a = await Kt(s, { exportAssets: !1, includeResources: !0 }), o = this.getPublishDir(e);
462
462
  if (_(L(o), { recursive: !0 }), Me(o, { force: !0, recursive: !0 }), Ce(a, o), e === "production") {
463
463
  const r = R(this.options.path);
464
464
  O.pageUrlMapCache.delete(r), await M.update({ productionState: { ...s } }, { where: { id: r } });
@@ -475,54 +475,54 @@ class O extends N.Doc {
475
475
  awarenessChangeHandler = ({ added: e, updated: s, removed: a }, o) => {
476
476
  const r = e.concat(s, a);
477
477
  if (o !== null) {
478
- const p = this.conns.get(o);
479
- p && (e.forEach((y) => {
480
- p.add(y);
478
+ const l = this.conns.get(o);
479
+ l && (e.forEach((y) => {
480
+ l.add(y);
481
481
  }), a.forEach((y) => {
482
- p.delete(y);
482
+ l.delete(y);
483
483
  }));
484
484
  }
485
- const c = T.createEncoder();
486
- T.writeVarUint(c, fe), T.writeVarUint8Array(c, je(this.awareness, r));
487
- const l = T.toUint8Array(c);
488
- this.conns.forEach((p, y) => this.send(y, l));
485
+ const i = k.createEncoder();
486
+ k.writeVarUint(i, fe), k.writeVarUint8Array(i, Te(this.awareness, r));
487
+ const p = k.toUint8Array(i);
488
+ this.conns.forEach((l, y) => this.send(y, p));
489
489
  };
490
490
  updateHandler = (e) => {
491
- const s = T.createEncoder();
492
- T.writeVarUint(s, X), At(s, e);
493
- const a = T.toUint8Array(s);
491
+ const s = k.createEncoder();
492
+ k.writeVarUint(s, X), Pt(s, e);
493
+ const a = k.toUint8Array(s);
494
494
  this.conns.forEach((o, r) => this.send(r, a));
495
495
  };
496
496
  ensureDataStructure = () => {
497
- const { supportedLocales: e, pages: s, pageIds: a, config: o, routes: r, routeIds: c } = this.syncedStore;
497
+ const { supportedLocales: e, pages: s, pageIds: a, config: o, routes: r, routeIds: i } = this.syncedStore;
498
498
  {
499
- const l = new Set(Object.keys(s));
500
- let p = 0;
501
- for (; p < a.length; ) {
502
- const y = a[p];
503
- l.has(y) ? (l.delete(y), p++) : a.splice(p, 1);
499
+ const p = new Set(Object.keys(s));
500
+ let l = 0;
501
+ for (; l < a.length; ) {
502
+ const y = a[l];
503
+ p.has(y) ? (p.delete(y), l++) : a.splice(l, 1);
504
504
  }
505
505
  }
506
506
  {
507
- const l = new Set(Object.keys(r));
508
- let p = 0;
509
- for (; p < c.length; ) {
510
- const y = c[p];
511
- l.has(y) ? (l.delete(y), p++) : c.splice(p, 1);
507
+ const p = new Set(Object.keys(r));
508
+ let l = 0;
509
+ for (; l < i.length; ) {
510
+ const y = i[l];
511
+ p.has(y) ? (p.delete(y), l++) : i.splice(l, 1);
512
512
  }
513
513
  }
514
- e.splice(0, e.length), e.push(...he.env.languages.map((l) => ({ locale: l.code, name: l.name }))), o.defaultLocale = e[0]?.locale;
514
+ e.splice(0, e.length), e.push(...he.env.languages.map((p) => ({ locale: p.code, name: p.name }))), o.defaultLocale = e[0]?.locale;
515
515
  {
516
- let l = 0;
517
- const p = /* @__PURE__ */ new Set();
518
- for (; l < e.length; ) {
519
- const { locale: y } = e[l];
520
- p.has(y) ? e.splice(l, 1) : (l++, p.add(y));
516
+ let p = 0;
517
+ const l = /* @__PURE__ */ new Set();
518
+ for (; p < e.length; ) {
519
+ const { locale: y } = e[p];
520
+ l.has(y) ? e.splice(p, 1) : (p++, l.add(y));
521
521
  }
522
522
  }
523
523
  };
524
524
  send = (e, s) => {
525
- e.readyState !== _t && e.readyState !== xt && this.closeConn(e);
525
+ e.readyState !== xt && e.readyState !== Bt && this.closeConn(e);
526
526
  try {
527
527
  e.send(s, (a) => {
528
528
  a && this.closeConn(e);
@@ -534,7 +534,7 @@ class O extends N.Doc {
534
534
  closeConn = (e) => {
535
535
  if (e.removeAllListeners(), this.conns.has(e)) {
536
536
  const s = this.conns.get(e);
537
- this.conns.delete(e), s && bt(this.awareness, Array.from(s), null);
537
+ this.conns.delete(e), s && wt(this.awareness, Array.from(s), null);
538
538
  }
539
539
  e.close(), this.checkAndScheduleRelease();
540
540
  };
@@ -560,42 +560,42 @@ class O extends N.Doc {
560
560
  }
561
561
  autoSave = Ne(() => {
562
562
  _(L(this.draftYjsFilePath), { recursive: !0 }), ee(this.draftYjsFilePath, N.encodeStateAsUpdate(this));
563
- }, Nt);
563
+ }, Ft);
564
564
  save = ({ flush: e = !1 } = {}) => {
565
565
  this.autoSave(), e && this.autoSave.flush();
566
566
  };
567
567
  publish = async ({ mode: e, routes: s }) => {
568
568
  const a = await this.getState("draft"), o = await this.getState("production");
569
- await Le(a, o, { routes: s, mergeMode: "replace", deleteRoutes: !0, publishMode: e }), o.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Rt(this.syncedStore, s), await this.setState(e, o), await this.clearPageCacheForRoutes(s, o);
569
+ await Le(a, o, { routes: s, mergeMode: "replace", deleteRoutes: !0, publishMode: e }), o.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Lt(this.syncedStore, s), await this.setState(e, o), await this.clearPageCacheForRoutes(s, o);
570
570
  };
571
571
  mergeState = async (e, s) => {
572
572
  const a = JSON.parse(JSON.stringify(s));
573
573
  e.config.fontFamily ??= {};
574
574
  const o = a.config?.fontFamily, r = e.config?.fontFamily;
575
- e.config.fontFamily.title = o?.title || r?.title, e.config.fontFamily.description = o?.description || r?.description, await new Promise((c, l) => {
575
+ e.config.fontFamily.title = o?.title || r?.title, e.config.fontFamily.description = o?.description || r?.description, await new Promise((i, p) => {
576
576
  this.transact(async () => {
577
577
  try {
578
- const p = await Le(e, s);
579
- c(p);
580
- } catch (p) {
581
- l(p);
578
+ const l = await Le(e, s);
579
+ i(l);
580
+ } catch (l) {
581
+ p(l);
582
582
  }
583
583
  });
584
584
  });
585
585
  };
586
586
  clearPageCacheForRoutes = async (e, s) => {
587
587
  const a = R(this.options.path), r = (await M.findByPk(a))?.slug || a;
588
- let c = e;
589
- (!c || c.length === 0) && (c = s.pageIds ?? []), f.info(`[SiteState] clearing page cache for project ${a}, routes:`, c || []);
590
- const l = s.supportedLocales.map((w) => w.locale), p = [], y = c.filter((w) => s.pageIds?.includes(w));
588
+ let i = e;
589
+ (!i || i.length === 0) && (i = s.pageIds ?? []), f.info(`[SiteState] clearing page cache for project ${a}, routes:`, i || []);
590
+ const p = s.supportedLocales.map((w) => w.locale), l = [], y = i.filter((w) => s.pageIds?.includes(w));
591
591
  for (const w of y) {
592
592
  const I = s.pages[w].slug;
593
- r && r !== a && (r === "/" ? p.push(I) : p.push(`/${r}${I}`)), p.push(`/${a}${I}`);
593
+ r && r !== a && (r === "/" ? l.push(I) : l.push(`/${r}${I}`)), l.push(`/${a}${I}`);
594
594
  }
595
- if (f.info(`[SiteState] clearing page cache for project ${a}, pathPatterns:`, p), p.length > 0)
595
+ if (l.length > 0)
596
596
  try {
597
- const w = $t(p, l);
598
- f.info(`[SiteState] cleared ${w} page cache entries for project ${a}, routes:`, c);
597
+ const w = $t(l, p);
598
+ f.info(`[SiteState] cleared ${w} page cache entries for project ${a}, routes:`, i);
599
599
  } catch {
600
600
  }
601
601
  };
@@ -615,31 +615,31 @@ class O extends N.Doc {
615
615
  this.closeConn(e), clearInterval(a);
616
616
  }
617
617
  }
618
- }, Ft);
618
+ }, _t);
619
619
  e.on("close", () => {
620
620
  this.closeConn(e), clearInterval(a);
621
621
  }), e.on("pong", () => {
622
622
  s = !0;
623
623
  });
624
624
  {
625
- const o = T.createEncoder();
626
- T.writeVarUint(o, X), Pt(o, this), this.send(e, T.toUint8Array(o));
625
+ const o = k.createEncoder();
626
+ k.writeVarUint(o, X), Ct(o, this), this.send(e, k.toUint8Array(o));
627
627
  const r = this.awareness.getStates();
628
628
  if (r.size > 0) {
629
- const c = T.createEncoder();
630
- T.writeVarUint(c, fe), T.writeVarUint8Array(c, je(this.awareness, Array.from(r.keys()))), this.send(e, T.toUint8Array(c));
629
+ const i = k.createEncoder();
630
+ k.writeVarUint(i, fe), k.writeVarUint8Array(i, Te(this.awareness, Array.from(r.keys()))), this.send(e, k.toUint8Array(i));
631
631
  }
632
632
  }
633
633
  };
634
634
  messageListener = (e, s) => {
635
635
  try {
636
- const a = T.createEncoder(), o = ue.createDecoder(s), r = ue.readVarUint(o);
636
+ const a = k.createEncoder(), o = ue.createDecoder(s), r = ue.readVarUint(o);
637
637
  switch (r) {
638
638
  case X:
639
- T.writeVarUint(a, X), Ct(o, a, this, null), T.length(a) > 1 && (this.ensureDataStructure(), this.send(e, T.toUint8Array(a)));
639
+ k.writeVarUint(a, X), Ot(o, a, this, null), k.length(a) > 1 && (this.ensureDataStructure(), this.send(e, k.toUint8Array(a)));
640
640
  break;
641
641
  case fe: {
642
- wt(this.awareness, ue.readVarUint8Array(o), e);
642
+ At(this.awareness, ue.readVarUint8Array(o), e);
643
643
  break;
644
644
  }
645
645
  default:
@@ -656,10 +656,10 @@ class O extends N.Doc {
656
656
  s ? a = [s] : a = await this.getProjectIds();
657
657
  let o = {};
658
658
  if (e === "production" && a?.length) {
659
- const r = new Map(a?.map((c) => [c, !0]) || []);
660
- for (const c of a) {
661
- const l = O.pageUrlMapCache.get(c);
662
- l && (o = { ...o, ...l }, r.delete(c));
659
+ const r = new Map(a?.map((i) => [i, !0]) || []);
660
+ for (const i of a) {
661
+ const p = O.pageUrlMapCache.get(i);
662
+ p && (o = { ...o, ...p }, r.delete(i));
663
663
  }
664
664
  a = Array.from(r.keys());
665
665
  }
@@ -672,35 +672,35 @@ class O extends N.Doc {
672
672
  }
673
673
  });
674
674
  await Promise.all(
675
- r?.map(async (c) => {
676
- const l = c.id, p = c.slug || l, y = {}, w = e === "production" && c?.productionState ? c.productionState : await O.getStateByProjectId(c.id, e), j = mt(
675
+ r?.map(async (i) => {
676
+ const p = i.id, l = i.slug || p, y = {}, w = e === "production" && i?.productionState ? i.productionState : await O.getStateByProjectId(i.id, e), T = mt(
677
677
  E.env.languages?.map((u) => u.code) || [],
678
678
  w.supportedLocales?.map((u) => u.locale) || []
679
- ), I = (u, i) => {
680
- p && (y[H("/", p, u)] = {
681
- ...i,
679
+ ), I = (u, c) => {
680
+ l && (y[H("/", l, u)] = {
681
+ ...c,
682
682
  shouldRedirect: !0,
683
683
  mainPage: !0
684
- }), y[H("/", l, u)] = {
685
- ...i,
684
+ }), y[H("/", p, u)] = {
685
+ ...c,
686
686
  shouldRedirect: !0,
687
687
  mainPage: !0
688
688
  };
689
- for (const g of j) {
690
- const C = { ...i, locale: g };
691
- y[H("/", g, l, u)] = C, p && (y[H("/", g, p, u)] = C);
689
+ for (const g of T) {
690
+ const C = { ...c, locale: g };
691
+ y[H("/", g, p, u)] = C, l && (y[H("/", g, l, u)] = C);
692
692
  }
693
693
  };
694
694
  if (e === "draft")
695
695
  for (const u of w.routeIds || []) {
696
- const i = w?.routes?.[u];
697
- if (!i) continue;
698
- if (i.params && i.params.length > 0) {
696
+ const c = w?.routes?.[u];
697
+ if (!c) continue;
698
+ if (c.params && c.params.length > 0) {
699
699
  const m = Se({
700
- basePath: i.path,
701
- params: i.params,
702
- routeId: i.id,
703
- paramsOptions: i.paramsOptions,
700
+ basePath: c.path,
701
+ params: c.params,
702
+ routeId: c.id,
703
+ paramsOptions: c.paramsOptions,
704
704
  currentIndex: 0,
705
705
  currentParams: [],
706
706
  currentOptionIds: [],
@@ -708,53 +708,53 @@ class O extends N.Doc {
708
708
  });
709
709
  for (const d of m) {
710
710
  const h = d.path, A = {
711
- projectId: l,
712
- projectSlug: p,
711
+ projectId: p,
712
+ projectSlug: l,
713
713
  pageSlug: h,
714
- pageId: i.displayTemplateId || "",
714
+ pageId: c.displayTemplateId || "",
715
715
  routeId: u,
716
716
  // default locale
717
- defaultLocale: j?.[0],
718
- locales: j,
717
+ defaultLocale: T?.[0],
718
+ locales: T,
719
719
  publishedAt: w.config.publishedAt,
720
- isPublic: i.isPublic && d?.routeMetaData?.isPublic
720
+ isPublic: c.isPublic && d?.routeMetaData?.isPublic
721
721
  };
722
722
  I(h, A);
723
723
  }
724
724
  }
725
- const g = i.path, C = {
726
- projectId: l,
727
- projectSlug: p,
725
+ const g = c.path, C = {
726
+ projectId: p,
727
+ projectSlug: l,
728
728
  pageSlug: g,
729
- pageId: i.displayTemplateId || "",
729
+ pageId: c.displayTemplateId || "",
730
730
  routeId: u,
731
731
  // default locale
732
- defaultLocale: j?.[0],
733
- locales: j,
732
+ defaultLocale: T?.[0],
733
+ locales: T,
734
734
  publishedAt: w.config.publishedAt,
735
- isPublic: i.isPublic
735
+ isPublic: c.isPublic
736
736
  };
737
737
  I(g, C);
738
738
  }
739
739
  for (const u of w.pageIds || []) {
740
- const i = w.pages[u];
741
- if (!i || e === "production" && !i.isPublic)
740
+ const c = w.pages[u];
741
+ if (!c || e === "production" && !c.isPublic)
742
742
  continue;
743
- const g = i.slug, C = c.slug || l, m = {
744
- projectId: l,
743
+ const g = c.slug, C = i.slug || p, m = {
744
+ projectId: p,
745
745
  projectSlug: C,
746
746
  pageSlug: g,
747
747
  pageId: u,
748
748
  // default locale
749
- defaultLocale: j?.[0],
750
- locales: j,
749
+ defaultLocale: T?.[0],
750
+ locales: T,
751
751
  publishedAt: w.config.publishedAt,
752
- isPublic: i.isPublic,
753
- templateConfig: i.templateConfig
752
+ isPublic: c.isPublic,
753
+ templateConfig: c.templateConfig
754
754
  };
755
755
  I(g, m);
756
756
  }
757
- e === "production" && O.pageUrlMapCache.set(l, y), o = { ...o, ...y };
757
+ e === "production" && O.pageUrlMapCache.set(p, y), o = { ...o, ...y };
758
758
  })
759
759
  );
760
760
  }
@@ -801,11 +801,11 @@ class O extends N.Doc {
801
801
  s.map((r) => r.projectId)
802
802
  );
803
803
  let o = 0;
804
- for (const { projectId: r, instance: c } of s)
804
+ for (const { projectId: r, instance: i } of s)
805
805
  try {
806
- f.info(`[SiteState] releasing instance due to periodic check: ${r}`), c.destroy(), o++;
807
- } catch (l) {
808
- f.error(`[SiteState] failed to release instance ${r} during periodic check:`, l);
806
+ f.info(`[SiteState] releasing instance due to periodic check: ${r}`), i.destroy(), o++;
807
+ } catch (p) {
808
+ f.error(`[SiteState] failed to release instance ${r} during periodic check:`, p);
809
809
  }
810
810
  f.info(
811
811
  `[SiteState] periodic check completed: ${o}/${s.length} instances released successfully`
@@ -813,13 +813,13 @@ class O extends N.Doc {
813
813
  } else e > 0 ? f.debug("[SiteState] periodic check: all instances have active connections") : f.debug("[SiteState] periodic check: no instances exist");
814
814
  }
815
815
  }
816
- async function Gt(t, e, s) {
817
- if (!t || !U(t) || !B(t).isFile())
816
+ async function Vt(t, e, s) {
817
+ if (!t || !$(t) || !B(t).isFile())
818
818
  return null;
819
819
  let a = s[t];
820
820
  return a || (a = (async () => {
821
821
  try {
822
- return (await Mt({
822
+ return (await Nt({
823
823
  filePath: t,
824
824
  fileName: e
825
825
  }))?.data?.filename;
@@ -828,7 +828,7 @@ async function Gt(t, e, s) {
828
828
  }
829
829
  })(), s[t] = a), a;
830
830
  }
831
- const Vt = async (t, e) => {
831
+ const zt = async (t, e) => {
832
832
  const s = R(t), a = await dt({
833
833
  name: xe,
834
834
  path: H("/uploads", s),
@@ -840,11 +840,11 @@ const Vt = async (t, e) => {
840
840
  await yt(a.data, o);
841
841
  } else
842
842
  throw new Error(`download asset failed ${a.status}`);
843
- }, zt = async (t, e) => {
843
+ }, Jt = async (t, e) => {
844
844
  await Promise.all(
845
845
  t.map(async (s) => {
846
846
  try {
847
- await Vt(s, b(e, R(s)));
847
+ await zt(s, b(e, R(s)));
848
848
  } catch (a) {
849
849
  f.error(`Failed to export assets: ${s}, ${a}`);
850
850
  }
@@ -857,14 +857,14 @@ function Ge(t) {
857
857
  async function Z(t, e, s) {
858
858
  const { getFilename: a, exportAssets: o } = s, r = b(e, a(t));
859
859
  if (_(L(r), { recursive: !0 }), ee(r, G.stringify(t)), o) {
860
- const l = ae(
860
+ const p = ae(
861
861
  t,
862
- (p) => typeof p == "string" && (Ae.test(p) || W.test(p))
863
- ).map((p) => {
864
- const y = Ie(t, p);
862
+ (l) => typeof l == "string" && (Ae.test(l) || W.test(l))
863
+ ).map((l) => {
864
+ const y = Ie(t, l);
865
865
  return Ge(y);
866
866
  }).flat().filter(Boolean);
867
- await zt(l, L(r));
867
+ await Jt(p, L(r));
868
868
  }
869
869
  }
870
870
  const ye = new be({
@@ -875,44 +875,44 @@ const ye = new be({
875
875
  async function Re(t, e, s) {
876
876
  const a = ae(
877
877
  t,
878
- (l) => typeof l == "string" && (Ae.test(l) || W.test(l))
878
+ (p) => typeof p == "string" && (Ae.test(p) || W.test(p))
879
879
  ), o = gt(2), r = a.map(
880
- (l) => o(async () => {
880
+ (p) => o(async () => {
881
881
  try {
882
- const p = Ie(t, l), y = Ge(p);
882
+ const l = Ie(t, p), y = Ge(l);
883
883
  for (const w of y) {
884
- const j = R(w), I = s.getFilePath(w, l), u = I ? `${I}:${j}` : j, i = ye.get(u);
885
- if (i) {
886
- W.test(p) || ve(t, l, i);
884
+ const T = R(w), I = s.getFilePath(w, p), u = I ? `${I}:${T}` : T, c = ye.get(u);
885
+ if (c) {
886
+ W.test(l) || ve(t, p, c);
887
887
  return;
888
888
  }
889
- const g = await Gt(I, j, e);
890
- g && (W.test(p) || ve(t, l, g), ye.set(u, g));
889
+ const g = await Vt(I, T, e);
890
+ g && (W.test(l) || ve(t, p, g), ye.set(u, g));
891
891
  }
892
- } catch (p) {
893
- f.error(`Failed to process upload for path ${l.join(".")}:`, p.message || p.reason);
892
+ } catch (l) {
893
+ f.error(`Failed to process upload for path ${p.join(".")}:`, l.message || l.reason);
894
894
  }
895
895
  })
896
- ), c = await Promise.allSettled(r);
897
- s.onFinish?.(c);
896
+ ), i = await Promise.allSettled(r);
897
+ s.onFinish?.(i);
898
898
  }
899
- async function Jt(t, {
899
+ async function Kt(t, {
900
900
  exportAssets: e,
901
901
  pageIds: s = "all",
902
902
  componentIds: a = "all",
903
903
  rawConfig: o,
904
904
  includeResources: r = !1,
905
- routeIds: c = "all"
905
+ routeIds: i = "all"
906
906
  } = {}) {
907
- const l = s === "all" ? t.pageIds : s, p = pt({
907
+ const p = s === "all" ? t.pageIds : s, l = pt({
908
908
  state: t,
909
- pageIds: l,
909
+ pageIds: p,
910
910
  componentIds: a === "all" ? Object.keys(t.components) : a
911
911
  });
912
912
  Object.entries(t.components).forEach(([n, S]) => {
913
- S.data?.renderer?.type === "component-template" && p.push(n);
913
+ S.data?.renderer?.type === "component-template" && l.push(n);
914
914
  });
915
- const y = c === "all" ? t.routeIds : c, w = (n) => ({
915
+ const y = i === "all" ? t.routeIds : i, w = (n) => ({
916
916
  id: n.id,
917
917
  name: n.name,
918
918
  isTemplateSection: n.isTemplateSection ?? !1,
@@ -930,7 +930,7 @@ async function Jt(t, {
930
930
  ) : void 0
931
931
  /** @deprecated 已经废弃,数据在 page.dataSource 中管理 */
932
932
  // properties: section.locales?.[locale] ?? {},
933
- }), j = (n, S) => ({
933
+ }), T = (n, S) => ({
934
934
  id: n.id,
935
935
  createdAt: n.createdAt,
936
936
  updatedAt: n.updatedAt,
@@ -965,14 +965,14 @@ async function Jt(t, {
965
965
  const S = t.routes[n];
966
966
  return S && I(S);
967
967
  })
968
- ), i = D(
968
+ ), c = D(
969
969
  t.supportedLocales.map((n) => n.locale).flatMap(
970
- (n) => l.map((S) => {
970
+ (n) => p.map((S) => {
971
971
  const v = t.pages[S];
972
972
  return v && {
973
973
  locale: n,
974
974
  slug: v.slug,
975
- page: j(v, n)
975
+ page: T(v, n)
976
976
  };
977
977
  })
978
978
  )
@@ -982,7 +982,7 @@ async function Jt(t, {
982
982
  _(m, { recursive: !0 });
983
983
  const d = b(g, "routes");
984
984
  _(d, { recursive: !0 });
985
- for (const { locale: n, slug: S, page: v } of i)
985
+ for (const { locale: n, slug: S, page: v } of c)
986
986
  await Z(v, C, {
987
987
  getFilename: () => `${oe(S) || "index"}.${n}.yml`,
988
988
  exportAssets: e
@@ -993,7 +993,7 @@ async function Jt(t, {
993
993
  getFilename: () => `${oe(n.path) || "index"}.yml`,
994
994
  exportAssets: e
995
995
  });
996
- for (const n of p) {
996
+ for (const n of l) {
997
997
  const S = t.components[n]?.data;
998
998
  S && await Z(S, m, {
999
999
  getFilename: (v) => `${v.name || "unnamed"}.${v.id}.yml`,
@@ -1004,7 +1004,7 @@ async function Jt(t, {
1004
1004
  _(L(h), { recursive: !0 });
1005
1005
  const A = {
1006
1006
  pages: D(
1007
- l.map((n) => {
1007
+ p.map((n) => {
1008
1008
  const S = t.pages[n];
1009
1009
  return S && { id: n, slug: S.slug };
1010
1010
  })
@@ -1016,7 +1016,7 @@ async function Jt(t, {
1016
1016
  })
1017
1017
  ),
1018
1018
  components: D(
1019
- p.map((n) => {
1019
+ l.map((n) => {
1020
1020
  const S = t.components[n]?.data;
1021
1021
  return S && {
1022
1022
  id: n,
@@ -1027,7 +1027,7 @@ async function Jt(t, {
1027
1027
  ...r ? {
1028
1028
  resources: {
1029
1029
  components: D(
1030
- Object.keys(t.resources?.components || {}).filter((n) => p.includes(n)).map((n) => ({
1030
+ Object.keys(t.resources?.components || {}).filter((n) => l.includes(n)).map((n) => ({
1031
1031
  id: n,
1032
1032
  name: t.resources?.components?.[n]?.component?.name
1033
1033
  }))
@@ -1043,28 +1043,28 @@ async function Jt(t, {
1043
1043
  const n = b(g, "resources"), S = b(n, "components");
1044
1044
  _(S, { recursive: !0 });
1045
1045
  for (const z of Object.keys(t?.resources?.components ?? {}).filter(
1046
- ($) => p.includes($)
1046
+ (U) => l.includes(U)
1047
1047
  )) {
1048
- const $ = t.resources?.components?.[z]?.component;
1049
- $ && await Z($, S, {
1048
+ const U = t.resources?.components?.[z]?.component;
1049
+ U && await Z(U, S, {
1050
1050
  getFilename: (J) => `${J.name || "unnamed"}.${J.id}.yml`,
1051
1051
  exportAssets: e
1052
1052
  });
1053
1053
  }
1054
1054
  const v = b(g, "chunks");
1055
1055
  _(v, { recursive: !0 });
1056
- const x = Kt();
1056
+ const x = qt();
1057
1057
  for (const z of Object.keys(t?.resources?.components ?? {}).filter(
1058
- ($) => p.includes($)
1058
+ (U) => l.includes(U)
1059
1059
  )) {
1060
- const $ = t.resources?.components?.[z]?.component;
1061
- if ($ && $.renderer?.type === "react-component") {
1062
- const J = $.renderer?.chunks ?? [];
1060
+ const U = t.resources?.components?.[z]?.component;
1061
+ if (U && U.renderer?.type === "react-component") {
1062
+ const J = U.renderer?.chunks ?? [];
1063
1063
  if (J?.length > 0)
1064
1064
  for (const pe of J) {
1065
1065
  const Pe = b(v, pe), le = x?.[pe];
1066
1066
  try {
1067
- le && U(le) && !U(Pe) && rt(le, Pe);
1067
+ le && $(le) && !$(Pe) && rt(le, Pe);
1068
1068
  } catch (We) {
1069
1069
  f.error(`copy chunk ${pe} error`, We.message);
1070
1070
  }
@@ -1075,18 +1075,18 @@ async function Jt(t, {
1075
1075
  return g;
1076
1076
  }
1077
1077
  async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1078
- if (!U(t))
1078
+ if (!$(t))
1079
1079
  return null;
1080
1080
  let a, o = !1;
1081
1081
  try {
1082
1082
  B(t).isDirectory() ? a = t : /\.(tgz|gz|tar)$/.test(t) && (o = !0, a = Be(), await St({ file: t, C: a }));
1083
- const r = te("**/.blocklet/pages/pages.config.yml", { cwd: a, absolute: !0 }).at(0), c = r && b(L(r), "../../pages"), l = r && b(L(r), "../../components"), p = r && b(L(r), "../../routes");
1083
+ const r = te("**/.blocklet/pages/pages.config.yml", { cwd: a, absolute: !0 }).at(0), i = r && b(L(r), "../../pages"), p = r && b(L(r), "../../components"), l = r && b(L(r), "../../routes");
1084
1084
  if (!r)
1085
1085
  return null;
1086
1086
  const y = G.parse(q(r).toString()), w = (m, d, h) => {
1087
1087
  let A = b(m, `${d}${h ? `.${h}` : ""}.yml`);
1088
- return (!U(A) || !B(A).isFile()) && (A = b(m, d, `index${h ? `.${h}` : ""}.yml`), !U(A) || !B(A)) ? null : G.parse(q(A).toString());
1089
- }, j = (m, d) => {
1088
+ return (!$(A) || !B(A).isFile()) && (A = b(m, d, `index${h ? `.${h}` : ""}.yml`), !$(A) || !B(A)) ? null : G.parse(q(A).toString());
1089
+ }, T = (m, d) => {
1090
1090
  try {
1091
1091
  const h = te(`*.${d}.yml`, { cwd: m, absolute: !0 })[0];
1092
1092
  return h ? G.parse(q(h).toString()) : null;
@@ -1096,15 +1096,15 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1096
1096
  return null;
1097
1097
  }, I = (m, d) => {
1098
1098
  let h = b(m, `${d}.yml`);
1099
- return (!U(h) || !B(h).isFile()) && (h = b(m, d, "index.yml"), !U(h) || !B(h)) ? null : G.parse(q(h).toString());
1099
+ return (!$(h) || !B(h).isFile()) && (h = b(m, d, "index.yml"), !$(h) || !B(h)) ? null : G.parse(q(h).toString());
1100
1100
  }, u = D(
1101
1101
  y.pages.map(({ slug: m }) => {
1102
1102
  const d = D(
1103
1103
  y.supportedLocales.map(({ locale: P }) => {
1104
- const n = c ? w(c, oe(m), P) : void 0;
1104
+ const n = i ? w(i, oe(m), P) : void 0;
1105
1105
  if (n)
1106
1106
  return { locale: P, page: n };
1107
- const S = c ? w(c, m, P) : void 0;
1107
+ const S = i ? w(i, m, P) : void 0;
1108
1108
  return S && { locale: P, page: S };
1109
1109
  })
1110
1110
  ), h = d[0]?.page;
@@ -1150,9 +1150,9 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1150
1150
  )
1151
1151
  };
1152
1152
  })
1153
- ), i = D(
1153
+ ), c = D(
1154
1154
  y?.routes?.map(({ path: m }) => {
1155
- const d = p ? I(p, oe(m)) : void 0;
1155
+ const d = l ? I(l, oe(m)) : void 0;
1156
1156
  return {
1157
1157
  ...d,
1158
1158
  id: d?.id || Oe(),
@@ -1168,20 +1168,20 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1168
1168
  dataSource: d?.dataSource ?? {}
1169
1169
  };
1170
1170
  }) ?? []
1171
- ), g = l ? D(y.components?.map(({ id: m }) => j(l, m)) ?? []) : [];
1171
+ ), g = p ? D(y.components?.map(({ id: m }) => T(p, m)) ?? []) : [];
1172
1172
  if (e) {
1173
1173
  const m = (...d) => {
1174
1174
  f.info(`[${o ? R(t) : R(b(t, "../../../../"))}] importAssets:`, ...d);
1175
1175
  };
1176
1176
  try {
1177
- m("wait image-bin api ready"), await It({
1177
+ m("wait image-bin api ready"), await Et({
1178
1178
  resources: [`${lt(Qe)}/api/sdk/uploads`],
1179
1179
  validateStatus: (A) => A >= 200 && A <= 500
1180
1180
  }), m("image-bin api is ready");
1181
1181
  const d = {}, h = {};
1182
1182
  m("start to upload assets"), await Promise.allSettled([
1183
1183
  Re(g, d, {
1184
- getFilePath: (A) => l && b(l, A),
1184
+ getFilePath: (A) => p && b(p, A),
1185
1185
  onFinish: (A) => {
1186
1186
  m(`upload ${A.length} component assets`);
1187
1187
  }
@@ -1189,7 +1189,7 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1189
1189
  Re(u, h, {
1190
1190
  getFilePath: (A, P) => {
1191
1191
  const n = Ie(u, P.slice(0, 1));
1192
- return c && b(c, L(n.slug), A);
1192
+ return i && b(i, L(n.slug), A);
1193
1193
  },
1194
1194
  onFinish: (A) => {
1195
1195
  m(`upload ${A.length} page assets`);
@@ -1203,7 +1203,7 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1203
1203
  const C = {};
1204
1204
  if (s) {
1205
1205
  const m = r && b(L(r), "../../resources/components"), d = D(
1206
- y.resources?.components?.map(({ id: h }) => j(m, h)) ?? []
1206
+ y.resources?.components?.map(({ id: h }) => T(m, h)) ?? []
1207
1207
  );
1208
1208
  d.length > 0 && (C.components = Object.fromEntries(
1209
1209
  d.map((h, A) => [h.id, { index: A, component: h }])
@@ -1216,8 +1216,8 @@ async function Ve(t, { importAssets: e, includeResources: s } = {}) {
1216
1216
  pages: Object.fromEntries(u.map((m) => [m.id, m])),
1217
1217
  config: y.config || {},
1218
1218
  resources: C,
1219
- routeIds: i.map((m) => m.id),
1220
- routes: Object.fromEntries(i.map((m) => [m.id, m])),
1219
+ routeIds: c.map((m) => m.id),
1220
+ routes: Object.fromEntries(c.map((m) => [m.id, m])),
1221
1221
  dataSourceIds: [],
1222
1222
  dataSources: {}
1223
1223
  };
@@ -1236,11 +1236,11 @@ async function Le(t, e, {
1236
1236
  } catch (I) {
1237
1237
  f.error("clear preload page cache error", { error: I });
1238
1238
  }
1239
- const { pages: c, pageIds: l, routeIds: p, routes: y, supportedLocales: w } = t;
1239
+ const { pages: i, pageIds: p, routeIds: l, routes: y, supportedLocales: w } = t;
1240
1240
  if (r === "production") {
1241
1241
  let I = s ?? [], u = null;
1242
- for (const i of p ?? []) {
1243
- const g = y?.[i];
1242
+ for (const c of l ?? []) {
1243
+ const g = y?.[c];
1244
1244
  if (g?.params && g?.params.length > 0 && g?.paramsOptions && g?.paramsOptions.length > 0) {
1245
1245
  const C = Se({
1246
1246
  basePath: g.path,
@@ -1251,13 +1251,13 @@ async function Le(t, e, {
1251
1251
  currentParams: [],
1252
1252
  currentOptionIds: [],
1253
1253
  result: []
1254
- }), m = Object.fromEntries(C.map((d) => [`${i}-${d.paramOptionIds.join("-")}`, d]));
1255
- u = { ...u || {}, ...m }, s || (I = [...I, ...C.map((d) => `${i}-${d.paramOptionIds.join("-")}`)]);
1256
- } else s || I.push(i);
1254
+ }), m = Object.fromEntries(C.map((d) => [`${c}-${d.paramOptionIds.join("-")}`, d]));
1255
+ u = { ...u || {}, ...m }, s || (I = [...I, ...C.map((d) => `${c}-${d.paramOptionIds.join("-")}`)]);
1256
+ } else s || I.push(c);
1257
1257
  }
1258
1258
  f.info("routeIds to be published: ", I);
1259
- for (const i of I) {
1260
- let g = i;
1259
+ for (const c of I) {
1260
+ let g = c;
1261
1261
  if (g.includes("-")) {
1262
1262
  const [d] = g.split("-");
1263
1263
  g = d;
@@ -1271,97 +1271,97 @@ async function Le(t, e, {
1271
1271
  f.info("delete main route page", g);
1272
1272
  continue;
1273
1273
  }
1274
- if (i.includes("-") && !u?.[i]) {
1275
- const d = e.pageIds.indexOf(i);
1276
- d !== -1 && o && (e.pageIds.splice(d, 1), delete e.pages[i]), f.info("delete page", i);
1274
+ if (c.includes("-") && !u?.[c]) {
1275
+ const d = e.pageIds.indexOf(c);
1276
+ d !== -1 && o && (e.pageIds.splice(d, 1), delete e.pages[c]), f.info("delete page", c);
1277
1277
  continue;
1278
1278
  }
1279
1279
  if (!C.displayTemplateId) {
1280
- f.info("no display template", i);
1280
+ f.info("no display template", c);
1281
1281
  continue;
1282
1282
  }
1283
- const m = c[C.displayTemplateId];
1283
+ const m = i[C.displayTemplateId];
1284
1284
  if (!m) {
1285
- f.info("no template page", i);
1285
+ f.info("no template page", c);
1286
1286
  continue;
1287
1287
  }
1288
- if (e.pageIds.includes(i)) {
1289
- if (f.info("has need update page", i), a === "replace")
1290
- e.pages[i] = de({
1288
+ if (e.pageIds.includes(c)) {
1289
+ if (f.info("has need update page", c), a === "replace")
1290
+ e.pages[c] = de({
1291
1291
  page: m,
1292
1292
  route: C,
1293
1293
  state: t,
1294
- routeId: i,
1295
- routePathInfo: u?.[i]
1296
- }), f.info("replace page", i);
1294
+ routeId: c,
1295
+ routePathInfo: u?.[c]
1296
+ }), f.info("replace page", c);
1297
1297
  else if (a === "byUpdateTime") {
1298
1298
  const d = e.pages[C.id];
1299
- (!d || C.updatedAt && C.updatedAt > d.updatedAt) && (e.pages[i] = de({
1299
+ (!d || C.updatedAt && C.updatedAt > d.updatedAt) && (e.pages[c] = de({
1300
1300
  page: m,
1301
1301
  route: C,
1302
1302
  state: t,
1303
- routeId: i,
1304
- routePathInfo: u?.[i]
1305
- }), f.info("replace page by update time", i));
1303
+ routeId: c,
1304
+ routePathInfo: u?.[c]
1305
+ }), f.info("replace page by update time", c));
1306
1306
  }
1307
1307
  } else
1308
- e.pageIds.push(i), e.pages[i] = de({
1308
+ e.pageIds.push(c), e.pages[c] = de({
1309
1309
  page: m,
1310
1310
  route: C,
1311
1311
  state: t,
1312
- routeId: i,
1313
- routePathInfo: u?.[i]
1314
- }), f.info("add page", i);
1312
+ routeId: c,
1313
+ routePathInfo: u?.[c]
1314
+ }), f.info("add page", c);
1315
1315
  }
1316
1316
  if (o && !s)
1317
- for (const i of e.pageIds)
1318
- I?.includes(i) || (delete e.pages[i], f.info("delete page", i)), e.pageIds = [...e.pageIds].filter((g) => I?.includes(g));
1317
+ for (const c of e.pageIds)
1318
+ I?.includes(c) || (delete e.pages[c], f.info("delete page", c)), e.pageIds = [...e.pageIds].filter((g) => I?.includes(g));
1319
1319
  } else {
1320
- for (const I of l) {
1321
- const u = c[I];
1320
+ for (const I of p) {
1321
+ const u = i[I];
1322
1322
  if (u)
1323
1323
  if (e.pageIds.includes(u.id)) {
1324
1324
  if (a === "replace")
1325
1325
  e.pages[u.id] = u;
1326
1326
  else if (a === "byUpdateTime") {
1327
- const i = e.pages[u.id];
1328
- (!i || u.updatedAt && u.updatedAt > i.updatedAt) && (e.pages[u.id] = u);
1327
+ const c = e.pages[u.id];
1328
+ (!c || u.updatedAt && u.updatedAt > c.updatedAt) && (e.pages[u.id] = u);
1329
1329
  }
1330
1330
  } else
1331
1331
  e.pageIds.push(u.id), e.pages[u.id] = u;
1332
1332
  }
1333
- for (const I of p) {
1333
+ for (const I of l) {
1334
1334
  const u = y[I];
1335
1335
  if (u)
1336
1336
  if (e.routeIds.includes(u.id)) {
1337
1337
  if (a === "replace")
1338
1338
  e.routes[u.id] = u;
1339
1339
  else if (a === "byUpdateTime") {
1340
- const i = e.routes[u.id];
1341
- (!i || u.updatedAt && u.updatedAt > i.updatedAt) && (e.routes[u.id] = u);
1340
+ const c = e.routes[u.id];
1341
+ (!c || u.updatedAt && u.updatedAt > c.updatedAt) && (e.routes[u.id] = u);
1342
1342
  }
1343
1343
  } else
1344
1344
  e.routeIds.push(u.id), e.routes[u.id] = u;
1345
1345
  }
1346
1346
  }
1347
- if (e.supportedLocales.splice(0, e.supportedLocales.length), e.supportedLocales.push(...Ue(w)), o)
1347
+ if (e.supportedLocales.splice(0, e.supportedLocales.length), e.supportedLocales.push(...$e(w)), o)
1348
1348
  for (const I of Object.keys(e.components))
1349
1349
  delete e.components[I];
1350
- let j = JSON.parse(JSON.stringify(t.components));
1351
- j = Object.fromEntries(
1350
+ let T = JSON.parse(JSON.stringify(t.components));
1351
+ T = Object.fromEntries(
1352
1352
  await Promise.all(
1353
- Object.entries(j).map(async ([I, u]) => {
1354
- const i = await ze(u?.data);
1353
+ Object.entries(T).map(async ([I, u]) => {
1354
+ const c = await ze(u?.data);
1355
1355
  return [
1356
1356
  I,
1357
1357
  {
1358
1358
  ...u,
1359
- data: i
1359
+ data: c
1360
1360
  }
1361
1361
  ];
1362
1362
  })
1363
1363
  )
1364
- ), Object.assign(e.components, j), Object.assign(e.config, JSON.parse(JSON.stringify(t.config))), Ee(t.resources.components) || (e.resources.components = JSON.parse(JSON.stringify(t.resources.components || {})));
1364
+ ), Object.assign(e.components, T), Object.assign(e.config, JSON.parse(JSON.stringify(t.config))), Ee(t.resources.components) || (e.resources.components = JSON.parse(JSON.stringify(t.resources.components || {})));
1365
1365
  }
1366
1366
  const ze = Ze(
1367
1367
  async (t) => {
@@ -1396,17 +1396,17 @@ const ze = Ze(
1396
1396
  let re, Q, ne, ie;
1397
1397
  const Je = () => ut({
1398
1398
  types: [
1399
- { did: xe, type: Te },
1400
- { did: kt, type: Te }
1399
+ { did: xe, type: ke },
1400
+ { did: kt, type: ke }
1401
1401
  ]
1402
- }), Kt = () => {
1402
+ }), qt = () => {
1403
1403
  const t = Je(), e = {};
1404
1404
  return t.forEach((s) => {
1405
1405
  const a = te("**/.blocklet/pages/pages.config.yml", { cwd: s.path, absolute: !0 }).at(0), o = a && b(L(a), "../../chunks");
1406
- if (o && U(o)) {
1406
+ if (o && $(o)) {
1407
1407
  const r = nt(o);
1408
- for (const c of r)
1409
- e[c] = b(o, c);
1408
+ for (const i of r)
1409
+ e[i] = b(o, i);
1410
1410
  }
1411
1411
  }), e;
1412
1412
  };
@@ -1452,7 +1452,7 @@ function Ke() {
1452
1452
  );
1453
1453
  })(), re;
1454
1454
  }
1455
- function qt(t) {
1455
+ function Ht(t) {
1456
1456
  const e = Ne(
1457
1457
  async () => {
1458
1458
  await Ke().catch((s) => {
@@ -1473,7 +1473,7 @@ function qt(t) {
1473
1473
  }
1474
1474
  const qe = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), He = Symbol.for("GLOBAL_ENV_UPDATE_LISTENER_KEY"), ce = globalThis;
1475
1475
  ce[qe]?.();
1476
- ce[qe] = qt(async ({ pages: t, components: e }) => {
1476
+ ce[qe] = Ht(async ({ pages: t, components: e }) => {
1477
1477
  const s = await O.getProjectIds();
1478
1478
  f.info(`start update resource states projects(${s.length})`, s), await Promise.race([
1479
1479
  new Promise((a) => {
@@ -1526,17 +1526,17 @@ async function Ye({
1526
1526
  if (a.syncedStore.resources.pages = e, (await M.findByPk(t))?.useAllResources)
1527
1527
  a.syncedStore.resources.components = s;
1528
1528
  else {
1529
- const c = (await we.findAll({ where: { projectId: t } })).map((p) => p.componentId), l = Object.fromEntries(
1530
- Object.entries(s || {}).filter(([p]) => c.includes(p))
1529
+ const i = (await we.findAll({ where: { projectId: t } })).map((l) => l.componentId), p = Object.fromEntries(
1530
+ Object.entries(s || {}).filter(([l]) => i.includes(l))
1531
1531
  );
1532
- a.syncedStore.resources.components = l;
1532
+ a.syncedStore.resources.components = p;
1533
1533
  }
1534
1534
  f.info(`update [${t}] resource states:`, {
1535
1535
  pages: Object.keys(a.syncedStore.resources.pages || {}).length,
1536
1536
  components: Object.keys(a.syncedStore.resources.components || {}).length
1537
1537
  });
1538
1538
  }
1539
- async function vs(t) {
1539
+ async function Ts(t) {
1540
1540
  return Ye({
1541
1541
  projectId: t,
1542
1542
  pages: ne,
@@ -1554,19 +1554,19 @@ async function ks({
1554
1554
  export {
1555
1555
  xe as C,
1556
1556
  M as P,
1557
- Te as R,
1557
+ ke as R,
1558
1558
  O as S,
1559
1559
  K as a,
1560
- Cs as b,
1561
- Os as c,
1562
- Bt as d,
1563
- Vt as e,
1564
- zt as f,
1560
+ Os as b,
1561
+ vs as c,
1562
+ Gt as d,
1563
+ zt as e,
1564
+ Jt as f,
1565
1565
  ks as g,
1566
1566
  Ve as h,
1567
- qt as i,
1567
+ Ht as i,
1568
1568
  js as j,
1569
1569
  Le as m,
1570
- Jt as t,
1571
- vs as u
1570
+ Kt as t,
1571
+ Ts as u
1572
1572
  };