@blocklet/pages-kit-inner-components 0.5.36 → 0.5.38

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.
@@ -4,7 +4,7 @@ import { Icon as P } from "@iconify-icon/react";
4
4
  import { TextField as A, Stack as w, FormControlLabel as F, Switch as L, Box as j, InputAdornment as k } from "@mui/material";
5
5
  import { forwardRef as B, useState as D, useEffect as E, useImperativeHandle as U } from "react";
6
6
  import { useDebounce as V } from "react-use";
7
- import { g as x } from "./state-Br2xp7Mf.js";
7
+ import { g as x } from "./state-BzwEX9VC.js";
8
8
  const J = B(function({ showMarkdown: I, markdown: h, onMarkdownChange: n, showUploader: S, value: o, meta: H, onChange: l, ...a }, z) {
9
9
  const [e, c] = D("");
10
10
  E(() => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { u as a, S as o, a as s, b as n } from "./state-Br2xp7Mf.js";
2
+ import { u as a, S as o, a as s, b as n } from "./state-BzwEX9VC.js";
3
3
  function d({ children: t }) {
4
4
  const r = a();
5
5
  return /* @__PURE__ */ e(o, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as $ } from "react/jsx-runtime";
2
- import { u as X, d as Y, e as fe, f as he, g as be, c as ye } from "./state-Br2xp7Mf.js";
2
+ import { u as X, d as Y, e as fe, f as he, g as be, c as ye } from "./state-BzwEX9VC.js";
3
3
  import { useLocaleContext as J } from "@arcblock/ux/lib/Locale/context";
4
4
  import Z from "@arcblock/ux/lib/Result";
5
5
  import { useHeaderState as ve } from "@blocklet/pages-kit/builtin/page/header";
@@ -21,7 +21,7 @@ import { Helmet as Be } from "react-helmet";
21
21
  import { useSearchParams as ue, Routes as Oe, Route as E, Navigate as Fe, ScrollRestoration as _e } from "react-router-dom";
22
22
  import { useAsync as pe } from "react-use";
23
23
  import { joinURL as S } from "ufo";
24
- import { S as De, n as K, P as Le, a as Ne, B as $e, g as Ae } from "./array-HCA75FfO.js";
24
+ import { S as De, n as K, P as Le, a as Ne, B as $e, g as Ae } from "./array-D34Qpnhk.js";
25
25
  import { styled as me, useTheme as He } from "@arcblock/ux/lib/Theme";
26
26
  import Ue from "@blocklet/ui-react/lib/Footer";
27
27
  import "webfontloader";
@@ -96,7 +96,7 @@ function Je({ mode: t }) {
96
96
  }
97
97
  return /* @__PURE__ */ e(Ze, { children: ({ state: n }) => /* @__PURE__ */ e(V, { mode: t, state: n }) });
98
98
  }
99
- const Ze = le(() => import("./draft-data-CyeVe0kA.js"));
99
+ const Ze = le(() => import("./draft-data-B5kzDvTI.js"));
100
100
  function et({
101
101
  mode: t,
102
102
  children: n
@@ -439,7 +439,7 @@ function H({
439
439
  !((I = l.footer) != null && I.hidden) && /* @__PURE__ */ e(We, {})
440
440
  ] });
441
441
  }
442
- const tt = le(() => import("./publish-button-WmGjhj6q.js")), de = re(xe)`
442
+ const tt = le(() => import("./publish-button-9J9uRZtS.js")), de = re(xe)`
443
443
  &.sticky {
444
444
  position: sticky;
445
445
  top: 0;
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as f, Fragment as le } from "react/jsx-runtime";
2
- import { u as ce, c as de } from "./state-Br2xp7Mf.js";
2
+ import { u as ce, c as de } from "./state-BzwEX9VC.js";
3
3
  import { useLocaleContext as U } from "@arcblock/ux/lib/Locale/context";
4
4
  import Q from "@arcblock/ux/lib/Toast";
5
5
  import { generateParamCombinations as me } from "@blocklet/pages-kit/utils/route";
@@ -10,8 +10,8 @@ import { produce as Oe } from "immer";
10
10
  import ee from "lodash/difference";
11
11
  import { useState as j, useMemo as R, useCallback as v, forwardRef as je, useImperativeHandle as ve, useEffect as $, useRef as Te } from "react";
12
12
  import { useAsync as Re } from "react-use";
13
- import { L as ze } from "./home-COrN_x32.js";
14
- import { p as Le, g as Be } from "./array-HCA75FfO.js";
13
+ import { L as ze } from "./home-B1ALs6m4.js";
14
+ import { p as Le, g as Be } from "./array-D34Qpnhk.js";
15
15
  function Ee(s) {
16
16
  const [y, w] = j(!1);
17
17
  return /* @__PURE__ */ t(
@@ -1,17 +1,17 @@
1
1
  import { jsx as T } from "react/jsx-runtime";
2
- import { Box as V, Alert as z } from "@mui/material";
3
- import { joinURL as _, withQuery as q } from "ufo";
4
- import { createAxios as Q } from "@blocklet/js-sdk";
5
- import X from "lodash/isEmpty";
6
- import * as H from "yaml";
7
- import { useLocaleContext as Y } from "@arcblock/ux/lib/Locale/context";
8
- import { TemplateModel as Z, PAGES_KIT_CHILDREN_PROPERTIES as ee } from "@blocklet/pages-kit-core";
9
- import te, { getYjsDoc as oe } from "@syncedstore/core";
10
- import { useSyncedStore as ne } from "@syncedstore/react";
11
- import { useLocalStorageState as re } from "ahooks";
2
+ import { Box as z, Alert as q } from "@mui/material";
3
+ import { joinURL as _, withQuery as Q } from "ufo";
4
+ import { createAxios as X } from "@blocklet/js-sdk";
5
+ import H from "lodash/isEmpty";
6
+ import * as Y from "yaml";
7
+ import { useLocaleContext as Z } from "@arcblock/ux/lib/Locale/context";
8
+ import { TemplateModel as ee, PAGES_KIT_CHILDREN_PROPERTIES as te } from "@blocklet/pages-kit-core";
9
+ import oe, { getYjsDoc as ne } from "@syncedstore/core";
10
+ import { useSyncedStore as re } from "@syncedstore/react";
11
+ import { useLocalStorageState as se } from "ahooks";
12
12
  import { produce as M } from "immer";
13
- import se from "lodash/cloneDeep";
14
- import U from "lodash/debounce";
13
+ import G from "lodash/cloneDeep";
14
+ import F from "lodash/debounce";
15
15
  import { customAlphabet as ce } from "nanoid";
16
16
  import { createContext as ie, useState as R, useRef as ae, useMemo as E, useCallback as $, useEffect as D, useContext as de } from "react";
17
17
  import { useParams as le, useNavigate as ue } from "react-router-dom";
@@ -33,17 +33,17 @@ function Qe(s) {
33
33
  return `${s}:pages:version`;
34
34
  }
35
35
  function Xe(s, n) {
36
- return n === "yaml" ? X(s) ? "" : H.stringify(s, { indent: 2 }) : n === "json" ? JSON.parse(JSON.stringify(s || {})) : n === "array" ? JSON.parse(JSON.stringify(s || [])) : s;
36
+ return n === "yaml" ? H(s) ? "" : Y.stringify(s, { indent: 2 }) : n === "json" ? JSON.parse(JSON.stringify(s || {})) : n === "array" ? JSON.parse(JSON.stringify(s || [])) : s;
37
37
  }
38
38
  function He({ error: s }) {
39
- return /* @__PURE__ */ T(V, { children: /* @__PURE__ */ T(z, { severity: "error", children: s.message }) });
39
+ return /* @__PURE__ */ T(z, { children: /* @__PURE__ */ T(q, { severity: "error", children: s.message }) });
40
40
  }
41
- var G;
42
- const J = ((G = window.blocklet) == null ? void 0 : G.prefix) || "/", F = Q({
41
+ var B;
42
+ const J = ((B = window.blocklet) == null ? void 0 : B.prefix) || "/", W = X({
43
43
  timeout: 200 * 1e3
44
44
  }), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (s) => _(`${ge}://${window.location.hostname}`, J, `api/${s}/ws/pages`), Pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
45
- var B;
46
- (B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((s) => s.did === Pe)) != null && B.mountPoint || _(J, "/image-bin");
45
+ var U;
46
+ (U = blocklet == null ? void 0 : blocklet.componentMountPoints.find((s) => s.did === Pe)) != null && U.mountPoint || _(J, "/image-bin");
47
47
  function Ze(s) {
48
48
  return s && !/^(https?:\/\/|\/)/.test(s) ? window.location.origin + _(J, "uploads", s) : s;
49
49
  }
@@ -54,28 +54,28 @@ function et(s, n, f) {
54
54
  return Ie(s, { imageFilter: "resize", w: h, f: "webp" });
55
55
  }
56
56
  function Ie(s, n) {
57
- return !s || !n ? s : q(s, n);
57
+ return !s || !n ? s : Q(s, n);
58
58
  }
59
59
  async function ye(s) {
60
- return F.get(`/api/projects/${s}`).then((n) => n.data);
60
+ return W.get(`/api/projects/${s}`).then((n) => n.data);
61
61
  }
62
62
  async function he(s) {
63
- return F.post(`/api/projects/${s.id}/update`, s).then((n) => n.data);
63
+ return W.post(`/api/projects/${s.id}/update`, s).then((n) => n.data);
64
64
  }
65
- const ve = 500, A = ce("abcdefghijklmnopqrstuvwxyz0123456789", 16), W = ie(null);
65
+ const ve = 500, A = ce("abcdefghijklmnopqrstuvwxyz0123456789", 16), N = ie(null);
66
66
  function tt({
67
67
  url: s,
68
68
  name: n,
69
69
  children: f,
70
70
  waitingSynced: h
71
71
  }) {
72
- const [L, O] = R(!1), { locale: S } = Y(), v = N(), k = `${v}:MakerLocalState`, e = `${v}:${n}`, [t, c] = re(k, {
72
+ const [L, O] = R(!1), { locale: S } = Z(), v = K(), k = `${v}:MakerLocalState`, e = `${v}:${n}`, [t, c] = se(k, {
73
73
  defaultValue: {},
74
74
  listenStorageChange: !0
75
75
  }), r = ae(t);
76
76
  r.current = t;
77
77
  const i = E(
78
- () => te({
78
+ () => oe({
79
79
  dataSourceIds: [],
80
80
  dataSources: {},
81
81
  pages: {},
@@ -88,7 +88,7 @@ function tt({
88
88
  resources: {}
89
89
  }),
90
90
  []
91
- ), o = E(() => oe(i), [i]);
91
+ ), o = E(() => ne(i), [i]);
92
92
  E(() => new me(e, o), [e, o]);
93
93
  const a = E(
94
94
  () => new fe(s, e, o, {
@@ -148,7 +148,7 @@ function tt({
148
148
  D(() => {
149
149
  v && p();
150
150
  }, [v, p]);
151
- const K = E(
151
+ const V = E(
152
152
  () => ({
153
153
  doc: o,
154
154
  state: i,
@@ -205,19 +205,19 @@ function tt({
205
205
  ...y,
206
206
  networkStatus: "offline"
207
207
  }));
208
- }, j = U(({ status: y }) => {
208
+ }, j = F(({ status: y }) => {
209
209
  y === "connected" ? g() : y === "disconnected" && I();
210
210
  }, ve);
211
211
  return a.on("status", j), window.addEventListener("online", g), window.addEventListener("offline", I), () => {
212
212
  a.off("status", j), window.removeEventListener("online", g), window.removeEventListener("offline", I);
213
213
  };
214
- }, [a, c]), h && !L ? null : /* @__PURE__ */ T(W.Provider, { value: K, children: f });
214
+ }, [a, c]), h && !L ? null : /* @__PURE__ */ T(N.Provider, { value: V, children: f });
215
215
  }
216
216
  const Ce = () => {
217
- const s = de(W);
217
+ const s = de(N);
218
218
  if (!s)
219
219
  throw new Error("Context is null");
220
- const n = ne(s.state), { setLocalState: f, localState: h } = s, L = ue(), O = N(), S = E(
220
+ const n = re(s.state), { setLocalState: f, localState: h } = s, L = ue(), O = K(), S = E(
221
221
  () => ({
222
222
  get currentPage() {
223
223
  const {
@@ -298,8 +298,8 @@ const Ce = () => {
298
298
  get currentPageModel() {
299
299
  const e = this.currentPage ?? null;
300
300
  if (e) {
301
- const t = new Z({
302
- childrenProperties: ee,
301
+ const t = new ee({
302
+ childrenProperties: te,
303
303
  locale: h.currentLocale
304
304
  });
305
305
  return t.parse(e), t;
@@ -336,12 +336,12 @@ const Ce = () => {
336
336
  setCustomComponentPreviewerProperties: (() => {
337
337
  const e = {};
338
338
  let t = "";
339
- const c = U(() => {
339
+ const c = F(() => {
340
340
  f(
341
341
  (r) => M(r, (i) => {
342
342
  i.customComponentPreviewerProperties ?? (i.customComponentPreviewerProperties = {}), i.customComponentPreviewerProperties[t] = {
343
343
  ...i.customComponentPreviewerProperties[t],
344
- ...e[t]
344
+ ...G(e[t])
345
345
  }, delete e[t];
346
346
  })
347
347
  );
@@ -447,7 +447,7 @@ const Ce = () => {
447
447
  id: t.id ?? A(),
448
448
  isTemplateSection: t.isTemplateSection ?? !0,
449
449
  llmConfig: t.llmConfig ?? {}
450
- }, a = se(o.locales);
450
+ }, a = G(o.locales);
451
451
  return delete o.locales, s.doc.transact(() => {
452
452
  var d, l, u;
453
453
  if (r && r.component === "layout-block") {
@@ -547,7 +547,7 @@ const Ce = () => {
547
547
  localActions: v,
548
548
  ...S
549
549
  };
550
- }, N = () => {
550
+ }, K = () => {
551
551
  const { projectId: s } = le();
552
552
  return s ?? pe() ?? "";
553
553
  }, ot = () => window.__PROJECT_SLUG__ ?? "";
@@ -598,12 +598,12 @@ export {
598
598
  et as f,
599
599
  Ze as g,
600
600
  nt as h,
601
- F as i,
601
+ W as i,
602
602
  qe as j,
603
603
  Oe as k,
604
604
  be as l,
605
605
  pe as m,
606
606
  A as n,
607
607
  Xe as t,
608
- N as u
608
+ K as u
609
609
  };
package/lib/es/home.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import "./chunks/state-Br2xp7Mf.js";
2
+ import "./chunks/state-BzwEX9VC.js";
3
3
  import "@arcblock/ux/lib/Locale/context";
4
4
  import "@arcblock/ux/lib/Result";
5
5
  import "@blocklet/pages-kit/builtin/page/header";
@@ -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/array-HCA75FfO.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-COrN_x32.js";
24
+ import "./chunks/array-D34Qpnhk.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-B1ALs6m4.js";
26
26
  import "./chunks/session-CVblGhSp.js";
27
27
  export {
28
28
  R as HomeView,
@@ -9,15 +9,15 @@ import { l as T, g as Y } from "./chunks/site-state-CfrteYXm.js";
9
9
  import { createSnapshotMiddleware as Q } from "@arcblock/crawler-middleware";
10
10
  import { PreloadComponentScriptModule as V } from "@blocklet/pages-kit/types";
11
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";
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
14
  import * as M from "cheerio/slim";
15
- import { Router as F } from "express";
15
+ import { Router as ee } from "express";
16
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 = {}) => {
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 = {}) => {
21
21
  const t = {
22
22
  data: /* @__PURE__ */ new Map(),
23
23
  timers: /* @__PURE__ */ new Map(),
@@ -38,31 +38,31 @@ const ne = (o = {}) => {
38
38
  }
39
39
  };
40
40
  return t;
41
- }, j = ne({
41
+ }, j = re({
42
42
  max: 1,
43
43
  ttl: 1e3 * 30
44
44
  // 30 seconds
45
45
  });
46
46
  R();
47
- const re = new J();
47
+ const ce = new J();
48
48
  new z({
49
- authenticator: re,
49
+ authenticator: ce,
50
50
  tokenStorage: new N({
51
51
  dbPath: G.join(l.env.dataDir, "auth.db")
52
52
  })
53
53
  });
54
- const ce = new O(), ie = async () => {
54
+ const ie = 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 ce.getBlocklet();
59
+ const { blocklet: t } = await ie.getBlocklet();
60
60
  return j.set("blockletInfo", t), t;
61
61
  } catch {
62
62
  return null;
63
63
  }
64
- }, se = ["/assets/"];
65
- function Pe({
64
+ }, le = ["/assets/"];
65
+ function Ae({
66
66
  app: o,
67
67
  viteDevServer: t,
68
68
  // projectId,
@@ -77,7 +77,7 @@ function Pe({
77
77
  });
78
78
  } else
79
79
  d = L(x(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
80
- const h = F();
80
+ const h = ee();
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");
@@ -92,7 +92,7 @@ function Pe({
92
92
  })
93
93
  ), h.get("/:path(*)?", async (n, k, _) => {
94
94
  var E, P, A;
95
- if (se.some((s) => {
95
+ if (le.some((s) => {
96
96
  var m;
97
97
  return (m = n.path) == null ? void 0 : m.startsWith(s);
98
98
  })) {
@@ -150,14 +150,14 @@ function Pe({
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 = oe(W(l.env.appUrl, "/.well-known/service/blocklet/og.png"), {
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"), {
154
154
  title: s,
155
155
  description: m
156
156
  });
157
- S = te.render(d, {
157
+ S = oe.render(d, {
158
158
  ogTitle: s,
159
159
  ogDescription: m,
160
- ogImage: le(c == null ? void 0 : c.image) || b,
160
+ ogImage: ae(c == null ? void 0 : c.image) || b,
161
161
  pagesPublishedAt: (e == null ? void 0 : e.config.publishedAt) || (/* @__PURE__ */ new Date()).getTime()
162
162
  });
163
163
  } catch {
@@ -165,8 +165,8 @@ function Pe({
165
165
  const r = e == null ? void 0 : e.config.fontFamily, K = n.query.mode === "draft" || n.url.includes("preview"), f = M.load(S);
166
166
  let a = c == null ? void 0 : c.backgroundColor;
167
167
  if (a && X(a)) {
168
- const s = await ie();
169
- a = ee(
168
+ const s = await se();
169
+ a = te(
170
170
  s,
171
171
  // 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
172
172
  `settings.theme.light.palette.${a}`,
@@ -179,7 +179,7 @@ function Pe({
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__ = ${JSON.stringify(e, null, 0)}
182
+ window.__PAGE_STATE__ = ${q(e || null)};
183
183
 
184
184
  document.querySelectorAll('link[rel="preload"][as="style"]').forEach(function (link) {
185
185
  const l = document.createElement('link');
@@ -204,10 +204,10 @@ function Pe({
204
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;
205
205
  }), o.use(h);
206
206
  }
207
- function le(o) {
208
- const t = q("image-bin");
207
+ function ae(o) {
208
+ const t = F("image-bin");
209
209
  return t && o && !/^(https?:\/\/|\/)/.test(o) ? l.env.appUrl + W(t, "uploads", o) : o;
210
210
  }
211
211
  export {
212
- Pe as default
212
+ Ae as default
213
213
  };