@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.
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 +1152 -888
  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,81 +1,81 @@
1
1
  import { jsx as T } from "react/jsx-runtime";
2
- import { Box as z, Alert as q } from "@mui/material";
2
+ import { Box as K, Alert as q } from "@mui/material";
3
3
  import { joinURL as _, withQuery as Q } from "ufo";
4
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";
5
+ import Y from "lodash/isEmpty";
6
+ import * as Z from "yaml";
7
+ import { useLocaleContext as H } from "@arcblock/ux/lib/Locale/context";
8
+ import { getPageTemplateModel as ee } from "@blocklet/pages-kit/utils/page-model";
9
+ import te, { getYjsDoc as oe } from "@syncedstore/core";
10
+ import { useSyncedStore as ne } from "@syncedstore/react";
11
+ import { useLocalStorageState as re } from "ahooks";
12
12
  import { produce as M } from "immer";
13
13
  import G from "lodash/cloneDeep";
14
14
  import F from "lodash/debounce";
15
- import { customAlphabet as ce } from "nanoid";
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
- import { useParams as le, useNavigate as ue } from "react-router-dom";
18
- import { IndexeddbPersistence as me } from "y-indexeddb";
19
- import { WebsocketProvider as fe } from "y-websocket";
20
- import { UndoManager as Se } from "yjs";
15
+ import { customAlphabet as se } from "nanoid";
16
+ import { createContext as ce, useState as $, useRef as ie, useMemo as L, useCallback as R, useEffect as D, useContext as ae } from "react";
17
+ import { useParams as de, useNavigate as le } from "react-router-dom";
18
+ import { IndexeddbPersistence as ue } from "y-indexeddb";
19
+ import { WebsocketProvider as me } from "y-websocket";
20
+ import { UndoManager as fe } from "yjs";
21
21
  import "@blocklet/pages-kit/types";
