@blocklet/sdk 1.16.17-beta-7ec31a60 → 1.16.17-beta-8cacb9b3

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/config.js CHANGED
@@ -66,7 +66,7 @@ if (appDataDir) {
66
66
  }
67
67
  }
68
68
  catch (error) {
69
- console.error(error);
69
+ logger.error(error);
70
70
  }
71
71
  try {
72
72
  const envFile = path_1.default.join(appDataDir, constant_1.APP_CONFIG_DIR, process.env.BLOCKLET_COMPONENT_DID, constant_1.COMPONENT_ENV_FILE_NAME);
@@ -84,7 +84,7 @@ if (appDataDir) {
84
84
  }
85
85
  }
86
86
  catch (error) {
87
- console.error(error);
87
+ logger.error(error);
88
88
  }
89
89
  }
90
90
  const env = {
@@ -234,7 +234,7 @@ const fetchBlockletJs = async () => {
234
234
  const componentDid = process.env.BLOCKLET_COMPONENT_DID;
235
235
  try {
236
236
  const { mountPoint } = componentStore.find((x) => x.did === componentDid);
237
- const res = await axios_1.default.get((0, url_join_1.default)(env.appUrl, mountPoint === '/' ? '' : mountPoint, `__blocklet__.js?t=${Date.now()}`), {
237
+ const res = await axios_1.default.get((0, url_join_1.default)(env.appUrl, mountPoint === '/' ? '' : mountPoint, `__blocklet__.js?force=1&t=${Date.now()}`), {
238
238
  timeout: 8000,
239
239
  headers: {
240
240
  'User-Agent': `BlockletSDK/${version_1.version}`,
@@ -252,19 +252,19 @@ const fetchBlockletJs = async () => {
252
252
  // Page group is dynamic, so we need to create it on the fly
253
253
  const normalize = (prefix) => `/${prefix}/`.replace(/\/+/g, '/');
254
254
  const getBlockletJs = (pageGroup = '', pathPrefix = '', source = blockletJs) => {
255
- let copy = source;
255
+ let copy = source.slice(0);
256
256
  if (pageGroup) {
257
257
  copy = copy.replace('pageGroup: "",', `pageGroup: "${pageGroup}",`);
258
258
  }
259
259
  if (pathPrefix) {
260
260
  const componentDid = process.env.BLOCKLET_COMPONENT_DID;
261
261
  const { mountPoint } = componentStore.find((x) => x.did === componentDid);
262
- copy = copy.replace(`prefix: "${normalize(mountPoint)}",`, `prefix: "${normalize(pathPrefix)}",`);
262
+ copy = copy.replace(`prefix: "${normalize(mountPoint)}",`, `prefix: "${normalize(pathPrefix)}",`).replace('prefix: "/",', `prefix: "${normalize(pathPrefix)}",`);
263
263
  }
264
264
  return copy;
265
265
  };
266
266
  exports.getBlockletJs = getBlockletJs;
267
- const refreshBlockletJs = (0, throttle_1.default)(fetchBlockletJs, 8000);
267
+ const refreshBlockletJs = (0, throttle_1.default)(fetchBlockletJs, 3000, { trailing: true });
268
268
  const runInServer = (fn, type) =>
269
269
  // eslint-disable-next-line consistent-return
270
270
  (...args) => {
@@ -18,6 +18,7 @@ const fallback = (file, options = {}) => {
18
18
  if ((req.method === 'GET' || req.method === 'HEAD') && req.accepts('html') && !resourcePattern.test(req.path)) {
19
19
  res.type('html');
20
20
  const pageGroup = req.headers['x-page-group'] || '';
21
+ const pathPrefix = req.headers['x-path-prefix'] || '';
21
22
  const pageData = typeof options.getPageData === 'function' ? await options.getPageData(req) : {};
22
23
  pageData.title = (0, escape_1.default)(pageData.title || config_1.env.appName);
23
24
  pageData.description = (0, escape_1.default)(pageData.description || config_1.env.appDescription);
@@ -49,7 +50,7 @@ const fallback = (file, options = {}) => {
49
50
  source = source.replace('</head>', `${og}</head>`);
50
51
  }
51
52
  // inline blocklet.js
52
- const blockletJs = (0, config_1.getBlockletJs)(pageGroup);
53
+ const blockletJs = (0, config_1.getBlockletJs)(pageGroup, pathPrefix);
53
54
  if (blockletJs) {
54
55
  source = source
55
56
  .replace('<script src="__blocklet__.js"></script>', `<script>${blockletJs}</script>`)
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.17-beta-7ec31a60",
6
+ "version": "1.16.17-beta-8cacb9b3",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
@@ -26,15 +26,15 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.16.17-beta-7ec31a60",
30
- "@abtnode/constant": "1.16.17-beta-7ec31a60",
29
+ "@abtnode/client": "1.16.17-beta-8cacb9b3",
30
+ "@abtnode/constant": "1.16.17-beta-8cacb9b3",
31
31
  "@arcblock/did": "1.18.91",
32
32
  "@arcblock/did-auth": "1.18.91",
33
33
  "@arcblock/jwt": "1.18.91",
34
34
  "@arcblock/ws": "1.18.91",
35
- "@blocklet/constant": "1.16.17-beta-7ec31a60",
36
- "@blocklet/env": "1.16.17-beta-7ec31a60",
37
- "@blocklet/meta": "1.16.17-beta-7ec31a60",
35
+ "@blocklet/constant": "1.16.17-beta-8cacb9b3",
36
+ "@blocklet/env": "1.16.17-beta-8cacb9b3",
37
+ "@blocklet/meta": "1.16.17-beta-8cacb9b3",
38
38
  "@did-connect/authenticator": "^2.2.0",
39
39
  "@did-connect/handler": "^2.2.0",
40
40
  "@nedb/core": "^2.1.5",
@@ -74,5 +74,5 @@
74
74
  "ts-node": "^10.9.1",
75
75
  "typescript": "^5.0.4"
76
76
  },
77
- "gitHead": "622bb131130d28c3fc554dcb5dc9d72b7da3fba2"
77
+ "gitHead": "0e3266f543b6d419a004ca94ee9efb572e3d9809"
78
78
  }