@blocklet/pages-kit 0.4.16 → 0.4.22

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.
@@ -2,4 +2,5 @@ export var PreloadComponentScriptModule;
2
2
  (function (PreloadComponentScriptModule) {
3
3
  PreloadComponentScriptModule["UMD_FN"] = "umd_fn";
4
4
  PreloadComponentScriptModule["ESM"] = "esm";
5
+ PreloadComponentScriptModule["CJS"] = "cjs";
5
6
  })(PreloadComponentScriptModule || (PreloadComponentScriptModule = {}));
@@ -1,13 +1,14 @@
1
- export function injectESModulesShimsOptions() {
1
+ export function injectESModulesShimsOptions(options = {}) {
2
+ var _a;
2
3
  // if already initialized, return
3
- if (window.esmsInitOptions) {
4
+ if (window.esmsInitOptions && !options.force) {
4
5
  return;
5
6
  }
6
7
  window.esmsInitOptions = {
7
- shimMode: true,
8
+ // Notice: 不要修改 shimMode 的默认值,否则可能会影响到其他 blocklet 的正常使用
9
+ // default is false, do not enable es-module-shims
10
+ shimMode: (_a = options.shimMode) !== null && _a !== void 0 ? _a : false,
8
11
  polyfillEnable: ['css-modules', 'json-modules', 'wasm-modules', 'source-phase'],
9
- skip: ['crypto-browserify', 'crypto'],
10
- mapOverrides: true,
11
12
  };
12
13
  }
13
14
  // enable es-module-shims
@@ -2,6 +2,7 @@ import 'es-module-shims';
2
2
  import React from 'react';
3
3
  import { joinURL } from 'ufo';
4
4
  import * as arcblockUx from '../builtin/arcblock/ux';
5
+ import * as aiRuntime from '../builtin/async/ai-runtime';
5
6
  import * as imagePreview from '../builtin/async/image-preview';
6
7
  import * as reactMarkdown from '../builtin/async/react-markdown';
7
8
  import * as reactScrollToBottom from '../builtin/async/react-scroll-to-bottom';
@@ -36,6 +37,11 @@ export function injectGlobalComponents() {
36
37
  return;
37
38
  }
38
39
  const enableShim = !!((_a = window === null || window === void 0 ? void 0 : window.esmsInitOptions) === null || _a === void 0 ? void 0 : _a.shimMode);
40
+ if (!enableShim) {
41
+ win.importShim.addImportMap = () => {
42
+ // avoid addImportMap error
43
+ };
44
+ }
39
45
  win.React = React;
40
46
  // create module map
41
47
  const modules = {
@@ -64,12 +70,7 @@ export function injectGlobalComponents() {
64
70
  '@blocklet/pages-kit/builtin/async/react-markdown': reactMarkdown,
65
71
  '@blocklet/pages-kit/builtin/async/react-syntax-highlighter': reactSyntaxHighlighter,
66
72
  '@blocklet/pages-kit/builtin/async/image-preview': imagePreview,
67
- '@blocklet/pages-kit/builtin/async/ai-runtime': {
68
- get: () => import('../builtin/async/ai-runtime').catch((err) => {
69
- console.error('Failed to load AI runtime', err);
70
- return {};
71
- }),
72
- },
73
+ '@blocklet/pages-kit/builtin/async/ai-runtime': aiRuntime,
73
74
  };
74
75
  // set global variable
75
76
  win[BuiltinModulesGlobalVariableName] = {
@@ -86,7 +87,7 @@ export function injectGlobalComponents() {
86
87
  const fileName = module.split('/').pop();
87
88
  const fullUrl = joinURL(window.location.origin, ((_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || '/', 'chunks', fileName);
88
89
  if (enableShim) {
89
- const mod = window.importShim(fullUrl);
90
+ const mod = window.importShim(/* @vite-ignore */ fullUrl);
90
91
  return mod;
91
92
  }
92
93
  const mod = import(/* @vite-ignore */ fullUrl);
@@ -125,6 +126,8 @@ export function injectGlobalComponents() {
125
126
  if (cachedData) {
126
127
  const { hash, imports } = JSON.parse(cachedData);
127
128
  if (hash === moduleHash) {
129
+ // eslint-disable-next-line no-console
130
+ console.info('load import map from cache', moduleHash);
128
131
  return imports; // 返回缓存的 imports
129
132
  }
130
133
  }
@@ -171,9 +174,10 @@ export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
171
174
  // fallback to create script tag
172
175
  const script = document.createElement('script');
173
176
  script.type = 'importmap';
174
- script.textContent = JSON.stringify(importMap);
177
+ script.textContent = JSON.stringify(importMap, null, 2);
175
178
  document.head.appendChild(script);
176
179
  }
180
+ win.importMap = importMap;
177
181
  };
178
182
  setupImportMap();
179
183
  }
@@ -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,13 +1 @@
1
- export declare function useSessionContext(): {
2
- session: {
3
- user?: {
4
- did: string;
5
- fullName: string;
6
- avatar: string;
7
- role: string;
8
- };
9
- loading?: boolean;
10
- login: (cb?: () => void) => any;
11
- };
12
- events: any;
13
- };
1
+ export * from '@arcblock/did-connect/lib/Session';