quick-platform 1.0.46
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/application/constants.d.ts +4 -0
- package/dist/application/index.d.ts +29 -0
- package/dist/application/manage.d.ts +31 -0
- package/dist/business/index.d.ts +72 -0
- package/dist/business/version.d.ts +7 -0
- package/dist/components/IconFont.d.ts +4 -0
- package/dist/components/LocalDebug.d.ts +6 -0
- package/dist/components/MicroApp.d.ts +14 -0
- package/dist/components/Permission.d.ts +6 -0
- package/dist/components/context.d.ts +3 -0
- package/dist/components/i18n.d.ts +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/event.d.ts +13 -0
- package/dist/index-543d110b.js +547 -0
- package/dist/index-543d110b.js.map +1 -0
- package/dist/index-be61d86b.js +2 -0
- package/dist/index-be61d86b.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/define/color.d.ts +9 -0
- package/dist/theme/define/font.d.ts +50 -0
- package/dist/theme/define/index.d.ts +5 -0
- package/dist/theme/define/size.d.ts +24 -0
- package/dist/theme/define/style.d.ts +21 -0
- package/dist/theme/doc.d.ts +2 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/lib/index.d.ts +1 -0
- package/dist/theme/react/hook.d.ts +5 -0
- package/dist/theme/react/index.d.ts +3 -0
- package/dist/theme/uno.d.ts +19 -0
- package/dist/utils/i18n.d.ts +6 -0
- package/dist/utils/image.d.ts +2 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/localstorage.d.ts +6 -0
- package/dist/utils/request.d.ts +37 -0
- package/dist/utils/utils.d.ts +3 -0
- package/package.json +67 -0
- package/src/application/constants.ts +7 -0
- package/src/application/index.ts +82 -0
- package/src/application/manage.ts +119 -0
- package/src/business/declare.d.ts +39 -0
- package/src/business/index.ts +130 -0
- package/src/business/version.ts +58 -0
- package/src/components/IconFont.ts +11 -0
- package/src/components/LocalDebug.ts +244 -0
- package/src/components/MicroApp.ts +97 -0
- package/src/components/Permission.ts +13 -0
- package/src/components/context.ts +31 -0
- package/src/components/i18n.ts +17 -0
- package/src/config.ts +3 -0
- package/src/event.ts +24 -0
- package/src/index.ts +38 -0
- package/src/theme/define/color.ts +53 -0
- package/src/theme/define/font.ts +29 -0
- package/src/theme/define/index.ts +8 -0
- package/src/theme/define/size.ts +31 -0
- package/src/theme/define/style.ts +41 -0
- package/src/theme/doc.tsx +438 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/lib/index.ts +15 -0
- package/src/theme/react/hook.ts +42 -0
- package/src/theme/react/index.ts +14 -0
- package/src/theme/uno.ts +218 -0
- package/src/utils/i18n.ts +84 -0
- package/src/utils/image.ts +52 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/localstorage.ts +32 -0
- package/src/utils/request.ts +173 -0
- package/src/utils/utils.ts +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 halvee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
registerApp(options) 注册应用
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
{
|
|
5
|
+
name:string;//应用名称
|
|
6
|
+
i18n:{
|
|
7
|
+
global?:boolean; 默认会全局挂载$$i18n和$i18n国际化函数
|
|
8
|
+
onReady?(hook):Promise<any>; 初始国际化完成,可以在这里面进行自定义的国际化操作
|
|
9
|
+
},
|
|
10
|
+
lifecycles:{};// 组件生命周期hook
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
MicroApp 子应用加载组件
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
{
|
|
18
|
+
name: string;// 子应用名称
|
|
19
|
+
extra?: any; //扩展信息
|
|
20
|
+
base?: string; // 子应用路由base
|
|
21
|
+
env?: string; // 环境 ,默认会取当前运行环境
|
|
22
|
+
host?: string;// 加载子应用的服务地址
|
|
23
|
+
className?: string //容器类名
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Permission 权限组件,会默认对接主应用的权限信息
|
|
29
|
+
|
|
30
|
+
AppEvent 应用间通信事件总线
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
trigger(name: string, data: any):void;向父级发送事件
|
|
34
|
+
broadcast(name: string, data: any):void;向子级发送事件
|
|
35
|
+
on(name: string, handler: (...args: any[]) => void):void;注册事件
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Utils 工具类
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Utils.buildHttpCtrl(base:string); 请求工具封装,与现在的httpCtrl相同功能,可平替
|
|
42
|
+
Utils.tryImageTranscode(url); 图片本地解码操作,主要针对heic类图片进行转码,正常展示
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Authentication 认证相关服务
|
|
46
|
+
|
|
47
|
+
## 更新日志
|
|
48
|
+
|
|
49
|
+
24.09.11:@quick/platform@1.0.15 修改 uno 的打包规则
|
|
50
|
+
24.09.11:@quick/platform@1.0.16 修改 uno 的打包规则
|
|
51
|
+
24.10.10:@quick/platform@1.0.17 新增 License 权限判断
|
|
52
|
+
24.10.17:@quick/platform@1.0.22 修改 system 的本地获取方式
|
|
53
|
+
24.10.24:@quick/platform@1.0.28 新增 MicroApp 组件 loading 过渡渲染
|
|
54
|
+
24.10.28:@quick/platform@1.0.33 新增 应用状态获取及环境判断
|
|
55
|
+
24.10.34:@quick/platform@1.0.34 补充 License 权限判断
|
|
56
|
+
24.10.35:@quick/platform@1.0.34 增加处理数据逻辑
|
|
57
|
+
24.11.22:@quick/platform@1.0.38 增加处理数据逻辑
|
|
58
|
+
24.11.25:@quick/platform@1.0.39 增加本地调度模式支撑(LocalDebug 组件)
|
|
59
|
+
24.11.27:@quick/platform@1.0.40 增加积分计费版本的 api
|
|
60
|
+
24.11.27:@quick/platform@1.0.41 增加积分计费版本的 api
|
|
61
|
+
24.11.28:@quick/platform@1.0.42 增加 oem 版本的识别 api
|
|
62
|
+
24.11.28:@quick/platform@1.0.45 处理国际化加载时机
|
|
63
|
+
24.11.28:@quick/platform@1.0.46 处理微应用初始状态值重置问题
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const ROUTER_BASE_KEY = "quick_qiankun_router_base";
|
|
2
|
+
export declare const APP_PARENT_KEY = "quick_qiankun_parent_app";
|
|
3
|
+
export declare const APP_CACHE_PARENT_KEY = "quick_qiankun_parent_cache";
|
|
4
|
+
export declare const APP_MANAGE_KEY = "quick_qiankun_manage";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="single-spa" />
|
|
3
|
+
import { intApp, getCurrentApp } from './manage';
|
|
4
|
+
import { installI18n } from '../utils/i18n';
|
|
5
|
+
export declare const loadApp: (name: string, container: HTMLElement, props?: {
|
|
6
|
+
host?: string | undefined;
|
|
7
|
+
base?: string | undefined;
|
|
8
|
+
env?: string | undefined;
|
|
9
|
+
entry?: string | undefined;
|
|
10
|
+
} | undefined) => import("single-spa").Parcel<import("single-spa").CustomProps>;
|
|
11
|
+
export declare const registerApp: (options: {
|
|
12
|
+
name: string;
|
|
13
|
+
env?: string | undefined;
|
|
14
|
+
i18n?: {
|
|
15
|
+
global?: boolean | undefined;
|
|
16
|
+
onReady?(hook: ReturnType<typeof installI18n>): Promise<any>;
|
|
17
|
+
} | undefined;
|
|
18
|
+
lifecycles: {
|
|
19
|
+
mount?(props: any): Promise<any>;
|
|
20
|
+
unmount?(props: any): Promise<any>;
|
|
21
|
+
bootstrap?(props: any): Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
beforeMount(): Promise<unknown>;
|
|
25
|
+
mount(props: any): Promise<any>;
|
|
26
|
+
unmount(props: any): Promise<any>;
|
|
27
|
+
bootstrap(props: any): Promise<any>;
|
|
28
|
+
};
|
|
29
|
+
export { intApp, getCurrentApp };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
declare class App {
|
|
3
|
+
name: string;
|
|
4
|
+
parent: App | undefined;
|
|
5
|
+
private children;
|
|
6
|
+
private cacheMap;
|
|
7
|
+
emitter: EventEmitter<string | symbol, any>;
|
|
8
|
+
constructor(name: string, parent?: string);
|
|
9
|
+
private getParent;
|
|
10
|
+
get root(): App;
|
|
11
|
+
get isRoot(): boolean;
|
|
12
|
+
addChildren(child: App): void;
|
|
13
|
+
removeChildren(name: string): void;
|
|
14
|
+
on: <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
15
|
+
once: <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
16
|
+
off: <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
17
|
+
/***
|
|
18
|
+
* 向父级通信
|
|
19
|
+
*/
|
|
20
|
+
trigger(name: string, data: any): void;
|
|
21
|
+
/**
|
|
22
|
+
* 向所有子级通信
|
|
23
|
+
*/
|
|
24
|
+
broadcast(name: string, data: any): void;
|
|
25
|
+
cache(key: string, value?: any): any;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare const intApp: (name: string) => void;
|
|
29
|
+
export declare const getCurrentApp: () => App;
|
|
30
|
+
export declare const disposeApp: () => void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { UserInfo } from './declare';
|
|
2
|
+
export declare const login: (userInfo: UserInfo) => void;
|
|
3
|
+
export declare const getUserInfo: () => Partial<any>;
|
|
4
|
+
export declare const getStaffInfo: () => Partial<{
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
email: string;
|
|
7
|
+
firstName: string;
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
role: string;
|
|
11
|
+
roleList: string[];
|
|
12
|
+
storeId: number;
|
|
13
|
+
userId: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const getStoreInfo: () => Partial<{
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
city: string;
|
|
18
|
+
id: number;
|
|
19
|
+
platform: string;
|
|
20
|
+
productCategory: string;
|
|
21
|
+
storeName: string;
|
|
22
|
+
timezone: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const getStoreLicense: () => Partial<{
|
|
25
|
+
storeId: number;
|
|
26
|
+
name: string;
|
|
27
|
+
enName: string;
|
|
28
|
+
expireTime: string;
|
|
29
|
+
daysToRemain: number;
|
|
30
|
+
remainExpire: boolean;
|
|
31
|
+
licenceId: number;
|
|
32
|
+
productCategory: string;
|
|
33
|
+
validInviteCode: any;
|
|
34
|
+
unLimitedLicence: boolean;
|
|
35
|
+
ultimate: boolean;
|
|
36
|
+
licenceType: string;
|
|
37
|
+
useBalance: number;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const hasAuth: (code: string) => boolean;
|
|
40
|
+
export declare const getSystem: () => {
|
|
41
|
+
oem: string | undefined;
|
|
42
|
+
env: string | undefined;
|
|
43
|
+
lang: "zh-CN" | "en-US" | "ko" | "ja" | "zh-TW";
|
|
44
|
+
token: string;
|
|
45
|
+
requestTokenKey: string;
|
|
46
|
+
storeId: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const getOEMName: () => any;
|
|
49
|
+
export declare const License: {
|
|
50
|
+
isPLG: () => boolean;
|
|
51
|
+
isSLG: () => boolean;
|
|
52
|
+
isEnterprise: () => boolean;
|
|
53
|
+
isFree: () => boolean;
|
|
54
|
+
isProfessional: () => boolean;
|
|
55
|
+
isCredits: () => boolean;
|
|
56
|
+
getLicense: () => Partial<{
|
|
57
|
+
storeId: number;
|
|
58
|
+
name: string;
|
|
59
|
+
enName: string;
|
|
60
|
+
expireTime: string;
|
|
61
|
+
daysToRemain: number;
|
|
62
|
+
remainExpire: boolean;
|
|
63
|
+
licenceId: number;
|
|
64
|
+
productCategory: string;
|
|
65
|
+
validInviteCode: any;
|
|
66
|
+
unLimitedLicence: boolean;
|
|
67
|
+
ultimate: boolean;
|
|
68
|
+
licenceType: string;
|
|
69
|
+
useBalance: number;
|
|
70
|
+
}>;
|
|
71
|
+
isOEM(): boolean;
|
|
72
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserInfo } from './declare';
|
|
2
|
+
export declare const isPLG: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
3
|
+
export declare const isSLG: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
4
|
+
export declare const isEnterprise: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
5
|
+
export declare const isFree: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
6
|
+
export declare const isProfessional: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
7
|
+
export declare const isCredits: (licence: Partial<UserInfo['storeLicenceInfo']>) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const MicroApp: React.FC<{
|
|
3
|
+
name: string;
|
|
4
|
+
extra?: any;
|
|
5
|
+
base?: string;
|
|
6
|
+
env?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
data?: any;
|
|
9
|
+
className?: string;
|
|
10
|
+
loading?: React.ReactNode;
|
|
11
|
+
entry?: string;
|
|
12
|
+
onMounted?(): void;
|
|
13
|
+
}>;
|
|
14
|
+
export default MicroApp;
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("./index-be61d86b.js"),e=function(r){return Object.keys(r).reduce((function(e,t){var o;return e[n(t)]="number"==typeof(o=r[t])?o+"px":o,e}),{})},t=function(){return[r.BrandColor,{primary:r.PrimaryColor}].reduce((function(e,t){return Object.keys(t).reduce((function(e,n){var o=r.generateVar(n);return e.colors["q-"+n]="var("+o+")",e.preflights.push(".bg-q-"+n+"{ background-color:var("+o+")}\n.text-q-"+n+"{ color:var("+o+")}"),e.vars.push(o+":"+t[n]+";"),e}),e)}),{colors:{},preflights:[],vars:[]})}(),n=function(r){return r.replace(/\B([A-Z])/g,"-$1").toLowerCase()},o=function(r){return r.replace(/\-(\w)/g,(function(r,e){return e.toUpperCase()})).replace(/^[a-z]/,(function(r){return r.toUpperCase()}))},u=function(){var t={rules:[]},n=function(r,n){t.rules.push([r,function(r){var t=o(r[1]);return n[t]?e(n[t]):{}}])};return n(/^text-q-([a-zA-Z-]+)$/,r.TextFont),n(/^title-q-([a-zA-Z-]+)$/,r.TitleFont),t}(),i=function(){var e={shortcuts:[],vars:{}},t=function(r){return{origin:r[0],type:r[1],value:r[2]}},n=function(r,n,o){var u=o.prefix,i=void 0===u?"":u,a=o.covert,s=void 0===a?t:a;e.shortcuts.push([r,function(r){var e=s(r),t=e.origin,o=e.type,u=e.value;return/title|text|top/.test(o)||!i&&/^(border)|(rd)|shadow/.test(o)?t:n[i+u]?Array.isArray(o)?o.map((function(r){return r+"-"+n[i+u]+"px"})).join(" "):o+"-"+n[i+u]+"px":t}])};return n(/^(.*)-q-(\d+)$/,r.BaseSize,{prefix:"size-"}),n(/^(m(-[rltbxy]+)?)-q-([a-z]*)$/,r.MarginSize,{covert:function(r){var e=t(r);return e.value=r[3],"m-lr"!==e.type&&"m-x"!==e.type||(e.type=["m-l","m-r"]),"m-tb"!==e.type&&"m-y"!==e.type||(e.type=["m-t","m-b"]),e}}),n(/^(p(-[rltbxy]+)?)-q-([a-z]*)$/,r.MarginSize,{covert:function(r){var e=t(r);return e.value=r[3],"p-lr"!==e.type&&"p-x"!==e.type||(e.type=["p-l","p-r"]),"p-tb"!==e.type&&"p-y"!==e.type||(e.type=["p-t","p-b"]),e}}),n(/^(gap)-q-([a-z]*)$/,r.MarginSize,{}),e}(),a=function(){var t={rules:[]},n=function(r,n,u){void 0===u&&(u=e),t.rules.push([r,function(r){var e=o(r[1]);return n[e]?u(n[e]):{}},{}])};return n(/^rd-q-([a-zA-Z-]+)$/,r.BorderRadius),n(/^border-q-([a-zA-Z-]+)$/,r.Border),["left","right","bottom","top"].forEach((function(e){n(new RegExp("^border-"+e.slice(0,1)+"-q-([a-zA-Z-]+)$"),r.Border,(function(r){var t;return(t={})["border-"+e]=r.borderWidth+"px "+r.borderStyle+" "+r.borderColor,t}))})),n(/^shadow-q-([a-zA-Z0-9-]+)$/,r.Shadow,(function(r){return{"box-shadow":r.offsetX+"px "+r.offsetY+"px "+r.blurRadius+"px "+r.spreadRadius+"px "+r.color}})),t}();exports.UnoConfig=function(){return{content:{pipeline:{include:["src/**/*.{js,ts,tsx}"]}},rules:[].concat(u.rules,a.rules),theme:{colors:t.colors},shortcuts:[].concat(i.shortcuts),layers:{default:1,"weight-lower":-1},preflights:[{getCSS:function(){return":root{"+t.vars.join("\n")+" }"}},{getCSS:function(){return t.preflights}}]}};
|
|
2
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/theme/uno.ts"],"sourcesContent":["import { Color, Font, Size, Style } from './define';\n\nconst prefix = 'q-';\n\nconst convertToCss = (obj: any) => {\n const toUnit = (value: string | number) => {\n if (typeof value === 'number') return value + 'px';\n return value;\n };\n return Object.keys(obj).reduce<any>((css, key) => {\n css[toLine(key)] = toUnit(obj[key]); //todo 转rem\n return css;\n }, {});\n};\n\nconst colors = (() => {\n const convertToConfig = (origin: any, colors: any) => {\n return Object.keys(colors).reduce<any>((map, key) => {\n const varKey = Color.generateVar(key);\n map['colors'][prefix + key] = `var(${varKey})`; //colors[key];\n map['preflights'].push(\n `.bg-${prefix}${key}{ background-color:var(${varKey})}\\n.text-${prefix}${key}{ color:var(${varKey})}`\n );\n map['vars'].push(`${varKey}:${colors[key]};`);\n return map;\n }, origin);\n };\n return [\n Color.BrandColor,\n // Color.NeutralColor,\n // Color.NeutralHelperColor,\n // Color.FunctionalColor,\n // Color.FunctionalHelperColor,\n { primary: Color.PrimaryColor },\n ].reduce(convertToConfig, {\n colors: {},\n preflights: [],\n vars: [],\n });\n})();\n\nconst toLine = (str: string) => {\n return str.replace(/\\B([A-Z])/g, '-$1').toLowerCase();\n};\n\nconst toCamel = (str: string) => {\n return str\n .replace(/\\-(\\w)/g, function(_, letter) {\n return letter.toUpperCase();\n })\n .replace(/^[a-z]/, m => m.toUpperCase());\n};\n\nconst fonts = (() => {\n const results = {\n rules: [] as [RegExp, Function][],\n };\n\n const convertToRules = (rule: RegExp, fonts: any) => {\n results.rules!.push([\n rule,\n ([_, match]: any) => {\n const name = toCamel(match);\n if (fonts[name]) return convertToCss(fonts[name]);\n return {};\n },\n ]);\n };\n convertToRules(/^text-q-([a-zA-Z-]+)$/, Font.TextFont);\n convertToRules(/^title-q-([a-zA-Z-]+)$/, Font.TitleFont);\n return results;\n})();\n\nconst size = (() => {\n const results = {\n shortcuts: [] as [RegExp, Function][],\n vars: {},\n };\n const matchCovert = (match: string[]) => ({\n origin: match[0],\n type: match[1],\n value: match[2],\n });\n const convertToShortCuts = (\n rule: RegExp,\n size: any,\n {\n prefix = '',\n covert = matchCovert,\n }: {\n prefix?: string;\n covert?: typeof matchCovert;\n }\n ) => {\n results.shortcuts!.push([\n rule,\n (match: any) => {\n const { origin: _, type, value } = covert(match);\n if (/title|text|top/.test(type)) return _;\n if (!prefix) {\n // 不为数字的情况,针对内置的样式需要过滤处理\n if (/^(border)|(rd)|shadow/.test(type)) return _;\n }\n\n if (size[prefix + value]) {\n if (Array.isArray(type))\n return type.map(t => `${t}-${size[prefix + value]}px`).join(' ');\n return `${type}-${size[prefix + value]}px`; //todo toRem\n }\n return _;\n },\n ]);\n };\n convertToShortCuts(/^(.*)-q-(\\d+)$/, Size.BaseSize, { prefix: 'size-' });\n // convertToShortCuts(/^(.*)-q-([a-z]*)$/, Size.ComponentSize, {});\n convertToShortCuts(/^(m(-[rltbxy]+)?)-q-([a-z]*)$/, Size.MarginSize, {\n covert(match) {\n const res = matchCovert(match);\n res.value = match[3];\n if (res.type === 'm-lr' || res.type === 'm-x') {\n res.type = ['m-l', 'm-r'] as any;\n }\n if (res.type === 'm-tb' || res.type === 'm-y') {\n res.type = ['m-t', 'm-b'] as any;\n }\n return res;\n },\n });\n convertToShortCuts(/^(p(-[rltbxy]+)?)-q-([a-z]*)$/, Size.MarginSize, {\n covert(match) {\n const res = matchCovert(match);\n res.value = match[3];\n if (res.type === 'p-lr' || res.type === 'p-x') {\n res.type = ['p-l', 'p-r'] as any;\n }\n if (res.type === 'p-tb' || res.type === 'p-y') {\n res.type = ['p-t', 'p-b'] as any;\n }\n\n return res;\n },\n });\n\n convertToShortCuts(/^(gap)-q-([a-z]*)$/, Size.MarginSize, {});\n\n return results;\n})();\n\nconst styles = (() => {\n const results = {\n rules: [] as [RegExp, Function, any][],\n };\n\n const convertToRules = (rule: RegExp, style: any, convert = convertToCss) => {\n results.rules!.push([\n rule,\n ([_, match]: any) => {\n const name = toCamel(match);\n if (style[name]) return convert(style[name]);\n return {};\n },\n {\n // layer: 'weight-lower',\n },\n ]);\n };\n convertToRules(/^rd-q-([a-zA-Z-]+)$/, Style.BorderRadius);\n convertToRules(/^border-q-([a-zA-Z-]+)$/, Style.Border);\n ['left', 'right', 'bottom', 'top'].forEach(dir => {\n convertToRules(\n new RegExp(`^border-${dir.slice(0, 1)}-${prefix}([a-zA-Z-]+)$`),\n Style.Border,\n style => {\n return {\n [`border-${dir}`]: `${style.borderWidth}px ${style.borderStyle} ${style.borderColor}`,\n };\n }\n );\n });\n convertToRules(/^shadow-q-([a-zA-Z0-9-]+)$/, Style.Shadow, shadow => {\n return {\n 'box-shadow': `${shadow.offsetX}px ${shadow.offsetY}px ${shadow.blurRadius}px ${shadow.spreadRadius}px ${shadow.color}`,\n };\n });\n return results;\n})();\n\nexport const UnoConfig = () => {\n return {\n // ...UnoCSS options\n content: {\n pipeline: {\n include: ['src/**/*.{js,ts,tsx}'],\n },\n },\n rules: [...fonts.rules!, ...styles.rules!],\n theme: {\n colors: colors.colors,\n },\n shortcuts: [...size.shortcuts],\n layers: {\n default: 1,\n 'weight-lower': -1,\n },\n preflights: [\n {\n getCSS() {\n return `:root{${colors.vars.join('\\n')} }`;\n },\n },\n {\n getCSS() {\n return colors.preflights;\n },\n },\n ],\n };\n};\n"],"names":["convertToCss","obj","Object","keys","reduce","css","key","value","toLine","colors","Color","primary","origin","map","varKey","push","preflights","vars","str","replace","toLowerCase","toCamel","_","letter","toUpperCase","m","fonts","results","rules","convertToRules","rule","_ref","name","Font","size","shortcuts","matchCovert","match","type","convertToShortCuts","_ref2","prefix","_ref2$prefix","_ref2$covert","covert","_covert","test","Array","isArray","t","join","Size","res","styles","style","convert","_ref3","Style","forEach","dir","RegExp","slice","_ref4","borderWidth","borderStyle","borderColor","shadow","box-shadow","offsetX","offsetY","blurRadius","spreadRadius","color","content","pipeline","include","concat","theme","layers","default","weight-lower","getCSS"],"mappings":"yGAIMA,EAAe,SAACC,GAKpB,OAAOC,OAAOC,KAAKF,GAAKG,QAAY,SAACC,EAAKC,GAJ3B,IAACC,EAMd,OADAF,EAAIG,EAAOF,IAJU,iBADPC,EAKYN,EAAIK,IAJQC,EAAQ,KACvCA,EAIAF,IACN,KAGCI,EAAU,WAYd,MAAO,CACLC,aAKA,CAAEC,QAASD,iBACXN,QAlBsB,SAACQ,EAAaH,GACpC,OAAOP,OAAOC,KAAKM,GAAQL,QAAY,SAACS,EAAKP,GAC3C,IAAMQ,EAASJ,cAAkBJ,GAMjC,OALAO,EAAY,OAjBH,KAiBcP,UAAcQ,MACrCD,EAAgB,WAAEE,cACAT,4BAA6BQ,iBAA4BR,iBAAkBQ,QAE7FD,EAAU,KAAEE,KAAQD,MAAUL,EAAOH,QAC9BO,IACND,KASqB,CACxBH,OAAQ,GACRO,WAAY,GACZC,KAAM,KAtBM,GA0BVT,EAAS,SAACU,GACd,OAAOA,EAAIC,QAAQ,aAAc,OAAOC,eAGpCC,EAAU,SAACH,GACf,OAAOA,EACJC,QAAQ,WAAW,SAASG,EAAGC,GAC9B,OAAOA,EAAOC,iBAEfL,QAAQ,UAAU,SAAAM,GAAC,OAAIA,EAAED,kBAGxBE,EAAS,WACb,IAAMC,EAAU,CACdC,MAAO,IAGHC,EAAiB,SAACC,EAAcJ,GACpCC,EAAQC,MAAOb,KAAK,CAClBe,EACA,SAAAC,OACQC,EAAOX,EADLU,MAER,OAAIL,EAAMM,GAAchC,EAAa0B,EAA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
*/
|
|
5
|
+
trigger(name: string, data: any): void;
|
|
6
|
+
/**
|
|
7
|
+
*向子级发送事件
|
|
8
|
+
*/
|
|
9
|
+
broadcast(name: string, data: any): void;
|
|
10
|
+
on(name: string, handler: (...args: any[]) => void): void;
|
|
11
|
+
off(name: string, handler: (...args: any[]) => void): void;
|
|
12
|
+
};
|
|
13
|
+
export default events;
|