@blocklet/pages-kit 0.4.16-beta.20250309-3 → 0.4.17

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.
@@ -5,4 +5,5 @@ var PreloadComponentScriptModule;
5
5
  (function (PreloadComponentScriptModule) {
6
6
  PreloadComponentScriptModule["UMD_FN"] = "umd_fn";
7
7
  PreloadComponentScriptModule["ESM"] = "esm";
8
+ PreloadComponentScriptModule["CJS"] = "cjs";
8
9
  })(PreloadComponentScriptModule || (exports.PreloadComponentScriptModule = PreloadComponentScriptModule = {}));
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.injectESModulesShimsOptions = injectESModulesShimsOptions;
4
- function injectESModulesShimsOptions() {
4
+ function injectESModulesShimsOptions(options = {}) {
5
+ var _a;
5
6
  // if already initialized, return
6
- if (window.esmsInitOptions) {
7
+ if (window.esmsInitOptions && !options.force) {
7
8
  return;
8
9
  }
9
10
  window.esmsInitOptions = {
10
- shimMode: true,
11
+ // Notice: 不要修改 shimMode 的默认值,否则可能会影响到其他 blocklet 的正常使用
12
+ // default is false, do not enable es-module-shims
13
+ shimMode: (_a = options.shimMode) !== null && _a !== void 0 ? _a : false,
11
14
  polyfillEnable: ['css-modules', 'json-modules', 'wasm-modules', 'source-phase'],
12
- skip: ['crypto-browserify', 'crypto'],
13
- mapOverrides: true,
14
15
  };
15
16
  }
16
17
  // enable es-module-shims
@@ -31,6 +31,7 @@ require("es-module-shims");
31
31
  const react_1 = __importDefault(require("react"));
32
32
  const ufo_1 = require("ufo");
33
33
  const arcblockUx = __importStar(require("../builtin/arcblock/ux"));
34
+ const aiRuntime = __importStar(require("../builtin/async/ai-runtime"));
34
35
  const imagePreview = __importStar(require("../builtin/async/image-preview"));
35
36
  const reactMarkdown = __importStar(require("../builtin/async/react-markdown"));
36
37
  const reactScrollToBottom = __importStar(require("../builtin/async/react-scroll-to-bottom"));
@@ -65,6 +66,11 @@ function injectGlobalComponents() {
65
66
  return;
66
67
  }
67
68
  const enableShim = !!((_a = window === null || window === void 0 ? void 0 : window.esmsInitOptions) === null || _a === void 0 ? void 0 : _a.shimMode);
69
+ if (!enableShim) {
70
+ win.importShim.addImportMap = () => {
71
+ // avoid addImportMap error
72
+ };
73
+ }
68
74
  win.React = react_1.default;
69
75
  // create module map
70
76
  const modules = {
@@ -93,12 +99,7 @@ function injectGlobalComponents() {
93
99
  '@blocklet/pages-kit/builtin/async/react-markdown': reactMarkdown,
94
100
  '@blocklet/pages-kit/builtin/async/react-syntax-highlighter': reactSyntaxHighlighter,
95
101
  '@blocklet/pages-kit/builtin/async/image-preview': imagePreview,
96
- '@blocklet/pages-kit/builtin/async/ai-runtime': {
97
- get: () => Promise.resolve().then(() => __importStar(require('../builtin/async/ai-runtime'))).catch((err) => {
98
- console.error('Failed to load AI runtime', err);
99
- return {};
100
- }),
101
- },
102
+ '@blocklet/pages-kit/builtin/async/ai-runtime': aiRuntime,
102
103
  };
103
104
  // set global variable
104
105
  win[builtin_1.BuiltinModulesGlobalVariableName] = {
@@ -115,7 +116,7 @@ function injectGlobalComponents() {
115
116
  const fileName = module.split('/').pop();
116
117
  const fullUrl = (0, ufo_1.joinURL)(window.location.origin, ((_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || '/', 'chunks', fileName);
117
118
  if (enableShim) {
118
- const mod = window.importShim(fullUrl);
119
+ const mod = window.importShim(/* @vite-ignore */ fullUrl);
119
120
  return mod;
120
121
  }
121
122
  const mod = Promise.resolve(`${fullUrl}`).then(s => __importStar(require(s)));
@@ -138,7 +139,10 @@ function injectGlobalComponents() {
138
139
  let hash = 0;
139
140
  for (let i = 0; i < str.length; i++) {
140
141
  const char = str.charCodeAt(i);
141
- hash = hash * 2 ** 5 - hash + char;
142
+ // eslint-disable-next-line no-bitwise
143
+ hash = (hash << 5) - hash + char;
144
+ // eslint-disable-next-line no-bitwise
145
+ hash &= hash;
142
146
  }
143
147
  return hash.toString(16);
144
148
  };
@@ -152,7 +156,7 @@ function injectGlobalComponents() {
152
156
  const { hash, imports } = JSON.parse(cachedData);
153
157
  if (hash === moduleHash) {
154
158
  // eslint-disable-next-line no-console
155
- console.log(`getImportsFromCache: ${hash}`, imports);
159
+ console.info('load import map from cache', moduleHash);
156
160
  return imports; // 返回缓存的 imports
157
161
  }
158
162
  }
@@ -199,9 +203,10 @@ export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
199
203
  // fallback to create script tag
200
204
  const script = document.createElement('script');
201
205
  script.type = 'importmap';
202
- script.textContent = JSON.stringify(importMap);
206
+ script.textContent = JSON.stringify(importMap, null, 2);
203
207
  document.head.appendChild(script);
204
208
  }
209
+ win.importMap = importMap;
205
210
  };
206
211
  setupImportMap();
207
212
  }
@@ -1 +1 @@
1
- export { LocaleProvider, useLocaleContext } from '@arcblock/ux/lib/Locale/context';
1
+ export * from '@arcblock/ux/lib/Locale/context';
@@ -1 +1 @@
1
- export { LoadingButton } from '@mui/lab';
1
+ export * from '@mui/lab';
@@ -1 +1 @@
1
- export { Checkbox, ListItemText, Alert, AlertTitle, Autocomplete, Avatar, Box, Button, IconButton, ButtonGroup, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, CircularProgress, ClickAwayListener, Collapse, Container, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Fade, GlobalStyles, Grid, Grow, LinearProgress, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListSubheader, Menu, MenuItem, MenuList, Paper, Popper, Select, Slide, Stack, Switch, TextField, ThemeProvider, Tooltip, Typography, Zoom, alpha, createTheme, styled, useMediaQuery, useTheme, } from '@mui/material';
1
+ export * from '@mui/material';
@@ -1,5 +1 @@
1
- import { SessionContext } from '@arcblock/did-connect/lib/Session';
2
- import { useContext } from 'react';
3
- export function useSessionContext() {
4
- return useContext(SessionContext);
5
- }
1
+ export * from '@arcblock/did-connect/lib/Session';