@blocklet/pages-kit-inner-components 0.6.20 → 0.6.22

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/es/home.js CHANGED
@@ -21,8 +21,8 @@ import "react-helmet";
21
21
  import "react-router-dom";
22
22
  import "react-use";
23
23
  import "ufo";
24
- import "./chunks/index-aeMNll_R.js";
25
- import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-Dmze9ay0.js";
24
+ import "./chunks/index-BHQcp5eX.js";
25
+ import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-pT8D7Ttx.js";
26
26
  import "./chunks/session-C72Dq8zg.js";
27
27
  export {
28
28
  R as HomeView,
package/lib/es/locales.js CHANGED
@@ -224,10 +224,43 @@ const t = e({
224
224
  dark: "Dark",
225
225
  reverse: "Reverse",
226
226
  background: "Background",
227
+ ignoreMaxWidth: "Ignore Page Global Style Limit",
228
+ ignoreMaxWidthHelper: "Ignore the page global style limit, such as maxWidth, horizontalPadding, etc.",
227
229
  badge: "Badge",
228
230
  buttons: "Buttons",
229
231
  button: "Button",
230
- border: "Border",
232
+ border: {
233
+ title: "Border",
234
+ helper: "Set the border style of the layout",
235
+ custom: "Custom Border",
236
+ width: "Border Width(px)",
237
+ style: "Border Style",
238
+ color: "Border Color",
239
+ preview: "Border Preview",
240
+ solid: "Solid",
241
+ dashed: "Dashed",
242
+ dotted: "Dotted",
243
+ double: "Double",
244
+ groove: "Groove",
245
+ ridge: "Ridge",
246
+ inset: "Inset",
247
+ outset: "Outset",
248
+ borderHelper: "Set the border style of the layout",
249
+ frame: {
250
+ borderFrame: "Border",
251
+ deviceFrame: "Device",
252
+ browserFrame: "Browser",
253
+ shadowFrame: "Shadow",
254
+ commonFrame: "Common"
255
+ }
256
+ },
257
+ borderRadius: {
258
+ title: "Border Radius",
259
+ helper: "Set the border radius of the layout",
260
+ custom: "Custom Border Radius",
261
+ value: "Radius Value(px)",
262
+ preview: "Radius Preview"
263
+ },
231
264
  shadow: "Shadow",
232
265
  color: "Color",
233
266
  variant: "Variant",
@@ -307,8 +340,14 @@ const t = e({
307
340
  gapUnit: "px",
308
341
  padding: "Padding",
309
342
  paddingHelper: "Set the padding of the layout",
310
- alignContent: "Content Alignment",
311
- alignContentHelper: "Set the alignment of the content in the layout",
343
+ alignContent: {
344
+ title: "Vertical Alignment",
345
+ helper: "Set the vertical alignment of content in the layout"
346
+ },
347
+ justifyContent: {
348
+ title: "Horizontal Alignment",
349
+ helper: "Set the horizontal alignment of content in the layout"
350
+ },
312
351
  visualGridLayout: "Configure Grid Layout",
313
352
  dragResizeInstructions: "Drag and resize cards to set layout, you can set different layouts for desktop and mobile",
314
353
  setAsBackgroundElement: "Set as background element (cannot drag and resize)",
@@ -740,10 +779,43 @@ const t = e({
740
779
  dark: "暗黑",
741
780
  reverse: "反转",
742
781
  background: "背景",
782
+ ignoreMaxWidth: "突破页面公共样式限制",
783
+ ignoreMaxWidthHelper: "突破页面公共样式限制,如 最大宽度、水平内边距等",
743
784
  badge: "标签",
744
785
  buttons: "按钮",
745
786
  button: "按钮",
746
- border: "边框",
787
+ border: {
788
+ title: "边框",
789
+ helper: "设置布局的边框样式",
790
+ custom: "自定义边框",
791
+ width: "边框宽度 (px)",
792
+ style: "边框样式",
793
+ color: "边框颜色",
794
+ preview: "边框预览",
795
+ solid: "实线",
796
+ dashed: "虚线",
797
+ dotted: "点线",
798
+ double: "双线",
799
+ groove: "凹槽",
800
+ ridge: "凸槽",
801
+ inset: "内嵌",
802
+ outset: "外凸",
803
+ borderHelper: "设置布局的边框样式",
804
+ frame: {
805
+ borderFrame: "边框",
806
+ deviceFrame: "设备",
807
+ browserFrame: "浏览器",
808
+ shadowFrame: "阴影",
809
+ commonFrame: "通用"
810
+ }
811
+ },
812
+ borderRadius: {
813
+ title: "边框圆角",
814
+ helper: "设置布局的边框圆角",
815
+ custom: "自定义边框圆角",
816
+ value: "圆角大小 (px)",
817
+ preview: "圆角预览"
818
+ },
747
819
  shadow: "阴影",
748
820
  color: "颜色",
749
821
  variant: "样式",
@@ -822,8 +894,14 @@ const t = e({
822
894
  gapHelper: "设置组件之间的间距",
823
895
  padding: "内边距",
824
896
  paddingHelper: "设置布局的内边距",
825
- alignContent: "内容对齐方式",
826
- alignContentHelper: "设置布局中内容的对齐方式",
897
+ alignContent: {
898
+ title: "垂直内容对齐",
899
+ helper: "设置布局中垂直内容的对齐方式"
900
+ },
901
+ justifyContent: {
902
+ title: "水平内容对齐",
903
+ helper: "设置布局中水平内容的对齐方式"
904
+ },
827
905
  visualGridLayout: "配置网格布局",
828
906
  dragResizeInstructions: "通过调整卡片位置和大小调整布局,可以分别设置桌面端和移动端两种布局",
829
907
  setAsBackgroundElement: "设置为背景卡片(无法拖拽排序、无法设置大小)",
@@ -1039,7 +1117,7 @@ const t = e({
1039
1117
  style: {
1040
1118
  title: "公共样式"
1041
1119
  }
1042
- }), n = { en: t, zh: a };
1120
+ }), r = { en: t, zh: a };
1043
1121
  export {
1044
- n as translations
1122
+ r as translations
1045
1123
  };
@@ -1,19 +1,19 @@
1
- import M from "@arcblock/did-auth-storage-nedb";
2
- import c, { getBlockletJs as B } from "@blocklet/sdk/lib/config";
3
- import H from "@blocklet/sdk/lib/service/auth";
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";
1
+ import x from "@arcblock/did-auth-storage-nedb";
2
+ import i, { getBlockletJs as L } from "@blocklet/sdk/lib/config";
3
+ import M from "@blocklet/sdk/lib/service/auth";
4
+ import B from "@blocklet/sdk/lib/wallet";
5
+ import D from "@blocklet/sdk/lib/wallet-authenticator";
6
+ import K from "@blocklet/sdk/lib/wallet-handler";
7
+ import U, { resolve as C } from "path";
8
+ import { l as v, g as W } from "./chunks/components-BWQM8y6L.js";
9
+ import { e as H, i as N } from "./chunks/html-DfzaaIYa.js";
10
10
  import { createSnapshotMiddleware as O } from "@arcblock/crawler-middleware";
11
11
  import { PreloadComponentScriptModule as R } from "@blocklet/pages-kit/types";
12
12
  import { isMuiColorKey as F } from "@blocklet/pages-kit/utils/common";
13
13
  import { injectPreloadComponents as J, safeJSONStringify as z } from "@blocklet/pages-kit/utils/preload";
14
14
  import { getComponentMountPoint as G } from "@blocklet/sdk/lib/component";
15
15
  import { Router as Y } from "express";
16
- import { readFileSync as T } from "fs";
16
+ import { readFileSync as I } from "fs";
17
17
  import Q from "lodash/get";
18
18
  import V from "mustache";
19
19
  import { withQuery as X, joinURL as j } from "ufo";
@@ -21,11 +21,11 @@ const Z = (o = {}) => {
21
21
  const e = {
22
22
  data: /* @__PURE__ */ new Map(),
23
23
  timers: /* @__PURE__ */ new Map(),
24
- set: (t, n, s = o.ttl || 36e5) => {
24
+ set: (t, p, m = 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), s)
28
- ), e.data.set(t, n);
27
+ setTimeout(() => e.delete(t), m)
28
+ ), e.data.set(t, p);
29
29
  },
30
30
  get: (t) => e.data.get(t),
31
31
  has: (t) => e.data.has(t),
@@ -38,179 +38,139 @@ const Z = (o = {}) => {
38
38
  }
39
39
  };
40
40
  return e;
41
- }, E = Z({
41
+ }, T = Z({
42
42
  max: 1,
43
43
  ttl: 1e3 * 30
44
44
  // 30 seconds
45
45
  });
46
- K();
47
- const q = new L();
48
- new W({
46
+ B();
47
+ const q = new D();
48
+ new K({
49
49
  authenticator: q,
50
- tokenStorage: new M({
51
- dbPath: D.join(c.env.dataDir, "auth.db")
50
+ tokenStorage: new x({
51
+ dbPath: U.join(i.env.dataDir, "auth.db")
52
52
  })
53
53
  });
54
- const ee = new H(), te = async () => {
54
+ const ee = new M(), te = async () => {
55
55
  try {
56
- const o = E.get("blockletInfo");
56
+ const o = T.get("blockletInfo");
57
57
  if (o)
58
58
  return o;
59
59
  const { blocklet: e } = await ee.getBlocklet();
60
- return E.set("blockletInfo", e), e;
60
+ return T.set("blockletInfo", e), e;
61
61
  } catch {
62
62
  return null;
63
63
  }
64
- }, oe = async () => await import("cheerio"), _ = {};
65
- function ne(o, e) {
66
- const t = JSON.stringify([o, e]);
67
- return U("md5").update(t).digest("hex");
68
- }
69
- async function re(o, e) {
70
- {
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
- }
81
- }
82
- return ce(o, e);
83
- }
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) {
92
- if (!e || e.length === 0)
93
- return o;
94
- const t = ne(o, e);
95
- return _[t] ??= re(o, e).finally(() => {
96
- setTimeout(() => {
97
- delete _[t];
98
- }, 10 * 1e3);
99
- }), _[t];
100
- }
101
- function ae(o) {
102
- return o.match(/<body[^>]*>(.*?)<\/body>/s)?.[1] || "";
103
- }
104
- const ie = ["/assets/"];
105
- function Ae({
64
+ }, oe = ["/assets/"];
65
+ function Ce({
106
66
  app: o,
107
67
  viteDevServer: e,
108
68
  // projectId,
109
69
  state: t
110
70
  }) {
111
- let n;
71
+ let p;
112
72
  if (e) {
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();
73
+ const n = I(C(process.cwd(), "./index.html"), "utf-8");
74
+ o.use(async (f, k, _) => {
75
+ const l = f.originalUrl;
76
+ p = await e.transformIndexHtml(l, n), _();
117
77
  });
118
78
  } else
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");
79
+ p = I(C(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
80
+ const m = Y();
81
+ m.use((n, f, k) => {
82
+ if (n.headers["x-unique-record"] === "dial_http") {
83
+ v.info("[html] dial http request, return 200 status code"), f.status(200).send("ok");
124
84
  return;
125
85
  }
126
- b();
127
- }), c.env.preferences.snapkitEnabled && c.env.preferences.snapkitEndpoint && c.env.SNAP_KIT_ACCESS_KEY && s.use(
86
+ k();
87
+ }), i.env.preferences.snapkitEnabled && i.env.preferences.snapkitEndpoint && i.env.SNAP_KIT_ACCESS_KEY && m.use(
128
88
  O({
129
- endpoint: c.env.preferences.snapkitEndpoint,
130
- accessKey: c.env.SNAP_KIT_ACCESS_KEY,
131
- cacheMax: c.env.preferences.snapkitCacheSize || 100
89
+ endpoint: i.env.preferences.snapkitEndpoint,
90
+ accessKey: i.env.SNAP_KIT_ACCESS_KEY,
91
+ cacheMax: i.env.preferences.snapkitCacheSize || 100
132
92
  })
133
- ), s.get("/:path(*)?", async (r, f, b) => {
134
- if (ie.some((a) => r.path?.startsWith(a))) {
135
- b();
93
+ ), m.get("/:path(*)?", async (n, f, k) => {
94
+ if (oe.some((s) => n.path?.startsWith(s))) {
95
+ k();
136
96
  return;
137
97
  }
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];
98
+ const _ = "production";
99
+ let l, b, g = p;
100
+ if (n.path.startsWith("/pages")) {
101
+ const s = n.params.lang, y = n.cookies.nf_lang, w = /* @__PURE__ */ new Set([...i.env.languages.map((h) => h.code)]);
102
+ let u = (s && w.has(s) ? s : void 0) || (w.has(y) ? y : void 0) || [...w][0];
143
103
  if ((!u || !t.supportedLocales?.find((h) => h.locale === u)) && (u = t.supportedLocales?.[0]?.locale || ""), u) {
144
104
  const h = [];
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]
105
+ Object.values(t.pages).forEach((r) => {
106
+ const $ = Object.values(r?.sections ?? {}).filter(
107
+ (c) => c.component === "custom-component" && c.config?.componentId
108
+ ).map((c) => ({
109
+ id: c.id,
110
+ componentId: c.config.componentId,
111
+ useCache: c.config.useCache,
112
+ cacheDuration: c.config.cacheDuration,
113
+ properties: r?.dataSource?.[c.id]?.[u]
154
114
  // ?? i.locales?.[respectLocale!]?.properties,
155
115
  }));
156
- h.push(...x);
116
+ h.push(...$);
157
117
  });
158
- const $ = new Promise((i) => {
118
+ const E = new Promise((r) => {
159
119
  setTimeout(() => {
160
- i({});
120
+ r({});
161
121
  }, 30 * 1e3);
162
122
  });
163
123
  try {
164
124
  await Promise.race([
165
- $,
166
- N({
167
- mode: v,
168
- req: r,
125
+ E,
126
+ W({
127
+ mode: _,
128
+ req: n,
169
129
  state: t,
170
130
  locale: u,
171
131
  instances: h,
172
132
  module: R.UMD_FN
173
- }).then((i) => {
174
- i && (k = J(i));
133
+ }).then((r) => {
134
+ r && (b = J(r));
175
135
  })
176
136
  ]);
177
- } catch (i) {
178
- S.warn("getPreloadComponents timeout in promise race, skip inject html elements", i);
137
+ } catch (r) {
138
+ v.warn("getPreloadComponents timeout in promise race, skip inject html elements", r);
179
139
  }
180
140
  }
181
141
  }
182
142
  try {
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,
143
+ const s = l?.title || i.env.appName, y = l?.description || i.env.appDescription, w = X(j(i.env.appUrl, "/.well-known/service/blocklet/og.png"), {
144
+ title: s,
185
145
  description: y
186
146
  });
187
- g = V.render(n, {
188
- ogTitle: a,
147
+ g = V.render(p, {
148
+ ogTitle: s,
189
149
  ogDescription: y,
190
- ogImage: le(m?.image) || w,
150
+ ogImage: ne(l?.image) || w,
191
151
  pagesPublishedAt: t?.config.publishedAt || (/* @__PURE__ */ new Date()).getTime()
192
152
  });
193
153
  } catch {
194
154
  }
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,
155
+ const d = t?.config.fontFamily, P = n.query.mode === "draft" || n.url.includes("preview") || n.path?.startsWith("/admin");
156
+ let a = l?.backgroundColor;
157
+ if (a && F(a)) {
158
+ const s = await te();
159
+ a = Q(
160
+ s,
201
161
  // 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
202
- `settings.theme.light.palette.${l}`,
203
- l
162
+ `settings.theme.light.palette.${a}`,
163
+ a
204
164
  );
205
165
  }
206
- const C = B(), A = [
166
+ const S = L(), A = [
207
167
  {
208
168
  selector: {
209
169
  cheerio: "#injected-head-elements",
210
170
  pattern: /<script[^>]*id=["']injected-head-elements["'][^>]*><\/script>/gis
211
171
  },
212
172
  value: `
213
- ${l ? `<meta name="theme-color" content="${l}" /><style>html,body,#app {background-color: ${l};}</style>` : ""}
173
+ ${a ? `<meta name="theme-color" content="${a}" /><style>html,body,#app {background-color: ${a};}</style>` : ""}
214
174
  ${d?.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${d.title}&display=swap">` : ""}
215
175
  ${d?.description && d?.description !== d?.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${d.description}&display=swap">` : ""}
216
176
 
@@ -238,37 +198,37 @@ function Ae({
238
198
  `
239
199
  },
240
200
  // blocklet.js script
241
- C && {
201
+ S && {
242
202
  selector: {
243
203
  cheerio: 'script[src="__blocklet__.js"]',
244
204
  pattern: /<script[^>]*src=["']__blocklet__\.js["'][^>]*><\/script>/gis
245
205
  },
246
- value: `<script>${C}<\/script>`
206
+ value: `<script>${S}<\/script>`
247
207
  },
248
208
  // injected-html-elements
249
- k?.html && {
209
+ b?.html && {
250
210
  selector: {
251
211
  cheerio: "#injected-html-elements",
252
212
  pattern: /<script[^>]*id=["']injected-html-elements["'][^>]*><\/script>/gis
253
213
  },
254
- value: k.html
214
+ value: b.html
255
215
  },
256
216
  // cachedHtml body content
257
- r.cachedHtml && {
217
+ n.cachedHtml && {
258
218
  selector: {
259
219
  cheerio: "body",
260
220
  pattern: /(<body[^>]*>).*?(<\/body>)/gis
261
221
  },
262
- value: `<body>${ae(r.cachedHtml)}</body>`
222
+ value: `<body>${H(n.cachedHtml)}</body>`
263
223
  }
264
224
  ].filter(Boolean);
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);
225
+ g = await N(g, A), f.send(g), v.info(`[html] render: ${n.path}`), g = null, l = null, b = null;
226
+ }), o.use(m);
267
227
  }
268
- function le(o) {
228
+ function ne(o) {
269
229
  const e = G("image-bin");
270
- return e && o && !/^(https?:\/\/|\/)/.test(o) ? c.env.appUrl + j(e, "uploads", o) : o;
230
+ return e && o && !/^(https?:\/\/|\/)/.test(o) ? i.env.appUrl + j(e, "uploads", o) : o;
271
231
  }
272
232
  export {
273
- Ae as default
233
+ Ce as default
274
234
  };
@@ -1,5 +1,5 @@
1
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-Dt2__Byi.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-CqlS8v17.js";
3
3
  import { Router as K } from "express";
4
4
  import a from "fs";
5
5
  import m from "joi";