@blocklet/pages-kit 0.4.16-beta.20250305 → 0.4.16-beta.20250305-2
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/components/index.js +2 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-es-module-shims-options.js +6 -9
- package/lib/cjs/utils/inject-global-components.js +15 -3
- package/lib/esm/components/index.js +2 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-es-module-shims-options.js +6 -9
- package/lib/esm/utils/inject-global-components.js +15 -3
- package/lib/types/components/index.d.ts +0 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/inject-es-module-shims-options.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
initShimsOptions();
|
|
2
|
+
window.esmsInitOptions = {
|
|
3
|
+
// Enable Shim Mode
|
|
4
|
+
shimMode: true,
|
|
5
|
+
// Enable polyfill features.
|
|
6
|
+
polyfillEnable: ['css-modules', 'json-modules', 'wasm-modules', 'source-phase'],
|
|
7
|
+
};
|
|
@@ -39,6 +39,7 @@ import { BuiltinModulesGlobalVariableName } from '../types/builtin';
|
|
|
39
39
|
// Initialize ES Module Shims before any imports
|
|
40
40
|
export function injectGlobalComponents() {
|
|
41
41
|
const win = window || {};
|
|
42
|
+
const importShim = win.importShim;
|
|
42
43
|
win.React = React;
|
|
43
44
|
// 创建模块映射
|
|
44
45
|
const modules = {
|
|
@@ -84,7 +85,10 @@ export function injectGlobalComponents() {
|
|
|
84
85
|
if (module.startsWith('./') || module.startsWith('../')) {
|
|
85
86
|
const fileName = module.split('/').pop();
|
|
86
87
|
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);
|
|
87
|
-
|
|
88
|
+
if (importShim) {
|
|
89
|
+
return yield importShim(fullUrl);
|
|
90
|
+
}
|
|
91
|
+
return yield import(/* @vite-ignore */ fullUrl);
|
|
88
92
|
}
|
|
89
93
|
return null;
|
|
90
94
|
});
|
|
@@ -111,8 +115,16 @@ export function injectGlobalComponents() {
|
|
|
111
115
|
const importMap = {
|
|
112
116
|
imports,
|
|
113
117
|
};
|
|
114
|
-
importShim.addImportMap
|
|
118
|
+
if (importShim === null || importShim === void 0 ? void 0 : importShim.addImportMap) {
|
|
119
|
+
importShim.addImportMap(importMap);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// fallback to create script tag
|
|
123
|
+
const script = document.createElement('script');
|
|
124
|
+
script.type = 'importmap';
|
|
125
|
+
script.textContent = JSON.stringify(importMap);
|
|
126
|
+
document.head.appendChild(script);
|
|
127
|
+
}
|
|
115
128
|
};
|
|
116
129
|
setupImportMap();
|
|
117
130
|
}
|
|
118
|
-
injectGlobalComponents();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import '../utils/inject-es-module-shims-options';
|
|
2
|
-
import '../utils/inject-global-components';
|
|
3
2
|
export { default as CustomComponentRenderer } from './CustomComponentRenderer';
|
|
4
3
|
export * from './CustomComponentRenderer';
|
|
5
4
|
export { default as ResponsiveImage } from './ResponsiveImage';
|