@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.
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- function initShimsOptions() {
3
- window.esmsInitOptions = {
4
- // Enable Shim Mode
5
- shimMode: true,
6
- // Enable polyfill features.
7
- polyfillEnable: ['css-modules', 'json-modules', 'wasm-modules', 'source-phase'],
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
+ };
@@ -68,6 +68,7 @@ const builtin_1 = require("../types/builtin");
68
68
  // Initialize ES Module Shims before any imports
69
69
  function injectGlobalComponents() {
70
70
  const win = window || {};
71
+ const importShim = win.importShim;
71
72
  win.React = react_1.default;
72
73
  // 创建模块映射
73
74
  const modules = {
@@ -113,7 +114,10 @@ function injectGlobalComponents() {
113
114
  if (module.startsWith('./') || module.startsWith('../')) {
114
115
  const fileName = module.split('/').pop();
115
116
  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);
116
- return yield importShim(fullUrl);
117
+ if (importShim) {
118
+ return yield importShim(fullUrl);
119
+ }
120
+ return yield Promise.resolve(`${fullUrl}`).then(s => __importStar(require(s)));
117
121
  }
118
122
  return null;
119
123
  });
@@ -140,8 +144,16 @@ function injectGlobalComponents() {
140
144
  const importMap = {
141
145
  imports,
142
146
  };
143
- importShim.addImportMap(importMap);
147
+ if (importShim === null || importShim === void 0 ? void 0 : importShim.addImportMap) {
148
+ importShim.addImportMap(importMap);
149
+ }
150
+ else {
151
+ // fallback to create script tag
152
+ const script = document.createElement('script');
153
+ script.type = 'importmap';
154
+ script.textContent = JSON.stringify(importMap);
155
+ document.head.appendChild(script);
156
+ }
144
157
  };
145
158
  setupImportMap();
146
159
  }
147
- injectGlobalComponents();
@@ -1,5 +1,6 @@
1
1
  import '../utils/inject-es-module-shims-options';
2
- import '../utils/inject-global-components';
2
+ import { injectGlobalComponents } from '../utils/inject-global-components';
3
3
  export { default as CustomComponentRenderer } from './CustomComponentRenderer';
4
4
  export * from './CustomComponentRenderer';
5
5
  export { default as ResponsiveImage } from './ResponsiveImage';
6
+ injectGlobalComponents();