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