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