@blocklet/pages-kit 0.6.7 → 0.6.9

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.
@@ -9,11 +9,17 @@ Object.defineProperty(exports, "joinURL", { enumerable: true, get: function () {
9
9
  Object.defineProperty(exports, "withQuery", { enumerable: true, get: function () { return ufo_2.withQuery; } });
10
10
  Object.defineProperty(exports, "getQuery", { enumerable: true, get: function () { return ufo_2.getQuery; } });
11
11
  function getComponentMountPoint(name) {
12
- if (typeof window === 'undefined') {
13
- // eslint-disable-next-line global-require
14
- return require('@blocklet/sdk/lib/component').getComponentMountPoint(name);
12
+ let mountPoints = globalThis.blocklet?.componentMountPoints || [];
13
+ // 如果是在 server 端,则尝试从环境变量中获取 mount points
14
+ if (!mountPoints?.length && typeof window === 'undefined') {
15
+ try {
16
+ mountPoints = JSON.parse(process.env.BLOCKLET_MOUNT_POINTS || '[]');
17
+ }
18
+ catch (error) {
19
+ // ignore error
20
+ }
15
21
  }
16
- return globalThis.blocklet?.componentMountPoints.find((i) => i.name === name || i.did === name)?.mountPoint;
22
+ return mountPoints?.find((i) => i.name === name || i.did === name)?.mountPoint || '';
17
23
  }
18
24
  function getMediaKitAbsoluteUrl(url) {
19
25
  if (url && url.startsWith('mediakit://') && typeof window !== 'undefined') {