@blocklet/pages-kit-inner-components 0.4.35 → 0.4.36
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/_chunks/{site-state--DPohEOl.js → site-state-BZ2jOaHm.js} +6 -6
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/_chunks/{site-state-DKSwkZqL.js → site-state-F2Hmj9eb.js} +347 -367
- package/lib/es/components.js +1 -1
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var P = (t, o, e) =>
|
|
4
|
-
import { getComponentMountPoint as
|
|
5
|
-
import { PreloadComponentScriptModule as
|
|
6
|
-
import { componentUMDName as
|
|
7
|
-
import { memoize as ae, Sandbox as
|
|
8
|
-
import
|
|
1
|
+
var Ze = Object.defineProperty;
|
|
2
|
+
var et = (t, o, e) => o in t ? Ze(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
|
|
3
|
+
var P = (t, o, e) => et(t, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { getComponentMountPoint as tt } from "@blocklet/pages-kit/builtin/utils";
|
|
5
|
+
import { PreloadComponentScriptModule as Q } from "@blocklet/pages-kit/types";
|
|
6
|
+
import { componentUMDName as st, RenderNestedComponent as Oe, mergeComponent as ot } from "@blocklet/pages-kit/utils/property";
|
|
7
|
+
import { memoize as ae, Sandbox as Me, BuiltinModules as nt } from "@blocklet/quickjs";
|
|
8
|
+
import S from "@blocklet/sdk/lib/config";
|
|
9
9
|
import { LRUCache as he } from "lru-cache";
|
|
10
|
-
import
|
|
11
|
-
import { joinURL as
|
|
10
|
+
import rt, { Headers as at } from "node-fetch";
|
|
11
|
+
import { joinURL as M, getQuery as it, withQuery as ct, parseURL as ve, withHttps as lt } from "ufo";
|
|
12
12
|
import { createHash as ie } from "crypto";
|
|
13
|
-
import
|
|
14
|
-
import { BuiltinModules as
|
|
15
|
-
import { createBuiltinModuleTransformer as
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
13
|
+
import pt from "@blocklet/logger";
|
|
14
|
+
import { BuiltinModules as ut } from "@blocklet/pages-kit/utils/builtin";
|
|
15
|
+
import { createBuiltinModuleTransformer as dt, isRelativeModule as mt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
|
|
16
|
+
import { getComponentWebEndpoint as ft, getResources as gt, call as ht } from "@blocklet/sdk/lib/component";
|
|
17
|
+
import yt from "autoprefixer";
|
|
18
18
|
import * as St from "esbuild";
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import
|
|
19
|
+
import { existsSync as V, readFileSync as X, renameSync as Ae, mkdirSync as F, rmSync as Fe, writeFileSync as te, lstatSync as Z, readdirSync as wt, mkdtempSync as Et, createWriteStream as bt } from "fs";
|
|
20
|
+
import It from "postcss";
|
|
21
|
+
import Ot from "tailwindcss";
|
|
22
22
|
import j from "typescript";
|
|
23
|
-
import { reactive as
|
|
24
|
-
import { syncedStore as
|
|
23
|
+
import { reactive as vt } from "@reactivedata/reactive";
|
|
24
|
+
import { syncedStore as At, getYjsValue as le } from "@syncedstore/core";
|
|
25
25
|
import { globSync as me } from "glob";
|
|
26
26
|
import * as pe from "lib0/decoding";
|
|
27
27
|
import * as C from "lib0/encoding";
|
|
28
|
-
import {
|
|
29
|
-
import { customAlphabet as
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import { pipeline as
|
|
33
|
-
import { x as
|
|
34
|
-
import
|
|
35
|
-
import { Awareness as
|
|
36
|
-
import { writeUpdate as
|
|
37
|
-
import * as
|
|
28
|
+
import { pick as Tt, debounce as $e, union as Pt, get as ye, cloneDeep as Ct, isEmpty as xt, set as Te } from "lodash";
|
|
29
|
+
import { customAlphabet as jt } from "nanoid";
|
|
30
|
+
import kt from "p-limit";
|
|
31
|
+
import Dt, { join as O, basename as J, dirname as L } from "path";
|
|
32
|
+
import { pipeline as Nt } from "stream/promises";
|
|
33
|
+
import { x as Lt } from "tar";
|
|
34
|
+
import Rt from "wait-on";
|
|
35
|
+
import { Awareness as Ut, encodeAwarenessUpdate as Pe, removeAwarenessStates as _t, applyAwarenessUpdate as Mt } from "y-protocols/awareness";
|
|
36
|
+
import { writeUpdate as Ft, writeSyncStep1 as $t, readSyncMessage as Bt } from "y-protocols/sync";
|
|
37
|
+
import * as H from "yaml";
|
|
38
38
|
import * as B from "yjs";
|
|
39
|
-
import
|
|
40
|
-
import { DataTypes as T, Sequelize as
|
|
39
|
+
import Vt from "lodash/isNil";
|
|
40
|
+
import { DataTypes as T, Sequelize as Gt, Model as Be, Op as Jt } from "sequelize";
|
|
41
41
|
import "sqlite3";
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
42
|
+
S.env.mode;
|
|
43
|
+
const Ht = "image-bin";
|
|
44
|
+
S.env.INIT_TEMPLATE_PATH;
|
|
45
|
+
const Kt = process.env.DATABASE_URL || Dt.join(S.env.dataDir, "db/pages-kit.db"), Ce = S, so = () => S.env.tenantMode === "multiple", oo = () => {
|
|
46
46
|
var t;
|
|
47
|
-
return (
|
|
48
|
-
}, v =
|
|
49
|
-
T.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) :
|
|
50
|
-
const
|
|
47
|
+
return (Vt(Ce.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = Ce.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
|
|
48
|
+
}, v = pt("pages-kit"), Wt = T.sqlite.DATE.parse;
|
|
49
|
+
T.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) : Wt(t, o);
|
|
50
|
+
const z = new Gt({
|
|
51
51
|
dialect: "sqlite",
|
|
52
|
-
storage:
|
|
52
|
+
storage: Kt,
|
|
53
53
|
benchmark: process.env.ENABLE_SEQUELIZE_BENCHMARK === "true",
|
|
54
54
|
retry: {
|
|
55
55
|
match: [/SQLITE_BUSY/],
|
|
@@ -60,10 +60,10 @@ const Y = new Jt({
|
|
|
60
60
|
logging: process.env.ENABLE_SEQUELIZE_LOGGING === "true" ? console.log : !1
|
|
61
61
|
// logQueryParameters: true,
|
|
62
62
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class ce extends
|
|
63
|
+
z.query("pragma journal_mode = WAL;");
|
|
64
|
+
z.query("pragma synchronous = normal;");
|
|
65
|
+
z.query("pragma journal_size_limit = 67108864;");
|
|
66
|
+
class ce extends Be {
|
|
67
67
|
// Foreign key to Component
|
|
68
68
|
}
|
|
69
69
|
ce.init(
|
|
@@ -83,13 +83,13 @@ ce.init(
|
|
|
83
83
|
allowNull: !1
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
{ sequelize:
|
|
86
|
+
{ sequelize: z, tableName: "ProjectComponents", timestamps: !1 }
|
|
87
87
|
);
|
|
88
|
-
class $ extends
|
|
88
|
+
class $ extends Be {
|
|
89
89
|
static async getProjectByIdOrSlug(o) {
|
|
90
90
|
return $.findOne({
|
|
91
91
|
where: {
|
|
92
|
-
[
|
|
92
|
+
[Jt.or]: [{ id: o }, { slug: o }]
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
}
|
|
@@ -132,19 +132,19 @@ $.init(
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
|
-
{ sequelize:
|
|
135
|
+
{ sequelize: z, paranoid: !0 }
|
|
136
136
|
);
|
|
137
137
|
$.hasMany(ce, {
|
|
138
138
|
foreignKey: "projectId",
|
|
139
139
|
as: "components"
|
|
140
140
|
});
|
|
141
|
-
const
|
|
141
|
+
const zt = async (t, { componentId: o }) => {
|
|
142
142
|
const e = `@tailwind components;
|
|
143
143
|
@tailwind utilities;
|
|
144
144
|
`, s = `.CustomComponent_${o}`;
|
|
145
|
-
return (await
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
return (await It([
|
|
146
|
+
Ot({ content: [{ raw: t, extension: "tsx" }] }),
|
|
147
|
+
yt({
|
|
148
148
|
overrideBrowserslist: ["> 1%", "last 2 versions"],
|
|
149
149
|
stats: {}
|
|
150
150
|
}),
|
|
@@ -156,13 +156,13 @@ const Yt = async (t, { componentId: o }) => {
|
|
|
156
156
|
// FIXME: cssnano use browserslist, it is not working with the fs isolation
|
|
157
157
|
// cssnano({ preset: 'default' }),
|
|
158
158
|
]).process(e)).css;
|
|
159
|
-
},
|
|
160
|
-
const e = await
|
|
159
|
+
}, Yt = async (t, { componentId: o }) => {
|
|
160
|
+
const e = await zt(t, { componentId: o });
|
|
161
161
|
return `export const __PagesKit_CSS__ = ${JSON.stringify(e)};
|
|
162
162
|
|
|
163
163
|
${t}
|
|
164
164
|
`;
|
|
165
|
-
},
|
|
165
|
+
}, xe = ae(
|
|
166
166
|
async (t, o) => {
|
|
167
167
|
let e = j.transpileModule(t, {
|
|
168
168
|
compilerOptions: {
|
|
@@ -171,10 +171,10 @@ ${t}
|
|
|
171
171
|
module: j.ModuleKind.ESNext
|
|
172
172
|
},
|
|
173
173
|
transformers: {
|
|
174
|
-
before: [
|
|
174
|
+
before: [dt(j)]
|
|
175
175
|
}
|
|
176
176
|
}).outputText;
|
|
177
|
-
if (o.tailwind && (e = await
|
|
177
|
+
if (o.tailwind && (e = await Yt(e, { componentId: o.componentId })), o.module === Q.ESM) return e;
|
|
178
178
|
const s = j.transpileModule(e, {
|
|
179
179
|
compilerOptions: {
|
|
180
180
|
jsx: j.JsxEmit.React,
|
|
@@ -183,7 +183,7 @@ ${t}
|
|
|
183
183
|
moduleResolution: j.ModuleResolutionKind.Node16
|
|
184
184
|
}
|
|
185
185
|
}).outputText;
|
|
186
|
-
return o.module ===
|
|
186
|
+
return o.module === Q.CJS ? s : Qt(o.moduleName, s);
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
keyGenerator: (t, o) => {
|
|
@@ -191,7 +191,7 @@ ${t}
|
|
|
191
191
|
...o,
|
|
192
192
|
componentId: o.componentId,
|
|
193
193
|
module: o.module,
|
|
194
|
-
...o.module !==
|
|
194
|
+
...o.module !== Q.ESM ? { moduleName: o.moduleName } : {},
|
|
195
195
|
tailwind: o.tailwind
|
|
196
196
|
};
|
|
197
197
|
return JSON.stringify(["transpileModule", e, s]);
|
|
@@ -203,11 +203,11 @@ ${t}
|
|
|
203
203
|
// 1小时过期时间
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
),
|
|
206
|
+
), qt = async (t, o) => {
|
|
207
207
|
var l, a;
|
|
208
208
|
const s = (a = (l = (await St.build({
|
|
209
209
|
entryPoints: ["index.tsx"],
|
|
210
|
-
external: Object.keys(
|
|
210
|
+
external: Object.keys(ut),
|
|
211
211
|
format: "esm",
|
|
212
212
|
target: "esnext",
|
|
213
213
|
bundle: !0,
|
|
@@ -216,27 +216,7 @@ ${t}
|
|
|
216
216
|
{
|
|
217
217
|
name: "vfs",
|
|
218
218
|
setup(i) {
|
|
219
|
-
|
|
220
|
-
i.onResolve({ filter: /.*/ }, (p) => p.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : p.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : Ae(p.path) ? { path: p.path, namespace: "vfs" } : null), i.onLoad({ filter: /.*/, namespace: "vfs" }, async (p) => {
|
|
221
|
-
var u;
|
|
222
|
-
if (p.path === "index.tsx")
|
|
223
|
-
return { contents: `export { ${o} } from './component'`, loader: "tsx" };
|
|
224
|
-
if (p.path === "component.tsx")
|
|
225
|
-
return { contents: t, loader: "tsx" };
|
|
226
|
-
if (Ae(p.path)) {
|
|
227
|
-
c || (c = await et({ ensureLoaded: !1 }));
|
|
228
|
-
const m = p.path.split("/").pop();
|
|
229
|
-
if ((u = c == null ? void 0 : c.chunks) != null && u[m])
|
|
230
|
-
return { contents: H(c.chunks[m], "utf-8"), loader: "js" };
|
|
231
|
-
const g = _("chunks", m), { data: h } = await $e({
|
|
232
|
-
name: "pages-kit",
|
|
233
|
-
method: "GET",
|
|
234
|
-
path: g
|
|
235
|
-
});
|
|
236
|
-
return { contents: h, loader: "js" };
|
|
237
|
-
}
|
|
238
|
-
return null;
|
|
239
|
-
});
|
|
219
|
+
i.onResolve({ filter: /.*/ }, (c) => c.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : c.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : mt(c.path) ? { path: c.path, namespace: "vfs" } : null), i.onLoad({ filter: /.*/, namespace: "vfs" }, async (c) => c.path === "index.tsx" ? { contents: `export { ${o} } from './component'`, loader: "tsx" } : c.path === "component.tsx" ? { contents: t, loader: "tsx" } : null);
|
|
240
220
|
}
|
|
241
221
|
}
|
|
242
222
|
]
|
|
@@ -246,9 +226,9 @@ ${t}
|
|
|
246
226
|
return j.transpileModule(n, {
|
|
247
227
|
compilerOptions: { module: j.ModuleKind.ESNext, target: j.ScriptTarget.ES2020 }
|
|
248
228
|
}).outputText;
|
|
249
|
-
},
|
|
229
|
+
}, Ve = ae(
|
|
250
230
|
async (t, o) => {
|
|
251
|
-
const e = await
|
|
231
|
+
const e = await qt(t, o);
|
|
252
232
|
return new RegExp(`export\\s+\\{\\s+${o}\\s+\\}`, "m").test(e) ? e : void 0;
|
|
253
233
|
},
|
|
254
234
|
{
|
|
@@ -261,7 +241,7 @@ ${t}
|
|
|
261
241
|
ttl: 1e3 * 60 * 60
|
|
262
242
|
}
|
|
263
243
|
}
|
|
264
|
-
),
|
|
244
|
+
), Qt = (t, o) => {
|
|
265
245
|
const e = /\bawait\b/.test(o);
|
|
266
246
|
return `// GENERATED FILE. DO NOT EDIT.
|
|
267
247
|
var ${t} = ${e ? "async" : ""} function () {
|
|
@@ -290,17 +270,17 @@ var ${t} = ${e ? "async" : ""} function () {
|
|
|
290
270
|
return exports;
|
|
291
271
|
};
|
|
292
272
|
`;
|
|
293
|
-
},
|
|
273
|
+
}, K = new he({
|
|
294
274
|
max: 100
|
|
295
|
-
}),
|
|
296
|
-
function
|
|
297
|
-
v.info("clear preload components cache", { cacheKey: t }),
|
|
275
|
+
}), Xt = 60 * 60, je = 60;
|
|
276
|
+
function Zt(t) {
|
|
277
|
+
v.info("clear preload components cache", { cacheKey: t }), K.delete(t);
|
|
298
278
|
}
|
|
299
|
-
function
|
|
300
|
-
for (const o of
|
|
301
|
-
o.includes(t) && (v.info("clear preload components cache", { cacheKey: o }),
|
|
279
|
+
function es(t) {
|
|
280
|
+
for (const o of K.keys())
|
|
281
|
+
o.includes(t) && (v.info("clear preload components cache", { cacheKey: o }), Zt(o));
|
|
302
282
|
}
|
|
303
|
-
function
|
|
283
|
+
function ts({
|
|
304
284
|
mode: t,
|
|
305
285
|
instanceId: o,
|
|
306
286
|
componentId: e,
|
|
@@ -324,17 +304,17 @@ async function no({
|
|
|
324
304
|
const i = (await Promise.all(
|
|
325
305
|
n.map(async (g) => {
|
|
326
306
|
try {
|
|
327
|
-
const
|
|
307
|
+
const y = ts({
|
|
328
308
|
mode: t,
|
|
329
309
|
instanceId: g.id,
|
|
330
310
|
componentId: g.componentId,
|
|
331
311
|
locale: s
|
|
332
312
|
});
|
|
333
|
-
if (t !== "draft" && g.useCache &&
|
|
334
|
-
return v.info(`get preload component from cache: ${
|
|
313
|
+
if (t !== "draft" && g.useCache && K.has(y))
|
|
314
|
+
return v.info(`get preload component from cache: ${y}`), K.get(y);
|
|
335
315
|
const A = se({ state: e, componentId: g.componentId });
|
|
336
316
|
if (!A) return null;
|
|
337
|
-
const x = await
|
|
317
|
+
const x = await ss({
|
|
338
318
|
req: o,
|
|
339
319
|
state: e,
|
|
340
320
|
componentId: A.id,
|
|
@@ -345,40 +325,40 @@ async function no({
|
|
|
345
325
|
if (!x) return null;
|
|
346
326
|
const U = { instanceId: g.id, preload: x };
|
|
347
327
|
if (t !== "draft" && g.useCache) {
|
|
348
|
-
let D =
|
|
349
|
-
g.cacheDuration && (D = g.cacheDuration), v.info(`set preload component to cache(${D}s): ${
|
|
328
|
+
let D = Xt;
|
|
329
|
+
g.cacheDuration && (D = g.cacheDuration), v.info(`set preload component to cache(${D}s): ${y}`), K.set(y, U, {
|
|
350
330
|
ttl: D * 1e3
|
|
351
331
|
});
|
|
352
332
|
}
|
|
353
333
|
return U;
|
|
354
|
-
} catch (
|
|
355
|
-
return v.error("get preload component error", { instanceId: g.id, componentId: g.componentId }, { error:
|
|
334
|
+
} catch (y) {
|
|
335
|
+
return v.error("get preload component error", { instanceId: g.id, componentId: g.componentId }, { error: y }), null;
|
|
356
336
|
}
|
|
357
337
|
})
|
|
358
338
|
)).filter((g) => !!g), c = Object.values(
|
|
359
|
-
i.reduce((g,
|
|
339
|
+
i.reduce((g, y) => ({ ...g, ...y.preload.components }), {})
|
|
360
340
|
);
|
|
361
341
|
async function p() {
|
|
362
342
|
const g = await Promise.all(
|
|
363
|
-
c.map(async (
|
|
364
|
-
const A =
|
|
343
|
+
c.map(async (y) => {
|
|
344
|
+
const A = st({ componentId: y.component.id }), x = r === Q.ESM ? {
|
|
365
345
|
module: r,
|
|
366
|
-
script: await
|
|
367
|
-
componentId:
|
|
346
|
+
script: await xe(y.script, {
|
|
347
|
+
componentId: y.component.id,
|
|
368
348
|
module: r,
|
|
369
349
|
tailwind: t !== "draft"
|
|
370
350
|
})
|
|
371
351
|
} : {
|
|
372
352
|
module: r,
|
|
373
|
-
script: await
|
|
374
|
-
componentId:
|
|
353
|
+
script: await xe(y.script, {
|
|
354
|
+
componentId: y.component.id,
|
|
375
355
|
module: r,
|
|
376
356
|
moduleName: A,
|
|
377
357
|
tailwind: t !== "draft"
|
|
378
358
|
}),
|
|
379
359
|
moduleName: A
|
|
380
360
|
};
|
|
381
|
-
return [
|
|
361
|
+
return [y.component.id, { component: y.component, script: x }];
|
|
382
362
|
})
|
|
383
363
|
);
|
|
384
364
|
return Object.fromEntries(g);
|
|
@@ -394,7 +374,7 @@ async function no({
|
|
|
394
374
|
}))
|
|
395
375
|
};
|
|
396
376
|
}
|
|
397
|
-
async function
|
|
377
|
+
async function ss({
|
|
398
378
|
req: t,
|
|
399
379
|
state: o,
|
|
400
380
|
componentId: e,
|
|
@@ -406,14 +386,14 @@ async function os({
|
|
|
406
386
|
if (!a) return null;
|
|
407
387
|
const i = l.some((p) => p.locale === s) ? s : n;
|
|
408
388
|
if (!i) return null;
|
|
409
|
-
const c = await
|
|
389
|
+
const c = await Ge({ req: t, state: o, componentId: e, locale: i, defaultLocale: n, properties: r });
|
|
410
390
|
return c ? {
|
|
411
391
|
component: a,
|
|
412
392
|
...c
|
|
413
393
|
} : null;
|
|
414
394
|
}
|
|
415
|
-
const
|
|
416
|
-
async function
|
|
395
|
+
const os = 20;
|
|
396
|
+
async function Ge({
|
|
417
397
|
req: t,
|
|
418
398
|
depth: o = 0,
|
|
419
399
|
state: e,
|
|
@@ -422,8 +402,8 @@ async function He({
|
|
|
422
402
|
defaultLocale: r,
|
|
423
403
|
properties: l
|
|
424
404
|
}) {
|
|
425
|
-
if (o >
|
|
426
|
-
const a =
|
|
405
|
+
if (o > os) throw new RangeError("max component depth exceeded");
|
|
406
|
+
const a = ns({ state: e, componentId: s, properties: l, locale: n });
|
|
427
407
|
if (!a) return null;
|
|
428
408
|
const { props: i } = a, c = {
|
|
429
409
|
locale: n || r,
|
|
@@ -431,7 +411,7 @@ async function He({
|
|
|
431
411
|
props: { ...i }
|
|
432
412
|
};
|
|
433
413
|
try {
|
|
434
|
-
const p = await
|
|
414
|
+
const p = await rs({ ...a, req: t });
|
|
435
415
|
p != null && p.props && Object.assign(c.props, p.props);
|
|
436
416
|
} catch (p) {
|
|
437
417
|
v.error("preload data at server side error", { componentId: s, name: a.component.name }, { error: p });
|
|
@@ -439,7 +419,7 @@ async function He({
|
|
|
439
419
|
return await Promise.all(
|
|
440
420
|
Object.entries(i).map(async ([p, u]) => {
|
|
441
421
|
if ((u == null ? void 0 : u.type) === Oe) {
|
|
442
|
-
const
|
|
422
|
+
const f = await Ge({
|
|
443
423
|
req: t,
|
|
444
424
|
depth: o + 1,
|
|
445
425
|
state: e,
|
|
@@ -448,18 +428,18 @@ async function He({
|
|
|
448
428
|
defaultLocale: r,
|
|
449
429
|
properties: u.properties
|
|
450
430
|
});
|
|
451
|
-
|
|
431
|
+
f && (Object.assign(c.components, f.components), Object.assign(c.props, {
|
|
452
432
|
[p]: {
|
|
453
433
|
type: Oe,
|
|
454
434
|
componentId: u.componentId,
|
|
455
|
-
props:
|
|
435
|
+
props: f.props
|
|
456
436
|
}
|
|
457
437
|
}));
|
|
458
438
|
}
|
|
459
439
|
})
|
|
460
440
|
), c;
|
|
461
441
|
}
|
|
462
|
-
function
|
|
442
|
+
function ns({
|
|
463
443
|
state: t,
|
|
464
444
|
componentId: o,
|
|
465
445
|
locale: e,
|
|
@@ -467,7 +447,7 @@ function rs({
|
|
|
467
447
|
}) {
|
|
468
448
|
const n = se({ state: t, componentId: o });
|
|
469
449
|
if (!n) return null;
|
|
470
|
-
const r =
|
|
450
|
+
const r = ot({
|
|
471
451
|
componentId: o,
|
|
472
452
|
getComponent: (l) => se({ state: t, componentId: l }),
|
|
473
453
|
locale: e,
|
|
@@ -491,22 +471,22 @@ function ro({ state: t, name: o }) {
|
|
|
491
471
|
return ((l = r.component.name) == null ? void 0 : l.toLowerCase()) === e;
|
|
492
472
|
})) == null ? void 0 : n.component);
|
|
493
473
|
}
|
|
494
|
-
async function
|
|
474
|
+
async function rs({
|
|
495
475
|
component: t,
|
|
496
476
|
script: o,
|
|
497
477
|
props: e,
|
|
498
478
|
req: s
|
|
499
479
|
}) {
|
|
500
|
-
const n = await
|
|
480
|
+
const n = await Ve(o, "getServerSideProps");
|
|
501
481
|
if (!n) return null;
|
|
502
482
|
const r = new Promise((a, i) => {
|
|
503
483
|
setTimeout(() => {
|
|
504
484
|
i(new Error("getServerSideProps timeout in promise race"));
|
|
505
|
-
},
|
|
485
|
+
}, je * 1e3);
|
|
506
486
|
});
|
|
507
487
|
return await Promise.race([
|
|
508
488
|
r,
|
|
509
|
-
|
|
489
|
+
Me.callFunction({
|
|
510
490
|
code: `${n}
|
|
511
491
|
|
|
512
492
|
export async function getServerSidePropsWrapper(props) {
|
|
@@ -532,7 +512,7 @@ export async function getServerSidePropsWrapper(props) {
|
|
|
532
512
|
export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
533
513
|
`;
|
|
534
514
|
if (a === "@blocklet/pages-kit/builtin/dayjs")
|
|
535
|
-
return
|
|
515
|
+
return nt.dayjs;
|
|
536
516
|
},
|
|
537
517
|
global: {
|
|
538
518
|
console: {
|
|
@@ -548,29 +528,29 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
|
548
528
|
v.error(...a);
|
|
549
529
|
}
|
|
550
530
|
},
|
|
551
|
-
getComponentMountPoint:
|
|
552
|
-
joinURL:
|
|
553
|
-
withQuery:
|
|
554
|
-
getQuery:
|
|
531
|
+
getComponentMountPoint: tt,
|
|
532
|
+
joinURL: M,
|
|
533
|
+
withQuery: ct,
|
|
534
|
+
getQuery: it
|
|
555
535
|
},
|
|
556
536
|
functionName: "getServerSidePropsWrapper",
|
|
557
537
|
args: [
|
|
558
538
|
{
|
|
559
539
|
// NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
|
|
560
540
|
// because the global is shared between all runtime and just init once
|
|
561
|
-
location: { href:
|
|
541
|
+
location: { href: M(lt(s.hostname), s.originalUrl) },
|
|
562
542
|
fetch: (a, { ...i } = {}) => {
|
|
563
|
-
const c = typeof a == "string" && a.startsWith("/") ?
|
|
564
|
-
if (typeof c == "string" && ve(c).host === ve(
|
|
543
|
+
const c = typeof a == "string" && a.startsWith("/") ? M(S.env.appUrl, a) : a;
|
|
544
|
+
if (typeof c == "string" && ve(c).host === ve(S.env.appUrl).host) {
|
|
565
545
|
const p = s.get("cookie");
|
|
566
546
|
if (p) {
|
|
567
|
-
const u = new
|
|
547
|
+
const u = new at(i.headers);
|
|
568
548
|
u.set("cookie", p), i.headers = u;
|
|
569
549
|
}
|
|
570
550
|
}
|
|
571
|
-
return
|
|
551
|
+
return rt(c, {
|
|
572
552
|
...i,
|
|
573
|
-
timeout:
|
|
553
|
+
timeout: je * 1e3
|
|
574
554
|
}).then((p) => ({
|
|
575
555
|
ok: p.ok,
|
|
576
556
|
status: p.status,
|
|
@@ -585,12 +565,12 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
|
585
565
|
})
|
|
586
566
|
]);
|
|
587
567
|
}
|
|
588
|
-
const
|
|
568
|
+
const as = ae(
|
|
589
569
|
async (t, o, e) => {
|
|
590
|
-
const s = await
|
|
570
|
+
const s = await Ve(t, o);
|
|
591
571
|
if (s)
|
|
592
572
|
try {
|
|
593
|
-
return await
|
|
573
|
+
return await Me.callFunction({
|
|
594
574
|
code: `
|
|
595
575
|
${s}
|
|
596
576
|
|
|
@@ -616,11 +596,11 @@ const is = ae(
|
|
|
616
596
|
ttl: 1e3 * 60 * 60
|
|
617
597
|
}
|
|
618
598
|
}
|
|
619
|
-
),
|
|
620
|
-
function
|
|
599
|
+
), is = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", ke = "page", fe = "trigger-reload-project-resource", Je = is, cs = "z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV", { uploadToMediaKit: ls } = require("@blocklet/uploader-server"), De = jt("abcdefghijklmnopqrstuvwxyz0123456789", 16), Se = /^\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, Ne = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, ps = 1e4, us = 3e4, Y = 0, ue = 1, ds = 0, ms = 1, ge = S, q = O(process.env.BLOCKLET_DATA_DIR, "site-state"), ao = ["production", "draft"], io = ["production"];
|
|
600
|
+
function He(t) {
|
|
621
601
|
return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
|
|
622
602
|
}
|
|
623
|
-
function
|
|
603
|
+
function fs() {
|
|
624
604
|
var e;
|
|
625
605
|
const t = ge.env.languages.map((s) => ({ locale: s.code, name: s.name })), o = (e = t[0]) == null ? void 0 : e.locale;
|
|
626
606
|
return {
|
|
@@ -632,7 +612,7 @@ function gs() {
|
|
|
632
612
|
resources: {}
|
|
633
613
|
};
|
|
634
614
|
}
|
|
635
|
-
const
|
|
615
|
+
const _ = class _ extends B.Doc {
|
|
636
616
|
constructor(e) {
|
|
637
617
|
super();
|
|
638
618
|
P(this, "states", {});
|
|
@@ -650,13 +630,13 @@ const M = class M extends B.Doc {
|
|
|
650
630
|
}));
|
|
651
631
|
}
|
|
652
632
|
const a = C.createEncoder();
|
|
653
|
-
C.writeVarUint(a, ue), C.writeVarUint8Array(a,
|
|
633
|
+
C.writeVarUint(a, ue), C.writeVarUint8Array(a, Pe(this.awareness, l));
|
|
654
634
|
const i = C.toUint8Array(a);
|
|
655
635
|
this.conns.forEach((c, p) => this.send(p, i));
|
|
656
636
|
});
|
|
657
637
|
P(this, "updateHandler", (e) => {
|
|
658
638
|
const s = C.createEncoder();
|
|
659
|
-
C.writeVarUint(s,
|
|
639
|
+
C.writeVarUint(s, Y), Ft(s, e);
|
|
660
640
|
const n = C.toUint8Array(s);
|
|
661
641
|
this.conns.forEach((r, l) => this.send(l, n));
|
|
662
642
|
});
|
|
@@ -682,7 +662,7 @@ const M = class M extends B.Doc {
|
|
|
682
662
|
}
|
|
683
663
|
});
|
|
684
664
|
P(this, "send", (e, s) => {
|
|
685
|
-
e.readyState !==
|
|
665
|
+
e.readyState !== ds && e.readyState !== ms && this.closeConn(e);
|
|
686
666
|
try {
|
|
687
667
|
e.send(s, (n) => {
|
|
688
668
|
n && this.closeConn(e);
|
|
@@ -694,19 +674,19 @@ const M = class M extends B.Doc {
|
|
|
694
674
|
P(this, "closeConn", (e) => {
|
|
695
675
|
if (e.removeAllListeners(), this.conns.has(e)) {
|
|
696
676
|
const s = this.conns.get(e);
|
|
697
|
-
this.conns.delete(e), s &&
|
|
677
|
+
this.conns.delete(e), s && _t(this.awareness, Array.from(s), null);
|
|
698
678
|
}
|
|
699
679
|
e.close();
|
|
700
680
|
});
|
|
701
|
-
P(this, "autoSave",
|
|
681
|
+
P(this, "autoSave", $e(() => {
|
|
702
682
|
F(L(this.draftYjsFilePath), { recursive: !0 }), te(this.draftYjsFilePath, B.encodeStateAsUpdate(this));
|
|
703
|
-
},
|
|
683
|
+
}, ps));
|
|
704
684
|
P(this, "save", ({ flush: e = !1 } = {}) => {
|
|
705
685
|
this.autoSave(), e && this.autoSave.flush();
|
|
706
686
|
});
|
|
707
687
|
P(this, "publish", async ({ mode: e, pages: s }) => {
|
|
708
688
|
const n = await this.getState("draft"), r = await this.getState("production");
|
|
709
|
-
await
|
|
689
|
+
await Ue(n, r, { pages: s, pageMergeMode: "replace", deletePages: !0, publishMode: e }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime();
|
|
710
690
|
for (const l of s || Object.keys(this.syncedStore.pages))
|
|
711
691
|
this.syncedStore.pages[l] && (this.syncedStore.pages[l].publishedAt = (/* @__PURE__ */ new Date()).toISOString());
|
|
712
692
|
await this.setState(e, r);
|
|
@@ -719,10 +699,10 @@ const M = class M extends B.Doc {
|
|
|
719
699
|
e.config.fontFamily.title = (r == null ? void 0 : r.title) || (l == null ? void 0 : l.title), e.config.fontFamily.description = (r == null ? void 0 : r.description) || (l == null ? void 0 : l.description), await new Promise((p, u) => {
|
|
720
700
|
this.transact(async () => {
|
|
721
701
|
try {
|
|
722
|
-
const
|
|
723
|
-
p(
|
|
724
|
-
} catch (
|
|
725
|
-
u(
|
|
702
|
+
const f = await Ue(e, s);
|
|
703
|
+
p(f);
|
|
704
|
+
} catch (f) {
|
|
705
|
+
u(f);
|
|
726
706
|
}
|
|
727
707
|
});
|
|
728
708
|
});
|
|
@@ -743,7 +723,7 @@ const M = class M extends B.Doc {
|
|
|
743
723
|
this.closeConn(e), clearInterval(n);
|
|
744
724
|
}
|
|
745
725
|
}
|
|
746
|
-
},
|
|
726
|
+
}, us);
|
|
747
727
|
e.on("close", () => {
|
|
748
728
|
this.closeConn(e), clearInterval(n);
|
|
749
729
|
}), e.on("pong", () => {
|
|
@@ -751,11 +731,11 @@ const M = class M extends B.Doc {
|
|
|
751
731
|
});
|
|
752
732
|
{
|
|
753
733
|
const r = C.createEncoder();
|
|
754
|
-
C.writeVarUint(r,
|
|
734
|
+
C.writeVarUint(r, Y), $t(r, this), this.send(e, C.toUint8Array(r));
|
|
755
735
|
const l = this.awareness.getStates();
|
|
756
736
|
if (l.size > 0) {
|
|
757
737
|
const a = C.createEncoder();
|
|
758
|
-
C.writeVarUint(a, ue), C.writeVarUint8Array(a,
|
|
738
|
+
C.writeVarUint(a, ue), C.writeVarUint8Array(a, Pe(this.awareness, Array.from(l.keys()))), this.send(e, C.toUint8Array(a));
|
|
759
739
|
}
|
|
760
740
|
}
|
|
761
741
|
});
|
|
@@ -763,11 +743,11 @@ const M = class M extends B.Doc {
|
|
|
763
743
|
try {
|
|
764
744
|
const n = C.createEncoder(), r = pe.createDecoder(s), l = pe.readVarUint(r);
|
|
765
745
|
switch (l) {
|
|
766
|
-
case
|
|
767
|
-
C.writeVarUint(n,
|
|
746
|
+
case Y:
|
|
747
|
+
C.writeVarUint(n, Y), Bt(r, n, this, null), C.length(n) > 1 && (this.ensureDataStructure(), this.send(e, C.toUint8Array(n)));
|
|
768
748
|
break;
|
|
769
749
|
case ue: {
|
|
770
|
-
|
|
750
|
+
Mt(this.awareness, pe.readVarUint8Array(r), e);
|
|
771
751
|
break;
|
|
772
752
|
}
|
|
773
753
|
default:
|
|
@@ -778,40 +758,40 @@ const M = class M extends B.Doc {
|
|
|
778
758
|
}
|
|
779
759
|
this.save();
|
|
780
760
|
});
|
|
781
|
-
this.options = e, V(this.draftYjsFilePath) && B.applyUpdate(this,
|
|
782
|
-
|
|
761
|
+
this.options = e, V(this.draftYjsFilePath) && B.applyUpdate(this, X(this.draftYjsFilePath)), this.syncedStore = vt(
|
|
762
|
+
At(
|
|
783
763
|
{ pages: {}, pageIds: [], components: {}, supportedLocales: [], config: {}, resources: {} },
|
|
784
764
|
this
|
|
785
765
|
)
|
|
786
|
-
), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new
|
|
766
|
+
), this.initObserver(), this.on("update", this.updateHandler), this.awareness = new Ut(this), this.awareness.on("update", this.awarenessChangeHandler), this.ensureDataStructure();
|
|
787
767
|
}
|
|
788
768
|
// safe delete project state dir
|
|
789
769
|
static safeDeleteProjectStateDir(e) {
|
|
790
770
|
if (!e)
|
|
791
771
|
throw new Error("Should provide project context");
|
|
792
772
|
try {
|
|
793
|
-
const s = O(
|
|
794
|
-
|
|
773
|
+
const s = O(q, e), n = O(q, `@del-${e}`);
|
|
774
|
+
Ae(s, n);
|
|
795
775
|
} catch (s) {
|
|
796
776
|
v.error("Failed to safe delete project state dir:", s);
|
|
797
777
|
}
|
|
798
778
|
}
|
|
799
779
|
static get projectIds() {
|
|
800
780
|
return me("*/", {
|
|
801
|
-
cwd:
|
|
781
|
+
cwd: q,
|
|
802
782
|
ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
|
|
803
783
|
// Ignore temp directories and hidden files
|
|
804
784
|
});
|
|
805
785
|
}
|
|
806
786
|
static get allShared() {
|
|
807
|
-
return this.projectIds.map((e) =>
|
|
787
|
+
return this.projectIds.map((e) => _.shared(e));
|
|
808
788
|
}
|
|
809
789
|
static shared(e) {
|
|
810
790
|
if (!e)
|
|
811
791
|
throw new Error("Should provide project context");
|
|
812
792
|
let s = this.sharedInstances.get(e);
|
|
813
|
-
return s || (s = new
|
|
814
|
-
path: O(
|
|
793
|
+
return s || (s = new _({
|
|
794
|
+
path: O(q, e)
|
|
815
795
|
}), this.sharedInstances.set(e, s), s);
|
|
816
796
|
}
|
|
817
797
|
destroy() {
|
|
@@ -844,20 +824,20 @@ const M = class M extends B.Doc {
|
|
|
844
824
|
var s, n, r, l;
|
|
845
825
|
if (e === "draft")
|
|
846
826
|
return JSON.parse(JSON.stringify(this.syncedStore));
|
|
847
|
-
if (!this.states[e] && (this.states[e] = await
|
|
827
|
+
if (!this.states[e] && (this.states[e] = await ze(this.getPublishDir(e), { includeResources: !0 }) ?? fs(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
|
|
848
828
|
(r = this.states[e]).config ?? (r.config = {});
|
|
849
829
|
const a = ge.env.languages.map((i) => ({ locale: i.code, name: i.name }));
|
|
850
830
|
this.states[e].config.defaultLocale = (l = a[0]) == null ? void 0 : l.locale;
|
|
851
831
|
}
|
|
852
832
|
return {
|
|
853
833
|
...this.states[e],
|
|
854
|
-
resources: await
|
|
855
|
-
var u,
|
|
856
|
-
const { pages: i, components: c } =
|
|
834
|
+
resources: await bs().then(async (a) => {
|
|
835
|
+
var u, f, g, y;
|
|
836
|
+
const { pages: i, components: c } = Tt(a, "pages", "components");
|
|
857
837
|
let p = c;
|
|
858
|
-
if ((
|
|
838
|
+
if ((f = (u = this.states[e]) == null ? void 0 : u.resources) != null && f.components)
|
|
859
839
|
p = {
|
|
860
|
-
...(
|
|
840
|
+
...(y = (g = this.states[e]) == null ? void 0 : g.resources) == null ? void 0 : y.components
|
|
861
841
|
};
|
|
862
842
|
else {
|
|
863
843
|
const A = J(this.options.path), x = await $.findByPk(A);
|
|
@@ -876,7 +856,7 @@ const M = class M extends B.Doc {
|
|
|
876
856
|
}
|
|
877
857
|
async setState(e, s) {
|
|
878
858
|
const n = await Ss(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
|
|
879
|
-
F(L(r), { recursive: !0 }),
|
|
859
|
+
F(L(r), { recursive: !0 }), Fe(r, { force: !0, recursive: !0 }), Ae(n, r), this.states[e] = s;
|
|
880
860
|
}
|
|
881
861
|
getPublishDir(e) {
|
|
882
862
|
return O(this.options.path, e);
|
|
@@ -886,17 +866,17 @@ const M = class M extends B.Doc {
|
|
|
886
866
|
for (const r of s) {
|
|
887
867
|
const l = await $.findByPk(r);
|
|
888
868
|
if (!l) continue;
|
|
889
|
-
const a = await
|
|
890
|
-
|
|
869
|
+
const a = await _.shared(r).getState(e), i = Pt(
|
|
870
|
+
S.env.languages.map((c) => c.code),
|
|
891
871
|
a.supportedLocales.map((c) => c.locale)
|
|
892
872
|
);
|
|
893
873
|
for (const c of a.pageIds) {
|
|
894
874
|
const p = a.pages[c];
|
|
895
875
|
if (!p || e === "production" && !p.isPublic)
|
|
896
876
|
continue;
|
|
897
|
-
const u = p.slug,
|
|
877
|
+
const u = p.slug, f = l.slug || r, g = {
|
|
898
878
|
projectId: r,
|
|
899
|
-
projectSlug:
|
|
879
|
+
projectSlug: f,
|
|
900
880
|
pageSlug: u,
|
|
901
881
|
pageId: c,
|
|
902
882
|
// default locale
|
|
@@ -906,36 +886,36 @@ const M = class M extends B.Doc {
|
|
|
906
886
|
isPublic: p.isPublic,
|
|
907
887
|
isTemplate: p.isTemplate
|
|
908
888
|
};
|
|
909
|
-
|
|
889
|
+
f && (n[M("/", f, u)] = {
|
|
910
890
|
...g,
|
|
911
891
|
shouldRedirect: !0,
|
|
912
892
|
mainPage: !0
|
|
913
|
-
}), n[
|
|
893
|
+
}), n[M("/", r, u)] = {
|
|
914
894
|
...g,
|
|
915
895
|
shouldRedirect: !0,
|
|
916
896
|
mainPage: !0
|
|
917
897
|
};
|
|
918
|
-
for (const
|
|
919
|
-
const A = { ...g, locale:
|
|
920
|
-
n[
|
|
898
|
+
for (const y of i) {
|
|
899
|
+
const A = { ...g, locale: y };
|
|
900
|
+
n[M("/", y, r, u)] = A, f && (n[M("/", y, f, u)] = A);
|
|
921
901
|
}
|
|
922
902
|
}
|
|
923
903
|
}
|
|
924
904
|
return n;
|
|
925
905
|
}
|
|
926
906
|
};
|
|
927
|
-
P(
|
|
928
|
-
P(
|
|
907
|
+
P(_, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
|
|
908
|
+
P(_, "sharedInstances", new he({
|
|
929
909
|
max: 100,
|
|
930
910
|
// Maximum number of instances to store
|
|
931
|
-
ttl:
|
|
911
|
+
ttl: _.INSTANCE_TTL,
|
|
932
912
|
dispose: (e) => {
|
|
933
913
|
e.destroy();
|
|
934
914
|
}
|
|
935
915
|
}));
|
|
936
|
-
let oe =
|
|
937
|
-
function
|
|
938
|
-
return
|
|
916
|
+
let oe = _;
|
|
917
|
+
function Ke() {
|
|
918
|
+
return Et(O(S.env.dataDir, "tmp-"));
|
|
939
919
|
}
|
|
940
920
|
function ne(t, o, e = []) {
|
|
941
921
|
return Array.isArray(t) ? t.flatMap((s, n) => ne(s, o, [...e, n])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([s, n]) => ne(n, o, [...e, s])) : o(t) ? [e] : [];
|
|
@@ -943,75 +923,75 @@ function ne(t, o, e = []) {
|
|
|
943
923
|
function R(t) {
|
|
944
924
|
return t.filter((o) => o != null);
|
|
945
925
|
}
|
|
946
|
-
async function
|
|
926
|
+
async function gs(t, o, e) {
|
|
947
927
|
if (!t || !V(t) || !Z(t).isFile())
|
|
948
928
|
return null;
|
|
949
929
|
let s = e[t];
|
|
950
|
-
return s || (s = (async () => (await
|
|
930
|
+
return s || (s = (async () => (await ls({
|
|
951
931
|
filePath: t,
|
|
952
932
|
fileName: o
|
|
953
933
|
})).data.filename)(), e[t] = s), s;
|
|
954
934
|
}
|
|
955
|
-
const
|
|
956
|
-
const e = J(t), s = await
|
|
957
|
-
name:
|
|
958
|
-
path:
|
|
935
|
+
const hs = async (t, o) => {
|
|
936
|
+
const e = J(t), s = await ht({
|
|
937
|
+
name: Je,
|
|
938
|
+
path: M("/uploads", e),
|
|
959
939
|
responseType: "stream",
|
|
960
940
|
method: "GET"
|
|
961
941
|
});
|
|
962
942
|
if (s.status >= 200 && s.status < 400) {
|
|
963
|
-
const n =
|
|
964
|
-
await
|
|
943
|
+
const n = bt(o);
|
|
944
|
+
await Nt(s.data, n);
|
|
965
945
|
} else
|
|
966
946
|
throw new Error(`download asset failed ${s.status}`);
|
|
967
|
-
},
|
|
947
|
+
}, ys = async (t, o) => {
|
|
968
948
|
await Promise.all(
|
|
969
949
|
t.map(async (e) => {
|
|
970
950
|
try {
|
|
971
|
-
await
|
|
951
|
+
await hs(e, O(o, J(e)));
|
|
972
952
|
} catch (s) {
|
|
973
953
|
v.error(`Failed to export assets: ${e}, ${s}`);
|
|
974
954
|
}
|
|
975
955
|
})
|
|
976
956
|
);
|
|
977
957
|
};
|
|
978
|
-
function
|
|
979
|
-
return
|
|
958
|
+
function We(t) {
|
|
959
|
+
return Se.test(t) ? [t] : W.test(t) ? (Ne.lastIndex = 0, Array.from(t.matchAll(Ne)).map((e) => e[1]).filter((e) => !!e)) : [];
|
|
980
960
|
}
|
|
981
961
|
async function de(t, o, e) {
|
|
982
962
|
const { getFilename: s, exportAssets: n } = e, r = O(o, s(t));
|
|
983
|
-
if (F(L(r), { recursive: !0 }), te(r,
|
|
963
|
+
if (F(L(r), { recursive: !0 }), te(r, H.stringify(t)), n) {
|
|
984
964
|
const a = ne(
|
|
985
965
|
t,
|
|
986
|
-
(i) => typeof i == "string" && (
|
|
966
|
+
(i) => typeof i == "string" && (Se.test(i) || W.test(i))
|
|
987
967
|
).map((i) => {
|
|
988
968
|
const c = ye(t, i);
|
|
989
|
-
return
|
|
969
|
+
return We(c);
|
|
990
970
|
}).flat().filter(Boolean);
|
|
991
|
-
await
|
|
971
|
+
await ys(a, L(r));
|
|
992
972
|
}
|
|
993
973
|
}
|
|
994
|
-
const
|
|
974
|
+
const Le = new he({
|
|
995
975
|
max: 1e3,
|
|
996
976
|
ttl: 30 * 24 * 60 * 60 * 1e3
|
|
997
977
|
});
|
|
998
|
-
async function
|
|
978
|
+
async function Re(t, o, e) {
|
|
999
979
|
var a;
|
|
1000
980
|
const s = ne(
|
|
1001
981
|
t,
|
|
1002
|
-
(i) => typeof i == "string" && (
|
|
1003
|
-
), n =
|
|
982
|
+
(i) => typeof i == "string" && (Se.test(i) || W.test(i))
|
|
983
|
+
), n = kt(2), r = s.map(
|
|
1004
984
|
(i) => n(async () => {
|
|
1005
985
|
try {
|
|
1006
|
-
const c = ye(t, i), p =
|
|
986
|
+
const c = ye(t, i), p = We(c);
|
|
1007
987
|
for (const u of p) {
|
|
1008
|
-
const
|
|
988
|
+
const f = J(u), g = e.getFilePath(u, i), y = g ? `${g}:${f}` : f, A = Le.get(y);
|
|
1009
989
|
if (A) {
|
|
1010
|
-
|
|
990
|
+
W.test(c) || Te(t, i, A);
|
|
1011
991
|
return;
|
|
1012
992
|
}
|
|
1013
|
-
const x = await
|
|
1014
|
-
x && (
|
|
993
|
+
const x = await gs(g, f, o);
|
|
994
|
+
x && (W.test(c) || Te(t, i, x), Le.set(y, x));
|
|
1015
995
|
}
|
|
1016
996
|
} catch (c) {
|
|
1017
997
|
v.error(`Failed to process upload for path ${i.join(".")}:`, c.message || c.reason);
|
|
@@ -1027,82 +1007,82 @@ async function Ss(t, {
|
|
|
1027
1007
|
rawConfig: n,
|
|
1028
1008
|
includeResources: r = !1
|
|
1029
1009
|
} = {}) {
|
|
1030
|
-
var U, D,
|
|
1031
|
-
const l = e === "all" ? t.pageIds : e, a =
|
|
1010
|
+
var U, D, h, E, b, I;
|
|
1011
|
+
const l = e === "all" ? t.pageIds : e, a = ws({
|
|
1032
1012
|
state: t,
|
|
1033
1013
|
pageIds: l,
|
|
1034
1014
|
componentIds: s === "all" ? Object.keys(t.components) : s
|
|
1035
|
-
}), i = (
|
|
1036
|
-
var
|
|
1015
|
+
}), i = (m, d) => {
|
|
1016
|
+
var w;
|
|
1037
1017
|
return {
|
|
1038
|
-
id:
|
|
1039
|
-
name:
|
|
1040
|
-
isTemplateSection:
|
|
1041
|
-
templateDescription:
|
|
1042
|
-
component:
|
|
1043
|
-
config:
|
|
1044
|
-
visibility:
|
|
1045
|
-
properties: ((
|
|
1018
|
+
id: m.id,
|
|
1019
|
+
name: m.name,
|
|
1020
|
+
isTemplateSection: m.isTemplateSection ?? !1,
|
|
1021
|
+
templateDescription: m.templateDescription,
|
|
1022
|
+
component: m.component,
|
|
1023
|
+
config: m.config,
|
|
1024
|
+
visibility: m.visibility,
|
|
1025
|
+
properties: ((w = m.locales) == null ? void 0 : w[d]) ?? {}
|
|
1046
1026
|
};
|
|
1047
|
-
}, c = (
|
|
1048
|
-
var
|
|
1027
|
+
}, c = (m, d) => {
|
|
1028
|
+
var w;
|
|
1049
1029
|
return {
|
|
1050
|
-
id:
|
|
1051
|
-
createdAt:
|
|
1052
|
-
updatedAt:
|
|
1053
|
-
publishedAt:
|
|
1054
|
-
isPublic:
|
|
1055
|
-
isTemplate:
|
|
1056
|
-
meta: ((
|
|
1030
|
+
id: m.id,
|
|
1031
|
+
createdAt: m.createdAt,
|
|
1032
|
+
updatedAt: m.updatedAt,
|
|
1033
|
+
publishedAt: m.publishedAt,
|
|
1034
|
+
isPublic: m.isPublic ?? !0,
|
|
1035
|
+
isTemplate: m.isTemplate ?? !1,
|
|
1036
|
+
meta: ((w = m.locales) == null ? void 0 : w[d]) ?? {},
|
|
1057
1037
|
sections: R(
|
|
1058
|
-
|
|
1059
|
-
const N =
|
|
1038
|
+
m.sectionIds.map((k) => {
|
|
1039
|
+
const N = m.sections[k];
|
|
1060
1040
|
return N && i(N, d);
|
|
1061
1041
|
})
|
|
1062
1042
|
)
|
|
1063
1043
|
};
|
|
1064
1044
|
}, p = R(
|
|
1065
|
-
t.supportedLocales.map((
|
|
1066
|
-
(
|
|
1067
|
-
const
|
|
1068
|
-
return
|
|
1069
|
-
locale:
|
|
1070
|
-
slug:
|
|
1071
|
-
page: c(
|
|
1045
|
+
t.supportedLocales.map((m) => m.locale).flatMap(
|
|
1046
|
+
(m) => l.map((d) => {
|
|
1047
|
+
const w = t.pages[d];
|
|
1048
|
+
return w && {
|
|
1049
|
+
locale: m,
|
|
1050
|
+
slug: w.slug,
|
|
1051
|
+
page: c(w, m)
|
|
1072
1052
|
};
|
|
1073
1053
|
})
|
|
1074
1054
|
)
|
|
1075
|
-
), u =
|
|
1076
|
-
F(
|
|
1055
|
+
), u = Ke(), f = O(u, "pages");
|
|
1056
|
+
F(f, { recursive: !0 });
|
|
1077
1057
|
const g = O(u, "components");
|
|
1078
1058
|
F(g, { recursive: !0 });
|
|
1079
|
-
for (const { locale:
|
|
1080
|
-
await de(
|
|
1081
|
-
getFilename: () => `${
|
|
1059
|
+
for (const { locale: m, slug: d, page: w } of p)
|
|
1060
|
+
await de(w, f, {
|
|
1061
|
+
getFilename: () => `${He(d) || "index"}.${m}.yml`,
|
|
1082
1062
|
exportAssets: o
|
|
1083
1063
|
});
|
|
1084
|
-
for (const
|
|
1085
|
-
const d = (U = t.components[
|
|
1064
|
+
for (const m of a) {
|
|
1065
|
+
const d = (U = t.components[m]) == null ? void 0 : U.data;
|
|
1086
1066
|
d && await de(d, g, {
|
|
1087
|
-
getFilename: (
|
|
1067
|
+
getFilename: (w) => `${w.name || "unnamed"}.${w.id}.yml`,
|
|
1088
1068
|
exportAssets: o
|
|
1089
1069
|
});
|
|
1090
1070
|
}
|
|
1091
|
-
const
|
|
1092
|
-
F(L(
|
|
1071
|
+
const y = O(u, ".blocklet/pages/pages.config.yml");
|
|
1072
|
+
F(L(y), { recursive: !0 });
|
|
1093
1073
|
const A = {
|
|
1094
1074
|
pages: R(
|
|
1095
|
-
l.map((
|
|
1096
|
-
const d = t.pages[
|
|
1097
|
-
return d && { id:
|
|
1075
|
+
l.map((m) => {
|
|
1076
|
+
const d = t.pages[m];
|
|
1077
|
+
return d && { id: m, slug: d.slug };
|
|
1098
1078
|
})
|
|
1099
1079
|
),
|
|
1100
1080
|
components: R(
|
|
1101
|
-
a.map((
|
|
1102
|
-
var
|
|
1103
|
-
const d = (
|
|
1081
|
+
a.map((m) => {
|
|
1082
|
+
var w;
|
|
1083
|
+
const d = (w = t.components[m]) == null ? void 0 : w.data;
|
|
1104
1084
|
return d && {
|
|
1105
|
-
id:
|
|
1085
|
+
id: m,
|
|
1106
1086
|
name: d.name
|
|
1107
1087
|
};
|
|
1108
1088
|
})
|
|
@@ -1110,11 +1090,11 @@ async function Ss(t, {
|
|
|
1110
1090
|
...r ? {
|
|
1111
1091
|
resources: {
|
|
1112
1092
|
components: R(
|
|
1113
|
-
Object.keys(((D = t.resources) == null ? void 0 : D.components) || {}).map((
|
|
1114
|
-
var d,
|
|
1093
|
+
Object.keys(((D = t.resources) == null ? void 0 : D.components) || {}).map((m) => {
|
|
1094
|
+
var d, w, k, N;
|
|
1115
1095
|
return {
|
|
1116
|
-
id:
|
|
1117
|
-
name: (N = (k = (
|
|
1096
|
+
id: m,
|
|
1097
|
+
name: (N = (k = (w = (d = t.resources) == null ? void 0 : d.components) == null ? void 0 : w[m]) == null ? void 0 : k.component) == null ? void 0 : N.name
|
|
1118
1098
|
};
|
|
1119
1099
|
})
|
|
1120
1100
|
)
|
|
@@ -1123,13 +1103,13 @@ async function Ss(t, {
|
|
|
1123
1103
|
supportedLocales: t.supportedLocales,
|
|
1124
1104
|
config: t.config
|
|
1125
1105
|
};
|
|
1126
|
-
te(
|
|
1106
|
+
te(y, H.stringify(A));
|
|
1127
1107
|
const x = O(u, "config.source.json");
|
|
1128
1108
|
if (n && te(x, JSON.stringify(n)), r) {
|
|
1129
|
-
const
|
|
1109
|
+
const m = O(u, "resources"), d = O(m, "components");
|
|
1130
1110
|
F(d, { recursive: !0 });
|
|
1131
|
-
for (const
|
|
1132
|
-
const k = (I = (b = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : b[
|
|
1111
|
+
for (const w of Object.keys(((h = t == null ? void 0 : t.resources) == null ? void 0 : h.components) ?? {})) {
|
|
1112
|
+
const k = (I = (b = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : b[w]) == null ? void 0 : I.component;
|
|
1133
1113
|
k && await de(k, d, {
|
|
1134
1114
|
getFilename: (N) => `${N.name || "unnamed"}.${N.id}.yml`,
|
|
1135
1115
|
exportAssets: o
|
|
@@ -1138,45 +1118,45 @@ async function Ss(t, {
|
|
|
1138
1118
|
}
|
|
1139
1119
|
return u;
|
|
1140
1120
|
}
|
|
1141
|
-
async function
|
|
1121
|
+
async function ze(t, { importAssets: o, includeResources: e } = {}) {
|
|
1142
1122
|
var r, l, a;
|
|
1143
1123
|
if (!V(t))
|
|
1144
1124
|
return null;
|
|
1145
1125
|
let s, n = !1;
|
|
1146
1126
|
try {
|
|
1147
|
-
Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s =
|
|
1127
|
+
Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s = Ke(), await Lt({ file: t, C: s }));
|
|
1148
1128
|
const i = me("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), c = i && O(L(i), "../../pages"), p = i && O(L(i), "../../components"), u = i && O(L(i), "../../chunks");
|
|
1149
1129
|
if (!i)
|
|
1150
1130
|
return null;
|
|
1151
|
-
const
|
|
1152
|
-
let I = O(
|
|
1153
|
-
return (!V(I) || !Z(I).isFile()) && (I = O(
|
|
1154
|
-
},
|
|
1131
|
+
const f = H.parse(X(i).toString()), g = (h, E, b) => {
|
|
1132
|
+
let I = O(h, `${E}${b ? `.${b}` : ""}.yml`);
|
|
1133
|
+
return (!V(I) || !Z(I).isFile()) && (I = O(h, E, `index${b ? `.${b}` : ""}.yml`), !V(I) || !Z(I)) ? null : H.parse(X(I).toString());
|
|
1134
|
+
}, y = (h, E) => {
|
|
1155
1135
|
try {
|
|
1156
|
-
const b = me(`*.${E}.yml`, { cwd:
|
|
1157
|
-
return b ?
|
|
1136
|
+
const b = me(`*.${E}.yml`, { cwd: h, absolute: !0 })[0];
|
|
1137
|
+
return b ? H.parse(X(b).toString()) : null;
|
|
1158
1138
|
} catch (b) {
|
|
1159
1139
|
v.error("parse component error", b);
|
|
1160
1140
|
}
|
|
1161
1141
|
return null;
|
|
1162
1142
|
}, A = R(
|
|
1163
|
-
|
|
1164
|
-
var
|
|
1143
|
+
f.pages.map(({ slug: h }) => {
|
|
1144
|
+
var m;
|
|
1165
1145
|
const E = R(
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
return { locale: d, page:
|
|
1170
|
-
const k = c ? g(c,
|
|
1146
|
+
f.supportedLocales.map(({ locale: d }) => {
|
|
1147
|
+
const w = c ? g(c, He(h), d) : void 0;
|
|
1148
|
+
if (w)
|
|
1149
|
+
return { locale: d, page: w };
|
|
1150
|
+
const k = c ? g(c, h, d) : void 0;
|
|
1171
1151
|
return k && { locale: d, page: k };
|
|
1172
1152
|
})
|
|
1173
|
-
), b = (
|
|
1153
|
+
), b = (m = E[0]) == null ? void 0 : m.page;
|
|
1174
1154
|
if (!b)
|
|
1175
1155
|
return null;
|
|
1176
1156
|
const I = b.sections.map((d) => {
|
|
1177
|
-
const
|
|
1157
|
+
const w = d.id || De();
|
|
1178
1158
|
return {
|
|
1179
|
-
id:
|
|
1159
|
+
id: w,
|
|
1180
1160
|
component: d.component,
|
|
1181
1161
|
config: d.config,
|
|
1182
1162
|
name: d.name,
|
|
@@ -1186,7 +1166,7 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1186
1166
|
locales: Object.fromEntries(
|
|
1187
1167
|
R(
|
|
1188
1168
|
E.map(({ locale: k, page: N }) => {
|
|
1189
|
-
const Ie = N.sections.find((
|
|
1169
|
+
const Ie = N.sections.find((Xe) => Xe.id === w);
|
|
1190
1170
|
return Ie && [k, Ie.properties];
|
|
1191
1171
|
})
|
|
1192
1172
|
)
|
|
@@ -1194,54 +1174,54 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1194
1174
|
};
|
|
1195
1175
|
});
|
|
1196
1176
|
return {
|
|
1197
|
-
id: b.id ||
|
|
1177
|
+
id: b.id || De(),
|
|
1198
1178
|
createdAt: b.createdAt,
|
|
1199
1179
|
updatedAt: b.updatedAt,
|
|
1200
1180
|
publishedAt: b.publishedAt,
|
|
1201
1181
|
isPublic: b.isPublic ?? !0,
|
|
1202
1182
|
isTemplate: b.isTemplate ?? !1,
|
|
1203
|
-
slug:
|
|
1183
|
+
slug: h,
|
|
1204
1184
|
sections: Object.fromEntries(I.map((d) => [d.id, d])),
|
|
1205
1185
|
sectionIds: I.map((d) => d.id),
|
|
1206
|
-
locales: Object.fromEntries(E.map(({ locale: d, page:
|
|
1186
|
+
locales: Object.fromEntries(E.map(({ locale: d, page: w }) => [d, w.meta]))
|
|
1207
1187
|
};
|
|
1208
1188
|
})
|
|
1209
|
-
), x = p ? R(((r =
|
|
1189
|
+
), x = p ? R(((r = f.components) == null ? void 0 : r.map(({ id: h }) => y(p, h))) ?? []) : [];
|
|
1210
1190
|
if (o) {
|
|
1211
|
-
const
|
|
1191
|
+
const h = (...E) => {
|
|
1212
1192
|
v.info(`[${n ? J(t) : J(O(t, "../../../../"))}] importAssets:`, ...E);
|
|
1213
1193
|
};
|
|
1214
1194
|
try {
|
|
1215
|
-
|
|
1216
|
-
resources: [`${
|
|
1195
|
+
h("wait image-bin api ready"), await Rt({
|
|
1196
|
+
resources: [`${ft(Ht)}/api/sdk/uploads`],
|
|
1217
1197
|
validateStatus: (I) => I >= 200 && I <= 500
|
|
1218
|
-
}),
|
|
1198
|
+
}), h("image-bin api is ready");
|
|
1219
1199
|
const E = {}, b = {};
|
|
1220
|
-
|
|
1221
|
-
|
|
1200
|
+
h("start to upload assets"), await Promise.allSettled([
|
|
1201
|
+
Re(x, E, {
|
|
1222
1202
|
getFilePath: (I) => p && O(p, I),
|
|
1223
1203
|
onFinish: (I) => {
|
|
1224
|
-
|
|
1204
|
+
h(`upload ${I.length} component assets`);
|
|
1225
1205
|
}
|
|
1226
1206
|
}),
|
|
1227
|
-
|
|
1228
|
-
getFilePath: (I,
|
|
1229
|
-
const d = ye(A,
|
|
1207
|
+
Re(A, b, {
|
|
1208
|
+
getFilePath: (I, m) => {
|
|
1209
|
+
const d = ye(A, m.slice(0, 1));
|
|
1230
1210
|
return c && O(c, L(d.slug), I);
|
|
1231
1211
|
},
|
|
1232
1212
|
onFinish: (I) => {
|
|
1233
|
-
|
|
1213
|
+
h(`upload ${I.length} page assets`);
|
|
1234
1214
|
}
|
|
1235
1215
|
})
|
|
1236
|
-
]),
|
|
1216
|
+
]), h("upload assets done"), global.gc && global.gc();
|
|
1237
1217
|
} catch (E) {
|
|
1238
|
-
|
|
1218
|
+
h("Error during asset import:", E);
|
|
1239
1219
|
}
|
|
1240
1220
|
}
|
|
1241
1221
|
const U = {};
|
|
1242
1222
|
if (e) {
|
|
1243
|
-
const
|
|
1244
|
-
((a = (l =
|
|
1223
|
+
const h = i && O(L(i), "../../resources/components"), E = R(
|
|
1224
|
+
((a = (l = f.resources) == null ? void 0 : l.components) == null ? void 0 : a.map(({ id: b }) => y(h, b))) ?? []
|
|
1245
1225
|
);
|
|
1246
1226
|
E.length > 0 && (U.components = Object.fromEntries(
|
|
1247
1227
|
E.map((b, I) => [b.id, { index: I, component: b }])
|
|
@@ -1249,31 +1229,31 @@ async function qe(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1249
1229
|
}
|
|
1250
1230
|
const D = {};
|
|
1251
1231
|
if (u && V(u)) {
|
|
1252
|
-
const
|
|
1253
|
-
for (const E of
|
|
1232
|
+
const h = wt(u);
|
|
1233
|
+
for (const E of h)
|
|
1254
1234
|
D[E] = O(u, E);
|
|
1255
1235
|
}
|
|
1256
1236
|
return {
|
|
1257
|
-
supportedLocales:
|
|
1258
|
-
pageIds: A.map((
|
|
1259
|
-
components: Object.fromEntries(x.map((
|
|
1260
|
-
pages: Object.fromEntries(A.map((
|
|
1261
|
-
config:
|
|
1237
|
+
supportedLocales: f.supportedLocales,
|
|
1238
|
+
pageIds: A.map((h) => h.id),
|
|
1239
|
+
components: Object.fromEntries(x.map((h, E) => [h.id, { index: E, data: h }])),
|
|
1240
|
+
pages: Object.fromEntries(A.map((h) => [h.id, h])),
|
|
1241
|
+
config: f.config || {},
|
|
1262
1242
|
resources: U,
|
|
1263
1243
|
chunks: D
|
|
1264
1244
|
};
|
|
1265
1245
|
} finally {
|
|
1266
|
-
n && s &&
|
|
1246
|
+
n && s && Fe(s, { force: !0, recursive: !0 });
|
|
1267
1247
|
}
|
|
1268
1248
|
}
|
|
1269
|
-
async function
|
|
1249
|
+
async function Ue(t, o, {
|
|
1270
1250
|
pages: e,
|
|
1271
1251
|
pageMergeMode: s = "byUpdateTime",
|
|
1272
1252
|
deletePages: n = !1,
|
|
1273
1253
|
publishMode: r = void 0
|
|
1274
1254
|
} = {}) {
|
|
1275
1255
|
try {
|
|
1276
|
-
r &&
|
|
1256
|
+
r && es(r);
|
|
1277
1257
|
} catch (p) {
|
|
1278
1258
|
v.error("clear preload page cache error", { error: p });
|
|
1279
1259
|
}
|
|
@@ -1281,16 +1261,16 @@ async function _e(t, o, {
|
|
|
1281
1261
|
for (const p of e ?? l) {
|
|
1282
1262
|
const u = a[p];
|
|
1283
1263
|
if (!u) {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1264
|
+
const f = o.pageIds.indexOf(p);
|
|
1265
|
+
f !== -1 && n && (o.pageIds.splice(f, 1), delete o.pages[p]);
|
|
1286
1266
|
continue;
|
|
1287
1267
|
}
|
|
1288
1268
|
if (o.pageIds.includes(u.id)) {
|
|
1289
1269
|
if (s === "replace")
|
|
1290
1270
|
o.pages[u.id] = u;
|
|
1291
1271
|
else if (s === "byUpdateTime") {
|
|
1292
|
-
const
|
|
1293
|
-
(!
|
|
1272
|
+
const f = o.pages[u.id];
|
|
1273
|
+
(!f || u.updatedAt && u.updatedAt > f.updatedAt) && (o.pages[u.id] = u);
|
|
1294
1274
|
}
|
|
1295
1275
|
} else
|
|
1296
1276
|
o.pageIds.push(u.id), o.pages[u.id] = u;
|
|
@@ -1298,35 +1278,35 @@ async function _e(t, o, {
|
|
|
1298
1278
|
if (n && !e)
|
|
1299
1279
|
for (const p of o.pageIds)
|
|
1300
1280
|
t.pageIds.includes(p) || delete o.pages[p], o.pageIds = [...o.pageIds].filter((u) => t.pageIds.includes(u));
|
|
1301
|
-
if (o.supportedLocales.splice(0, o.supportedLocales.length), o.supportedLocales.push(...
|
|
1281
|
+
if (o.supportedLocales.splice(0, o.supportedLocales.length), o.supportedLocales.push(...Ct(i)), n)
|
|
1302
1282
|
for (const p of Object.keys(o.components))
|
|
1303
1283
|
delete o.components[p];
|
|
1304
1284
|
let c = JSON.parse(JSON.stringify(t.components));
|
|
1305
1285
|
c = Object.fromEntries(
|
|
1306
1286
|
await Promise.all(
|
|
1307
1287
|
Object.entries(c).map(async ([p, u]) => {
|
|
1308
|
-
const
|
|
1288
|
+
const f = await Ye(u == null ? void 0 : u.data);
|
|
1309
1289
|
return [
|
|
1310
1290
|
p,
|
|
1311
1291
|
{
|
|
1312
1292
|
...u,
|
|
1313
|
-
data:
|
|
1293
|
+
data: f
|
|
1314
1294
|
}
|
|
1315
1295
|
];
|
|
1316
1296
|
})
|
|
1317
1297
|
)
|
|
1318
1298
|
), Object.assign(o.components, c), Object.assign(o.config, JSON.parse(JSON.stringify(t.config))), o.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
|
|
1319
1299
|
}
|
|
1320
|
-
const
|
|
1300
|
+
const Ye = ae(
|
|
1321
1301
|
async (t) => {
|
|
1322
1302
|
var o;
|
|
1323
|
-
if (!
|
|
1303
|
+
if (!xt(t == null ? void 0 : t.properties))
|
|
1324
1304
|
return t;
|
|
1325
1305
|
if (((o = t == null ? void 0 : t.renderer) == null ? void 0 : o.type) === "react-component") {
|
|
1326
1306
|
const { script: e } = (t == null ? void 0 : t.renderer) || {};
|
|
1327
1307
|
if (e)
|
|
1328
1308
|
try {
|
|
1329
|
-
const s = await
|
|
1309
|
+
const s = await as(e, "PROPERTIES_SCHEMA", t.id);
|
|
1330
1310
|
s && s.length > 0 && t && (t.properties = {}, s.forEach((n, r) => {
|
|
1331
1311
|
t != null && t.properties && (t.properties[n.id] = {
|
|
1332
1312
|
index: r,
|
|
@@ -1351,7 +1331,7 @@ const Qe = ae(
|
|
|
1351
1331
|
}
|
|
1352
1332
|
}
|
|
1353
1333
|
);
|
|
1354
|
-
function
|
|
1334
|
+
function ws({
|
|
1355
1335
|
state: t,
|
|
1356
1336
|
pageIds: o = [],
|
|
1357
1337
|
componentIds: e = []
|
|
@@ -1373,21 +1353,21 @@ function Es({
|
|
|
1373
1353
|
}
|
|
1374
1354
|
return [...n];
|
|
1375
1355
|
}
|
|
1376
|
-
let re, G,
|
|
1377
|
-
function
|
|
1356
|
+
let re, G, we, Ee, be;
|
|
1357
|
+
function qe() {
|
|
1378
1358
|
return re = (async () => {
|
|
1379
|
-
const t =
|
|
1359
|
+
const t = gt({
|
|
1380
1360
|
types: [
|
|
1381
|
-
{ did:
|
|
1382
|
-
{ did:
|
|
1361
|
+
{ did: Je, type: ke },
|
|
1362
|
+
{ did: cs, type: ke }
|
|
1383
1363
|
]
|
|
1384
1364
|
});
|
|
1385
1365
|
G = (await Promise.all(
|
|
1386
1366
|
t.map(async (e) => {
|
|
1387
|
-
const s = e.path ? await
|
|
1367
|
+
const s = e.path ? await ze(e.path, { importAssets: !1 }) : void 0;
|
|
1388
1368
|
return s ? { blockletId: e.did, state: s, blockletTitle: e.title } : void 0;
|
|
1389
1369
|
})
|
|
1390
|
-
)).filter((e) => !!e),
|
|
1370
|
+
)).filter((e) => !!e), we = G.reduce(
|
|
1391
1371
|
(e, s) => Object.assign(
|
|
1392
1372
|
e,
|
|
1393
1373
|
Object.fromEntries(
|
|
@@ -1408,7 +1388,7 @@ function Xe() {
|
|
|
1408
1388
|
Ee = Object.fromEntries(
|
|
1409
1389
|
await Promise.all(
|
|
1410
1390
|
Object.entries(o).map(async ([e, s]) => {
|
|
1411
|
-
const n = await
|
|
1391
|
+
const n = await Ye(s.component);
|
|
1412
1392
|
return [
|
|
1413
1393
|
e,
|
|
1414
1394
|
{
|
|
@@ -1421,14 +1401,14 @@ function Xe() {
|
|
|
1421
1401
|
), be = G.reduce((e, s) => Object.assign(e, s.state.chunks), {});
|
|
1422
1402
|
})(), re;
|
|
1423
1403
|
}
|
|
1424
|
-
function
|
|
1425
|
-
const o =
|
|
1404
|
+
function Es(t) {
|
|
1405
|
+
const o = $e(
|
|
1426
1406
|
async () => {
|
|
1427
|
-
await
|
|
1407
|
+
await qe().catch((e) => {
|
|
1428
1408
|
v.error("load resource states error", { error: e });
|
|
1429
1409
|
}), await (t == null ? void 0 : t({
|
|
1430
1410
|
states: G,
|
|
1431
|
-
pages:
|
|
1411
|
+
pages: we,
|
|
1432
1412
|
components: Ee,
|
|
1433
1413
|
chunks: be
|
|
1434
1414
|
}));
|
|
@@ -1436,14 +1416,14 @@ function bs(t) {
|
|
|
1436
1416
|
3e3,
|
|
1437
1417
|
{ leading: !1, trailing: !0 }
|
|
1438
1418
|
);
|
|
1439
|
-
return o(),
|
|
1440
|
-
|
|
1419
|
+
return o(), S.events.on(S.Events.componentAdded, o), S.events.on(S.Events.componentRemoved, o), S.events.on(S.Events.componentStarted, o), S.events.on(S.Events.componentStopped, o), S.events.on(S.Events.componentUpdated, o), S.events.on(fe, o), () => {
|
|
1420
|
+
S.events.off(S.Events.componentAdded, o), S.events.off(S.Events.componentRemoved, o), S.events.off(S.Events.componentStarted, o), S.events.off(S.Events.componentStopped, o), S.events.off(S.Events.componentUpdated, o), S.events.off(fe, o);
|
|
1441
1421
|
};
|
|
1442
1422
|
}
|
|
1443
|
-
const
|
|
1444
|
-
var
|
|
1445
|
-
(
|
|
1446
|
-
ee[
|
|
1423
|
+
const Qe = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ee = globalThis;
|
|
1424
|
+
var _e;
|
|
1425
|
+
(_e = ee[Qe]) == null || _e.call(ee);
|
|
1426
|
+
ee[Qe] = Es(async ({ pages: t, components: o }) => {
|
|
1447
1427
|
const { projectIds: e } = oe;
|
|
1448
1428
|
await Promise.all(
|
|
1449
1429
|
e.map(async (s) => {
|
|
@@ -1466,39 +1446,39 @@ ee[Ze] = bs(async ({ pages: t, components: o }) => {
|
|
|
1466
1446
|
);
|
|
1467
1447
|
});
|
|
1468
1448
|
async function co() {
|
|
1469
|
-
v.info("trigger reload all project resource"),
|
|
1449
|
+
v.info("trigger reload all project resource"), S.events.emit(fe);
|
|
1470
1450
|
}
|
|
1471
|
-
async function
|
|
1451
|
+
async function bs({
|
|
1472
1452
|
ensureLoaded: t = !0
|
|
1473
1453
|
} = {}) {
|
|
1474
|
-
return t && (re ?? (re =
|
|
1454
|
+
return t && (re ?? (re = qe()), await re), { states: G, pages: we, components: Ee, chunks: be };
|
|
1475
1455
|
}
|
|
1476
1456
|
export {
|
|
1477
|
-
|
|
1478
|
-
|
|
1457
|
+
Je as C,
|
|
1458
|
+
je as G,
|
|
1479
1459
|
$ as P,
|
|
1480
|
-
|
|
1460
|
+
ke as R,
|
|
1481
1461
|
oe as S,
|
|
1482
|
-
|
|
1462
|
+
bs as a,
|
|
1483
1463
|
no as b,
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1464
|
+
Xt as c,
|
|
1465
|
+
Zt as d,
|
|
1466
|
+
es as e,
|
|
1467
|
+
ts as f,
|
|
1488
1468
|
oo as g,
|
|
1489
|
-
|
|
1469
|
+
ss as h,
|
|
1490
1470
|
so as i,
|
|
1491
1471
|
se as j,
|
|
1492
1472
|
ro as k,
|
|
1493
1473
|
v as l,
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1474
|
+
as as m,
|
|
1475
|
+
De as n,
|
|
1476
|
+
q as o,
|
|
1497
1477
|
ao as p,
|
|
1498
1478
|
io as q,
|
|
1499
|
-
|
|
1500
|
-
|
|
1479
|
+
ze as r,
|
|
1480
|
+
Ue as s,
|
|
1501
1481
|
Ss as t,
|
|
1502
|
-
|
|
1482
|
+
Es as u,
|
|
1503
1483
|
co as v
|
|
1504
1484
|
};
|