@blocklet/pages-kit-inner-components 0.5.41 → 0.5.42
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/{array-Cr5KF-hM.js → array-Cip5uTnI.js} +1 -1
- package/lib/cjs/chunks/{config-string-BYZ5HfyY.js → config-string-CEipCOnU.js} +1 -1
- package/lib/cjs/chunks/{draft-data-6zW9mu28.js → draft-data-F0V4PcIs.js} +1 -1
- package/lib/cjs/chunks/{home-DryEAaN4.js → home-BCFoaIEZ.js} +3 -3
- package/lib/cjs/chunks/{publish-button-oe4N0mbK.js → publish-button-Bbd4z1_d.js} +1 -1
- package/lib/cjs/chunks/site-state-CeQEnrvX.js +57 -0
- package/lib/cjs/chunks/state-UwRWAZRe.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/project-html.js +3 -3
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +2 -2
- package/lib/cjs/site-state.js +1 -1
- package/lib/cjs/theme.js +1 -1
- package/lib/es/add-component.js +3 -3
- package/lib/es/chunks/{array-D34Qpnhk.js → array-DM0x2Sjw.js} +1 -1
- package/lib/es/chunks/{config-string-DgK7ETCs.js → config-string-Dw6sJMn_.js} +1 -1
- package/lib/es/chunks/{draft-data-B5kzDvTI.js → draft-data-sTSk4UTm.js} +1 -1
- package/lib/es/chunks/{home-DZ0sRPEQ.js → home-ClxOpmCx.js} +4 -4
- package/lib/es/chunks/{publish-button-Ctl_bvtq.js → publish-button-CKXdANG9.js} +3 -3
- package/lib/es/chunks/{site-state-YSH6XJUc.js → site-state-BeEHvakk.js} +408 -397
- package/lib/es/chunks/{state-BzwEX9VC.js → state-COB6reM7.js} +98 -103
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/project-html.js +70 -70
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +1152 -888
- package/lib/es/site-state.js +1 -1
- package/lib/es/theme.js +14 -11
- package/package.json +7 -7
- package/lib/cjs/chunks/site-state-B8sLWiY2.js +0 -57
- package/lib/cjs/chunks/state-BWuBNdK8.js +0 -1
package/lib/es/project-html.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import l, { getBlockletJs as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { l as T, g as
|
|
9
|
-
import { createSnapshotMiddleware as
|
|
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
|
|
1
|
+
import H from "@arcblock/did-auth-storage-nedb";
|
|
2
|
+
import l, { getBlockletJs as O } from "@blocklet/sdk/lib/config";
|
|
3
|
+
import R from "@blocklet/sdk/lib/service/auth";
|
|
4
|
+
import J from "@blocklet/sdk/lib/wallet";
|
|
5
|
+
import z from "@blocklet/sdk/lib/wallet-authenticator";
|
|
6
|
+
import G from "@blocklet/sdk/lib/wallet-handler";
|
|
7
|
+
import Y, { resolve as M } from "path";
|
|
8
|
+
import { l as T, g as Q } from "./chunks/site-state-BeEHvakk.js";
|
|
9
|
+
import { createSnapshotMiddleware as V } from "@arcblock/crawler-middleware";
|
|
10
|
+
import { PreloadComponentScriptModule as X } from "@blocklet/pages-kit/types";
|
|
11
|
+
import { isMuiColorKey as Z } from "@blocklet/pages-kit/utils/common";
|
|
12
|
+
import { injectPreloadComponents as q, safeJSONStringify as F } from "@blocklet/pages-kit/utils/preload";
|
|
13
|
+
import { getComponentMountPoint as ee } from "@blocklet/sdk/lib/component";
|
|
14
|
+
import * as L from "cheerio/slim";
|
|
15
|
+
import { Router as te } from "express";
|
|
16
|
+
import { readFileSync as W } from "fs";
|
|
17
|
+
import oe from "lodash/get";
|
|
18
|
+
import ne from "mustache";
|
|
19
|
+
import { withQuery as re, joinURL as D } from "ufo";
|
|
20
|
+
const ie = (o = {}) => {
|
|
21
21
|
const t = {
|
|
22
22
|
data: /* @__PURE__ */ new Map(),
|
|
23
23
|
timers: /* @__PURE__ */ new Map(),
|
|
@@ -38,31 +38,31 @@ const re = (o = {}) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
return t;
|
|
41
|
-
}, j =
|
|
41
|
+
}, j = ie({
|
|
42
42
|
max: 1,
|
|
43
43
|
ttl: 1e3 * 30
|
|
44
44
|
// 30 seconds
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
const ce = new
|
|
48
|
-
new
|
|
46
|
+
J();
|
|
47
|
+
const ce = new z();
|
|
48
|
+
new G({
|
|
49
49
|
authenticator: ce,
|
|
50
|
-
tokenStorage: new
|
|
51
|
-
dbPath:
|
|
50
|
+
tokenStorage: new H({
|
|
51
|
+
dbPath: Y.join(l.env.dataDir, "auth.db")
|
|
52
52
|
})
|
|
53
53
|
});
|
|
54
|
-
const
|
|
54
|
+
const se = new R(), le = 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 se.getBlocklet();
|
|
60
60
|
return j.set("blockletInfo", t), t;
|
|
61
61
|
} catch {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
},
|
|
65
|
-
function
|
|
64
|
+
}, ae = ["/assets/"];
|
|
65
|
+
function $e({
|
|
66
66
|
app: o,
|
|
67
67
|
viteDevServer: t,
|
|
68
68
|
// projectId,
|
|
@@ -70,14 +70,14 @@ function Ae({
|
|
|
70
70
|
}) {
|
|
71
71
|
let d;
|
|
72
72
|
if (t) {
|
|
73
|
-
const n =
|
|
73
|
+
const n = W(M(process.cwd(), "./index.html"), "utf-8");
|
|
74
74
|
o.use(async (k, _, y) => {
|
|
75
75
|
const C = k.originalUrl;
|
|
76
76
|
d = await t.transformIndexHtml(C, n), y();
|
|
77
77
|
});
|
|
78
78
|
} else
|
|
79
|
-
d =
|
|
80
|
-
const h =
|
|
79
|
+
d = W(M(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
|
|
80
|
+
const h = te();
|
|
81
81
|
h.use((n, k, _) => {
|
|
82
82
|
if (n.headers["x-unique-record"] === "dial_http") {
|
|
83
83
|
T.info("[html] dial http request, return 200 status code"), k.status(200).send("ok");
|
|
@@ -85,88 +85,88 @@ function Ae({
|
|
|
85
85
|
}
|
|
86
86
|
_();
|
|
87
87
|
}), l.env.preferences.snapkitEnabled && l.env.preferences.snapkitEndpoint && l.env.SNAP_KIT_ACCESS_KEY && h.use(
|
|
88
|
-
|
|
88
|
+
V({
|
|
89
89
|
endpoint: l.env.preferences.snapkitEndpoint,
|
|
90
90
|
accessKey: l.env.SNAP_KIT_ACCESS_KEY,
|
|
91
91
|
cacheMax: l.env.preferences.snapkitCacheSize || 100
|
|
92
92
|
})
|
|
93
93
|
), h.get("/:path(*)?", async (n, k, _) => {
|
|
94
|
-
var E, P, A
|
|
95
|
-
if (
|
|
94
|
+
var E, P, A, $;
|
|
95
|
+
if (ae.some((s) => {
|
|
96
96
|
var m;
|
|
97
97
|
return (m = n.path) == null ? void 0 : m.startsWith(s);
|
|
98
98
|
})) {
|
|
99
99
|
_();
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
const y = performance.now(), C = () => Math.round(performance.now() - y),
|
|
103
|
-
let
|
|
102
|
+
const y = performance.now(), C = () => Math.round(performance.now() - y), K = "production";
|
|
103
|
+
let i, u, S = d;
|
|
104
104
|
if (n.path.startsWith("/pages")) {
|
|
105
105
|
const s = n.params.lang, m = n.cookies.nf_lang, b = /* @__PURE__ */ new Set([...l.env.languages.map((w) => w.code)]);
|
|
106
106
|
let g = (s && b.has(s) ? s : void 0) || (b.has(m) ? m : void 0) || [...b][0];
|
|
107
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
108
|
const w = [];
|
|
109
|
-
Object.values(e.pages).forEach((
|
|
110
|
-
const
|
|
109
|
+
Object.values(e.pages).forEach((c) => {
|
|
110
|
+
const N = Object.values((c == null ? void 0 : c.sections) ?? {}).filter(
|
|
111
111
|
(p) => {
|
|
112
112
|
var v;
|
|
113
113
|
return p.component === "custom-component" && ((v = p.config) == null ? void 0 : v.componentId);
|
|
114
114
|
}
|
|
115
115
|
).map((p) => {
|
|
116
|
-
var v,
|
|
116
|
+
var v, x;
|
|
117
117
|
return {
|
|
118
118
|
id: p.id,
|
|
119
119
|
componentId: p.config.componentId,
|
|
120
120
|
useCache: p.config.useCache,
|
|
121
121
|
cacheDuration: p.config.cacheDuration,
|
|
122
|
-
properties: (
|
|
122
|
+
properties: (x = (v = c == null ? void 0 : c.dataSource) == null ? void 0 : v[p.id]) == null ? void 0 : x[g]
|
|
123
123
|
// ?? i.locales?.[respectLocale!]?.properties,
|
|
124
124
|
};
|
|
125
125
|
});
|
|
126
|
-
w.push(...
|
|
126
|
+
w.push(...N);
|
|
127
127
|
});
|
|
128
|
-
const
|
|
128
|
+
const B = new Promise((c) => {
|
|
129
129
|
setTimeout(() => {
|
|
130
|
-
|
|
130
|
+
c({});
|
|
131
131
|
}, 90 * 1e3);
|
|
132
132
|
});
|
|
133
133
|
try {
|
|
134
134
|
await Promise.race([
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
mode:
|
|
135
|
+
B,
|
|
136
|
+
Q({
|
|
137
|
+
mode: K,
|
|
138
138
|
req: n,
|
|
139
139
|
state: e,
|
|
140
140
|
locale: g,
|
|
141
141
|
instances: w,
|
|
142
|
-
module:
|
|
143
|
-
}).then((
|
|
144
|
-
|
|
142
|
+
module: X.UMD_FN
|
|
143
|
+
}).then((c) => {
|
|
144
|
+
c && (u = q(c));
|
|
145
145
|
})
|
|
146
146
|
]);
|
|
147
|
-
} catch (
|
|
148
|
-
T.warn("getPreloadComponents timeout in promise race, skip inject html elements",
|
|
147
|
+
} catch (c) {
|
|
148
|
+
T.warn("getPreloadComponents timeout in promise race, skip inject html elements", c);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
try {
|
|
153
|
-
const s = (
|
|
153
|
+
const s = (i == null ? void 0 : i.title) || l.env.appName, m = (i == null ? void 0 : i.description) || l.env.appDescription, b = re(D(l.env.appUrl, "/.well-known/service/blocklet/og.png"), {
|
|
154
154
|
title: s,
|
|
155
155
|
description: m
|
|
156
156
|
});
|
|
157
|
-
S =
|
|
157
|
+
S = ne.render(d, {
|
|
158
158
|
ogTitle: s,
|
|
159
159
|
ogDescription: m,
|
|
160
|
-
ogImage:
|
|
160
|
+
ogImage: me(i == null ? void 0 : i.image) || b,
|
|
161
161
|
pagesPublishedAt: (e == null ? void 0 : e.config.publishedAt) || (/* @__PURE__ */ new Date()).getTime()
|
|
162
162
|
});
|
|
163
163
|
} catch {
|
|
164
164
|
}
|
|
165
|
-
const r = e == null ? void 0 : e.config.fontFamily,
|
|
166
|
-
let a =
|
|
167
|
-
if (a &&
|
|
168
|
-
const s = await
|
|
169
|
-
a =
|
|
165
|
+
const r = e == null ? void 0 : e.config.fontFamily, U = n.query.mode === "draft" || n.url.includes("preview") || (($ = n.path) == null ? void 0 : $.startsWith("/admin")), f = L.load(S);
|
|
166
|
+
let a = i == null ? void 0 : i.backgroundColor;
|
|
167
|
+
if (a && Z(a)) {
|
|
168
|
+
const s = await le();
|
|
169
|
+
a = oe(
|
|
170
170
|
s,
|
|
171
171
|
// 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
|
|
172
172
|
`settings.theme.light.palette.${a}`,
|
|
@@ -179,7 +179,7 @@ function Ae({
|
|
|
179
179
|
${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">` : ""}
|
|
180
180
|
<script>
|
|
181
181
|
|
|
182
|
-
window.__PAGE_STATE__ = ${
|
|
182
|
+
window.__PAGE_STATE__ = ${F(e || null)};
|
|
183
183
|
|
|
184
184
|
document.querySelectorAll('link[rel="preload"][as="style"]').forEach(function (link) {
|
|
185
185
|
const l = document.createElement('link');
|
|
@@ -189,25 +189,25 @@ function Ae({
|
|
|
189
189
|
});
|
|
190
190
|
<\/script>
|
|
191
191
|
|
|
192
|
-
${
|
|
192
|
+
${U ? `<script src="https://cdn.tailwindcss.com"><\/script>
|
|
193
193
|
<script>
|
|
194
194
|
window.tailwind.config = {
|
|
195
195
|
darkMode: "class",
|
|
196
196
|
};
|
|
197
197
|
<\/script>` : ""}
|
|
198
198
|
`);
|
|
199
|
-
const I =
|
|
199
|
+
const I = O();
|
|
200
200
|
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) {
|
|
201
|
-
const s =
|
|
201
|
+
const s = L.load(n.cachedHtml);
|
|
202
202
|
f("body").html(s("body").html() || "");
|
|
203
203
|
}
|
|
204
|
-
S = f.html(), k.send(S), T.info(`[html] render: ${n.path}, ${C()}ms`), f.root().children().remove(), S = null,
|
|
204
|
+
S = f.html(), k.send(S), T.info(`[html] render: ${n.path}, ${C()}ms`), f.root().children().remove(), S = null, i = null, u = null;
|
|
205
205
|
}), o.use(h);
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
const t =
|
|
209
|
-
return t && o && !/^(https?:\/\/|\/)/.test(o) ? l.env.appUrl +
|
|
207
|
+
function me(o) {
|
|
208
|
+
const t = ee("image-bin");
|
|
209
|
+
return t && o && !/^(https?:\/\/|\/)/.test(o) ? l.env.appUrl + D(t, "uploads", o) : o;
|
|
210
210
|
}
|
|
211
211
|
export {
|
|
212
|
-
|
|
212
|
+
$e as default
|
|
213
213
|
};
|
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-BeEHvakk.js";
|
|
2
2
|
import { AsyncLocalStorage as K } from "async_hooks";
|
|
3
3
|
import { Router as Y } from "express";
|
|
4
4
|
import d from "fs";
|