@blocklet/pages-kit-inner-components 0.6.20 → 0.6.22
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/add-component.js +1 -1
- package/lib/cjs/chunks/{home-D6CNLMDa.js → home-CmcR9R89.js} +2 -2
- package/lib/cjs/chunks/html-JOhPskS4.js +1 -0
- package/lib/cjs/chunks/index-7_tPWvdE.js +475 -0
- package/lib/cjs/chunks/{publish-button-FsuH_RMC.js → publish-button-CuIP1HAR.js} +1 -1
- package/lib/cjs/chunks/site-state-CkqENAbR.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/project-html.js +6 -6
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +3 -3
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +2 -2
- package/lib/es/chunks/{home-Dmze9ay0.js → home-pT8D7Ttx.js} +2 -2
- package/lib/es/chunks/html-DfzaaIYa.js +49 -0
- package/lib/es/chunks/{index-aeMNll_R.js → index-BHQcp5eX.js} +964 -563
- package/lib/es/chunks/{publish-button-BPtL08Ue.js → publish-button-CIVPDQb7.js} +2 -2
- package/lib/es/chunks/{site-state-Dt2__Byi.js → site-state-CqlS8v17.js} +536 -562
- package/lib/es/home.js +2 -2
- package/lib/es/locales.js +86 -8
- package/lib/es/project-html.js +93 -133
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +143 -141
- package/lib/es/site-state.js +1 -1
- package/package.json +5 -5
- package/lib/cjs/chunks/index-D3fT0ax0.js +0 -475
- package/lib/cjs/chunks/site-state-Vc48a38-.js +0 -1
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { getYjsValue as V, syncedStore as
|
|
1
|
+
import { d as $e, l as f, I as We, c as Qe, m as Xe, b as Ze } from "./components-BWQM8y6L.js";
|
|
2
|
+
import { getYjsValue as V, syncedStore as et } from "@syncedstore/core";
|
|
3
3
|
import * as N from "yjs";
|
|
4
|
-
import { setPageDataSource as
|
|
5
|
-
import { getRouteMetaDataByOptionIds as
|
|
6
|
-
import { cloneDeep as
|
|
7
|
-
import
|
|
8
|
-
import { mkdtempSync as
|
|
9
|
-
import { join as E, basename as
|
|
4
|
+
import { setPageDataSource as tt } from "@blocklet/pages-kit/utils/data-source";
|
|
5
|
+
import { getRouteMetaDataByOptionIds as st, generateParamCombinations as Se } from "@blocklet/pages-kit/utils/route";
|
|
6
|
+
import { cloneDeep as at } from "lodash";
|
|
7
|
+
import b from "@blocklet/sdk/lib/config";
|
|
8
|
+
import { mkdtempSync as ot, existsSync as U, readFileSync as q, renameSync as Ce, mkdirSync as _, rmSync as Ue, writeFileSync as ee, copyFileSync as rt, lstatSync as B, readdirSync as nt, createWriteStream as it } from "fs";
|
|
9
|
+
import { join as E, basename as R, dirname as L } from "path";
|
|
10
10
|
import { nextId as Oe } from "@blocklet/pages-kit/utils/common";
|
|
11
|
-
import { unzipSection as
|
|
12
|
-
import { getComponentDependencies as
|
|
13
|
-
import { getComponentWebEndpoint as
|
|
14
|
-
import { reactive as
|
|
11
|
+
import { unzipSection as ct } from "@blocklet/pages-kit/utils/page-model";
|
|
12
|
+
import { getComponentDependencies as pt } from "@blocklet/pages-kit/utils/property";
|
|
13
|
+
import { getComponentWebEndpoint as lt, getResources as ut, call as dt } from "@blocklet/sdk/lib/component";
|
|
14
|
+
import { reactive as ft } from "@reactivedata/reactive";
|
|
15
15
|
import { globSync as te } from "glob";
|
|
16
|
-
import * as
|
|
16
|
+
import * as ue from "lib0/decoding";
|
|
17
17
|
import * as D from "lib0/encoding";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
18
|
+
import mt from "lodash/cloneDeep";
|
|
19
|
+
import Me from "lodash/debounce";
|
|
20
20
|
import Ie from "lodash/get";
|
|
21
|
-
import
|
|
21
|
+
import be from "lodash/isEmpty";
|
|
22
22
|
import ve from "lodash/set";
|
|
23
|
-
import
|
|
24
|
-
import { LRUCache as
|
|
23
|
+
import gt from "lodash/union";
|
|
24
|
+
import { LRUCache as Ee } from "lru-cache";
|
|
25
25
|
import ht from "p-limit";
|
|
26
|
-
import { DataTypes as k, Sequelize as
|
|
27
|
-
import { pipeline as
|
|
28
|
-
import { x as
|
|
29
|
-
import { joinURL as
|
|
30
|
-
import
|
|
31
|
-
import { Awareness as Et, encodeAwarenessUpdate as
|
|
32
|
-
import { writeUpdate as
|
|
26
|
+
import { DataTypes as k, Sequelize as yt, Model as Ne, Op as Fe } from "sequelize";
|
|
27
|
+
import { pipeline as St } from "stream/promises";
|
|
28
|
+
import { x as It } from "tar";
|
|
29
|
+
import { joinURL as H } from "ufo";
|
|
30
|
+
import bt from "wait-on";
|
|
31
|
+
import { Awareness as Et, encodeAwarenessUpdate as je, removeAwarenessStates as wt, applyAwarenessUpdate as At } from "y-protocols/awareness";
|
|
32
|
+
import { writeUpdate as Pt, writeSyncStep1 as Ct, readSyncMessage as Ot } from "y-protocols/sync";
|
|
33
33
|
import * as G from "yaml";
|
|
34
|
+
import { m as ke } from "./html-DfzaaIYa.js";
|
|
34
35
|
import "sqlite3";
|
|
35
36
|
import "@blocklet/pages-kit/types/state";
|
|
36
|
-
const
|
|
37
|
-
k.sqlite.DATE.parse = (t, e) => typeof t == "number" ? new Date(t) :
|
|
38
|
-
const F = new
|
|
37
|
+
const vt = k.sqlite.DATE.parse;
|
|
38
|
+
k.sqlite.DATE.parse = (t, e) => typeof t == "number" ? new Date(t) : vt(t, e);
|
|
39
|
+
const F = new yt({
|
|
39
40
|
dialect: "sqlite",
|
|
40
|
-
storage:
|
|
41
|
+
storage: $e,
|
|
41
42
|
benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
|
|
42
43
|
retry: {
|
|
43
44
|
match: [/SQLITE_BUSY/],
|
|
@@ -59,7 +60,7 @@ process.on("SIGINT", async () => {
|
|
|
59
60
|
process.on("SIGTERM", async () => {
|
|
60
61
|
await F.close(), process.exit(0);
|
|
61
62
|
});
|
|
62
|
-
async function
|
|
63
|
+
async function jt(t, e) {
|
|
63
64
|
try {
|
|
64
65
|
if (t.getDialect() !== "sqlite")
|
|
65
66
|
return;
|
|
@@ -77,12 +78,12 @@ let me = null;
|
|
|
77
78
|
me && clearInterval(me);
|
|
78
79
|
me = setInterval(
|
|
79
80
|
async () => {
|
|
80
|
-
f.info("Start cleanupSqliteMemory"), await
|
|
81
|
+
f.info("Start cleanupSqliteMemory"), await jt(F, $e), f.info("End cleanupSqliteMemory");
|
|
81
82
|
},
|
|
82
83
|
60 * 1e3 * 10
|
|
83
84
|
// 10 minutes
|
|
84
85
|
);
|
|
85
|
-
class we extends
|
|
86
|
+
class we extends Ne {
|
|
86
87
|
// Foreign key to Component
|
|
87
88
|
}
|
|
88
89
|
we.init(
|
|
@@ -104,11 +105,11 @@ we.init(
|
|
|
104
105
|
},
|
|
105
106
|
{ sequelize: F, tableName: "ProjectComponents", timestamps: !1 }
|
|
106
107
|
);
|
|
107
|
-
class M extends
|
|
108
|
+
class M extends Ne {
|
|
108
109
|
static async getProjectByIdOrSlug(e) {
|
|
109
110
|
return M.findOne({
|
|
110
111
|
where: {
|
|
111
|
-
[
|
|
112
|
+
[Fe.or]: [{ id: e }, { slug: e }]
|
|
112
113
|
}
|
|
113
114
|
});
|
|
114
115
|
}
|
|
@@ -191,22 +192,22 @@ M.hasMany(we, {
|
|
|
191
192
|
foreignKey: "projectId",
|
|
192
193
|
as: "components"
|
|
193
194
|
});
|
|
194
|
-
const kt = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",
|
|
195
|
+
const kt = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", De = "page", ge = "trigger-reload-project-resource", _e = kt, Dt = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";
|
|
195
196
|
function se(t) {
|
|
196
197
|
t.observeDeep((e) => {
|
|
197
198
|
e.some((s) => s.changes.keys.has("updatedAt") || s.changes.keys.has("publishedAt")) || t.set("updatedAt", (/* @__PURE__ */ new Date()).toISOString());
|
|
198
199
|
});
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
201
|
+
function xe() {
|
|
202
|
+
return ot(E(b.env.dataDir, "tmp-"));
|
|
202
203
|
}
|
|
203
204
|
function ae(t, e, s = []) {
|
|
204
205
|
return Array.isArray(t) ? t.flatMap((a, o) => ae(a, e, [...s, o])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([a, o]) => ae(o, e, [...s, a])) : e(t) ? [s] : [];
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function T(t) {
|
|
207
208
|
return t.filter((e) => e != null);
|
|
208
209
|
}
|
|
209
|
-
function
|
|
210
|
+
function Tt(t) {
|
|
210
211
|
t.pages && Object.keys(t.pages).forEach((s) => {
|
|
211
212
|
const a = V(t.pages[s]);
|
|
212
213
|
a && a instanceof N.Map && se(a);
|
|
@@ -236,12 +237,12 @@ function Rt(t) {
|
|
|
236
237
|
});
|
|
237
238
|
});
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function Lt(t, e) {
|
|
240
241
|
for (const s of e || Object.keys(t.routes || {})) {
|
|
241
242
|
let a = s, o = [];
|
|
242
243
|
if (s.includes("-")) {
|
|
243
|
-
const [r, ...
|
|
244
|
-
a = r, o =
|
|
244
|
+
const [r, ...c] = s.split("-");
|
|
245
|
+
a = r, o = c || [];
|
|
245
246
|
}
|
|
246
247
|
if (t.routes?.[a] !== void 0) {
|
|
247
248
|
t.routes[a].publishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -249,11 +250,11 @@ function jt(t, e) {
|
|
|
249
250
|
if (!r || !r.params || r.params.length === 0)
|
|
250
251
|
continue;
|
|
251
252
|
if (s.includes("-") && o.length > 0) {
|
|
252
|
-
const
|
|
253
|
-
|
|
253
|
+
const c = st(o, r);
|
|
254
|
+
c && (c.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
|
|
254
255
|
}
|
|
255
256
|
if (!e) {
|
|
256
|
-
const
|
|
257
|
+
const c = Se({
|
|
257
258
|
basePath: r.path,
|
|
258
259
|
params: r.params,
|
|
259
260
|
routeId: r.id,
|
|
@@ -263,13 +264,13 @@ function jt(t, e) {
|
|
|
263
264
|
currentOptionIds: [],
|
|
264
265
|
result: []
|
|
265
266
|
});
|
|
266
|
-
for (const
|
|
267
|
-
|
|
267
|
+
for (const l of c)
|
|
268
|
+
l.routeMetaData ??= {}, l.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function de({
|
|
273
274
|
page: t,
|
|
274
275
|
route: e,
|
|
275
276
|
state: s,
|
|
@@ -280,7 +281,7 @@ function ue({
|
|
|
280
281
|
`Executing datasource data assembly, routeId: ${a}, routePathInfo: ${JSON.stringify(o)}`
|
|
281
282
|
);
|
|
282
283
|
const r = {
|
|
283
|
-
...
|
|
284
|
+
...at(t),
|
|
284
285
|
id: a,
|
|
285
286
|
slug: o?.path ?? e.path,
|
|
286
287
|
createdAt: e.createdAt,
|
|
@@ -288,74 +289,51 @@ function ue({
|
|
|
288
289
|
publishedAt: o?.routeMetaData?.publishedAt ?? e.publishedAt,
|
|
289
290
|
isPublic: (o?.routeMetaData?.isPublic ?? e.isPublic) && e.isPublic
|
|
290
291
|
};
|
|
291
|
-
for (const
|
|
292
|
+
for (const c of s.supportedLocales) {
|
|
292
293
|
if (e.dataSource) {
|
|
293
|
-
let
|
|
294
|
-
o && (
|
|
295
|
-
const
|
|
296
|
-
if (!
|
|
294
|
+
let l = e.id;
|
|
295
|
+
o && (l = o.paramOptionIds.join("-"));
|
|
296
|
+
const p = e.dataSource.pathDataMappings?.[l]?.dataCache?.[c.locale] ?? e.dataSource.pathDataMappings?.[l]?.dataCache?.[s.config.defaultLocale || "en"];
|
|
297
|
+
if (!p)
|
|
297
298
|
continue;
|
|
298
|
-
|
|
299
|
+
tt(r, s, c.locale, p);
|
|
299
300
|
}
|
|
300
301
|
o && o.routeMetaData && (o.routeMetaData.publishedAt = (/* @__PURE__ */ new Date()).toISOString());
|
|
301
302
|
}
|
|
302
303
|
return r;
|
|
303
304
|
}
|
|
304
|
-
const
|
|
305
|
+
const $t = 30 * 60 * 1e3, Y = new Ee({
|
|
305
306
|
max: 100,
|
|
306
|
-
ttl:
|
|
307
|
+
ttl: $t
|
|
307
308
|
});
|
|
308
|
-
function
|
|
309
|
+
function Ut(t, e = []) {
|
|
309
310
|
let s = 0;
|
|
310
|
-
const a = Array.from(
|
|
311
|
-
for (const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
for (const r of a) {
|
|
317
|
-
const i = r.split(":lang-path=")[0] || "";
|
|
318
|
-
for (const c of o) {
|
|
319
|
-
const m = (c.split(":lang-path=")[0] || "").replace(/\/:[^/]+/g, "");
|
|
320
|
-
if (i.startsWith(m)) {
|
|
321
|
-
z.delete(r), s++, f.info(`[Cache CLEAR] key: ${r}`);
|
|
311
|
+
const a = Array.from(Y.keys());
|
|
312
|
+
for (const o of a)
|
|
313
|
+
for (const r of t) {
|
|
314
|
+
if (ke(o, { currentPath: r })) {
|
|
315
|
+
Y.delete(o), s++, f.info(`[Cache CLEAR] key: ${o}`);
|
|
322
316
|
break;
|
|
323
317
|
}
|
|
318
|
+
for (const c of e)
|
|
319
|
+
if (ke(o, { currentPath: `/${c}${r}` })) {
|
|
320
|
+
Y.delete(o), s++, f.info(`[Cache CLEAR] key: ${o}`);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
324
323
|
}
|
|
325
|
-
}
|
|
326
|
-
return f.info(`[Cache CLEAR] cleared ${s} entries for patterns:`, o), s;
|
|
327
|
-
}
|
|
328
|
-
function Ut({
|
|
329
|
-
projectId: t,
|
|
330
|
-
projectSlug: e,
|
|
331
|
-
supportedLocales: s = []
|
|
332
|
-
}) {
|
|
333
|
-
let a = 0;
|
|
334
|
-
const o = Array.from(z.keys()), r = [];
|
|
335
|
-
r.push(`page-html:prod:/${t}`), e && e !== t && r.push(`page-html:prod:/${e}`);
|
|
336
|
-
for (const i of s)
|
|
337
|
-
r.push(`page-html:prod:/${i}/${t}`), e && e !== t && (e !== "/" ? r.push(`page-html:prod:/${i}/${e}`) : r.push(`page-html:prod:/${i}`));
|
|
338
|
-
for (const i of o)
|
|
339
|
-
for (const c of r)
|
|
340
|
-
if (i.startsWith(c)) {
|
|
341
|
-
z.delete(i), a++, f.info(`[Cache CLEAR PROJECT] key: ${i}`);
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
return f.info(
|
|
345
|
-
`[Cache CLEAR PROJECT] cleared ${a} entries for project ${t}${e ? ` (slug: ${e})` : ""}`
|
|
346
|
-
), a;
|
|
324
|
+
return f.info(`[Cache CLEAR] cleared ${s} entries for paths:`, t), s;
|
|
347
325
|
}
|
|
348
326
|
function Mt() {
|
|
349
|
-
const t =
|
|
350
|
-
return
|
|
327
|
+
const t = Y.size;
|
|
328
|
+
return Y.clear(), f.info(`[Cache CLEAR ALL] cleared ${t} entries`), t;
|
|
351
329
|
}
|
|
352
|
-
|
|
353
|
-
const { uploadToMediaKit: Nt } = require("@blocklet/uploader-server"), Ae = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, W = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,
|
|
330
|
+
b.events.on(b.Events.envUpdate, Mt);
|
|
331
|
+
const { uploadToMediaKit: Nt } = require("@blocklet/uploader-server"), Ae = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, W = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Te = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Ft = 1e4, _t = 3e4, X = 0, fe = 1, xt = 0, Bt = 1, he = b, K = E(process.env.BLOCKLET_DATA_DIR, "site-state"), vs = ["production", "draft"], js = ["production"];
|
|
354
332
|
function oe(t) {
|
|
355
333
|
return t?.replace(/\//g, "|") || "";
|
|
356
334
|
}
|
|
357
335
|
function Gt() {
|
|
358
|
-
const t =
|
|
336
|
+
const t = he.env.languages?.map((s) => ({ locale: s.code, name: s.name })) || [], e = t[0]?.locale || "en";
|
|
359
337
|
return {
|
|
360
338
|
pageIds: [],
|
|
361
339
|
pages: {},
|
|
@@ -369,10 +347,10 @@ function Gt() {
|
|
|
369
347
|
resources: {}
|
|
370
348
|
};
|
|
371
349
|
}
|
|
372
|
-
class
|
|
350
|
+
class O extends N.Doc {
|
|
373
351
|
constructor(e) {
|
|
374
|
-
super(), this.options = e, U(this.draftYjsFilePath) && N.applyUpdate(this,
|
|
375
|
-
|
|
352
|
+
super(), this.options = e, U(this.draftYjsFilePath) && N.applyUpdate(this, q(this.draftYjsFilePath)), this.syncedStore = ft(
|
|
353
|
+
et(
|
|
376
354
|
{
|
|
377
355
|
pages: {},
|
|
378
356
|
pageIds: [],
|
|
@@ -395,7 +373,7 @@ class C extends N.Doc {
|
|
|
395
373
|
static PERIODIC_CHECK_INTERVAL = 2 * 60 * 60 * 1e3;
|
|
396
374
|
// 2 hours
|
|
397
375
|
static sharedInstances = {};
|
|
398
|
-
static pageUrlMapCache = new
|
|
376
|
+
static pageUrlMapCache = new Ee({
|
|
399
377
|
max: 100,
|
|
400
378
|
ttl: 1e3 * 60 * 60 * 24
|
|
401
379
|
// 1 day
|
|
@@ -407,7 +385,7 @@ class C extends N.Doc {
|
|
|
407
385
|
if (!e)
|
|
408
386
|
throw new Error("Should provide project context");
|
|
409
387
|
try {
|
|
410
|
-
const s = E(
|
|
388
|
+
const s = E(K, e), a = E(K, `@del-${e}`);
|
|
411
389
|
Ce(s, a);
|
|
412
390
|
} catch (s) {
|
|
413
391
|
f.error("Failed to safe delete project state dir:", s);
|
|
@@ -419,33 +397,33 @@ class C extends N.Doc {
|
|
|
419
397
|
/** @deprecated 不再使用这个 getter 了,仅作为兼容性处理,请使用 getProjectIds 代替 */
|
|
420
398
|
static get projectIds() {
|
|
421
399
|
return te("*/", {
|
|
422
|
-
cwd:
|
|
400
|
+
cwd: K,
|
|
423
401
|
ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*", "undefined"]
|
|
424
402
|
// Ignore temp directories and hidden files
|
|
425
403
|
});
|
|
426
404
|
}
|
|
427
405
|
/** @deprecated 不再使用这个 getter 了,仅作为兼容性处理 */
|
|
428
406
|
static get allShared() {
|
|
429
|
-
return this.projectIds.map((e) =>
|
|
407
|
+
return this.projectIds.map((e) => O.shared(e));
|
|
430
408
|
}
|
|
431
409
|
static shared(e) {
|
|
432
410
|
if (!e)
|
|
433
411
|
throw new Error("Should provide project context");
|
|
434
|
-
let s =
|
|
435
|
-
return s || (s = new
|
|
436
|
-
path: E(
|
|
437
|
-
}),
|
|
412
|
+
let s = O.sharedInstances[e];
|
|
413
|
+
return s || (s = new O({
|
|
414
|
+
path: E(K, e)
|
|
415
|
+
}), O.sharedInstances[e] = s, s);
|
|
438
416
|
}
|
|
439
417
|
// 轻量级 production 状态获取,不加载 draft 数据
|
|
440
418
|
static async getProductionState(e) {
|
|
441
419
|
const s = await M.findByPk(e, {
|
|
442
420
|
attributes: ["productionState"]
|
|
443
421
|
});
|
|
444
|
-
if (
|
|
445
|
-
const a = E(
|
|
422
|
+
if (be(s?.productionState)) {
|
|
423
|
+
const a = E(K, e, "production"), o = await Ge(a, { includeResources: !0 }) ?? Gt();
|
|
446
424
|
if (!o?.config?.defaultLocale) {
|
|
447
425
|
o.config ??= {};
|
|
448
|
-
const r =
|
|
426
|
+
const r = he.env.languages?.map((c) => ({ locale: c.code, name: c.name })) || [];
|
|
449
427
|
o.config.defaultLocale = r[0]?.locale;
|
|
450
428
|
}
|
|
451
429
|
return o;
|
|
@@ -454,33 +432,33 @@ class C extends N.Doc {
|
|
|
454
432
|
}
|
|
455
433
|
destroy() {
|
|
456
434
|
this.cancelRelease(), this.save({ flush: !0 }), this.conns.forEach((s, a) => this.closeConn(a)), this.awareness.destroy();
|
|
457
|
-
const e =
|
|
458
|
-
delete
|
|
435
|
+
const e = R(this.options.path);
|
|
436
|
+
delete O.sharedInstances[e], super.destroy();
|
|
459
437
|
}
|
|
460
438
|
initObserver() {
|
|
461
|
-
|
|
439
|
+
Tt(this.syncedStore), Rt(this.syncedStore);
|
|
462
440
|
}
|
|
463
441
|
get draftYjsFilePath() {
|
|
464
442
|
return E(this.options.path, "draft.yjs");
|
|
465
443
|
}
|
|
466
444
|
static async getStateByProjectId(e, s) {
|
|
467
445
|
if (s === "draft") {
|
|
468
|
-
const a =
|
|
446
|
+
const a = O.shared(e);
|
|
469
447
|
return JSON.parse(JSON.stringify(a.syncedStore));
|
|
470
448
|
}
|
|
471
|
-
return
|
|
449
|
+
return O.getProductionState(e);
|
|
472
450
|
}
|
|
473
451
|
async getState(e) {
|
|
474
452
|
if (e === "draft")
|
|
475
453
|
return JSON.parse(JSON.stringify(this.syncedStore));
|
|
476
|
-
const s =
|
|
477
|
-
return
|
|
454
|
+
const s = R(this.options.path);
|
|
455
|
+
return O.getProductionState(s);
|
|
478
456
|
}
|
|
479
457
|
async setState(e, s) {
|
|
480
458
|
const a = await Kt(s, { exportAssets: !1, includeResources: !0 }), o = this.getPublishDir(e);
|
|
481
|
-
if (_(L(o), { recursive: !0 }),
|
|
482
|
-
const r =
|
|
483
|
-
|
|
459
|
+
if (_(L(o), { recursive: !0 }), Ue(o, { force: !0, recursive: !0 }), Ce(a, o), e === "production") {
|
|
460
|
+
const r = R(this.options.path);
|
|
461
|
+
O.pageUrlMapCache.delete(r), await M.update({ productionState: { ...s } }, { where: { id: r } });
|
|
484
462
|
}
|
|
485
463
|
}
|
|
486
464
|
getPublishDir(e) {
|
|
@@ -494,49 +472,49 @@ class C extends N.Doc {
|
|
|
494
472
|
awarenessChangeHandler = ({ added: e, updated: s, removed: a }, o) => {
|
|
495
473
|
const r = e.concat(s, a);
|
|
496
474
|
if (o !== null) {
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}), a.forEach((
|
|
501
|
-
|
|
475
|
+
const p = this.conns.get(o);
|
|
476
|
+
p && (e.forEach((y) => {
|
|
477
|
+
p.add(y);
|
|
478
|
+
}), a.forEach((y) => {
|
|
479
|
+
p.delete(y);
|
|
502
480
|
}));
|
|
503
481
|
}
|
|
504
|
-
const
|
|
505
|
-
D.writeVarUint(
|
|
506
|
-
const
|
|
507
|
-
this.conns.forEach((
|
|
482
|
+
const c = D.createEncoder();
|
|
483
|
+
D.writeVarUint(c, fe), D.writeVarUint8Array(c, je(this.awareness, r));
|
|
484
|
+
const l = D.toUint8Array(c);
|
|
485
|
+
this.conns.forEach((p, y) => this.send(y, l));
|
|
508
486
|
};
|
|
509
487
|
updateHandler = (e) => {
|
|
510
488
|
const s = D.createEncoder();
|
|
511
|
-
D.writeVarUint(s, X),
|
|
489
|
+
D.writeVarUint(s, X), Pt(s, e);
|
|
512
490
|
const a = D.toUint8Array(s);
|
|
513
491
|
this.conns.forEach((o, r) => this.send(r, a));
|
|
514
492
|
};
|
|
515
493
|
ensureDataStructure = () => {
|
|
516
|
-
const { supportedLocales: e, pages: s, pageIds: a, config: o, routes: r, routeIds:
|
|
494
|
+
const { supportedLocales: e, pages: s, pageIds: a, config: o, routes: r, routeIds: c } = this.syncedStore;
|
|
517
495
|
{
|
|
518
|
-
const
|
|
519
|
-
let
|
|
520
|
-
for (;
|
|
521
|
-
const
|
|
522
|
-
|
|
496
|
+
const l = new Set(Object.keys(s));
|
|
497
|
+
let p = 0;
|
|
498
|
+
for (; p < a.length; ) {
|
|
499
|
+
const y = a[p];
|
|
500
|
+
l.has(y) ? (l.delete(y), p++) : a.splice(p, 1);
|
|
523
501
|
}
|
|
524
502
|
}
|
|
525
503
|
{
|
|
526
|
-
const
|
|
527
|
-
let
|
|
528
|
-
for (;
|
|
529
|
-
const
|
|
530
|
-
|
|
504
|
+
const l = new Set(Object.keys(r));
|
|
505
|
+
let p = 0;
|
|
506
|
+
for (; p < c.length; ) {
|
|
507
|
+
const y = c[p];
|
|
508
|
+
l.has(y) ? (l.delete(y), p++) : c.splice(p, 1);
|
|
531
509
|
}
|
|
532
510
|
}
|
|
533
|
-
e.splice(0, e.length), e.push(...
|
|
511
|
+
e.splice(0, e.length), e.push(...he.env.languages.map((l) => ({ locale: l.code, name: l.name }))), o.defaultLocale = e[0]?.locale;
|
|
534
512
|
{
|
|
535
|
-
let
|
|
536
|
-
const
|
|
537
|
-
for (;
|
|
538
|
-
const { locale:
|
|
539
|
-
|
|
513
|
+
let l = 0;
|
|
514
|
+
const p = /* @__PURE__ */ new Set();
|
|
515
|
+
for (; l < e.length; ) {
|
|
516
|
+
const { locale: y } = e[l];
|
|
517
|
+
p.has(y) ? e.splice(l, 1) : (l++, p.add(y));
|
|
540
518
|
}
|
|
541
519
|
}
|
|
542
520
|
};
|
|
@@ -553,7 +531,7 @@ class C extends N.Doc {
|
|
|
553
531
|
closeConn = (e) => {
|
|
554
532
|
if (e.removeAllListeners(), this.conns.has(e)) {
|
|
555
533
|
const s = this.conns.get(e);
|
|
556
|
-
this.conns.delete(e), s &&
|
|
534
|
+
this.conns.delete(e), s && wt(this.awareness, Array.from(s), null);
|
|
557
535
|
}
|
|
558
536
|
e.close(), this.checkAndScheduleRelease();
|
|
559
537
|
};
|
|
@@ -564,20 +542,20 @@ class C extends N.Doc {
|
|
|
564
542
|
// 调度延迟释放
|
|
565
543
|
scheduleRelease() {
|
|
566
544
|
this.cancelRelease();
|
|
567
|
-
const e =
|
|
545
|
+
const e = R(this.options.path);
|
|
568
546
|
this.releaseTimer = setTimeout(() => {
|
|
569
547
|
f.info(`[SiteState] releasing instance due to no active connections: ${e}`), this.conns.size === 0 && (this.releaseTimer = void 0, this.destroy());
|
|
570
|
-
},
|
|
548
|
+
}, O.RELEASE_DELAY), f.info(`[SiteState] scheduled release for project ${e} in ${O.RELEASE_DELAY / 1e3}s`);
|
|
571
549
|
}
|
|
572
550
|
// 取消延迟释放
|
|
573
551
|
cancelRelease() {
|
|
574
552
|
if (this.releaseTimer) {
|
|
575
553
|
clearTimeout(this.releaseTimer), this.releaseTimer = void 0;
|
|
576
|
-
const e =
|
|
554
|
+
const e = R(this.options.path);
|
|
577
555
|
f.info(`[SiteState] cancelled scheduled release for project ${e}`);
|
|
578
556
|
}
|
|
579
557
|
}
|
|
580
|
-
autoSave =
|
|
558
|
+
autoSave = Me(() => {
|
|
581
559
|
_(L(this.draftYjsFilePath), { recursive: !0 }), ee(this.draftYjsFilePath, N.encodeStateAsUpdate(this));
|
|
582
560
|
}, Ft);
|
|
583
561
|
save = ({ flush: e = !1 } = {}) => {
|
|
@@ -585,42 +563,38 @@ class C extends N.Doc {
|
|
|
585
563
|
};
|
|
586
564
|
publish = async ({ mode: e, routes: s }) => {
|
|
587
565
|
const a = await this.getState("draft"), o = await this.getState("production");
|
|
588
|
-
await
|
|
566
|
+
await Le(a, o, { routes: s, mergeMode: "replace", deleteRoutes: !0, publishMode: e }), o.config.publishedAt = (/* @__PURE__ */ new Date()).getTime(), Lt(this.syncedStore, s), await this.setState(e, o), await this.clearPageCacheForRoutes(s, o);
|
|
589
567
|
};
|
|
590
568
|
mergeState = async (e, s) => {
|
|
591
569
|
const a = JSON.parse(JSON.stringify(s));
|
|
592
570
|
e.config.fontFamily ??= {};
|
|
593
571
|
const o = a.config?.fontFamily, r = e.config?.fontFamily;
|
|
594
|
-
e.config.fontFamily.title = o?.title || r?.title, e.config.fontFamily.description = o?.description || r?.description, await new Promise((
|
|
572
|
+
e.config.fontFamily.title = o?.title || r?.title, e.config.fontFamily.description = o?.description || r?.description, await new Promise((c, l) => {
|
|
595
573
|
this.transact(async () => {
|
|
596
574
|
try {
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
} catch (
|
|
600
|
-
|
|
575
|
+
const p = await Le(e, s);
|
|
576
|
+
c(p);
|
|
577
|
+
} catch (p) {
|
|
578
|
+
l(p);
|
|
601
579
|
}
|
|
602
580
|
});
|
|
603
581
|
});
|
|
604
582
|
};
|
|
605
583
|
clearPageCacheForRoutes = async (e, s) => {
|
|
606
|
-
const a =
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
});
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const i = s.supportedLocales.map((m) => m.locale), c = [], l = e.filter((m) => s.pages[m]);
|
|
616
|
-
for (const m of l) {
|
|
617
|
-
const O = s.pages[m].slug;
|
|
618
|
-
r && r !== a && (r === "/" ? c.push(O) : c.push(`/${r}${O}`)), c.push(`/${a}${O}`);
|
|
619
|
-
}
|
|
620
|
-
if (f.info(`[SiteState] clearing page cache for project ${a}, pathPatterns:`, c), c.length > 0) {
|
|
621
|
-
const m = $t(c, i);
|
|
622
|
-
f.info(`[SiteState] cleared ${m} page cache entries for project ${a}, routes:`, e);
|
|
584
|
+
const a = R(this.options.path), r = (await M.findByPk(a))?.slug || a;
|
|
585
|
+
let c = e;
|
|
586
|
+
(!c || c.length === 0) && (c = s.pageIds ?? []), f.info(`[SiteState] clearing page cache for project ${a}, routes:`, c || []);
|
|
587
|
+
const l = s.supportedLocales.map((w) => w.locale), p = [], y = c.filter((w) => s.pageIds?.includes(w));
|
|
588
|
+
for (const w of y) {
|
|
589
|
+
const I = s.pages[w].slug;
|
|
590
|
+
r && r !== a && (r === "/" ? p.push(I) : p.push(`/${r}${I}`)), p.push(`/${a}${I}`);
|
|
623
591
|
}
|
|
592
|
+
if (f.info(`[SiteState] clearing page cache for project ${a}, pathPatterns:`, p), p.length > 0)
|
|
593
|
+
try {
|
|
594
|
+
const w = Ut(p, l);
|
|
595
|
+
f.info(`[SiteState] cleared ${w} page cache entries for project ${a}, routes:`, c);
|
|
596
|
+
} catch {
|
|
597
|
+
}
|
|
624
598
|
};
|
|
625
599
|
addConnection = (e) => {
|
|
626
600
|
if (this.conns.has(e))
|
|
@@ -646,23 +620,23 @@ class C extends N.Doc {
|
|
|
646
620
|
});
|
|
647
621
|
{
|
|
648
622
|
const o = D.createEncoder();
|
|
649
|
-
D.writeVarUint(o, X),
|
|
623
|
+
D.writeVarUint(o, X), Ct(o, this), this.send(e, D.toUint8Array(o));
|
|
650
624
|
const r = this.awareness.getStates();
|
|
651
625
|
if (r.size > 0) {
|
|
652
|
-
const
|
|
653
|
-
D.writeVarUint(
|
|
626
|
+
const c = D.createEncoder();
|
|
627
|
+
D.writeVarUint(c, fe), D.writeVarUint8Array(c, je(this.awareness, Array.from(r.keys()))), this.send(e, D.toUint8Array(c));
|
|
654
628
|
}
|
|
655
629
|
}
|
|
656
630
|
};
|
|
657
631
|
messageListener = (e, s) => {
|
|
658
632
|
try {
|
|
659
|
-
const a = D.createEncoder(), o =
|
|
633
|
+
const a = D.createEncoder(), o = ue.createDecoder(s), r = ue.readVarUint(o);
|
|
660
634
|
switch (r) {
|
|
661
635
|
case X:
|
|
662
|
-
D.writeVarUint(a, X),
|
|
636
|
+
D.writeVarUint(a, X), Ot(o, a, this, null), D.length(a) > 1 && (this.ensureDataStructure(), this.send(e, D.toUint8Array(a)));
|
|
663
637
|
break;
|
|
664
638
|
case fe: {
|
|
665
|
-
|
|
639
|
+
At(this.awareness, ue.readVarUint8Array(o), e);
|
|
666
640
|
break;
|
|
667
641
|
}
|
|
668
642
|
default:
|
|
@@ -679,10 +653,10 @@ class C extends N.Doc {
|
|
|
679
653
|
s ? a = [s] : a = await this.getProjectIds();
|
|
680
654
|
let o = {};
|
|
681
655
|
if (e === "production" && a?.length) {
|
|
682
|
-
const r = new Map(a?.map((
|
|
683
|
-
for (const
|
|
684
|
-
const
|
|
685
|
-
|
|
656
|
+
const r = new Map(a?.map((c) => [c, !0]) || []);
|
|
657
|
+
for (const c of a) {
|
|
658
|
+
const l = O.pageUrlMapCache.get(c);
|
|
659
|
+
l && (o = { ...o, ...l }, r.delete(c));
|
|
686
660
|
}
|
|
687
661
|
a = Array.from(r.keys());
|
|
688
662
|
}
|
|
@@ -690,94 +664,94 @@ class C extends N.Doc {
|
|
|
690
664
|
const r = await M.findAll({
|
|
691
665
|
where: {
|
|
692
666
|
id: {
|
|
693
|
-
[
|
|
667
|
+
[Fe.in]: a
|
|
694
668
|
}
|
|
695
669
|
}
|
|
696
670
|
});
|
|
697
671
|
await Promise.all(
|
|
698
|
-
r?.map(async (
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
),
|
|
703
|
-
|
|
704
|
-
...
|
|
672
|
+
r?.map(async (c) => {
|
|
673
|
+
const l = c.id, p = c.slug || l, y = {}, w = e === "production" && c?.productionState ? c.productionState : await O.getStateByProjectId(c.id, e), j = gt(
|
|
674
|
+
b.env.languages?.map((u) => u.code) || [],
|
|
675
|
+
w.supportedLocales?.map((u) => u.locale) || []
|
|
676
|
+
), I = (u, i) => {
|
|
677
|
+
p && (y[H("/", p, u)] = {
|
|
678
|
+
...i,
|
|
705
679
|
shouldRedirect: !0,
|
|
706
680
|
mainPage: !0
|
|
707
|
-
}),
|
|
708
|
-
...
|
|
681
|
+
}), y[H("/", l, u)] = {
|
|
682
|
+
...i,
|
|
709
683
|
shouldRedirect: !0,
|
|
710
684
|
mainPage: !0
|
|
711
685
|
};
|
|
712
|
-
for (const g of
|
|
713
|
-
const
|
|
714
|
-
|
|
686
|
+
for (const g of j) {
|
|
687
|
+
const C = { ...i, locale: g };
|
|
688
|
+
y[H("/", g, l, u)] = C, p && (y[H("/", g, p, u)] = C);
|
|
715
689
|
}
|
|
716
690
|
};
|
|
717
691
|
if (e === "draft")
|
|
718
|
-
for (const
|
|
719
|
-
const
|
|
720
|
-
if (!
|
|
721
|
-
if (
|
|
722
|
-
const
|
|
723
|
-
basePath:
|
|
724
|
-
params:
|
|
725
|
-
routeId:
|
|
726
|
-
paramsOptions:
|
|
692
|
+
for (const u of w.routeIds || []) {
|
|
693
|
+
const i = w?.routes?.[u];
|
|
694
|
+
if (!i) continue;
|
|
695
|
+
if (i.params && i.params.length > 0) {
|
|
696
|
+
const m = Se({
|
|
697
|
+
basePath: i.path,
|
|
698
|
+
params: i.params,
|
|
699
|
+
routeId: i.id,
|
|
700
|
+
paramsOptions: i.paramsOptions,
|
|
727
701
|
currentIndex: 0,
|
|
728
702
|
currentParams: [],
|
|
729
703
|
currentOptionIds: [],
|
|
730
704
|
result: []
|
|
731
705
|
});
|
|
732
|
-
for (const
|
|
733
|
-
const
|
|
734
|
-
projectId:
|
|
735
|
-
projectSlug:
|
|
736
|
-
pageSlug:
|
|
737
|
-
pageId:
|
|
738
|
-
routeId:
|
|
706
|
+
for (const d of m) {
|
|
707
|
+
const h = d.path, A = {
|
|
708
|
+
projectId: l,
|
|
709
|
+
projectSlug: p,
|
|
710
|
+
pageSlug: h,
|
|
711
|
+
pageId: i.displayTemplateId || "",
|
|
712
|
+
routeId: u,
|
|
739
713
|
// default locale
|
|
740
|
-
defaultLocale:
|
|
741
|
-
locales:
|
|
742
|
-
publishedAt:
|
|
743
|
-
isPublic:
|
|
714
|
+
defaultLocale: j?.[0],
|
|
715
|
+
locales: j,
|
|
716
|
+
publishedAt: w.config.publishedAt,
|
|
717
|
+
isPublic: i.isPublic && d?.routeMetaData?.isPublic
|
|
744
718
|
};
|
|
745
|
-
|
|
719
|
+
I(h, A);
|
|
746
720
|
}
|
|
747
721
|
}
|
|
748
|
-
const g =
|
|
749
|
-
projectId:
|
|
750
|
-
projectSlug:
|
|
722
|
+
const g = i.path, C = {
|
|
723
|
+
projectId: l,
|
|
724
|
+
projectSlug: p,
|
|
751
725
|
pageSlug: g,
|
|
752
|
-
pageId:
|
|
753
|
-
routeId:
|
|
726
|
+
pageId: i.displayTemplateId || "",
|
|
727
|
+
routeId: u,
|
|
754
728
|
// default locale
|
|
755
|
-
defaultLocale:
|
|
756
|
-
locales:
|
|
757
|
-
publishedAt:
|
|
758
|
-
isPublic:
|
|
729
|
+
defaultLocale: j?.[0],
|
|
730
|
+
locales: j,
|
|
731
|
+
publishedAt: w.config.publishedAt,
|
|
732
|
+
isPublic: i.isPublic
|
|
759
733
|
};
|
|
760
|
-
|
|
734
|
+
I(g, C);
|
|
761
735
|
}
|
|
762
|
-
for (const
|
|
763
|
-
const
|
|
764
|
-
if (!
|
|
736
|
+
for (const u of w.pageIds) {
|
|
737
|
+
const i = w.pages[u];
|
|
738
|
+
if (!i || e === "production" && !i.isPublic)
|
|
765
739
|
continue;
|
|
766
|
-
const g =
|
|
767
|
-
projectId:
|
|
768
|
-
projectSlug:
|
|
740
|
+
const g = i.slug, C = c.slug || l, m = {
|
|
741
|
+
projectId: l,
|
|
742
|
+
projectSlug: C,
|
|
769
743
|
pageSlug: g,
|
|
770
|
-
pageId:
|
|
744
|
+
pageId: u,
|
|
771
745
|
// default locale
|
|
772
|
-
defaultLocale:
|
|
773
|
-
locales:
|
|
774
|
-
publishedAt:
|
|
775
|
-
isPublic:
|
|
776
|
-
templateConfig:
|
|
746
|
+
defaultLocale: j?.[0],
|
|
747
|
+
locales: j,
|
|
748
|
+
publishedAt: w.config.publishedAt,
|
|
749
|
+
isPublic: i.isPublic,
|
|
750
|
+
templateConfig: i.templateConfig
|
|
777
751
|
};
|
|
778
|
-
|
|
752
|
+
I(g, m);
|
|
779
753
|
}
|
|
780
|
-
e === "production" &&
|
|
754
|
+
e === "production" && O.pageUrlMapCache.set(l, y), o = { ...o, ...y };
|
|
781
755
|
})
|
|
782
756
|
);
|
|
783
757
|
}
|
|
@@ -788,7 +762,7 @@ class C extends N.Doc {
|
|
|
788
762
|
}
|
|
789
763
|
static getInstancesSizeInfo() {
|
|
790
764
|
const e = [];
|
|
791
|
-
for (const [s, a] of Object.entries(
|
|
765
|
+
for (const [s, a] of Object.entries(O.sharedInstances)) {
|
|
792
766
|
const o = a.getDocumentSize();
|
|
793
767
|
e.push({
|
|
794
768
|
projectId: s,
|
|
@@ -813,8 +787,8 @@ class C extends N.Doc {
|
|
|
813
787
|
}
|
|
814
788
|
// 执行定期检查
|
|
815
789
|
static performPeriodicCheck() {
|
|
816
|
-
const e = Object.keys(
|
|
817
|
-
for (const [o, r] of Object.entries(
|
|
790
|
+
const e = Object.keys(O.sharedInstances).length, s = [], a = [];
|
|
791
|
+
for (const [o, r] of Object.entries(O.sharedInstances))
|
|
818
792
|
r.conns.size === 0 ? s.push({ projectId: o, instance: r }) : a.push({ projectId: o, connections: r.conns.size });
|
|
819
793
|
if (f.info(
|
|
820
794
|
`[SiteState] periodic check summary: total instances: ${e}, with connections: ${a.length}, without connections: ${s.length}`
|
|
@@ -824,11 +798,11 @@ class C extends N.Doc {
|
|
|
824
798
|
s.map((r) => r.projectId)
|
|
825
799
|
);
|
|
826
800
|
let o = 0;
|
|
827
|
-
for (const { projectId: r, instance:
|
|
801
|
+
for (const { projectId: r, instance: c } of s)
|
|
828
802
|
try {
|
|
829
|
-
f.info(`[SiteState] releasing instance due to periodic check: ${r}`),
|
|
830
|
-
} catch (
|
|
831
|
-
f.error(`[SiteState] failed to release instance ${r} during periodic check:`,
|
|
803
|
+
f.info(`[SiteState] releasing instance due to periodic check: ${r}`), c.destroy(), o++;
|
|
804
|
+
} catch (l) {
|
|
805
|
+
f.error(`[SiteState] failed to release instance ${r} during periodic check:`, l);
|
|
832
806
|
}
|
|
833
807
|
f.info(
|
|
834
808
|
`[SiteState] periodic check completed: ${o}/${s.length} instances released successfully`
|
|
@@ -852,45 +826,45 @@ async function Vt(t, e, s) {
|
|
|
852
826
|
})(), s[t] = a), a;
|
|
853
827
|
}
|
|
854
828
|
const zt = async (t, e) => {
|
|
855
|
-
const s =
|
|
856
|
-
name:
|
|
857
|
-
path:
|
|
829
|
+
const s = R(t), a = await dt({
|
|
830
|
+
name: _e,
|
|
831
|
+
path: H("/uploads", s),
|
|
858
832
|
responseType: "stream",
|
|
859
833
|
method: "GET"
|
|
860
834
|
});
|
|
861
835
|
if (a.status >= 200 && a.status < 400) {
|
|
862
|
-
const o =
|
|
863
|
-
await
|
|
836
|
+
const o = it(e);
|
|
837
|
+
await St(a.data, o);
|
|
864
838
|
} else
|
|
865
839
|
throw new Error(`download asset failed ${a.status}`);
|
|
866
840
|
}, Jt = async (t, e) => {
|
|
867
841
|
await Promise.all(
|
|
868
842
|
t.map(async (s) => {
|
|
869
843
|
try {
|
|
870
|
-
await zt(s, E(e,
|
|
844
|
+
await zt(s, E(e, R(s)));
|
|
871
845
|
} catch (a) {
|
|
872
846
|
f.error(`Failed to export assets: ${s}, ${a}`);
|
|
873
847
|
}
|
|
874
848
|
})
|
|
875
849
|
);
|
|
876
850
|
};
|
|
877
|
-
function
|
|
878
|
-
return Ae.test(t) ? [t] : W.test(t) ? (
|
|
851
|
+
function Be(t) {
|
|
852
|
+
return Ae.test(t) ? [t] : W.test(t) ? (Te.lastIndex = 0, Array.from(t.matchAll(Te)).map((s) => s[1]).filter((s) => !!s)) : [];
|
|
879
853
|
}
|
|
880
854
|
async function Z(t, e, s) {
|
|
881
855
|
const { getFilename: a, exportAssets: o } = s, r = E(e, a(t));
|
|
882
856
|
if (_(L(r), { recursive: !0 }), ee(r, G.stringify(t)), o) {
|
|
883
|
-
const
|
|
857
|
+
const l = ae(
|
|
884
858
|
t,
|
|
885
|
-
(
|
|
886
|
-
).map((
|
|
887
|
-
const
|
|
888
|
-
return
|
|
859
|
+
(p) => typeof p == "string" && (Ae.test(p) || W.test(p))
|
|
860
|
+
).map((p) => {
|
|
861
|
+
const y = Ie(t, p);
|
|
862
|
+
return Be(y);
|
|
889
863
|
}).flat().filter(Boolean);
|
|
890
|
-
await Jt(
|
|
864
|
+
await Jt(l, L(r));
|
|
891
865
|
}
|
|
892
866
|
}
|
|
893
|
-
const ye = new
|
|
867
|
+
const ye = new Ee({
|
|
894
868
|
max: 100,
|
|
895
869
|
ttl: 1 * 60 * 1e3
|
|
896
870
|
// 1 minute
|
|
@@ -898,26 +872,26 @@ const ye = new be({
|
|
|
898
872
|
async function Re(t, e, s) {
|
|
899
873
|
const a = ae(
|
|
900
874
|
t,
|
|
901
|
-
(
|
|
875
|
+
(l) => typeof l == "string" && (Ae.test(l) || W.test(l))
|
|
902
876
|
), o = ht(2), r = a.map(
|
|
903
|
-
(
|
|
877
|
+
(l) => o(async () => {
|
|
904
878
|
try {
|
|
905
|
-
const
|
|
906
|
-
for (const
|
|
907
|
-
const
|
|
908
|
-
if (
|
|
909
|
-
W.test(
|
|
879
|
+
const p = Ie(t, l), y = Be(p);
|
|
880
|
+
for (const w of y) {
|
|
881
|
+
const j = R(w), I = s.getFilePath(w, l), u = I ? `${I}:${j}` : j, i = ye.get(u);
|
|
882
|
+
if (i) {
|
|
883
|
+
W.test(p) || ve(t, l, i);
|
|
910
884
|
return;
|
|
911
885
|
}
|
|
912
|
-
const g = await Vt(
|
|
913
|
-
g && (W.test(
|
|
886
|
+
const g = await Vt(I, j, e);
|
|
887
|
+
g && (W.test(p) || ve(t, l, g), ye.set(u, g));
|
|
914
888
|
}
|
|
915
|
-
} catch (
|
|
916
|
-
f.error(`Failed to process upload for path ${
|
|
889
|
+
} catch (p) {
|
|
890
|
+
f.error(`Failed to process upload for path ${l.join(".")}:`, p.message || p.reason);
|
|
917
891
|
}
|
|
918
892
|
})
|
|
919
|
-
),
|
|
920
|
-
s.onFinish?.(
|
|
893
|
+
), c = await Promise.allSettled(r);
|
|
894
|
+
s.onFinish?.(c);
|
|
921
895
|
}
|
|
922
896
|
async function Kt(t, {
|
|
923
897
|
exportAssets: e,
|
|
@@ -925,13 +899,13 @@ async function Kt(t, {
|
|
|
925
899
|
componentIds: a = "all",
|
|
926
900
|
rawConfig: o,
|
|
927
901
|
includeResources: r = !1,
|
|
928
|
-
routeIds:
|
|
902
|
+
routeIds: c = "all"
|
|
929
903
|
} = {}) {
|
|
930
|
-
const
|
|
904
|
+
const l = s === "all" ? t.pageIds : s, p = pt({
|
|
931
905
|
state: t,
|
|
932
|
-
pageIds:
|
|
906
|
+
pageIds: l,
|
|
933
907
|
componentIds: a === "all" ? Object.keys(t.components) : a
|
|
934
|
-
}),
|
|
908
|
+
}), y = c === "all" ? t.routeIds : c, w = (n) => ({
|
|
935
909
|
id: n.id,
|
|
936
910
|
name: n.name,
|
|
937
911
|
isTemplateSection: n.isTemplateSection ?? !1,
|
|
@@ -940,15 +914,15 @@ async function Kt(t, {
|
|
|
940
914
|
component: n.component,
|
|
941
915
|
config: n.config,
|
|
942
916
|
visibility: n.visibility,
|
|
943
|
-
sections: n?.sectionIds ?
|
|
917
|
+
sections: n?.sectionIds ? T(
|
|
944
918
|
n?.sectionIds?.map((S) => {
|
|
945
919
|
const v = n.sections?.[S];
|
|
946
|
-
return v &&
|
|
920
|
+
return v && w(v);
|
|
947
921
|
})
|
|
948
922
|
) : void 0
|
|
949
923
|
// 已经废弃,数据在 page.dataSource 中管理
|
|
950
924
|
// properties: section.locales?.[locale] ?? {},
|
|
951
|
-
}),
|
|
925
|
+
}), j = (n, S) => ({
|
|
952
926
|
id: n.id,
|
|
953
927
|
createdAt: n.createdAt,
|
|
954
928
|
updatedAt: n.updatedAt,
|
|
@@ -956,17 +930,17 @@ async function Kt(t, {
|
|
|
956
930
|
isPublic: n.isPublic ?? !0,
|
|
957
931
|
templateConfig: n.templateConfig,
|
|
958
932
|
meta: n.locales?.[S] ?? {},
|
|
959
|
-
sections:
|
|
933
|
+
sections: T(
|
|
960
934
|
n.sectionIds.map((v) => {
|
|
961
935
|
const x = n.sections[v];
|
|
962
|
-
return x &&
|
|
936
|
+
return x && w(x);
|
|
963
937
|
})
|
|
964
938
|
),
|
|
965
939
|
// 将 dataSource.sectionId.locale 转换为 dataSource.sectionId
|
|
966
940
|
dataSource: Object.fromEntries(
|
|
967
941
|
Object.entries(n.dataSource || {}).map(([v, x]) => [v, x?.[S] ?? {}])
|
|
968
942
|
)
|
|
969
|
-
}),
|
|
943
|
+
}), I = (n) => ({
|
|
970
944
|
id: n.id,
|
|
971
945
|
createdAt: n.createdAt,
|
|
972
946
|
updatedAt: n.updatedAt,
|
|
@@ -978,63 +952,63 @@ async function Kt(t, {
|
|
|
978
952
|
enabledGenerate: n.enabledGenerate ?? !1,
|
|
979
953
|
displayTemplateId: n.displayTemplateId,
|
|
980
954
|
dataSource: n.dataSource
|
|
981
|
-
}),
|
|
982
|
-
|
|
955
|
+
}), u = T(
|
|
956
|
+
y.map((n) => {
|
|
983
957
|
const S = t.routes[n];
|
|
984
|
-
return S &&
|
|
958
|
+
return S && I(S);
|
|
985
959
|
})
|
|
986
|
-
),
|
|
960
|
+
), i = T(
|
|
987
961
|
t.supportedLocales.map((n) => n.locale).flatMap(
|
|
988
|
-
(n) =>
|
|
962
|
+
(n) => l.map((S) => {
|
|
989
963
|
const v = t.pages[S];
|
|
990
964
|
return v && {
|
|
991
965
|
locale: n,
|
|
992
966
|
slug: v.slug,
|
|
993
|
-
page:
|
|
967
|
+
page: j(v, n)
|
|
994
968
|
};
|
|
995
969
|
})
|
|
996
970
|
)
|
|
997
|
-
), g =
|
|
998
|
-
_(
|
|
999
|
-
const
|
|
1000
|
-
_(
|
|
1001
|
-
const
|
|
1002
|
-
_(
|
|
1003
|
-
for (const { locale: n, slug: S, page: v } of
|
|
1004
|
-
await Z(v,
|
|
971
|
+
), g = xe(), C = E(g, "pages");
|
|
972
|
+
_(C, { recursive: !0 });
|
|
973
|
+
const m = E(g, "components");
|
|
974
|
+
_(m, { recursive: !0 });
|
|
975
|
+
const d = E(g, "routes");
|
|
976
|
+
_(d, { recursive: !0 });
|
|
977
|
+
for (const { locale: n, slug: S, page: v } of i)
|
|
978
|
+
await Z(v, C, {
|
|
1005
979
|
getFilename: () => `${oe(S) || "index"}.${n}.yml`,
|
|
1006
980
|
exportAssets: e
|
|
1007
981
|
});
|
|
1008
|
-
for (const n of
|
|
1009
|
-
await Z(n,
|
|
982
|
+
for (const n of u)
|
|
983
|
+
await Z(n, d, {
|
|
1010
984
|
// getFilename: () => `${sanitizeSlug(route.path)}.yml`,
|
|
1011
985
|
getFilename: () => `${oe(n.path) || "index"}.yml`,
|
|
1012
986
|
exportAssets: e
|
|
1013
987
|
});
|
|
1014
|
-
for (const n of
|
|
988
|
+
for (const n of p) {
|
|
1015
989
|
const S = t.components[n]?.data;
|
|
1016
|
-
S && await Z(S,
|
|
990
|
+
S && await Z(S, m, {
|
|
1017
991
|
getFilename: (v) => `${v.name || "unnamed"}.${v.id}.yml`,
|
|
1018
992
|
exportAssets: e
|
|
1019
993
|
});
|
|
1020
994
|
}
|
|
1021
|
-
const
|
|
1022
|
-
_(L(
|
|
1023
|
-
const
|
|
1024
|
-
pages:
|
|
1025
|
-
|
|
995
|
+
const h = E(g, ".blocklet/pages/pages.config.yml");
|
|
996
|
+
_(L(h), { recursive: !0 });
|
|
997
|
+
const A = {
|
|
998
|
+
pages: T(
|
|
999
|
+
l.map((n) => {
|
|
1026
1000
|
const S = t.pages[n];
|
|
1027
1001
|
return S && { id: n, slug: S.slug };
|
|
1028
1002
|
})
|
|
1029
1003
|
),
|
|
1030
|
-
routes:
|
|
1031
|
-
|
|
1004
|
+
routes: T(
|
|
1005
|
+
y.map((n) => {
|
|
1032
1006
|
const S = t.routes[n];
|
|
1033
1007
|
return S && { id: n, path: S.path };
|
|
1034
1008
|
})
|
|
1035
1009
|
),
|
|
1036
|
-
components:
|
|
1037
|
-
|
|
1010
|
+
components: T(
|
|
1011
|
+
p.map((n) => {
|
|
1038
1012
|
const S = t.components[n]?.data;
|
|
1039
1013
|
return S && {
|
|
1040
1014
|
id: n,
|
|
@@ -1044,8 +1018,8 @@ async function Kt(t, {
|
|
|
1044
1018
|
),
|
|
1045
1019
|
...r ? {
|
|
1046
1020
|
resources: {
|
|
1047
|
-
components:
|
|
1048
|
-
Object.keys(t.resources?.components || {}).filter((n) =>
|
|
1021
|
+
components: T(
|
|
1022
|
+
Object.keys(t.resources?.components || {}).filter((n) => p.includes(n)).map((n) => ({
|
|
1049
1023
|
id: n,
|
|
1050
1024
|
name: t.resources?.components?.[n]?.component?.name
|
|
1051
1025
|
}))
|
|
@@ -1055,36 +1029,36 @@ async function Kt(t, {
|
|
|
1055
1029
|
supportedLocales: t.supportedLocales,
|
|
1056
1030
|
config: t.config
|
|
1057
1031
|
};
|
|
1058
|
-
ee(
|
|
1059
|
-
const
|
|
1060
|
-
if (o && ee(
|
|
1032
|
+
ee(h, G.stringify(A));
|
|
1033
|
+
const P = E(g, "config.source.json");
|
|
1034
|
+
if (o && ee(P, JSON.stringify(o)), r) {
|
|
1061
1035
|
const n = E(g, "resources"), S = E(n, "components");
|
|
1062
1036
|
_(S, { recursive: !0 });
|
|
1063
|
-
for (const
|
|
1064
|
-
($) =>
|
|
1037
|
+
for (const z of Object.keys(t?.resources?.components ?? {}).filter(
|
|
1038
|
+
($) => p.includes($)
|
|
1065
1039
|
)) {
|
|
1066
|
-
const $ = t.resources?.components?.[
|
|
1040
|
+
const $ = t.resources?.components?.[z]?.component;
|
|
1067
1041
|
$ && await Z($, S, {
|
|
1068
|
-
getFilename: (
|
|
1042
|
+
getFilename: (J) => `${J.name || "unnamed"}.${J.id}.yml`,
|
|
1069
1043
|
exportAssets: e
|
|
1070
1044
|
});
|
|
1071
1045
|
}
|
|
1072
1046
|
const v = E(g, "chunks");
|
|
1073
1047
|
_(v, { recursive: !0 });
|
|
1074
1048
|
const x = qt();
|
|
1075
|
-
for (const
|
|
1076
|
-
($) =>
|
|
1049
|
+
for (const z of Object.keys(t?.resources?.components ?? {}).filter(
|
|
1050
|
+
($) => p.includes($)
|
|
1077
1051
|
)) {
|
|
1078
|
-
const $ = t.resources?.components?.[
|
|
1052
|
+
const $ = t.resources?.components?.[z]?.component;
|
|
1079
1053
|
if ($ && $.renderer?.type === "react-component") {
|
|
1080
|
-
const
|
|
1081
|
-
if (
|
|
1082
|
-
for (const pe of
|
|
1054
|
+
const J = $.renderer?.chunks ?? [];
|
|
1055
|
+
if (J?.length > 0)
|
|
1056
|
+
for (const pe of J) {
|
|
1083
1057
|
const Pe = E(v, pe), le = x?.[pe];
|
|
1084
1058
|
try {
|
|
1085
|
-
le && U(le) && !U(Pe) &&
|
|
1086
|
-
} catch (
|
|
1087
|
-
f.error(`copy chunk ${pe} error`,
|
|
1059
|
+
le && U(le) && !U(Pe) && rt(le, Pe);
|
|
1060
|
+
} catch (Ye) {
|
|
1061
|
+
f.error(`copy chunk ${pe} error`, Ye.message);
|
|
1088
1062
|
}
|
|
1089
1063
|
}
|
|
1090
1064
|
}
|
|
@@ -1092,75 +1066,75 @@ async function Kt(t, {
|
|
|
1092
1066
|
}
|
|
1093
1067
|
return g;
|
|
1094
1068
|
}
|
|
1095
|
-
async function
|
|
1069
|
+
async function Ge(t, { importAssets: e, includeResources: s } = {}) {
|
|
1096
1070
|
if (!U(t))
|
|
1097
1071
|
return null;
|
|
1098
1072
|
let a, o = !1;
|
|
1099
1073
|
try {
|
|
1100
|
-
B(t).isDirectory() ? a = t : /\.(tgz|gz|tar)$/.test(t) && (o = !0, a =
|
|
1101
|
-
const r = te("**/.blocklet/pages/pages.config.yml", { cwd: a, absolute: !0 }).at(0),
|
|
1074
|
+
B(t).isDirectory() ? a = t : /\.(tgz|gz|tar)$/.test(t) && (o = !0, a = xe(), await It({ file: t, C: a }));
|
|
1075
|
+
const r = te("**/.blocklet/pages/pages.config.yml", { cwd: a, absolute: !0 }).at(0), c = r && E(L(r), "../../pages"), l = r && E(L(r), "../../components"), p = r && E(L(r), "../../routes");
|
|
1102
1076
|
if (!r)
|
|
1103
1077
|
return null;
|
|
1104
|
-
const
|
|
1105
|
-
let
|
|
1106
|
-
return (!U(
|
|
1107
|
-
},
|
|
1078
|
+
const y = G.parse(q(r).toString()), w = (m, d, h) => {
|
|
1079
|
+
let A = E(m, `${d}${h ? `.${h}` : ""}.yml`);
|
|
1080
|
+
return (!U(A) || !B(A).isFile()) && (A = E(m, d, `index${h ? `.${h}` : ""}.yml`), !U(A) || !B(A)) ? null : G.parse(q(A).toString());
|
|
1081
|
+
}, j = (m, d) => {
|
|
1108
1082
|
try {
|
|
1109
|
-
const
|
|
1110
|
-
return
|
|
1111
|
-
} catch (
|
|
1112
|
-
f.error("parse component error",
|
|
1083
|
+
const h = te(`*.${d}.yml`, { cwd: m, absolute: !0 })[0];
|
|
1084
|
+
return h ? G.parse(q(h).toString()) : null;
|
|
1085
|
+
} catch (h) {
|
|
1086
|
+
f.error("parse component error", h);
|
|
1113
1087
|
}
|
|
1114
1088
|
return null;
|
|
1115
|
-
},
|
|
1116
|
-
let
|
|
1117
|
-
return (!U(
|
|
1118
|
-
},
|
|
1119
|
-
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
const n =
|
|
1089
|
+
}, I = (m, d) => {
|
|
1090
|
+
let h = E(m, `${d}.yml`);
|
|
1091
|
+
return (!U(h) || !B(h).isFile()) && (h = E(m, d, "index.yml"), !U(h) || !B(h)) ? null : G.parse(q(h).toString());
|
|
1092
|
+
}, u = T(
|
|
1093
|
+
y.pages.map(({ slug: m }) => {
|
|
1094
|
+
const d = T(
|
|
1095
|
+
y.supportedLocales.map(({ locale: P }) => {
|
|
1096
|
+
const n = c ? w(c, oe(m), P) : void 0;
|
|
1123
1097
|
if (n)
|
|
1124
|
-
return { locale:
|
|
1125
|
-
const S =
|
|
1126
|
-
return S && { locale:
|
|
1098
|
+
return { locale: P, page: n };
|
|
1099
|
+
const S = c ? w(c, m, P) : void 0;
|
|
1100
|
+
return S && { locale: P, page: S };
|
|
1127
1101
|
})
|
|
1128
|
-
),
|
|
1129
|
-
if (!
|
|
1102
|
+
), h = d[0]?.page;
|
|
1103
|
+
if (!h)
|
|
1130
1104
|
return null;
|
|
1131
|
-
const
|
|
1105
|
+
const A = h.sections.map(ct);
|
|
1132
1106
|
return {
|
|
1133
|
-
id:
|
|
1134
|
-
createdAt:
|
|
1135
|
-
updatedAt:
|
|
1136
|
-
publishedAt:
|
|
1137
|
-
isPublic:
|
|
1138
|
-
templateConfig:
|
|
1139
|
-
slug:
|
|
1140
|
-
sections: Object.fromEntries(
|
|
1141
|
-
sectionIds:
|
|
1142
|
-
locales: Object.fromEntries(
|
|
1143
|
-
dataSource:
|
|
1107
|
+
id: h.id || Oe(),
|
|
1108
|
+
createdAt: h.createdAt,
|
|
1109
|
+
updatedAt: h.updatedAt,
|
|
1110
|
+
publishedAt: h.publishedAt,
|
|
1111
|
+
isPublic: h.isPublic ?? !0,
|
|
1112
|
+
templateConfig: h.templateConfig,
|
|
1113
|
+
slug: m,
|
|
1114
|
+
sections: Object.fromEntries(A.map((P) => [P.id, P])),
|
|
1115
|
+
sectionIds: A.map((P) => P.id),
|
|
1116
|
+
locales: Object.fromEntries(d.map(({ locale: P, page: n }) => [P, n.meta])),
|
|
1117
|
+
dataSource: h.dataSource ? Object.fromEntries(
|
|
1144
1118
|
// 获取 dataSource 中所有 section ID
|
|
1145
|
-
[...new Set(
|
|
1146
|
-
|
|
1119
|
+
[...new Set(d.flatMap(({ page: P }) => Object.keys(P.dataSource ?? {})))].map((P) => [
|
|
1120
|
+
P,
|
|
1147
1121
|
Object.fromEntries(
|
|
1148
|
-
|
|
1149
|
-
const v = S.dataSource?.[
|
|
1122
|
+
d.map(({ locale: n, page: S }) => {
|
|
1123
|
+
const v = S.dataSource?.[P];
|
|
1150
1124
|
return [n, v || {}];
|
|
1151
1125
|
})
|
|
1152
1126
|
)
|
|
1153
1127
|
])
|
|
1154
1128
|
) : Object.fromEntries(
|
|
1155
1129
|
// 获取所有 section ID
|
|
1156
|
-
[...new Set(
|
|
1157
|
-
|
|
1130
|
+
[...new Set(d.flatMap(({ page: P }) => P.sections.map((n) => n.id)))].map((P) => [
|
|
1131
|
+
P,
|
|
1158
1132
|
Object.fromEntries(
|
|
1159
|
-
|
|
1160
|
-
const v = S.dataSource?.[
|
|
1133
|
+
d.map(({ locale: n, page: S }) => {
|
|
1134
|
+
const v = S.dataSource?.[P];
|
|
1161
1135
|
if (v)
|
|
1162
1136
|
return [n, v];
|
|
1163
|
-
const x = S.sections.find((
|
|
1137
|
+
const x = S.sections.find((z) => z.id === P);
|
|
1164
1138
|
return [n, x?.properties || {}];
|
|
1165
1139
|
})
|
|
1166
1140
|
)
|
|
@@ -1168,99 +1142,99 @@ async function Be(t, { importAssets: e, includeResources: s } = {}) {
|
|
|
1168
1142
|
)
|
|
1169
1143
|
};
|
|
1170
1144
|
})
|
|
1171
|
-
),
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1145
|
+
), i = T(
|
|
1146
|
+
y?.routes?.map(({ path: m }) => {
|
|
1147
|
+
const d = p ? I(p, oe(m)) : void 0;
|
|
1174
1148
|
return {
|
|
1175
|
-
...
|
|
1176
|
-
id:
|
|
1177
|
-
createdAt:
|
|
1178
|
-
updatedAt:
|
|
1149
|
+
...d,
|
|
1150
|
+
id: d?.id || Oe(),
|
|
1151
|
+
createdAt: d?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1152
|
+
updatedAt: d?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1179
1153
|
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1180
|
-
path:
|
|
1181
|
-
params:
|
|
1182
|
-
handler:
|
|
1183
|
-
isPublic:
|
|
1184
|
-
enabledGenerate:
|
|
1185
|
-
displayTemplateId:
|
|
1186
|
-
dataSource:
|
|
1154
|
+
path: d?.path ?? `/${d?.id}`,
|
|
1155
|
+
params: d?.params,
|
|
1156
|
+
handler: d?.handler ?? "Pages Kit",
|
|
1157
|
+
isPublic: d?.isPublic ?? !0,
|
|
1158
|
+
enabledGenerate: d?.enabledGenerate ?? !1,
|
|
1159
|
+
displayTemplateId: d?.displayTemplateId ?? void 0,
|
|
1160
|
+
dataSource: d?.dataSource ?? {}
|
|
1187
1161
|
};
|
|
1188
1162
|
}) ?? []
|
|
1189
|
-
), g =
|
|
1163
|
+
), g = l ? T(y.components?.map(({ id: m }) => j(l, m)) ?? []) : [];
|
|
1190
1164
|
if (e) {
|
|
1191
|
-
const
|
|
1192
|
-
f.info(`[${o ?
|
|
1165
|
+
const m = (...d) => {
|
|
1166
|
+
f.info(`[${o ? R(t) : R(E(t, "../../../../"))}] importAssets:`, ...d);
|
|
1193
1167
|
};
|
|
1194
1168
|
try {
|
|
1195
|
-
|
|
1196
|
-
resources: [`${
|
|
1197
|
-
validateStatus: (
|
|
1198
|
-
}),
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
Re(g,
|
|
1202
|
-
getFilePath: (
|
|
1203
|
-
onFinish: (
|
|
1204
|
-
|
|
1169
|
+
m("wait image-bin api ready"), await bt({
|
|
1170
|
+
resources: [`${lt(We)}/api/sdk/uploads`],
|
|
1171
|
+
validateStatus: (A) => A >= 200 && A <= 500
|
|
1172
|
+
}), m("image-bin api is ready");
|
|
1173
|
+
const d = {}, h = {};
|
|
1174
|
+
m("start to upload assets"), await Promise.allSettled([
|
|
1175
|
+
Re(g, d, {
|
|
1176
|
+
getFilePath: (A) => l && E(l, A),
|
|
1177
|
+
onFinish: (A) => {
|
|
1178
|
+
m(`upload ${A.length} component assets`);
|
|
1205
1179
|
}
|
|
1206
1180
|
}),
|
|
1207
|
-
Re(
|
|
1208
|
-
getFilePath: (
|
|
1209
|
-
const n = Ie(
|
|
1210
|
-
return
|
|
1181
|
+
Re(u, h, {
|
|
1182
|
+
getFilePath: (A, P) => {
|
|
1183
|
+
const n = Ie(u, P.slice(0, 1));
|
|
1184
|
+
return c && E(c, L(n.slug), A);
|
|
1211
1185
|
},
|
|
1212
|
-
onFinish: (
|
|
1213
|
-
|
|
1186
|
+
onFinish: (A) => {
|
|
1187
|
+
m(`upload ${A.length} page assets`);
|
|
1214
1188
|
}
|
|
1215
1189
|
})
|
|
1216
|
-
]),
|
|
1217
|
-
} catch (
|
|
1218
|
-
|
|
1190
|
+
]), m("upload assets done"), ye.clear(), global.gc && global.gc();
|
|
1191
|
+
} catch (d) {
|
|
1192
|
+
m("Error during asset import:", d);
|
|
1219
1193
|
}
|
|
1220
1194
|
}
|
|
1221
|
-
const
|
|
1195
|
+
const C = {};
|
|
1222
1196
|
if (s) {
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1197
|
+
const m = r && E(L(r), "../../resources/components"), d = T(
|
|
1198
|
+
y.resources?.components?.map(({ id: h }) => j(m, h)) ?? []
|
|
1225
1199
|
);
|
|
1226
|
-
|
|
1227
|
-
|
|
1200
|
+
d.length > 0 && (C.components = Object.fromEntries(
|
|
1201
|
+
d.map((h, A) => [h.id, { index: A, component: h }])
|
|
1228
1202
|
));
|
|
1229
1203
|
}
|
|
1230
1204
|
return {
|
|
1231
|
-
supportedLocales:
|
|
1232
|
-
pageIds:
|
|
1233
|
-
components: Object.fromEntries(g.map((
|
|
1234
|
-
pages: Object.fromEntries(
|
|
1235
|
-
config:
|
|
1236
|
-
resources:
|
|
1237
|
-
routeIds:
|
|
1238
|
-
routes: Object.fromEntries(
|
|
1205
|
+
supportedLocales: y.supportedLocales,
|
|
1206
|
+
pageIds: u.map((m) => m.id),
|
|
1207
|
+
components: Object.fromEntries(g.map((m, d) => [m.id, { index: d, data: m }])),
|
|
1208
|
+
pages: Object.fromEntries(u.map((m) => [m.id, m])),
|
|
1209
|
+
config: y.config || {},
|
|
1210
|
+
resources: C,
|
|
1211
|
+
routeIds: i.map((m) => m.id),
|
|
1212
|
+
routes: Object.fromEntries(i.map((m) => [m.id, m])),
|
|
1239
1213
|
dataSourceIds: [],
|
|
1240
1214
|
dataSources: {}
|
|
1241
1215
|
};
|
|
1242
1216
|
} finally {
|
|
1243
|
-
o && a &&
|
|
1217
|
+
o && a && Ue(a, { force: !0, recursive: !0 });
|
|
1244
1218
|
}
|
|
1245
1219
|
}
|
|
1246
|
-
async function
|
|
1220
|
+
async function Le(t, e, {
|
|
1247
1221
|
routes: s,
|
|
1248
1222
|
mergeMode: a = "byUpdateTime",
|
|
1249
1223
|
deleteRoutes: o = !1,
|
|
1250
1224
|
publishMode: r = void 0
|
|
1251
1225
|
} = {}) {
|
|
1252
1226
|
try {
|
|
1253
|
-
r &&
|
|
1254
|
-
} catch (
|
|
1255
|
-
f.error("clear preload page cache error", { error:
|
|
1227
|
+
r && Qe(r);
|
|
1228
|
+
} catch (I) {
|
|
1229
|
+
f.error("clear preload page cache error", { error: I });
|
|
1256
1230
|
}
|
|
1257
|
-
const { pages:
|
|
1231
|
+
const { pages: c, pageIds: l, routeIds: p, routes: y, supportedLocales: w } = t;
|
|
1258
1232
|
if (r === "production") {
|
|
1259
|
-
let
|
|
1260
|
-
for (const
|
|
1261
|
-
const g =
|
|
1233
|
+
let I = s ?? [], u = null;
|
|
1234
|
+
for (const i of p ?? []) {
|
|
1235
|
+
const g = y?.[i];
|
|
1262
1236
|
if (g?.params && g?.params.length > 0 && g?.paramsOptions && g?.paramsOptions.length > 0) {
|
|
1263
|
-
const
|
|
1237
|
+
const C = Se({
|
|
1264
1238
|
basePath: g.path,
|
|
1265
1239
|
params: g.params,
|
|
1266
1240
|
routeId: g.id,
|
|
@@ -1269,127 +1243,127 @@ async function je(t, e, {
|
|
|
1269
1243
|
currentParams: [],
|
|
1270
1244
|
currentOptionIds: [],
|
|
1271
1245
|
result: []
|
|
1272
|
-
}),
|
|
1273
|
-
|
|
1274
|
-
} else s ||
|
|
1246
|
+
}), m = Object.fromEntries(C.map((d) => [`${i}-${d.paramOptionIds.join("-")}`, d]));
|
|
1247
|
+
u = { ...u || {}, ...m }, s || (I = [...I, ...C.map((d) => `${i}-${d.paramOptionIds.join("-")}`)]);
|
|
1248
|
+
} else s || I.push(i);
|
|
1275
1249
|
}
|
|
1276
|
-
f.info("routeIds to be published: ",
|
|
1277
|
-
for (const
|
|
1278
|
-
let g =
|
|
1250
|
+
f.info("routeIds to be published: ", I);
|
|
1251
|
+
for (const i of I) {
|
|
1252
|
+
let g = i;
|
|
1279
1253
|
if (g.includes("-")) {
|
|
1280
|
-
const [
|
|
1281
|
-
g =
|
|
1254
|
+
const [d] = g.split("-");
|
|
1255
|
+
g = d;
|
|
1282
1256
|
}
|
|
1283
|
-
const
|
|
1284
|
-
if (!
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
for (const
|
|
1288
|
-
|
|
1257
|
+
const C = y?.[g];
|
|
1258
|
+
if (!C) {
|
|
1259
|
+
const d = e.pageIds.indexOf(g);
|
|
1260
|
+
d !== -1 && o && (e.pageIds.splice(d, 1), delete e.pages[g]);
|
|
1261
|
+
for (const h of e.pageIds)
|
|
1262
|
+
h.includes(`${g}-`) && (e.pageIds.splice(e.pageIds.indexOf(h), 1), delete e.pages[h]);
|
|
1289
1263
|
f.info("delete main route page", g);
|
|
1290
1264
|
continue;
|
|
1291
1265
|
}
|
|
1292
|
-
if (
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1266
|
+
if (i.includes("-") && !u?.[i]) {
|
|
1267
|
+
const d = e.pageIds.indexOf(i);
|
|
1268
|
+
d !== -1 && o && (e.pageIds.splice(d, 1), delete e.pages[i]), f.info("delete page", i);
|
|
1295
1269
|
continue;
|
|
1296
1270
|
}
|
|
1297
|
-
if (!
|
|
1298
|
-
f.info("no display template",
|
|
1271
|
+
if (!C.displayTemplateId) {
|
|
1272
|
+
f.info("no display template", i);
|
|
1299
1273
|
continue;
|
|
1300
1274
|
}
|
|
1301
|
-
const
|
|
1302
|
-
if (!
|
|
1303
|
-
f.info("no template page",
|
|
1275
|
+
const m = c[C.displayTemplateId];
|
|
1276
|
+
if (!m) {
|
|
1277
|
+
f.info("no template page", i);
|
|
1304
1278
|
continue;
|
|
1305
1279
|
}
|
|
1306
|
-
if (e.pageIds.includes(
|
|
1307
|
-
if (f.info("has need update page",
|
|
1308
|
-
e.pages[
|
|
1309
|
-
page:
|
|
1310
|
-
route:
|
|
1280
|
+
if (e.pageIds.includes(i)) {
|
|
1281
|
+
if (f.info("has need update page", i), a === "replace")
|
|
1282
|
+
e.pages[i] = de({
|
|
1283
|
+
page: m,
|
|
1284
|
+
route: C,
|
|
1311
1285
|
state: t,
|
|
1312
|
-
routeId:
|
|
1313
|
-
routePathInfo:
|
|
1314
|
-
}), f.info("replace page",
|
|
1286
|
+
routeId: i,
|
|
1287
|
+
routePathInfo: u?.[i]
|
|
1288
|
+
}), f.info("replace page", i);
|
|
1315
1289
|
else if (a === "byUpdateTime") {
|
|
1316
|
-
const
|
|
1317
|
-
(!
|
|
1318
|
-
page:
|
|
1319
|
-
route:
|
|
1290
|
+
const d = e.pages[C.id];
|
|
1291
|
+
(!d || C.updatedAt && C.updatedAt > d.updatedAt) && (e.pages[i] = de({
|
|
1292
|
+
page: m,
|
|
1293
|
+
route: C,
|
|
1320
1294
|
state: t,
|
|
1321
|
-
routeId:
|
|
1322
|
-
routePathInfo:
|
|
1323
|
-
}), f.info("replace page by update time",
|
|
1295
|
+
routeId: i,
|
|
1296
|
+
routePathInfo: u?.[i]
|
|
1297
|
+
}), f.info("replace page by update time", i));
|
|
1324
1298
|
}
|
|
1325
1299
|
} else
|
|
1326
|
-
e.pageIds.push(
|
|
1327
|
-
page:
|
|
1328
|
-
route:
|
|
1300
|
+
e.pageIds.push(i), e.pages[i] = de({
|
|
1301
|
+
page: m,
|
|
1302
|
+
route: C,
|
|
1329
1303
|
state: t,
|
|
1330
|
-
routeId:
|
|
1331
|
-
routePathInfo:
|
|
1332
|
-
}), f.info("add page",
|
|
1304
|
+
routeId: i,
|
|
1305
|
+
routePathInfo: u?.[i]
|
|
1306
|
+
}), f.info("add page", i);
|
|
1333
1307
|
}
|
|
1334
1308
|
if (o && !s)
|
|
1335
|
-
for (const
|
|
1336
|
-
|
|
1309
|
+
for (const i of e.pageIds)
|
|
1310
|
+
I?.includes(i) || (delete e.pages[i], f.info("delete page", i)), e.pageIds = [...e.pageIds].filter((g) => I?.includes(g));
|
|
1337
1311
|
} else {
|
|
1338
|
-
for (const
|
|
1339
|
-
const
|
|
1340
|
-
if (
|
|
1341
|
-
if (e.pageIds.includes(
|
|
1312
|
+
for (const I of l) {
|
|
1313
|
+
const u = c[I];
|
|
1314
|
+
if (u)
|
|
1315
|
+
if (e.pageIds.includes(u.id)) {
|
|
1342
1316
|
if (a === "replace")
|
|
1343
|
-
e.pages[
|
|
1317
|
+
e.pages[u.id] = u;
|
|
1344
1318
|
else if (a === "byUpdateTime") {
|
|
1345
|
-
const
|
|
1346
|
-
(!
|
|
1319
|
+
const i = e.pages[u.id];
|
|
1320
|
+
(!i || u.updatedAt && u.updatedAt > i.updatedAt) && (e.pages[u.id] = u);
|
|
1347
1321
|
}
|
|
1348
1322
|
} else
|
|
1349
|
-
e.pageIds.push(
|
|
1323
|
+
e.pageIds.push(u.id), e.pages[u.id] = u;
|
|
1350
1324
|
}
|
|
1351
|
-
for (const
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1354
|
-
if (e.routeIds.includes(
|
|
1325
|
+
for (const I of p) {
|
|
1326
|
+
const u = y[I];
|
|
1327
|
+
if (u)
|
|
1328
|
+
if (e.routeIds.includes(u.id)) {
|
|
1355
1329
|
if (a === "replace")
|
|
1356
|
-
e.routes[
|
|
1330
|
+
e.routes[u.id] = u;
|
|
1357
1331
|
else if (a === "byUpdateTime") {
|
|
1358
|
-
const
|
|
1359
|
-
(!
|
|
1332
|
+
const i = e.routes[u.id];
|
|
1333
|
+
(!i || u.updatedAt && u.updatedAt > i.updatedAt) && (e.routes[u.id] = u);
|
|
1360
1334
|
}
|
|
1361
1335
|
} else
|
|
1362
|
-
e.routeIds.push(
|
|
1336
|
+
e.routeIds.push(u.id), e.routes[u.id] = u;
|
|
1363
1337
|
}
|
|
1364
1338
|
}
|
|
1365
|
-
if (e.supportedLocales.splice(0, e.supportedLocales.length), e.supportedLocales.push(...
|
|
1366
|
-
for (const
|
|
1367
|
-
delete e.components[
|
|
1368
|
-
let
|
|
1369
|
-
|
|
1339
|
+
if (e.supportedLocales.splice(0, e.supportedLocales.length), e.supportedLocales.push(...mt(w)), o)
|
|
1340
|
+
for (const I of Object.keys(e.components))
|
|
1341
|
+
delete e.components[I];
|
|
1342
|
+
let j = JSON.parse(JSON.stringify(t.components));
|
|
1343
|
+
j = Object.fromEntries(
|
|
1370
1344
|
await Promise.all(
|
|
1371
|
-
Object.entries(
|
|
1372
|
-
const
|
|
1345
|
+
Object.entries(j).map(async ([I, u]) => {
|
|
1346
|
+
const i = await Ve(u?.data);
|
|
1373
1347
|
return [
|
|
1374
|
-
|
|
1348
|
+
I,
|
|
1375
1349
|
{
|
|
1376
|
-
...
|
|
1377
|
-
data:
|
|
1350
|
+
...u,
|
|
1351
|
+
data: i
|
|
1378
1352
|
}
|
|
1379
1353
|
];
|
|
1380
1354
|
})
|
|
1381
1355
|
)
|
|
1382
|
-
), Object.assign(e.components,
|
|
1356
|
+
), Object.assign(e.components, j), Object.assign(e.config, JSON.parse(JSON.stringify(t.config))), be(t.resources.components) || (e.resources.components = JSON.parse(JSON.stringify(t.resources.components || {})));
|
|
1383
1357
|
}
|
|
1384
|
-
const
|
|
1358
|
+
const Ve = Xe(
|
|
1385
1359
|
async (t) => {
|
|
1386
|
-
if (!
|
|
1360
|
+
if (!be(t?.properties))
|
|
1387
1361
|
return t;
|
|
1388
1362
|
if (t?.renderer?.type === "react-component") {
|
|
1389
1363
|
const { script: e, PROPERTIES_SCHEMA: s } = t?.renderer || {};
|
|
1390
1364
|
if (s || e && e.includes("PROPERTIES_SCHEMA"))
|
|
1391
1365
|
try {
|
|
1392
|
-
const a = await
|
|
1366
|
+
const a = await Ze(
|
|
1393
1367
|
e ?? "",
|
|
1394
1368
|
"PROPERTIES_SCHEMA",
|
|
1395
1369
|
t.id,
|
|
@@ -1412,28 +1386,28 @@ const Ge = Qe(
|
|
|
1412
1386
|
}
|
|
1413
1387
|
);
|
|
1414
1388
|
let re, Q, ne, ie;
|
|
1415
|
-
const
|
|
1389
|
+
const ze = () => ut({
|
|
1416
1390
|
types: [
|
|
1417
|
-
{ did:
|
|
1418
|
-
{ did:
|
|
1391
|
+
{ did: _e, type: De },
|
|
1392
|
+
{ did: Dt, type: De }
|
|
1419
1393
|
]
|
|
1420
1394
|
}), qt = () => {
|
|
1421
|
-
const t =
|
|
1395
|
+
const t = ze(), e = {};
|
|
1422
1396
|
return t.forEach((s) => {
|
|
1423
1397
|
const a = te("**/.blocklet/pages/pages.config.yml", { cwd: s.path, absolute: !0 }).at(0), o = a && E(L(a), "../../chunks");
|
|
1424
1398
|
if (o && U(o)) {
|
|
1425
|
-
const r =
|
|
1426
|
-
for (const
|
|
1427
|
-
e[
|
|
1399
|
+
const r = nt(o);
|
|
1400
|
+
for (const c of r)
|
|
1401
|
+
e[c] = E(o, c);
|
|
1428
1402
|
}
|
|
1429
1403
|
}), e;
|
|
1430
1404
|
};
|
|
1431
|
-
function
|
|
1405
|
+
function Je() {
|
|
1432
1406
|
return re = (async () => {
|
|
1433
|
-
const t =
|
|
1407
|
+
const t = ze();
|
|
1434
1408
|
Q = (await Promise.all(
|
|
1435
1409
|
t.map(async (s) => {
|
|
1436
|
-
const a = s.path ? await
|
|
1410
|
+
const a = s.path ? await Ge(s.path, { importAssets: !1 }) : void 0;
|
|
1437
1411
|
return a ? { blockletId: s.did, state: a, blockletTitle: s.title } : void 0;
|
|
1438
1412
|
})
|
|
1439
1413
|
)).filter((s) => !!s), ne = Q.reduce(
|
|
@@ -1457,7 +1431,7 @@ function ze() {
|
|
|
1457
1431
|
ie = Object.fromEntries(
|
|
1458
1432
|
await Promise.all(
|
|
1459
1433
|
Object.entries(e).map(async ([s, a]) => {
|
|
1460
|
-
const o = await
|
|
1434
|
+
const o = await Ve(a.component);
|
|
1461
1435
|
return [
|
|
1462
1436
|
s,
|
|
1463
1437
|
{
|
|
@@ -1471,9 +1445,9 @@ function ze() {
|
|
|
1471
1445
|
})(), re;
|
|
1472
1446
|
}
|
|
1473
1447
|
function Ht(t) {
|
|
1474
|
-
const e =
|
|
1448
|
+
const e = Me(
|
|
1475
1449
|
async () => {
|
|
1476
|
-
await
|
|
1450
|
+
await Je().catch((s) => {
|
|
1477
1451
|
f.error("load resource states error", { error: s });
|
|
1478
1452
|
}), await t?.({
|
|
1479
1453
|
states: Q,
|
|
@@ -1485,14 +1459,14 @@ function Ht(t) {
|
|
|
1485
1459
|
// 3s
|
|
1486
1460
|
{ leading: !1, trailing: !0 }
|
|
1487
1461
|
);
|
|
1488
|
-
return e(),
|
|
1489
|
-
|
|
1462
|
+
return e(), b.events.on(b.Events.componentAdded, e), b.events.on(b.Events.componentRemoved, e), b.events.on(b.Events.componentStarted, e), b.events.on(b.Events.componentStopped, e), b.events.on(b.Events.componentUpdated, e), b.events.on(ge, e), () => {
|
|
1463
|
+
b.events.off(b.Events.componentAdded, e), b.events.off(b.Events.componentRemoved, e), b.events.off(b.Events.componentStarted, e), b.events.off(b.Events.componentStopped, e), b.events.off(b.Events.componentUpdated, e), b.events.off(ge, e);
|
|
1490
1464
|
};
|
|
1491
1465
|
}
|
|
1492
|
-
const
|
|
1493
|
-
ce[
|
|
1494
|
-
ce[
|
|
1495
|
-
const s = await
|
|
1466
|
+
const Ke = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), qe = Symbol.for("GLOBAL_ENV_UPDATE_LISTENER_KEY"), ce = globalThis;
|
|
1467
|
+
ce[Ke]?.();
|
|
1468
|
+
ce[Ke] = Ht(async ({ pages: t, components: e }) => {
|
|
1469
|
+
const s = await O.getProjectIds();
|
|
1496
1470
|
f.info(`start update resource states projects(${s.length})`, s), await Promise.race([
|
|
1497
1471
|
new Promise((a) => {
|
|
1498
1472
|
setTimeout(() => {
|
|
@@ -1501,7 +1475,7 @@ ce[Je] = Ht(async ({ pages: t, components: e }) => {
|
|
|
1501
1475
|
}),
|
|
1502
1476
|
Promise.all(
|
|
1503
1477
|
s.map(async (a) => {
|
|
1504
|
-
|
|
1478
|
+
He({
|
|
1505
1479
|
projectId: a,
|
|
1506
1480
|
pages: t,
|
|
1507
1481
|
components: e
|
|
@@ -1512,31 +1486,31 @@ ce[Je] = Ht(async ({ pages: t, components: e }) => {
|
|
|
1512
1486
|
f.error("update resource states failed:", a);
|
|
1513
1487
|
});
|
|
1514
1488
|
});
|
|
1515
|
-
ce[
|
|
1516
|
-
ce[
|
|
1489
|
+
ce[qe]?.();
|
|
1490
|
+
ce[qe] = () => {
|
|
1517
1491
|
const t = () => {
|
|
1518
|
-
|
|
1492
|
+
O.pageUrlMapCache.clear(), f.info("[Cache CLEAR ALL] clear all page url map cache by env update");
|
|
1519
1493
|
};
|
|
1520
|
-
return
|
|
1521
|
-
|
|
1494
|
+
return b.events.on(b.Events.envUpdate, t), () => {
|
|
1495
|
+
b.events.off(b.Events.envUpdate, t);
|
|
1522
1496
|
};
|
|
1523
1497
|
};
|
|
1524
|
-
|
|
1498
|
+
O.startPeriodicCheck();
|
|
1525
1499
|
process.on("beforeExit", () => {
|
|
1526
|
-
|
|
1500
|
+
O.stopPeriodicCheck();
|
|
1527
1501
|
});
|
|
1528
1502
|
process.on("SIGINT", () => {
|
|
1529
|
-
|
|
1503
|
+
O.stopPeriodicCheck(), process.exit(0);
|
|
1530
1504
|
});
|
|
1531
1505
|
process.on("SIGTERM", () => {
|
|
1532
|
-
|
|
1506
|
+
O.stopPeriodicCheck(), process.exit(0);
|
|
1533
1507
|
});
|
|
1534
|
-
async function
|
|
1508
|
+
async function He({
|
|
1535
1509
|
projectId: t,
|
|
1536
1510
|
pages: e,
|
|
1537
1511
|
components: s
|
|
1538
1512
|
}) {
|
|
1539
|
-
const a =
|
|
1513
|
+
const a = O.sharedInstances[t];
|
|
1540
1514
|
if (!a) {
|
|
1541
1515
|
f.info(`projectId: ${t} not found in sharedInstances`);
|
|
1542
1516
|
return;
|
|
@@ -1544,10 +1518,10 @@ async function qe({
|
|
|
1544
1518
|
if (a.syncedStore.resources.pages = e, (await M.findByPk(t))?.useAllResources)
|
|
1545
1519
|
a.syncedStore.resources.components = s;
|
|
1546
1520
|
else {
|
|
1547
|
-
const
|
|
1548
|
-
Object.entries(s || {}).filter(([
|
|
1521
|
+
const c = (await we.findAll({ where: { projectId: t } })).map((p) => p.componentId), l = Object.fromEntries(
|
|
1522
|
+
Object.entries(s || {}).filter(([p]) => c.includes(p))
|
|
1549
1523
|
);
|
|
1550
|
-
a.syncedStore.resources.components =
|
|
1524
|
+
a.syncedStore.resources.components = l;
|
|
1551
1525
|
}
|
|
1552
1526
|
f.info(`update [${t}] resource states:`, {
|
|
1553
1527
|
pages: Object.keys(a.syncedStore.resources.pages || {}).length,
|
|
@@ -1555,36 +1529,36 @@ async function qe({
|
|
|
1555
1529
|
});
|
|
1556
1530
|
}
|
|
1557
1531
|
async function ks(t) {
|
|
1558
|
-
return
|
|
1532
|
+
return He({
|
|
1559
1533
|
projectId: t,
|
|
1560
1534
|
pages: ne,
|
|
1561
1535
|
components: ie
|
|
1562
1536
|
});
|
|
1563
1537
|
}
|
|
1564
|
-
async function
|
|
1565
|
-
f.info("trigger reload all project resource"),
|
|
1538
|
+
async function Ds() {
|
|
1539
|
+
f.info("trigger reload all project resource"), b.events.emit(ge);
|
|
1566
1540
|
}
|
|
1567
|
-
async function
|
|
1541
|
+
async function Ts({
|
|
1568
1542
|
ensureLoaded: t = !0
|
|
1569
1543
|
} = {}) {
|
|
1570
|
-
return t && (re ??=
|
|
1544
|
+
return t && (re ??= Je(), await re), { states: Q, pages: ne, components: ie };
|
|
1571
1545
|
}
|
|
1572
1546
|
export {
|
|
1573
|
-
|
|
1547
|
+
_e as C,
|
|
1574
1548
|
M as P,
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1549
|
+
De as R,
|
|
1550
|
+
O as S,
|
|
1551
|
+
K as a,
|
|
1552
|
+
vs as b,
|
|
1553
|
+
js as c,
|
|
1580
1554
|
Gt as d,
|
|
1581
1555
|
zt as e,
|
|
1582
1556
|
Jt as f,
|
|
1583
|
-
|
|
1584
|
-
|
|
1557
|
+
Ts as g,
|
|
1558
|
+
Ge as h,
|
|
1585
1559
|
Ht as i,
|
|
1586
|
-
|
|
1587
|
-
|
|
1560
|
+
Ds as j,
|
|
1561
|
+
Le as m,
|
|
1588
1562
|
Kt as t,
|
|
1589
1563
|
ks as u
|
|
1590
1564
|
};
|