@blocklet/pages-kit 0.6.7 → 0.6.8
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/utils.js +9 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/cjs/utils/preload.js +0 -2
- package/lib/cjs/utils/typescript/builtin-module-transformer.js +23 -20
- package/lib/esm/builtin/utils.js +9 -3
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/esm/utils/preload.js +0 -2
- package/lib/esm/utils/typescript/builtin-module-transformer.js +22 -18
- package/lib/types/builtin/utils.d.ts +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/api.d.ts +13 -12
- package/lib/types/types/core.d.ts +1 -0
- package/lib/types/utils/typescript/builtin-module-transformer.d.ts +0 -1
- package/package.json +2 -2
package/lib/cjs/utils/preload.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const path_1 = require("path");
|
|
3
|
+
exports.createBuiltinModuleTransformer = exports.isBuiltinModule = exports.isAsyncModule = exports.isRelativeModule = void 0;
|
|
5
4
|
const builtin_1 = require("../../types/builtin");
|
|
6
5
|
const isRelativeModule = (moduleSpecifier) => {
|
|
7
6
|
if (!moduleSpecifier) {
|
|
@@ -91,21 +90,25 @@ const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
91
90
|
return factory.updateSourceFile(file, statements);
|
|
92
91
|
};
|
|
93
92
|
exports.createBuiltinModuleTransformer = createBuiltinModuleTransformer;
|
|
94
|
-
const createWellKnownChunksTransformer =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
93
|
+
// export const createWellKnownChunksTransformer =
|
|
94
|
+
// (ts: typeof import('typescript')): TransformerFactory<SourceFile> =>
|
|
95
|
+
// (context) =>
|
|
96
|
+
// (file) => {
|
|
97
|
+
// const { factory } = context;
|
|
98
|
+
// // 转换所有导入声明
|
|
99
|
+
// const transformedStatements = file.statements.map((node) => {
|
|
100
|
+
// if (
|
|
101
|
+
// ts.isImportDeclaration(node) &&
|
|
102
|
+
// ts.isStringLiteral(node.moduleSpecifier) &&
|
|
103
|
+
// isRelativeModule(node.moduleSpecifier.text)
|
|
104
|
+
// ) {
|
|
105
|
+
// const moduleSpecifier = node.moduleSpecifier.text;
|
|
106
|
+
// const fileName = basename(moduleSpecifier);
|
|
107
|
+
// const newPath = `/.well-known/chunks/${fileName}`;
|
|
108
|
+
// // 创建新的导入声明
|
|
109
|
+
// return factory.createImportDeclaration(node.modifiers, node.importClause, factory.createStringLiteral(newPath));
|
|
110
|
+
// }
|
|
111
|
+
// return node;
|
|
112
|
+
// });
|
|
113
|
+
// return factory.updateSourceFile(file, transformedStatements);
|
|
114
|
+
// };
|
package/lib/esm/builtin/utils.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { joinURL } from 'ufo';
|
|
2
2
|
export { joinURL, withQuery, getQuery } from 'ufo';
|
|
3
3
|
export function getComponentMountPoint(name) {
|
|
4
|
+
let mountPoints = globalThis.blocklet?.componentMountPoints || [];
|
|
5
|
+
// 如果是在 server 端,则从环境变量中获取 mount points
|
|
4
6
|
if (typeof window === 'undefined') {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
try {
|
|
8
|
+
mountPoints = JSON.parse(process.env.BLOCKLET_MOUNT_POINTS || '[]');
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
// ignore error
|
|
12
|
+
}
|
|
7
13
|
}
|
|
8
|
-
return
|
|
14
|
+
return mountPoints?.find((i) => i.name === name || i.did === name)?.mountPoint || '';
|
|
9
15
|
}
|
|
10
16
|
export function getMediaKitAbsoluteUrl(url) {
|
|
11
17
|
if (url && url.startsWith('mediakit://') && typeof window !== 'undefined') {
|