@blocklet/pages-kit-inner-components 0.4.124 → 0.4.125
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-BMf96RZL.js → site-state-DMexEilp.js} +5 -5
- 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-kjir-UCL.js → site-state-BHfXVFkY.js} +249 -247
- 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
|
@@ -3,29 +3,29 @@ var St = (t, s, e) => s in t ? yt(t, s, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var x = (t, s, e) => St(t, typeof s != "symbol" ? s + "" : s, e);
|
|
4
4
|
import { getComponentMountPoint as wt } from "@blocklet/pages-kit/builtin/utils";
|
|
5
5
|
import { PreloadComponentScriptModule as me } from "@blocklet/pages-kit/types";
|
|
6
|
-
import { componentUMDName as
|
|
6
|
+
import { componentUMDName as Et, RenderNestedComponent as Ge, mergeComponent as bt, getComponentDependencies as It } from "@blocklet/pages-kit/utils/property";
|
|
7
7
|
import { memoize as Ie, Sandbox as st, BuiltinModules as At } from "@blocklet/quickjs";
|
|
8
|
-
import
|
|
9
|
-
import { LRUCache as
|
|
8
|
+
import w from "@blocklet/sdk/lib/config";
|
|
9
|
+
import { LRUCache as Re } from "lru-cache";
|
|
10
10
|
import Pt, { Headers as Ot } from "node-fetch";
|
|
11
|
-
import { joinURL as
|
|
11
|
+
import { joinURL as R, getQuery as Tt, withQuery as vt, parseURL as Ve, withHttps as Ct } from "ufo";
|
|
12
12
|
import { createHash as Ae } from "crypto";
|
|
13
13
|
import xt from "@blocklet/logger";
|
|
14
|
-
import { BuiltinModules as
|
|
15
|
-
import { createBuiltinModuleTransformer as
|
|
16
|
-
import { getResources as
|
|
17
|
-
import
|
|
18
|
-
import * as
|
|
19
|
-
import { readFileSync as Z, existsSync as $, lstatSync as X, readdirSync as
|
|
14
|
+
import { BuiltinModules as Dt } from "@blocklet/pages-kit/utils/builtin";
|
|
15
|
+
import { createBuiltinModuleTransformer as jt, isRelativeModule as kt } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
|
|
16
|
+
import { getResources as Nt, getComponentWebEndpoint as Rt, call as Lt } from "@blocklet/sdk/lib/component";
|
|
17
|
+
import _t from "autoprefixer";
|
|
18
|
+
import * as Mt from "esbuild";
|
|
19
|
+
import { readFileSync as Z, existsSync as $, lstatSync as X, readdirSync as Ut, rmSync as ot, mkdtempSync as $t, renameSync as Je, mkdirSync as B, writeFileSync as he, copyFileSync as Ft, createWriteStream as Bt } from "fs";
|
|
20
20
|
import Gt from "postcss";
|
|
21
21
|
import Vt from "tailwindcss";
|
|
22
|
-
import
|
|
22
|
+
import k from "typescript";
|
|
23
23
|
import { setPageDataSource as Jt } from "@blocklet/pages-kit/utils/data-source";
|
|
24
24
|
import { reactive as Ht } from "@reactivedata/reactive";
|
|
25
25
|
import { syncedStore as Kt, getYjsValue as Q } from "@syncedstore/core";
|
|
26
|
-
import { globSync as
|
|
27
|
-
import * as
|
|
28
|
-
import * as
|
|
26
|
+
import { globSync as je } from "glob";
|
|
27
|
+
import * as ve from "lib0/decoding";
|
|
28
|
+
import * as D from "lib0/encoding";
|
|
29
29
|
import nt from "lodash/cloneDeep";
|
|
30
30
|
import rt from "lodash/debounce";
|
|
31
31
|
import Le from "lodash/get";
|
|
@@ -35,24 +35,26 @@ import He from "lodash/set";
|
|
|
35
35
|
import Wt from "lodash/union";
|
|
36
36
|
import { customAlphabet as qt } from "nanoid";
|
|
37
37
|
import Qt from "p-limit";
|
|
38
|
-
import Xt, { join as
|
|
38
|
+
import Xt, { join as b, dirname as L, basename as se } from "path";
|
|
39
39
|
import { pipeline as Zt } from "stream/promises";
|
|
40
40
|
import { x as es } from "tar";
|
|
41
41
|
import ts from "wait-on";
|
|
42
42
|
import { Awareness as ss, encodeAwarenessUpdate as Ke, removeAwarenessStates as os, applyAwarenessUpdate as ns } from "y-protocols/awareness";
|
|
43
43
|
import { writeUpdate as rs, writeSyncStep1 as as, readSyncMessage as is } from "y-protocols/sync";
|
|
44
44
|
import * as ee from "yaml";
|
|
45
|
-
import * as
|
|
45
|
+
import * as U from "yjs";
|
|
46
46
|
import cs from "lodash/isNil";
|
|
47
47
|
import { DataTypes as C, Sequelize as ls, Model as at, Op as ps } from "sequelize";
|
|
48
48
|
import "sqlite3";
|
|
49
49
|
import "@blocklet/pages-kit/types/state";
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
w.env.mode;
|
|
51
|
+
w.env.OPENAI_API_KEY || process.env.OPENAI_API_KEY;
|
|
52
|
+
w.env.OPENAI_BASE_URL || process.env.OPENAI_BASE_URL;
|
|
53
|
+
w.env.TRANSLATE_ADDITIONAL_PROMPT || process.env.TRANSLATE_ADDITIONAL_PROMPT;
|
|
54
|
+
w.env.PAGE_CONTENT_ADDITIONAL_PROMPT || process.env.PAGE_CONTENT_ADDITIONAL_PROMPT;
|
|
53
55
|
const us = "image-bin";
|
|
54
|
-
|
|
55
|
-
const ds = process.env.DATABASE_URL || Xt.join(
|
|
56
|
+
w.env.INIT_TEMPLATE_PATH;
|
|
57
|
+
const ds = process.env.DATABASE_URL || Xt.join(w.env.dataDir, "db/pages-kit.db"), ze = w, xo = () => w.env.tenantMode === "multiple", Do = () => {
|
|
56
58
|
var t;
|
|
57
59
|
return (cs(ze.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = ze.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
|
|
58
60
|
}, P = xt("pages-kit"), fs = C.sqlite.DATE.parse;
|
|
@@ -155,7 +157,7 @@ const ms = async (t, { componentId: s }) => {
|
|
|
155
157
|
`, o = `.CustomComponent_${s}`;
|
|
156
158
|
return (await Gt([
|
|
157
159
|
Vt({ content: [{ raw: t, extension: "tsx" }] }),
|
|
158
|
-
|
|
160
|
+
_t({
|
|
159
161
|
overrideBrowserslist: ["> 1%", "last 2 versions"],
|
|
160
162
|
stats: {}
|
|
161
163
|
}),
|
|
@@ -175,23 +177,23 @@ ${t}
|
|
|
175
177
|
`;
|
|
176
178
|
}, Ye = Ie(
|
|
177
179
|
async (t, s) => {
|
|
178
|
-
let e =
|
|
180
|
+
let e = k.transpileModule(t, {
|
|
179
181
|
compilerOptions: {
|
|
180
|
-
jsx:
|
|
181
|
-
target:
|
|
182
|
-
module:
|
|
182
|
+
jsx: k.JsxEmit.React,
|
|
183
|
+
target: k.ScriptTarget.ES2016,
|
|
184
|
+
module: k.ModuleKind.ESNext
|
|
183
185
|
},
|
|
184
186
|
transformers: {
|
|
185
|
-
before: [
|
|
187
|
+
before: [jt(k)]
|
|
186
188
|
}
|
|
187
189
|
}).outputText;
|
|
188
190
|
if (s.tailwind && (e = await gs(e, { componentId: s.componentId })), s.module === me.ESM) return e;
|
|
189
|
-
const o =
|
|
191
|
+
const o = k.transpileModule(e, {
|
|
190
192
|
compilerOptions: {
|
|
191
|
-
jsx:
|
|
192
|
-
target:
|
|
193
|
-
module:
|
|
194
|
-
moduleResolution:
|
|
193
|
+
jsx: k.JsxEmit.React,
|
|
194
|
+
target: k.ScriptTarget.ES2016,
|
|
195
|
+
module: k.ModuleKind.CommonJS,
|
|
196
|
+
moduleResolution: k.ModuleResolutionKind.Node16
|
|
195
197
|
}
|
|
196
198
|
}).outputText;
|
|
197
199
|
return s.module === me.CJS ? o : ys(s.moduleName, o);
|
|
@@ -216,9 +218,9 @@ ${t}
|
|
|
216
218
|
}
|
|
217
219
|
), hs = async (t, s) => {
|
|
218
220
|
var c, a;
|
|
219
|
-
const o = (a = (c = (await
|
|
221
|
+
const o = (a = (c = (await Mt.build({
|
|
220
222
|
entryPoints: ["index.tsx"],
|
|
221
|
-
external: Object.keys(
|
|
223
|
+
external: Object.keys(Dt),
|
|
222
224
|
format: "esm",
|
|
223
225
|
target: "esnext",
|
|
224
226
|
bundle: !0,
|
|
@@ -234,7 +236,7 @@ ${t}
|
|
|
234
236
|
return { contents: `export { ${s} } from './component'`, loader: "tsx" };
|
|
235
237
|
if (u.path === "component.tsx")
|
|
236
238
|
return { contents: t, loader: "tsx" };
|
|
237
|
-
if (
|
|
239
|
+
if (kt(u.path)) {
|
|
238
240
|
const S = u.path.split("/").pop();
|
|
239
241
|
if (l || (l = await Fe({ ensureLoaded: !1 })), (g = l == null ? void 0 : l.chunks) != null && g[S])
|
|
240
242
|
try {
|
|
@@ -251,8 +253,8 @@ ${t}
|
|
|
251
253
|
})).outputFiles) == null ? void 0 : c[0]) == null ? void 0 : a.contents;
|
|
252
254
|
if (!o) throw new Error("Failed to build server code");
|
|
253
255
|
const n = Buffer.from(o).toString();
|
|
254
|
-
return
|
|
255
|
-
compilerOptions: { module:
|
|
256
|
+
return k.transpileModule(n, {
|
|
257
|
+
compilerOptions: { module: k.ModuleKind.ESNext, target: k.ScriptTarget.ES2020 }
|
|
256
258
|
}).outputText;
|
|
257
259
|
}, it = Ie(
|
|
258
260
|
async (t, s) => {
|
|
@@ -298,17 +300,17 @@ var ${t} = ${e ? "async" : ""} function () {
|
|
|
298
300
|
return exports;
|
|
299
301
|
};
|
|
300
302
|
`;
|
|
301
|
-
}, re = new
|
|
303
|
+
}, re = new Re({
|
|
302
304
|
max: 100
|
|
303
305
|
}), Ss = 60 * 60, We = 60;
|
|
304
306
|
function ws(t) {
|
|
305
307
|
P.info("clear preload components cache", { cacheKey: t }), re.delete(t);
|
|
306
308
|
}
|
|
307
|
-
function
|
|
309
|
+
function Es(t) {
|
|
308
310
|
for (const s of re.keys())
|
|
309
311
|
s.includes(t) && (P.info("clear preload components cache", { cacheKey: s }), ws(s));
|
|
310
312
|
}
|
|
311
|
-
function
|
|
313
|
+
function bs({
|
|
312
314
|
mode: t,
|
|
313
315
|
instanceId: s,
|
|
314
316
|
componentId: e,
|
|
@@ -316,7 +318,7 @@ function Es({
|
|
|
316
318
|
}) {
|
|
317
319
|
return ["getPreloadComponents", t, s, e, o].join("-");
|
|
318
320
|
}
|
|
319
|
-
async function
|
|
321
|
+
async function jo({
|
|
320
322
|
mode: t,
|
|
321
323
|
req: s,
|
|
322
324
|
state: e,
|
|
@@ -332,7 +334,7 @@ async function ko({
|
|
|
332
334
|
const p = (await Promise.all(
|
|
333
335
|
n.map(async (d) => {
|
|
334
336
|
try {
|
|
335
|
-
const i =
|
|
337
|
+
const i = bs({
|
|
336
338
|
mode: t,
|
|
337
339
|
instanceId: d.id,
|
|
338
340
|
componentId: d.componentId,
|
|
@@ -353,9 +355,9 @@ async function ko({
|
|
|
353
355
|
if (!I) return null;
|
|
354
356
|
const G = { instanceId: d.id, preload: I };
|
|
355
357
|
if (t !== "draft" && d.useCache) {
|
|
356
|
-
let
|
|
357
|
-
d.cacheDuration && (
|
|
358
|
-
ttl:
|
|
358
|
+
let j = Ss;
|
|
359
|
+
d.cacheDuration && (j = d.cacheDuration), P.info(`set preload component to cache(${j}s): ${i}`), re.set(i, G, {
|
|
360
|
+
ttl: j * 1e3
|
|
359
361
|
});
|
|
360
362
|
}
|
|
361
363
|
return G;
|
|
@@ -369,7 +371,7 @@ async function ko({
|
|
|
369
371
|
async function u() {
|
|
370
372
|
const d = await Promise.all(
|
|
371
373
|
l.map(async (i) => {
|
|
372
|
-
const h =
|
|
374
|
+
const h = Et({ componentId: i.component.id }), I = r === me.ESM ? {
|
|
373
375
|
module: r,
|
|
374
376
|
script: await Ye(i.script, {
|
|
375
377
|
componentId: i.component.id,
|
|
@@ -475,7 +477,7 @@ function Ps({
|
|
|
475
477
|
}) {
|
|
476
478
|
const n = ye({ state: t, componentId: s });
|
|
477
479
|
if (!n) return null;
|
|
478
|
-
const r =
|
|
480
|
+
const r = bt({
|
|
479
481
|
componentId: s,
|
|
480
482
|
getComponent: (c) => ye({ state: t, componentId: c }),
|
|
481
483
|
locale: e,
|
|
@@ -488,7 +490,7 @@ function ye({ state: t, componentId: s }) {
|
|
|
488
490
|
var e, o, n;
|
|
489
491
|
return ((e = t.components[s]) == null ? void 0 : e.data) ?? ((n = (o = t.resources.components) == null ? void 0 : o[s]) == null ? void 0 : n.component);
|
|
490
492
|
}
|
|
491
|
-
function
|
|
493
|
+
function ko({ state: t, name: s }) {
|
|
492
494
|
var o, n;
|
|
493
495
|
const e = s.toLowerCase();
|
|
494
496
|
return ((o = Object.values(t.components).find((r) => {
|
|
@@ -559,19 +561,19 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
|
559
561
|
}
|
|
560
562
|
},
|
|
561
563
|
getComponentMountPoint: wt,
|
|
562
|
-
joinURL:
|
|
563
|
-
withQuery:
|
|
564
|
-
getQuery:
|
|
564
|
+
joinURL: R,
|
|
565
|
+
withQuery: vt,
|
|
566
|
+
getQuery: Tt
|
|
565
567
|
},
|
|
566
568
|
functionName: "getServerSidePropsWrapper",
|
|
567
569
|
args: [
|
|
568
570
|
{
|
|
569
571
|
// NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
|
|
570
572
|
// because the global is shared between all runtime and just init once
|
|
571
|
-
location: { href:
|
|
573
|
+
location: { href: R(Ct(o.hostname), o.originalUrl) },
|
|
572
574
|
fetch: (a, { ...p } = {}) => {
|
|
573
|
-
const l = typeof a == "string" && a.startsWith("/") ?
|
|
574
|
-
if (typeof l == "string" && Ve(l).host === Ve(
|
|
575
|
+
const l = typeof a == "string" && a.startsWith("/") ? R(w.env.appUrl, a) : a;
|
|
576
|
+
if (typeof l == "string" && Ve(l).host === Ve(w.env.appUrl).host) {
|
|
575
577
|
const u = o.get("cookie");
|
|
576
578
|
if (u) {
|
|
577
579
|
const g = new Ot(p.headers);
|
|
@@ -595,7 +597,7 @@ export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
|
595
597
|
})
|
|
596
598
|
]);
|
|
597
599
|
}
|
|
598
|
-
const
|
|
600
|
+
const Ts = Ie(
|
|
599
601
|
async (t, s, e) => {
|
|
600
602
|
if (!(t != null && t.includes(s)))
|
|
601
603
|
return null;
|
|
@@ -628,13 +630,13 @@ const vs = Ie(
|
|
|
628
630
|
ttl: 1e3 * 60 * 60
|
|
629
631
|
}
|
|
630
632
|
}
|
|
631
|
-
),
|
|
633
|
+
), vs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", qe = "page", ke = "trigger-reload-project-resource", lt = vs, Cs = "z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM", { uploadToMediaKit: xs } = require("@blocklet/uploader-server"), Ce = qt("abcdefghijklmnopqrstuvwxyz0123456789", 16), _e = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, ae = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Qe = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, Ds = 1e4, js = 3e4, ue = 0, xe = 1, ks = 0, Ns = 1, Ne = w, de = b(process.env.BLOCKLET_DATA_DIR, "site-state"), No = ["production", "draft"], Ro = ["production"];
|
|
632
634
|
function Se(t) {
|
|
633
635
|
return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
|
|
634
636
|
}
|
|
635
|
-
function
|
|
637
|
+
function Rs() {
|
|
636
638
|
var e;
|
|
637
|
-
const t =
|
|
639
|
+
const t = Ne.env.languages.map((o) => ({ locale: o.code, name: o.name })), s = (e = t[0]) == null ? void 0 : e.locale;
|
|
638
640
|
return {
|
|
639
641
|
pageIds: [],
|
|
640
642
|
pages: {},
|
|
@@ -646,7 +648,7 @@ function Ns() {
|
|
|
646
648
|
resources: {}
|
|
647
649
|
};
|
|
648
650
|
}
|
|
649
|
-
const H = class H extends
|
|
651
|
+
const H = class H extends U.Doc {
|
|
650
652
|
constructor(e) {
|
|
651
653
|
super();
|
|
652
654
|
x(this, "states", {});
|
|
@@ -663,15 +665,15 @@ const H = class H extends M.Doc {
|
|
|
663
665
|
l.delete(u);
|
|
664
666
|
}));
|
|
665
667
|
}
|
|
666
|
-
const a =
|
|
667
|
-
|
|
668
|
-
const p =
|
|
668
|
+
const a = D.createEncoder();
|
|
669
|
+
D.writeVarUint(a, xe), D.writeVarUint8Array(a, Ke(this.awareness, c));
|
|
670
|
+
const p = D.toUint8Array(a);
|
|
669
671
|
this.conns.forEach((l, u) => this.send(u, p));
|
|
670
672
|
});
|
|
671
673
|
x(this, "updateHandler", (e) => {
|
|
672
|
-
const o =
|
|
673
|
-
|
|
674
|
-
const n =
|
|
674
|
+
const o = D.createEncoder();
|
|
675
|
+
D.writeVarUint(o, ue), rs(o, e);
|
|
676
|
+
const n = D.toUint8Array(o);
|
|
675
677
|
this.conns.forEach((r, c) => this.send(c, n));
|
|
676
678
|
});
|
|
677
679
|
x(this, "ensureDataStructure", () => {
|
|
@@ -685,7 +687,7 @@ const H = class H extends M.Doc {
|
|
|
685
687
|
a.has(l) ? (a.delete(l), p++) : n.splice(p, 1);
|
|
686
688
|
}
|
|
687
689
|
}
|
|
688
|
-
e.splice(0, e.length), e.push(...
|
|
690
|
+
e.splice(0, e.length), e.push(...Ne.env.languages.map((a) => ({ locale: a.code, name: a.name }))), r.defaultLocale = (c = e[0]) == null ? void 0 : c.locale;
|
|
689
691
|
{
|
|
690
692
|
let a = 0;
|
|
691
693
|
const p = /* @__PURE__ */ new Set();
|
|
@@ -696,7 +698,7 @@ const H = class H extends M.Doc {
|
|
|
696
698
|
}
|
|
697
699
|
});
|
|
698
700
|
x(this, "send", (e, o) => {
|
|
699
|
-
e.readyState !==
|
|
701
|
+
e.readyState !== ks && e.readyState !== Ns && this.closeConn(e);
|
|
700
702
|
try {
|
|
701
703
|
e.send(o, (n) => {
|
|
702
704
|
n && this.closeConn(e);
|
|
@@ -713,8 +715,8 @@ const H = class H extends M.Doc {
|
|
|
713
715
|
e.close();
|
|
714
716
|
});
|
|
715
717
|
x(this, "autoSave", rt(() => {
|
|
716
|
-
B(L(this.draftYjsFilePath), { recursive: !0 }), he(this.draftYjsFilePath,
|
|
717
|
-
},
|
|
718
|
+
B(L(this.draftYjsFilePath), { recursive: !0 }), he(this.draftYjsFilePath, U.encodeStateAsUpdate(this));
|
|
719
|
+
}, Ds));
|
|
718
720
|
x(this, "save", ({ flush: e = !1 } = {}) => {
|
|
719
721
|
this.autoSave(), e && this.autoSave.flush();
|
|
720
722
|
});
|
|
@@ -758,31 +760,31 @@ const H = class H extends M.Doc {
|
|
|
758
760
|
this.closeConn(e), clearInterval(n);
|
|
759
761
|
}
|
|
760
762
|
}
|
|
761
|
-
},
|
|
763
|
+
}, js);
|
|
762
764
|
e.on("close", () => {
|
|
763
765
|
this.closeConn(e), clearInterval(n);
|
|
764
766
|
}), e.on("pong", () => {
|
|
765
767
|
o = !0;
|
|
766
768
|
});
|
|
767
769
|
{
|
|
768
|
-
const r =
|
|
769
|
-
|
|
770
|
+
const r = D.createEncoder();
|
|
771
|
+
D.writeVarUint(r, ue), as(r, this), this.send(e, D.toUint8Array(r));
|
|
770
772
|
const c = this.awareness.getStates();
|
|
771
773
|
if (c.size > 0) {
|
|
772
|
-
const a =
|
|
773
|
-
|
|
774
|
+
const a = D.createEncoder();
|
|
775
|
+
D.writeVarUint(a, xe), D.writeVarUint8Array(a, Ke(this.awareness, Array.from(c.keys()))), this.send(e, D.toUint8Array(a));
|
|
774
776
|
}
|
|
775
777
|
}
|
|
776
778
|
});
|
|
777
779
|
x(this, "messageListener", (e, o) => {
|
|
778
780
|
try {
|
|
779
|
-
const n =
|
|
781
|
+
const n = D.createEncoder(), r = ve.createDecoder(o), c = ve.readVarUint(r);
|
|
780
782
|
switch (c) {
|
|
781
783
|
case ue:
|
|
782
|
-
|
|
784
|
+
D.writeVarUint(n, ue), is(r, n, this, null), D.length(n) > 1 && (this.ensureDataStructure(), this.send(e, D.toUint8Array(n)));
|
|
783
785
|
break;
|
|
784
786
|
case xe: {
|
|
785
|
-
ns(this.awareness,
|
|
787
|
+
ns(this.awareness, ve.readVarUint8Array(r), e);
|
|
786
788
|
break;
|
|
787
789
|
}
|
|
788
790
|
default:
|
|
@@ -793,7 +795,7 @@ const H = class H extends M.Doc {
|
|
|
793
795
|
}
|
|
794
796
|
this.save();
|
|
795
797
|
});
|
|
796
|
-
this.options = e, $(this.draftYjsFilePath) &&
|
|
798
|
+
this.options = e, $(this.draftYjsFilePath) && U.applyUpdate(this, Z(this.draftYjsFilePath)), this.syncedStore = Ht(
|
|
797
799
|
Kt(
|
|
798
800
|
{
|
|
799
801
|
pages: {},
|
|
@@ -814,14 +816,14 @@ const H = class H extends M.Doc {
|
|
|
814
816
|
if (!e)
|
|
815
817
|
throw new Error("Should provide project context");
|
|
816
818
|
try {
|
|
817
|
-
const o =
|
|
819
|
+
const o = b(de, e), n = b(de, `@del-${e}`);
|
|
818
820
|
Je(o, n);
|
|
819
821
|
} catch (o) {
|
|
820
822
|
P.error("Failed to safe delete project state dir:", o);
|
|
821
823
|
}
|
|
822
824
|
}
|
|
823
825
|
static get projectIds() {
|
|
824
|
-
return
|
|
826
|
+
return je("*/", {
|
|
825
827
|
cwd: de,
|
|
826
828
|
ignore: ["@del-*", "@tmp-*", ".*", "staging", "production", "@backup-*"]
|
|
827
829
|
// Ignore temp directories and hidden files
|
|
@@ -835,7 +837,7 @@ const H = class H extends M.Doc {
|
|
|
835
837
|
throw new Error("Should provide project context");
|
|
836
838
|
let o = this.sharedInstances.get(e);
|
|
837
839
|
return o || (o = new H({
|
|
838
|
-
path:
|
|
840
|
+
path: b(de, e)
|
|
839
841
|
}), this.sharedInstances.set(e, o), o);
|
|
840
842
|
}
|
|
841
843
|
destroy() {
|
|
@@ -849,42 +851,42 @@ const H = class H extends M.Doc {
|
|
|
849
851
|
};
|
|
850
852
|
this.syncedStore.pages && Object.keys(this.syncedStore.pages).forEach((r) => {
|
|
851
853
|
const c = Q(this.syncedStore.pages[r]);
|
|
852
|
-
c && c instanceof
|
|
854
|
+
c && c instanceof U.Map && e(c);
|
|
853
855
|
});
|
|
854
856
|
const o = Q(this.syncedStore.pages);
|
|
855
|
-
o && o instanceof
|
|
857
|
+
o && o instanceof U.Map && o.observe((r) => {
|
|
856
858
|
r.changes.keys.forEach((c, a) => {
|
|
857
859
|
if (c.action === "add") {
|
|
858
860
|
const p = Q(this.syncedStore.pages[a]);
|
|
859
|
-
p && p instanceof
|
|
861
|
+
p && p instanceof U.Map && e(p);
|
|
860
862
|
}
|
|
861
863
|
});
|
|
862
864
|
}), this.syncedStore.routes && Object.keys(this.syncedStore.routes).forEach((r) => {
|
|
863
865
|
var a;
|
|
864
866
|
const c = Q((a = this.syncedStore.routes) == null ? void 0 : a[r]);
|
|
865
|
-
c && c instanceof
|
|
867
|
+
c && c instanceof U.Map && e(c);
|
|
866
868
|
});
|
|
867
869
|
const n = Q(this.syncedStore.routes);
|
|
868
|
-
n && n instanceof
|
|
870
|
+
n && n instanceof U.Map && n.observe((r) => {
|
|
869
871
|
r.changes.keys.forEach((c, a) => {
|
|
870
872
|
var p;
|
|
871
873
|
if (c.action === "add") {
|
|
872
874
|
const l = Q((p = this.syncedStore.routes) == null ? void 0 : p[a]);
|
|
873
|
-
l && l instanceof
|
|
875
|
+
l && l instanceof U.Map && e(l);
|
|
874
876
|
}
|
|
875
877
|
});
|
|
876
878
|
});
|
|
877
879
|
}
|
|
878
880
|
get draftYjsFilePath() {
|
|
879
|
-
return
|
|
881
|
+
return b(this.options.path, "draft.yjs");
|
|
880
882
|
}
|
|
881
883
|
async getState(e) {
|
|
882
884
|
var o, n, r, c;
|
|
883
885
|
if (e === "draft")
|
|
884
886
|
return JSON.parse(JSON.stringify(this.syncedStore));
|
|
885
|
-
if (!this.states[e] && (this.states[e] = await dt(this.getPublishDir(e), { includeResources: !0 }) ??
|
|
887
|
+
if (!this.states[e] && (this.states[e] = await dt(this.getPublishDir(e), { includeResources: !0 }) ?? Rs(), !((n = (o = this.states[e]) == null ? void 0 : o.config) != null && n.defaultLocale))) {
|
|
886
888
|
(r = this.states[e]).config ?? (r.config = {});
|
|
887
|
-
const a =
|
|
889
|
+
const a = Ne.env.languages.map((p) => ({ locale: p.code, name: p.name }));
|
|
888
890
|
this.states[e].config.defaultLocale = (c = a[0]) == null ? void 0 : c.locale;
|
|
889
891
|
}
|
|
890
892
|
return {
|
|
@@ -897,9 +899,9 @@ const H = class H extends M.Doc {
|
|
|
897
899
|
if (S != null && S.useAllResources)
|
|
898
900
|
u = l;
|
|
899
901
|
else {
|
|
900
|
-
const
|
|
902
|
+
const j = (await Pe.findAll({ where: { projectId: g } })).map((V) => V.componentId);
|
|
901
903
|
u = Object.fromEntries(
|
|
902
|
-
Object.entries(l || {}).filter(([V]) =>
|
|
904
|
+
Object.entries(l || {}).filter(([V]) => j.includes(V))
|
|
903
905
|
);
|
|
904
906
|
}
|
|
905
907
|
return Object.keys(((i = (d = this.states[e]) == null ? void 0 : d.resources) == null ? void 0 : i.components) || {}).length > 0 && (u = {
|
|
@@ -910,11 +912,11 @@ const H = class H extends M.Doc {
|
|
|
910
912
|
};
|
|
911
913
|
}
|
|
912
914
|
async setState(e, o) {
|
|
913
|
-
const n = await
|
|
915
|
+
const n = await Us(o, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
|
|
914
916
|
B(L(r), { recursive: !0 }), ot(r, { force: !0, recursive: !0 }), Je(n, r), this.states[e] = o;
|
|
915
917
|
}
|
|
916
918
|
getPublishDir(e) {
|
|
917
|
-
return
|
|
919
|
+
return b(this.options.path, e);
|
|
918
920
|
}
|
|
919
921
|
static async pageUrlMap(e) {
|
|
920
922
|
var r;
|
|
@@ -923,7 +925,7 @@ const H = class H extends M.Doc {
|
|
|
923
925
|
const a = await W.findByPk(c);
|
|
924
926
|
if (!a) continue;
|
|
925
927
|
const p = await H.shared(c).getState(e), l = Wt(
|
|
926
|
-
|
|
928
|
+
w.env.languages.map((u) => u.code),
|
|
927
929
|
p.supportedLocales.map((u) => u.locale)
|
|
928
930
|
);
|
|
929
931
|
if (e === "draft")
|
|
@@ -942,18 +944,18 @@ const H = class H extends M.Doc {
|
|
|
942
944
|
publishedAt: p.config.publishedAt,
|
|
943
945
|
isPublic: g.isPublic
|
|
944
946
|
};
|
|
945
|
-
d && (n[
|
|
947
|
+
d && (n[R("/", d, S)] = {
|
|
946
948
|
...i,
|
|
947
949
|
shouldRedirect: !0,
|
|
948
950
|
mainPage: !0
|
|
949
|
-
}), n[
|
|
951
|
+
}), n[R("/", c, S)] = {
|
|
950
952
|
...i,
|
|
951
953
|
shouldRedirect: !0,
|
|
952
954
|
mainPage: !0
|
|
953
955
|
};
|
|
954
956
|
for (const h of l) {
|
|
955
957
|
const I = { ...i, locale: h };
|
|
956
|
-
n[
|
|
958
|
+
n[R("/", h, c, S)] = I, d && (n[R("/", h, d, S)] = I);
|
|
957
959
|
}
|
|
958
960
|
}
|
|
959
961
|
for (const u of p.pageIds) {
|
|
@@ -972,25 +974,25 @@ const H = class H extends M.Doc {
|
|
|
972
974
|
isPublic: g.isPublic,
|
|
973
975
|
templateConfig: g.templateConfig
|
|
974
976
|
};
|
|
975
|
-
d && (n[
|
|
977
|
+
d && (n[R("/", d, S)] = {
|
|
976
978
|
...i,
|
|
977
979
|
shouldRedirect: !0,
|
|
978
980
|
mainPage: !0
|
|
979
|
-
}), n[
|
|
981
|
+
}), n[R("/", c, S)] = {
|
|
980
982
|
...i,
|
|
981
983
|
shouldRedirect: !0,
|
|
982
984
|
mainPage: !0
|
|
983
985
|
};
|
|
984
986
|
for (const h of l) {
|
|
985
987
|
const I = { ...i, locale: h };
|
|
986
|
-
n[
|
|
988
|
+
n[R("/", h, c, S)] = I, d && (n[R("/", h, d, S)] = I);
|
|
987
989
|
}
|
|
988
990
|
}
|
|
989
991
|
}
|
|
990
992
|
return n;
|
|
991
993
|
}
|
|
992
994
|
getDocumentSize() {
|
|
993
|
-
return
|
|
995
|
+
return U.encodeStateAsUpdate(this).byteLength;
|
|
994
996
|
}
|
|
995
997
|
static getInstancesSizeInfo() {
|
|
996
998
|
const e = [];
|
|
@@ -1007,7 +1009,7 @@ const H = class H extends M.Doc {
|
|
|
1007
1009
|
}
|
|
1008
1010
|
};
|
|
1009
1011
|
x(H, "INSTANCE_TTL", 30 * 60 * 1e3), // 30 minutes
|
|
1010
|
-
x(H, "sharedInstances", new
|
|
1012
|
+
x(H, "sharedInstances", new Re({
|
|
1011
1013
|
max: 100,
|
|
1012
1014
|
// Maximum number of instances to store
|
|
1013
1015
|
ttl: H.INSTANCE_TTL,
|
|
@@ -1017,12 +1019,12 @@ x(H, "sharedInstances", new Ne({
|
|
|
1017
1019
|
}));
|
|
1018
1020
|
let we = H;
|
|
1019
1021
|
function pt() {
|
|
1020
|
-
return $t(
|
|
1022
|
+
return $t(b(w.env.dataDir, "tmp-"));
|
|
1021
1023
|
}
|
|
1022
|
-
function
|
|
1023
|
-
return Array.isArray(t) ? t.flatMap((o, n) =>
|
|
1024
|
+
function Ee(t, s, e = []) {
|
|
1025
|
+
return Array.isArray(t) ? t.flatMap((o, n) => Ee(o, s, [...e, n])) : typeof t == "object" ? t === null ? [] : Object.entries(t).flatMap(([o, n]) => Ee(n, s, [...e, o])) : s(t) ? [e] : [];
|
|
1024
1026
|
}
|
|
1025
|
-
function
|
|
1027
|
+
function N(t) {
|
|
1026
1028
|
return t.filter((s) => s != null);
|
|
1027
1029
|
}
|
|
1028
1030
|
async function Ls(t, s, e) {
|
|
@@ -1042,10 +1044,10 @@ async function Ls(t, s, e) {
|
|
|
1042
1044
|
}
|
|
1043
1045
|
})(), e[t] = o), o;
|
|
1044
1046
|
}
|
|
1045
|
-
const
|
|
1047
|
+
const _s = async (t, s) => {
|
|
1046
1048
|
const e = se(t), o = await Lt({
|
|
1047
1049
|
name: lt,
|
|
1048
|
-
path:
|
|
1050
|
+
path: R("/uploads", e),
|
|
1049
1051
|
responseType: "stream",
|
|
1050
1052
|
method: "GET"
|
|
1051
1053
|
});
|
|
@@ -1054,11 +1056,11 @@ const Us = async (t, s) => {
|
|
|
1054
1056
|
await Zt(o.data, n);
|
|
1055
1057
|
} else
|
|
1056
1058
|
throw new Error(`download asset failed ${o.status}`);
|
|
1057
|
-
},
|
|
1059
|
+
}, Ms = async (t, s) => {
|
|
1058
1060
|
await Promise.all(
|
|
1059
1061
|
t.map(async (e) => {
|
|
1060
1062
|
try {
|
|
1061
|
-
await
|
|
1063
|
+
await _s(e, b(s, se(e)));
|
|
1062
1064
|
} catch (o) {
|
|
1063
1065
|
P.error(`Failed to export assets: ${e}, ${o}`);
|
|
1064
1066
|
}
|
|
@@ -1066,30 +1068,30 @@ const Us = async (t, s) => {
|
|
|
1066
1068
|
);
|
|
1067
1069
|
};
|
|
1068
1070
|
function ut(t) {
|
|
1069
|
-
return
|
|
1071
|
+
return _e.test(t) ? [t] : ae.test(t) ? (Qe.lastIndex = 0, Array.from(t.matchAll(Qe)).map((e) => e[1]).filter((e) => !!e)) : [];
|
|
1070
1072
|
}
|
|
1071
1073
|
async function fe(t, s, e) {
|
|
1072
|
-
const { getFilename: o, exportAssets: n } = e, r =
|
|
1074
|
+
const { getFilename: o, exportAssets: n } = e, r = b(s, o(t));
|
|
1073
1075
|
if (B(L(r), { recursive: !0 }), he(r, ee.stringify(t)), n) {
|
|
1074
|
-
const a =
|
|
1076
|
+
const a = Ee(
|
|
1075
1077
|
t,
|
|
1076
|
-
(p) => typeof p == "string" && (
|
|
1078
|
+
(p) => typeof p == "string" && (_e.test(p) || ae.test(p))
|
|
1077
1079
|
).map((p) => {
|
|
1078
1080
|
const l = Le(t, p);
|
|
1079
1081
|
return ut(l);
|
|
1080
1082
|
}).flat().filter(Boolean);
|
|
1081
|
-
await
|
|
1083
|
+
await Ms(a, L(r));
|
|
1082
1084
|
}
|
|
1083
1085
|
}
|
|
1084
|
-
const Xe = new
|
|
1086
|
+
const Xe = new Re({
|
|
1085
1087
|
max: 1e3,
|
|
1086
1088
|
ttl: 30 * 24 * 60 * 60 * 1e3
|
|
1087
1089
|
});
|
|
1088
1090
|
async function Ze(t, s, e) {
|
|
1089
1091
|
var a;
|
|
1090
|
-
const o =
|
|
1092
|
+
const o = Ee(
|
|
1091
1093
|
t,
|
|
1092
|
-
(p) => typeof p == "string" && (
|
|
1094
|
+
(p) => typeof p == "string" && (_e.test(p) || ae.test(p))
|
|
1093
1095
|
), n = Qt(2), r = o.map(
|
|
1094
1096
|
(p) => n(async () => {
|
|
1095
1097
|
try {
|
|
@@ -1110,7 +1112,7 @@ async function Ze(t, s, e) {
|
|
|
1110
1112
|
), c = await Promise.allSettled(r);
|
|
1111
1113
|
(a = e.onFinish) == null || a.call(e, c);
|
|
1112
1114
|
}
|
|
1113
|
-
async function
|
|
1115
|
+
async function Us(t, {
|
|
1114
1116
|
exportAssets: s,
|
|
1115
1117
|
pageIds: e = "all",
|
|
1116
1118
|
componentIds: o = "all",
|
|
@@ -1118,13 +1120,13 @@ async function Ms(t, {
|
|
|
1118
1120
|
includeResources: r = !1,
|
|
1119
1121
|
routeIds: c = "all"
|
|
1120
1122
|
} = {}) {
|
|
1121
|
-
var oe, y, f,
|
|
1123
|
+
var oe, y, f, E, O, K, T, _, z, le, ne, pe;
|
|
1122
1124
|
const a = e === "all" ? t.pageIds : e, p = It({
|
|
1123
1125
|
state: t,
|
|
1124
1126
|
pageIds: a,
|
|
1125
1127
|
componentIds: o === "all" ? Object.keys(t.components) : o
|
|
1126
1128
|
}), l = c === "all" ? t.routeIds : c, u = (m, A) => {
|
|
1127
|
-
var
|
|
1129
|
+
var v;
|
|
1128
1130
|
return {
|
|
1129
1131
|
id: m.id,
|
|
1130
1132
|
name: m.name,
|
|
@@ -1134,10 +1136,10 @@ async function Ms(t, {
|
|
|
1134
1136
|
component: m.component,
|
|
1135
1137
|
config: m.config,
|
|
1136
1138
|
visibility: m.visibility,
|
|
1137
|
-
properties: ((
|
|
1139
|
+
properties: ((v = m.locales) == null ? void 0 : v[A]) ?? {}
|
|
1138
1140
|
};
|
|
1139
1141
|
}, g = (m, A) => {
|
|
1140
|
-
var
|
|
1142
|
+
var v;
|
|
1141
1143
|
return {
|
|
1142
1144
|
id: m.id,
|
|
1143
1145
|
createdAt: m.createdAt,
|
|
@@ -1145,8 +1147,8 @@ async function Ms(t, {
|
|
|
1145
1147
|
publishedAt: m.publishedAt,
|
|
1146
1148
|
isPublic: m.isPublic ?? !0,
|
|
1147
1149
|
templateConfig: m.templateConfig,
|
|
1148
|
-
meta: ((
|
|
1149
|
-
sections:
|
|
1150
|
+
meta: ((v = m.locales) == null ? void 0 : v[A]) ?? {},
|
|
1151
|
+
sections: N(
|
|
1150
1152
|
m.sectionIds.map((J) => {
|
|
1151
1153
|
const F = m.sections[J];
|
|
1152
1154
|
return F && u(F, A);
|
|
@@ -1165,35 +1167,35 @@ async function Ms(t, {
|
|
|
1165
1167
|
enabledGenerate: m.enabledGenerate ?? !1,
|
|
1166
1168
|
displayTemplateId: m.displayTemplateId,
|
|
1167
1169
|
dataSource: m.dataSource
|
|
1168
|
-
}), d =
|
|
1170
|
+
}), d = N(
|
|
1169
1171
|
l.map((m) => {
|
|
1170
1172
|
const A = t.routes[m];
|
|
1171
1173
|
return A && S(A);
|
|
1172
1174
|
})
|
|
1173
|
-
), i =
|
|
1175
|
+
), i = N(
|
|
1174
1176
|
t.supportedLocales.map((m) => m.locale).flatMap(
|
|
1175
1177
|
(m) => a.map((A) => {
|
|
1176
|
-
const
|
|
1177
|
-
return
|
|
1178
|
+
const v = t.pages[A];
|
|
1179
|
+
return v && {
|
|
1178
1180
|
locale: m,
|
|
1179
|
-
slug:
|
|
1180
|
-
page: g(
|
|
1181
|
+
slug: v.slug,
|
|
1182
|
+
page: g(v, m)
|
|
1181
1183
|
};
|
|
1182
1184
|
})
|
|
1183
1185
|
)
|
|
1184
|
-
), h = pt(), I =
|
|
1186
|
+
), h = pt(), I = b(h, "pages");
|
|
1185
1187
|
B(I, { recursive: !0 });
|
|
1186
|
-
const G =
|
|
1188
|
+
const G = b(h, "components");
|
|
1187
1189
|
B(G, { recursive: !0 });
|
|
1188
|
-
const
|
|
1189
|
-
B(
|
|
1190
|
-
for (const { locale: m, slug: A, page:
|
|
1191
|
-
await fe(
|
|
1190
|
+
const j = b(h, "routes");
|
|
1191
|
+
B(j, { recursive: !0 });
|
|
1192
|
+
for (const { locale: m, slug: A, page: v } of i)
|
|
1193
|
+
await fe(v, I, {
|
|
1192
1194
|
getFilename: () => `${Se(A) || "index"}.${m}.yml`,
|
|
1193
1195
|
exportAssets: s
|
|
1194
1196
|
});
|
|
1195
1197
|
for (const m of d)
|
|
1196
|
-
await fe(m,
|
|
1198
|
+
await fe(m, j, {
|
|
1197
1199
|
// getFilename: () => `${sanitizeSlug(route.path)}.yml`,
|
|
1198
1200
|
getFilename: () => `${Se(m.path) || "index"}.yml`,
|
|
1199
1201
|
exportAssets: s
|
|
@@ -1201,29 +1203,29 @@ async function Ms(t, {
|
|
|
1201
1203
|
for (const m of p) {
|
|
1202
1204
|
const A = (oe = t.components[m]) == null ? void 0 : oe.data;
|
|
1203
1205
|
A && await fe(A, G, {
|
|
1204
|
-
getFilename: (
|
|
1206
|
+
getFilename: (v) => `${v.name || "unnamed"}.${v.id}.yml`,
|
|
1205
1207
|
exportAssets: s
|
|
1206
1208
|
});
|
|
1207
1209
|
}
|
|
1208
|
-
const q =
|
|
1210
|
+
const q = b(h, ".blocklet/pages/pages.config.yml");
|
|
1209
1211
|
B(L(q), { recursive: !0 });
|
|
1210
1212
|
const V = {
|
|
1211
|
-
pages:
|
|
1213
|
+
pages: N(
|
|
1212
1214
|
a.map((m) => {
|
|
1213
1215
|
const A = t.pages[m];
|
|
1214
1216
|
return A && { id: m, slug: A.slug };
|
|
1215
1217
|
})
|
|
1216
1218
|
),
|
|
1217
|
-
routes:
|
|
1219
|
+
routes: N(
|
|
1218
1220
|
l.map((m) => {
|
|
1219
1221
|
const A = t.routes[m];
|
|
1220
1222
|
return A && { id: m, path: A.path };
|
|
1221
1223
|
})
|
|
1222
1224
|
),
|
|
1223
|
-
components:
|
|
1225
|
+
components: N(
|
|
1224
1226
|
p.map((m) => {
|
|
1225
|
-
var
|
|
1226
|
-
const A = (
|
|
1227
|
+
var v;
|
|
1228
|
+
const A = (v = t.components[m]) == null ? void 0 : v.data;
|
|
1227
1229
|
return A && {
|
|
1228
1230
|
id: m,
|
|
1229
1231
|
name: A.name
|
|
@@ -1232,12 +1234,12 @@ async function Ms(t, {
|
|
|
1232
1234
|
),
|
|
1233
1235
|
...r ? {
|
|
1234
1236
|
resources: {
|
|
1235
|
-
components:
|
|
1237
|
+
components: N(
|
|
1236
1238
|
Object.keys(((y = t.resources) == null ? void 0 : y.components) || {}).filter((m) => p.includes(m)).map((m) => {
|
|
1237
|
-
var A,
|
|
1239
|
+
var A, v, J, F;
|
|
1238
1240
|
return {
|
|
1239
1241
|
id: m,
|
|
1240
|
-
name: (F = (J = (
|
|
1242
|
+
name: (F = (J = (v = (A = t.resources) == null ? void 0 : A.components) == null ? void 0 : v[m]) == null ? void 0 : J.component) == null ? void 0 : F.name
|
|
1241
1243
|
};
|
|
1242
1244
|
})
|
|
1243
1245
|
)
|
|
@@ -1247,33 +1249,33 @@ async function Ms(t, {
|
|
|
1247
1249
|
config: t.config
|
|
1248
1250
|
};
|
|
1249
1251
|
he(q, ee.stringify(V));
|
|
1250
|
-
const ce =
|
|
1252
|
+
const ce = b(h, "config.source.json");
|
|
1251
1253
|
if (n && he(ce, JSON.stringify(n)), r) {
|
|
1252
|
-
const m =
|
|
1254
|
+
const m = b(h, "resources"), A = b(m, "components");
|
|
1253
1255
|
B(A, { recursive: !0 });
|
|
1254
1256
|
for (const F of Object.keys(((f = t == null ? void 0 : t.resources) == null ? void 0 : f.components) ?? {}).filter(
|
|
1255
|
-
(
|
|
1257
|
+
(M) => p.includes(M)
|
|
1256
1258
|
)) {
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
+
const M = (K = (O = (E = t.resources) == null ? void 0 : E.components) == null ? void 0 : O[F]) == null ? void 0 : K.component;
|
|
1260
|
+
M && await fe(M, A, {
|
|
1259
1261
|
getFilename: (Y) => `${Y.name || "unnamed"}.${Y.id}.yml`,
|
|
1260
1262
|
exportAssets: s
|
|
1261
1263
|
});
|
|
1262
1264
|
}
|
|
1263
|
-
const
|
|
1264
|
-
B(
|
|
1265
|
+
const v = b(h, "chunks");
|
|
1266
|
+
B(v, { recursive: !0 });
|
|
1265
1267
|
const { chunks: J } = await Fe();
|
|
1266
|
-
for (const F of Object.keys(((
|
|
1267
|
-
(
|
|
1268
|
+
for (const F of Object.keys(((T = t == null ? void 0 : t.resources) == null ? void 0 : T.components) ?? {}).filter(
|
|
1269
|
+
(M) => p.includes(M)
|
|
1268
1270
|
)) {
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
const Y = ((pe =
|
|
1271
|
+
const M = (le = (z = (_ = t.resources) == null ? void 0 : _.components) == null ? void 0 : z[F]) == null ? void 0 : le.component;
|
|
1272
|
+
if (M && ((ne = M.renderer) == null ? void 0 : ne.type) === "react-component") {
|
|
1273
|
+
const Y = ((pe = M.renderer) == null ? void 0 : pe.chunks) ?? [];
|
|
1272
1274
|
if ((Y == null ? void 0 : Y.length) > 0)
|
|
1273
1275
|
for (const Oe of Y) {
|
|
1274
|
-
const Be =
|
|
1276
|
+
const Be = b(v, Oe), Te = J == null ? void 0 : J[Oe];
|
|
1275
1277
|
try {
|
|
1276
|
-
|
|
1278
|
+
Te && $(Te) && !$(Be) && Ft(Te, Be);
|
|
1277
1279
|
} catch (ht) {
|
|
1278
1280
|
P.error(`copy chunk ${Oe} error`, ht.message);
|
|
1279
1281
|
}
|
|
@@ -1290,52 +1292,52 @@ async function dt(t, { importAssets: s, includeResources: e } = {}) {
|
|
|
1290
1292
|
let o, n = !1;
|
|
1291
1293
|
try {
|
|
1292
1294
|
X(t).isDirectory() ? o = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, o = pt(), await es({ file: t, C: o }));
|
|
1293
|
-
const l =
|
|
1295
|
+
const l = je("**/.blocklet/pages/pages.config.yml", { cwd: o, absolute: !0 }).at(0), u = l && b(L(l), "../../pages"), g = l && b(L(l), "../../components"), S = l && b(L(l), "../../chunks"), d = l && b(L(l), "../../routes");
|
|
1294
1296
|
if (!l)
|
|
1295
1297
|
return null;
|
|
1296
|
-
const i = ee.parse(Z(l).toString()), h = (y, f,
|
|
1297
|
-
let O =
|
|
1298
|
-
return (!$(O) || !X(O).isFile()) && (O =
|
|
1298
|
+
const i = ee.parse(Z(l).toString()), h = (y, f, E) => {
|
|
1299
|
+
let O = b(y, `${f}${E ? `.${E}` : ""}.yml`);
|
|
1300
|
+
return (!$(O) || !X(O).isFile()) && (O = b(y, f, `index${E ? `.${E}` : ""}.yml`), !$(O) || !X(O)) ? null : ee.parse(Z(O).toString());
|
|
1299
1301
|
}, I = (y, f) => {
|
|
1300
1302
|
try {
|
|
1301
|
-
const
|
|
1302
|
-
return
|
|
1303
|
-
} catch (
|
|
1304
|
-
P.error("parse component error",
|
|
1303
|
+
const E = je(`*.${f}.yml`, { cwd: y, absolute: !0 })[0];
|
|
1304
|
+
return E ? ee.parse(Z(E).toString()) : null;
|
|
1305
|
+
} catch (E) {
|
|
1306
|
+
P.error("parse component error", E);
|
|
1305
1307
|
}
|
|
1306
1308
|
return null;
|
|
1307
1309
|
}, G = (y, f) => {
|
|
1308
|
-
let
|
|
1309
|
-
return (!$(
|
|
1310
|
-
},
|
|
1310
|
+
let E = b(y, `${f}.yml`);
|
|
1311
|
+
return (!$(E) || !X(E).isFile()) && (E = b(y, f, "index.yml"), !$(E) || !X(E)) ? null : ee.parse(Z(E).toString());
|
|
1312
|
+
}, j = N(
|
|
1311
1313
|
i.pages.map(({ slug: y }) => {
|
|
1312
1314
|
var K;
|
|
1313
|
-
const f =
|
|
1314
|
-
i.supportedLocales.map(({ locale:
|
|
1315
|
-
const
|
|
1316
|
-
if (
|
|
1317
|
-
return { locale:
|
|
1318
|
-
const z = u ? h(u, y,
|
|
1319
|
-
return z && { locale:
|
|
1315
|
+
const f = N(
|
|
1316
|
+
i.supportedLocales.map(({ locale: T }) => {
|
|
1317
|
+
const _ = u ? h(u, Se(y), T) : void 0;
|
|
1318
|
+
if (_)
|
|
1319
|
+
return { locale: T, page: _ };
|
|
1320
|
+
const z = u ? h(u, y, T) : void 0;
|
|
1321
|
+
return z && { locale: T, page: z };
|
|
1320
1322
|
})
|
|
1321
|
-
),
|
|
1322
|
-
if (!
|
|
1323
|
+
), E = (K = f[0]) == null ? void 0 : K.page;
|
|
1324
|
+
if (!E)
|
|
1323
1325
|
return null;
|
|
1324
|
-
const O =
|
|
1325
|
-
const
|
|
1326
|
+
const O = E.sections.map((T) => {
|
|
1327
|
+
const _ = T.id || Ce();
|
|
1326
1328
|
return {
|
|
1327
|
-
id:
|
|
1328
|
-
component:
|
|
1329
|
-
config:
|
|
1330
|
-
name:
|
|
1331
|
-
isTemplateSection:
|
|
1332
|
-
templateDescription:
|
|
1333
|
-
llmConfig:
|
|
1334
|
-
visibility:
|
|
1329
|
+
id: _,
|
|
1330
|
+
component: T.component,
|
|
1331
|
+
config: T.config,
|
|
1332
|
+
name: T.name,
|
|
1333
|
+
isTemplateSection: T.isTemplateSection ?? !1,
|
|
1334
|
+
templateDescription: T.templateDescription,
|
|
1335
|
+
llmConfig: T.llmConfig,
|
|
1336
|
+
visibility: T.visibility,
|
|
1335
1337
|
locales: Object.fromEntries(
|
|
1336
|
-
|
|
1338
|
+
N(
|
|
1337
1339
|
f.map(({ locale: z, page: le }) => {
|
|
1338
|
-
const ne = le.sections.find((pe) => pe.id ===
|
|
1340
|
+
const ne = le.sections.find((pe) => pe.id === _);
|
|
1339
1341
|
return ne && [z, ne.properties];
|
|
1340
1342
|
})
|
|
1341
1343
|
)
|
|
@@ -1343,19 +1345,19 @@ async function dt(t, { importAssets: s, includeResources: e } = {}) {
|
|
|
1343
1345
|
};
|
|
1344
1346
|
});
|
|
1345
1347
|
return {
|
|
1346
|
-
id:
|
|
1347
|
-
createdAt:
|
|
1348
|
-
updatedAt:
|
|
1349
|
-
publishedAt:
|
|
1350
|
-
isPublic:
|
|
1351
|
-
templateConfig:
|
|
1348
|
+
id: E.id || Ce(),
|
|
1349
|
+
createdAt: E.createdAt,
|
|
1350
|
+
updatedAt: E.updatedAt,
|
|
1351
|
+
publishedAt: E.publishedAt,
|
|
1352
|
+
isPublic: E.isPublic ?? !0,
|
|
1353
|
+
templateConfig: E.templateConfig,
|
|
1352
1354
|
slug: y,
|
|
1353
|
-
sections: Object.fromEntries(O.map((
|
|
1354
|
-
sectionIds: O.map((
|
|
1355
|
-
locales: Object.fromEntries(f.map(({ locale:
|
|
1355
|
+
sections: Object.fromEntries(O.map((T) => [T.id, T])),
|
|
1356
|
+
sectionIds: O.map((T) => T.id),
|
|
1357
|
+
locales: Object.fromEntries(f.map(({ locale: T, page: _ }) => [T, _.meta]))
|
|
1356
1358
|
};
|
|
1357
1359
|
})
|
|
1358
|
-
), q =
|
|
1360
|
+
), q = N(
|
|
1359
1361
|
((r = i == null ? void 0 : i.routes) == null ? void 0 : r.map(({ path: y }) => {
|
|
1360
1362
|
const f = d ? G(d, Se(y)) : void 0;
|
|
1361
1363
|
return {
|
|
@@ -1373,28 +1375,28 @@ async function dt(t, { importAssets: s, includeResources: e } = {}) {
|
|
|
1373
1375
|
dataSource: (f == null ? void 0 : f.dataSource) ?? {}
|
|
1374
1376
|
};
|
|
1375
1377
|
})) ?? []
|
|
1376
|
-
), V = g ?
|
|
1378
|
+
), V = g ? N(((c = i.components) == null ? void 0 : c.map(({ id: y }) => I(g, y))) ?? []) : [];
|
|
1377
1379
|
if (s) {
|
|
1378
1380
|
const y = (...f) => {
|
|
1379
|
-
P.info(`[${n ? se(t) : se(
|
|
1381
|
+
P.info(`[${n ? se(t) : se(b(t, "../../../../"))}] importAssets:`, ...f);
|
|
1380
1382
|
};
|
|
1381
1383
|
try {
|
|
1382
1384
|
y("wait image-bin api ready"), await ts({
|
|
1383
|
-
resources: [`${
|
|
1385
|
+
resources: [`${Rt(us)}/api/sdk/uploads`],
|
|
1384
1386
|
validateStatus: (O) => O >= 200 && O <= 500
|
|
1385
1387
|
}), y("image-bin api is ready");
|
|
1386
|
-
const f = {},
|
|
1388
|
+
const f = {}, E = {};
|
|
1387
1389
|
y("start to upload assets"), await Promise.allSettled([
|
|
1388
1390
|
Ze(V, f, {
|
|
1389
|
-
getFilePath: (O) => g &&
|
|
1391
|
+
getFilePath: (O) => g && b(g, O),
|
|
1390
1392
|
onFinish: (O) => {
|
|
1391
1393
|
y(`upload ${O.length} component assets`);
|
|
1392
1394
|
}
|
|
1393
1395
|
}),
|
|
1394
|
-
Ze(
|
|
1396
|
+
Ze(j, E, {
|
|
1395
1397
|
getFilePath: (O, K) => {
|
|
1396
|
-
const
|
|
1397
|
-
return u &&
|
|
1398
|
+
const T = Le(j, K.slice(0, 1));
|
|
1399
|
+
return u && b(u, L(T.slug), O);
|
|
1398
1400
|
},
|
|
1399
1401
|
onFinish: (O) => {
|
|
1400
1402
|
y(`upload ${O.length} page assets`);
|
|
@@ -1407,24 +1409,24 @@ async function dt(t, { importAssets: s, includeResources: e } = {}) {
|
|
|
1407
1409
|
}
|
|
1408
1410
|
const ce = {};
|
|
1409
1411
|
if (e) {
|
|
1410
|
-
const y = l &&
|
|
1411
|
-
((p = (a = i.resources) == null ? void 0 : a.components) == null ? void 0 : p.map(({ id:
|
|
1412
|
+
const y = l && b(L(l), "../../resources/components"), f = N(
|
|
1413
|
+
((p = (a = i.resources) == null ? void 0 : a.components) == null ? void 0 : p.map(({ id: E }) => I(y, E))) ?? []
|
|
1412
1414
|
);
|
|
1413
1415
|
f.length > 0 && (ce.components = Object.fromEntries(
|
|
1414
|
-
f.map((
|
|
1416
|
+
f.map((E, O) => [E.id, { index: O, component: E }])
|
|
1415
1417
|
));
|
|
1416
1418
|
}
|
|
1417
1419
|
const oe = {};
|
|
1418
1420
|
if (S && $(S)) {
|
|
1419
|
-
const y =
|
|
1421
|
+
const y = Ut(S);
|
|
1420
1422
|
for (const f of y)
|
|
1421
|
-
oe[f] =
|
|
1423
|
+
oe[f] = b(S, f);
|
|
1422
1424
|
}
|
|
1423
1425
|
return {
|
|
1424
1426
|
supportedLocales: i.supportedLocales,
|
|
1425
|
-
pageIds:
|
|
1427
|
+
pageIds: j.map((y) => y.id),
|
|
1426
1428
|
components: Object.fromEntries(V.map((y, f) => [y.id, { index: f, data: y }])),
|
|
1427
|
-
pages: Object.fromEntries(
|
|
1429
|
+
pages: Object.fromEntries(j.map((y) => [y.id, y])),
|
|
1428
1430
|
config: i.config || {},
|
|
1429
1431
|
resources: ce,
|
|
1430
1432
|
chunks: oe,
|
|
@@ -1435,7 +1437,7 @@ async function dt(t, { importAssets: s, includeResources: e } = {}) {
|
|
|
1435
1437
|
n && o && ot(o, { force: !0, recursive: !0 });
|
|
1436
1438
|
}
|
|
1437
1439
|
}
|
|
1438
|
-
function
|
|
1440
|
+
function De(t, s, e) {
|
|
1439
1441
|
var n, r, c, a, p, l;
|
|
1440
1442
|
const o = {
|
|
1441
1443
|
...nt(t),
|
|
@@ -1463,7 +1465,7 @@ async function et(t, s, {
|
|
|
1463
1465
|
} = {}) {
|
|
1464
1466
|
var S;
|
|
1465
1467
|
try {
|
|
1466
|
-
r &&
|
|
1468
|
+
r && Es(r);
|
|
1467
1469
|
} catch (d) {
|
|
1468
1470
|
P.error("clear preload page cache error", { error: d });
|
|
1469
1471
|
}
|
|
@@ -1482,13 +1484,13 @@ async function et(t, s, {
|
|
|
1482
1484
|
if (h)
|
|
1483
1485
|
if (s.pageIds.includes(i.id)) {
|
|
1484
1486
|
if (o === "replace")
|
|
1485
|
-
s.pages[i.id] =
|
|
1487
|
+
s.pages[i.id] = De(h, i, t);
|
|
1486
1488
|
else if (o === "byUpdateTime") {
|
|
1487
1489
|
const I = s.pages[i.id];
|
|
1488
|
-
(!I || i.updatedAt && i.updatedAt > I.updatedAt) && (s.pages[i.id] =
|
|
1490
|
+
(!I || i.updatedAt && i.updatedAt > I.updatedAt) && (s.pages[i.id] = De(h, i, t));
|
|
1489
1491
|
}
|
|
1490
1492
|
} else
|
|
1491
|
-
s.pageIds.push(i.id), s.pages[i.id] =
|
|
1493
|
+
s.pageIds.push(i.id), s.pages[i.id] = De(h, i, t);
|
|
1492
1494
|
}
|
|
1493
1495
|
if (n && !e)
|
|
1494
1496
|
for (const d of s.pageIds)
|
|
@@ -1552,7 +1554,7 @@ const ft = Ie(
|
|
|
1552
1554
|
const { script: e } = (t == null ? void 0 : t.renderer) || {};
|
|
1553
1555
|
if (e && e.includes("PROPERTIES_SCHEMA"))
|
|
1554
1556
|
try {
|
|
1555
|
-
const o = await
|
|
1557
|
+
const o = await Ts(e, "PROPERTIES_SCHEMA", t.id);
|
|
1556
1558
|
o && o.length > 0 && t && (t.properties = {}, o.forEach((n, r) => {
|
|
1557
1559
|
t != null && t.properties && (t.properties[n.id] = {
|
|
1558
1560
|
index: r,
|
|
@@ -1577,10 +1579,10 @@ const ft = Ie(
|
|
|
1577
1579
|
}
|
|
1578
1580
|
}
|
|
1579
1581
|
);
|
|
1580
|
-
let
|
|
1582
|
+
let be, te, Me, Ue, $e;
|
|
1581
1583
|
function mt() {
|
|
1582
|
-
return
|
|
1583
|
-
const t =
|
|
1584
|
+
return be = (async () => {
|
|
1585
|
+
const t = Nt({
|
|
1584
1586
|
types: [
|
|
1585
1587
|
{ did: lt, type: qe },
|
|
1586
1588
|
{ did: Cs, type: qe }
|
|
@@ -1591,7 +1593,7 @@ function mt() {
|
|
|
1591
1593
|
const o = e.path ? await dt(e.path, { importAssets: !1 }) : void 0;
|
|
1592
1594
|
return o ? { blockletId: e.did, state: o, blockletTitle: e.title } : void 0;
|
|
1593
1595
|
})
|
|
1594
|
-
)).filter((e) => !!e),
|
|
1596
|
+
)).filter((e) => !!e), Me = te.reduce(
|
|
1595
1597
|
(e, o) => Object.assign(
|
|
1596
1598
|
e,
|
|
1597
1599
|
Object.fromEntries(
|
|
@@ -1609,7 +1611,7 @@ function mt() {
|
|
|
1609
1611
|
),
|
|
1610
1612
|
{}
|
|
1611
1613
|
);
|
|
1612
|
-
|
|
1614
|
+
Ue = Object.fromEntries(
|
|
1613
1615
|
await Promise.all(
|
|
1614
1616
|
Object.entries(s).map(async ([e, o]) => {
|
|
1615
1617
|
const n = await ft(o.component);
|
|
@@ -1623,7 +1625,7 @@ function mt() {
|
|
|
1623
1625
|
})
|
|
1624
1626
|
)
|
|
1625
1627
|
), $e = te.reduce((e, o) => Object.assign(e, o.state.chunks), {});
|
|
1626
|
-
})(),
|
|
1628
|
+
})(), be;
|
|
1627
1629
|
}
|
|
1628
1630
|
function $s(t) {
|
|
1629
1631
|
const s = rt(
|
|
@@ -1632,8 +1634,8 @@ function $s(t) {
|
|
|
1632
1634
|
P.error("load resource states error", { error: e });
|
|
1633
1635
|
}), await (t == null ? void 0 : t({
|
|
1634
1636
|
states: te,
|
|
1635
|
-
pages:
|
|
1636
|
-
components:
|
|
1637
|
+
pages: Me,
|
|
1638
|
+
components: Ue,
|
|
1637
1639
|
chunks: $e
|
|
1638
1640
|
}));
|
|
1639
1641
|
},
|
|
@@ -1641,8 +1643,8 @@ function $s(t) {
|
|
|
1641
1643
|
// 3s
|
|
1642
1644
|
{ leading: !1, trailing: !0 }
|
|
1643
1645
|
);
|
|
1644
|
-
return s(),
|
|
1645
|
-
|
|
1646
|
+
return s(), w.events.on(w.Events.componentAdded, s), w.events.on(w.Events.componentRemoved, s), w.events.on(w.Events.componentStarted, s), w.events.on(w.Events.componentStopped, s), w.events.on(w.Events.componentUpdated, s), w.events.on(ke, s), () => {
|
|
1647
|
+
w.events.off(w.Events.componentAdded, s), w.events.off(w.Events.componentRemoved, s), w.events.off(w.Events.componentStarted, s), w.events.off(w.Events.componentStopped, s), w.events.off(w.Events.componentUpdated, s), w.events.off(ke, s);
|
|
1646
1648
|
};
|
|
1647
1649
|
}
|
|
1648
1650
|
const gt = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ge = globalThis;
|
|
@@ -1680,12 +1682,12 @@ ge[gt] = $s(async ({ pages: t, components: s }) => {
|
|
|
1680
1682
|
});
|
|
1681
1683
|
});
|
|
1682
1684
|
async function Lo() {
|
|
1683
|
-
P.info("trigger reload all project resource"),
|
|
1685
|
+
P.info("trigger reload all project resource"), w.events.emit(ke);
|
|
1684
1686
|
}
|
|
1685
1687
|
async function Fe({
|
|
1686
1688
|
ensureLoaded: t = !0
|
|
1687
1689
|
} = {}) {
|
|
1688
|
-
return t && (
|
|
1690
|
+
return t && (be ?? (be = mt()), await be), { states: te, pages: Me, components: Ue, chunks: $e };
|
|
1689
1691
|
}
|
|
1690
1692
|
export {
|
|
1691
1693
|
lt as C,
|
|
@@ -1693,26 +1695,26 @@ export {
|
|
|
1693
1695
|
W as P,
|
|
1694
1696
|
qe as R,
|
|
1695
1697
|
we as S,
|
|
1696
|
-
|
|
1698
|
+
Do as a,
|
|
1697
1699
|
Fe as b,
|
|
1698
1700
|
Ss as c,
|
|
1699
1701
|
ws as d,
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1702
|
+
Es as e,
|
|
1703
|
+
bs as f,
|
|
1704
|
+
jo as g,
|
|
1703
1705
|
Is as h,
|
|
1704
1706
|
xo as i,
|
|
1705
1707
|
ye as j,
|
|
1706
|
-
|
|
1708
|
+
ko as k,
|
|
1707
1709
|
P as l,
|
|
1708
|
-
|
|
1710
|
+
Ts as m,
|
|
1709
1711
|
Ce as n,
|
|
1710
1712
|
de as o,
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
+
No as p,
|
|
1714
|
+
Ro as q,
|
|
1713
1715
|
dt as r,
|
|
1714
1716
|
et as s,
|
|
1715
|
-
|
|
1717
|
+
Us as t,
|
|
1716
1718
|
$s as u,
|
|
1717
1719
|
Lo as v
|
|
1718
1720
|
};
|