@blocklet/pages-kit-inner-components 0.4.85 → 0.4.87

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,6 +1,6 @@
1
1
  var pt = Object.defineProperty;
2
2
  var ut = (t, o, e) => o in t ? pt(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
3
- var C = (t, o, e) => ut(t, typeof o != "symbol" ? o + "" : o, e);
3
+ var P = (t, o, e) => ut(t, typeof o != "symbol" ? o + "" : o, e);
4
4
  import { getComponentMountPoint as dt } from "@blocklet/pages-kit/builtin/utils";
5
5
  import { PreloadComponentScriptModule as ae } from "@blocklet/pages-kit/types";
6
6
  import { componentUMDName as mt, RenderNestedComponent as Le, mergeComponent as ft, getComponentDependencies as gt } from "@blocklet/pages-kit/utils/property";
@@ -13,7 +13,7 @@ import { createHash as ge } from "crypto";
13
13
  import It from "@blocklet/logger";
14
14
  import { BuiltinModules as Ot } from "@blocklet/pages-kit/utils/builtin";
15
15
  import { createBuiltinModuleTransformer as Tt, isRelativeModule as vt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
16
- import { getResources as At, getComponentWebEndpoint as Pt, call as Ct } from "@blocklet/sdk/lib/component";
16
+ import { getResources as At, getComponentWebEndpoint as Ct, call as Pt } from "@blocklet/sdk/lib/component";
17
17
  import xt from "autoprefixer";
18
18
  import * as jt from "esbuild";
19
19
  import { readFileSync as X, existsSync as V, lstatSync as ie, readdirSync as kt, rmSync as qe, mkdtempSync as Dt, renameSync as Ue, mkdirSync as B, writeFileSync as le, copyFileSync as Nt, createWriteStream as Lt } from "fs";
@@ -25,10 +25,16 @@ import { syncedStore as _t, getYjsValue as we } from "@syncedstore/core";
25
25
  import { globSync as Oe } from "glob";
26
26
  import * as Ee from "lib0/decoding";
27
27
  import * as x from "lib0/encoding";
28
- import { get as Pe, isEmpty as $t, set as Me, pick as Ft, debounce as Qe, union as Bt, cloneDeep as Gt } from "lodash";
28
+ import $t from "lodash/cloneDeep";
29
+ import Qe from "lodash/debounce";
30
+ import Ce from "lodash/get";
31
+ import Ft from "lodash/isEmpty";
32
+ import Bt from "lodash/pick";
33
+ import Me from "lodash/set";
34
+ import Gt from "lodash/union";
29
35
  import { customAlphabet as Vt } from "nanoid";
30
36
  import Jt from "p-limit";
31
- import Ht, { join as b, dirname as R, basename as q } from "path";
37
+ import Ht, { join as E, dirname as R, basename as q } from "path";
32
38
  import { pipeline as Kt } from "stream/promises";
33
39
  import { x as zt } from "tar";
34
40
  import Yt from "wait-on";
@@ -37,17 +43,17 @@ import { writeUpdate as Xt, writeSyncStep1 as Zt, readSyncMessage as es } from "
37
43
  import * as Z from "yaml";
38
44
  import * as z from "yjs";
39
45
  import ts from "lodash/isNil";
40
- import { DataTypes as P, Sequelize as ss, Model as Xe, Op as os } from "sequelize";
46
+ import { DataTypes as C, Sequelize as ss, Model as Xe, Op as os } from "sequelize";
41
47
  import "sqlite3";
42
48
  import "@blocklet/pages-kit/types/state";
43
49
  y.env.mode;
44
50
  const ns = "image-bin";
45
51
  y.env.INIT_TEMPLATE_PATH;
46
- const rs = process.env.DATABASE_URL || Ht.join(y.env.dataDir, "db/pages-kit.db"), $e = y, go = () => y.env.tenantMode === "multiple", ho = () => {
52
+ const rs = process.env.DATABASE_URL || Ht.join(y.env.dataDir, "db/pages-kit.db"), $e = y, bo = () => y.env.tenantMode === "multiple", Io = () => {
47
53
  var t;
48
54
  return (ts($e.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = $e.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
49
- }, w = It("pages-kit"), as = P.sqlite.DATE.parse;
50
- P.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) : as(t, o);
55
+ }, b = It("pages-kit"), as = C.sqlite.DATE.parse;
56
+ C.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) : as(t, o);
51
57
  const se = new ss({
52
58
  dialect: "sqlite",
53
59
  storage: rs,
@@ -70,17 +76,17 @@ class he extends Xe {
70
76
  he.init(
71
77
  {
72
78
  id: {
73
- type: P.UUID,
79
+ type: C.UUID,
74
80
  allowNull: !1,
75
81
  primaryKey: !0,
76
- defaultValue: P.UUIDV4
82
+ defaultValue: C.UUIDV4
77
83
  },
78
84
  projectId: {
79
- type: P.UUID,
85
+ type: C.UUID,
80
86
  allowNull: !1
81
87
  },
82
88
  componentId: {
83
- type: P.STRING,
89
+ type: C.STRING,
84
90
  allowNull: !1
85
91
  }
86
92
  },
@@ -98,32 +104,32 @@ class Y extends Xe {
98
104
  Y.init(
99
105
  {
100
106
  id: {
101
- type: P.UUID,
102
- defaultValue: P.UUIDV4,
107
+ type: C.UUID,
108
+ defaultValue: C.UUIDV4,
103
109
  primaryKey: !0
104
110
  },
105
111
  name: {
106
- type: P.STRING,
112
+ type: C.STRING,
107
113
  allowNull: !1
108
114
  },
109
- description: P.TEXT,
110
- createdAt: P.DATE,
111
- updatedAt: P.DATE,
115
+ description: C.TEXT,
116
+ createdAt: C.DATE,
117
+ updatedAt: C.DATE,
112
118
  createdBy: {
113
- type: P.STRING,
119
+ type: C.STRING,
114
120
  allowNull: !1
115
121
  },
116
122
  updatedBy: {
117
- type: P.STRING,
123
+ type: C.STRING,
118
124
  allowNull: !1
119
125
  },
120
- slug: P.STRING,
121
- icon: P.STRING,
122
- pinnedAt: P.DATE,
123
- useAllResources: P.BOOLEAN,
124
- npmSecret: P.STRING,
126
+ slug: C.STRING,
127
+ icon: C.STRING,
128
+ pinnedAt: C.DATE,
129
+ useAllResources: C.BOOLEAN,
130
+ npmSecret: C.STRING,
125
131
  relatedBlocklets: {
126
- type: P.JSON,
132
+ type: C.JSON,
127
133
  allowNull: !1,
128
134
  defaultValue: {},
129
135
  get() {
@@ -230,7 +236,7 @@ ${t}
230
236
  if (c || (c = await De({ ensureLoaded: !1 })), (u = c == null ? void 0 : c.chunks) != null && u[d])
231
237
  try {
232
238
  const f = X(c.chunks[d], "utf-8");
233
- return w.info("get chunk from local file system", d), { contents: f, loader: "tsx" };
239
+ return b.info("get chunk from local file system", d), { contents: f, loader: "tsx" };
234
240
  } catch {
235
241
  }
236
242
  }
@@ -293,11 +299,11 @@ var ${t} = ${e ? "async" : ""} function () {
293
299
  max: 100
294
300
  }), us = 60 * 60, Be = 60;
295
301
  function ds(t) {
296
- w.info("clear preload components cache", { cacheKey: t }), ee.delete(t);
302
+ b.info("clear preload components cache", { cacheKey: t }), ee.delete(t);
297
303
  }
298
304
  function ms(t) {
299
305
  for (const o of ee.keys())
300
- o.includes(t) && (w.info("clear preload components cache", { cacheKey: o }), ds(o));
306
+ o.includes(t) && (b.info("clear preload components cache", { cacheKey: o }), ds(o));
301
307
  }
302
308
  function fs({
303
309
  mode: t,
@@ -307,7 +313,7 @@ function fs({
307
313
  }) {
308
314
  return ["getPreloadComponents", t, o, e, s].join("-");
309
315
  }
310
- async function yo({
316
+ async function Oo({
311
317
  mode: t,
312
318
  req: o,
313
319
  state: e,
@@ -330,7 +336,7 @@ async function yo({
330
336
  locale: s
331
337
  });
332
338
  if (t !== "draft" && f.useCache && ee.has(h))
333
- return w.info(`get preload component from cache: ${h}`), ee.get(h);
339
+ return b.info(`get preload component from cache: ${h}`), ee.get(h);
334
340
  const A = pe({ state: e, componentId: f.componentId });
335
341
  if (!A) return null;
336
342
  const j = await gs({
@@ -345,13 +351,13 @@ async function yo({
345
351
  const M = { instanceId: f.id, preload: j };
346
352
  if (t !== "draft" && f.useCache) {
347
353
  let D = us;
348
- f.cacheDuration && (D = f.cacheDuration), w.info(`set preload component to cache(${D}s): ${h}`), ee.set(h, M, {
354
+ f.cacheDuration && (D = f.cacheDuration), b.info(`set preload component to cache(${D}s): ${h}`), ee.set(h, M, {
349
355
  ttl: D * 1e3
350
356
  });
351
357
  }
352
358
  return M;
353
359
  } catch (h) {
354
- return w.error("get preload component error", { instanceId: f.id, componentId: f.componentId }, { error: h }), null;
360
+ return b.error("get preload component error", { instanceId: f.id, componentId: f.componentId }, { error: h }), null;
355
361
  }
356
362
  })
357
363
  )).filter((f) => !!f), c = Object.values(
@@ -433,7 +439,7 @@ async function et({
433
439
  const p = await Ss({ ...a, req: t });
434
440
  p != null && p.props && Object.assign(c.props, p.props);
435
441
  } catch (p) {
436
- w.error("preload data at server side error", { componentId: s, name: a.component.name }, { error: p });
442
+ b.error("preload data at server side error", { componentId: s, name: a.component.name }, { error: p });
437
443
  }
438
444
  return await Promise.all(
439
445
  Object.entries(i).map(async ([p, u]) => {
@@ -479,7 +485,7 @@ function pe({ state: t, componentId: o }) {
479
485
  var e, s, n;
480
486
  return ((e = t.components[o]) == null ? void 0 : e.data) ?? ((n = (s = t.resources.components) == null ? void 0 : s[o]) == null ? void 0 : n.component);
481
487
  }
482
- function So({ state: t, name: o }) {
488
+ function To({ state: t, name: o }) {
483
489
  var s, n;
484
490
  const e = o.toLowerCase();
485
491
  return ((s = Object.values(t.components).find((r) => {
@@ -502,7 +508,7 @@ async function Ss({
502
508
  if (!n) return null;
503
509
  const r = new Promise((a) => {
504
510
  setTimeout(() => {
505
- w.error("getServerSideProps timeout"), a({});
511
+ a({});
506
512
  }, Be * 1e3);
507
513
  });
508
514
  return await Promise.race([
@@ -540,13 +546,13 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
540
546
  // NOTE: do not return logger.xxx result, it will cause memory leak
541
547
  // eslint-disable-next-line prettier/prettier
542
548
  log: (...a) => {
543
- w.info(...a);
549
+ b.info(...a);
544
550
  },
545
551
  warn: (...a) => {
546
- w.warn(...a);
552
+ b.warn(...a);
547
553
  },
548
554
  error: (...a) => {
549
- w.error(...a);
555
+ b.error(...a);
550
556
  }
551
557
  },
552
558
  getComponentMountPoint: dt,
@@ -605,7 +611,7 @@ const ws = fe(
605
611
  functionName: `get${o}SchemaWrapper`
606
612
  });
607
613
  } catch (n) {
608
- return w.error(`获取 ${o} 失败`, { componentId: e, error: n }), null;
614
+ return b.error(`获取 ${o} 失败`, { componentId: e, error: n }), null;
609
615
  }
610
616
  return null;
611
617
  },
@@ -619,11 +625,11 @@ const ws = fe(
619
625
  ttl: 1e3 * 60 * 60
620
626
  }
621
627
  }
622
- ), Es = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", Ge = "page", Te = "trigger-reload-project-resource", tt = Es, bs = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM", { uploadToMediaKit: Is } = require("@blocklet/uploader-server"), Ve = Vt("abcdefghijklmnopqrstuvwxyz0123456789", 16), Ce = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, te = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Je = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Os = 1e4, Ts = 3e4, ne = 0, be = 1, vs = 0, As = 1, ve = y, re = b(process.env.BLOCKLET_DATA_DIR, "site-state"), wo = ["production", "draft"], Eo = ["production"];
628
+ ), Es = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", Ge = "page", Te = "trigger-reload-project-resource", tt = Es, bs = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM", { uploadToMediaKit: Is } = require("@blocklet/uploader-server"), Ve = Vt("abcdefghijklmnopqrstuvwxyz0123456789", 16), Pe = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, te = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Je = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Os = 1e4, Ts = 3e4, ne = 0, be = 1, vs = 0, As = 1, ve = y, re = E(process.env.BLOCKLET_DATA_DIR, "site-state"), vo = ["production", "draft"], Ao = ["production"];
623
629
  function st(t) {
624
630
  return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
625
631
  }
626
- function Ps() {
632
+ function Cs() {
627
633
  var e;
628
634
  const t = ve.env.languages.map((s) => ({ locale: s.code, name: s.name })), o = (e = t[0]) == null ? void 0 : e.locale;
629
635
  return {
@@ -638,11 +644,11 @@ function Ps() {
638
644
  const F = class F extends z.Doc {
639
645
  constructor(e) {
640
646
  super();
641
- C(this, "states", {});
642
- C(this, "syncedStore");
643
- C(this, "conns", /* @__PURE__ */ new Map());
644
- C(this, "awareness");
645
- C(this, "awarenessChangeHandler", ({ added: e, updated: s, removed: n }, r) => {
647
+ P(this, "states", {});
648
+ P(this, "syncedStore");
649
+ P(this, "conns", /* @__PURE__ */ new Map());
650
+ P(this, "awareness");
651
+ P(this, "awarenessChangeHandler", ({ added: e, updated: s, removed: n }, r) => {
646
652
  const l = e.concat(s, n);
647
653
  if (r !== null) {
648
654
  const c = this.conns.get(r);
@@ -657,13 +663,13 @@ const F = class F extends z.Doc {
657
663
  const i = x.toUint8Array(a);
658
664
  this.conns.forEach((c, p) => this.send(p, i));
659
665
  });
660
- C(this, "updateHandler", (e) => {
666
+ P(this, "updateHandler", (e) => {
661
667
  const s = x.createEncoder();
662
668
  x.writeVarUint(s, ne), Xt(s, e);
663
669
  const n = x.toUint8Array(s);
664
670
  this.conns.forEach((r, l) => this.send(l, n));
665
671
  });
666
- C(this, "ensureDataStructure", () => {
672
+ P(this, "ensureDataStructure", () => {
667
673
  var l;
668
674
  const { supportedLocales: e, pages: s, pageIds: n, config: r } = this.syncedStore;
669
675
  {
@@ -684,7 +690,7 @@ const F = class F extends z.Doc {
684
690
  }
685
691
  }
686
692
  });
687
- C(this, "send", (e, s) => {
693
+ P(this, "send", (e, s) => {
688
694
  e.readyState !== vs && e.readyState !== As && this.closeConn(e);
689
695
  try {
690
696
  e.send(s, (n) => {
@@ -694,27 +700,27 @@ const F = class F extends z.Doc {
694
700
  this.closeConn(e);
695
701
  }
696
702
  });
697
- C(this, "closeConn", (e) => {
703
+ P(this, "closeConn", (e) => {
698
704
  if (e.removeAllListeners(), this.conns.has(e)) {
699
705
  const s = this.conns.get(e);
700
706
  this.conns.delete(e), s && qt(this.awareness, Array.from(s), null);
701
707
  }
702
708
  e.close();
703
709
  });
704
- C(this, "autoSave", Qe(() => {
710
+ P(this, "autoSave", Qe(() => {
705
711
  B(R(this.draftYjsFilePath), { recursive: !0 }), le(this.draftYjsFilePath, z.encodeStateAsUpdate(this));
706
712
  }, Os));
707
- C(this, "save", ({ flush: e = !1 } = {}) => {
713
+ P(this, "save", ({ flush: e = !1 } = {}) => {
708
714
  this.autoSave(), e && this.autoSave.flush();
709
715
  });
710
- C(this, "publish", async ({ mode: e, pages: s }) => {
716
+ P(this, "publish", async ({ mode: e, pages: s }) => {
711
717
  const n = await this.getState("draft"), r = await this.getState("production");
712
718
  await ze(n, r, { pages: s, pageMergeMode: "replace", deletePages: !0, publishMode: e }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime();
713
719
  for (const l of s || Object.keys(this.syncedStore.pages))
714
720
  this.syncedStore.pages[l] && (this.syncedStore.pages[l].publishedAt = (/* @__PURE__ */ new Date()).toISOString());
715
721
  await this.setState(e, r);
716
722
  });
717
- C(this, "mergeState", async (e, s) => {
723
+ P(this, "mergeState", async (e, s) => {
718
724
  var a, i, c;
719
725
  const n = JSON.parse(JSON.stringify(s));
720
726
  (a = e.config).fontFamily ?? (a.fontFamily = {});
@@ -730,7 +736,7 @@ const F = class F extends z.Doc {
730
736
  });
731
737
  });
732
738
  });
733
- C(this, "addConnection", (e) => {
739
+ P(this, "addConnection", (e) => {
734
740
  if (this.conns.has(e))
735
741
  return;
736
742
  e.binaryType = "arraybuffer", this.conns.set(e, /* @__PURE__ */ new Set()), e.on("message", (r) => this.messageListener(e, new Uint8Array(r)));
@@ -762,7 +768,7 @@ const F = class F extends z.Doc {
762
768
  }
763
769
  }
764
770
  });
765
- C(this, "messageListener", (e, s) => {
771
+ P(this, "messageListener", (e, s) => {
766
772
  try {
767
773
  const n = x.createEncoder(), r = Ee.createDecoder(s), l = Ee.readVarUint(r);
768
774
  switch (l) {
@@ -774,10 +780,10 @@ const F = class F extends z.Doc {
774
780
  break;
775
781
  }
776
782
  default:
777
- w.warn(`Unsupported messageType ${l}`);
783
+ b.warn(`Unsupported messageType ${l}`);
778
784
  }
779
785
  } catch (n) {
780
- w.error(n);
786
+ b.error(n);
781
787
  }
782
788
  this.save();
783
789
  });
@@ -793,10 +799,10 @@ const F = class F extends z.Doc {
793
799
  if (!e)
794
800
  throw new Error("Should provide project context");
795
801
  try {
796
- const s = b(re, e), n = b(re, `@del-${e}`);
802
+ const s = E(re, e), n = E(re, `@del-${e}`);
797
803
  Ue(s, n);
798
804
  } catch (s) {
799
- w.error("Failed to safe delete project state dir:", s);
805
+ b.error("Failed to safe delete project state dir:", s);
800
806
  }
801
807
  }
802
808
  static get projectIds() {
@@ -814,7 +820,7 @@ const F = class F extends z.Doc {
814
820
  throw new Error("Should provide project context");
815
821
  let s = this.sharedInstances.get(e);
816
822
  return s || (s = new F({
817
- path: b(re, e)
823
+ path: E(re, e)
818
824
  }), this.sharedInstances.set(e, s), s);
819
825
  }
820
826
  destroy() {
@@ -841,13 +847,13 @@ const F = class F extends z.Doc {
841
847
  });
842
848
  }
843
849
  get draftYjsFilePath() {
844
- return b(this.options.path, "draft.yjs");
850
+ return E(this.options.path, "draft.yjs");
845
851
  }
846
852
  async getState(e) {
847
853
  var s, n, r, l;
848
854
  if (e === "draft")
849
855
  return JSON.parse(JSON.stringify(this.syncedStore));
850
- if (!this.states[e] && (this.states[e] = await rt(this.getPublishDir(e), { includeResources: !0 }) ?? Ps(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
856
+ if (!this.states[e] && (this.states[e] = await rt(this.getPublishDir(e), { includeResources: !0 }) ?? Cs(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
851
857
  (r = this.states[e]).config ?? (r.config = {});
852
858
  const a = ve.env.languages.map((i) => ({ locale: i.code, name: i.name }));
853
859
  this.states[e].config.defaultLocale = (l = a[0]) == null ? void 0 : l.locale;
@@ -856,7 +862,7 @@ const F = class F extends z.Doc {
856
862
  ...this.states[e],
857
863
  resources: await De().then(async (a) => {
858
864
  var u, d, f, h;
859
- const { pages: i, components: c } = Ft(a, "pages", "components");
865
+ const { pages: i, components: c } = Bt(a, "pages", "components");
860
866
  let p = c;
861
867
  if ((d = (u = this.states[e]) == null ? void 0 : u.resources) != null && d.components)
862
868
  p = {
@@ -882,14 +888,14 @@ const F = class F extends z.Doc {
882
888
  B(R(r), { recursive: !0 }), qe(r, { force: !0, recursive: !0 }), Ue(n, r), this.states[e] = s;
883
889
  }
884
890
  getPublishDir(e) {
885
- return b(this.options.path, e);
891
+ return E(this.options.path, e);
886
892
  }
887
893
  static async pageUrlMap(e) {
888
894
  const { projectIds: s } = this, n = {};
889
895
  for (const r of s) {
890
896
  const l = await Y.findByPk(r);
891
897
  if (!l) continue;
892
- const a = await F.shared(r).getState(e), i = Bt(
898
+ const a = await F.shared(r).getState(e), i = Gt(
893
899
  y.env.languages.map((c) => c.code),
894
900
  a.supportedLocales.map((c) => c.locale)
895
901
  );
@@ -943,8 +949,8 @@ const F = class F extends z.Doc {
943
949
  return e;
944
950
  }
945
951
  };
946
- C(F, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
947
- C(F, "sharedInstances", new Ae({
952
+ P(F, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
953
+ P(F, "sharedInstances", new Ae({
948
954
  max: 100,
949
955
  // Maximum number of instances to store
950
956
  ttl: F.INSTANCE_TTL,
@@ -954,7 +960,7 @@ C(F, "sharedInstances", new Ae({
954
960
  }));
955
961
  let ue = F;
956
962
  function ot() {
957
- return Dt(b(y.env.dataDir, "tmp-"));
963
+ return Dt(E(y.env.dataDir, "tmp-"));
958
964
  }
959
965
  function de(t, o, e = []) {
960
966
  return Array.isArray(t) ? t.flatMap((s, n) => de(s, o, [...e, n])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([s, n]) => de(n, o, [...e, s])) : o(t) ? [e] : [];
@@ -962,7 +968,7 @@ function de(t, o, e = []) {
962
968
  function U(t) {
963
969
  return t.filter((o) => o != null);
964
970
  }
965
- async function Cs(t, o, e) {
971
+ async function Ps(t, o, e) {
966
972
  if (!t || !V(t) || !ie(t).isFile())
967
973
  return null;
968
974
  let s = e[t];
@@ -975,12 +981,12 @@ async function Cs(t, o, e) {
975
981
  })) == null ? void 0 : n.data;
976
982
  return r == null ? void 0 : r.filename;
977
983
  } catch (r) {
978
- return w.error(`Failed to upload asset ${t}:`, r), null;
984
+ return b.error(`Failed to upload asset ${t}:`, r), null;
979
985
  }
980
986
  })(), e[t] = s), s;
981
987
  }
982
988
  const xs = async (t, o) => {
983
- const e = q(t), s = await Ct({
989
+ const e = q(t), s = await Pt({
984
990
  name: tt,
985
991
  path: G("/uploads", e),
986
992
  responseType: "stream",
@@ -995,24 +1001,24 @@ const xs = async (t, o) => {
995
1001
  await Promise.all(
996
1002
  t.map(async (e) => {
997
1003
  try {
998
- await xs(e, b(o, q(e)));
1004
+ await xs(e, E(o, q(e)));
999
1005
  } catch (s) {
1000
- w.error(`Failed to export assets: ${e}, ${s}`);
1006
+ b.error(`Failed to export assets: ${e}, ${s}`);
1001
1007
  }
1002
1008
  })
1003
1009
  );
1004
1010
  };
1005
1011
  function nt(t) {
1006
- return Ce.test(t) ? [t] : te.test(t) ? (Je.lastIndex = 0, Array.from(t.matchAll(Je)).map((e) => e[1]).filter((e) => !!e)) : [];
1012
+ return Pe.test(t) ? [t] : te.test(t) ? (Je.lastIndex = 0, Array.from(t.matchAll(Je)).map((e) => e[1]).filter((e) => !!e)) : [];
1007
1013
  }
1008
1014
  async function Ie(t, o, e) {
1009
- const { getFilename: s, exportAssets: n } = e, r = b(o, s(t));
1015
+ const { getFilename: s, exportAssets: n } = e, r = E(o, s(t));
1010
1016
  if (B(R(r), { recursive: !0 }), le(r, Z.stringify(t)), n) {
1011
1017
  const a = de(
1012
1018
  t,
1013
- (i) => typeof i == "string" && (Ce.test(i) || te.test(i))
1019
+ (i) => typeof i == "string" && (Pe.test(i) || te.test(i))
1014
1020
  ).map((i) => {
1015
- const c = Pe(t, i);
1021
+ const c = Ce(t, i);
1016
1022
  return nt(c);
1017
1023
  }).flat().filter(Boolean);
1018
1024
  await js(a, R(r));
@@ -1026,22 +1032,22 @@ async function Ke(t, o, e) {
1026
1032
  var a;
1027
1033
  const s = de(
1028
1034
  t,
1029
- (i) => typeof i == "string" && (Ce.test(i) || te.test(i))
1035
+ (i) => typeof i == "string" && (Pe.test(i) || te.test(i))
1030
1036
  ), n = Jt(2), r = s.map(
1031
1037
  (i) => n(async () => {
1032
1038
  try {
1033
- const c = Pe(t, i), p = nt(c);
1039
+ const c = Ce(t, i), p = nt(c);
1034
1040
  for (const u of p) {
1035
1041
  const d = q(u), f = e.getFilePath(u, i), h = f ? `${f}:${d}` : d, A = He.get(h);
1036
1042
  if (A) {
1037
1043
  te.test(c) || Me(t, i, A);
1038
1044
  return;
1039
1045
  }
1040
- const j = await Cs(f, d, o);
1046
+ const j = await Ps(f, d, o);
1041
1047
  j && (te.test(c) || Me(t, i, j), He.set(h, j));
1042
1048
  }
1043
1049
  } catch (c) {
1044
- w.error(`Failed to process upload for path ${i.join(".")}:`, c.message || c.reason);
1050
+ b.error(`Failed to process upload for path ${i.join(".")}:`, c.message || c.reason);
1045
1051
  }
1046
1052
  })
1047
1053
  ), l = await Promise.allSettled(r);
@@ -1054,7 +1060,7 @@ async function ks(t, {
1054
1060
  rawConfig: n,
1055
1061
  includeResources: r = !1
1056
1062
  } = {}) {
1057
- var M, D, g, S, E, I, J, O, N, H, oe, Q;
1063
+ var M, D, g, S, w, I, J, O, N, H, oe, Q;
1058
1064
  const l = e === "all" ? t.pageIds : e, a = gt({
1059
1065
  state: t,
1060
1066
  pageIds: l,
@@ -1100,9 +1106,9 @@ async function ks(t, {
1100
1106
  };
1101
1107
  })
1102
1108
  )
1103
- ), u = ot(), d = b(u, "pages");
1109
+ ), u = ot(), d = E(u, "pages");
1104
1110
  B(d, { recursive: !0 });
1105
- const f = b(u, "components");
1111
+ const f = E(u, "components");
1106
1112
  B(f, { recursive: !0 });
1107
1113
  for (const { locale: m, slug: T, page: v } of p)
1108
1114
  await Ie(v, d, {
@@ -1116,7 +1122,7 @@ async function ks(t, {
1116
1122
  exportAssets: o
1117
1123
  });
1118
1124
  }
1119
- const h = b(u, ".blocklet/pages/pages.config.yml");
1125
+ const h = E(u, ".blocklet/pages/pages.config.yml");
1120
1126
  B(R(h), { recursive: !0 });
1121
1127
  const A = {
1122
1128
  pages: U(
@@ -1152,20 +1158,20 @@ async function ks(t, {
1152
1158
  config: t.config
1153
1159
  };
1154
1160
  le(h, Z.stringify(A));
1155
- const j = b(u, "config.source.json");
1161
+ const j = E(u, "config.source.json");
1156
1162
  if (n && le(j, JSON.stringify(n)), r) {
1157
- const m = b(u, "resources"), T = b(m, "components");
1163
+ const m = E(u, "resources"), T = E(m, "components");
1158
1164
  B(T, { recursive: !0 });
1159
1165
  for (const _ of Object.keys(((g = t == null ? void 0 : t.resources) == null ? void 0 : g.components) ?? {}).filter(
1160
1166
  (L) => a.includes(L)
1161
1167
  )) {
1162
- const L = (I = (E = (S = t.resources) == null ? void 0 : S.components) == null ? void 0 : E[_]) == null ? void 0 : I.component;
1168
+ const L = (I = (w = (S = t.resources) == null ? void 0 : S.components) == null ? void 0 : w[_]) == null ? void 0 : I.component;
1163
1169
  L && await Ie(L, T, {
1164
1170
  getFilename: (K) => `${K.name || "unnamed"}.${K.id}.yml`,
1165
1171
  exportAssets: o
1166
1172
  });
1167
1173
  }
1168
- const v = b(u, "chunks");
1174
+ const v = E(u, "chunks");
1169
1175
  B(v, { recursive: !0 });
1170
1176
  const { chunks: $ } = await De();
1171
1177
  for (const _ of Object.keys(((J = t == null ? void 0 : t.resources) == null ? void 0 : J.components) ?? {}).filter(
@@ -1176,11 +1182,11 @@ async function ks(t, {
1176
1182
  const K = ((Q = L.renderer) == null ? void 0 : Q.chunks) ?? [];
1177
1183
  if ((K == null ? void 0 : K.length) > 0)
1178
1184
  for (const ye of K) {
1179
- const Ne = b(v, ye), Se = $ == null ? void 0 : $[ye];
1185
+ const Ne = E(v, ye), Se = $ == null ? void 0 : $[ye];
1180
1186
  try {
1181
1187
  Se && V(Se) && !V(Ne) && Nt(Se, Ne);
1182
1188
  } catch (lt) {
1183
- w.error(`copy chunk ${ye} error`, lt.message);
1189
+ b.error(`copy chunk ${ye} error`, lt.message);
1184
1190
  }
1185
1191
  }
1186
1192
  }
@@ -1195,18 +1201,18 @@ async function rt(t, { importAssets: o, includeResources: e } = {}) {
1195
1201
  let s, n = !1;
1196
1202
  try {
1197
1203
  ie(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s = ot(), await zt({ file: t, C: s }));
1198
- const i = Oe("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), c = i && b(R(i), "../../pages"), p = i && b(R(i), "../../components"), u = i && b(R(i), "../../chunks");
1204
+ const i = Oe("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), c = i && E(R(i), "../../pages"), p = i && E(R(i), "../../components"), u = i && E(R(i), "../../chunks");
1199
1205
  if (!i)
1200
1206
  return null;
1201
- const d = Z.parse(X(i).toString()), f = (g, S, E) => {
1202
- let I = b(g, `${S}${E ? `.${E}` : ""}.yml`);
1203
- return (!V(I) || !ie(I).isFile()) && (I = b(g, S, `index${E ? `.${E}` : ""}.yml`), !V(I) || !ie(I)) ? null : Z.parse(X(I).toString());
1207
+ const d = Z.parse(X(i).toString()), f = (g, S, w) => {
1208
+ let I = E(g, `${S}${w ? `.${w}` : ""}.yml`);
1209
+ return (!V(I) || !ie(I).isFile()) && (I = E(g, S, `index${w ? `.${w}` : ""}.yml`), !V(I) || !ie(I)) ? null : Z.parse(X(I).toString());
1204
1210
  }, h = (g, S) => {
1205
1211
  try {
1206
- const E = Oe(`*.${S}.yml`, { cwd: g, absolute: !0 })[0];
1207
- return E ? Z.parse(X(E).toString()) : null;
1208
- } catch (E) {
1209
- w.error("parse component error", E);
1212
+ const w = Oe(`*.${S}.yml`, { cwd: g, absolute: !0 })[0];
1213
+ return w ? Z.parse(X(w).toString()) : null;
1214
+ } catch (w) {
1215
+ b.error("parse component error", w);
1210
1216
  }
1211
1217
  return null;
1212
1218
  }, A = U(
@@ -1220,10 +1226,10 @@ async function rt(t, { importAssets: o, includeResources: e } = {}) {
1220
1226
  const H = c ? f(c, g, O) : void 0;
1221
1227
  return H && { locale: O, page: H };
1222
1228
  })
1223
- ), E = (J = S[0]) == null ? void 0 : J.page;
1224
- if (!E)
1229
+ ), w = (J = S[0]) == null ? void 0 : J.page;
1230
+ if (!w)
1225
1231
  return null;
1226
- const I = E.sections.map((O) => {
1232
+ const I = w.sections.map((O) => {
1227
1233
  const N = O.id || Ve();
1228
1234
  return {
1229
1235
  id: N,
@@ -1245,12 +1251,12 @@ async function rt(t, { importAssets: o, includeResources: e } = {}) {
1245
1251
  };
1246
1252
  });
1247
1253
  return {
1248
- id: E.id || Ve(),
1249
- createdAt: E.createdAt,
1250
- updatedAt: E.updatedAt,
1251
- publishedAt: E.publishedAt,
1252
- isPublic: E.isPublic ?? !0,
1253
- isTemplate: E.isTemplate ?? !1,
1254
+ id: w.id || Ve(),
1255
+ createdAt: w.createdAt,
1256
+ updatedAt: w.updatedAt,
1257
+ publishedAt: w.publishedAt,
1258
+ isPublic: w.isPublic ?? !0,
1259
+ isTemplate: w.isTemplate ?? !1,
1254
1260
  slug: g,
1255
1261
  sections: Object.fromEntries(I.map((O) => [O.id, O])),
1256
1262
  sectionIds: I.map((O) => O.id),
@@ -1260,25 +1266,25 @@ async function rt(t, { importAssets: o, includeResources: e } = {}) {
1260
1266
  ), j = p ? U(((r = d.components) == null ? void 0 : r.map(({ id: g }) => h(p, g))) ?? []) : [];
1261
1267
  if (o) {
1262
1268
  const g = (...S) => {
1263
- w.info(`[${n ? q(t) : q(b(t, "../../../../"))}] importAssets:`, ...S);
1269
+ b.info(`[${n ? q(t) : q(E(t, "../../../../"))}] importAssets:`, ...S);
1264
1270
  };
1265
1271
  try {
1266
1272
  g("wait image-bin api ready"), await Yt({
1267
- resources: [`${Pt(ns)}/api/sdk/uploads`],
1273
+ resources: [`${Ct(ns)}/api/sdk/uploads`],
1268
1274
  validateStatus: (I) => I >= 200 && I <= 500
1269
1275
  }), g("image-bin api is ready");
1270
- const S = {}, E = {};
1276
+ const S = {}, w = {};
1271
1277
  g("start to upload assets"), await Promise.allSettled([
1272
1278
  Ke(j, S, {
1273
- getFilePath: (I) => p && b(p, I),
1279
+ getFilePath: (I) => p && E(p, I),
1274
1280
  onFinish: (I) => {
1275
1281
  g(`upload ${I.length} component assets`);
1276
1282
  }
1277
1283
  }),
1278
- Ke(A, E, {
1284
+ Ke(A, w, {
1279
1285
  getFilePath: (I, J) => {
1280
- const O = Pe(A, J.slice(0, 1));
1281
- return c && b(c, R(O.slug), I);
1286
+ const O = Ce(A, J.slice(0, 1));
1287
+ return c && E(c, R(O.slug), I);
1282
1288
  },
1283
1289
  onFinish: (I) => {
1284
1290
  g(`upload ${I.length} page assets`);
@@ -1291,18 +1297,18 @@ async function rt(t, { importAssets: o, includeResources: e } = {}) {
1291
1297
  }
1292
1298
  const M = {};
1293
1299
  if (e) {
1294
- const g = i && b(R(i), "../../resources/components"), S = U(
1295
- ((a = (l = d.resources) == null ? void 0 : l.components) == null ? void 0 : a.map(({ id: E }) => h(g, E))) ?? []
1300
+ const g = i && E(R(i), "../../resources/components"), S = U(
1301
+ ((a = (l = d.resources) == null ? void 0 : l.components) == null ? void 0 : a.map(({ id: w }) => h(g, w))) ?? []
1296
1302
  );
1297
1303
  S.length > 0 && (M.components = Object.fromEntries(
1298
- S.map((E, I) => [E.id, { index: I, component: E }])
1304
+ S.map((w, I) => [w.id, { index: I, component: w }])
1299
1305
  ));
1300
1306
  }
1301
1307
  const D = {};
1302
1308
  if (u && V(u)) {
1303
1309
  const g = kt(u);
1304
1310
  for (const S of g)
1305
- D[S] = b(u, S);
1311
+ D[S] = E(u, S);
1306
1312
  }
1307
1313
  return {
1308
1314
  supportedLocales: d.supportedLocales,
@@ -1326,7 +1332,7 @@ async function ze(t, o, {
1326
1332
  try {
1327
1333
  r && ms(r);
1328
1334
  } catch (p) {
1329
- w.error("clear preload page cache error", { error: p });
1335
+ b.error("clear preload page cache error", { error: p });
1330
1336
  }
1331
1337
  const { pageIds: l, pages: a, supportedLocales: i } = t;
1332
1338
  for (const p of e ?? l) {
@@ -1349,7 +1355,7 @@ async function ze(t, o, {
1349
1355
  if (n && !e)
1350
1356
  for (const p of o.pageIds)
1351
1357
  t.pageIds.includes(p) || delete o.pages[p], o.pageIds = [...o.pageIds].filter((u) => t.pageIds.includes(u));
1352
- if (o.supportedLocales.splice(0, o.supportedLocales.length), o.supportedLocales.push(...Gt(i)), n)
1358
+ if (o.supportedLocales.splice(0, o.supportedLocales.length), o.supportedLocales.push(...$t(i)), n)
1353
1359
  for (const p of Object.keys(o.components))
1354
1360
  delete o.components[p];
1355
1361
  let c = JSON.parse(JSON.stringify(t.components));
@@ -1371,7 +1377,7 @@ async function ze(t, o, {
1371
1377
  const at = fe(
1372
1378
  async (t) => {
1373
1379
  var o;
1374
- if (!$t(t == null ? void 0 : t.properties))
1380
+ if (!Ft(t == null ? void 0 : t.properties))
1375
1381
  return t;
1376
1382
  if (((o = t == null ? void 0 : t.renderer) == null ? void 0 : o.type) === "react-component") {
1377
1383
  const { script: e } = (t == null ? void 0 : t.renderer) || {};
@@ -1385,7 +1391,7 @@ const at = fe(
1385
1391
  });
1386
1392
  }));
1387
1393
  } catch (s) {
1388
- w.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: s });
1394
+ b.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: s });
1389
1395
  }
1390
1396
  }
1391
1397
  return t;
@@ -1454,7 +1460,7 @@ function Ds(t) {
1454
1460
  const o = Qe(
1455
1461
  async () => {
1456
1462
  await it().catch((e) => {
1457
- w.error("load resource states error", { error: e });
1463
+ b.error("load resource states error", { error: e });
1458
1464
  }), await (t == null ? void 0 : t({
1459
1465
  states: W,
1460
1466
  pages: xe,
@@ -1475,10 +1481,10 @@ var Ye;
1475
1481
  (Ye = ce[ct]) == null || Ye.call(ce);
1476
1482
  ce[ct] = Ds(async ({ pages: t, components: o }) => {
1477
1483
  const { projectIds: e } = ue;
1478
- w.info(`start update resource states projects(${e.length})`, e), await Promise.race([
1484
+ b.info(`start update resource states projects(${e.length})`, e), await Promise.race([
1479
1485
  new Promise((s) => {
1480
1486
  setTimeout(() => {
1481
- w.error("update resource states timeout"), s({});
1487
+ s({});
1482
1488
  }, 30 * 1e3);
1483
1489
  }),
1484
1490
  Promise.all(
@@ -1494,18 +1500,18 @@ ce[ct] = Ds(async ({ pages: t, components: o }) => {
1494
1500
  );
1495
1501
  n.syncedStore.resources.components = i;
1496
1502
  }
1497
- w.info(`update [${s}] resource states:`, {
1503
+ b.info(`update [${s}] resource states:`, {
1498
1504
  pages: Object.keys(n.syncedStore.resources.pages || {}).length,
1499
1505
  components: Object.keys(n.syncedStore.resources.components || {}).length
1500
1506
  });
1501
1507
  })
1502
1508
  )
1503
1509
  ]).catch((s) => {
1504
- w.error("update resource states failed:", s);
1510
+ b.error("update resource states failed:", s);
1505
1511
  });
1506
1512
  });
1507
- async function bo() {
1508
- w.info("trigger reload all project resource"), y.events.emit(Te);
1513
+ async function Co() {
1514
+ b.info("trigger reload all project resource"), y.events.emit(Te);
1509
1515
  }
1510
1516
  async function De({
1511
1517
  ensureLoaded: t = !0
@@ -1519,25 +1525,25 @@ export {
1519
1525
  Ge as R,
1520
1526
  ue as S,
1521
1527
  De as a,
1522
- yo as b,
1528
+ Oo as b,
1523
1529
  us as c,
1524
1530
  ds as d,
1525
1531
  ms as e,
1526
1532
  fs as f,
1527
- ho as g,
1533
+ Io as g,
1528
1534
  gs as h,
1529
- go as i,
1535
+ bo as i,
1530
1536
  pe as j,
1531
- So as k,
1532
- w as l,
1537
+ To as k,
1538
+ b as l,
1533
1539
  ws as m,
1534
1540
  Ve as n,
1535
1541
  re as o,
1536
- wo as p,
1537
- Eo as q,
1542
+ vo as p,
1543
+ Ao as q,
1538
1544
  rt as r,
1539
1545
  ze as s,
1540
1546
  ks as t,
1541
1547
  Ds as u,
1542
- bo as v
1548
+ Co as v
1543
1549
  };