@blocklet/pages-kit-inner-components 0.0.7 → 0.0.9

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,40 +1,40 @@
1
- import { l as P, c as Ne, g as Re } from "./components-DsmhMXRy.mjs";
2
- import { memoize as Ue } from "@blocklet/quickjs";
3
- import { getComponentWebEndpoint as Fe, getResources as _e, call as Me } from "@blocklet/sdk/lib/component";
4
- import f from "@blocklet/sdk/lib/config";
5
- import { reactive as $e } from "@reactivedata/reactive";
6
- import { syncedStore as Be, getYjsValue as se } from "@syncedstore/core";
7
- import { mkdirSync as F, writeFileSync as X, existsSync as x, readFileSync as Y, renameSync as ue, rmSync as be, lstatSync as z, mkdtempSync as xe, createWriteStream as Ve } from "fs";
1
+ import { l as T, c as Re, g as Ue } from "./components-Bo3_pN-Y.mjs";
2
+ import { memoize as Fe } from "@blocklet/quickjs";
3
+ import { getComponentWebEndpoint as _e, getResources as Me, call as $e } from "@blocklet/sdk/lib/component";
4
+ import m from "@blocklet/sdk/lib/config";
5
+ import { reactive as Be } from "@reactivedata/reactive";
6
+ import { syncedStore as xe, getYjsValue as se } from "@syncedstore/core";
7
+ import { mkdirSync as F, writeFileSync as X, existsSync as x, readFileSync as K, renameSync as ue, rmSync as be, lstatSync as Y, mkdtempSync as Ve, createWriteStream as Ge } from "fs";
8
8
  import { globSync as ae } from "glob";
9
9
  import * as ne from "lib0/decoding";
10
10
  import * as I from "lib0/encoding";
11
- import { debounce as ve, pick as Ge, union as Je, get as ce, cloneDeep as qe, isEmpty as He, set as fe } from "lodash";
11
+ import { debounce as ve, pick as Je, union as qe, get as ce, cloneDeep as ze, isEmpty as He, set as fe } from "lodash";
12
12
  import { LRUCache as Ie } from "lru-cache";
13
13
  import { customAlphabet as Ke } from "nanoid";
14
14
  import Ye from "p-limit";
15
- import ze, { join as E, dirname as L, basename as _ } from "path";
16
- import { pipeline as We } from "stream/promises";
17
- import { x as Xe } from "tar";
15
+ import We, { join as E, dirname as L, basename as $ } from "path";
16
+ import { pipeline as Xe } from "stream/promises";
17
+ import { x as Qe } from "tar";
18
18
  import { joinURL as B } from "ufo";
19
- import Qe from "wait-on";
20
- import { encodeAwarenessUpdate as me, removeAwarenessStates as Ze, applyAwarenessUpdate as et, Awareness as tt } from "y-protocols/awareness";
21
- import { writeUpdate as st, writeSyncStep1 as nt, readSyncMessage as rt } from "y-protocols/sync";
19
+ import Ze from "wait-on";
20
+ import { encodeAwarenessUpdate as me, removeAwarenessStates as et, applyAwarenessUpdate as tt, Awareness as st } from "y-protocols/awareness";
21
+ import { writeUpdate as nt, writeSyncStep1 as rt, readSyncMessage as ot } from "y-protocols/sync";
22
22
  import * as V from "yaml";
23
- import * as $ from "yjs";
24
- import ot from "lodash/isNil";
25
- import { DataTypes as v, Sequelize as at, Model as Oe, Op as it } from "sequelize";
23
+ import * as M from "yjs";
24
+ import at from "lodash/isNil";
25
+ import { DataTypes as v, Sequelize as it, Model as Oe, Op as ct } from "sequelize";
26
26
  import "sqlite3";
