@blocklet/pages-kit 0.4.84 → 0.4.86
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/CustomComponentRenderer/state.js +2 -2
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +9 -6
- package/lib/cjs/utils/typescript/builtin-module-transformer.js +4 -4
- package/lib/esm/components/CustomComponentRenderer/state.js +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +9 -6
- package/lib/esm/utils/typescript/builtin-module-transformer.js +2 -2
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/typescript/builtin-module-transformer.d.ts +1 -1
- package/package.json +3 -3
|
@@ -106,13 +106,16 @@ function injectGlobalComponents() {
|
|
|
106
106
|
modules,
|
|
107
107
|
require(module) {
|
|
108
108
|
// handle builtin module
|
|
109
|
-
const builtinModule =
|
|
109
|
+
const builtinModule = win[builtin_1.BuiltinModulesGlobalVariableName].modules[module];
|
|
110
|
+
const mergeModuleExports = (mod) => ({
|
|
111
|
+
...(mod.default ? { ...mod.default } : {}),
|
|
112
|
+
...mod,
|
|
113
|
+
});
|
|
114
|
+
if (builtinModule instanceof Promise) {
|
|
115
|
+
return builtinModule.then(mergeModuleExports);
|
|
116
|
+
}
|
|
110
117
|
if (builtinModule) {
|
|
111
|
-
return
|
|
112
|
-
// 针对某些包,比如 react-dom,需要同时导出 default 和非 default 的值
|
|
113
|
-
...(builtinModule.default ? { ...builtinModule.default } : {}),
|
|
114
|
-
...builtinModule,
|
|
115
|
-
};
|
|
118
|
+
return mergeModuleExports(builtinModule);
|
|
116
119
|
}
|
|
117
120
|
// handle relative path import
|
|
118
121
|
if ((0, builtin_module_transformer_1.isRelativeModule)(module)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBuiltinModuleTransformer = exports.
|
|
3
|
+
exports.createBuiltinModuleTransformer = exports.isAsyncModule = exports.isRelativeModule = void 0;
|
|
4
4
|
const builtin_1 = require("../../types/builtin");
|
|
5
5
|
const isRelativeModule = (moduleSpecifier) => {
|
|
6
6
|
if (!moduleSpecifier) {
|
|
@@ -9,13 +9,13 @@ const isRelativeModule = (moduleSpecifier) => {
|
|
|
9
9
|
return moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../');
|
|
10
10
|
};
|
|
11
11
|
exports.isRelativeModule = isRelativeModule;
|
|
12
|
-
const
|
|
12
|
+
const isAsyncModule = (moduleSpecifier) => {
|
|
13
13
|
if (!moduleSpecifier) {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
return ['@blocklet/pages-kit/builtin/async/ai-runtime'].includes(moduleSpecifier);
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
18
|
+
exports.isAsyncModule = isAsyncModule;
|
|
19
19
|
const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
20
20
|
const { factory } = context;
|
|
21
21
|
// 统一的模块导入收集器
|
|
@@ -61,7 +61,7 @@ const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
61
61
|
// call inject-global-components require method
|
|
62
62
|
const requireCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(builtin_1.BuiltinModulesGlobalVariableName), 'require'), undefined, [factory.createStringLiteral(importInfo.moduleName)]);
|
|
63
63
|
// create await expression if the module is ../ or ./
|
|
64
|
-
const mod = (0, exports.isRelativeModule)(importInfo.moduleName) || (0, exports.
|
|
64
|
+
const mod = (0, exports.isRelativeModule)(importInfo.moduleName) || (0, exports.isAsyncModule)(importInfo.moduleName)
|
|
65
65
|
? factory.createAwaitExpression(requireCall)
|
|
66
66
|
: requireCall;
|
|
67
67
|
return [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from '@emotion/css';
|
|
3
3
|
import { Skeleton, Fade, Box } from '@mui/material';
|
|
4
|
-
import
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
5
|
import set from 'lodash/set';
|
|
6
6
|
import { useDeferredValue, useEffect, useRef, useState, useMemo } from 'react';
|
|
7
7
|
import { Helmet } from 'react-helmet';
|