@blocklet/pages-kit-inner-components 0.5.28 → 0.5.30

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.
@@ -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-BB9-Tm4i.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-DJ3JcBMm.js";
11
11
  export {
12
12
  _ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
13
13
  E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
@@ -1,30 +1,30 @@
1
1
  import N from "@arcblock/did-auth-storage-nedb";
2
- import s, { getBlockletJs as J } from "@blocklet/sdk/lib/config";
3
- import G from "@blocklet/sdk/lib/service/auth";
4
- import K from "@blocklet/sdk/lib/wallet";
5
- import z from "@blocklet/sdk/lib/wallet-authenticator";
6
- import Q from "@blocklet/sdk/lib/wallet-handler";
7
- import V, { resolve as x } from "path";
8
- import { l as I, g as X } from "./chunks/site-state-BB9-Tm4i.js";
9
- import { initCronCrawlBlocklet as Y, cancelCronCrawlBlocklet as Z, initSEOMiddleware as q } from "@blocklet/crawler/middlewares";
10
- import { PreloadComponentScriptModule as F } from "@blocklet/pages-kit/types";
11
- import { isMuiColorKey as ee } from "@blocklet/pages-kit/utils/common";
12
- import { injectPreloadComponents as te } from "@blocklet/pages-kit/utils/preload";
13
- import { getComponentMountPoint as oe } from "@blocklet/sdk/lib/component";
14
- import * as L from "cheerio/slim";
15
- import { Router as re } from "express";
16
- import { readFileSync as M } from "fs";
17
- import ne from "lodash/get";
18
- import le from "mustache";
19
- import { withQuery as ie, joinURL as W } from "ufo";
20
- const ce = (o = {}) => {
2
+ import i, { getBlockletJs as H } from "@blocklet/sdk/lib/config";
3
+ import O from "@blocklet/sdk/lib/service/auth";
4
+ import R from "@blocklet/sdk/lib/wallet";
5
+ import J from "@blocklet/sdk/lib/wallet-authenticator";
6
+ import z from "@blocklet/sdk/lib/wallet-handler";
7
+ import G, { resolve as x } from "path";
8
+ import { l as T, g as Y } from "./chunks/site-state-DJ3JcBMm.js";
9
+ import { createSnapshotMiddleware as Q } from "@arcblock/crawler-middleware";
10
+ import { PreloadComponentScriptModule as V } from "@blocklet/pages-kit/types";
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";
14
+ import * as M from "cheerio/slim";
15
+ import { Router as F } from "express";
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 = {}) => {
21
21
  const t = {
22
22
  data: /* @__PURE__ */ new Map(),
23
23
  timers: /* @__PURE__ */ new Map(),
24
- set: (e, d, w = o.ttl || 36e5) => {
24
+ set: (e, d, h = o.ttl || 36e5) => {
25
25
  o.max && t.data.size >= o.max && t.delete(t.data.keys().next().value), t.timers.has(e) && clearTimeout(t.timers.get(e)), t.timers.set(
26
26
  e,
27
- setTimeout(() => t.delete(e), w)
27
+ setTimeout(() => t.delete(e), h)
28
28
  ), t.data.set(e, d);
29
29
  },
30
30
  get: (e) => t.data.get(e),
@@ -38,39 +38,31 @@ const ce = (o = {}) => {
38
38
  }
39
39
  };
40
40
  return t;
41
- }, j = ce({
41
+ }, j = ne({
42
42
  max: 1,
43
43
  ttl: 1e3 * 30
44
44
  // 30 seconds
45
45
  });
46
- K();
47
- const se = new z();
48
- new Q({
49
- authenticator: se,
46
+ R();
47
+ const re = new J();
48
+ new z({
49
+ authenticator: re,
50
50
  tokenStorage: new N({
51
- dbPath: V.join(s.env.dataDir, "auth.db")
51
+ dbPath: G.join(i.env.dataDir, "auth.db")
52
52
  })
53
53
  });
54
- const ae = new G(), me = async () => {
54
+ const ce = 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 ae.getBlocklet();
59
+ const { blocklet: t } = await ce.getBlocklet();
60
60
  return j.set("blockletInfo", t), t;
61
61
  } catch {
62
62
  return null;
63
63
  }
64
- }, pe = ["/assets/"], B = () => [!0, "true"].includes(s.env.preferences.allowCrawler);
65
- function U() {
66
- B() ? Y({
67
- time: "0 0 */12 * * *",
68
- options: {}
69
- }) : Z();
70
- }
71
- U();
72
- s.events.on(s.Events.envUpdate, U);
73
- function Le({
64
+ }, ie = ["/assets/"];
65
+ function Pe({
74
66
  app: o,
75
67
  viteDevServer: t,
76
68
  // projectId,
@@ -78,112 +70,112 @@ function Le({
78
70
  }) {
79
71
  let d;
80
72
  if (t) {
81
- const r = M(x(process.cwd(), "./index.html"), "utf-8");
82
- o.use(async (C, y, T) => {
83
- const _ = C.originalUrl;
84
- d = await t.transformIndexHtml(_, r), T();
73
+ const n = L(x(process.cwd(), "./index.html"), "utf-8");
74
+ o.use(async (k, _, y) => {
75
+ const C = k.originalUrl;
76
+ d = await t.transformIndexHtml(C, n), y();
85
77
  });
86
78
  } else
87
- d = M(x(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
88
- const w = re();
89
- w.use(
90
- (r, C, y) => {
91
- if (r.headers["x-unique-record"] === "dial_http") {
92
- I.info("[html] dial http request, return 200 status code"), C.status(200).send("ok");
93
- return;
94
- }
95
- y();
96
- },
97
- q({
98
- autoReturnHtml: !0,
99
- allowCrawler: B
79
+ d = L(x(process.env.BLOCKLET_APP_DIR, "dist/index.html"), "utf-8");
80
+ const h = F();
81
+ h.use((n, k, _) => {
82
+ if (n.headers["x-unique-record"] === "dial_http") {
83
+ T.info("[html] dial http request, return 200 status code"), k.status(200).send("ok");
84
+ return;
85
+ }
86
+ _();
87
+ }), i.env.preferences.snapkitEnabled && i.env.preferences.snapkitEndpoint && i.env.SNAP_KIT_ACCESS_KEY && h.use(
88
+ Q({
89
+ endpoint: i.env.preferences.snapkitEndpoint,
90
+ accessKey: i.env.SNAP_KIT_ACCESS_KEY,
91
+ cacheMax: i.env.preferences.snapkitCacheSize || 100
100
92
  })
101
- ), w.get("/:path(*)?", async (r, C, y) => {
102
- var $, P, A;
103
- if (pe.some((i) => {
104
- var m;
105
- return (m = r.path) == null ? void 0 : m.startsWith(i);
93
+ ), h.get("/:path(*)?", async (n, k, _) => {
94
+ var E, P, A;
95
+ if (ie.some((s) => {
96
+ var p;
97
+ return (p = n.path) == null ? void 0 : p.startsWith(s);
106
98
  })) {
107
- y();
99
+ _();
108
100
  return;
109
101
  }
110
- const T = performance.now(), _ = () => Math.round(performance.now() - T), D = "production";
111
- let l, u, k = d;
112
- if (r.path.startsWith("/pages")) {
113
- const i = r.params.lang, m = r.cookies.nf_lang, b = /* @__PURE__ */ new Set([...s.env.languages.map((g) => g.code)]);
114
- let f = (i && b.has(i) ? i : void 0) || (b.has(m) ? m : void 0) || [...b][0];
115
- if ((!f || !(($ = e.supportedLocales) != null && $.find((g) => g.locale === f))) && (f = ((A = (P = e.supportedLocales) == null ? void 0 : P[0]) == null ? void 0 : A.locale) || ""), f) {
116
- const g = [];
117
- Object.values(e.pages).forEach((c) => {
118
- const R = Object.values((c == null ? void 0 : c.sections) ?? {}).filter(
119
- (p) => {
120
- var v;
121
- return p.component === "custom-component" && ((v = p.config) == null ? void 0 : v.componentId);
102
+ const y = performance.now(), C = () => Math.round(performance.now() - y), D = "production";
103
+ let c, u, b = d;
104
+ if (n.path.startsWith("/pages")) {
105
+ const s = n.params.lang, p = n.cookies.nf_lang, v = /* @__PURE__ */ new Set([...i.env.languages.map((w) => w.code)]);
106
+ let g = (s && v.has(s) ? s : void 0) || (v.has(p) ? p : void 0) || [...v][0];
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
+ const w = [];
109
+ Object.values(e.pages).forEach((l) => {
110
+ const B = Object.values((l == null ? void 0 : l.sections) ?? {}).filter(
111
+ (m) => {
112
+ var S;
113
+ return m.component === "custom-component" && ((S = m.config) == null ? void 0 : S.componentId);
122
114
  }
123
- ).map((p) => {
124
- var v, E;
115
+ ).map((m) => {
116
+ var S, $;
125
117
  return {
126
- id: p.id,
127
- componentId: p.config.componentId,
128
- useCache: p.config.useCache,
129
- cacheDuration: p.config.cacheDuration,
130
- properties: (E = (v = p.locales) == null ? void 0 : v[f]) == null ? void 0 : E.properties
118
+ id: m.id,
119
+ componentId: m.config.componentId,
120
+ useCache: m.config.useCache,
121
+ cacheDuration: m.config.cacheDuration,
122
+ properties: ($ = (S = m.locales) == null ? void 0 : S[g]) == null ? void 0 : $.properties
131
123
  };
132
124
  });
133
- g.push(...R);
125
+ w.push(...B);
134
126
  });
135
- const O = new Promise((c) => {
127
+ const U = new Promise((l) => {
136
128
  setTimeout(() => {
137
- c({});
129
+ l({});
138
130
  }, 90 * 1e3);
139
131
  });
140
132
  try {
141
133
  await Promise.race([
142
- O,
143
- X({
134
+ U,
135
+ Y({
144
136
  mode: D,
145
- req: r,
137
+ req: n,
146
138
  state: e,
147
- locale: f,
148
- instances: g,
149
- module: F.UMD_FN
150
- }).then((c) => {
151
- c && (u = te(c));
139
+ locale: g,
140
+ instances: w,
141
+ module: V.UMD_FN
142
+ }).then((l) => {
143
+ l && (u = Z(l));
152
144
  })
153
145
  ]);
154
- } catch (c) {
155
- I.warn("getPreloadComponents timeout in promise race, skip inject html elements", c);
146
+ } catch (l) {
147
+ T.warn("getPreloadComponents timeout in promise race, skip inject html elements", l);
156
148
  }
157
149
  }
158
150
  }
159
151
  try {
160
- const i = (l == null ? void 0 : l.title) || s.env.appName, m = (l == null ? void 0 : l.description) || s.env.appDescription, b = ie(W(s.env.appUrl, "/.well-known/service/blocklet/og.png"), {
161
- title: i,
162
- description: m
152
+ const s = (c == null ? void 0 : c.title) || i.env.appName, p = (c == null ? void 0 : c.description) || i.env.appDescription, v = oe(W(i.env.appUrl, "/.well-known/service/blocklet/og.png"), {
153
+ title: s,
154
+ description: p
163
155
  });
164
- k = le.render(d, {
165
- ogTitle: i,
166
- ogDescription: m,
167
- ogImage: de(l == null ? void 0 : l.image) || b,
156
+ b = te.render(d, {
157
+ ogTitle: s,
158
+ ogDescription: p,
159
+ ogImage: le(c == null ? void 0 : c.image) || v,
168
160
  pagesPublishedAt: (e == null ? void 0 : e.config.publishedAt) || (/* @__PURE__ */ new Date()).getTime()
169
161
  });
170
162
  } catch {
171
163
  }
172
- const n = e == null ? void 0 : e.config.fontFamily, H = r.query.mode === "draft" || r.url.includes("preview"), h = L.load(k);
173
- let a = l == null ? void 0 : l.backgroundColor;
174
- if (a && ee(a)) {
175
- const i = await me();
176
- a = ne(
177
- i,
164
+ const r = e == null ? void 0 : e.config.fontFamily, K = n.query.mode === "draft" || n.url.includes("preview"), f = M.load(b);
165
+ let a = c == null ? void 0 : c.backgroundColor;
166
+ if (a && X(a)) {
167
+ const s = await se();
168
+ a = ee(
169
+ s,
178
170
  // 目前 dark 和 light 还是前端行为,后端通过 从 light 中获取
179
171
  `settings.theme.light.palette.${a}`,
180
172
  a
181
173
  );
182
174
  }
183
- h("head").find("#injected-head-elements").replaceWith(`
175
+ f("head").find("#injected-head-elements").replaceWith(`
184
176
  ${a ? `<meta name="theme-color" content="${a}" /><style>html,body,#app {background-color: ${a};}</style>` : ""}
185
- ${n != null && n.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${n.title}&display=swap">` : ""}
186
- ${n != null && n.description && (n == null ? void 0 : n.description) !== (n == null ? void 0 : n.title) ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${n.description}&display=swap">` : ""}
177
+ ${r != null && r.title ? `<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${r.title}&display=swap">` : ""}
178
+ ${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">` : ""}
187
179
  <script>
188
180
 
189
181
  window.__PAGE_STATE__ = ${JSON.stringify(e, null, 0)}
@@ -196,25 +188,25 @@ function Le({
196
188
  });
197
189
  <\/script>
198
190
 
199
- ${H ? `<script src="https://cdn.tailwindcss.com"><\/script>
191
+ ${K ? `<script src="https://cdn.tailwindcss.com"><\/script>
200
192
  <script>
201
193
  window.tailwind.config = {
202
194
  darkMode: "class",
203
195
  };
204
196
  <\/script>` : ""}
205
197
  `);
206
- const S = J();
207
- if (S && h('script[src="__blocklet__.js"]').replaceWith(`<script>${S}<\/script>`), u != null && u.html && h("head").find("#injected-html-elements").replaceWith(u.html), r.cachedHtml) {
208
- const i = L.load(r.cachedHtml);
209
- h("body").html(i("body").html() || "");
198
+ const I = H();
199
+ 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) {
200
+ const s = M.load(n.cachedHtml);
201
+ f("body").html(s("body").html() || "");
210
202
  }
211
- k = h.html(), C.send(k), I.info(`[html] render: ${r.path}, ${_()}ms`), h.root().children().remove(), k = null, l = null, u = null;
212
- }), o.use(w);
203
+ b = f.html(), k.send(b), T.info(`[html] render: ${n.path}, ${C()}ms`), f.root().children().remove(), b = null, c = null, u = null;
204
+ }), o.use(h);
213
205
  }
214
- function de(o) {
215
- const t = oe("image-bin");
216
- return t && o && !/^(https?:\/\/|\/)/.test(o) ? s.env.appUrl + W(t, "uploads", o) : o;
206
+ function le(o) {
207
+ const t = q("image-bin");
208
+ return t && o && !/^(https?:\/\/|\/)/.test(o) ? i.env.appUrl + W(t, "uploads", o) : o;
217
209
  }
218
210
  export {
219
- Le as default
211
+ Pe as default
220
212
  };
@@ -1,4 +1,4 @@
1
- import { P as S, i as b, a as M, l as x, C as J, R as X, S as N, t as W, b as G } from "./chunks/site-state-BB9-Tm4i.js";
1
+ import { P as S, i as b, a as M, l as x, C as J, R as X, S as N, t as W, b as G } from "./chunks/site-state-DJ3JcBMm.js";
2
2
  import { AsyncLocalStorage as K } from "async_hooks";
3
3
  import { Router as Y } from "express";
4
4
  import d from "fs";
@@ -9,16 +9,16 @@ import C, { join as z } from "path";
9
9
  import D from "@blocklet/sdk/lib/middlewares/auth";
10
10
  import { getResourceExportDir as H } from "@blocklet/sdk/lib/component";
11
11
  new K();
12
- const Q = async (e, t, o) => {
12
+ const Q = async (o, t, e) => {
13
13
  var n, s, r, i;
14
14
  try {
15
- const { projectId: a } = e.params;
15
+ const { projectId: a } = o.params;
16
16
  if (!a)
17
- return o();
17
+ return e();
18
18
  const m = await S.findByPk(a);
19
19
  if (!m)
20
20
  return t == null ? void 0 : t.status(404).json({ error: "Project not found" });
21
- const y = (n = e.user) == null ? void 0 : n.did, w = ((s = e.user) == null ? void 0 : s.role) || "UNKNOWN_ROLE";
21
+ const y = (n = o.user) == null ? void 0 : n.did, w = ((s = o.user) == null ? void 0 : s.role) || "UNKNOWN_ROLE";
22
22
  if (!y)
23
23
  return t == null ? void 0 : t.status(401).json({ error: "Authentication required" });
24
24
  if (b()) {
@@ -27,75 +27,75 @@ const Q = async (e, t, o) => {
27
27
  return t == null ? void 0 : t.status(403).json({ error: "No permission to access this project in multi-tenant mode" });
28
28
  } else if (!["owner", "admin", "pagesEditor"].includes(w))
29
29
  return t == null ? void 0 : t.status(403).json({ error: "No permission to access this project in single-tenant mode" });
30
- e.project = m, e.projectId = a, o();
30
+ o.project = m, o.projectId = a, e();
31
31
  } catch (a) {
32
32
  x.error("Project middleware error:", a), t == null || t.status(500).json({ error: "Internal server error" });
33
33
  }
34
34
  };
35
- function T(e, t) {
36
- return new Promise((o, n) => {
37
- const s = d.createReadStream(e), r = d.createWriteStream(t);
38
- s.on("error", n), r.on("error", n), r.on("finish", o), s.pipe(r);
35
+ function B(o, t) {
36
+ return new Promise((e, n) => {
37
+ const s = d.createReadStream(o), r = d.createWriteStream(t);
38
+ s.on("error", n), r.on("error", n), r.on("finish", e), s.pipe(r);
39
39
  });
40
40
  }
41
- async function B(e, t) {
41
+ async function T(o, t) {
42
42
  await d.promises.mkdir(t, { recursive: !0 });
43
- const o = await d.promises.readdir(e, { withFileTypes: !0 });
44
- for (const n of o) {
45
- const s = C.join(e, n.name), r = C.join(t, n.name);
46
- n.isDirectory() ? await B(s, r) : await T(s, r);
43
+ const e = await d.promises.readdir(o, { withFileTypes: !0 });
44
+ for (const n of e) {
45
+ const s = C.join(o, n.name), r = C.join(t, n.name);
46
+ n.isDirectory() ? await T(s, r) : await B(s, r);
47
47
  }
48
48
  }
49
- async function V(e, t) {
50
- (await d.promises.stat(e)).isDirectory() ? await B(e, t) : await T(e, t);
49
+ async function V(o, t) {
50
+ (await d.promises.stat(o)).isDirectory() ? await T(o, t) : await B(o, t);
51
51
  }
52
- const h = (e, t, o) => b() ? D()(e, t, o) : D({ roles: ["owner", "admin", "pagesEditor"] })(e, t, o), Z = (e, t) => {
53
- const o = H({ projectId: e, releaseId: t });
54
- return z(o, J, X);
55
- }, O = Y(), L = "@page", U = "@component", I = ":", E = "ALL", F = "@project", k = ({ pageId: e, projectId: t }) => [L, t, e].join(I), q = (e) => {
56
- const [t, o, n] = e.split(I);
57
- if (t === L) return { pageId: n, projectId: o };
58
- }, v = ({ componentId: e, projectId: t }) => [U, t, e].join(I), tt = (e) => {
59
- const [t, o, n] = e.split(I);
60
- if (t === U) return { componentId: n, projectId: o };
61
- }, et = (e) => [F, e].join(I), ot = (e) => {
62
- const [t, o] = e.split(I);
63
- if (t === F) return o;
64
- }, rt = (e) => {
52
+ const h = (o, t, e) => b() ? D()(o, t, e) : D({ roles: ["owner", "admin", "pagesEditor"] })(o, t, e), Z = (o, t) => {
53
+ const e = H({ projectId: o, releaseId: t });
54
+ return z(e, J, X);
55
+ }, O = Y(), L = "@page", U = "@component", I = ":", E = "ALL", F = "@project", k = ({ pageId: o, projectId: t }) => [L, t, o].join(I), q = (o) => {
56
+ const [t, e, n] = o.split(I);
57
+ if (t === L) return { pageId: n, projectId: e };
58
+ }, v = ({ componentId: o, projectId: t }) => [U, t, o].join(I), tt = (o) => {
59
+ const [t, e, n] = o.split(I);
60
+ if (t === U) return { componentId: n, projectId: e };
61
+ }, ot = (o) => [F, o].join(I), et = (o) => {
62
+ const [t, e] = o.split(I);
63
+ if (t === F) return e;
64
+ }, rt = (o) => {
65
65
  try {
66
- return JSON.parse(e);
66
+ return JSON.parse(o);
67
67
  } catch {
68
68
  }
69
69
  return {};
70
70
  };
71
- async function A(e) {
72
- const t = await N.shared(e).getState("production"), o = await S.findByPk(e), n = t.pageIds.map((r) => {
71
+ async function A(o) {
72
+ const t = await N.getStateByProjectId(o, "production"), e = await S.findByPk(o), n = t.pageIds.map((r) => {
73
73
  const i = t.pages[r];
74
74
  if (i)
75
- return { id: k({ pageId: r, projectId: e }), name: i.slug };
75
+ return { id: k({ pageId: r, projectId: o }), name: i.slug };
76
76
  }).filter(Boolean), s = $(Object.values(t.components), (r) => r.index).map(({ data: r }) => ({
77
- id: v({ componentId: r.id, projectId: e }),
77
+ id: v({ componentId: r.id, projectId: o }),
78
78
  name: r.name || r.id
79
79
  }));
80
80
  return {
81
- id: et(e),
82
- name: (o == null ? void 0 : o.name) || "Unnamed Project",
81
+ id: ot(o),
82
+ name: (e == null ? void 0 : e.name) || "Unnamed Project",
83
83
  children: [
84
- { id: k({ pageId: E, projectId: e }), name: "Pages", children: n },
84
+ { id: k({ pageId: E, projectId: o }), name: "Pages", children: n },
85
85
  {
86
- id: v({ componentId: E, projectId: e }),
86
+ id: v({ componentId: E, projectId: o }),
87
87
  name: "Components",
88
88
  children: s
89
89
  }
90
90
  ]
91
91
  };
92
92
  }
93
- O.get("/resources", h, async (e, t) => {
94
- const { projectId: o } = rt(e.query.resourcesParams);
95
- if (o) {
96
- e.params = { ...e.params, projectId: o }, await Q(e, t, () => {
93
+ O.get("/resources", h, async (o, t) => {
94
+ const { projectId: e } = rt(o.query.resourcesParams);
95
+ if (e) {
96
+ o.params = { ...o.params, projectId: e }, await Q(o, t, () => {
97
97
  });
98
- const r = await A(o);
98
+ const r = await A(e);
99
99
  t.json({ resources: [r] });
100
100
  return;
101
101
  }
@@ -113,10 +113,10 @@ const nt = g.object({
113
113
  resources: g.array().items(g.string()).required(),
114
114
  locale: g.string().allow("")
115
115
  });
116
- O.post("/resources", h, async (e, t) => {
117
- const { resources: o, projectId: n, releaseId: s } = await nt.validateAsync(e.body), r = "production", i = [], a = [];
118
- for (const c of o) {
119
- if (ot(c))
116
+ O.post("/resources", h, async (o, t) => {
117
+ const { resources: e, projectId: n, releaseId: s } = await nt.validateAsync(o.body), r = "production", i = [], a = [];
118
+ for (const c of e) {
119
+ if (et(c))
120
120
  continue;
121
121
  const { pageId: l, projectId: f } = q(c) || {};
122
122
  if (l)
@@ -135,7 +135,7 @@ O.post("/resources", h, async (e, t) => {
135
135
  const m = _(i, "projectId"), y = _(a, "projectId"), w = /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(y)]), P = Z(n, s);
136
136
  d.rmSync(P, { recursive: !0, force: !0 }), d.mkdirSync(P, { recursive: !0 });
137
137
  for (const c of w) {
138
- const l = await N.shared(c).getState(r), f = m[c], u = y[c], p = f == null ? void 0 : f.map((j) => j.pageId), R = u == null ? void 0 : u.map((j) => j.componentId);
138
+ const l = await N.getStateByProjectId(c, r), f = m[c], u = y[c], p = f == null ? void 0 : f.map((j) => j.pageId), R = u == null ? void 0 : u.map((j) => j.componentId);
139
139
  if (p != null && p.length || R != null && R.length) {
140
140
  const j = await W(l, {
141
141
  exportAssets: !0,
@@ -151,8 +151,8 @@ O.post("/resources", h, async (e, t) => {
151
151
  }
152
152
  t.json({});
153
153
  });
154
- O.get("/all-resources", h, async (e, t) => {
155
- const { states: o } = await G(), n = o == null ? void 0 : o.map((s) => {
154
+ O.get("/all-resources", h, async (o, t) => {
155
+ const { states: e } = await G(), n = e == null ? void 0 : e.map((s) => {
156
156
  const r = {
157
157
  blockletId: s.blockletId,
158
158
  blockletTitle: s.blockletTitle,
@@ -1,4 +1,4 @@
1
- import { q as j, o as q, p as v, S as B, r as L, s as U, u as h, b as y, w as z, v as C, n as F, t as G, x as J } from "./chunks/site-state-BB9-Tm4i.js";
1
+ import { q as j, o as q, p as v, S as B, r as L, s as U, u as h, b as y, w as z, v as C, n as F, t as G, x as J } from "./chunks/site-state-DJ3JcBMm.js";
2
2
  import "@blocklet/pages-kit/utils/property";
3
3
  import "@blocklet/pages-kit/utils/route";
4
4
  import "@blocklet/sdk/lib/component";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.5.28",
3
+ "version": "0.5.30",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -77,7 +77,6 @@
77
77
  "@blocklet/ai-kit": "^0.1.78",
78
78
  "@blocklet/ai-runtime": "^0.4.271",
79
79
  "@blocklet/code-editor": "^0.4.271",
80
- "@blocklet/crawler": "^2.3.54",
81
80
  "@blocklet/embed": "^0.2.4",
82
81
  "@blocklet/js-sdk": "^1.16.43",
83
82
  "@blocklet/logger": "1.16.36",
@@ -205,8 +204,8 @@
205
204
  "yaml": "^2.5.0",
206
205
  "yjs": "^13.6.18",
207
206
  "zustand": "^4.5.5",
208
- "@blocklet/pages-kit": "^0.5.28",
209
- "@blocklet/pages-kit-block-studio": "^0.5.28"
207
+ "@blocklet/pages-kit": "^0.5.30",
208
+ "@blocklet/pages-kit-block-studio": "^0.5.30"
210
209
  },
211
210
  "devDependencies": {
212
211
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",