@blocklet/pages-kit-inner-components 0.5.31 → 0.5.33
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/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{array-BH41o7C6.js → array-DxhrK2d5.js} +1 -1
- package/lib/cjs/chunks/{config-string-B3JoYJVu.js → config-string-DqWgB7yO.js} +1 -1
- package/lib/cjs/chunks/{draft-data-hZaTeHgL.js → draft-data-DzN2u_NT.js} +1 -1
- package/lib/cjs/chunks/{home-B6E0yAU3.js → home-0fezWT4S.js} +3 -3
- package/lib/cjs/chunks/{publish-button-CO_WU_f5.js → publish-button-D2jaaXXn.js} +1 -1
- package/lib/cjs/chunks/{site-state-D5jk8eJT.js → site-state-D00xEf4T.js} +8 -8
- package/lib/cjs/chunks/state-DoGBMTzI.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +3 -3
- package/lib/es/chunks/{array-NLDZzhVt.js → array-D6qyZucY.js} +1 -1
- package/lib/es/chunks/{config-string-DutyRoOh.js → config-string-Btybe5Rd.js} +1 -1
- package/lib/es/chunks/{draft-data-DjX0kpDC.js → draft-data-DQ7_JyJX.js} +1 -1
- package/lib/es/chunks/{home-CxRa0eKd.js → home-Dox9JwvF.js} +4 -4
- package/lib/es/chunks/{publish-button-1bl_Nuva.js → publish-button-T2YJBoty.js} +3 -3
- package/lib/es/chunks/{site-state-DEduMTrY.js → site-state-nXcBqjeR.js} +464 -461
- package/lib/es/chunks/{state-C02ZI8vz.js → state-NhsHvaKm.js} +176 -176
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +4 -2
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +2 -2
- package/lib/es/site-state.js +1 -1
- package/package.json +19 -19
- package/lib/cjs/chunks/state-DxOb57hO.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
2
2
|
import { Box as V, Alert as z } from "@mui/material";
|
|
3
|
-
import { joinURL as
|
|
3
|
+
import { joinURL as _, withQuery as q } from "ufo";
|
|
4
4
|
import { createAxios as Q } from "@blocklet/js-sdk";
|
|
5
5
|
import X from "lodash/isEmpty";
|
|
6
6
|
import * as H from "yaml";
|
|
@@ -9,11 +9,11 @@ import { TemplateModel as Z, PAGES_KIT_CHILDREN_PROPERTIES as ee } from "@blockl
|
|
|
9
9
|
import te, { getYjsDoc as oe } from "@syncedstore/core";
|
|
10
10
|
import { useSyncedStore as ne } from "@syncedstore/react";
|
|
11
11
|
import { useLocalStorageState as re } from "ahooks";
|
|
12
|
-
import { produce as
|
|
13
|
-
import
|
|
12
|
+
import { produce as M } from "immer";
|
|
13
|
+
import se from "lodash/cloneDeep";
|
|
14
14
|
import U from "lodash/debounce";
|
|
15
|
-
import { customAlphabet as
|
|
16
|
-
import { createContext as ie, useState as
|
|
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
17
|
import { useParams as le, useNavigate as ue } from "react-router-dom";
|
|
18
18
|
import { IndexeddbPersistence as me } from "y-indexeddb";
|
|
19
19
|
import { WebsocketProvider as fe } from "y-websocket";
|
|
@@ -36,16 +36,16 @@ function Xe(r, o) {
|
|
|
36
36
|
return o === "yaml" ? X(r) ? "" : H.stringify(r, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(r || {})) : o === "array" ? JSON.parse(JSON.stringify(r || [])) : r;
|
|
37
37
|
}
|
|
38
38
|
function He({ error: r }) {
|
|
39
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ T(V, { children: /* @__PURE__ */ T(z, { severity: "error", children: r.message }) });
|
|
40
40
|
}
|
|
41
41
|
var G;
|
|
42
|
-
const
|
|
42
|
+
const J = ((G = window.blocklet) == null ? void 0 : G.prefix) || "/", F = Q({
|
|
43
43
|
timeout: 200 * 1e3
|
|
44
|
-
}), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (r) =>
|
|
44
|
+
}), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (r) => _(`${ge}://${window.location.hostname}`, J, `api/${r}/ws/pages`), Pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
45
45
|
var B;
|
|
46
|
-
(B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((r) => r.did === Pe)) != null && B.mountPoint ||
|
|
46
|
+
(B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((r) => r.did === Pe)) != null && B.mountPoint || _(J, "/image-bin");
|
|
47
47
|
function Ze(r) {
|
|
48
|
-
return r && !/^(https?:\/\/|\/)/.test(r) ? window.location.origin +
|
|
48
|
+
return r && !/^(https?:\/\/|\/)/.test(r) ? window.location.origin + _(J, "uploads", r) : r;
|
|
49
49
|
}
|
|
50
50
|
const we = window.innerWidth <= 750;
|
|
51
51
|
function et(r, o, f) {
|
|
@@ -62,19 +62,19 @@ async function ye(r) {
|
|
|
62
62
|
async function he(r) {
|
|
63
63
|
return F.post(`/api/projects/${r.id}/update`, r).then((o) => o.data);
|
|
64
64
|
}
|
|
65
|
-
const ve = 500,
|
|
65
|
+
const ve = 500, A = ce("abcdefghijklmnopqrstuvwxyz0123456789", 16), W = ie(null);
|
|
66
66
|
function tt({
|
|
67
67
|
url: r,
|
|
68
68
|
name: o,
|
|
69
69
|
children: f,
|
|
70
70
|
waitingSynced: h
|
|
71
71
|
}) {
|
|
72
|
-
const [
|
|
72
|
+
const [L, O] = R(!1), { locale: S } = Y(), v = N(), k = `${v}:MakerLocalState`, e = `${v}:${o}`, [t, c] = re(k, {
|
|
73
73
|
defaultValue: {},
|
|
74
74
|
listenStorageChange: !0
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
const i =
|
|
75
|
+
}), s = ae(t);
|
|
76
|
+
s.current = t;
|
|
77
|
+
const i = E(
|
|
78
78
|
() => te({
|
|
79
79
|
dataSourceIds: [],
|
|
80
80
|
dataSources: {},
|
|
@@ -88,17 +88,17 @@ function tt({
|
|
|
88
88
|
resources: {}
|
|
89
89
|
}),
|
|
90
90
|
[]
|
|
91
|
-
), n =
|
|
92
|
-
|
|
93
|
-
const a =
|
|
91
|
+
), n = E(() => oe(i), [i]);
|
|
92
|
+
E(() => new me(e, n), [e, n]);
|
|
93
|
+
const a = E(
|
|
94
94
|
() => new fe(r, e, n, {
|
|
95
95
|
params: {},
|
|
96
96
|
resyncInterval: 5 * 60 * 1e3
|
|
97
97
|
}),
|
|
98
98
|
[r, e, n]
|
|
99
|
-
), d =
|
|
99
|
+
), d = $(() => {
|
|
100
100
|
a && (a.disconnect(), a.connect());
|
|
101
|
-
}, [a]), l =
|
|
101
|
+
}, [a]), l = E(
|
|
102
102
|
() => new Se(
|
|
103
103
|
[
|
|
104
104
|
n.getArray("pageIds"),
|
|
@@ -113,42 +113,42 @@ function tt({
|
|
|
113
113
|
{ doc: n }
|
|
114
114
|
),
|
|
115
115
|
[n]
|
|
116
|
-
), [u, m] =
|
|
116
|
+
), [u, m] = R(null), [x, P] = R(!1), [w, C] = R(void 0), p = $(async () => {
|
|
117
117
|
if (v) {
|
|
118
|
-
|
|
118
|
+
P(!0);
|
|
119
119
|
try {
|
|
120
|
-
const
|
|
121
|
-
m(
|
|
122
|
-
} catch (
|
|
123
|
-
console.error("Failed to fetch project:",
|
|
120
|
+
const g = await ye(v);
|
|
121
|
+
m(g);
|
|
122
|
+
} catch (g) {
|
|
123
|
+
console.error("Failed to fetch project:", g);
|
|
124
124
|
} finally {
|
|
125
|
-
|
|
125
|
+
P(!1);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
}, [v]),
|
|
129
|
-
async (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
128
|
+
}, [v]), b = $(
|
|
129
|
+
async (g, I) => {
|
|
130
|
+
var j;
|
|
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
137
|
const y = await he({
|
|
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),
|
|
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);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
146
|
[v, u]
|
|
147
147
|
);
|
|
148
|
-
|
|
149
|
-
v &&
|
|
150
|
-
}, [v,
|
|
151
|
-
const K =
|
|
148
|
+
D(() => {
|
|
149
|
+
v && p();
|
|
150
|
+
}, [v, p]);
|
|
151
|
+
const K = E(
|
|
152
152
|
() => ({
|
|
153
153
|
doc: n,
|
|
154
154
|
state: i,
|
|
@@ -157,14 +157,14 @@ function tt({
|
|
|
157
157
|
// always use the locale from the context
|
|
158
158
|
currentLocale: S
|
|
159
159
|
},
|
|
160
|
-
setLocalState: (
|
|
160
|
+
setLocalState: (g) => c(typeof g == "function" ? (I) => g(I ?? {}) : g),
|
|
161
161
|
undoManager: l,
|
|
162
162
|
projectState: {
|
|
163
163
|
project: u,
|
|
164
|
-
isLoadingProject:
|
|
165
|
-
error:
|
|
164
|
+
isLoadingProject: x,
|
|
165
|
+
error: w
|
|
166
166
|
},
|
|
167
|
-
updateProject:
|
|
167
|
+
updateProject: b,
|
|
168
168
|
forceSync: d
|
|
169
169
|
}),
|
|
170
170
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -173,51 +173,51 @@ function tt({
|
|
|
173
173
|
i,
|
|
174
174
|
JSON.stringify(t),
|
|
175
175
|
// resolve the problem of react warning
|
|
176
|
-
|
|
176
|
+
c,
|
|
177
177
|
l,
|
|
178
178
|
u,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
x,
|
|
180
|
+
b,
|
|
181
|
+
w,
|
|
182
182
|
S,
|
|
183
183
|
d
|
|
184
184
|
]
|
|
185
185
|
);
|
|
186
|
-
return
|
|
187
|
-
l.on("stack-item-added", ({ stackItem:
|
|
188
|
-
const { currentPageId: I, currentLocale:
|
|
189
|
-
|
|
190
|
-
}), l.on("stack-item-popped", ({ stackItem:
|
|
191
|
-
const I =
|
|
192
|
-
I &&
|
|
186
|
+
return D(() => {
|
|
187
|
+
l.on("stack-item-added", ({ stackItem: g }) => {
|
|
188
|
+
const { currentPageId: I, currentLocale: j, pages: y } = s.current;
|
|
189
|
+
g.meta.set("localState", { currentPageId: I, currentLocale: j, pages: y });
|
|
190
|
+
}), l.on("stack-item-popped", ({ stackItem: g }) => {
|
|
191
|
+
const I = g.meta.get("localState");
|
|
192
|
+
I && c((j) => ({ ...j, ...I }));
|
|
193
193
|
});
|
|
194
|
-
}, [l,
|
|
194
|
+
}, [l, c]), D(() => {
|
|
195
195
|
a.awareness.setLocalState(t);
|
|
196
|
-
}, [a, t]),
|
|
197
|
-
a.once("synced", () =>
|
|
198
|
-
const
|
|
199
|
-
|
|
196
|
+
}, [a, t]), D(() => {
|
|
197
|
+
a.once("synced", () => O(!0));
|
|
198
|
+
const g = () => {
|
|
199
|
+
c((y) => ({
|
|
200
200
|
...y,
|
|
201
201
|
networkStatus: void 0
|
|
202
202
|
}));
|
|
203
203
|
}, I = () => {
|
|
204
|
-
|
|
204
|
+
c((y) => ({
|
|
205
205
|
...y,
|
|
206
206
|
networkStatus: "offline"
|
|
207
207
|
}));
|
|
208
|
-
},
|
|
209
|
-
y === "connected" ?
|
|
208
|
+
}, j = U(({ status: y }) => {
|
|
209
|
+
y === "connected" ? g() : y === "disconnected" && I();
|
|
210
210
|
}, ve);
|
|
211
|
-
return a.on("status",
|
|
212
|
-
a.off("status",
|
|
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);
|
|
213
213
|
};
|
|
214
|
-
}, [a,
|
|
214
|
+
}, [a, c]), h && !L ? null : /* @__PURE__ */ T(W.Provider, { value: K, children: f });
|
|
215
215
|
}
|
|
216
216
|
const Ce = () => {
|
|
217
|
-
const r = de(
|
|
217
|
+
const r = de(W);
|
|
218
218
|
if (!r)
|
|
219
219
|
throw new Error("Context is null");
|
|
220
|
-
const o = ne(r.state), { setLocalState: f, localState: h } = r,
|
|
220
|
+
const o = ne(r.state), { setLocalState: f, localState: h } = r, L = ue(), O = N(), S = E(
|
|
221
221
|
() => ({
|
|
222
222
|
get currentPage() {
|
|
223
223
|
const {
|
|
@@ -226,15 +226,15 @@ const Ce = () => {
|
|
|
226
226
|
return e ? o.pages[e] : void 0;
|
|
227
227
|
},
|
|
228
228
|
get currentSection() {
|
|
229
|
-
var
|
|
229
|
+
var s, i, n, a, d;
|
|
230
230
|
const {
|
|
231
231
|
localState: { currentPageId: e, ...t }
|
|
232
232
|
} = r;
|
|
233
233
|
if (!e)
|
|
234
234
|
return;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
return ((n = o.pages[e]) == null ? void 0 : n.sections[
|
|
235
|
+
const c = (i = (s = t.pages) == null ? void 0 : s[e]) == null ? void 0 : i.currentSectionId;
|
|
236
|
+
if (c)
|
|
237
|
+
return ((n = o.pages[e]) == null ? void 0 : n.sections[c]) ?? ((d = (a = this.currentPageModel) == null ? void 0 : a.getComponentById(c)) == null ? void 0 : d.model);
|
|
238
238
|
},
|
|
239
239
|
get currentSectionProperties() {
|
|
240
240
|
var n, a, d, l;
|
|
@@ -243,14 +243,14 @@ const Ce = () => {
|
|
|
243
243
|
} = r;
|
|
244
244
|
if (!e)
|
|
245
245
|
return;
|
|
246
|
-
const
|
|
247
|
-
if (!s)
|
|
248
|
-
return;
|
|
249
|
-
const c = (l = (d = o.pages[e]) == null ? void 0 : d.dataSource) == null ? void 0 : l[s];
|
|
246
|
+
const c = (a = (n = t.pages) == null ? void 0 : n[e]) == null ? void 0 : a.currentSectionId;
|
|
250
247
|
if (!c)
|
|
251
248
|
return;
|
|
249
|
+
const s = (l = (d = o.pages[e]) == null ? void 0 : d.dataSource) == null ? void 0 : l[c];
|
|
250
|
+
if (!s)
|
|
251
|
+
return;
|
|
252
252
|
const { currentLocale: i } = this.currentLocaleMap;
|
|
253
|
-
return i ?
|
|
253
|
+
return i ? s[i] : void 0;
|
|
254
254
|
},
|
|
255
255
|
get currentSectionPropertiesWithFallback() {
|
|
256
256
|
var d, l, u, m;
|
|
@@ -259,33 +259,33 @@ const Ce = () => {
|
|
|
259
259
|
} = r;
|
|
260
260
|
if (!e)
|
|
261
261
|
return;
|
|
262
|
-
const
|
|
263
|
-
if (!s)
|
|
264
|
-
return;
|
|
265
|
-
const c = (m = (u = o.pages[e]) == null ? void 0 : u.dataSource) == null ? void 0 : m[s];
|
|
262
|
+
const c = (l = (d = t.pages) == null ? void 0 : d[e]) == null ? void 0 : l.currentSectionId;
|
|
266
263
|
if (!c)
|
|
267
264
|
return;
|
|
265
|
+
const s = (m = (u = o.pages[e]) == null ? void 0 : u.dataSource) == null ? void 0 : m[c];
|
|
266
|
+
if (!s)
|
|
267
|
+
return;
|
|
268
268
|
const { currentLocale: i, defaultLocale: n, fallbackLocale: a } = this.currentLocaleMap;
|
|
269
|
-
if (i &&
|
|
270
|
-
return
|
|
271
|
-
if (n &&
|
|
272
|
-
return
|
|
273
|
-
if (a &&
|
|
274
|
-
return
|
|
269
|
+
if (i && s[i])
|
|
270
|
+
return s[i];
|
|
271
|
+
if (n && s[n])
|
|
272
|
+
return s[n];
|
|
273
|
+
if (a && s[a])
|
|
274
|
+
return s[a];
|
|
275
275
|
},
|
|
276
276
|
get currentLocaleMap() {
|
|
277
|
-
var
|
|
277
|
+
var s;
|
|
278
278
|
const {
|
|
279
279
|
localState: { currentLocale: e },
|
|
280
280
|
state: {
|
|
281
281
|
supportedLocales: t,
|
|
282
|
-
config: { defaultLocale:
|
|
282
|
+
config: { defaultLocale: c }
|
|
283
283
|
}
|
|
284
284
|
} = r;
|
|
285
285
|
return {
|
|
286
286
|
currentLocale: e,
|
|
287
|
-
defaultLocale:
|
|
288
|
-
fallbackLocale: ((
|
|
287
|
+
defaultLocale: c,
|
|
288
|
+
fallbackLocale: ((s = t == null ? void 0 : t[0]) == null ? void 0 : s.locale) ?? "en"
|
|
289
289
|
};
|
|
290
290
|
},
|
|
291
291
|
get currentRoute() {
|
|
@@ -307,59 +307,59 @@ const Ce = () => {
|
|
|
307
307
|
}
|
|
308
308
|
}),
|
|
309
309
|
[JSON.stringify(h), o]
|
|
310
|
-
), v =
|
|
310
|
+
), v = E(
|
|
311
311
|
() => ({
|
|
312
312
|
setCurrentSectionId: (e, t) => {
|
|
313
|
-
var
|
|
314
|
-
e === h.currentPageId && t === ((
|
|
315
|
-
(i) =>
|
|
313
|
+
var c, s;
|
|
314
|
+
e === h.currentPageId && t === ((s = (c = h.pages) == null ? void 0 : c[e]) == null ? void 0 : s.currentSectionId) || (L(_("/admin/maker", O ?? "", "pages", e)), f(
|
|
315
|
+
(i) => M(i, (n) => {
|
|
316
316
|
var a;
|
|
317
317
|
n.currentPageId = e, n.currentComponentId = void 0, n.customComponentPreviewerProperties = {}, t !== void 0 && (n.pages ?? (n.pages = {}), (a = n.pages)[e] ?? (a[e] = {}), n.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
318
318
|
})
|
|
319
319
|
));
|
|
320
320
|
},
|
|
321
321
|
setCurrentComponentId: (e) => {
|
|
322
|
-
e !== h.currentComponentId && (
|
|
323
|
-
(t) =>
|
|
324
|
-
|
|
322
|
+
e !== h.currentComponentId && (L(_("/admin/maker", O ?? "", "components", e)), f(
|
|
323
|
+
(t) => M(t, (c) => {
|
|
324
|
+
c.currentComponentId = e, c.customComponentPreviewerProperties = {};
|
|
325
325
|
})
|
|
326
326
|
));
|
|
327
327
|
},
|
|
328
328
|
setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
|
|
329
329
|
f(
|
|
330
|
-
(
|
|
331
|
-
|
|
330
|
+
(c) => M(c, (s) => {
|
|
331
|
+
s.currentRouteId = e, s.currentDynamicParams = t;
|
|
332
332
|
})
|
|
333
333
|
);
|
|
334
334
|
},
|
|
335
335
|
setCustomComponentPreviewerProperties: (() => {
|
|
336
336
|
const e = {}, t = U(() => {
|
|
337
337
|
f(
|
|
338
|
-
(
|
|
339
|
-
|
|
340
|
-
...
|
|
338
|
+
(c) => M(c, (s) => {
|
|
339
|
+
s.customComponentPreviewerProperties = {
|
|
340
|
+
...s == null ? void 0 : s.customComponentPreviewerProperties,
|
|
341
341
|
...e
|
|
342
342
|
}, Object.keys(e).forEach((i) => delete e[i]);
|
|
343
343
|
})
|
|
344
344
|
);
|
|
345
345
|
}, 5);
|
|
346
|
-
return (
|
|
347
|
-
Object.assign(e,
|
|
346
|
+
return (c) => {
|
|
347
|
+
Object.assign(e, c), t();
|
|
348
348
|
};
|
|
349
349
|
})(),
|
|
350
350
|
setRouteGenerateProcess: (e) => {
|
|
351
351
|
f(
|
|
352
|
-
(t) =>
|
|
353
|
-
e ?
|
|
354
|
-
...
|
|
352
|
+
(t) => M(t, (c) => {
|
|
353
|
+
e ? c.routeGenerateProcess = {
|
|
354
|
+
...c.routeGenerateProcess,
|
|
355
355
|
...e
|
|
356
|
-
} :
|
|
356
|
+
} : c.routeGenerateProcess = {};
|
|
357
357
|
})
|
|
358
358
|
);
|
|
359
359
|
},
|
|
360
360
|
resetRouteGenerateProcess: () => {
|
|
361
361
|
f(
|
|
362
|
-
(e) =>
|
|
362
|
+
(e) => M(e, (t) => {
|
|
363
363
|
t.routeGenerateProcess = {
|
|
364
364
|
progress: "complete"
|
|
365
365
|
};
|
|
@@ -367,18 +367,18 @@ const Ce = () => {
|
|
|
367
367
|
);
|
|
368
368
|
}
|
|
369
369
|
}),
|
|
370
|
-
[f,
|
|
371
|
-
),
|
|
370
|
+
[f, L, O, S]
|
|
371
|
+
), k = E(
|
|
372
372
|
() => ({
|
|
373
373
|
addPage: (e, t) => {
|
|
374
374
|
var i, n, a, d, l, u;
|
|
375
|
-
const
|
|
375
|
+
const c = (e == null ? void 0 : e.id) ?? A(), s = {
|
|
376
376
|
...e,
|
|
377
|
-
id:
|
|
377
|
+
id: c,
|
|
378
378
|
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
379
379
|
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
380
380
|
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
381
|
-
slug: (e == null ? void 0 : e.slug) ?? `/${
|
|
381
|
+
slug: (e == null ? void 0 : e.slug) ?? `/${c}`,
|
|
382
382
|
sections: (e == null ? void 0 : e.sections) ?? {},
|
|
383
383
|
sectionIds: (e == null ? void 0 : e.sectionIds) ?? [],
|
|
384
384
|
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
@@ -392,17 +392,17 @@ const Ce = () => {
|
|
|
392
392
|
}
|
|
393
393
|
};
|
|
394
394
|
return r.doc.transact(() => {
|
|
395
|
-
o.pages[
|
|
396
|
-
}),
|
|
395
|
+
o.pages[s.id] = s, o.pageIds.splice(t ?? o.pageIds.length, 0, s.id);
|
|
396
|
+
}), s;
|
|
397
397
|
},
|
|
398
398
|
addRoute: (e, t) => {
|
|
399
|
-
const
|
|
399
|
+
const c = (e == null ? void 0 : e.id) ?? A(), s = {
|
|
400
400
|
...e,
|
|
401
|
-
id:
|
|
401
|
+
id: c,
|
|
402
402
|
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
403
403
|
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
404
404
|
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
405
|
-
path: (e == null ? void 0 : e.path) ?? `/${
|
|
405
|
+
path: (e == null ? void 0 : e.path) ?? `/${c}`,
|
|
406
406
|
handler: (e == null ? void 0 : e.handler) ?? "Pages Kit",
|
|
407
407
|
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
408
408
|
params: (e == null ? void 0 : e.params) ?? [],
|
|
@@ -411,17 +411,17 @@ const Ce = () => {
|
|
|
411
411
|
dataSource: (e == null ? void 0 : e.dataSource) ?? {}
|
|
412
412
|
};
|
|
413
413
|
return r.doc.transact(() => {
|
|
414
|
-
o.routes ?? (o.routes = {}), o.routeIds ?? (o.routeIds = []), o.routes[
|
|
415
|
-
}),
|
|
414
|
+
o.routes ?? (o.routes = {}), o.routeIds ?? (o.routeIds = []), o.routes[s.id] = s, o.routeIds.splice(t ?? o.routeIds.length, 0, s.id);
|
|
415
|
+
}), s;
|
|
416
416
|
},
|
|
417
417
|
deleteRoute: (e) => {
|
|
418
|
-
var
|
|
418
|
+
var c;
|
|
419
419
|
if (!e)
|
|
420
420
|
return;
|
|
421
|
-
const t = (
|
|
421
|
+
const t = (c = o.routeIds) == null ? void 0 : c.indexOf(e);
|
|
422
422
|
t !== void 0 && t !== -1 && r.doc.transact(() => {
|
|
423
|
-
var
|
|
424
|
-
(
|
|
423
|
+
var s, i;
|
|
424
|
+
(s = o.routeIds) == null || s.splice(t, 1), (i = o.routes) == null || delete i[e];
|
|
425
425
|
});
|
|
426
426
|
},
|
|
427
427
|
deletePage: (e) => {
|
|
@@ -431,50 +431,50 @@ const Ce = () => {
|
|
|
431
431
|
});
|
|
432
432
|
},
|
|
433
433
|
movePage: (e, t) => {
|
|
434
|
-
const { pageIds:
|
|
435
|
-
|
|
434
|
+
const { pageIds: c } = o, s = c.indexOf(e);
|
|
435
|
+
s >= 0 && c.splice(t, 0, ...c.splice(s, 1));
|
|
436
436
|
},
|
|
437
|
-
addSection: (e, t,
|
|
437
|
+
addSection: (e, t, c, s) => {
|
|
438
438
|
const i = o.pages[e];
|
|
439
439
|
if (!i)
|
|
440
440
|
throw new Error(`Page ${e} is not exists`);
|
|
441
441
|
const n = {
|
|
442
442
|
...t,
|
|
443
|
-
id: t.id ??
|
|
443
|
+
id: t.id ?? A(),
|
|
444
444
|
isTemplateSection: t.isTemplateSection ?? !0,
|
|
445
445
|
llmConfig: t.llmConfig ?? {}
|
|
446
|
-
}, a =
|
|
446
|
+
}, a = se(n.locales);
|
|
447
447
|
return delete n.locales, r.doc.transact(() => {
|
|
448
448
|
var d, l, u;
|
|
449
|
-
if (
|
|
450
|
-
const m = (d = S.currentPageModel) == null ? void 0 : d.getComponentById(
|
|
449
|
+
if (s && s.component === "layout-block") {
|
|
450
|
+
const m = (d = S.currentPageModel) == null ? void 0 : d.getComponentById(s.id);
|
|
451
451
|
m && ((l = m.model).sections ?? (l.sections = {}), m.model.sections[n.id] = n, (u = m.model).sectionIds ?? (u.sectionIds = []), m.model.sectionIds.push(n.id));
|
|
452
452
|
} else
|
|
453
|
-
i.sections[n.id] = n, i.sectionIds.splice(
|
|
453
|
+
i.sections[n.id] = n, i.sectionIds.splice(c ?? i.sectionIds.length, 0, n.id);
|
|
454
454
|
a && (i.dataSource ?? (i.dataSource = {}), i.dataSource[n.id] = a);
|
|
455
455
|
}), n;
|
|
456
456
|
},
|
|
457
457
|
deleteSection: (e, t) => {
|
|
458
|
-
const
|
|
459
|
-
if (!
|
|
458
|
+
const c = o.pages[e];
|
|
459
|
+
if (!c)
|
|
460
460
|
throw new Error(`Page ${e} is not exists`);
|
|
461
461
|
r.doc.transact(() => {
|
|
462
|
-
var a, d, l, u, m,
|
|
463
|
-
const
|
|
464
|
-
if (i && (
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
var
|
|
462
|
+
var a, d, l, u, m, x;
|
|
463
|
+
const s = [], i = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(t), n = i == null ? void 0 : i.parent;
|
|
464
|
+
if (i && (s.push(i.model.id, ...i.all().map((P) => P.model.id)), (n == null ? void 0 : n.model.component) === "layout-block")) {
|
|
465
|
+
const P = (d = n.model.sectionIds) == null ? void 0 : d.indexOf(t);
|
|
466
|
+
P !== void 0 && P !== -1 && ((l = n.model.sectionIds) == null || l.splice(P, 1), (u = n.model.sections) == null || delete u[t]), (m = n.model.config) != null && m.gridSettings && Object.keys(n.model.config.gridSettings).forEach((w) => {
|
|
467
|
+
var C;
|
|
468
468
|
try {
|
|
469
|
-
(
|
|
469
|
+
(C = n.model.config.gridSettings[w]) == null || delete C[t];
|
|
470
470
|
} catch {
|
|
471
471
|
}
|
|
472
|
-
}), ((
|
|
472
|
+
}), ((x = n.model.config) == null ? void 0 : x.backgroundSectionId) === t && (n.model.config.backgroundSectionId = void 0);
|
|
473
473
|
}
|
|
474
|
-
|
|
475
|
-
var
|
|
476
|
-
const
|
|
477
|
-
|
|
474
|
+
s.forEach((P) => {
|
|
475
|
+
var C, p;
|
|
476
|
+
const w = c.sectionIds.indexOf(P);
|
|
477
|
+
w !== -1 && c.sectionIds.splice(w, 1), c.sections[P] && delete c.sections[P], (C = c.dataSource) != null && C[P] && ((p = c.dataSource) == null || delete p[P]);
|
|
478
478
|
});
|
|
479
479
|
});
|
|
480
480
|
},
|
|
@@ -482,26 +482,26 @@ const Ce = () => {
|
|
|
482
482
|
var i, n;
|
|
483
483
|
if (!o.pages[e])
|
|
484
484
|
throw new Error(`Page ${e} is not exists`);
|
|
485
|
-
const
|
|
486
|
-
|
|
485
|
+
const s = (n = (i = S.currentPageModel) == null ? void 0 : i.getComponentById(t)) == null ? void 0 : n.model;
|
|
486
|
+
s && (s.locked = !s.locked);
|
|
487
487
|
},
|
|
488
|
-
toggleSectionVisibility: (e, t,
|
|
488
|
+
toggleSectionVisibility: (e, t, c) => {
|
|
489
489
|
var n, a;
|
|
490
490
|
if (!o.pages[e])
|
|
491
491
|
throw new Error(`Page ${e} is not exists`);
|
|
492
492
|
const i = (a = (n = S.currentPageModel) == null ? void 0 : n.getComponentById(t)) == null ? void 0 : a.model;
|
|
493
|
-
i && (i.visibility =
|
|
493
|
+
i && (i.visibility = c);
|
|
494
494
|
},
|
|
495
|
-
moveSection: (e, t,
|
|
496
|
-
var n, a, d, l, u, m;
|
|
495
|
+
moveSection: (e, t, c, s) => {
|
|
496
|
+
var n, a, d, l, u, m, x, P;
|
|
497
497
|
if (!o.pages[e])
|
|
498
498
|
throw new Error(`Page ${e} is not exists`);
|
|
499
|
-
if (
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}) :
|
|
504
|
-
|
|
499
|
+
if (s && s !== t) {
|
|
500
|
+
const w = (n = S.currentPageModel) == null ? void 0 : n.getComponentById(t), C = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(s), p = w == null ? void 0 : w.parent, b = C == null ? void 0 : C.parent;
|
|
501
|
+
b && p && ((d = b == null ? void 0 : b.model) == null ? void 0 : d.id) === ((l = p == null ? void 0 : p.model) == null ? void 0 : l.id) ? r.doc.transact(() => {
|
|
502
|
+
p.model.sectionIds.splice(w.getIndex(), 1), p.model.sectionIds.splice(C.getIndex(), 0, t);
|
|
503
|
+
}) : b && p && ((u = b == null ? void 0 : b.model) == null ? void 0 : u.id) !== ((m = p == null ? void 0 : p.model) == null ? void 0 : m.id) && t !== s && !((P = (x = w == null ? void 0 : w.model) == null ? void 0 : x.sectionIds) != null && P.includes(s)) && r.doc.transact(() => {
|
|
504
|
+
b.model.sections[t] = JSON.parse(JSON.stringify(w.model)), b.model.sectionIds.splice(C.getIndex(), 0, t), p.model.sectionIds.splice(w.getIndex(), 1), delete p.model.sections[t];
|
|
505
505
|
});
|
|
506
506
|
}
|
|
507
507
|
},
|
|
@@ -509,22 +509,22 @@ const Ce = () => {
|
|
|
509
509
|
var l, u, m;
|
|
510
510
|
if (!o.pages[e])
|
|
511
511
|
throw new Error(`Page ${e} is not exists`);
|
|
512
|
-
const
|
|
513
|
-
if (!(
|
|
512
|
+
const s = (l = S.currentPageModel) == null ? void 0 : l.getComponentById(t);
|
|
513
|
+
if (!(s != null && s.model))
|
|
514
514
|
throw new Error(`Section ${t} is not exists`);
|
|
515
|
-
const i = JSON.parse(JSON.stringify(
|
|
515
|
+
const i = JSON.parse(JSON.stringify(s.model)), n = Ee(i), a = n.id, d = s == null ? void 0 : s.parent;
|
|
516
516
|
return d && (d.model.sections[a] = n, 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(
|
|
517
517
|
JSON.stringify(S.currentPage.dataSource[t])
|
|
518
518
|
))), n;
|
|
519
519
|
},
|
|
520
520
|
addDataSource: (e) => {
|
|
521
|
-
const t = e.id ??
|
|
521
|
+
const t = e.id ?? A(), c = {
|
|
522
522
|
...e ?? {},
|
|
523
523
|
id: t,
|
|
524
524
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
525
525
|
};
|
|
526
526
|
return r.doc.transact(() => {
|
|
527
|
-
o.dataSourceIds ?? (o.dataSourceIds = []), o.dataSources ?? (o.dataSources = {}), o.dataSourceIds.push(t), o.dataSources[t] =
|
|
527
|
+
o.dataSourceIds ?? (o.dataSourceIds = []), o.dataSources ?? (o.dataSources = {}), o.dataSourceIds.push(t), o.dataSources[t] = c;
|
|
528
528
|
}), o.dataSources[t];
|
|
529
529
|
},
|
|
530
530
|
deleteDataSource: (e) => {
|
|
@@ -539,28 +539,28 @@ const Ce = () => {
|
|
|
539
539
|
return {
|
|
540
540
|
...r,
|
|
541
541
|
state: o,
|
|
542
|
-
actions:
|
|
542
|
+
actions: k,
|
|
543
543
|
localActions: v,
|
|
544
544
|
...S
|
|
545
545
|
};
|
|
546
|
-
},
|
|
546
|
+
}, N = () => {
|
|
547
547
|
const { projectId: r } = le();
|
|
548
548
|
return r ?? pe() ?? "";
|
|
549
549
|
}, ot = () => window.__PROJECT_SLUG__ ?? "";
|
|
550
550
|
function be(r) {
|
|
551
|
-
var h,
|
|
551
|
+
var h, L;
|
|
552
552
|
const { resources: o } = r;
|
|
553
553
|
if (!o.components)
|
|
554
554
|
return {};
|
|
555
555
|
const f = {};
|
|
556
|
-
return (
|
|
557
|
-
f[
|
|
556
|
+
return (L = (h = window == null ? void 0 : window.blocklet) == null ? void 0 : h.componentMountPoints) == null || L.forEach((O) => {
|
|
557
|
+
f[O.did] = O;
|
|
558
558
|
}), Object.fromEntries(
|
|
559
|
-
Object.entries(o.components).map(([
|
|
560
|
-
var
|
|
559
|
+
Object.entries(o.components).map(([O, { blockletId: S, component: v }]) => {
|
|
560
|
+
var k;
|
|
561
561
|
return [
|
|
562
|
-
|
|
563
|
-
{ data: v, blockletId: S, blockletTitle: ((
|
|
562
|
+
O,
|
|
563
|
+
{ data: v, blockletId: S, blockletTitle: ((k = f[S]) == null ? void 0 : k.title) || S }
|
|
564
564
|
];
|
|
565
565
|
})
|
|
566
566
|
);
|
|
@@ -577,7 +577,7 @@ function je(r) {
|
|
|
577
577
|
}
|
|
578
578
|
const nt = () => je(Ce().state);
|
|
579
579
|
function Ee(r) {
|
|
580
|
-
const o = JSON.parse(JSON.stringify(r)), f =
|
|
580
|
+
const o = JSON.parse(JSON.stringify(r)), f = A();
|
|
581
581
|
return {
|
|
582
582
|
...o,
|
|
583
583
|
id: f
|
|
@@ -599,7 +599,7 @@ export {
|
|
|
599
599
|
Oe as k,
|
|
600
600
|
be as l,
|
|
601
601
|
pe as m,
|
|
602
|
-
|
|
602
|
+
A as n,
|
|
603
603
|
Xe as t,
|
|
604
|
-
|
|
604
|
+
N as u
|
|
605
605
|
};
|