@blocklet/pages-kit-inner-components 0.4.35 → 0.4.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- var st = Object.defineProperty;
2
- var ot = (t, o, e) => o in t ? st(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
3
- var P = (t, o, e) => ot(t, typeof o != "symbol" ? o + "" : o, e);
4
- import { getComponentMountPoint as nt } from "@blocklet/pages-kit/builtin/utils";
1
+ var tt = Object.defineProperty;
2
+ var st = (t, o, e) => o in t ? tt(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
3
+ var P = (t, o, e) => st(t, typeof o != "symbol" ? o + "" : o, e);
4
+ import { getComponentMountPoint as ot } from "@blocklet/pages-kit/builtin/utils";
5
5
  import { PreloadComponentScriptModule as X } from "@blocklet/pages-kit/types";
6
- import { componentUMDName as rt, RenderNestedComponent as Oe, mergeComponent as at } from "@blocklet/pages-kit/utils/property";
7
- import { memoize as ae, Sandbox as Fe, BuiltinModules as it } from "@blocklet/quickjs";
8
- import w from "@blocklet/sdk/lib/config";
6
+ import { componentUMDName as nt, RenderNestedComponent as Oe, mergeComponent as rt } from "@blocklet/pages-kit/utils/property";
7
+ import { memoize as ae, Sandbox as Fe, BuiltinModules as at } from "@blocklet/quickjs";
8
+ import S from "@blocklet/sdk/lib/config";
9
9
  import { LRUCache as he } from "lru-cache";
10
- import ct, { Headers as lt } from "node-fetch";
11
- import { joinURL as _, getQuery as pt, withQuery as ut, parseURL as ve, withHttps as dt } from "ufo";
10
+ import it, { Headers as ct } from "node-fetch";
11
+ import { joinURL as M, getQuery as lt, withQuery as pt, parseURL as ve, withHttps as ut } from "ufo";
12
12
  import { createHash as ie } from "crypto";
13
- import mt from "@blocklet/logger";
14
- import { BuiltinModules as ft } from "@blocklet/pages-kit/utils/builtin";
15
- import { createBuiltinModuleTransformer as gt, isRelativeModule as Ae } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
16
- import { call as $e, getResources as ht, getComponentWebEndpoint as yt } from "@blocklet/sdk/lib/component";
17
- import wt from "autoprefixer";
18
- import * as St from "esbuild";
19
- import { readFileSync as H, existsSync as V, lstatSync as Z, readdirSync as Et, rmSync as Be, mkdtempSync as bt, renameSync as Te, mkdirSync as F, writeFileSync as te, createWriteStream as It } from "fs";
13
+ import dt from "@blocklet/logger";
14
+ import { BuiltinModules as mt } from "@blocklet/pages-kit/utils/builtin";
15
+ import { createBuiltinModuleTransformer as ft, isRelativeModule as Ae } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
16
+ import { getResources as gt, getComponentWebEndpoint as ht, call as yt } from "@blocklet/sdk/lib/component";
17
+ import St from "autoprefixer";
18
+ import * as wt from "esbuild";
19
+ import { readFileSync as H, existsSync as V, lstatSync as Z, readdirSync as Et, rmSync as $e, mkdtempSync as bt, renameSync as Te, mkdirSync as F, writeFileSync as te, createWriteStream as It } from "fs";
20
20
  import Ot from "postcss";
21
21
  import vt from "tailwindcss";
22
22
  import j from "typescript";
@@ -25,7 +25,7 @@ import { syncedStore as Tt, getYjsValue as le } from "@syncedstore/core";
25
25
  import { globSync as me } from "glob";
26
26
  import * as pe from "lib0/decoding";
27
27
  import * as C from "lib0/encoding";
28
- import { get as ye, isEmpty as Pt, set as Pe, pick as Ct, debounce as Ve, union as xt, cloneDeep as jt } from "lodash";
28
+ import { get as ye, isEmpty as Pt, set as Pe, pick as Ct, debounce as Be, union as xt, cloneDeep as jt } from "lodash";
29
29
  import { customAlphabet as kt } from "nanoid";
30
30
  import Dt from "p-limit";
31
31
  import Nt, { join as O, dirname as L, basename as J } from "path";
@@ -37,15 +37,15 @@ import { writeUpdate as $t, writeSyncStep1 as Bt, readSyncMessage as Vt } from "
37
37
  import * as K from "yaml";
38
38
  import * as B from "yjs";
39
39
  import Gt from "lodash/isNil";
40
- import { DataTypes as T, Sequelize as Jt, Model as Ge, Op as Ht } from "sequelize";
40
+ import { DataTypes as T, Sequelize as Jt, Model as Ve, Op as Ht } from "sequelize";
41
41
  import "sqlite3";
42
- w.env.mode;
42
+ S.env.mode;
43
43
  const Kt = "image-bin";
44
- w.env.INIT_TEMPLATE_PATH;
45
- const Wt = process.env.DATABASE_URL || Nt.join(w.env.dataDir, "db/pages-kit.db"), xe = w, so = () => w.env.tenantMode === "multiple", oo = () => {
44
+ S.env.INIT_TEMPLATE_PATH;
45
+ const Wt = process.env.DATABASE_URL || Nt.join(S.env.dataDir, "db/pages-kit.db"), xe = S, so = () => S.env.tenantMode === "multiple", oo = () => {
46
46
  var t;
47
47
  return (Gt(xe.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = xe.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
48
- }, v = mt("pages-kit"), zt = T.sqlite.DATE.parse;
48
+ }, v = dt("pages-kit"), zt = T.sqlite.DATE.parse;
49
49
  T.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) : zt(t, o);
50
50
  const Y = new Jt({
51
51
  dialect: "sqlite",
@@ -63,7 +63,7 @@ const Y = new Jt({
63
63
  Y.query("pragma journal_mode = WAL;");
64
64
  Y.query("pragma synchronous = normal;");
65
65
  Y.query("pragma journal_size_limit = 67108864;");
66
- class ce extends Ge {
66
+ class ce extends Ve {
67
67
  // Foreign key to Component
68
68
  }
69
69
  ce.init(
@@ -85,7 +85,7 @@ ce.init(
85
85
  },
86
86
  { sequelize: Y, tableName: "ProjectComponents", timestamps: !1 }
87
87
  );
88
- class $ extends Ge {
88
+ class $ extends Ve {
89
89
  static async getProjectByIdOrSlug(o) {
90
90
  return $.findOne({
91
91
  where: {
@@ -144,7 +144,7 @@ const Yt = async (t, { componentId: o }) => {
144
144
  `, s = `.CustomComponent_${o}`;
145
145
  return (await Ot([
146
146
  vt({ content: [{ raw: t, extension: "tsx" }] }),
147
- wt({
147
+ St({
148
148
  overrideBrowserslist: ["> 1%", "last 2 versions"],
149
149
  stats: {}
150
150
  }),
@@ -171,7 +171,7 @@ ${t}
171
171
  module: j.ModuleKind.ESNext
172
172
  },
173
173
  transformers: {
174
- before: [gt(j)]
174
+ before: [ft(j)]
175
175
  }
176
176
  }).outputText;
177
177
  if (o.tailwind && (e = await qt(e, { componentId: o.componentId })), o.module === X.ESM) return e;
@@ -205,9 +205,9 @@ ${t}
205
205
  }
206
206
  ), Qt = async (t, o) => {
207
207
  var l, a;
208
- const s = (a = (l = (await St.build({
208
+ const s = (a = (l = (await wt.build({
209
209
  entryPoints: ["index.tsx"],
210
- external: Object.keys(ft),
210
+ external: Object.keys(mt),
211
211
  format: "esm",
212
212
  target: "esnext",
213
213
  bundle: !0,
@@ -224,16 +224,9 @@ ${t}
224
224
  if (p.path === "component.tsx")
225
225
  return { contents: t, loader: "tsx" };
226
226
  if (Ae(p.path)) {
227
- c || (c = await et({ ensureLoaded: !1 }));
228
- const m = p.path.split("/").pop();
229
- if ((u = c == null ? void 0 : c.chunks) != null && u[m])
230
- return { contents: H(c.chunks[m], "utf-8"), loader: "js" };
231
- const g = _("chunks", m), { data: h } = await $e({
232
- name: "pages-kit",
233
- method: "GET",
234
- path: g
235
- });
236
- return { contents: h, loader: "js" };
227
+ c || (c = await Ze({ ensureLoaded: !1 }));
228
+ const f = p.path.split("/").pop();
229
+ return (u = c == null ? void 0 : c.chunks) != null && u[f] ? { contents: H(c.chunks[f], "utf-8"), loader: "js" } : { contents: "", loader: "js" };
237
230
  }
238
231
  return null;
239
232
  });
@@ -246,7 +239,7 @@ ${t}
246
239
  return j.transpileModule(n, {
247
240
  compilerOptions: { module: j.ModuleKind.ESNext, target: j.ScriptTarget.ES2020 }
248
241
  }).outputText;
249
- }, Je = ae(
242
+ }, Ge = ae(
250
243
  async (t, o) => {
251
244
  const e = await Qt(t, o);
252
245
  return new RegExp(`export\\s+\\{\\s+${o}\\s+\\}`, "m").test(e) ? e : void 0;
@@ -324,14 +317,14 @@ async function no({
324
317
  const i = (await Promise.all(
325
318
  n.map(async (g) => {
326
319
  try {
327
- const h = ss({
320
+ const y = ss({
328
321
  mode: t,
329
322
  instanceId: g.id,
330
323
  componentId: g.componentId,
331
324
  locale: s
332
325
  });
333
- if (t !== "draft" && g.useCache && W.has(h))
334
- return v.info(`get preload component from cache: ${h}`), W.get(h);
326
+ if (t !== "draft" && g.useCache && W.has(y))
327
+ return v.info(`get preload component from cache: ${y}`), W.get(y);
335
328
  const A = se({ state: e, componentId: g.componentId });
336
329
  if (!A) return null;
337
330
  const x = await os({
@@ -346,39 +339,39 @@ async function no({
346
339
  const U = { instanceId: g.id, preload: x };
347
340
  if (t !== "draft" && g.useCache) {
348
341
  let D = Zt;
349
- g.cacheDuration && (D = g.cacheDuration), v.info(`set preload component to cache(${D}s): ${h}`), W.set(h, U, {
342
+ g.cacheDuration && (D = g.cacheDuration), v.info(`set preload component to cache(${D}s): ${y}`), W.set(y, U, {
350
343
  ttl: D * 1e3
351
344
  });
352
345
  }
353
346
  return U;
354
- } catch (h) {
355
- return v.error("get preload component error", { instanceId: g.id, componentId: g.componentId }, { error: h }), null;
347
+ } catch (y) {
348
+ return v.error("get preload component error", { instanceId: g.id, componentId: g.componentId }, { error: y }), null;
356
349
  }
357
350
  })
358
351
  )).filter((g) => !!g), c = Object.values(
359
- i.reduce((g, h) => ({ ...g, ...h.preload.components }), {})
352
+ i.reduce((g, y) => ({ ...g, ...y.preload.components }), {})
360
353
  );
361
354
  async function p() {
362
355
  const g = await Promise.all(
363
- c.map(async (h) => {
364
- const A = rt({ componentId: h.component.id }), x = r === X.ESM ? {
356
+ c.map(async (y) => {
357
+ const A = nt({ componentId: y.component.id }), x = r === X.ESM ? {
365
358
  module: r,
366
- script: await je(h.script, {
367
- componentId: h.component.id,
359
+ script: await je(y.script, {
360
+ componentId: y.component.id,
368
361
  module: r,
369
362
  tailwind: t !== "draft"
370
363
  })
371
364
  } : {
372
365
  module: r,
373
- script: await je(h.script, {
374
- componentId: h.component.id,
366
+ script: await je(y.script, {
367
+ componentId: y.component.id,
375
368
  module: r,
376
369
  moduleName: A,
377
370
  tailwind: t !== "draft"
378
371
  }),
379
372
  moduleName: A
380
373
  };
381
- return [h.component.id, { component: h.component, script: x }];
374
+ return [y.component.id, { component: y.component, script: x }];
382
375
  })
383
376
  );
384
377
  return Object.fromEntries(g);
@@ -406,14 +399,14 @@ async function os({
406
399
  if (!a) return null;
407
400
  const i = l.some((p) => p.locale === s) ? s : n;
408
401
  if (!i) return null;
409
- const c = await He({ req: t, state: o, componentId: e, locale: i, defaultLocale: n, properties: r });
402
+ const c = await Je({ req: t, state: o, componentId: e, locale: i, defaultLocale: n, properties: r });
410
403
  return c ? {
411
404
  component: a,
412
405
  ...c
413
406
  } : null;
414
407
  }
415
408
  const ns = 20;
416
- async function He({
409
+ async function Je({
417
410
  req: t,
418
411
  depth: o = 0,
419
412
  state: e,
@@ -439,7 +432,7 @@ async function He({
439
432
  return await Promise.all(
440
433
  Object.entries(i).map(async ([p, u]) => {
441
434
  if ((u == null ? void 0 : u.type) === Oe) {
442
- const m = await He({
435
+ const f = await Je({
443
436
  req: t,
444
437
  depth: o + 1,
445
438
  state: e,
@@ -448,11 +441,11 @@ async function He({
448
441
  defaultLocale: r,
449
442
  properties: u.properties
450
443
  });
451
- m && (Object.assign(c.components, m.components), Object.assign(c.props, {
444
+ f && (Object.assign(c.components, f.components), Object.assign(c.props, {
452
445
  [p]: {
453
446
  type: Oe,
454
447
  componentId: u.componentId,
455
- props: m.props
448
+ props: f.props
456
449
  }
457
450
  }));
458
451
  }
@@ -467,7 +460,7 @@ function rs({
467
460
  }) {
468
461
  const n = se({ state: t, componentId: o });
469
462
  if (!n) return null;
470
- const r = at({
463
+ const r = rt({
471
464
  componentId: o,
472
465
  getComponent: (l) => se({ state: t, componentId: l }),
473
466
  locale: e,
@@ -497,7 +490,7 @@ async function as({
497
490
  props: e,
498
491
  req: s
499
492
  }) {
500
- const n = await Je(o, "getServerSideProps");
493
+ const n = await Ge(o, "getServerSideProps");
501
494
  if (!n) return null;
502
495
  const r = new Promise((a, i) => {
503
496
  setTimeout(() => {
@@ -532,7 +525,7 @@ export async function getServerSidePropsWrapper(props) {
532
525
  export { joinURL, withQuery, getQuery, getComponentMountPoint }
533
526
  `;
534
527
  if (a === "@blocklet/pages-kit/builtin/dayjs")
535
- return it.dayjs;
528
+ return at.dayjs;
536
529
  },
537
530
  global: {
538
531
  console: {
@@ -548,27 +541,27 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
548
541
  v.error(...a);
549
542
  }
550
543
  },
551
- getComponentMountPoint: nt,
552
- joinURL: _,
553
- withQuery: ut,
554
- getQuery: pt
544
+ getComponentMountPoint: ot,
545
+ joinURL: M,
546
+ withQuery: pt,
547
+ getQuery: lt
555
548
  },
556
549
  functionName: "getServerSidePropsWrapper",
557
550
  args: [
558
551
  {
559
552
  // NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
560
553
  // because the global is shared between all runtime and just init once
561
- location: { href: _(dt(s.hostname), s.originalUrl) },
554
+ location: { href: M(ut(s.hostname), s.originalUrl) },
562
555
  fetch: (a, { ...i } = {}) => {
563
- const c = typeof a == "string" && a.startsWith("/") ? _(w.env.appUrl, a) : a;
564
- if (typeof c == "string" && ve(c).host === ve(w.env.appUrl).host) {
556
+ const c = typeof a == "string" && a.startsWith("/") ? M(S.env.appUrl, a) : a;
557
+ if (typeof c == "string" && ve(c).host === ve(S.env.appUrl).host) {
565
558
  const p = s.get("cookie");
566
559
  if (p) {
567
- const u = new lt(i.headers);
560
+ const u = new ct(i.headers);
568
561
  u.set("cookie", p), i.headers = u;
569
562
  }
570
563
  }
571
- return ct(c, {
564
+ return it(c, {
572
565
  ...i,
573
566
  timeout: ke * 1e3
574
567
  }).then((p) => ({
@@ -587,7 +580,7 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
587
580
  }
588
581
  const is = ae(
589
582
  async (t, o, e) => {
590
- const s = await Je(t, o);
583
+ const s = await Ge(t, o);
591
584
  if (s)
592
585
  try {
593
586
  return await Fe.callFunction({
@@ -616,8 +609,8 @@ const is = ae(
616
609
  ttl: 1e3 * 60 * 60
617
610
  }
618
611
  }
619
- ), cs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", De = "page", fe = "trigger-reload-project-resource", Ke = cs, ls = "z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV", { uploadToMediaKit: ps } = require("@blocklet/uploader-server"), Ne = kt("abcdefghijklmnopqrstuvwxyz0123456789", 16), we = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, z = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Le = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, us = 1e4, ds = 3e4, q = 0, ue = 1, ms = 0, fs = 1, ge = w, Q = O(process.env.BLOCKLET_DATA_DIR, "site-state"), ao = ["production", "draft"], io = ["production"];
620
- function We(t) {
612
+ ), cs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", De = "page", fe = "trigger-reload-project-resource", He = cs, ls = "z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV", { uploadToMediaKit: ps } = require("@blocklet/uploader-server"), Ne = kt("abcdefghijklmnopqrstuvwxyz0123456789", 16), Se = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, z = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Le = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, us = 1e4, ds = 3e4, q = 0, ue = 1, ms = 0, fs = 1, ge = S, Q = O(process.env.BLOCKLET_DATA_DIR, "site-state"), ao = ["production", "draft"], io = ["production"];
613
+ function Ke(t) {
621
614
  return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
622
615
  }
623
616
  function gs() {
@@ -632,7 +625,7 @@ function gs() {
632
625
  resources: {}
633
626
  };
634
627
  }
635
- const M = class M extends B.Doc {
628
+ const _ = class _ extends B.Doc {
636
629
  constructor(e) {
637
630
  super();
638
631
  P(this, "states", {});
@@ -698,7 +691,7 @@ const M = class M extends B.Doc {
698
691
  }
699
692
  e.close();
700
693
  });
701
- P(this, "autoSave", Ve(() => {
694
+ P(this, "autoSave", Be(() => {
702
695
  F(L(this.draftYjsFilePath), { recursive: !0 }), te(this.draftYjsFilePath, B.encodeStateAsUpdate(this));
703
696
  }, us));
704
697
  P(this, "save", ({ flush: e = !1 } = {}) => {
@@ -719,10 +712,10 @@ const M = class M extends B.Doc {
719
712
  e.config.fontFamily.title = (r == null ? void 0 : r.title) || (l == null ? void 0 : l.title), e.config.fontFamily.description = (r == null ? void 0 : r.description) || (l == null ? void 0 : l.description), await new Promise((p, u) => {
720
713
  this.transact(async () => {
721
714
  try {
722
- const m = await _e(e, s);
723
- p(m);
724
- } catch (m) {
725
- u(m);
715
+ const f = await _e(e, s);
716
+ p(f);
717
+ } catch (f) {
718
+ u(f);
726
719
  }
727
720
  });
728
721
  });
@@ -804,13 +797,13 @@ const M = class M extends B.Doc {
804
797
  });
805
798
  }
806
799
  static get allShared() {
807
- return this.projectIds.map((e) => M.shared(e));
800
+ return this.projectIds.map((e) => _.shared(e));
808
801
  }
809
802
  static shared(e) {
810
803
  if (!e)
811
804
  throw new Error("Should provide project context");
812
805
  let s = this.sharedInstances.get(e);
813
- return s || (s = new M({
806
+ return s || (s = new _({
814
807
  path: O(Q, e)
815
808
  }), this.sharedInstances.set(e, s), s);
816
809
  }
@@ -844,20 +837,20 @@ const M = class M extends B.Doc {
844
837
  var s, n, r, l;
845
838
  if (e === "draft")
846
839
  return JSON.parse(JSON.stringify(this.syncedStore));
847
- if (!this.states[e] && (this.states[e] = await qe(this.getPublishDir(e), { includeResources: !0 }) ?? gs(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
840
+ if (!this.states[e] && (this.states[e] = await Ye(this.getPublishDir(e), { includeResources: !0 }) ?? gs(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
848
841
  (r = this.states[e]).config ?? (r.config = {});
849
842
  const a = ge.env.languages.map((i) => ({ locale: i.code, name: i.name }));
850
843
  this.states[e].config.defaultLocale = (l = a[0]) == null ? void 0 : l.locale;
851
844
  }
852
845
  return {
853
846
  ...this.states[e],
854
- resources: await et().then(async (a) => {
855
- var u, m, g, h;
847
+ resources: await Ze().then(async (a) => {
848
+ var u, f, g, y;
856
849
  const { pages: i, components: c } = Ct(a, "pages", "components");
857
850
  let p = c;
858
- if ((m = (u = this.states[e]) == null ? void 0 : u.resources) != null && m.components)
851
+ if ((f = (u = this.states[e]) == null ? void 0 : u.resources) != null && f.components)
859
852
  p = {
860
- ...(h = (g = this.states[e]) == null ? void 0 : g.resources) == null ? void 0 : h.components
853
+ ...(y = (g = this.states[e]) == null ? void 0 : g.resources) == null ? void 0 : y.components
861
854
  };
862
855
  else {
863
856
  const A = J(this.options.path), x = await $.findByPk(A);
@@ -875,8 +868,8 @@ const M = class M extends B.Doc {
875
868
  };
876
869
  }
877
870
  async setState(e, s) {
878
- const n = await Ss(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
879
- F(L(r), { recursive: !0 }), Be(r, { force: !0, recursive: !0 }), Te(n, r), this.states[e] = s;
871
+ const n = await ws(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
872
+ F(L(r), { recursive: !0 }), $e(r, { force: !0, recursive: !0 }), Te(n, r), this.states[e] = s;
880
873
  }
881
874
  getPublishDir(e) {
882
875
  return O(this.options.path, e);
@@ -886,17 +879,17 @@ const M = class M extends B.Doc {
886
879
  for (const r of s) {
887
880
  const l = await $.findByPk(r);
888
881
  if (!l) continue;
889
- const a = await M.shared(r).getState(e), i = xt(
890
- w.env.languages.map((c) => c.code),
882
+ const a = await _.shared(r).getState(e), i = xt(
883
+ S.env.languages.map((c) => c.code),
891
884
  a.supportedLocales.map((c) => c.locale)
892
885
  );
893
886
  for (const c of a.pageIds) {
894
887
  const p = a.pages[c];
895
888
  if (!p || e === "production" && !p.isPublic)
896
889
  continue;
897
- const u = p.slug, m = l.slug || r, g = {
890
+ const u = p.slug, f = l.slug || r, g = {
898
891
  projectId: r,
899
- projectSlug: m,
892
+ projectSlug: f,
900
893
  pageSlug: u,
901
894
  pageId: c,
902
895
  // default locale
@@ -906,36 +899,36 @@ const M = class M extends B.Doc {
906
899
  isPublic: p.isPublic,
907
900
  isTemplate: p.isTemplate
908
901
  };
909
- m && (n[_("/", m, u)] = {
902
+ f && (n[M("/", f, u)] = {
910
903
  ...g,
911
904
  shouldRedirect: !0,
912
905
  mainPage: !0
913
- }), n[_("/", r, u)] = {
906
+ }), n[M("/", r, u)] = {
914
907
  ...g,
915
908
  shouldRedirect: !0,
916
909
  mainPage: !0
917
910
  };
918
- for (const h of i) {
919
- const A = { ...g, locale: h };
920
- n[_("/", h, r, u)] = A, m && (n[_("/", h, m, u)] = A);
911
+ for (const y of i) {
912
+ const A = { ...g, locale: y };
913
+ n[M("/", y, r, u)] = A, f && (n[M("/", y, f, u)] = A);
921
914
  }
922
915
  }
923
916
  }
924
917
  return n;
925
918
  }
926
919
  };
927
- P(M, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
928
- P(M, "sharedInstances", new he({
920
+ P(_, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
921
+ P(_, "sharedInstances", new he({
929
922
  max: 100,
930
923
  // Maximum number of instances to store
931
- ttl: M.INSTANCE_TTL,
924
+ ttl: _.INSTANCE_TTL,
932
925
  dispose: (e) => {
933
926
  e.destroy();
934
927
  }
935
928
  }));
936
- let oe = M;
937
- function ze() {
938
- return bt(O(w.env.dataDir, "tmp-"));
929
+ let oe = _;
930
+ function We() {
931
+ return bt(O(S.env.dataDir, "tmp-"));
939
932
  }
940
933
  function ne(t, o, e = []) {
941
934
  return Array.isArray(t) ? t.flatMap((s, n) => ne(s, o, [...e, n])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([s, n]) => ne(n, o, [...e, s])) : o(t) ? [e] : [];
@@ -953,9 +946,9 @@ async function hs(t, o, e) {
953
946
  })).data.filename)(), e[t] = s), s;
954
947
  }
955
948
  const ys = async (t, o) => {
956
- const e = J(t), s = await $e({
957
- name: Ke,
958
- path: _("/uploads", e),
949
+ const e = J(t), s = await yt({
950
+ name: He,
951
+ path: M("/uploads", e),
959
952
  responseType: "stream",
960
953
  method: "GET"
961
954
  });
@@ -964,7 +957,7 @@ const ys = async (t, o) => {
964
957
  await Lt(s.data, n);
965
958
  } else
966
959
  throw new Error(`download asset failed ${s.status}`);
967
- }, ws = async (t, o) => {
960
+ }, Ss = async (t, o) => {
968
961
  await Promise.all(
969
962
  t.map(async (e) => {
970
963
  try {
@@ -975,20 +968,20 @@ const ys = async (t, o) => {
975
968
  })
976
969
  );
977
970
  };
978
- function Ye(t) {
979
- return we.test(t) ? [t] : z.test(t) ? (Le.lastIndex = 0, Array.from(t.matchAll(Le)).map((e) => e[1]).filter((e) => !!e)) : [];
971
+ function ze(t) {
972
+ return Se.test(t) ? [t] : z.test(t) ? (Le.lastIndex = 0, Array.from(t.matchAll(Le)).map((e) => e[1]).filter((e) => !!e)) : [];
980
973
  }
981
974
  async function de(t, o, e) {
982
975
  const { getFilename: s, exportAssets: n } = e, r = O(o, s(t));
983
976
  if (F(L(r), { recursive: !0 }), te(r, K.stringify(t)), n) {
984
977
  const a = ne(
985
978
  t,
986
- (i) => typeof i == "string" && (we.test(i) || z.test(i))
979
+ (i) => typeof i == "string" && (Se.test(i) || z.test(i))
987
980
  ).map((i) => {
988
981
  const c = ye(t, i);
989
- return Ye(c);
982
+ return ze(c);
990
983
  }).flat().filter(Boolean);
991
- await ws(a, L(r));
984
+ await Ss(a, L(r));
992
985
  }
993
986
  }
994
987
  const Re = new he({
@@ -999,19 +992,19 @@ async function Ue(t, o, e) {
999
992
  var a;
1000
993
  const s = ne(
1001
994
  t,
1002
- (i) => typeof i == "string" && (we.test(i) || z.test(i))
995
+ (i) => typeof i == "string" && (Se.test(i) || z.test(i))
1003
996
  ), n = Dt(2), r = s.map(
1004
997
  (i) => n(async () => {
1005
998
  try {
1006
- const c = ye(t, i), p = Ye(c);
999
+ const c = ye(t, i), p = ze(c);
1007
1000
  for (const u of p) {
1008
- const m = J(u), g = e.getFilePath(u, i), h = g ? `${g}:${m}` : m, A = Re.get(h);
1001
+ const f = J(u), g = e.getFilePath(u, i), y = g ? `${g}:${f}` : f, A = Re.get(y);
1009
1002
  if (A) {
1010
1003
  z.test(c) || Pe(t, i, A);
1011
1004
  return;
1012
1005
  }
1013
- const x = await hs(g, m, o);
1014
- x && (z.test(c) || Pe(t, i, x), Re.set(h, x));
1006
+ const x = await hs(g, f, o);
1007
+ x && (z.test(c) || Pe(t, i, x), Re.set(y, x));
1015
1008
  }
1016
1009
  } catch (c) {
1017
1010
  v.error(`Failed to process upload for path ${i.join(".")}:`, c.message || c.reason);
@@ -1020,89 +1013,89 @@ async function Ue(t, o, e) {
1020
1013
  ), l = await Promise.allSettled(r);
1021
1014
  (a = e.onFinish) == null || a.call(e, l);
1022
1015
  }
1023
- async function Ss(t, {
1016
+ async function ws(t, {
1024
1017
  exportAssets: o,
1025
1018
  pageIds: e = "all",
1026
1019
  componentIds: s = "all",
1027
1020
  rawConfig: n,
1028
1021
  includeResources: r = !1
1029
1022
  } = {}) {
1030
- var U, D, y, E, b, I;
1023
+ var U, D, h, E, b, I;
1031
1024
  const l = e === "all" ? t.pageIds : e, a = Es({
1032
1025
  state: t,
1033
1026
  pageIds: l,
1034
1027
  componentIds: s === "all" ? Object.keys(t.components) : s
1035
- }), i = (f, d) => {
1036
- var S;
1028
+ }), i = (m, d) => {
1029
+ var w;
1037
1030
  return {
1038
- id: f.id,
1039
- name: f.name,
1040
- isTemplateSection: f.isTemplateSection ?? !1,
1041
- templateDescription: f.templateDescription,
1042
- component: f.component,
1043
- config: f.config,
1044
- visibility: f.visibility,
1045
- properties: ((S = f.locales) == null ? void 0 : S[d]) ?? {}
1031
+ id: m.id,
1032
+ name: m.name,
1033
+ isTemplateSection: m.isTemplateSection ?? !1,
1034
+ templateDescription: m.templateDescription,
1035
+ component: m.component,
1036
+ config: m.config,
1037
+ visibility: m.visibility,
1038
+ properties: ((w = m.locales) == null ? void 0 : w[d]) ?? {}
1046
1039
  };
1047
- }, c = (f, d) => {
1048
- var S;
1040
+ }, c = (m, d) => {
1041
+ var w;
1049
1042
  return {
1050
- id: f.id,
1051
- createdAt: f.createdAt,
1052
- updatedAt: f.updatedAt,
1053
- publishedAt: f.publishedAt,
1054
- isPublic: f.isPublic ?? !0,
1055
- isTemplate: f.isTemplate ?? !1,
1056
- meta: ((S = f.locales) == null ? void 0 : S[d]) ?? {},
1043
+ id: m.id,
1044
+ createdAt: m.createdAt,
1045
+ updatedAt: m.updatedAt,
1046
+ publishedAt: m.publishedAt,
1047
+ isPublic: m.isPublic ?? !0,
1048
+ isTemplate: m.isTemplate ?? !1,
1049
+ meta: ((w = m.locales) == null ? void 0 : w[d]) ?? {},
1057
1050
  sections: R(
1058
- f.sectionIds.map((k) => {
1059
- const N = f.sections[k];
1051
+ m.sectionIds.map((k) => {
1052
+ const N = m.sections[k];
1060
1053
  return N && i(N, d);
1061
1054
  })
1062
1055
  )
1063
1056
  };
1064
1057
  }, p = R(
1065
- t.supportedLocales.map((f) => f.locale).flatMap(
1066
- (f) => l.map((d) => {
1067
- const S = t.pages[d];
1068
- return S && {
1069
- locale: f,
1070
- slug: S.slug,
1071
- page: c(S, f)
1058
+ t.supportedLocales.map((m) => m.locale).flatMap(
1059
+ (m) => l.map((d) => {
1060
+ const w = t.pages[d];
1061
+ return w && {
1062
+ locale: m,
1063
+ slug: w.slug,
1064
+ page: c(w, m)
1072
1065
  };
1073
1066
  })
1074
1067
  )
1075
- ), u = ze(), m = O(u, "pages");
1076
- F(m, { recursive: !0 });
1068
+ ), u = We(), f = O(u, "pages");
1069
+ F(f, { recursive: !0 });
1077
1070
  const g = O(u, "components");
1078
1071
  F(g, { recursive: !0 });
1079
- for (const { locale: f, slug: d, page: S } of p)
1080
- await de(S, m, {
1081
- getFilename: () => `${We(d) || "index"}.${f}.yml`,
1072
+ for (const { locale: m, slug: d, page: w } of p)
1073
+ await de(w, f, {
1074
+ getFilename: () => `${Ke(d) || "index"}.${m}.yml`,
1082
1075
  exportAssets: o
1083
1076
  });
1084
- for (const f of a) {
1085
- const d = (U = t.components[f]) == null ? void 0 : U.data;
1077
+ for (const m of a) {
1078
+ const d = (U = t.components[m]) == null ? void 0 : U.data;
1086
1079
  d && await de(d, g, {
1087
- getFilename: (S) => `${S.name || "unnamed"}.${S.id}.yml`,
1080
+ getFilename: (w) => `${w.name || "unnamed"}.${w.id}.yml`,
1088
1081
  exportAssets: o
1089
1082
  });
1090
1083
  }
1091
- const h = O(u, ".blocklet/pages/pages.config.yml");
1092
- F(L(h), { recursive: !0 });
1084
+ const y = O(u, ".blocklet/pages/pages.config.yml");
1085
+ F(L(y), { recursive: !0 });
1093
1086
  const A = {
1094
1087
  pages: R(
1095
- l.map((f) => {
1096
- const d = t.pages[f];
1097
- return d && { id: f, slug: d.slug };
1088
+ l.map((m) => {
1089
+ const d = t.pages[m];
1090
+ return d && { id: m, slug: d.slug };
1098
1091
  })
1099
1092
  ),
1100
1093
  components: R(
1101
- a.map((f) => {
1102
- var S;
1103
- const d = (S = t.components[f]) == null ? void 0 : S.data;
1094
+ a.map((m) => {
1095
+ var w;
1096
+ const d = (w = t.components[m]) == null ? void 0 : w.data;
1104
1097
  return d && {
1105
- id: f,
1098
+ id: m,
1106
1099
  name: d.name
1107
1100
  };
1108
1101
  })
@@ -1110,11 +1103,11 @@ async function Ss(t, {
1110
1103
  ...r ? {
1111
1104
  resources: {
1112
1105
  components: R(
1113
- Object.keys(((D = t.resources) == null ? void 0 : D.components) || {}).map((f) => {
1114
- var d, S, k, N;
1106
+ Object.keys(((D = t.resources) == null ? void 0 : D.components) || {}).map((m) => {
1107
+ var d, w, k, N;
1115
1108
  return {
1116
- id: f,
1117
- name: (N = (k = (S = (d = t.resources) == null ? void 0 : d.components) == null ? void 0 : S[f]) == null ? void 0 : k.component) == null ? void 0 : N.name
1109
+ id: m,
1110
+ name: (N = (k = (w = (d = t.resources) == null ? void 0 : d.components) == null ? void 0 : w[m]) == null ? void 0 : k.component) == null ? void 0 : N.name
1118
1111
  };
1119
1112
  })
1120
1113
  )
@@ -1123,13 +1116,13 @@ async function Ss(t, {
1123
1116
  supportedLocales: t.supportedLocales,
1124
1117
  config: t.config
1125
1118
  };
1126
- te(h, K.stringify(A));
1119
+ te(y, K.stringify(A));
1127
1120
  const x = O(u, "config.source.json");
1128
1121
  if (n && te(x, JSON.stringify(n)), r) {
1129
- const f = O(u, "resources"), d = O(f, "components");
1122
+ const m = O(u, "resources"), d = O(m, "components");
1130
1123
  F(d, { recursive: !0 });
1131
- for (const S of Object.keys(((y = t == null ? void 0 : t.resources) == null ? void 0 : y.components) ?? {})) {
1132
- const k = (I = (b = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : b[S]) == null ? void 0 : I.component;
1124
+ for (const w of Object.keys(((h = t == null ? void 0 : t.resources) == null ? void 0 : h.components) ?? {})) {
1125
+ const k = (I = (b = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : b[w]) == null ? void 0 : I.component;
1133
1126
  k && await de(k, d, {
1134
1127
  getFilename: (N) => `${N.name || "unnamed"}.${N.id}.yml`,
1135
1128
  exportAssets: o
@@ -1138,45 +1131,45 @@ async function Ss(t, {
1138
1131
  }
1139
1132
  return u;
1140
1133
  }
1141
- async function qe(t, { importAssets: o, includeResources: e } = {}) {
1134
+ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
1142
1135
  var r, l, a;
1143
1136
  if (!V(t))
1144
1137
  return null;
1145
1138
  let s, n = !1;
1146
1139
  try {
1147
- Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s = ze(), await Rt({ file: t, C: s }));
1140
+ Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s = We(), await Rt({ file: t, C: s }));
1148
1141
  const i = me("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), c = i && O(L(i), "../../pages"), p = i && O(L(i), "../../components"), u = i && O(L(i), "../../chunks");
1149
1142
  if (!i)
1150
1143
  return null;
1151
- const m = K.parse(H(i).toString()), g = (y, E, b) => {
1152
- let I = O(y, `${E}${b ? `.${b}` : ""}.yml`);
1153
- return (!V(I) || !Z(I).isFile()) && (I = O(y, E, `index${b ? `.${b}` : ""}.yml`), !V(I) || !Z(I)) ? null : K.parse(H(I).toString());
1154
- }, h = (y, E) => {
1144
+ const f = K.parse(H(i).toString()), g = (h, E, b) => {
1145
+ let I = O(h, `${E}${b ? `.${b}` : ""}.yml`);
1146
+ return (!V(I) || !Z(I).isFile()) && (I = O(h, E, `index${b ? `.${b}` : ""}.yml`), !V(I) || !Z(I)) ? null : K.parse(H(I).toString());
1147
+ }, y = (h, E) => {
1155
1148
  try {
1156
- const b = me(`*.${E}.yml`, { cwd: y, absolute: !0 })[0];
1149
+ const b = me(`*.${E}.yml`, { cwd: h, absolute: !0 })[0];
1157
1150
  return b ? K.parse(H(b).toString()) : null;
1158
1151
  } catch (b) {
1159
1152
  v.error("parse component error", b);
1160
1153
  }
1161
1154
  return null;
1162
1155
  }, A = R(
1163
- m.pages.map(({ slug: y }) => {
1164
- var f;
1156
+ f.pages.map(({ slug: h }) => {
1157
+ var m;
1165
1158
  const E = R(
1166
- m.supportedLocales.map(({ locale: d }) => {
1167
- const S = c ? g(c, We(y), d) : void 0;
1168
- if (S)
1169
- return { locale: d, page: S };
1170
- const k = c ? g(c, y, d) : void 0;
1159
+ f.supportedLocales.map(({ locale: d }) => {
1160
+ const w = c ? g(c, Ke(h), d) : void 0;
1161
+ if (w)
1162
+ return { locale: d, page: w };
1163
+ const k = c ? g(c, h, d) : void 0;
1171
1164
  return k && { locale: d, page: k };
1172
1165
  })
1173
- ), b = (f = E[0]) == null ? void 0 : f.page;
1166
+ ), b = (m = E[0]) == null ? void 0 : m.page;
1174
1167
  if (!b)
1175
1168
  return null;
1176
1169
  const I = b.sections.map((d) => {
1177
- const S = d.id || Ne();
1170
+ const w = d.id || Ne();
1178
1171
  return {
1179
- id: S,
1172
+ id: w,
1180
1173
  component: d.component,
1181
1174
  config: d.config,
1182
1175
  name: d.name,
@@ -1186,7 +1179,7 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
1186
1179
  locales: Object.fromEntries(
1187
1180
  R(
1188
1181
  E.map(({ locale: k, page: N }) => {
1189
- const Ie = N.sections.find((tt) => tt.id === S);
1182
+ const Ie = N.sections.find((et) => et.id === w);
1190
1183
  return Ie && [k, Ie.properties];
1191
1184
  })
1192
1185
  )
@@ -1200,48 +1193,48 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
1200
1193
  publishedAt: b.publishedAt,
1201
1194
  isPublic: b.isPublic ?? !0,
1202
1195
  isTemplate: b.isTemplate ?? !1,
1203
- slug: y,
1196
+ slug: h,
1204
1197
  sections: Object.fromEntries(I.map((d) => [d.id, d])),
1205
1198
  sectionIds: I.map((d) => d.id),
1206
- locales: Object.fromEntries(E.map(({ locale: d, page: S }) => [d, S.meta]))
1199
+ locales: Object.fromEntries(E.map(({ locale: d, page: w }) => [d, w.meta]))
1207
1200
  };
1208
1201
  })
1209
- ), x = p ? R(((r = m.components) == null ? void 0 : r.map(({ id: y }) => h(p, y))) ?? []) : [];
1202
+ ), x = p ? R(((r = f.components) == null ? void 0 : r.map(({ id: h }) => y(p, h))) ?? []) : [];
1210
1203
  if (o) {
1211
- const y = (...E) => {
1204
+ const h = (...E) => {
1212
1205
  v.info(`[${n ? J(t) : J(O(t, "../../../../"))}] importAssets:`, ...E);
1213
1206
  };
1214
1207
  try {
1215
- y("wait image-bin api ready"), await Ut({
1216
- resources: [`${yt(Kt)}/api/sdk/uploads`],
1208
+ h("wait image-bin api ready"), await Ut({
1209
+ resources: [`${ht(Kt)}/api/sdk/uploads`],
1217
1210
  validateStatus: (I) => I >= 200 && I <= 500
1218
- }), y("image-bin api is ready");
1211
+ }), h("image-bin api is ready");
1219
1212
  const E = {}, b = {};
1220
- y("start to upload assets"), await Promise.allSettled([
1213
+ h("start to upload assets"), await Promise.allSettled([
1221
1214
  Ue(x, E, {
1222
1215
  getFilePath: (I) => p && O(p, I),
1223
1216
  onFinish: (I) => {
1224
- y(`upload ${I.length} component assets`);
1217
+ h(`upload ${I.length} component assets`);
1225
1218
  }
1226
1219
  }),
1227
1220
  Ue(A, b, {
1228
- getFilePath: (I, f) => {
1229
- const d = ye(A, f.slice(0, 1));
1221
+ getFilePath: (I, m) => {
1222
+ const d = ye(A, m.slice(0, 1));
1230
1223
  return c && O(c, L(d.slug), I);
1231
1224
  },
1232
1225
  onFinish: (I) => {
1233
- y(`upload ${I.length} page assets`);
1226
+ h(`upload ${I.length} page assets`);
1234
1227
  }
1235
1228
  })
1236
- ]), y("upload assets done"), global.gc && global.gc();
1229
+ ]), h("upload assets done"), global.gc && global.gc();
1237
1230
  } catch (E) {
1238
- y("Error during asset import:", E);
1231
+ h("Error during asset import:", E);
1239
1232
  }
1240
1233
  }
1241
1234
  const U = {};
1242
1235
  if (e) {
1243
- const y = i && O(L(i), "../../resources/components"), E = R(
1244
- ((a = (l = m.resources) == null ? void 0 : l.components) == null ? void 0 : a.map(({ id: b }) => h(y, b))) ?? []
1236
+ const h = i && O(L(i), "../../resources/components"), E = R(
1237
+ ((a = (l = f.resources) == null ? void 0 : l.components) == null ? void 0 : a.map(({ id: b }) => y(h, b))) ?? []
1245
1238
  );
1246
1239
  E.length > 0 && (U.components = Object.fromEntries(
1247
1240
  E.map((b, I) => [b.id, { index: I, component: b }])
@@ -1249,21 +1242,21 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
1249
1242
  }
1250
1243
  const D = {};
1251
1244
  if (u && V(u)) {
1252
- const y = Et(u);
1253
- for (const E of y)
1245
+ const h = Et(u);
1246
+ for (const E of h)
1254
1247
  D[E] = O(u, E);
1255
1248
  }
1256
1249
  return {
1257
- supportedLocales: m.supportedLocales,
1258
- pageIds: A.map((y) => y.id),
1259
- components: Object.fromEntries(x.map((y, E) => [y.id, { index: E, data: y }])),
1260
- pages: Object.fromEntries(A.map((y) => [y.id, y])),
1261
- config: m.config || {},
1250
+ supportedLocales: f.supportedLocales,
1251
+ pageIds: A.map((h) => h.id),
1252
+ components: Object.fromEntries(x.map((h, E) => [h.id, { index: E, data: h }])),
1253
+ pages: Object.fromEntries(A.map((h) => [h.id, h])),
1254
+ config: f.config || {},
1262
1255
  resources: U,
1263
1256
  chunks: D
1264
1257
  };
1265
1258
  } finally {
1266
- n && s && Be(s, { force: !0, recursive: !0 });
1259
+ n && s && $e(s, { force: !0, recursive: !0 });
1267
1260
  }
1268
1261
  }
1269
1262
  async function _e(t, o, {
@@ -1281,16 +1274,16 @@ async function _e(t, o, {
1281
1274
  for (const p of e ?? l) {
1282
1275
  const u = a[p];
1283
1276
  if (!u) {
1284
- const m = o.pageIds.indexOf(p);
1285
- m !== -1 && n && (o.pageIds.splice(m, 1), delete o.pages[p]);
1277
+ const f = o.pageIds.indexOf(p);
1278
+ f !== -1 && n && (o.pageIds.splice(f, 1), delete o.pages[p]);
1286
1279
  continue;
1287
1280
  }
1288
1281
  if (o.pageIds.includes(u.id)) {
1289
1282
  if (s === "replace")
1290
1283
  o.pages[u.id] = u;
1291
1284
  else if (s === "byUpdateTime") {
1292
- const m = o.pages[u.id];
1293
- (!m || u.updatedAt && u.updatedAt > m.updatedAt) && (o.pages[u.id] = u);
1285
+ const f = o.pages[u.id];
1286
+ (!f || u.updatedAt && u.updatedAt > f.updatedAt) && (o.pages[u.id] = u);
1294
1287
  }
1295
1288
  } else
1296
1289
  o.pageIds.push(u.id), o.pages[u.id] = u;
@@ -1305,19 +1298,19 @@ async function _e(t, o, {
1305
1298
  c = Object.fromEntries(
1306
1299
  await Promise.all(
1307
1300
  Object.entries(c).map(async ([p, u]) => {
1308
- const m = await Qe(u == null ? void 0 : u.data);
1301
+ const f = await qe(u == null ? void 0 : u.data);
1309
1302
  return [
1310
1303
  p,
1311
1304
  {
1312
1305
  ...u,
1313
- data: m
1306
+ data: f
1314
1307
  }
1315
1308
  ];
1316
1309
  })
1317
1310
  )
1318
1311
  ), Object.assign(o.components, c), Object.assign(o.config, JSON.parse(JSON.stringify(t.config))), o.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
1319
1312
  }
1320
- const Qe = ae(
1313
+ const qe = ae(
1321
1314
  async (t) => {
1322
1315
  var o;
1323
1316
  if (!Pt(t == null ? void 0 : t.properties))
@@ -1373,21 +1366,21 @@ function Es({
1373
1366
  }
1374
1367
  return [...n];
1375
1368
  }
1376
- let re, G, Se, Ee, be;
1377
- function Xe() {
1369
+ let re, G, we, Ee, be;
1370
+ function Qe() {
1378
1371
  return re = (async () => {
1379
- const t = ht({
1372
+ const t = gt({
1380
1373
  types: [
1381
- { did: Ke, type: De },
1374
+ { did: He, type: De },
1382
1375
  { did: ls, type: De }
1383
1376
  ]
1384
1377
  });
1385
1378
  G = (await Promise.all(
1386
1379
  t.map(async (e) => {
1387
- const s = e.path ? await qe(e.path, { importAssets: !1 }) : void 0;
1380
+ const s = e.path ? await Ye(e.path, { importAssets: !1 }) : void 0;
1388
1381
  return s ? { blockletId: e.did, state: s, blockletTitle: e.title } : void 0;
1389
1382
  })
1390
- )).filter((e) => !!e), Se = G.reduce(
1383
+ )).filter((e) => !!e), we = G.reduce(
1391
1384
  (e, s) => Object.assign(
1392
1385
  e,
1393
1386
  Object.fromEntries(
@@ -1408,7 +1401,7 @@ function Xe() {
1408
1401
  Ee = Object.fromEntries(
1409
1402
  await Promise.all(
1410
1403
  Object.entries(o).map(async ([e, s]) => {
1411
- const n = await Qe(s.component);
1404
+ const n = await qe(s.component);
1412
1405
  return [
1413
1406
  e,
1414
1407
  {
@@ -1422,13 +1415,13 @@ function Xe() {
1422
1415
  })(), re;
1423
1416
  }
1424
1417
  function bs(t) {
1425
- const o = Ve(
1418
+ const o = Be(
1426
1419
  async () => {
1427
- await Xe().catch((e) => {
1420
+ await Qe().catch((e) => {
1428
1421
  v.error("load resource states error", { error: e });
1429
1422
  }), await (t == null ? void 0 : t({
1430
1423
  states: G,
1431
- pages: Se,
1424
+ pages: we,
1432
1425
  components: Ee,
1433
1426
  chunks: be
1434
1427
  }));
@@ -1436,14 +1429,14 @@ function bs(t) {
1436
1429
  3e3,
1437
1430
  { leading: !1, trailing: !0 }
1438
1431
  );
1439
- return o(), w.events.on(w.Events.componentAdded, o), w.events.on(w.Events.componentRemoved, o), w.events.on(w.Events.componentStarted, o), w.events.on(w.Events.componentStopped, o), w.events.on(w.Events.componentUpdated, o), w.events.on(fe, o), () => {
1440
- w.events.off(w.Events.componentAdded, o), w.events.off(w.Events.componentRemoved, o), w.events.off(w.Events.componentStarted, o), w.events.off(w.Events.componentStopped, o), w.events.off(w.Events.componentUpdated, o), w.events.off(fe, o);
1432
+ return o(), S.events.on(S.Events.componentAdded, o), S.events.on(S.Events.componentRemoved, o), S.events.on(S.Events.componentStarted, o), S.events.on(S.Events.componentStopped, o), S.events.on(S.Events.componentUpdated, o), S.events.on(fe, o), () => {
1433
+ S.events.off(S.Events.componentAdded, o), S.events.off(S.Events.componentRemoved, o), S.events.off(S.Events.componentStarted, o), S.events.off(S.Events.componentStopped, o), S.events.off(S.Events.componentUpdated, o), S.events.off(fe, o);
1441
1434
  };
1442
1435
  }
1443
- const Ze = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ee = globalThis;
1436
+ const Xe = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ee = globalThis;
1444
1437
  var Me;
1445
- (Me = ee[Ze]) == null || Me.call(ee);
1446
- ee[Ze] = bs(async ({ pages: t, components: o }) => {
1438
+ (Me = ee[Xe]) == null || Me.call(ee);
1439
+ ee[Xe] = bs(async ({ pages: t, components: o }) => {
1447
1440
  const { projectIds: e } = oe;
1448
1441
  await Promise.all(
1449
1442
  e.map(async (s) => {
@@ -1466,20 +1459,20 @@ ee[Ze] = bs(async ({ pages: t, components: o }) => {
1466
1459
  );
1467
1460
  });
1468
1461
  async function co() {
1469
- v.info("trigger reload all project resource"), w.events.emit(fe);
1462
+ v.info("trigger reload all project resource"), S.events.emit(fe);
1470
1463
  }
1471
- async function et({
1464
+ async function Ze({
1472
1465
  ensureLoaded: t = !0
1473
1466
  } = {}) {
1474
- return t && (re ?? (re = Xe()), await re), { states: G, pages: Se, components: Ee, chunks: be };
1467
+ return t && (re ?? (re = Qe()), await re), { states: G, pages: we, components: Ee, chunks: be };
1475
1468
  }
1476
1469
  export {
1477
- Ke as C,
1470
+ He as C,
1478
1471
  ke as G,
1479
1472
  $ as P,
1480
1473
  De as R,
1481
1474
  oe as S,
1482
- et as a,
1475
+ Ze as a,
1483
1476
  no as b,
1484
1477
  Zt as c,
1485
1478
  es as d,
@@ -1496,9 +1489,9 @@ export {
1496
1489
  Q as o,
1497
1490
  ao as p,
1498
1491
  io as q,
1499
- qe as r,
1492
+ Ye as r,
1500
1493
  _e as s,
1501
- Ss as t,
1494
+ ws as t,
1502
1495
  bs as u,
1503
1496
  co as v
1504
1497
  };