@blueking/bk-weweb 0.0.35 → 0.0.36-beta.16
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/dist/index.d.mts +649 -107
- package/dist/index.esm.js +2245 -1449
- package/dist/index.esm.js.map +1 -1
- package/dist/vite/helper.d.mts +11 -0
- package/dist/vite/helper.esm.js +50 -0
- package/dist/vite/helper.esm.js.map +1 -0
- package/package.json +3 -2
- package/readme.md +13 -13
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface WewebVitePluginOptions {
|
|
4
|
+
injectWindowKeys?: string[];
|
|
5
|
+
appKey: string;
|
|
6
|
+
}
|
|
7
|
+
declare function wewebVitePlugin(options: WewebVitePluginOptions): Plugin<{
|
|
8
|
+
version: string;
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
export { type WewebVitePluginOptions, wewebVitePlugin as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/vite/helper.ts
|
|
2
|
+
var viteGlobalInjectKeys = [
|
|
3
|
+
"window",
|
|
4
|
+
"globalThis",
|
|
5
|
+
"self",
|
|
6
|
+
"document",
|
|
7
|
+
"location",
|
|
8
|
+
"process",
|
|
9
|
+
"__VUE_OPTIONS_API__",
|
|
10
|
+
"__BK_WEWEB_APP_KEY__",
|
|
11
|
+
"__BK_WEWEB_DATA__",
|
|
12
|
+
"__POWERED_BY_BK_WEWEB__",
|
|
13
|
+
"__VUE_DEVTOOLS_HOOK_REPLAY__",
|
|
14
|
+
"__VUE_DEVTOOLS_PLUGINS__",
|
|
15
|
+
"__VUE_HMR_RUNTIME__",
|
|
16
|
+
"__VUE_INSTANCE_SETTERS__",
|
|
17
|
+
"__VUE_PROD_DEVTOOLS__",
|
|
18
|
+
"__VUE_PROD_HYDRATION_MISMATCH_DETAILS__",
|
|
19
|
+
"__VUE__",
|
|
20
|
+
"__bkui_vue_version__"
|
|
21
|
+
];
|
|
22
|
+
function wewebVitePlugin(options) {
|
|
23
|
+
if (!options.appKey) {
|
|
24
|
+
throw new Error("\u3010bk-weweb\u3011wewebVitePlugin appKey is required");
|
|
25
|
+
}
|
|
26
|
+
const injectCode = [...viteGlobalInjectKeys, ...options.injectWindowKeys || []].flat().map((key) => `var ${key} = top?.['${options.appKey}']?.${key} || top?.${key};`).join("");
|
|
27
|
+
const version = "1.0.0";
|
|
28
|
+
return {
|
|
29
|
+
name: "weweb-vite-plugin",
|
|
30
|
+
apply: "serve",
|
|
31
|
+
enforce: "post",
|
|
32
|
+
transform(code, id) {
|
|
33
|
+
if (false) {
|
|
34
|
+
const newCode = code;
|
|
35
|
+
return {
|
|
36
|
+
code: `
|
|
37
|
+
${injectCode}
|
|
38
|
+
${newCode}
|
|
39
|
+
`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return code;
|
|
43
|
+
},
|
|
44
|
+
version
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
wewebVitePlugin as default
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=helper.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/helper.ts"],"sourcesContent":["/*\n * Tencent is pleased to support the open source community by making\n * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.\n *\n * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.\n *\n * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.\n *\n * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):\n *\n * ---------------------------------------------------\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n * documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\n * to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of\n * the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO\n * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport type { Plugin } from 'vite';\n\nconst viteGlobalInjectKeys = [\n 'window',\n 'globalThis',\n 'self',\n 'document',\n 'location',\n 'process',\n '__VUE_OPTIONS_API__',\n '__BK_WEWEB_APP_KEY__',\n '__BK_WEWEB_DATA__',\n '__POWERED_BY_BK_WEWEB__',\n '__VUE_DEVTOOLS_HOOK_REPLAY__',\n '__VUE_DEVTOOLS_PLUGINS__',\n '__VUE_HMR_RUNTIME__',\n '__VUE_INSTANCE_SETTERS__',\n '__VUE_PROD_DEVTOOLS__',\n '__VUE_PROD_HYDRATION_MISMATCH_DETAILS__',\n '__VUE__',\n '__bkui_vue_version__',\n];\n\nexport interface WewebVitePluginOptions {\n injectWindowKeys?: string[];\n appKey: string;\n}\nexport default function wewebVitePlugin(options: WewebVitePluginOptions): Plugin<{\n version: string;\n}> {\n if (!options.appKey) {\n throw new Error('【bk-weweb】wewebVitePlugin appKey is required');\n }\n const injectCode = [...viteGlobalInjectKeys, ...(options.injectWindowKeys || [])]\n .flat()\n .map(key => `var ${key} = top?.['${options.appKey}']?.${key} || top?.${key};`)\n .join('');\n const version = '1.0.0';\n return {\n name: 'weweb-vite-plugin',\n apply: 'serve',\n enforce: 'post',\n transform(code, id) {\n if (process.env.NODE_ENV === 'development' && id.match(/\\.(js|ts|jsx|tsx|mjs|vue|css)/)) {\n const newCode = code;\n // // vite 对应.css 文件的特殊处理\n // if (id.includes('vite/dist/client/client.mjs')) {\n // newCode = code.replace(\n // 'const sheetsMap = new Map();',\n // `const sheetsMap = new Map(); window.__sheetsMap__ = sheetsMap; console.info(sheetsMap, '=================')`,\n // );\n // }\n return {\n code: `\n ${injectCode}\n ${newCode}\n `,\n };\n }\n return code;\n },\n version,\n };\n}\n"],"mappings":";AA4BA,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMe,SAAR,gBAAiC,SAErC;AACD,MAAI,CAAC,QAAQ,QAAQ;AACnB,UAAM,IAAI,MAAM,wDAA8C;AAAA,EAChE;AACA,QAAM,aAAa,CAAC,GAAG,sBAAsB,GAAI,QAAQ,oBAAoB,CAAC,CAAE,EAC7E,KAAK,EACL,IAAI,SAAO,OAAO,GAAG,aAAa,QAAQ,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,EAC5E,KAAK,EAAE;AACV,QAAM,UAAU;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU,MAAM,IAAI;AAClB,UAAI,OAAqF;AACvF,cAAM,UAAU;AAQhB,eAAO;AAAA,UACL,MAAM;AAAA,YACJ,UAAU;AAAA,YACV,OAAO;AAAA;AAAA,QAEX;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueking/bk-weweb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36-beta.16",
|
|
4
4
|
"description": "bk micro frontend web",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
@@ -66,9 +66,10 @@
|
|
|
66
66
|
"tslib": "^2.6.3",
|
|
67
67
|
"tsup": "^8.1.0",
|
|
68
68
|
"typescript": "^5.5.3",
|
|
69
|
+
"vite": "^7.1.9",
|
|
69
70
|
"vue-eslint-parser": "^9.4.3"
|
|
70
71
|
},
|
|
71
72
|
"engines": {
|
|
72
73
|
"node": ">=14.18.1"
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
+
}
|
package/readme.md
CHANGED
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
[](https://github.com/TencentBlueKing/bk-weweb/pulls)
|
|
10
10
|
|
|
11
11
|
[English](readme_en.md) | 简体中文
|
|
12
|
+
|
|
12
13
|
## Overview
|
|
13
14
|
|
|
14
15
|
️🔧 BlueKing bk-weweb 是一款跨框架、无依赖、可伸缩的 无任何侵入的支持微应用、微模块统一的轻量微前端框架工具
|
|
15
16
|
|
|
16
17
|
## Features
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
- [Basic] 支持多应用、多模块、及混合应用
|
|
20
|
+
- [Basic] bk-weweb webcomponent
|
|
21
|
+
- [Basic] 丰富简单的hooks
|
|
22
|
+
- [Basic] 支持预加载资源
|
|
23
|
+
- [Basic] 主应用与子应用、子模块之间共享缓存资源
|
|
23
24
|
|
|
24
25
|
## Getting started
|
|
25
26
|
|
|
@@ -33,10 +34,9 @@ $ npm install @blueking/bk-weweb
|
|
|
33
34
|
|
|
34
35
|
> 更多用法参考:[使用文档](https://github.com/TencentBlueKing/bk-weweb/blob/main/docs/docs/intro/hooks.md)
|
|
35
36
|
|
|
36
|
-
|
|
37
37
|
**基础用法**
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
```javascript
|
|
40
40
|
import '@blueking/bk-weweb'
|
|
41
41
|
|
|
42
42
|
// 微应用
|
|
@@ -44,12 +44,12 @@ import '@blueking/bk-weweb'
|
|
|
44
44
|
|
|
45
45
|
// 微模块
|
|
46
46
|
<bk-weweb mode='js' url='http://xxx.xx.x.js' />
|
|
47
|
-
|
|
47
|
+
```
|
|
48
48
|
|
|
49
49
|
**自定义微应用容器**
|
|
50
50
|
|
|
51
51
|
#### 1. 自定义微应用容器
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
<template>
|
|
54
54
|
<div class="bk-weweb">
|
|
55
55
|
<div ref="instanceWrap"/>
|
|
@@ -69,10 +69,10 @@ export default defineComponent({
|
|
|
69
69
|
showSourceCode: true,
|
|
70
70
|
scopeCss: true,
|
|
71
71
|
scopeLocation: true,
|
|
72
|
-
|
|
72
|
+
setShadowDom: true,
|
|
73
73
|
keepAlive: false,
|
|
74
74
|
data: {
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
mount(appKey, instanceWrap.value)
|
|
@@ -93,7 +93,6 @@ export default defineComponent({
|
|
|
93
93
|
height: 200px;
|
|
94
94
|
}
|
|
95
95
|
</style>
|
|
96
|
-
```
|
|
97
96
|
|
|
98
97
|
#### 2. 自定义微模块容器
|
|
99
98
|
|
|
@@ -157,6 +156,7 @@ export default defineComponent({
|
|
|
157
156
|
- [蓝鲸社区版交流群](https://jq.qq.com/?_wv=1027&k=5zk8F7G)
|
|
158
157
|
|
|
159
158
|
## BlueKing Community
|
|
159
|
+
|
|
160
160
|
- [BKUI-VUE2](https://github.com/TencentBlueKing/bkui-vue2):蓝鲸Vue2.0版本组件库。
|
|
161
161
|
- [BKUI-VUE3](https://github.com/TencentBlueKing/bkui-vue3):蓝鲸Vue3.0版本组件库。
|
|
162
162
|
- [BK-CMDB](https://github.com/Tencent/bk-cmdb):蓝鲸配置平台(蓝鲸 CMDB)是一个面向资产及应用的企业级配置管理平台。
|
|
@@ -168,7 +168,7 @@ export default defineComponent({
|
|
|
168
168
|
|
|
169
169
|
## Contributing
|
|
170
170
|
|
|
171
|
-
如果你有好的意见或建议,欢迎给我们提 Issues 或 Pull Requests,为蓝鲸开源社区贡献力量。
|
|
171
|
+
如果你有好的意见或建议,欢迎给我们提 Issues 或 Pull Requests,为蓝鲸开源社区贡献力量。
|
|
172
172
|
[腾讯开源激励计划](https://opensource.tencent.com/contribution) 鼓励开发者的参与和贡献,期待你的加入。
|
|
173
173
|
|
|
174
174
|
## License
|