@blocklet/pages-kit-inner-components 0.5.28 → 0.5.30
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-DvIWP0pO.js +57 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/project-html.js +6 -6
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/chunks/site-state-DJ3JcBMm.js +2041 -0
- package/lib/es/components.js +1 -1
- package/lib/es/project-html.js +113 -121
- package/lib/es/resources.js +51 -51
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -4
- package/lib/cjs/chunks/site-state-JgP3yURe.js +0 -57
- package/lib/es/chunks/site-state-BB9-Tm4i.js +0 -1930
package/lib/es/components.js
CHANGED
|
@@ -7,7 +7,7 @@ import "lru-cache";
|
|
|
7
7
|
import "node-fetch";
|
|
8
8
|
import "ufo";
|
|
9
9
|
import "crypto";
|
|
10
|
-
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-
|
|
10
|
+
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-DJ3JcBMm.js";
|
|
11
11
|
export {
|
|
12
12
|
_ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
|
|
13
13
|
E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
|
package/lib/es/project-html.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import N from "@arcblock/did-auth-storage-nedb";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { l as
|
|
9
|
-
import {
|
|
10
|
-
import { PreloadComponentScriptModule as
|
|
11
|
-
import { isMuiColorKey as
|
|
12
|
-
import { injectPreloadComponents as
|
|
13
|
-
import { getComponentMountPoint as
|
|
14
|
-
import * as
|
|
15
|
-
import { Router as
|
|
16
|
-
import { readFileSync as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { withQuery as
|
|
20
|
-
const
|
|
2
|
+
import i, { getBlockletJs as H } from "@blocklet/sdk/lib/config";
|
|
3
|
+
import O from "@blocklet/sdk/lib/service/auth";
|
|
4
|
+
import R from "@blocklet/sdk/lib/wallet";
|
|
5
|
+
import J from "@blocklet/sdk/lib/wallet-authenticator";
|
|
6
|
+
import z from "@blocklet/sdk/lib/wallet-handler";
|
|
7
|
+
import G, { resolve as x } from "path";
|
|
8
|
+
import { l as T, g as Y } from "./chunks/site-state-DJ3JcBMm.js";
|
|
9
|
+
import { createSnapshotMiddleware as Q } from "@arcblock/crawler-middleware";
|
|
10
|
+
import { PreloadComponentScriptModule as V } from "@blocklet/pages-kit/types";
|
|
11
|
+
import { isMuiColorKey as X } from "@blocklet/pages-kit/utils/common";
|
|
12
|
+
import { injectPreloadComponents as Z } from "@blocklet/pages-kit/utils/preload";
|
|
13
|
+
import { getComponentMountPoint as q } from "@blocklet/sdk/lib/component";
|
|
14
|
+
import * as M from "cheerio/slim";
|
|
15
|
+
import { Router as F } from "express";
|
|
16
|
+
import { readFileSync as L } from "fs";
|
|
17
|
+
import ee from "lodash/get";
|
|
18
|
+
import te from "mustache";
|
|
19
|
+
import { withQuery as oe, joinURL as W } from "ufo";
|
|
20
|
+
const ne = (o = {}) => {
|
|
21
21
|
const t = {
|
|
22
22
|
data: /* @__PURE__ */ new Map(),
|
|
23
23
|
timers: /* @__PURE__ */ new Map(),
|
|
24
|
-
set: (e, d,
|
|
24
|
+
set: (e, d, h = o.ttl || 36e5) => {
|
|
25
25
|
o.max && t.data.size >= o.max && t.delete(t.data.keys().next().value), t.timers.has(e) && clearTimeout(t.timers.get(e)), t.timers.set(
|
|
26
26
|
e,
|
|
27
|
-
setTimeout(() => t.delete(e),
|
|
27
|
+
setTimeout(() => t.delete(e), h)
|
|
28
28
|
), t.data.set(e, d);
|
|
29
29
|
},
|
|
30
30
|
get: (e) => t.data.get(e),
|
|
@@ -38,39 +38,31 @@ const ce = (o = {}) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
return t;
|
|
41
|
-
}, j =
|
|
41
|
+
}, j = ne({
|
|
42
42
|
max: 1,
|
|
43
43
|
ttl: 1e3 * 30
|
|
44
44
|
// 30 seconds
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
new
|
|
49
|
-
authenticator:
|
|
46
|
+
R();
|
|
47
|
+
const re = new J();
|
|
48
|
+
new z({
|
|
49
|
+
authenticator: re,
|
|
50
50
|
tokenStorage: new N({
|
|
51
|
-
dbPath:
|
|
51
|
+
dbPath: G.join(i.env.dataDir, "auth.db")
|
|
52
52
|
})
|
|
53
53
|
});
|
|
54
|
-
const
|
|
54
|
+
const ce = new O(), se = async () => {
|
|
55
55
|
try {
|
|
56
56
|
const o = j.get("blockletInfo");
|
|
57
57
|
if (o)
|
|
58
58
|
return o;
|
|
59
|
-
const { blocklet: t } = await
|
|
59
|
+
const { blocklet: t } = await ce.getBlocklet();
|
|
60
60
|
return j.set("blockletInfo", t), t;
|
|
61
61
|
} catch {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
},
|
|
65
|
-
function
|
|
66
|
-
B() ? Y({
|
|
67
|
-
time: "0 0 */12 * * *",
|
|
68
|
-
options: {}
|
|
69
|
-
}) : Z();
|
|
70
|
-
}
|
|
71
|
-
U();
|
|
72
|
-
s.events.on(s.Events.envUpdate, U);
|
|
73
|
-
function Le({
|
|
64
|
+
}, ie = ["/assets/"];
|
|
65
|
+
function Pe({
|
|
74
66
|
app: o,
|
|
75
67
|
viteDevServer: t,
|
|
76
68
|
// projectId,
|
|
@@ -78,112 +70,112 @@ function Le({
|
|
|
78
70
|
}) {
|
|
79
71
|
let d;
|
|
80
72
|
if (t) {
|
|
81
|
-
const
|
|
82
|
-
o.use(async (
|
|
83
|
-
const
|
|
84
|
-
d = await t.transformIndexHtml(
|
|
73
|
+
const n = L(x(process.cwd(), "./index.html"), "utf-8");
|
|
74
|
+
o.use(async (k, _, y) => {
|
|
75
|
+
const C = k.originalUrl;
|
|
76
|
+
d = await t.transformIndexHtml(C, n), y();
|
|
85
77
|
});
|
|
86
78
|
} else
|
|
87
|
-
d =
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
d = L(x(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
|
|
80
|
+
const h = F();
|
|
81
|
+
h.use((n, k, _) => {
|
|
82
|
+
if (n.headers["x-unique-record"] === "dial_http") {
|
|
83
|
+
T.info("[html] dial http request, return 200 status code"), k.status(200).send("ok");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
_();
|
|
87
|
+
}), i.env.preferences.snapkitEnabled && i.env.preferences.snapkitEndpoint && i.env.SNAP_KIT_ACCESS_KEY && h.use(
|
|
88
|
+
Q({
|
|
89
|
+
endpoint: i.env.preferences.snapkitEndpoint,
|
|
90
|
+
accessKey: i.env.SNAP_KIT_ACCESS_KEY,
|
|
91
|
+
cacheMax: i.env.preferences.snapkitCacheSize || 100
|
|
100
92
|
})
|
|
101
|
-
),
|
|
102
|
-
var
|
|
103
|
-
if (
|
|
104
|
-
var
|
|
105
|
-
return (
|
|
93
|
+
), h.get("/:path(*)?", async (n, k, _) => {
|
|
94
|
+
var E, P, A;
|
|
95
|
+
if (ie.some((s) => {
|
|
96
|
+
var p;
|
|
97
|
+
return (p = n.path) == null ? void 0 : p.startsWith(s);
|
|
106
98
|
})) {
|
|
107
|
-
|
|
99
|
+
_();
|
|
108
100
|
return;
|
|
109
101
|
}
|
|
110
|
-
const
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
let
|
|
115
|
-
if ((!
|
|
116
|
-
const
|
|
117
|
-
Object.values(e.pages).forEach((
|
|
118
|
-
const
|
|
119
|
-
(
|
|
120
|
-
var
|
|
121
|
-
return
|
|
102
|
+
const y = performance.now(), C = () => Math.round(performance.now() - y), D = "production";
|
|
103
|
+
let c, u, b = d;
|
|
104
|
+
if (n.path.startsWith("/pages")) {
|
|
105
|
+
const s = n.params.lang, p = n.cookies.nf_lang, v = /* @__PURE__ */ new Set([...i.env.languages.map((w) => w.code)]);
|
|
106
|
+
let g = (s && v.has(s) ? s : void 0) || (v.has(p) ? p : void 0) || [...v][0];
|
|
107
|
+
if ((!g || !((E = e.supportedLocales) != null && E.find((w) => w.locale === g))) && (g = ((A = (P = e.supportedLocales) == null ? void 0 : P[0]) == null ? void 0 : A.locale) || ""), g) {
|
|
108
|
+
const w = [];
|
|
109
|
+
Object.values(e.pages).forEach((l) => {
|
|
110
|
+
const B = Object.values((l == null ? void 0 : l.sections) ?? {}).filter(
|
|
111
|
+
(m) => {
|
|
112
|
+
var S;
|
|
113
|
+
return m.component === "custom-component" && ((S = m.config) == null ? void 0 : S.componentId);
|
|
122
114
|
}
|
|
123
|
-
).map((
|
|
124
|
-
var
|
|
115
|
+
).map((m) => {
|
|
116
|
+
var S, $;
|
|
125
117
|
return {
|
|
126
|
-
id:
|
|
127
|
-
componentId:
|
|
128
|
-
useCache:
|
|
129
|
-
cacheDuration:
|
|
130
|
-
properties: (
|
|
118
|
+
id: m.id,
|
|
119
|
+
componentId: m.config.componentId,
|
|
120
|
+
useCache: m.config.useCache,
|
|
121
|
+
cacheDuration: m.config.cacheDuration,
|
|
122
|
+
properties: ($ = (S = m.locales) == null ? void 0 : S[g]) == null ? void 0 : $.properties
|
|
131
123
|
};
|
|
132
124
|
});
|
|
133
|
-
|
|
125
|
+
w.push(...B);
|
|
134
126
|
});
|
|
135
|
-
const
|
|
127
|
+
const U = new Promise((l) => {
|
|
136
128
|
setTimeout(() => {
|
|
137
|
-
|
|
129
|
+
l({});
|
|
138
130
|
}, 90 * 1e3);
|
|
139
131
|
});
|
|
140
132
|
try {
|
|
141
133
|
await Promise.race([
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
U,
|
|
135
|
+
Y({
|
|
144
136
|
mode: D,
|
|
145
|
-
req:
|
|
137
|
+
req: n,
|
|
146
138
|
state: e,
|
|
147
|
-
locale:
|
|
148
|
-
instances:
|
|
149
|
-
module:
|
|
150
|
-
}).then((
|
|
151
|
-
|
|
139
|
+
locale: g,
|
|
140
|
+
instances: w,
|
|
141
|
+
module: V.UMD_FN
|
|
142
|
+
}).then((l) => {
|
|
143
|
+
l && (u = Z(l));
|
|
152
144
|
})
|
|
153
145
|
]);
|
|
154
|
-
} catch (
|
|
155
|
-
|
|
146
|
+
} catch (l) {
|
|
147
|
+
T.warn("getPreloadComponents timeout in promise race, skip inject html elements", l);
|
|
156
148
|
}
|
|
157
149
|
}
|
|
158
150
|
}
|
|
159
151
|
try {
|
|
160
|
-
const
|
|
161
|
-
title:
|
|
162
|
-
description:
|
|
152
|
+
const s = (c == null ? void 0 : c.title) || i.env.appName, p = (c == null ? void 0 : c.description) || i.env.appDescription, v = oe(W(i.env.appUrl, "/.well-known/service/blocklet/og.png"), {
|
|
153
|
+
title: s,
|
|
154
|
+
description: p
|
|
163
155
|
});
|
|
164
|
-
|
|
165
|
-
ogTitle:
|
|
166
|
-
ogDescription:
|
|
167
|
-
ogImage:
|
|
156
|
+
b = te.render(d, {
|
|
157
|
+
ogTitle: s,
|
|
158
|
+
ogDescription: p,
|
|
159
|
+
ogImage: le(c == null ? void 0 : c.image) || v,
|
|
168
160
|
pagesPublishedAt: (e == null ? void 0 : e.config.publishedAt) || (/* @__PURE__ */ new Date()).getTime()
|
|
169
161
|
});
|
|
170
162
|
} catch {
|
|
171
163
|
}
|
|
172
|
-
const
|
|
173
|
-
let a =
|
|
174
|
-
if (a &&
|
|
175
|
-
const
|
|
176
|
-
a =
|
|
177
|
-
|
|
164
|
+
const r = e == null ? void 0 : e.config.fontFamily, K = n.query.mode === "draft" || n.url.includes("preview"), f = M.load(b);
|
|
165
|
+
let a = c == null ? void 0 : c.backgroundColor;
|
|
166
|
+
if (a && X(a)) {
|
|
167
|
+
const s = await se();
|
|
168
|
+
a = ee(
|
|
169
|
+
s,
|
|
178
170
|
// 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
|
|
179
171
|
`settings.theme.light.palette.${a}`,
|
|
180
172
|
a
|
|
181
173
|
);
|
|
182
174
|
}
|
|
183
|
-
|
|
175
|
+
f("head").find("#injected-head-elements").replaceWith(`
|
|
184
176
|
${a ? `<meta name="theme-color" content="${a}" /><style>html,body,#app {background-color: ${a};}</style>` : ""}
|
|
185
|
-
${
|
|
186
|
-
${
|
|
177
|
+
${r != null && r.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${r.title}&display=swap">` : ""}
|
|
178
|
+
${r != null && r.description && (r == null ? void 0 : r.description) !== (r == null ? void 0 : r.title) ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${r.description}&display=swap">` : ""}
|
|
187
179
|
<script>
|
|
188
180
|
|
|
189
181
|
window.__PAGE_STATE__ = ${JSON.stringify(e, null, 0)}
|
|
@@ -196,25 +188,25 @@ function Le({
|
|
|
196
188
|
});
|
|
197
189
|
<\/script>
|
|
198
190
|
|
|
199
|
-
${
|
|
191
|
+
${K ? `<script src="https://cdn.tailwindcss.com"><\/script>
|
|
200
192
|
<script>
|
|
201
193
|
window.tailwind.config = {
|
|
202
194
|
darkMode: "class",
|
|
203
195
|
};
|
|
204
196
|
<\/script>` : ""}
|
|
205
197
|
`);
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
|
|
198
|
+
const I = H();
|
|
199
|
+
if (I && f('script[src="__blocklet__.js"]').replaceWith(`<script>${I}<\/script>`), u != null && u.html && f("head").find("#injected-html-elements").replaceWith(u.html), n.cachedHtml) {
|
|
200
|
+
const s = M.load(n.cachedHtml);
|
|
201
|
+
f("body").html(s("body").html() || "");
|
|
210
202
|
}
|
|
211
|
-
|
|
212
|
-
}), o.use(
|
|
203
|
+
b = f.html(), k.send(b), T.info(`[html] render: ${n.path}, ${C()}ms`), f.root().children().remove(), b = null, c = null, u = null;
|
|
204
|
+
}), o.use(h);
|
|
213
205
|
}
|
|
214
|
-
function
|
|
215
|
-
const t =
|
|
216
|
-
return t && o && !/^(https?:\/\/|\/)/.test(o) ?
|
|
206
|
+
function le(o) {
|
|
207
|
+
const t = q("image-bin");
|
|
208
|
+
return t && o && !/^(https?:\/\/|\/)/.test(o) ? i.env.appUrl + W(t, "uploads", o) : o;
|
|
217
209
|
}
|
|
218
210
|
export {
|
|
219
|
-
|
|
211
|
+
Pe as default
|
|
220
212
|
};
|
package/lib/es/resources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as S, i as b, a as M, l as x, C as J, R as X, S as N, t as W, b as G } from "./chunks/site-state-
|
|
1
|
+
import { P as S, i as b, a as M, l as x, C as J, R as X, S as N, t as W, b as G } from "./chunks/site-state-DJ3JcBMm.js";
|
|
2
2
|
import { AsyncLocalStorage as K } from "async_hooks";
|
|
3
3
|
import { Router as Y } from "express";
|
|
4
4
|
import d from "fs";
|
|
@@ -9,16 +9,16 @@ import C, { join as z } from "path";
|
|
|
9
9
|
import D from "@blocklet/sdk/lib/middlewares/auth";
|
|
10
10
|
import { getResourceExportDir as H } from "@blocklet/sdk/lib/component";
|
|
11
11
|
new K();
|
|
12
|
-
const Q = async (
|
|
12
|
+
const Q = async (o, t, e) => {
|
|
13
13
|
var n, s, r, i;
|
|
14
14
|
try {
|
|
15
|
-
const { projectId: a } =
|
|
15
|
+
const { projectId: a } = o.params;
|
|
16
16
|
if (!a)
|
|
17
|
-
return
|
|
17
|
+
return e();
|
|
18
18
|
const m = await S.findByPk(a);
|
|
19
19
|
if (!m)
|
|
20
20
|
return t == null ? void 0 : t.status(404).json({ error: "Project not found" });
|
|
21
|
-
const y = (n =
|
|
21
|
+
const y = (n = o.user) == null ? void 0 : n.did, w = ((s = o.user) == null ? void 0 : s.role) || "UNKNOWN_ROLE";
|
|
22
22
|
if (!y)
|
|
23
23
|
return t == null ? void 0 : t.status(401).json({ error: "Authentication required" });
|
|
24
24
|
if (b()) {
|
|
@@ -27,75 +27,75 @@ const Q = async (e, t, o) => {
|
|
|
27
27
|
return t == null ? void 0 : t.status(403).json({ error: "No permission to access this project in multi-tenant mode" });
|
|
28
28
|
} else if (!["owner", "admin", "pagesEditor"].includes(w))
|
|
29
29
|
return t == null ? void 0 : t.status(403).json({ error: "No permission to access this project in single-tenant mode" });
|
|
30
|
-
|
|
30
|
+
o.project = m, o.projectId = a, e();
|
|
31
31
|
} catch (a) {
|
|
32
32
|
x.error("Project middleware error:", a), t == null || t.status(500).json({ error: "Internal server error" });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
function
|
|
36
|
-
return new Promise((
|
|
37
|
-
const s = d.createReadStream(
|
|
38
|
-
s.on("error", n), r.on("error", n), r.on("finish",
|
|
35
|
+
function B(o, t) {
|
|
36
|
+
return new Promise((e, n) => {
|
|
37
|
+
const s = d.createReadStream(o), r = d.createWriteStream(t);
|
|
38
|
+
s.on("error", n), r.on("error", n), r.on("finish", e), s.pipe(r);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
async function
|
|
41
|
+
async function T(o, t) {
|
|
42
42
|
await d.promises.mkdir(t, { recursive: !0 });
|
|
43
|
-
const
|
|
44
|
-
for (const n of
|
|
45
|
-
const s = C.join(
|
|
46
|
-
n.isDirectory() ? await
|
|
43
|
+
const e = await d.promises.readdir(o, { withFileTypes: !0 });
|
|
44
|
+
for (const n of e) {
|
|
45
|
+
const s = C.join(o, n.name), r = C.join(t, n.name);
|
|
46
|
+
n.isDirectory() ? await T(s, r) : await B(s, r);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
async function V(
|
|
50
|
-
(await d.promises.stat(
|
|
49
|
+
async function V(o, t) {
|
|
50
|
+
(await d.promises.stat(o)).isDirectory() ? await T(o, t) : await B(o, t);
|
|
51
51
|
}
|
|
52
|
-
const h = (
|
|
53
|
-
const
|
|
54
|
-
return z(
|
|
55
|
-
}, O = Y(), L = "@page", U = "@component", I = ":", E = "ALL", F = "@project", k = ({ pageId:
|
|
56
|
-
const [t,
|
|
57
|
-
if (t === L) return { pageId: n, projectId:
|
|
58
|
-
}, v = ({ componentId:
|
|
59
|
-
const [t,
|
|
60
|
-
if (t === U) return { componentId: n, projectId:
|
|
61
|
-
},
|
|
62
|
-
const [t,
|
|
63
|
-
if (t === F) return
|
|
64
|
-
}, rt = (
|
|
52
|
+
const h = (o, t, e) => b() ? D()(o, t, e) : D({ roles: ["owner", "admin", "pagesEditor"] })(o, t, e), Z = (o, t) => {
|
|
53
|
+
const e = H({ projectId: o, releaseId: t });
|
|
54
|
+
return z(e, J, X);
|
|
55
|
+
}, O = Y(), L = "@page", U = "@component", I = ":", E = "ALL", F = "@project", k = ({ pageId: o, projectId: t }) => [L, t, o].join(I), q = (o) => {
|
|
56
|
+
const [t, e, n] = o.split(I);
|
|
57
|
+
if (t === L) return { pageId: n, projectId: e };
|
|
58
|
+
}, v = ({ componentId: o, projectId: t }) => [U, t, o].join(I), tt = (o) => {
|
|
59
|
+
const [t, e, n] = o.split(I);
|
|
60
|
+
if (t === U) return { componentId: n, projectId: e };
|
|
61
|
+
}, ot = (o) => [F, o].join(I), et = (o) => {
|
|
62
|
+
const [t, e] = o.split(I);
|
|
63
|
+
if (t === F) return e;
|
|
64
|
+
}, rt = (o) => {
|
|
65
65
|
try {
|
|
66
|
-
return JSON.parse(
|
|
66
|
+
return JSON.parse(o);
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
return {};
|
|
70
70
|
};
|
|
71
|
-
async function A(
|
|
72
|
-
const t = await N.
|
|
71
|
+
async function A(o) {
|
|
72
|
+
const t = await N.getStateByProjectId(o, "production"), e = await S.findByPk(o), n = t.pageIds.map((r) => {
|
|
73
73
|
const i = t.pages[r];
|
|
74
74
|
if (i)
|
|
75
|
-
return { id: k({ pageId: r, projectId:
|
|
75
|
+
return { id: k({ pageId: r, projectId: o }), name: i.slug };
|
|
76
76
|
}).filter(Boolean), s = $(Object.values(t.components), (r) => r.index).map(({ data: r }) => ({
|
|
77
|
-
id: v({ componentId: r.id, projectId:
|
|
77
|
+
id: v({ componentId: r.id, projectId: o }),
|
|
78
78
|
name: r.name || r.id
|
|
79
79
|
}));
|
|
80
80
|
return {
|
|
81
|
-
id:
|
|
82
|
-
name: (
|
|
81
|
+
id: ot(o),
|
|
82
|
+
name: (e == null ? void 0 : e.name) || "Unnamed Project",
|
|
83
83
|
children: [
|
|
84
|
-
{ id: k({ pageId: E, projectId:
|
|
84
|
+
{ id: k({ pageId: E, projectId: o }), name: "Pages", children: n },
|
|
85
85
|
{
|
|
86
|
-
id: v({ componentId: E, projectId:
|
|
86
|
+
id: v({ componentId: E, projectId: o }),
|
|
87
87
|
name: "Components",
|
|
88
88
|
children: s
|
|
89
89
|
}
|
|
90
90
|
]
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
O.get("/resources", h, async (
|
|
94
|
-
const { projectId:
|
|
95
|
-
if (
|
|
96
|
-
|
|
93
|
+
O.get("/resources", h, async (o, t) => {
|
|
94
|
+
const { projectId: e } = rt(o.query.resourcesParams);
|
|
95
|
+
if (e) {
|
|
96
|
+
o.params = { ...o.params, projectId: e }, await Q(o, t, () => {
|
|
97
97
|
});
|
|
98
|
-
const r = await A(
|
|
98
|
+
const r = await A(e);
|
|
99
99
|
t.json({ resources: [r] });
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
@@ -113,10 +113,10 @@ const nt = g.object({
|
|
|
113
113
|
resources: g.array().items(g.string()).required(),
|
|
114
114
|
locale: g.string().allow("")
|
|
115
115
|
});
|
|
116
|
-
O.post("/resources", h, async (
|
|
117
|
-
const { resources:
|
|
118
|
-
for (const c of
|
|
119
|
-
if (
|
|
116
|
+
O.post("/resources", h, async (o, t) => {
|
|
117
|
+
const { resources: e, projectId: n, releaseId: s } = await nt.validateAsync(o.body), r = "production", i = [], a = [];
|
|
118
|
+
for (const c of e) {
|
|
119
|
+
if (et(c))
|
|
120
120
|
continue;
|
|
121
121
|
const { pageId: l, projectId: f } = q(c) || {};
|
|
122
122
|
if (l)
|
|
@@ -135,7 +135,7 @@ O.post("/resources", h, async (e, t) => {
|
|
|
135
135
|
const m = _(i, "projectId"), y = _(a, "projectId"), w = /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(y)]), P = Z(n, s);
|
|
136
136
|
d.rmSync(P, { recursive: !0, force: !0 }), d.mkdirSync(P, { recursive: !0 });
|
|
137
137
|
for (const c of w) {
|
|
138
|
-
const l = await N.
|
|
138
|
+
const l = await N.getStateByProjectId(c, r), f = m[c], u = y[c], p = f == null ? void 0 : f.map((j) => j.pageId), R = u == null ? void 0 : u.map((j) => j.componentId);
|
|
139
139
|
if (p != null && p.length || R != null && R.length) {
|
|
140
140
|
const j = await W(l, {
|
|
141
141
|
exportAssets: !0,
|
|
@@ -151,8 +151,8 @@ O.post("/resources", h, async (e, t) => {
|
|
|
151
151
|
}
|
|
152
152
|
t.json({});
|
|
153
153
|
});
|
|
154
|
-
O.get("/all-resources", h, async (
|
|
155
|
-
const { states:
|
|
154
|
+
O.get("/all-resources", h, async (o, t) => {
|
|
155
|
+
const { states: e } = await G(), n = e == null ? void 0 : e.map((s) => {
|
|
156
156
|
const r = {
|
|
157
157
|
blockletId: s.blockletId,
|
|
158
158
|
blockletTitle: s.blockletTitle,
|
package/lib/es/site-state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as j, o as q, p as v, S as B, r as L, s as U, u as h, b as y, w as z, v as C, n as F, t as G, x as J } from "./chunks/site-state-
|
|
1
|
+
import { q as j, o as q, p as v, S as B, r as L, s as U, u as h, b as y, w as z, v as C, n as F, t as G, x as J } from "./chunks/site-state-DJ3JcBMm.js";
|
|
2
2
|
import "@blocklet/pages-kit/utils/property";
|
|
3
3
|
import "@blocklet/pages-kit/utils/route";
|
|
4
4
|
import "@blocklet/sdk/lib/component";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.30",
|
|
4
4
|
"description": "Pages Kit inner components library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"@blocklet/ai-kit": "^0.1.78",
|
|
78
78
|
"@blocklet/ai-runtime": "^0.4.271",
|
|
79
79
|
"@blocklet/code-editor": "^0.4.271",
|
|
80
|
-
"@blocklet/crawler": "^2.3.54",
|
|
81
80
|
"@blocklet/embed": "^0.2.4",
|
|
82
81
|
"@blocklet/js-sdk": "^1.16.43",
|
|
83
82
|
"@blocklet/logger": "1.16.36",
|
|
@@ -205,8 +204,8 @@
|
|
|
205
204
|
"yaml": "^2.5.0",
|
|
206
205
|
"yjs": "^13.6.18",
|
|
207
206
|
"zustand": "^4.5.5",
|
|
208
|
-
"@blocklet/pages-kit": "^0.5.
|
|
209
|
-
"@blocklet/pages-kit-block-studio": "^0.5.
|
|
207
|
+
"@blocklet/pages-kit": "^0.5.30",
|
|
208
|
+
"@blocklet/pages-kit-block-studio": "^0.5.30"
|
|
210
209
|
},
|
|
211
210
|
"devDependencies": {
|
|
212
211
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|