boke-devops 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- package/.vscode/settings.json +2 -0
- package/lerna.json +4 -0
- package/package.json +43 -0
- package/packages/boke-devops-vue/.eslintrc.cjs +22 -0
- package/packages/boke-devops-vue/README.md +45 -0
- package/packages/boke-devops-vue/demo/App.vue +62 -0
- package/packages/boke-devops-vue/demo/main.ts +7 -0
- package/packages/boke-devops-vue/package-lock.json +13513 -0
- package/packages/boke-devops-vue/package.json +59 -0
- package/packages/boke-devops-vue/pnpm-lock.yaml +6063 -0
- package/packages/boke-devops-vue/src/AegisUser/__tests__/Avatar.test.js +18 -0
- package/packages/boke-devops-vue/src/AegisUser/__tests__/__snapshots__/Avatar.test.js.snap +60 -0
- package/packages/boke-devops-vue/src/AegisUser/multiple-user-select.vue +190 -0
- package/packages/boke-devops-vue/src/AegisUser/store.ts +23 -0
- package/packages/boke-devops-vue/src/AegisUser/user-avatar-group.vue +76 -0
- package/packages/boke-devops-vue/src/AegisUser/user-avatar.vue +347 -0
- package/packages/boke-devops-vue/src/Microapp/MicroAppProvider.vue +50 -0
- package/packages/boke-devops-vue/src/Provider/Provider.vue +22 -0
- package/packages/boke-devops-vue/src/Provider/store.ts +23 -0
- package/packages/boke-devops-vue/src/global.d.ts +43 -0
- package/packages/boke-devops-vue/src/index.ts +39 -0
- package/packages/boke-devops-vue/src/style/variables.less +79 -0
- package/packages/boke-devops-vue/tsconfig.json +34 -0
- package/packages/boke-devops-vue/tsconfig.web.json +20 -0
- package/packages/boke-devops-vue/types/AegisUser/multiple-user-select.vue.d.ts +97 -0
- package/packages/boke-devops-vue/types/AegisUser/store.d.ts +7 -0
- package/packages/boke-devops-vue/types/AegisUser/user-avatar-group.vue.d.ts +44 -0
- package/packages/boke-devops-vue/types/AegisUser/user-avatar.vue.d.ts +217 -0
- package/packages/boke-devops-vue/types/Microapp/MicroAppProvider.vue.d.ts +39 -0
- package/packages/boke-devops-vue/types/Provider/Provider.vue.d.ts +63 -0
- package/packages/boke-devops-vue/types/Provider/store.d.ts +15 -0
- package/packages/boke-devops-vue/types/index.d.ts +13 -0
- package/packages/boke-devops-vue/types/store.d.ts +12 -0
- package/packages/boke-devops-vue/vite.config.ts +90 -0
- package/packages/boke-docs/.dumirc.ts +64 -0
- package/packages/boke-docs/.eslintrc.js +14 -0
- package/packages/boke-docs/.fatherrc.ts +7 -0
- package/packages/boke-docs/README.md +1 -0
- package/packages/boke-docs/docs/components/Avatar/demo/normal.vue +25 -0
- package/packages/boke-docs/docs/components/Avatar/demo/with_provider.vue +38 -0
- package/packages/boke-docs/docs/components/Avatar/index.md +10 -0
- package/packages/boke-docs/docs/components/UserSelect/demo/normal.vue +34 -0
- package/packages/boke-docs/docs/components/UserSelect/demo/with_provider.vue +40 -0
- package/packages/boke-docs/docs/components/UserSelect/index.md +12 -0
- package/packages/boke-docs/docs/components/index.md +126 -0
- package/packages/boke-docs/docs/framework-test/external/App.vue +303 -0
- package/packages/boke-docs/docs/framework-test/index.md +96 -0
- package/packages/boke-docs/docs/index.md +50 -0
- package/packages/boke-docs/node_modules/.bin/acorn +17 -0
- package/packages/boke-docs/node_modules/.bin/acorn.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/acorn.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/browserslist +17 -0
- package/packages/boke-docs/node_modules/.bin/browserslist.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/browserslist.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/dumi +17 -0
- package/packages/boke-docs/node_modules/.bin/dumi.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/dumi.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/eslint +17 -0
- package/packages/boke-docs/node_modules/.bin/eslint.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/eslint.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/prettier +17 -0
- package/packages/boke-docs/node_modules/.bin/prettier.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/prettier.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/stylelint +17 -0
- package/packages/boke-docs/node_modules/.bin/stylelint.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/stylelint.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/tsc +17 -0
- package/packages/boke-docs/node_modules/.bin/tsc.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/tsc.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/tsserver +17 -0
- package/packages/boke-docs/node_modules/.bin/tsserver.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/tsserver.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/vite +17 -0
- package/packages/boke-docs/node_modules/.bin/vite.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/vite.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/webpack +17 -0
- package/packages/boke-docs/node_modules/.bin/webpack.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/webpack.ps1 +41 -0
- package/packages/boke-docs/package.json +38 -0
- package/packages/boke-docs/pnpm-lock.yaml +11506 -0
- package/packages/boke-docs/tsconfig.json +14 -0
- package/packages/boke-docs/tsconfig.vue.json +10 -0
- package/packages/boke-js-bridge/es/child.d.ts +27 -0
- package/packages/boke-js-bridge/es/child.js +144 -0
- package/packages/boke-js-bridge/es/index.d.ts +3 -0
- package/packages/boke-js-bridge/es/index.js +3 -0
- package/packages/boke-js-bridge/es/parent.d.ts +24 -0
- package/packages/boke-js-bridge/es/parent.js +71 -0
- package/packages/boke-js-bridge/es/utils.d.ts +2 -0
- package/packages/boke-js-bridge/es/utils.js +6 -0
- package/packages/boke-js-bridge/package-lock.json +2028 -0
- package/packages/boke-js-bridge/package.json +35 -0
- package/packages/boke-js-bridge/readme.md +11 -0
- package/packages/boke-js-bridge/src/child.ts +174 -0
- package/packages/boke-js-bridge/src/index.ts +3 -0
- package/packages/boke-js-bridge/src/parent.ts +92 -0
- package/packages/boke-js-bridge/src/utils.ts +15 -0
- package/packages/boke-js-bridge/tsconfig.json +26 -0
- package/packages/boke-js-bridge/typings.d.ts +4 -0
- package/packages/boke-js-bridge/umd/child.js +156 -0
- package/packages/boke-js-bridge/umd/index.js +18 -0
- package/packages/boke-js-bridge/umd/parent.js +84 -0
- package/packages/boke-js-bridge/umd/utils.js +18 -0
- package/packages/test/Provider-test.vue +85 -0
- package/pnpm-workspace.yaml +2 -0
- package/scripts/configs.mjs +52 -0
- package/scripts/index.mjs +43 -0
- package/scripts/release.mjs +16 -0
- package/test-setup.js +24 -0
- package/vite.config.ts +21 -0
- package/vitest.config.js +22 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"baseUrl": "./",
|
4
|
+
"paths": {
|
5
|
+
"@devops/boke-docs": ["./src"],
|
6
|
+
"@devops/boke-devops-vue": ["./../boke-devops-vue"]
|
7
|
+
},
|
8
|
+
"allowJs": true,
|
9
|
+
"jsx": "preserve",
|
10
|
+
"jsxImportSource": "vue",
|
11
|
+
"strictNullChecks": false
|
12
|
+
},
|
13
|
+
"include": [".dumirc.ts", "src/**/*", "docs/**/*"]
|
14
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
interface ChildMethods {
|
2
|
+
/*** 获取授权 */
|
3
|
+
getAuthorization: () => Promise<any>;
|
4
|
+
/*** 获取用户信息 */
|
5
|
+
getUserInfo: () => Promise<any>;
|
6
|
+
/*** 获取自定义事件的数据 */
|
7
|
+
fetchCustomData: (tokenName /*** 获取授权 */: any) => Promise<any>;
|
8
|
+
/*** 触发parent的事件 */
|
9
|
+
triggerEvent: (methodName: string, methodData?: any) => any;
|
10
|
+
/**事件挂载函数到Child */
|
11
|
+
$on: (methodName: string, cb: (data: string) => void) => void;
|
12
|
+
/**事件移除函数到Child */
|
13
|
+
$off: (methodName: string) => void;
|
14
|
+
/**事件挂载函数到Child, 包含Parent回调函数 */
|
15
|
+
$onCallback: (methodName: string, cb: (data: string) => void) => void;
|
16
|
+
/**事件移除函数到Child, 包含Parent回调函数 */
|
17
|
+
$offCallback: (methodName: string) => void;
|
18
|
+
goPage: (path: string, params: any) => void;
|
19
|
+
refreshTag: () => void;
|
20
|
+
/*** 关闭弹窗 */
|
21
|
+
closeModal: () => void;
|
22
|
+
toast: (msg: string) => void;
|
23
|
+
cacheData: any;
|
24
|
+
version: string;
|
25
|
+
}
|
26
|
+
declare const _default: ChildMethods;
|
27
|
+
export default _default;
|
@@ -0,0 +1,144 @@
|
|
1
|
+
import * as tslib_1 from "tslib";
|
2
|
+
import { childLogger } from './utils';
|
3
|
+
const ChildHanlder = () => {
|
4
|
+
let methods = {};
|
5
|
+
const triggerAppEvent = (eventName, eventData) => {
|
6
|
+
const webviewBridge = window || null;
|
7
|
+
if (!webviewBridge && window.bokeJsBridge) {
|
8
|
+
alert('请在 boke 中运行此页面!');
|
9
|
+
}
|
10
|
+
else {
|
11
|
+
const postdata = {
|
12
|
+
eventName: eventName,
|
13
|
+
eventData: eventData,
|
14
|
+
msgScoped: "boke-JS-BRIDGE"
|
15
|
+
};
|
16
|
+
childLogger("boke-JS-BRIDGE", `postMessage to ParentSdk: ${postdata}`);
|
17
|
+
webviewBridge.parent.postMessage(JSON.stringify(postdata), '*');
|
18
|
+
}
|
19
|
+
};
|
20
|
+
methods.goPage = (path = '', params = {}) => {
|
21
|
+
triggerAppEvent('goPage', { path, params });
|
22
|
+
};
|
23
|
+
methods.refreshTag = () => {
|
24
|
+
triggerAppEvent('refreshTag', {});
|
25
|
+
};
|
26
|
+
methods.closeModal = () => {
|
27
|
+
triggerAppEvent('closeModal', {});
|
28
|
+
};
|
29
|
+
methods.toast = (text = '你触发了一个提示!') => {
|
30
|
+
triggerAppEvent('toast', text);
|
31
|
+
};
|
32
|
+
methods.$on = (eventName, callback) => {
|
33
|
+
window.messageArray.set(eventName, (eventData) => {
|
34
|
+
callback(eventData);
|
35
|
+
});
|
36
|
+
};
|
37
|
+
methods.$off = (eventName) => {
|
38
|
+
window.messageArray.delete(eventName);
|
39
|
+
};
|
40
|
+
methods.$onCallback = (eventName, callback) => {
|
41
|
+
methods.$on(eventName + '@Callback', callback);
|
42
|
+
};
|
43
|
+
methods.$offCallback = (eventName) => {
|
44
|
+
methods.$off(eventName + '@Callback');
|
45
|
+
};
|
46
|
+
methods.cacheData = {};
|
47
|
+
methods.version = '0.0.1';
|
48
|
+
const cratePromise = (asyncName, timeout = 1200) => {
|
49
|
+
let result = {
|
50
|
+
status: "pending",
|
51
|
+
data: null,
|
52
|
+
err: null
|
53
|
+
};
|
54
|
+
let pro = new Promise((resolve, rejected) => {
|
55
|
+
let autoTimer;
|
56
|
+
const callback = (eventData) => {
|
57
|
+
autoTimer && clearTimeout(autoTimer);
|
58
|
+
methods.$offCallback(asyncName);
|
59
|
+
resolve(eventData);
|
60
|
+
};
|
61
|
+
autoTimer = setTimeout(() => {
|
62
|
+
callback(null);
|
63
|
+
}, timeout); // 1.2秒内没有应答 直接结束.
|
64
|
+
methods.$onCallback(asyncName, callback);
|
65
|
+
triggerAppEvent(asyncName, null);
|
66
|
+
}).then(res => {
|
67
|
+
result.data = res;
|
68
|
+
result.status = "fulfiled";
|
69
|
+
methods.cacheData[asyncName] = result;
|
70
|
+
return result;
|
71
|
+
}).catch(e => {
|
72
|
+
result.err = e;
|
73
|
+
result.status = "rejected";
|
74
|
+
methods.cacheData[asyncName] = result;
|
75
|
+
return result;
|
76
|
+
});
|
77
|
+
return pro;
|
78
|
+
};
|
79
|
+
function withAsyncContext(asyncName) {
|
80
|
+
let run = null;
|
81
|
+
try {
|
82
|
+
run = () => {
|
83
|
+
if (methods.cacheData[asyncName]) {
|
84
|
+
if (methods.cacheData[asyncName].status === 'fulfiled') {
|
85
|
+
return methods.cacheData[asyncName].data;
|
86
|
+
}
|
87
|
+
else if (methods.cacheData[asyncName].status === 'rejected') {
|
88
|
+
throw methods.cacheData[asyncName].err;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
throw cratePromise(asyncName).then(res => res.data);
|
92
|
+
};
|
93
|
+
return run();
|
94
|
+
}
|
95
|
+
catch (e) {
|
96
|
+
if (e instanceof Promise) {
|
97
|
+
e.finally(done => {
|
98
|
+
throw methods.cacheData[asyncName].data;
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
methods.getAuthorization = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
104
|
+
return yield cratePromise("getAuthorization").then(res => res.data);
|
105
|
+
});
|
106
|
+
methods.getUserInfo = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
107
|
+
return yield cratePromise("getUserInfo").then(res => res.data);
|
108
|
+
});
|
109
|
+
methods.fetchCustomData = (tokenName) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
110
|
+
return yield cratePromise(tokenName, 3000).then(res => res.data);
|
111
|
+
});
|
112
|
+
methods.triggerEvent = (eventName, eventArgs) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
113
|
+
triggerAppEvent(eventName, eventArgs);
|
114
|
+
});
|
115
|
+
if (!window.bokeJsBridge) {
|
116
|
+
window.bokeJsBridge = new Proxy(methods, {
|
117
|
+
get(target, property) {
|
118
|
+
if (property in target) {
|
119
|
+
return target[property];
|
120
|
+
}
|
121
|
+
},
|
122
|
+
});
|
123
|
+
window.messageArray = new Map();
|
124
|
+
window.addEventListener('message', ({ data, source, origin }) => {
|
125
|
+
window.messageArray.forEach((callback, key) => {
|
126
|
+
try {
|
127
|
+
const { eventName, eventData, msgScoped } = JSON.parse(data);
|
128
|
+
if (msgScoped != "boke-JS-BRIDGE") {
|
129
|
+
return; // 非boke的信息不处理
|
130
|
+
}
|
131
|
+
if (eventName == key) {
|
132
|
+
callback(eventData);
|
133
|
+
childLogger("boke-JS-BRIDGE", `postMessage to ChildSdk: ${data}`);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
catch (e) {
|
137
|
+
}
|
138
|
+
});
|
139
|
+
});
|
140
|
+
childLogger("boke-JS-BRIDGE", "ChildSdk is ready");
|
141
|
+
}
|
142
|
+
return window.bokeJsBridge;
|
143
|
+
};
|
144
|
+
export default ChildHanlder();
|
@@ -0,0 +1,24 @@
|
|
1
|
+
interface CommonEvent {
|
2
|
+
[props: string]: (prop: any) => any;
|
3
|
+
}
|
4
|
+
interface CallbackEvent {
|
5
|
+
getAuthorization?: (data?: any) => any;
|
6
|
+
getUserInfo?: (data?: any) => any;
|
7
|
+
[props: string]: (prop?: any) => any;
|
8
|
+
}
|
9
|
+
declare type ConfigType = {
|
10
|
+
/***自定义事件的具体实现 */
|
11
|
+
events: CommonEvent;
|
12
|
+
/***异步自定义事件的具体实现: 支持async异步方法 */
|
13
|
+
eventsCallback: CallbackEvent;
|
14
|
+
/***自动启动父iframe事件绑定, 默认: 是 */
|
15
|
+
autoStart?: boolean;
|
16
|
+
};
|
17
|
+
export default function (iframeTarget: HTMLIFrameElement, configs: ConfigType): {
|
18
|
+
postMessage(eventName: any, eventData: any): void;
|
19
|
+
destory(): void;
|
20
|
+
start(): void;
|
21
|
+
on(eventName: any, cb: any): void;
|
22
|
+
off(key: any): void;
|
23
|
+
};
|
24
|
+
export {};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import * as tslib_1 from "tslib";
|
2
|
+
import { parentLogger } from './utils';
|
3
|
+
(() => {
|
4
|
+
if (!(window.bokeMessageQueue)) {
|
5
|
+
window.bokeMessageQueue = new Map();
|
6
|
+
window.addEventListener("message", (data) => {
|
7
|
+
window.bokeMessageQueue.forEach((cb, key) => {
|
8
|
+
key && cb(data);
|
9
|
+
});
|
10
|
+
});
|
11
|
+
}
|
12
|
+
parentLogger("boke-JS-BRIDGE", "ParentSDK is Ready");
|
13
|
+
return;
|
14
|
+
})();
|
15
|
+
export default function (iframeTarget, configs) {
|
16
|
+
const frameUUID = encodeURIComponent(iframeTarget.src);
|
17
|
+
let { events = {}, eventsCallback = {}, autoStart = true } = configs;
|
18
|
+
const handler = function (e) {
|
19
|
+
try {
|
20
|
+
const { eventName, eventData, msgScoped } = JSON.parse(e.data);
|
21
|
+
if (msgScoped != "boke-JS-BRIDGE") {
|
22
|
+
return; // 没有msgScoped, 不属于sdk传递的消息
|
23
|
+
}
|
24
|
+
Object.keys(events).forEach((key) => {
|
25
|
+
if (eventName == key) {
|
26
|
+
events[key](eventData);
|
27
|
+
parentLogger("boke-JS-BRIDGE", `postMessage to ParentSdk: ${e.data}`);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
Object.keys(eventsCallback).forEach((key) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
31
|
+
if (eventName == key) {
|
32
|
+
let cbdata = yield eventsCallback[key](eventData);
|
33
|
+
let data = JSON.stringify({
|
34
|
+
eventName: eventName + "@Callback",
|
35
|
+
eventData: cbdata,
|
36
|
+
msgScoped: "boke-JS-BRIDGE"
|
37
|
+
});
|
38
|
+
parentLogger("boke-JS-BRIDGE", `callbackListener to ChildSdk: ${data}`);
|
39
|
+
iframeTarget.contentWindow.postMessage(data, "*");
|
40
|
+
}
|
41
|
+
}));
|
42
|
+
}
|
43
|
+
catch (error) {
|
44
|
+
}
|
45
|
+
};
|
46
|
+
const methods = {
|
47
|
+
postMessage(eventName, eventData) {
|
48
|
+
const data = JSON.stringify({
|
49
|
+
eventName: eventName,
|
50
|
+
eventData: eventData,
|
51
|
+
msgScoped: "boke-JS-BRIDGE"
|
52
|
+
});
|
53
|
+
parentLogger("boke-JS-BRIDGE", `postMessage to ChildSdk: ${data}`);
|
54
|
+
iframeTarget.contentWindow.postMessage(data, "*");
|
55
|
+
},
|
56
|
+
destory() {
|
57
|
+
window.bokeMessageQueue.delete(frameUUID);
|
58
|
+
},
|
59
|
+
start() {
|
60
|
+
window.bokeMessageQueue.set(frameUUID, handler);
|
61
|
+
},
|
62
|
+
on(eventName, cb) {
|
63
|
+
events[eventName] = cb;
|
64
|
+
},
|
65
|
+
off(key) {
|
66
|
+
delete events[key];
|
67
|
+
},
|
68
|
+
};
|
69
|
+
autoStart && methods.start();
|
70
|
+
return Object.assign({}, methods);
|
71
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export const parentLogger = (title, msg) => {
|
2
|
+
console.log(` %c ${title} %c ${msg} `, 'color: #fff; background: #4B60CF; padding:5px 0;', 'background: #030307; color: #fff; padding:5px 0;word-break:break-all');
|
3
|
+
};
|
4
|
+
export const childLogger = (title, msg) => {
|
5
|
+
console.log(` %c ${title} %c ${msg}`, 'color: #fa8c16; background: #fff7e6; padding:5px 0;', 'background: #030307; color: #fff; padding:5px 0;word-break:break-all');
|
6
|
+
};
|