22
- const qe = (s) => {
22
+ const Ke = (s) => {
23
23
  const n = blocklet == null ? void 0 : blocklet.componentMountPoints.find((f) => f.name === s);
24
24
  return n ? n.mountPoint : "/";
25
25
  };
26
- function pe() {
26
+ function Se() {
27
27
  const { pathname: s } = window.location, n = s.match(/\/admin\/(maker|previewer)\/([^/]+)/), f = n == null ? void 0 : n[2], h = window.__PROJECT_ID__;
28
28
  if (!f && !h)
29
29
  throw new Error("Unable to get projectId from pathname");
30
30
  return f || h;
31
31
  }
32
- function Qe(s) {
32
+ function qe(s) {
33
33
  return `${s}:pages:version`;
34
34
  }
35
- function Xe(s, n) {
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;
35
+ function Qe(s, n) {
36
+ return n === "yaml" ? Y(s) ? "" : Z.stringify(s, { indent: 2 }) : n === "json" ? JSON.parse(JSON.stringify(s || {})) : n === "array" ? JSON.parse(JSON.stringify(s || [])) : s;
37
37
  }
38
- function He({ error: s }) {
39
- return /* @__PURE__ */ T(z, { children: /* @__PURE__ */ T(q, { severity: "error", children: s.message }) });
38
+ function Xe({ error: s }) {
39
+ return /* @__PURE__ */ T(K, { children: /* @__PURE__ */ T(q, { severity: "error", children: s.message }) });
40
40
  }
41
41
  var B;
42
42
  const J = ((B = window.blocklet) == null ? void 0 : B.prefix) || "/", W = X({
43
43
  timeout: 200 * 1e3
44
- }), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (s) => _(`${ge}://${window.location.hostname}`, J, `api/${s}/ws/pages`), Pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
44
+ }), pe = window.location.protocol === "https:" ? "wss" : "ws", Ye = (s) => _(`${pe}://${window.location.hostname}`, J, `api/${s}/ws/pages`), ge = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
45
45
  var U;
46
- (U = blocklet == null ? void 0 : blocklet.componentMountPoints.find((s) => s.did === Pe)) != null && U.mountPoint || _(J, "/image-bin");
46
+ (U = blocklet == null ? void 0 : blocklet.componentMountPoints.find((s) => s.did === ge)) != 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
  }
50
- const we = window.innerWidth <= 750;
51
- function et(s, n, f) {
50
+ const Pe = window.innerWidth <= 750;
51
+ function He(s, n, f) {
52
52
  if (!s || /\.gif/.test(s)) return s;
53
- const h = (we ? n / 1.5 : n) * (f === "quality" ? 1.5 : 1);
54
- return Ie(s, { imageFilter: "resize", w: h, f: "webp" });
53
+ const h = (Pe ? n / 1.5 : n) * (f === "quality" ? 1.5 : 1);
54
+ return we(s, { imageFilter: "resize", w: h, f: "webp" });
55
55
  }
56
- function Ie(s, n) {
56
+ function we(s, n) {
57
57
  return !s || !n ? s : Q(s, n);
58
58
  }
59
- async function ye(s) {
59
+ async function Ie(s) {
60
60
  return W.get(`/api/projects/${s}`).then((n) => n.data);
61
61
  }
62
- async function he(s) {
62
+ async function ye(s) {
63
63
  return W.post(`/api/projects/${s.id}/update`, s).then((n) => n.data);
64
64
  }
65
- const ve = 500, A = ce("abcdefghijklmnopqrstuvwxyz0123456789", 16), N = ie(null);
66
- function tt({
65
+ const he = 500, A = se("abcdefghijklmnopqrstuvwxyz0123456789", 16), N = ce(null);
66
+ function et({
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 } = Z(), v = K(), k = `${v}:MakerLocalState`, e = `${v}:${n}`, [t, c] = se(k, {
72
+ const [E, j] = $(!1), { locale: S } = H(), v = V(), k = `${v}:MakerLocalState`, e = `${v}:${n}`, [t, c] = re(k, {
73
73
  defaultValue: {},
74
74
  listenStorageChange: !0
75
- }), r = ae(t);
75
+ }), r = ie(t);
76
76
  r.current = t;
77
- const i = E(
78
- () => oe({
77
+ const i = L(
78
+ () => te({
79
79
  dataSourceIds: [],
80
80
  dataSources: {},
81
81
  pages: {},
@@ -88,18 +88,18 @@ function tt({
88
88
  resources: {}
89
89
  }),
90
90
  []
91
- ), o = E(() => ne(i), [i]);
92
- E(() => new me(e, o), [e, o]);
93
- const a = E(
94
- () => new fe(s, e, o, {
91
+ ), o = L(() => oe(i), [i]);
92
+ L(() => new ue(e, o), [e, o]);
93
+ const a = L(
94
+ () => new me(s, e, o, {
95
95
  params: {},
96
96
  resyncInterval: 5 * 60 * 1e3
97
97
  }),
98
98
  [s, e, o]
99
- ), d = $(() => {
99
+ ), d = R(() => {
100
100
  a && (a.disconnect(), a.connect());
101
- }, [a]), l = E(
102
- () => new Se(
101
+ }, [a]), l = L(
102
+ () => new fe(
103
103
  [
104
104
  o.getArray("pageIds"),
105
105
  o.getMap("pages"),
@@ -113,11 +113,11 @@ function tt({
113
113
  { doc: o }
114
114
  ),
115
115
  [o]
116
- ), [u, m] = R(null), [x, P] = R(!1), [w, C] = R(void 0), p = $(async () => {
116
+ ), [u, m] = $(null), [x, P] = $(!1), [w, C] = $(void 0), p = R(async () => {
117
117
  if (v) {
118
118
  P(!0);
119
119
  try {
120
- const g = await ye(v);
120
+ const g = await Ie(v);
121
121
  m(g);
122
122
  } catch (g) {
123
123
  console.error("Failed to fetch project:", g);
@@ -125,21 +125,21 @@ function tt({
125
125
  P(!1);
126
126
  }
127
127
  }
128
- }, [v]), b = $(
128
+ }, [v]), b = R(
129
129
  async (g, I) => {
130
- var j;
130
+ var O;
131
131
  if (C(void 0), !!v) {
132
132
  I != null && I.optimisticUpdate && u && m((y) => ({
133
133
  ...y,
134
134
  ...g
135
135
  }));
136
136
  try {
137
- const y = await he({
137
+ const y = await ye({
138
138
  ...g
139
139
  });
140
140
  m(y);
141
141
  } catch (y) {
142
- console.error("Failed to update project:", y), I != null && I.optimisticUpdate && m(u), C((j = y == null ? void 0 : y.response) == null ? void 0 : j.data);
142
+ console.error("Failed to update project:", y), I != null && I.optimisticUpdate && m(u), C((O = y == null ? void 0 : y.response) == null ? void 0 : O.data);
143
143
  }
144
144
  }
145
145
  },
@@ -148,7 +148,7 @@ function tt({
148
148
  D(() => {
149
149
  v && p();
150
150
  }, [v, p]);
151
- const V = E(
151
+ const z = L(
152
152
  () => ({
153
153
  doc: o,
154
154
  state: i,
@@ -185,16 +185,16 @@ function tt({
185
185
  );
186
186
  return D(() => {
187
187
  l.on("stack-item-added", ({ stackItem: g }) => {
188
- const { currentPageId: I, currentLocale: j, pages: y } = r.current;
189
- g.meta.set("localState", { currentPageId: I, currentLocale: j, pages: y });
188
+ const { currentPageId: I, currentLocale: O, pages: y } = r.current;
189
+ g.meta.set("localState", { currentPageId: I, currentLocale: O, pages: y });
190
190
  }), l.on("stack-item-popped", ({ stackItem: g }) => {
191
191
  const I = g.meta.get("localState");
192
- I && c((j) => ({ ...j, ...I }));
192
+ I && c((O) => ({ ...O, ...I }));
193
193
  });
194
194
  }, [l, c]), D(() => {
195
195
  a.awareness.setLocalState(t);
196
196
  }, [a, t]), D(() => {
197
- a.once("synced", () => O(!0));
197
+ a.once("synced", () => j(!0));
198
198
  const g = () => {
199
199
  c((y) => ({
200
200
  ...y,
@@ -205,19 +205,19 @@ function tt({
205
205
  ...y,
206
206
  networkStatus: "offline"
207
207
  }));
208
- }, j = F(({ status: y }) => {
208
+ }, O = F(({ status: y }) => {
209
209
  y === "connected" ? g() : y === "disconnected" && I();
210
- }, ve);
211
- return a.on("status", j), window.addEventListener("online", g), window.addEventListener("offline", I), () => {
212
- a.off("status", j), window.removeEventListener("online", g), window.removeEventListener("offline", I);
210
+ }, he);
211
+ return a.on("status", O), window.addEventListener("online", g), window.addEventListener("offline", I), () => {
212
+ a.off("status", O), window.removeEventListener("online", g), window.removeEventListener("offline", I);
213
213
  };
214
- }, [a, c]), h && !L ? null : /* @__PURE__ */ T(N.Provider, { value: V, children: f });
214
+ }, [a, c]), h && !E ? null : /* @__PURE__ */ T(N.Provider, { value: z, children: f });
215
215
  }
216
- const Ce = () => {
217
- const s = de(N);
216
+ const ve = () => {
217
+ const s = ae(N);
218
218
  if (!s)
219
219
  throw new Error("Context is null");
220
- const n = re(s.state), { setLocalState: f, localState: h } = s, L = ue(), O = K(), S = E(
220
+ const n = ne(s.state), { setLocalState: f, localState: h } = s, E = le(), j = V(), S = L(
221
221
  () => ({
222
222
  get currentPage() {
223
223
  const {
@@ -297,21 +297,16 @@ const Ce = () => {
297
297
  },
298
298
  get currentPageModel() {
299
299
  const e = this.currentPage ?? null;
300
- if (e) {
301
- const t = new ee({
302
- childrenProperties: te,
303
- locale: h.currentLocale
304
- });
305
- return t.parse(e), t;
306
- }
300
+ if (e)
301
+ return ee(e, !1);
307
302
  }
308
303
  }),
309
304
  [JSON.stringify(h), n]
310
- ), v = E(
305
+ ), v = L(
311
306
  () => ({
312
307
  setCurrentSectionId: (e, t) => {
313
308
  var c, r;
314
- e === h.currentPageId && t === ((r = (c = h.pages) == null ? void 0 : c[e]) == null ? void 0 : r.currentSectionId) || (L(_("/admin/maker", O ?? "", "pages", e)), f(
309
+ e === h.currentPageId && t === ((r = (c = h.pages) == null ? void 0 : c[e]) == null ? void 0 : r.currentSectionId) || (E(_("/admin/maker", j ?? "", "pages", e)), f(
315
310
  (i) => M(i, (o) => {
316
311
  var a;
317
312
  o.currentPageId = e, o.currentComponentId = void 0, t !== void 0 && (o.pages ?? (o.pages = {}), (a = o.pages)[e] ?? (a[e] = {}), o.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
@@ -319,7 +314,7 @@ const Ce = () => {
319
314
  ));
320
315
  },
321
316
  setCurrentComponentId: (e) => {
322
- e !== h.currentComponentId && (L(_("/admin/maker", O ?? "", "components", e)), f(
317
+ e !== h.currentComponentId && (E(_("/admin/maker", j ?? "", "components", e)), f(
323
318
  (t) => M(t, (c) => {
324
319
  c.currentComponentId = e;
325
320
  })
@@ -371,8 +366,8 @@ const Ce = () => {
371
366
  );
372
367
  }
373
368
  }),
374
- [f, L, O, S]
375
- ), k = E(
369
+ [f, E, j, S]
370
+ ), k = L(
376
371
  () => ({
377
372
  addPage: (e, t) => {
378
373
  var i, o, a, d, l, u;
@@ -516,7 +511,7 @@ const Ce = () => {
516
511
  const r = (l = S.currentPageModel) == null ? void 0 : l.getComponentById(t);
517
512
  if (!(r != null && r.model))
518
513
  throw new Error(`Section ${t} is not exists`);
519
- const i = JSON.parse(JSON.stringify(r.model)), o = Ee(i), a = o.id, d = r == null ? void 0 : r.parent;
514
+ const i = JSON.parse(JSON.stringify(r.model)), o = Oe(i), a = o.id, d = r == null ? void 0 : r.parent;
520
515
  return d && (d.model.sections[a] = o, d.model.sectionIds.push(a), v.setCurrentSectionId(e, a), (m = (u = S.currentPage) == null ? void 0 : u.dataSource) != null && m[t] && (S.currentPage.dataSource[a] = JSON.parse(
521
516
  JSON.stringify(S.currentPage.dataSource[t])
522
517
  ))), o;
@@ -547,40 +542,40 @@ const Ce = () => {
547
542
  localActions: v,
548
543
  ...S
549
544
  };
550
- }, K = () => {
551
- const { projectId: s } = le();
552
- return s ?? pe() ?? "";
553
- }, ot = () => window.__PROJECT_SLUG__ ?? "";
554
- function be(s) {
555
- var h, L;
545
+ }, V = () => {
546
+ const { projectId: s } = de();
547
+ return s ?? Se() ?? "";
548
+ }, tt = () => window.__PROJECT_SLUG__ ?? "";
549
+ function Ce(s) {
550
+ var h, E;
556
551
  const { resources: n } = s;
557
552
  if (!n.components)
558
553
  return {};
559
554
  const f = {};
560
- return (L = (h = window == null ? void 0 : window.blocklet) == null ? void 0 : h.componentMountPoints) == null || L.forEach((O) => {
561
- f[O.did] = O;
555
+ return (E = (h = window == null ? void 0 : window.blocklet) == null ? void 0 : h.componentMountPoints) == null || E.forEach((j) => {
556
+ f[j.did] = j;
562
557
  }), Object.fromEntries(
563
- Object.entries(n.components).map(([O, { blockletId: S, component: v }]) => {
558
+ Object.entries(n.components).map(([j, { blockletId: S, component: v }]) => {
564
559
  var k;
565
560
  return [
566
- O,
561
+ j,
567
562
  { data: v, blockletId: S, blockletTitle: ((k = f[S]) == null ? void 0 : k.title) || S }
568
563
  ];
569
564
  })
570
565
  );
571
566
  }
572
- function Oe(s) {
567
+ function be(s) {
573
568
  const { components: n } = s;
574
569
  return n || {};
575
570
  }
576
571
  function je(s) {
577
572
  return {
578
- ...be(s),
579
- ...Oe(s)
573
+ ...Ce(s),
574
+ ...be(s)
580
575
  };
581
576
  }
582
- const nt = () => je(Ce().state);
583
- function Ee(s) {
577
+ const ot = () => je(ve().state);
578
+ function Oe(s) {
584
579
  const n = JSON.parse(JSON.stringify(s)), f = A();
585
580
  return {
586
581
  ...n,
@@ -588,22 +583,22 @@ function Ee(s) {
588
583
  };
589
584
  }
590
585
  export {
591
- He as E,
592
- tt as S,
586
+ Xe as E,
587
+ et as S,
593
588
  Ye as a,
594
- Ce as b,
595
- Qe as c,
589
+ ve as b,
590
+ qe as c,
596
591
  je as d,
597
- ot as e,
598
- et as f,
592
+ tt as e,
593
+ He as f,
599
594
  Ze as g,
600
- nt as h,
595
+ ot as h,
601
596
  W as i,
602
- qe as j,
603
- Oe as k,
604
- be as l,
605
- pe as m,
597
+ Ke as j,
598
+ be as k,
599
+ Ce as l,
600
+ Se as m,
606
601
  A as n,
607
- Xe as t,
608
- K as u
602
+ Qe as t,
603
+ V as u
609
604
  };
@@ -7,7 +7,7 @@ import "lru-cache";
7
7
  import "node-fetch";
8
8
  import "ufo";
9
9
  import "crypto";
10
- import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-YSH6XJUc.js";
10
+ import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-BeEHvakk.js";
11
11
  export {
12
12
  _ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
13
13
  E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
package/lib/es/home.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import "./chunks/state-BzwEX9VC.js";
2
+ import "./chunks/state-COB6reM7.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-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-DZ0sRPEQ.js";
24
+ import "./chunks/array-DM0x2Sjw.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-ClxOpmCx.js";
26
26
  import "./chunks/session-CVblGhSp.js";
27
27
  export {
28
28
  R as HomeView,