@blocklet/pages-kit-inner-components 0.5.41 → 0.5.43

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.
Files changed (33) hide show
  1. package/lib/cjs/add-component.js +1 -1
  2. package/lib/cjs/chunks/{array-Cr5KF-hM.js → array-Cip5uTnI.js} +1 -1
  3. package/lib/cjs/chunks/{config-string-BYZ5HfyY.js → config-string-CEipCOnU.js} +1 -1
  4. package/lib/cjs/chunks/{draft-data-6zW9mu28.js → draft-data-F0V4PcIs.js} +1 -1
  5. package/lib/cjs/chunks/{home-DryEAaN4.js → home-BCFoaIEZ.js} +3 -3
  6. package/lib/cjs/chunks/{publish-button-oe4N0mbK.js → publish-button-Bbd4z1_d.js} +1 -1
  7. package/lib/cjs/chunks/site-state-CeQEnrvX.js +57 -0
  8. package/lib/cjs/chunks/state-UwRWAZRe.js +1 -0
  9. package/lib/cjs/components.js +1 -1
  10. package/lib/cjs/home.js +1 -1
  11. package/lib/cjs/project-html.js +3 -3
  12. package/lib/cjs/resources.js +1 -1
  13. package/lib/cjs/setting.js +2 -2
  14. package/lib/cjs/site-state.js +1 -1
  15. package/lib/cjs/theme.js +1 -1
  16. package/lib/es/add-component.js +3 -3
  17. package/lib/es/chunks/{array-D34Qpnhk.js → array-DM0x2Sjw.js} +1 -1
  18. package/lib/es/chunks/{config-string-DgK7ETCs.js → config-string-Dw6sJMn_.js} +1 -1
  19. package/lib/es/chunks/{draft-data-B5kzDvTI.js → draft-data-sTSk4UTm.js} +1 -1
  20. package/lib/es/chunks/{home-DZ0sRPEQ.js → home-ClxOpmCx.js} +4 -4
  21. package/lib/es/chunks/{publish-button-Ctl_bvtq.js → publish-button-CKXdANG9.js} +3 -3
  22. package/lib/es/chunks/{site-state-YSH6XJUc.js → site-state-BeEHvakk.js} +408 -397
  23. package/lib/es/chunks/{state-BzwEX9VC.js → state-COB6reM7.js} +98 -103
  24. package/lib/es/components.js +1 -1
  25. package/lib/es/home.js +3 -3
  26. package/lib/es/project-html.js +70 -70
  27. package/lib/es/resources.js +1 -1
  28. package/lib/es/setting.js +1188 -924
  29. package/lib/es/site-state.js +1 -1
  30. package/lib/es/theme.js +14 -11
  31. package/package.json +7 -7
  32. package/lib/cjs/chunks/site-state-B8sLWiY2.js +0 -57
  33. package/lib/cjs/chunks/state-BWuBNdK8.js +0 -1
@@ -1,23 +1,23 @@
1
- import N from "@arcblock/did-auth-storage-nedb";
2
- import l, { 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-YSH6XJUc.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, safeJSONStringify as q } from "@blocklet/pages-kit/utils/preload";
13
- import { getComponentMountPoint as F } from "@blocklet/sdk/lib/component";
14
- import * as M from "cheerio/slim";
15
- import { Router as ee } from "express";
16
- import { readFileSync as L } from "fs";
17
- import te from "lodash/get";
18
- import oe from "mustache";
19
- import { withQuery as ne, joinURL as W } from "ufo";
20
- const re = (o = {}) => {
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 = re({
41
+ }, j = ie({
42
42
  max: 1,
43
43
  ttl: 1e3 * 30
44
44
  // 30 seconds
45
45
  });
46
- R();
47
- const ce = new J();
48
- new z({
46
+ J();
47
+ const ce = new z();
48
+ new G({
49
49
  authenticator: ce,
50
- tokenStorage: new N({
51
- dbPath: G.join(l.env.dataDir, "auth.db")
50
+ tokenStorage: new H({
51
+ dbPath: Y.join(l.env.dataDir, "auth.db")
52
52
  })
53
53
  });
54
- const ie = new O(), se = async () => {
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 ie.getBlocklet();
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
- }, le = ["/assets/"];
65
- function Ae({
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 = L(x(process.cwd(), "./index.html"), "utf-8");
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 = L(x(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
80
- const h = ee();
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
- Q({
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 (le.some((s) => {
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), D = "production";
103
- let c, u, S = d;
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((i) => {
110
- const B = Object.values((i == null ? void 0 : i.sections) ?? {}).filter(
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: ($ = (v = i == null ? void 0 : i.dataSource) == null ? void 0 : v[p.id]) == null ? void 0 : $[g]
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(...B);
126
+ w.push(...N);
127
127
  });
128
- const U = new Promise((i) => {
128
+ const B = new Promise((c) => {
129
129
  setTimeout(() => {
130
- i({});
130
+ c({});
131
131
  }, 90 * 1e3);
132
132
  });
133
133
  try {
134
134
  await Promise.race([
135
- U,
136
- Y({
137
- mode: D,
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: V.UMD_FN
143
- }).then((i) => {
144
- i && (u = Z(i));
142
+ module: X.UMD_FN
143
+ }).then((c) => {
144
+ c && (u = q(c));
145
145
  })
146
146
  ]);
147
- } catch (i) {
148
- T.warn("getPreloadComponents timeout in promise race, skip inject html elements", i);
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 = (c == null ? void 0 : c.title) || l.env.appName, m = (c == null ? void 0 : c.description) || l.env.appDescription, b = ne(W(l.env.appUrl, "/.well-known/service/blocklet/og.png"), {
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 = oe.render(d, {
157
+ S = ne.render(d, {
158
158
  ogTitle: s,
159
159
  ogDescription: m,
160
- ogImage: ae(c == null ? void 0 : c.image) || b,
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, K = n.query.mode === "draft" || n.url.includes("preview"), f = M.load(S);
166
- let a = c == null ? void 0 : c.backgroundColor;
167
- if (a && X(a)) {
168
- const s = await se();
169
- a = te(
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__ = ${q(e || null)};
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
- ${K ? `<script src="https://cdn.tailwindcss.com"><\/script>
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 = H();
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 = M.load(n.cachedHtml);
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, c = null, u = 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 ae(o) {
208
- const t = F("image-bin");
209
- return t && o && !/^(https?:\/\/|\/)/.test(o) ? l.env.appUrl + W(t, "uploads", o) : o;
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
- Ae as default
212
+ $e as default
213
213
  };
@@ -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-YSH6XJUc.js";
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";