@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.
- package/lib/cjs/builtin/locale.js +15 -4
- package/lib/cjs/builtin/mui/lab.js +15 -3
- package/lib/cjs/builtin/mui/material.js +15 -60
- package/lib/cjs/builtin/session.js +15 -6
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/types/api.js +1 -0
- package/lib/cjs/utils/inject-es-module-shims-options.js +6 -5
- package/lib/cjs/utils/inject-global-components.js +15 -10
- package/lib/esm/builtin/locale.js +1 -1
- package/lib/esm/builtin/mui/lab.js +1 -1
- package/lib/esm/builtin/mui/material.js +1 -1
- package/lib/esm/builtin/session.js +1 -5
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/types/api.js +1 -0
- package/lib/esm/utils/inject-es-module-shims-options.js +6 -5
- package/lib/esm/utils/inject-global-components.js +15 -10
- package/lib/types/builtin/locale.d.ts +1 -1
- package/lib/types/builtin/mui/lab.d.ts +1 -1
- package/lib/types/builtin/mui/material.d.ts +1 -1
- package/lib/types/builtin/session.d.ts +1 -13
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/api.d.ts +6 -1
- package/lib/types/utils/inject-es-module-shims-options.d.ts +4 -1
- package/package.json +8 -8
package/lib/esm/types/api.js
CHANGED
|
@@ -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
|
-
|
|
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);
|
|
@@ -109,7 +110,10 @@ export function injectGlobalComponents() {
|
|
|
109
110
|
let hash = 0;
|
|
110
111
|
for (let i = 0; i < str.length; i++) {
|
|
111
112
|
const char = str.charCodeAt(i);
|
|
112
|
-
|
|
113
|
+
// eslint-disable-next-line no-bitwise
|
|
114
|
+
hash = (hash << 5) - hash + char;
|
|
115
|
+
// eslint-disable-next-line no-bitwise
|
|
116
|
+
hash &= hash;
|
|
113
117
|
}
|
|
114
118
|
return hash.toString(16);
|
|
115
119
|
};
|
|
@@ -123,7 +127,7 @@ export function injectGlobalComponents() {
|
|
|
123
127
|
const { hash, imports } = JSON.parse(cachedData);
|
|
124
128
|
if (hash === moduleHash) {
|
|
125
129
|
// eslint-disable-next-line no-console
|
|
126
|
-
console.
|
|
130
|
+
console.info('load import map from cache', moduleHash);
|
|
127
131
|
return imports; // 返回缓存的 imports
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -170,9 +174,10 @@ export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
|
|
|
170
174
|
// fallback to create script tag
|
|
171
175
|
const script = document.createElement('script');
|
|
172
176
|
script.type = 'importmap';
|
|
173
|
-
script.textContent = JSON.stringify(importMap);
|
|
177
|
+
script.textContent = JSON.stringify(importMap, null, 2);
|
|
174
178
|
document.head.appendChild(script);
|
|
175
179
|
}
|
|
180
|
+
win.importMap = importMap;
|
|
176
181
|
};
|
|
177
182
|
setupImportMap();
|
|
178
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@arcblock/ux/lib/Locale/context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@mui/lab';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@mui/material';
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export
|
|
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';
|