@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
+ };
@@ -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
- return yield importShim(fullUrl);
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(importMap);
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';