@blocklet/pages-kit-inner-components 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/components-CacZMc0_.js +57 -0
- package/lib/cjs/chunks/{draft-data-D44_IEV2.js → draft-data-CVjF01PQ.js} +1 -1
- package/lib/cjs/chunks/{home-BYk01EUy.js → home-BarvCpAK.js} +2 -2
- package/lib/cjs/chunks/index-DH8UBqWG.js +475 -0
- package/lib/cjs/chunks/{publish-button-C8XPA4g_.js → publish-button-CNo2gT6Q.js} +1 -1
- package/lib/cjs/chunks/site-state-BkjuFb4-.js +1 -0
- package/lib/cjs/chunks/state-DCxHc_MB.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/project-html.js +6 -9
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +2 -2
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +2 -2
- package/lib/es/chunks/components-BWQM8y6L.js +608 -0
- package/lib/es/chunks/{draft-data-CafrGKeh.js → draft-data-BiayOfQz.js} +1 -1
- package/lib/es/chunks/{home-DW8SdyfO.js → home-DBc-g4K0.js} +3 -3
- package/lib/es/chunks/{index-D5gXPe_7.js → index-DaF8ujCZ.js} +675 -763
- package/lib/es/chunks/{publish-button-XSZrDaTQ.js → publish-button-DiKDLFU8.js} +3 -3
- package/lib/es/chunks/site-state-BMW2lUR1.js +1586 -0
- package/lib/es/chunks/{state-0gvZF3k2.js → state-C3hsEhCe.js} +117 -121
- package/lib/es/components.js +11 -10
- package/lib/es/home.js +3 -3
- package/lib/es/project-html.js +132 -121
- package/lib/es/resources.js +28 -29
- package/lib/es/setting.js +148 -145
- package/lib/es/site-state.js +16 -15
- package/package.json +3 -3
- package/lib/cjs/chunks/index-BRgYwvuv.js +0 -475
- package/lib/cjs/chunks/site-state-BlQzwACl.js +0 -57
- package/lib/cjs/chunks/state-B6BF5wJ-.js +0 -1
- package/lib/es/chunks/site-state-BdLTu3Od.js +0 -2123
package/lib/es/project-html.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import M from "@arcblock/did-auth-storage-nedb";
|
|
2
|
+
import c, { getBlockletJs as B } from "@blocklet/sdk/lib/config";
|
|
3
3
|
import H from "@blocklet/sdk/lib/service/auth";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { l as
|
|
9
|
-
import { createHash as
|
|
10
|
-
import { createSnapshotMiddleware as
|
|
11
|
-
import { PreloadComponentScriptModule as
|
|
12
|
-
import { isMuiColorKey as
|
|
13
|
-
import { injectPreloadComponents as
|
|
14
|
-
import { getComponentMountPoint as
|
|
15
|
-
import { Router as
|
|
16
|
-
import { readFileSync as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { withQuery as
|
|
20
|
-
const
|
|
4
|
+
import K from "@blocklet/sdk/lib/wallet";
|
|
5
|
+
import L from "@blocklet/sdk/lib/wallet-authenticator";
|
|
6
|
+
import W from "@blocklet/sdk/lib/wallet-handler";
|
|
7
|
+
import D, { resolve as I } from "path";
|
|
8
|
+
import { l as S, g as N } from "./chunks/components-BWQM8y6L.js";
|
|
9
|
+
import { createHash as U } from "crypto";
|
|
10
|
+
import { createSnapshotMiddleware as O } from "@arcblock/crawler-middleware";
|
|
11
|
+
import { PreloadComponentScriptModule as R } from "@blocklet/pages-kit/types";
|
|
12
|
+
import { isMuiColorKey as F } from "@blocklet/pages-kit/utils/common";
|
|
13
|
+
import { injectPreloadComponents as J, safeJSONStringify as z } from "@blocklet/pages-kit/utils/preload";
|
|
14
|
+
import { getComponentMountPoint as G } from "@blocklet/sdk/lib/component";
|
|
15
|
+
import { Router as Y } from "express";
|
|
16
|
+
import { readFileSync as T } from "fs";
|
|
17
|
+
import Q from "lodash/get";
|
|
18
|
+
import V from "mustache";
|
|
19
|
+
import { withQuery as X, joinURL as j } from "ufo";
|
|
20
|
+
const Z = (o = {}) => {
|
|
21
21
|
const e = {
|
|
22
22
|
data: /* @__PURE__ */ new Map(),
|
|
23
23
|
timers: /* @__PURE__ */ new Map(),
|
|
24
|
-
set: (t,
|
|
24
|
+
set: (t, n, s = o.ttl || 36e5) => {
|
|
25
25
|
o.max && e.data.size >= o.max && e.delete(e.data.keys().next().value), e.timers.has(t) && clearTimeout(e.timers.get(t)), e.timers.set(
|
|
26
26
|
t,
|
|
27
|
-
setTimeout(() => e.delete(t),
|
|
28
|
-
), e.data.set(t,
|
|
27
|
+
setTimeout(() => e.delete(t), s)
|
|
28
|
+
), e.data.set(t, n);
|
|
29
29
|
},
|
|
30
30
|
get: (t) => e.data.get(t),
|
|
31
31
|
has: (t) => e.data.has(t),
|
|
@@ -38,158 +38,172 @@ const ee = (o = {}) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
return e;
|
|
41
|
-
}, E =
|
|
41
|
+
}, E = Z({
|
|
42
42
|
max: 1,
|
|
43
43
|
ttl: 1e3 * 30
|
|
44
44
|
// 30 seconds
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
new
|
|
49
|
-
authenticator:
|
|
50
|
-
tokenStorage: new
|
|
51
|
-
dbPath:
|
|
46
|
+
K();
|
|
47
|
+
const q = new L();
|
|
48
|
+
new W({
|
|
49
|
+
authenticator: q,
|
|
50
|
+
tokenStorage: new M({
|
|
51
|
+
dbPath: D.join(c.env.dataDir, "auth.db")
|
|
52
52
|
})
|
|
53
53
|
});
|
|
54
|
-
const
|
|
54
|
+
const ee = new H(), te = async () => {
|
|
55
55
|
try {
|
|
56
56
|
const o = E.get("blockletInfo");
|
|
57
57
|
if (o)
|
|
58
58
|
return o;
|
|
59
|
-
const { blocklet: e } = await
|
|
59
|
+
const { blocklet: e } = await ee.getBlocklet();
|
|
60
60
|
return E.set("blockletInfo", e), e;
|
|
61
61
|
} catch {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
},
|
|
65
|
-
function
|
|
64
|
+
}, oe = async () => await import("cheerio"), _ = {};
|
|
65
|
+
function ne(o, e) {
|
|
66
66
|
const t = JSON.stringify([o, e]);
|
|
67
|
-
return
|
|
67
|
+
return U("md5").update(t).digest("hex");
|
|
68
68
|
}
|
|
69
|
-
async function
|
|
69
|
+
async function re(o, e) {
|
|
70
70
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
let t = await oe();
|
|
72
|
+
try {
|
|
73
|
+
const n = t.load(o);
|
|
74
|
+
return e.forEach((s) => {
|
|
75
|
+
n(s.selector.cheerio).replaceWith(s.value);
|
|
76
|
+
}), n.html();
|
|
77
|
+
} catch {
|
|
78
|
+
} finally {
|
|
79
|
+
t = null;
|
|
80
|
+
}
|
|
75
81
|
}
|
|
82
|
+
return ce(o, e);
|
|
76
83
|
}
|
|
77
|
-
|
|
84
|
+
function ce(o, e) {
|
|
85
|
+
let t = o;
|
|
86
|
+
return e.forEach((n) => {
|
|
87
|
+
const s = typeof n.selector.pattern == "string" ? new RegExp(n.selector.pattern, "gis") : n.selector.pattern;
|
|
88
|
+
t = t.replace(s, n.value);
|
|
89
|
+
}), t;
|
|
90
|
+
}
|
|
91
|
+
async function se(o, e) {
|
|
78
92
|
if (!e || e.length === 0)
|
|
79
93
|
return o;
|
|
80
|
-
const t =
|
|
81
|
-
return
|
|
94
|
+
const t = ne(o, e);
|
|
95
|
+
return _[t] ??= re(o, e).finally(() => {
|
|
82
96
|
setTimeout(() => {
|
|
83
|
-
delete
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
97
|
+
delete _[t];
|
|
98
|
+
}, 10 * 1e3);
|
|
99
|
+
}), _[t];
|
|
86
100
|
}
|
|
87
101
|
function ae(o) {
|
|
88
102
|
return o.match(/<body[^>]*>(.*?)<\/body>/s)?.[1] || "";
|
|
89
103
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
104
|
+
const ie = ["/assets/"];
|
|
105
|
+
function Ae({
|
|
92
106
|
app: o,
|
|
93
107
|
viteDevServer: e,
|
|
94
108
|
// projectId,
|
|
95
109
|
state: t
|
|
96
110
|
}) {
|
|
97
|
-
let
|
|
111
|
+
let n;
|
|
98
112
|
if (e) {
|
|
99
|
-
const
|
|
100
|
-
o.use(async (
|
|
101
|
-
const
|
|
102
|
-
|
|
113
|
+
const r = T(I(process.cwd(), "./index.html"), "utf-8");
|
|
114
|
+
o.use(async (f, b, v) => {
|
|
115
|
+
const m = f.originalUrl;
|
|
116
|
+
n = await e.transformIndexHtml(m, r), v();
|
|
103
117
|
});
|
|
104
118
|
} else
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
119
|
+
n = T(I(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
|
|
120
|
+
const s = Y();
|
|
121
|
+
s.use((r, f, b) => {
|
|
122
|
+
if (r.headers["x-unique-record"] === "dial_http") {
|
|
123
|
+
S.info("[html] dial http request, return 200 status code"), f.status(200).send("ok");
|
|
110
124
|
return;
|
|
111
125
|
}
|
|
112
126
|
b();
|
|
113
|
-
}),
|
|
114
|
-
|
|
115
|
-
endpoint:
|
|
116
|
-
accessKey:
|
|
117
|
-
cacheMax:
|
|
127
|
+
}), c.env.preferences.snapkitEnabled && c.env.preferences.snapkitEndpoint && c.env.SNAP_KIT_ACCESS_KEY && s.use(
|
|
128
|
+
O({
|
|
129
|
+
endpoint: c.env.preferences.snapkitEndpoint,
|
|
130
|
+
accessKey: c.env.SNAP_KIT_ACCESS_KEY,
|
|
131
|
+
cacheMax: c.env.preferences.snapkitCacheSize || 100
|
|
118
132
|
})
|
|
119
|
-
),
|
|
120
|
-
if (
|
|
133
|
+
), s.get("/:path(*)?", async (r, f, b) => {
|
|
134
|
+
if (ie.some((a) => r.path?.startsWith(a))) {
|
|
121
135
|
b();
|
|
122
136
|
return;
|
|
123
137
|
}
|
|
124
|
-
const v =
|
|
125
|
-
let
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
let
|
|
129
|
-
if ((!
|
|
138
|
+
const v = "production";
|
|
139
|
+
let m, k, g = n;
|
|
140
|
+
if (r.path.startsWith("/pages")) {
|
|
141
|
+
const a = r.params.lang, y = r.cookies.nf_lang, w = /* @__PURE__ */ new Set([...c.env.languages.map((h) => h.code)]);
|
|
142
|
+
let u = (a && w.has(a) ? a : void 0) || (w.has(y) ? y : void 0) || [...w][0];
|
|
143
|
+
if ((!u || !t.supportedLocales?.find((h) => h.locale === u)) && (u = t.supportedLocales?.[0]?.locale || ""), u) {
|
|
130
144
|
const h = [];
|
|
131
|
-
Object.values(t.pages).forEach((
|
|
132
|
-
const
|
|
133
|
-
(
|
|
134
|
-
).map((
|
|
135
|
-
id:
|
|
136
|
-
componentId:
|
|
137
|
-
useCache:
|
|
138
|
-
cacheDuration:
|
|
139
|
-
properties:
|
|
145
|
+
Object.values(t.pages).forEach((i) => {
|
|
146
|
+
const x = Object.values(i?.sections ?? {}).filter(
|
|
147
|
+
(p) => p.component === "custom-component" && p.config?.componentId
|
|
148
|
+
).map((p) => ({
|
|
149
|
+
id: p.id,
|
|
150
|
+
componentId: p.config.componentId,
|
|
151
|
+
useCache: p.config.useCache,
|
|
152
|
+
cacheDuration: p.config.cacheDuration,
|
|
153
|
+
properties: i?.dataSource?.[p.id]?.[u]
|
|
140
154
|
// ?? i.locales?.[respectLocale!]?.properties,
|
|
141
155
|
}));
|
|
142
|
-
h.push(...
|
|
156
|
+
h.push(...x);
|
|
143
157
|
});
|
|
144
|
-
const
|
|
158
|
+
const $ = new Promise((i) => {
|
|
145
159
|
setTimeout(() => {
|
|
146
|
-
|
|
160
|
+
i({});
|
|
147
161
|
}, 30 * 1e3);
|
|
148
162
|
});
|
|
149
163
|
try {
|
|
150
164
|
await Promise.race([
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
mode:
|
|
154
|
-
req:
|
|
165
|
+
$,
|
|
166
|
+
N({
|
|
167
|
+
mode: v,
|
|
168
|
+
req: r,
|
|
155
169
|
state: t,
|
|
156
|
-
locale:
|
|
170
|
+
locale: u,
|
|
157
171
|
instances: h,
|
|
158
|
-
module:
|
|
159
|
-
}).then((
|
|
160
|
-
|
|
172
|
+
module: R.UMD_FN
|
|
173
|
+
}).then((i) => {
|
|
174
|
+
i && (k = J(i));
|
|
161
175
|
})
|
|
162
176
|
]);
|
|
163
|
-
} catch (
|
|
164
|
-
|
|
177
|
+
} catch (i) {
|
|
178
|
+
S.warn("getPreloadComponents timeout in promise race, skip inject html elements", i);
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
181
|
}
|
|
168
182
|
try {
|
|
169
|
-
const
|
|
170
|
-
title:
|
|
183
|
+
const a = m?.title || c.env.appName, y = m?.description || c.env.appDescription, w = X(j(c.env.appUrl, "/.well-known/service/blocklet/og.png"), {
|
|
184
|
+
title: a,
|
|
171
185
|
description: y
|
|
172
186
|
});
|
|
173
|
-
g =
|
|
174
|
-
ogTitle:
|
|
187
|
+
g = V.render(n, {
|
|
188
|
+
ogTitle: a,
|
|
175
189
|
ogDescription: y,
|
|
176
|
-
ogImage:
|
|
190
|
+
ogImage: le(m?.image) || w,
|
|
177
191
|
pagesPublishedAt: t?.config.publishedAt || (/* @__PURE__ */ new Date()).getTime()
|
|
178
192
|
});
|
|
179
193
|
} catch {
|
|
180
194
|
}
|
|
181
|
-
const
|
|
182
|
-
let l =
|
|
183
|
-
if (l &&
|
|
184
|
-
const
|
|
185
|
-
l =
|
|
186
|
-
|
|
195
|
+
const d = t?.config.fontFamily, P = r.query.mode === "draft" || r.url.includes("preview") || r.path?.startsWith("/admin");
|
|
196
|
+
let l = m?.backgroundColor;
|
|
197
|
+
if (l && F(l)) {
|
|
198
|
+
const a = await te();
|
|
199
|
+
l = Q(
|
|
200
|
+
a,
|
|
187
201
|
// 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
|
|
188
202
|
`settings.theme.light.palette.${l}`,
|
|
189
203
|
l
|
|
190
204
|
);
|
|
191
205
|
}
|
|
192
|
-
const
|
|
206
|
+
const C = B(), A = [
|
|
193
207
|
{
|
|
194
208
|
selector: {
|
|
195
209
|
cheerio: "#injected-head-elements",
|
|
@@ -197,14 +211,12 @@ function $e({
|
|
|
197
211
|
},
|
|
198
212
|
value: `
|
|
199
213
|
${l ? `<meta name="theme-color" content="${l}" /><style>html,body,#app {background-color: ${l};}</style>` : ""}
|
|
200
|
-
${
|
|
201
|
-
${
|
|
214
|
+
${d?.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${d.title}&display=swap">` : ""}
|
|
215
|
+
${d?.description && d?.description !== d?.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${d.description}&display=swap">` : ""}
|
|
202
216
|
|
|
203
217
|
|
|
204
218
|
<script>
|
|
205
|
-
|
|
206
|
-
window.__PAGE_STATE__ = ${Y(t || null)};
|
|
207
|
-
|
|
219
|
+
window.__PAGE_STATE__ = ${z(t || null)};
|
|
208
220
|
<\/script>
|
|
209
221
|
|
|
210
222
|
|
|
@@ -215,10 +227,9 @@ function $e({
|
|
|
215
227
|
l.href = link.href;
|
|
216
228
|
document.head.appendChild(l);
|
|
217
229
|
});
|
|
218
|
-
|
|
219
230
|
<\/script>
|
|
220
231
|
|
|
221
|
-
${
|
|
232
|
+
${P ? `<script src="https://cdn.tailwindcss.com"><\/script>
|
|
222
233
|
<script>
|
|
223
234
|
window.tailwind.config = {
|
|
224
235
|
darkMode: "class",
|
|
@@ -227,12 +238,12 @@ function $e({
|
|
|
227
238
|
`
|
|
228
239
|
},
|
|
229
240
|
// blocklet.js script
|
|
230
|
-
|
|
241
|
+
C && {
|
|
231
242
|
selector: {
|
|
232
243
|
cheerio: 'script[src="__blocklet__.js"]',
|
|
233
244
|
pattern: /<script[^>]*src=["']__blocklet__\.js["'][^>]*><\/script>/gis
|
|
234
245
|
},
|
|
235
|
-
value: `<script>${
|
|
246
|
+
value: `<script>${C}<\/script>`
|
|
236
247
|
},
|
|
237
248
|
// injected-html-elements
|
|
238
249
|
k?.html && {
|
|
@@ -243,21 +254,21 @@ function $e({
|
|
|
243
254
|
value: k.html
|
|
244
255
|
},
|
|
245
256
|
// cachedHtml body content
|
|
246
|
-
|
|
257
|
+
r.cachedHtml && {
|
|
247
258
|
selector: {
|
|
248
259
|
cheerio: "body",
|
|
249
260
|
pattern: /(<body[^>]*>).*?(<\/body>)/gis
|
|
250
261
|
},
|
|
251
|
-
value: `<body>${ae(
|
|
262
|
+
value: `<body>${ae(r.cachedHtml)}</body>`
|
|
252
263
|
}
|
|
253
264
|
].filter(Boolean);
|
|
254
|
-
g = await
|
|
255
|
-
}), o.use(
|
|
265
|
+
g = await se(g, A), f.send(g), S.info(`[html] render: ${r.path}`), g = null, m = null, k = null;
|
|
266
|
+
}), o.use(s);
|
|
256
267
|
}
|
|
257
|
-
function
|
|
258
|
-
const e =
|
|
259
|
-
return e && o && !/^(https?:\/\/|\/)/.test(o) ?
|
|
268
|
+
function le(o) {
|
|
269
|
+
const e = G("image-bin");
|
|
270
|
+
return e && o && !/^(https?:\/\/|\/)/.test(o) ? c.env.appUrl + j(e, "uploads", o) : o;
|
|
260
271
|
}
|
|
261
272
|
export {
|
|
262
|
-
|
|
273
|
+
Ae as default
|
|
263
274
|
};
|
package/lib/es/resources.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Router as
|
|
1
|
+
import { i as A, a as M, l as b } from "./chunks/components-BWQM8y6L.js";
|
|
2
|
+
import { P as w, C as J, R as X, S as x, t as W, g as G } from "./chunks/site-state-BMW2lUR1.js";
|
|
3
|
+
import { Router as K } from "express";
|
|
4
4
|
import a from "fs";
|
|
5
5
|
import m from "joi";
|
|
6
6
|
import C from "lodash/groupBy";
|
|
7
|
-
import
|
|
8
|
-
import O, { join as
|
|
7
|
+
import Y from "lodash/sortBy";
|
|
8
|
+
import O, { join as $ } from "path";
|
|
9
9
|
import _ from "@blocklet/sdk/lib/middlewares/auth";
|
|
10
|
-
import { getResourceExportDir as
|
|
11
|
-
|
|
12
|
-
const Q = async (e, t, o) => {
|
|
10
|
+
import { getResourceExportDir as z } from "@blocklet/sdk/lib/component";
|
|
11
|
+
const H = async (e, t, o) => {
|
|
13
12
|
try {
|
|
14
13
|
const { projectId: s } = e.params;
|
|
15
14
|
if (!s)
|
|
@@ -45,22 +44,22 @@ async function U(e, t) {
|
|
|
45
44
|
s.isDirectory() ? await U(n, r) : await N(n, r);
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
async function
|
|
47
|
+
async function Q(e, t) {
|
|
49
48
|
(await a.promises.stat(e)).isDirectory() ? await U(e, t) : await N(e, t);
|
|
50
49
|
}
|
|
51
|
-
const E = (e, t, o) => A() ? _()(e, t, o) : _({ roles: ["owner", "admin", "pagesEditor"] })(e, t, o),
|
|
52
|
-
const o =
|
|
53
|
-
return
|
|
54
|
-
}, S =
|
|
50
|
+
const E = (e, t, o) => A() ? _()(e, t, o) : _({ roles: ["owner", "admin", "pagesEditor"] })(e, t, o), V = (e, t) => {
|
|
51
|
+
const o = z({ projectId: e, releaseId: t });
|
|
52
|
+
return $(o, J, X);
|
|
53
|
+
}, S = K(), B = "@page", T = "@component", l = ":", P = "ALL", F = "@project", D = ({ pageId: e, projectId: t }) => [B, t, e].join(l), Z = (e) => {
|
|
55
54
|
const [t, o, s] = e.split(l);
|
|
56
55
|
if (t === B) return { pageId: s, projectId: o };
|
|
57
|
-
}, k = ({ componentId: e, projectId: t }) => [T, t, e].join(l),
|
|
56
|
+
}, k = ({ componentId: e, projectId: t }) => [T, t, e].join(l), q = (e) => {
|
|
58
57
|
const [t, o, s] = e.split(l);
|
|
59
58
|
if (t === T) return { componentId: s, projectId: o };
|
|
60
|
-
},
|
|
59
|
+
}, ee = (e) => [F, e].join(l), te = (e) => {
|
|
61
60
|
const [t, o] = e.split(l);
|
|
62
|
-
if (t ===
|
|
63
|
-
},
|
|
61
|
+
if (t === F) return o;
|
|
62
|
+
}, oe = (e) => {
|
|
64
63
|
try {
|
|
65
64
|
return JSON.parse(e);
|
|
66
65
|
} catch {
|
|
@@ -72,12 +71,12 @@ async function v(e) {
|
|
|
72
71
|
const c = t.pages[r];
|
|
73
72
|
if (c)
|
|
74
73
|
return { id: D({ pageId: r, projectId: e }), name: c.slug };
|
|
75
|
-
}).filter(Boolean), n =
|
|
74
|
+
}).filter(Boolean), n = Y(Object.values(t.components), (r) => r.index).map(({ data: r }) => ({
|
|
76
75
|
id: k({ componentId: r.id, projectId: e }),
|
|
77
76
|
name: r.name || r.id
|
|
78
77
|
}));
|
|
79
78
|
return {
|
|
80
|
-
id:
|
|
79
|
+
id: ee(e),
|
|
81
80
|
name: o?.name || "Unnamed Project",
|
|
82
81
|
children: [
|
|
83
82
|
{ id: D({ pageId: P, projectId: e }), name: "Pages", children: s },
|
|
@@ -90,9 +89,9 @@ async function v(e) {
|
|
|
90
89
|
};
|
|
91
90
|
}
|
|
92
91
|
S.get("/resources", E, async (e, t) => {
|
|
93
|
-
const { projectId: o } =
|
|
92
|
+
const { projectId: o } = oe(e.query.resourcesParams);
|
|
94
93
|
if (o) {
|
|
95
|
-
e.params = { ...e.params, projectId: o }, await
|
|
94
|
+
e.params = { ...e.params, projectId: o }, await H(e, t, () => {
|
|
96
95
|
});
|
|
97
96
|
const r = await v(o);
|
|
98
97
|
t.json({ resources: [r] });
|
|
@@ -106,34 +105,34 @@ S.get("/resources", E, async (e, t) => {
|
|
|
106
105
|
}), n = await Promise.all(s.map((r) => v(r.id)));
|
|
107
106
|
t.json({ resources: n });
|
|
108
107
|
});
|
|
109
|
-
const
|
|
108
|
+
const re = m.object({
|
|
110
109
|
projectId: m.string().required().min(1),
|
|
111
110
|
releaseId: m.string().allow(""),
|
|
112
111
|
resources: m.array().items(m.string()).required(),
|
|
113
112
|
locale: m.string().allow("")
|
|
114
113
|
});
|
|
115
114
|
S.post("/resources", E, async (e, t) => {
|
|
116
|
-
const { resources: o, projectId: s, releaseId: n } = await
|
|
115
|
+
const { resources: o, projectId: s, releaseId: n } = await re.validateAsync(e.body), r = "production", c = [], j = [];
|
|
117
116
|
for (const i of o) {
|
|
118
|
-
if (
|
|
117
|
+
if (te(i))
|
|
119
118
|
continue;
|
|
120
|
-
const { pageId: p, projectId: g } =
|
|
119
|
+
const { pageId: p, projectId: g } = Z(i) || {};
|
|
121
120
|
if (p)
|
|
122
121
|
p === P || p && g && c.push({
|
|
123
122
|
pageId: p,
|
|
124
123
|
projectId: g
|
|
125
124
|
});
|
|
126
125
|
else {
|
|
127
|
-
const { componentId: f, projectId: d } =
|
|
126
|
+
const { componentId: f, projectId: d } = q(i) || {};
|
|
128
127
|
f === P || f && d && j.push({
|
|
129
128
|
componentId: f,
|
|
130
129
|
projectId: d
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
|
-
const I = C(c, "projectId"), h = C(j, "projectId"),
|
|
133
|
+
const I = C(c, "projectId"), h = C(j, "projectId"), L = /* @__PURE__ */ new Set([...Object.keys(I), ...Object.keys(h)]), y = V(s, n);
|
|
135
134
|
a.rmSync(y, { recursive: !0, force: !0 }), a.mkdirSync(y, { recursive: !0 });
|
|
136
|
-
for (const i of
|
|
135
|
+
for (const i of L) {
|
|
137
136
|
const p = await x.getStateByProjectId(i, r), g = I[i], f = h[i], d = g?.map((u) => u.pageId), R = f?.map((u) => u.componentId);
|
|
138
137
|
if (d?.length || R?.length) {
|
|
139
138
|
const u = await W(p, {
|
|
@@ -141,7 +140,7 @@ S.post("/resources", E, async (e, t) => {
|
|
|
141
140
|
pageIds: d,
|
|
142
141
|
componentIds: R
|
|
143
142
|
});
|
|
144
|
-
await
|
|
143
|
+
await Q(u, y), a.rmSync(u, { recursive: !0, force: !0 });
|
|
145
144
|
}
|
|
146
145
|
b.info(`Exported resources for project ${i}`, {
|
|
147
146
|
pageIds: d,
|