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

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,
@@ -1,6 +1,6 @@
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";
1
+ import U from "@arcblock/did-auth-storage-nedb";
2
+ import l, { getBlockletJs as O } from "@blocklet/sdk/lib/config";
3
+ import H from "@blocklet/sdk/lib/service/auth";
4
4
  import R from "@blocklet/sdk/lib/wallet";
5
5
  import J from "@blocklet/sdk/lib/wallet-authenticator";
6
6
  import z from "@blocklet/sdk/lib/wallet-handler";
@@ -47,11 +47,11 @@ R();
47
47
  const re = new J();
48
48
  new z({
49
49
  authenticator: re,
50
- tokenStorage: new N({
50
+ tokenStorage: new U({
51
51
  dbPath: G.join(l.env.dataDir, "auth.db")
52
52
  })
53
53
  });
54
- const ce = new O(), ie = async () => {
54
+ const ce = new H(), ie = async () => {
55
55
  try {
56
56
  const o = j.get("blockletInfo");
57
57
  if (o)
@@ -99,7 +99,7 @@ function Pe({
99
99
  _();
100
100
  return;
101
101
  }
102
- const y = performance.now(), C = () => Math.round(performance.now() - y), D = "production";
102
+ const y = performance.now(), C = () => Math.round(performance.now() - y), B = "production";
103
103
  let c, 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)]);
@@ -107,7 +107,7 @@ function Pe({
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
109
  Object.values(e.pages).forEach((i) => {
110
- const B = Object.values((i == null ? void 0 : i.sections) ?? {}).filter(
110
+ const N = Object.values((i == null ? void 0 : i.sections) ?? {}).filter(
111
111
  (p) => {
112
112
  var v;
113
113
  return p.component === "custom-component" && ((v = p.config) == null ? void 0 : v.componentId);
@@ -123,18 +123,18 @@ function Pe({
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 K = new Promise((i) => {
129
129
  setTimeout(() => {
130
130
  i({});
131
131
  }, 90 * 1e3);
132
132
  });
133
133
  try {
134
134
  await Promise.race([
135
- U,
135
+ K,
136
136
  Y({
137
- mode: D,
137
+ mode: B,
138
138
  req: n,
139
139
  state: e,
140
140
  locale: g,
@@ -162,7 +162,7 @@ function Pe({
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);
165
+ const r = e == null ? void 0 : e.config.fontFamily, D = 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
168
  const s = await ie();
@@ -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__ = JSON.parse(atob('${Buffer.from(JSON.stringify(e, null, 0) || "", "utf8").toString("base64")}'));
183
183
 
184
184
  document.querySelectorAll('link[rel="preload"][as="style"]').forEach(function (link) {
185
185
  const l = document.createElement('link');
@@ -189,14 +189,14 @@ function Pe({
189
189
  });
190
190
  <\/script>
191
191
 
192
- ${K ? `<script src="https://cdn.tailwindcss.com"><\/script>
192
+ ${D ? `<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
201
  const s = M.load(n.cachedHtml);
202
202
  f("body").html(s("body").html() || "");