27
- f.env.mode;
28
- const ct = "image-bin";
29
- f.env.INIT_TEMPLATE_PATH;
30
- const lt = process.env.DATABASE_URL || ze.join(f.env.dataDir, "db/pages-kit.db"), ge = f, zt = () => f.env.tenantMode === "multiple", Wt = () => {
27
+ m.env.mode;
28
+ const lt = "image-bin";
29
+ m.env.INIT_TEMPLATE_PATH;
30
+ const pt = process.env.DATABASE_URL || We.join(m.env.dataDir, "db/pages-kit.db"), ge = m, Wt = () => m.env.tenantMode === "multiple", Xt = () => {
31
31
  var t;
32
- return (ot(ge.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = ge.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
33
- }, pt = v.sqlite.DATE.parse;
34
- v.sqlite.DATE.parse = (t, s) => typeof t == "number" ? new Date(t) : pt(t, s);
35
- const q = new at({
32
+ return (at(ge.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = ge.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
33
+ }, dt = v.sqlite.DATE.parse;
34
+ v.sqlite.DATE.parse = (t, s) => typeof t == "number" ? new Date(t) : dt(t, s);
35
+ const q = new it({
36
36
  dialect: "sqlite",
37
- storage: lt,
37
+ storage: pt,
38
38
  benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
39
39
  retry: {
40
40
  match: [/SQLITE_BUSY/],
@@ -70,16 +70,16 @@ te.init(
70
70
  },
71
71
  { sequelize: q, tableName: "ProjectComponents", timestamps: !1 }
72
72
  );
73
- class M extends Oe {
73
+ class _ extends Oe {
74
74
  static async getProjectByIdOrSlug(s) {
75
- return M.findOne({
75
+ return _.findOne({
76
76
  where: {
77
- [it.or]: [{ id: s }, { slug: s }]
77
+ [ct.or]: [{ id: s }, { slug: s }]
78
78
  }
79
79
  });
80
80
  }
81
81
  }
82
- M.init(
82
+ _.init(
83
83
  {
84
84
  id: {
85
85
  type: v.UUID,
@@ -119,12 +119,15 @@ M.init(
119
119
  },
120
120
  { sequelize: q, paranoid: !0 }
121
121
  );
122
- M.hasMany(te, {
122
+ _.hasMany(te, {
123
123
  foreignKey: "projectId",
124
124
  as: "components"
125
125
  });
126
- const dt = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", ut = "page", ie = "trigger-reload-project-resource", Te = dt, { uploadToMediaKit: ft } = require("@blocklet/uploader-server"), he = Ke("abcdefghijklmnopqrstuvwxyz0123456789", 16), le = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, G = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, ye = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, mt = 1e4, gt = 3e4, H = 0, re = 1, ht = 0, yt = 1, St = f, K = E(process.env.BLOCKLET_DATA_DIR, "site-state"), Xt = ["production", "draft"], Qt = ["production"];
127
- function wt() {
126
+ const ut = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", ft = "page", ie = "trigger-reload-project-resource", Pe = ut, { uploadToMediaKit: mt } = require("@blocklet/uploader-server"), he = Ke("abcdefghijklmnopqrstuvwxyz0123456789", 16), le = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, G = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, ye = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, gt = 1e4, ht = 3e4, z = 0, re = 1, yt = 0, St = 1, wt = m, H = E(process.env.BLOCKLET_DATA_DIR, "site-state"), Qt = ["production", "draft"], Zt = ["production"];
127
+ function Te(t) {
128
+ return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
129
+ }
130
+ function Et() {
128
131
  return {
129
132
  pageIds: [],
130
133
  pages: {},
@@ -134,49 +137,49 @@ function wt() {
134
137
  resources: {}
135
138
  };
136
139
  }
137
- const R = class R extends $.Doc {
140
+ const R = class R extends M.Doc {
138
141
  constructor(s) {
139
142
  super(), this.options = s, this.states = {}, this.conns = /* @__PURE__ */ new Map(), this.awarenessChangeHandler = ({ added: e, updated: n, removed: r }, o) => {
140
- const c = e.concat(n, r);
143
+ const l = e.concat(n, r);
141
144
  if (o !== null) {
142
- const l = this.conns.get(o);
143
- l && (e.forEach((u) => {
144
- l.add(u);
145
+ const c = this.conns.get(o);
146
+ c && (e.forEach((u) => {
147
+ c.add(u);
145
148
  }), r.forEach((u) => {
146
- l.delete(u);
149
+ c.delete(u);
147
150
  }));
148
151
  }
149
152
  const i = I.createEncoder();
150
- I.writeVarUint(i, re), I.writeVarUint8Array(i, me(this.awareness, c));
153
+ I.writeVarUint(i, re), I.writeVarUint8Array(i, me(this.awareness, l));
151
154
  const a = I.toUint8Array(i);
152
- this.conns.forEach((l, u) => this.send(u, a));
155
+ this.conns.forEach((c, u) => this.send(u, a));
153
156
  }, this.updateHandler = (e) => {
154
157
  const n = I.createEncoder();
155
- I.writeVarUint(n, H), st(n, e);
158
+ I.writeVarUint(n, z), nt(n, e);
156
159
  const r = I.toUint8Array(n);
157
- this.conns.forEach((o, c) => this.send(c, r));
160
+ this.conns.forEach((o, l) => this.send(l, r));
158
161
  }, this.ensureDataStructure = () => {
159
- var c;
162
+ var l;
160
163
  const { supportedLocales: e, pages: n, pageIds: r, config: o } = this.syncedStore;
161
164
  {
162
165
  const i = new Set(Object.keys(n));
163
166
  let a = 0;
164
167
  for (; a < r.length; ) {
165
- const l = r[a];
166
- i.has(l) ? (i.delete(l), a++) : r.splice(a, 1);
168
+ const c = r[a];
169
+ i.has(c) ? (i.delete(c), a++) : r.splice(a, 1);
167
170
  }
168
171
  }
169
- e.splice(0, e.length), e.push(...St.env.languages.map((i) => ({ locale: i.code, name: i.name }))), o.defaultLocale = (c = e[0]) == null ? void 0 : c.locale;
172
+ e.splice(0, e.length), e.push(...wt.env.languages.map((i) => ({ locale: i.code, name: i.name }))), o.defaultLocale = (l = e[0]) == null ? void 0 : l.locale;
170
173
  {
171
174
  let i = 0;
172
175
  const a = /* @__PURE__ */ new Set();
173
176
  for (; i < e.length; ) {
174
- const { locale: l } = e[i];
175
- a.has(l) ? e.splice(i, 1) : (i++, a.add(l));
177
+ const { locale: c } = e[i];
178
+ a.has(c) ? e.splice(i, 1) : (i++, a.add(c));
176
179
  }
177
180
  }
178
181
  }, this.send = (e, n) => {
179
- e.readyState !== ht && e.readyState !== yt && this.closeConn(e);
182
+ e.readyState !== yt && e.readyState !== St && this.closeConn(e);
180
183
  try {
181
184
  e.send(n, (r) => {
182
185
  r && this.closeConn(e);
@@ -187,25 +190,25 @@ const R = class R extends $.Doc {
187
190
  }, this.closeConn = (e) => {
188
191
  if (e.removeAllListeners(), this.conns.has(e)) {
189
192
  const n = this.conns.get(e);
190
- this.conns.delete(e), n && Ze(this.awareness, Array.from(n), null);
193
+ this.conns.delete(e), n && et(this.awareness, Array.from(n), null);
191
194
  }
192
195
  e.close();
193
196
  }, this.autoSave = ve(() => {
194
- F(L(this.draftYjsFilePath), { recursive: !0 }), X(this.draftYjsFilePath, $.encodeStateAsUpdate(this));
195
- }, mt), this.save = ({ flush: e = !1 } = {}) => {
197
+ F(L(this.draftYjsFilePath), { recursive: !0 }), X(this.draftYjsFilePath, M.encodeStateAsUpdate(this));
198
+ }, gt), this.save = ({ flush: e = !1 } = {}) => {
196
199
  this.autoSave(), e && this.autoSave.flush();
197
200
  }, this.publish = async ({ mode: e, pages: n }) => {
198
201
  const r = await this.getState("draft"), o = await this.getState("production");
199
202
  await Ee(r, o, { pages: n, pageMergeMode: "replace", deletePages: !0, publishMode: e }), o.config.publishedAt = (/* @__PURE__ */ new Date()).getTime();
200
- for (const c of n || Object.keys(this.syncedStore.pages))
201
- this.syncedStore.pages[c] && (this.syncedStore.pages[c].publishedAt = (/* @__PURE__ */ new Date()).toISOString());
203
+ for (const l of n || Object.keys(this.syncedStore.pages))
204
+ this.syncedStore.pages[l] && (this.syncedStore.pages[l].publishedAt = (/* @__PURE__ */ new Date()).toISOString());
202
205
  await this.setState(e, o);
203
206
  }, this.mergeState = async (e, n) => {
204
- var i, a, l;
207
+ var i, a, c;
205
208
  const r = JSON.parse(JSON.stringify(n));
206
209
  (i = e.config).fontFamily ?? (i.fontFamily = {});
207
- const o = (a = r.config) == null ? void 0 : a.fontFamily, c = (l = e.config) == null ? void 0 : l.fontFamily;
208
- e.config.fontFamily.title = (o == null ? void 0 : o.title) || (c == null ? void 0 : c.title), e.config.fontFamily.description = (o == null ? void 0 : o.description) || (c == null ? void 0 : c.description), await new Promise((u, p) => {
210
+ const o = (a = r.config) == null ? void 0 : a.fontFamily, l = (c = e.config) == null ? void 0 : c.fontFamily;
211
+ e.config.fontFamily.title = (o == null ? void 0 : o.title) || (l == null ? void 0 : l.title), e.config.fontFamily.description = (o == null ? void 0 : o.description) || (l == null ? void 0 : l.description), await new Promise((u, p) => {
209
212
  this.transact(async () => {
210
213
  try {
211
214
  const y = await Ee(e, n);
@@ -231,7 +234,7 @@ const R = class R extends $.Doc {
231
234
  this.closeConn(e), clearInterval(r);
232
235
  }
233
236
  }
234
- }, gt);
237
+ }, ht);
235
238
  e.on("close", () => {
236
239
  this.closeConn(e), clearInterval(r);
237
240
  }), e.on("pong", () => {
@@ -239,52 +242,52 @@ const R = class R extends $.Doc {
239
242
  });
240
243
  {
241
244
  const o = I.createEncoder();
242
- I.writeVarUint(o, H), nt(o, this), this.send(e, I.toUint8Array(o));
243
- const c = this.awareness.getStates();
244
- if (c.size > 0) {
245
+ I.writeVarUint(o, z), rt(o, this), this.send(e, I.toUint8Array(o));
246
+ const l = this.awareness.getStates();
247
+ if (l.size > 0) {
245
248
  const i = I.createEncoder();
246
- I.writeVarUint(i, re), I.writeVarUint8Array(i, me(this.awareness, Array.from(c.keys()))), this.send(e, I.toUint8Array(i));
249
+ I.writeVarUint(i, re), I.writeVarUint8Array(i, me(this.awareness, Array.from(l.keys()))), this.send(e, I.toUint8Array(i));
247
250
  }
248
251
  }
249
252
  }, this.messageListener = (e, n) => {
250
253
  try {
251
- const r = I.createEncoder(), o = ne.createDecoder(n), c = ne.readVarUint(o);
252
- switch (c) {
253
- case H:
254
- I.writeVarUint(r, H), rt(o, r, this, null), I.length(r) > 1 && (this.ensureDataStructure(), this.send(e, I.toUint8Array(r)));
254
+ const r = I.createEncoder(), o = ne.createDecoder(n), l = ne.readVarUint(o);
255
+ switch (l) {
256
+ case z:
257
+ I.writeVarUint(r, z), ot(o, r, this, null), I.length(r) > 1 && (this.ensureDataStructure(), this.send(e, I.toUint8Array(r)));
255
258
  break;
256
259
  case re: {
257
- et(this.awareness, ne.readVarUint8Array(o), e);
260
+ tt(this.awareness, ne.readVarUint8Array(o), e);
258
261
  break;
259
262
  }
260
263
  default:
261
- P.warn(`Unsupported messageType ${c}`);
264
+ T.warn(`Unsupported messageType ${l}`);
262
265
  }
263
266
  } catch (r) {
264
- P.error(r);
267
+ T.error(r);
265
268
  }
266
269
  this.save();
267
- }, x(this.draftYjsFilePath) && $.applyUpdate(this, Y(this.draftYjsFilePath)), this.syncedStore = $e(
268
- Be(
270
+ }, x(this.draftYjsFilePath) && M.applyUpdate(this, K(this.draftYjsFilePath)), this.syncedStore = Be(
271
+ xe(
269
272
  { pages: {}, pageIds: [], components: {}, supportedLocales: [], config: {}, resources: {} },
270
273
  this
271
274
  )
272
- ), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new tt(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
275
+ ), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new st(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
273
276
  }
274
277
  // safe delete project state dir
275
278
  static safeDeleteProjectStateDir(s) {
276
279
  if (!s)
277
280
  throw new Error("Should provide project context");
278
281
  try {
279
- const e = E(K, s), n = E(K, `@del-${s}`);
282
+ const e = E(H, s), n = E(H, `@del-${s}`);
280
283
  ue(e, n);
281
284
  } catch (e) {
282
- P.error("Failed to safe delete project state dir:", e);
285
+ T.error("Failed to safe delete project state dir:", e);
283
286
  }
284
287
  }
285
288
  static get projectIds() {
286
289
  return ae("*/", {
287
- cwd: K,
290
+ cwd: H,
288
291
  ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
289
292
  // Ignore temp directories and hidden files
290
293
  });
@@ -297,7 +300,7 @@ const R = class R extends $.Doc {
297
300
  throw new Error("Should provide project context");
298
301
  let e = this.sharedInstances.get(s);
299
302
  return e || (e = new R({
300
- path: E(K, s)
303
+ path: E(H, s)
301
304
  }), this.sharedInstances.set(s, e), e);
302
305
  }
303
306
  destroy() {
@@ -311,14 +314,14 @@ const R = class R extends $.Doc {
311
314
  };
312
315
  this.syncedStore.pages && Object.keys(this.syncedStore.pages).forEach((n) => {
313
316
  const r = se(this.syncedStore.pages[n]);
314
- r && r instanceof $.Map && s(r);
317
+ r && r instanceof M.Map && s(r);
315
318
  });
316
319
  const e = se(this.syncedStore.pages);
317
- e && e instanceof $.Map && e.observe((n) => {
320
+ e && e instanceof M.Map && e.observe((n) => {
318
321
  n.changes.keys.forEach((r, o) => {
319
322
  if (r.action === "add") {
320
- const c = se(this.syncedStore.pages[o]);
321
- c && c instanceof $.Map && s(c);
323
+ const l = se(this.syncedStore.pages[o]);
324
+ l && l instanceof M.Map && s(l);
322
325
  }
323
326
  });
324
327
  });
@@ -327,18 +330,18 @@ const R = class R extends $.Doc {
327
330
  return E(this.options.path, "draft.yjs");
328
331
  }
329
332
  async getState(s) {
330
- return s === "draft" ? JSON.parse(JSON.stringify(this.syncedStore)) : (this.states[s] || (this.states[s] = await De(this.getPublishDir(s), { includeResources: !0 }) ?? wt()), {
333
+ return s === "draft" ? JSON.parse(JSON.stringify(this.syncedStore)) : (this.states[s] || (this.states[s] = await Ce(this.getPublishDir(s), { includeResources: !0 }) ?? Et()), {
331
334
  ...this.states[s],
332
335
  resources: await Tt().then(async (e) => {
333
- var c, i, a, l;
334
- const { pages: n, components: r } = Ge(e, "pages", "components");
336
+ var l, i, a, c;
337
+ const { pages: n, components: r } = Je(e, "pages", "components");
335
338
  let o = r;
336
- if ((i = (c = this.states[s]) == null ? void 0 : c.resources) != null && i.components)
339
+ if ((i = (l = this.states[s]) == null ? void 0 : l.resources) != null && i.components)
337
340
  o = {
338
- ...(l = (a = this.states[s]) == null ? void 0 : a.resources) == null ? void 0 : l.components
341
+ ...(c = (a = this.states[s]) == null ? void 0 : a.resources) == null ? void 0 : c.components
339
342
  };
340
343
  else {
341
- const u = _(this.options.path), p = await M.findByPk(u);
344
+ const u = $(this.options.path), p = await _.findByPk(u);
342
345
  if (p != null && p.useAllResources)
343
346
  o = r;
344
347
  else {
@@ -353,7 +356,7 @@ const R = class R extends $.Doc {
353
356
  });
354
357
  }
355
358
  async setState(s, e) {
356
- const n = await vt(e, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(s);
359
+ const n = await It(e, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(s);
357
360
  F(L(r), { recursive: !0 }), be(r, { force: !0, recursive: !0 }), ue(n, r), this.states[s] = e;
358
361
  }
359
362
  getPublishDir(s) {
@@ -362,16 +365,17 @@ const R = class R extends $.Doc {
362
365
  static async pageUrlMap(s) {
363
366
  const { projectIds: e } = this, n = {};
364
367
  for (const r of e) {
365
- const o = await M.findByPk(r);
368
+ const o = await _.findByPk(r);
366
369
  if (!o) continue;
367
- const c = await R.shared(r).getState(s), i = Je(
368
- f.env.languages.map((a) => a.code),
369
- c.supportedLocales.map((a) => a.locale)
370
+ const l = await R.shared(r).getState(s), i = qe(
371
+ m.env.languages.map((a) => a.code),
372
+ l.supportedLocales.map((a) => a.locale)
370
373
  );
371
- for (const a of c.pageIds) {
372
- const l = c.pages[a];
373
- if (!l) continue;
374
- const u = l.slug, p = o.slug || r, y = {
374
+ for (const a of l.pageIds) {
375
+ const c = l.pages[a];
376
+ if (!c || s === "production" && !c.isPublic)
377
+ continue;
378
+ const u = c.slug, p = o.slug || r, y = {
375
379
  projectId: r,
376
380
  projectSlug: p,
377
381
  pageSlug: u,
@@ -379,7 +383,8 @@ const R = class R extends $.Doc {
379
383
  // default locale
380
384
  defaultLocale: i == null ? void 0 : i[0],
381
385
  locales: i,
382
- publishedAt: c.config.publishedAt
386
+ publishedAt: l.config.publishedAt,
387
+ isPublic: c.isPublic
383
388
  };
384
389
  p && (n[B("/", p, u)] = {
385
390
  ...y,
@@ -391,8 +396,8 @@ const R = class R extends $.Doc {
391
396
  mainPage: !0
392
397
  };
393
398
  for (const O of i) {
394
- const T = { ...y, locale: O };
395
- n[B("/", O, r, u)] = T, p && (n[B("/", O, p, u)] = T);
399
+ const P = { ...y, locale: O };
400
+ n[B("/", O, r, u)] = P, p && (n[B("/", O, p, u)] = P);
396
401
  }
397
402
  }
398
403
  }
@@ -408,8 +413,8 @@ R.INSTANCE_TTL = 30 * 60 * 1e3, R.sharedInstances = new Ie({
408
413
  }
409
414
  });
410
415
  let Q = R;
411
- function Pe() {
412
- return xe(E(f.env.dataDir, "tmp-"));
416
+ function je() {
417
+ return Ve(E(m.env.dataDir, "tmp-"));
413
418
  }
414
419
  function Z(t, s, e = []) {
415
420
  return Array.isArray(t) ? t.flatMap((n, r) => Z(n, s, [...e, r])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([n, r]) => Z(r, s, [...e, n])) : s(t) ? [e] : [];
@@ -417,39 +422,39 @@ function Z(t, s, e = []) {
417
422
  function k(t) {
418
423
  return t.filter((s) => s != null);
419
424
  }
420
- async function Et(t, s, e) {
421
- if (!t || !x(t) || !z(t).isFile())
425
+ async function At(t, s, e) {
426
+ if (!t || !x(t) || !Y(t).isFile())
422
427
  return null;
423
428
  let n = e[t];
424
- return n || (n = (async () => (await ft({
429
+ return n || (n = (async () => (await mt({
425
430
  filePath: t,
426
431
  fileName: s
427
432
  })).data.filename)(), e[t] = n), n;
428
433
  }
429
- const At = async (t, s) => {
430
- const e = _(t), n = await Me({
431
- name: Te,
434
+ const bt = async (t, s) => {
435
+ const e = $(t), n = await $e({
436
+ name: Pe,
432
437
  path: B("/uploads", e),
433
438
  responseType: "stream",
434
439
  method: "GET"
435
440
  });
436
441
  if (n.status >= 200 && n.status < 400) {
437
- const r = Ve(s);
438
- await We(n.data, r);
442
+ const r = Ge(s);
443
+ await Xe(n.data, r);
439
444
  } else
440
445
  throw new Error(`download asset failed ${n.status}`);
441
- }, bt = async (t, s) => {
446
+ }, vt = async (t, s) => {
442
447
  await Promise.all(
443
448
  t.map(async (e) => {
444
449
  try {
445
- await At(e, E(s, _(e)));
450
+ await bt(e, E(s, $(e)));
446
451
  } catch (n) {
447
- P.error(`Failed to export assets: ${e}, ${n}`);
452
+ T.error(`Failed to export assets: ${e}, ${n}`);
448
453
  }
449
454
  })
450
455
  );
451
456
  };
452
- function je(t) {
457
+ function De(t) {
453
458
  return le.test(t) ? [t] : G.test(t) ? (ye.lastIndex = 0, Array.from(t.matchAll(ye)).map((e) => e[1]).filter((e) => !!e)) : [];
454
459
  }
455
460
  async function oe(t, s, e) {
@@ -459,10 +464,10 @@ async function oe(t, s, e) {
459
464
  t,
460
465
  (a) => typeof a == "string" && (le.test(a) || G.test(a))
461
466
  ).map((a) => {
462
- const l = ce(t, a);
463
- return je(l);
467
+ const c = ce(t, a);
468
+ return De(c);
464
469
  }).flat().filter(Boolean);
465
- await bt(i, L(o));
470
+ await vt(i, L(o));
466
471
  }
467
472
  }
468
473
  const Se = new Ie({
@@ -477,36 +482,36 @@ async function we(t, s, e) {
477
482
  ), r = Ye(2), o = n.map(
478
483
  (a) => r(async () => {
479
484
  try {
480
- const l = ce(t, a), u = je(l);
485
+ const c = ce(t, a), u = De(c);
481
486
  for (const p of u) {
482
- const y = _(p), O = e.getFilePath(p, a), T = O ? `${O}:${y}` : y, j = Se.get(T);
487
+ const y = $(p), O = e.getFilePath(p, a), P = O ? `${O}:${y}` : y, j = Se.get(P);
483
488
  if (j) {
484
- G.test(l) || fe(t, a, j);
489
+ G.test(c) || fe(t, a, j);
485
490
  return;
486
491
  }
487
- const N = await Et(O, y, s);
488
- N && (G.test(l) || fe(t, a, N), Se.set(T, N));
492
+ const N = await At(O, y, s);
493
+ N && (G.test(c) || fe(t, a, N), Se.set(P, N));
489
494
  }
490
- } catch (l) {
491
- P.error(`Failed to process upload for path ${a.join(".")}:`, l.message || l.reason);
495
+ } catch (c) {
496
+ T.error(`Failed to process upload for path ${a.join(".")}:`, c.message || c.reason);
492
497
  }
493
498
  })
494
- ), c = await Promise.allSettled(o);
495
- (i = e.onFinish) == null || i.call(e, c);
499
+ ), l = await Promise.allSettled(o);
500
+ (i = e.onFinish) == null || i.call(e, l);
496
501
  }
497
- async function vt(t, {
502
+ async function It(t, {
498
503
  exportAssets: s,
499
504
  pageIds: e = "all",
500
505
  componentIds: n = "all",
501
506
  rawConfig: r,
502
507
  includeResources: o = !1
503
508
  } = {}) {
504
- var m, A, g, S, U, b;
505
- const c = e === "all" ? t.pageIds : e, i = It({
509
+ var f, A, h, S, U, b;
510
+ const l = e === "all" ? t.pageIds : e, i = Ot({
506
511
  state: t,
507
- pageIds: c,
512
+ pageIds: l,
508
513
  componentIds: n === "all" ? Object.keys(t.components) : n
509
- }), a = (d, h) => {
514
+ }), a = (d, g) => {
510
515
  var w;
511
516
  return {
512
517
  id: d.id,
@@ -514,66 +519,67 @@ async function vt(t, {
514
519
  component: d.component,
515
520
  config: d.config,
516
521
  visibility: d.visibility,
517
- properties: ((w = d.locales) == null ? void 0 : w[h]) ?? {}
522
+ properties: ((w = d.locales) == null ? void 0 : w[g]) ?? {}
518
523
  };
519
- }, l = (d, h) => {
524
+ }, c = (d, g) => {
520
525
  var w;
521
526
  return {
522
527
  id: d.id,
523
528
  createdAt: d.createdAt,
524
529
  updatedAt: d.updatedAt,
525
530
  publishedAt: d.publishedAt,
526
- meta: ((w = d.locales) == null ? void 0 : w[h]) ?? {},
531
+ isPublic: d.isPublic ?? !0,
532
+ meta: ((w = d.locales) == null ? void 0 : w[g]) ?? {},
527
533
  sections: k(
528
534
  d.sectionIds.map((D) => {
529
535
  const C = d.sections[D];
530
- return C && a(C, h);
536
+ return C && a(C, g);
531
537
  })
532
538
  )
533
539
  };
534
540
  }, u = k(
535
541
  t.supportedLocales.map((d) => d.locale).flatMap(
536
- (d) => c.map((h) => {
537
- const w = t.pages[h];
542
+ (d) => l.map((g) => {
543
+ const w = t.pages[g];
538
544
  return w && {
539
545
  locale: d,
540
546
  slug: w.slug,
541
- page: l(w, d)
547
+ page: c(w, d)
542
548
  };
543
549
  })
544
550
  )
545
- ), p = Pe(), y = E(p, "pages");
551
+ ), p = je(), y = E(p, "pages");
546
552
  F(y, { recursive: !0 });
547
553
  const O = E(p, "components");
548
554
  F(O, { recursive: !0 });
549
- for (const { locale: d, slug: h, page: w } of u)
555
+ for (const { locale: d, slug: g, page: w } of u)
550
556
  await oe(w, y, {
551
- getFilename: () => E(L(h), `${_(h) || "index"}.${d}.yml`),
557
+ getFilename: () => `${Te(g) || "index"}.${d}.yml`,
552
558
  exportAssets: s
553
559
  });
554
560
  for (const d of i) {
555
- const h = (m = t.components[d]) == null ? void 0 : m.data;
556
- h && await oe(h, O, {
561
+ const g = (f = t.components[d]) == null ? void 0 : f.data;
562
+ g && await oe(g, O, {
557
563
  getFilename: (w) => `${w.name || "unnamed"}.${w.id}.yml`,
558
564
  exportAssets: s
559
565
  });
560
566
  }
561
- const T = E(p, ".blocklet/pages/pages.config.yml");
562
- F(L(T), { recursive: !0 });
567
+ const P = E(p, ".blocklet/pages/pages.config.yml");
568
+ F(L(P), { recursive: !0 });
563
569
  const j = {
564
570
  pages: k(
565
- c.map((d) => {
566
- const h = t.pages[d];
567
- return h && { id: d, slug: h.slug };
571
+ l.map((d) => {
572
+ const g = t.pages[d];
573
+ return g && { id: d, slug: g.slug };
568
574
  })
569
575
  ),
570
576
  components: k(
571
577
  i.map((d) => {
572
578
  var w;
573
- const h = (w = t.components[d]) == null ? void 0 : w.data;
574
- return h && {
579
+ const g = (w = t.components[d]) == null ? void 0 : w.data;
580
+ return g && {
575
581
  id: d,
576
- name: h.name
582
+ name: g.name
577
583
  };
578
584
  })
579
585
  ),
@@ -581,10 +587,10 @@ async function vt(t, {
581
587
  resources: {
582
588
  components: k(
583
589
  Object.keys(((A = t.resources) == null ? void 0 : A.components) || {}).map((d) => {
584
- var h, w, D, C;
590
+ var g, w, D, C;
585
591
  return {
586
592
  id: d,
587
- name: (C = (D = (w = (h = t.resources) == null ? void 0 : h.components) == null ? void 0 : w[d]) == null ? void 0 : D.component) == null ? void 0 : C.name
593
+ name: (C = (D = (w = (g = t.resources) == null ? void 0 : g.components) == null ? void 0 : w[d]) == null ? void 0 : D.component) == null ? void 0 : C.name
588
594
  };
589
595
  })
590
596
  )
@@ -593,14 +599,14 @@ async function vt(t, {
593
599
  supportedLocales: t.supportedLocales,
594
600
  config: t.config
595
601
  };
596
- X(T, V.stringify(j));
602
+ X(P, V.stringify(j));
597
603
  const N = E(p, "config.source.json");
598
604
  if (r && X(N, JSON.stringify(r)), o) {
599
- const d = E(p, "resources"), h = E(d, "components");
600
- F(h, { recursive: !0 });
601
- for (const w of Object.keys(((g = t == null ? void 0 : t.resources) == null ? void 0 : g.components) ?? {})) {
605
+ const d = E(p, "resources"), g = E(d, "components");
606
+ F(g, { recursive: !0 });
607
+ for (const w of Object.keys(((h = t == null ? void 0 : t.resources) == null ? void 0 : h.components) ?? {})) {
602
608
  const D = (b = (U = (S = t.resources) == null ? void 0 : S.components) == null ? void 0 : U[w]) == null ? void 0 : b.component;
603
- D && await oe(D, h, {
609
+ D && await oe(D, g, {
604
610
  getFilename: (C) => `${C.name || "unnamed"}.${C.id}.yml`,
605
611
  exportAssets: s
606
612
  });
@@ -608,39 +614,42 @@ async function vt(t, {
608
614
  }
609
615
  return p;
610
616
  }
611
- async function De(t, { importAssets: s, includeResources: e } = {}) {
612
- var o, c, i;
617
+ async function Ce(t, { importAssets: s, includeResources: e } = {}) {
618
+ var o, l, i;
613
619
  if (!x(t))
614
620
  return null;
615
621
  let n, r = !1;
616
622
  try {
617
- z(t).isDirectory() ? n = t : /\.(tgz|gz|tar)$/.test(t) && (r = !0, n = Pe(), await Xe({ file: t, C: n }));
618
- const a = ae("**/.blocklet/pages/pages.config.yml", { cwd: n, absolute: !0 }).at(0), l = a && E(L(a), "../../pages"), u = a && E(L(a), "../../components");
623
+ Y(t).isDirectory() ? n = t : /\.(tgz|gz|tar)$/.test(t) && (r = !0, n = je(), await Qe({ file: t, C: n }));
624
+ const a = ae("**/.blocklet/pages/pages.config.yml", { cwd: n, absolute: !0 }).at(0), c = a && E(L(a), "../../pages"), u = a && E(L(a), "../../components");
619
625
  if (!a)
620
626
  return null;
621
- const p = V.parse(Y(a).toString()), y = (m, A, g) => {
622
- let S = E(m, `${A}${g ? `.${g}` : ""}.yml`);
623
- return (!x(S) || !z(S).isFile()) && (S = E(m, A, `index${g ? `.${g}` : ""}.yml`), !x(S) || !z(S)) ? null : V.parse(Y(S).toString());
624
- }, O = (m, A) => {
627
+ const p = V.parse(K(a).toString()), y = (f, A, h) => {
628
+ let S = E(f, `${A}${h ? `.${h}` : ""}.yml`);
629
+ return (!x(S) || !Y(S).isFile()) && (S = E(f, A, `index${h ? `.${h}` : ""}.yml`), !x(S) || !Y(S)) ? null : V.parse(K(S).toString());
630
+ }, O = (f, A) => {
625
631
  try {
626
- const g = ae(`*.${A}.yml`, { cwd: m, absolute: !0 })[0];
627
- return g ? V.parse(Y(g).toString()) : null;
628
- } catch (g) {
629
- P.error("parse component error", g);
632
+ const h = ae(`*.${A}.yml`, { cwd: f, absolute: !0 })[0];
633
+ return h ? V.parse(K(h).toString()) : null;
634
+ } catch (h) {
635
+ T.error("parse component error", h);
630
636
  }
631
637
  return null;
632
- }, T = k(
633
- p.pages.map(({ slug: m }) => {
638
+ }, P = k(
639
+ p.pages.map(({ slug: f }) => {
634
640
  var U;
635
641
  const A = k(
636
642
  p.supportedLocales.map(({ locale: b }) => {
637
- const d = l ? y(l, m, b) : void 0;
638
- return d && { locale: b, page: d };
643
+ const d = c ? y(c, Te(f), b) : void 0;
644
+ if (d)
645
+ return { locale: b, page: d };
646
+ const g = c ? y(c, f, b) : void 0;
647
+ return g && { locale: b, page: g };
639
648
  })
640
- ), g = (U = A[0]) == null ? void 0 : U.page;
641
- if (!g)
649
+ ), h = (U = A[0]) == null ? void 0 : U.page;
650
+ if (!h)
642
651
  return null;
643
- const S = g.sections.map((b) => {
652
+ const S = h.sections.map((b) => {
644
653
  const d = b.id || he();
645
654
  return {
646
655
  id: d,
@@ -650,71 +659,72 @@ async function De(t, { importAssets: s, includeResources: e } = {}) {
650
659
  visibility: b.visibility,
651
660
  locales: Object.fromEntries(
652
661
  k(
653
- A.map(({ locale: h, page: w }) => {
662
+ A.map(({ locale: g, page: w }) => {
654
663
  const D = w.sections.find((C) => C.id === d);
655
- return D && [h, D.properties];
664
+ return D && [g, D.properties];
656
665
  })
657
666
  )
658
667
  )
659
668
  };
660
669
  });
661
670
  return {
662
- id: g.id || he(),
663
- createdAt: g.createdAt,
664
- updatedAt: g.updatedAt,
665
- publishedAt: g.publishedAt,
666
- slug: m,
671
+ id: h.id || he(),
672
+ createdAt: h.createdAt,
673
+ updatedAt: h.updatedAt,
674
+ publishedAt: h.publishedAt,
675
+ isPublic: h.isPublic ?? !0,
676
+ slug: f,
667
677
  sections: Object.fromEntries(S.map((b) => [b.id, b])),
668
678
  sectionIds: S.map((b) => b.id),
669
679
  locales: Object.fromEntries(A.map(({ locale: b, page: d }) => [b, d.meta]))
670
680
  };
671
681
  })
672
- ), j = u ? k(((o = p.components) == null ? void 0 : o.map(({ id: m }) => O(u, m))) ?? []) : [];
682
+ ), j = u ? k(((o = p.components) == null ? void 0 : o.map(({ id: f }) => O(u, f))) ?? []) : [];
673
683
  if (s) {
674
- const m = (...A) => {
675
- P.info(`[${r ? _(t) : _(E(t, "../../../../"))}] importAssets:`, ...A);
684
+ const f = (...A) => {
685
+ T.info(`[${r ? $(t) : $(E(t, "../../../../"))}] importAssets:`, ...A);
676
686
  };
677
687
  try {
678
- m("wait image-bin api ready"), await Qe({
679
- resources: [`${Fe(ct)}/api/sdk/uploads`],
688
+ f("wait image-bin api ready"), await Ze({
689
+ resources: [`${_e(lt)}/api/sdk/uploads`],
680
690
  validateStatus: (S) => S >= 200 && S <= 500
681
- }), m("image-bin api is ready");
682
- const A = {}, g = {};
683
- m("start to upload assets"), await Promise.allSettled([
691
+ }), f("image-bin api is ready");
692
+ const A = {}, h = {};
693
+ f("start to upload assets"), await Promise.allSettled([
684
694
  we(j, A, {
685
695
  getFilePath: (S) => u && E(u, S),
686
696
  onFinish: (S) => {
687
- m(`upload ${S.length} component assets`);
697
+ f(`upload ${S.length} component assets`);
688
698
  }
689
699
  }),
690
- we(T, g, {
700
+ we(P, h, {
691
701
  getFilePath: (S, U) => {
692
- const b = ce(T, U.slice(0, 1));
693
- return l && E(l, L(b.slug), S);
702
+ const b = ce(P, U.slice(0, 1));
703
+ return c && E(c, L(b.slug), S);
694
704
  },
695
705
  onFinish: (S) => {
696
- m(`upload ${S.length} page assets`);
706
+ f(`upload ${S.length} page assets`);
697
707
  }
698
708
  })
699
- ]), m("upload assets done"), global.gc && global.gc();
709
+ ]), f("upload assets done"), global.gc && global.gc();
700
710
  } catch (A) {
701
- m("Error during asset import:", A);
711
+ f("Error during asset import:", A);
702
712
  }
703
713
  }
704
714
  const N = {};
705
715
  if (e) {
706
- const m = a && E(L(a), "../../resources/components"), A = k(
707
- ((i = (c = p.resources) == null ? void 0 : c.components) == null ? void 0 : i.map(({ id: g }) => O(m, g))) ?? []
716
+ const f = a && E(L(a), "../../resources/components"), A = k(
717
+ ((i = (l = p.resources) == null ? void 0 : l.components) == null ? void 0 : i.map(({ id: h }) => O(f, h))) ?? []
708
718
  );
709
719
  A.length > 0 && (N.components = Object.fromEntries(
710
- A.map((g, S) => [g.id, { index: S, component: g }])
720
+ A.map((h, S) => [h.id, { index: S, component: h }])
711
721
  ));
712
722
  }
713
723
  return {
714
724
  supportedLocales: p.supportedLocales,
715
- pageIds: T.map((m) => m.id),
716
- components: Object.fromEntries(j.map((m, A) => [m.id, { index: A, data: m }])),
717
- pages: Object.fromEntries(T.map((m) => [m.id, m])),
725
+ pageIds: P.map((f) => f.id),
726
+ components: Object.fromEntries(j.map((f, A) => [f.id, { index: A, data: f }])),
727
+ pages: Object.fromEntries(P.map((f) => [f.id, f])),
718
728
  config: p.config || {},
719
729
  resources: N
720
730
  };
@@ -729,12 +739,12 @@ async function Ee(t, s, {
729
739
  publishMode: o = void 0
730
740
  } = {}) {
731
741
  try {
732
- o && Ne(o);
742
+ o && Re(o);
733
743
  } catch (u) {
734
- P.error("clear preload page cache error", { error: u });
744
+ T.error("clear preload page cache error", { error: u });
735
745
  }
736
- const { pageIds: c, pages: i, supportedLocales: a } = t;
737
- for (const u of e ?? c) {
746
+ const { pageIds: l, pages: i, supportedLocales: a } = t;
747
+ for (const u of e ?? l) {
738
748
  const p = i[u];
739
749
  if (!p) {
740
750
  const y = s.pageIds.indexOf(u);
@@ -754,14 +764,14 @@ async function Ee(t, s, {
754
764
  if (r && !e)
755
765
  for (const u of s.pageIds)
756
766
  t.pageIds.includes(u) || delete s.pages[u], s.pageIds = [...s.pageIds].filter((p) => t.pageIds.includes(p));
757
- if (s.supportedLocales.splice(0, s.supportedLocales.length), s.supportedLocales.push(...qe(a)), r)
767
+ if (s.supportedLocales.splice(0, s.supportedLocales.length), s.supportedLocales.push(...ze(a)), r)
758
768
  for (const u of Object.keys(s.components))
759
769
  delete s.components[u];
760
- let l = JSON.parse(JSON.stringify(t.components));
761
- l = Object.fromEntries(
770
+ let c = JSON.parse(JSON.stringify(t.components));
771
+ c = Object.fromEntries(
762
772
  await Promise.all(
763
- Object.entries(l).map(async ([u, p]) => {
764
- const y = await Ce(p == null ? void 0 : p.data);
773
+ Object.entries(c).map(async ([u, p]) => {
774
+ const y = await ke(p == null ? void 0 : p.data);
765
775
  return [
766
776
  u,
767
777
  {
@@ -771,9 +781,9 @@ async function Ee(t, s, {
771
781
  ];
772
782
  })
773
783
  )
774
- ), Object.assign(s.components, l), Object.assign(s.config, JSON.parse(JSON.stringify(t.config))), s.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
784
+ ), Object.assign(s.components, c), Object.assign(s.config, JSON.parse(JSON.stringify(t.config))), s.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
775
785
  }
776
- const Ce = Ue(
786
+ const ke = Fe(
777
787
  async (t) => {
778
788
  var s;
779
789
  if (!He(t == null ? void 0 : t.properties))
@@ -782,7 +792,7 @@ const Ce = Ue(
782
792
  const { script: e } = (t == null ? void 0 : t.renderer) || {};
783
793
  if (e)
784
794
  try {
785
- const n = await Re(e, "PROPERTIES_SCHEMA", t.id);
795
+ const n = await Ue(e, "PROPERTIES_SCHEMA", t.id);
786
796
  n && n.length > 0 && t && (t.properties = {}, n.forEach((r, o) => {
787
797
  t != null && t.properties && (t.properties[r.id] = {
788
798
  index: o,
@@ -790,7 +800,7 @@ const Ce = Ue(
790
800
  });
791
801
  }));
792
802
  } catch (n) {
793
- P.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: n });
803
+ T.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: n });
794
804
  }
795
805
  }
796
806
  return t;
@@ -799,13 +809,13 @@ const Ce = Ue(
799
809
  keyGenerator: (t) => JSON.stringify(["checkPropertiesFromCode", t])
800
810
  }
801
811
  );
802
- function It({
812
+ function Ot({
803
813
  state: t,
804
814
  pageIds: s = [],
805
815
  componentIds: e = []
806
816
  }) {
807
- var c;
808
- const n = (i, a = /* @__PURE__ */ new Set()) => (Array.isArray(i) && i.forEach((l) => n(l, a)), i && typeof i == "object" && (typeof i.componentId == "string" && a.add(i.componentId), Object.values(i).forEach((l) => n(l, a))), a), r = new Set(e);
817
+ var l;
818
+ const n = (i, a = /* @__PURE__ */ new Set()) => (Array.isArray(i) && i.forEach((c) => n(c, a)), i && typeof i == "object" && (typeof i.componentId == "string" && a.add(i.componentId), Object.values(i).forEach((c) => n(c, a))), a), r = new Set(e);
809
819
  for (const i of s) {
810
820
  const a = t.pages[i];
811
821
  n(a, r);
@@ -814,20 +824,20 @@ function It({
814
824
  for (; o.length; ) {
815
825
  const i = o.shift();
816
826
  r.has(i) || r.add(i);
817
- const a = (c = t.components[i]) == null ? void 0 : c.data;
827
+ const a = (l = t.components[i]) == null ? void 0 : l.data;
818
828
  if (a)
819
- for (const l of n(a))
820
- r.has(l) || o.push(l);
829
+ for (const c of n(a))
830
+ r.has(c) || o.push(c);
821
831
  }
822
832
  return [...r];
823
833
  }
824
834
  let ee, J, pe, de;
825
- function ke() {
835
+ function Le() {
826
836
  return ee = (async () => {
827
- const t = _e({ types: [{ did: Te, type: ut }] });
837
+ const t = Me({ types: [{ did: Pe, type: ft }] });
828
838
  J = (await Promise.all(
829
839
  t.map(async (e) => {
830
- const n = e.path ? await De(e.path, { importAssets: !1 }) : void 0;
840
+ const n = e.path ? await Ce(e.path, { importAssets: !1 }) : void 0;
831
841
  return n ? { blockletId: e.did, state: n, blockletTitle: e.title } : void 0;
832
842
  })
833
843
  )).filter((e) => !!e), pe = J.reduce(
@@ -851,7 +861,7 @@ function ke() {
851
861
  de = Object.fromEntries(
852
862
  await Promise.all(
853
863
  Object.entries(s).map(async ([e, n]) => {
854
- const r = await Ce(n.component);
864
+ const r = await ke(n.component);
855
865
  return [
856
866
  e,
857
867
  {
@@ -864,66 +874,66 @@ function ke() {
864
874
  );
865
875
  })(), ee;
866
876
  }
867
- function Ot(t) {
877
+ function Pt(t) {
868
878
  const s = ve(
869
879
  async () => {
870
- await ke().catch((e) => {
871
- P.error("load resource states error", { error: e });
880
+ await Le().catch((e) => {
881
+ T.error("load resource states error", { error: e });
872
882
  }), await (t == null ? void 0 : t({ states: J, pages: pe, components: de }));
873
883
  },
874
884
  3e3,
875
885
  { leading: !1, trailing: !0 }
876
886
  );
877
- return s(), f.events.on(f.Events.componentAdded, s), f.events.on(f.Events.componentRemoved, s), f.events.on(f.Events.componentStarted, s), f.events.on(f.Events.componentStopped, s), f.events.on(f.Events.componentUpdated, s), f.events.on(ie, s), () => {
878
- f.events.off(f.Events.componentAdded, s), f.events.off(f.Events.componentRemoved, s), f.events.off(f.Events.componentStarted, s), f.events.off(f.Events.componentStopped, s), f.events.off(f.Events.componentUpdated, s), f.events.off(ie, s);
887
+ return s(), m.events.on(m.Events.componentAdded, s), m.events.on(m.Events.componentRemoved, s), m.events.on(m.Events.componentStarted, s), m.events.on(m.Events.componentStopped, s), m.events.on(m.Events.componentUpdated, s), m.events.on(ie, s), () => {
888
+ m.events.off(m.Events.componentAdded, s), m.events.off(m.Events.componentRemoved, s), m.events.off(m.Events.componentStarted, s), m.events.off(m.Events.componentStopped, s), m.events.off(m.Events.componentUpdated, s), m.events.off(ie, s);
879
889
  };
880
890
  }
881
- const Le = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), W = globalThis;
891
+ const Ne = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), W = globalThis;
882
892
  var Ae;
883
- (Ae = W[Le]) == null || Ae.call(W);
884
- W[Le] = Ot(async ({ pages: t, components: s }) => {
893
+ (Ae = W[Ne]) == null || Ae.call(W);
894
+ W[Ne] = Pt(async ({ pages: t, components: s }) => {
885
895
  const { projectIds: e } = Q;
886
896
  await Promise.all(
887
897
  e.map(async (n) => {
888
898
  const r = Q.shared(n);
889
899
  r.syncedStore.resources.pages = t;
890
- const o = await M.findByPk(n);
900
+ const o = await _.findByPk(n);
891
901
  if (o != null && o.useAllResources)
892
902
  r.syncedStore.resources.components = s;
893
903
  else {
894
- const i = (await te.findAll({ where: { projectId: n } })).map((l) => l.componentId), a = Object.fromEntries(
895
- Object.entries(s || {}).filter(([l]) => i.includes(l))
904
+ const i = (await te.findAll({ where: { projectId: n } })).map((c) => c.componentId), a = Object.fromEntries(
905
+ Object.entries(s || {}).filter(([c]) => i.includes(c))
896
906
  );
897
907
  r.syncedStore.resources.components = a;
898
908
  }
899
- P.info(`update [${n}] resource states:`, {
909
+ T.info(`update [${n}] resource states:`, {
900
910
  pages: Object.keys(r.syncedStore.resources.pages || {}).length,
901
911
  components: Object.keys(r.syncedStore.resources.components || {}).length
902
912
  });
903
913
  })
904
914
  );
905
915
  });
906
- async function Zt() {
907
- P.info("trigger reload all project resource"), f.events.emit(ie);
916
+ async function es() {
917
+ T.info("trigger reload all project resource"), m.events.emit(ie);
908
918
  }
909
919
  async function Tt() {
910
- return ee ?? (ee = ke()), await ee, { states: J, pages: pe, components: de };
920
+ return ee ?? (ee = Le()), await ee, { states: J, pages: pe, components: de };
911
921
  }
912
922
  export {
913
- Te as C,
914
- M as P,
915
- ut as R,
923
+ Pe as C,
924
+ _ as P,
925
+ ft as R,
916
926
  Q as S,
917
927
  Tt as a,
918
- K as b,
919
- Xt as c,
920
- Qt as d,
921
- Ot as e,
922
- De as f,
923
- Wt as g,
924
- Zt as h,
925
- zt as i,
928
+ H as b,
929
+ Qt as c,
930
+ Zt as d,
931
+ Pt as e,
932
+ Ce as f,
933
+ Xt as g,
934
+ es as h,
935
+ Wt as i,
926
936
  Ee as m,
927
937
  he as n,
928
- vt as t
938
+ It as t
929
939
  };