vite-uni-dev-tool 0.0.11 → 0.0.13
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/README.md +55 -1
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
- package/dev/components/ConsoleList/RunJSInput.vue +0 -235
- package/dev/components/ConsoleList/index.vue +0 -130
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -182
- package/dev/components/DevToolButton/index.vue +0 -213
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1037
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -474
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -197
- package/dev/components/NetworkList/NetworkItem.vue +0 -106
- package/dev/components/NetworkList/index.vue +0 -115
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -110
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -225
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -124
- package/dev/components/UniEvent/index.vue +0 -94
- package/dev/components/UploadList/UploadDetail.vue +0 -208
- package/dev/components/UploadList/UploadItem.vue +0 -111
- package/dev/components/UploadList/index.vue +0 -104
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -175
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -98
- package/dev/components/WebSocket/WebSocketList.vue +0 -176
- package/dev/components/WebSocket/index.vue +0 -111
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -166
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -806
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -718
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -264
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -46
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -72
- package/dev/utils/object.ts +0 -298
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../dev/v2/JsonPretty/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,GAAG,CAAC;IACnB,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC;AACF,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EACA,SAAS,GACT,aAAa,GACb,WAAW,GACX,iBAAiB,GAC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,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,EAAE,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentInternalInstance } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare function getRect(selector: string, context: ComponentInternalInstance | null | any, node?: boolean): Promise<UniApp.NodeInfo>;
|
|
4
|
+
export declare function addUnit(value?: string | number): string;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../dev/v3/AutoSizer/utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,KAAK,CAAC;AAE9E,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,yBAAyB,GAAG,IAAI,GAAG,GAAG,EAC/C,IAAI,GAAE,OAAe,4BAmCtB;AAED,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Tip = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
result: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const staticTips: Record<string, {
|
|
7
|
+
attr: Tip[];
|
|
8
|
+
fun: Tip[];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const flatStaticTips: Tip[];
|
|
11
|
+
export declare const singleTips: string[];
|
|
12
|
+
export declare const baseSymbols: string[];
|
|
13
|
+
//# sourceMappingURL=staticTips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticTips.d.ts","sourceRoot":"","sources":["../../../dev/v3/ConsoleList/staticTips.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,MAAM,EACN;IACE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,GAAG,EAAE,GAAG,EAAE,CAAC;CACZ,CA4lCF,CAAC;AAEF,eAAO,MAAM,cAAc,OAEjB,CAAC;AAEX,eAAO,MAAM,UAAU,UAStB,CAAC;AAEF,eAAO,MAAM,WAAW,UAAqD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClipboard.d.ts","sourceRoot":"","sources":["../../../../dev/v3/JsonPretty/hooks/useClipboard.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY;mBAGE,MAAM;EAenC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useError.d.ts","sourceRoot":"","sources":["../../../../dev/v3/JsonPretty/hooks/useError.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,EAAE,eAAe;;EAc1E"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CSSProperties } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type JsonPrettyNodeProps = {
|
|
4
|
+
data: any;
|
|
5
|
+
rootPath: string;
|
|
6
|
+
indent: number;
|
|
7
|
+
showLength: boolean;
|
|
8
|
+
showDoubleQuotes: boolean;
|
|
9
|
+
renderNodeKey: any;
|
|
10
|
+
renderNodeValue: any;
|
|
11
|
+
};
|
|
12
|
+
export interface NodeDataType extends JSONFlattenReturnType {
|
|
13
|
+
id: number;
|
|
14
|
+
}
|
|
15
|
+
export interface JSONFlattenOptions {
|
|
16
|
+
key?: string;
|
|
17
|
+
index?: number;
|
|
18
|
+
showComma: boolean;
|
|
19
|
+
length: number;
|
|
20
|
+
type: 'content' | 'objectStart' | 'objectEnd' | 'objectCollapsed' | 'arrayStart' | 'arrayEnd' | 'arrayCollapsed';
|
|
21
|
+
}
|
|
22
|
+
export type JSONDataType = string | number | boolean | unknown[] | Record<string, unknown> | null;
|
|
23
|
+
export interface JSONFlattenReturnType extends JSONFlattenOptions {
|
|
24
|
+
content: string | number | null | boolean;
|
|
25
|
+
level: number;
|
|
26
|
+
path: string;
|
|
27
|
+
}
|
|
28
|
+
export type StyleValue = false | null | undefined | string | CSSProperties | Array<StyleValue>;
|
|
29
|
+
type SelectableType = 'single' | 'multiple' | null;
|
|
30
|
+
export type TreeNodeProps = Partial<{
|
|
31
|
+
data: any;
|
|
32
|
+
indent: number;
|
|
33
|
+
showLength: boolean;
|
|
34
|
+
showDoubleQuotes: boolean;
|
|
35
|
+
selectableType: SelectableType;
|
|
36
|
+
showSelectController: boolean;
|
|
37
|
+
showLine: boolean;
|
|
38
|
+
showLineNumber: boolean;
|
|
39
|
+
showNodeActions: boolean;
|
|
40
|
+
selectOnClickNode: boolean;
|
|
41
|
+
highlightSelectedNode: boolean;
|
|
42
|
+
showIcon: boolean;
|
|
43
|
+
theme: string;
|
|
44
|
+
showKeyValueSpace: boolean;
|
|
45
|
+
editable: boolean;
|
|
46
|
+
editableTrigger: string;
|
|
47
|
+
node: NodeDataType;
|
|
48
|
+
checked: boolean;
|
|
49
|
+
collapsed: boolean;
|
|
50
|
+
style: CSSProperties;
|
|
51
|
+
fontSize: string;
|
|
52
|
+
onNodeClick: (node: NodeDataType) => void;
|
|
53
|
+
onNodeMouseover: (node: NodeDataType) => void;
|
|
54
|
+
onBracketsClick: (collapsed: boolean, node: NodeDataType) => void;
|
|
55
|
+
onIconClick: (collapsed: boolean, node: NodeDataType) => void;
|
|
56
|
+
onValueChange: (value: boolean, path: string) => void;
|
|
57
|
+
onSelectedChange: (node: NodeDataType) => void;
|
|
58
|
+
}> & TreeNodeRequiredProps;
|
|
59
|
+
export type TreeNodeRequiredProps = {
|
|
60
|
+
node: NodeDataType;
|
|
61
|
+
rootPath: string;
|
|
62
|
+
nodeSelectable: (node: NodeDataType) => boolean;
|
|
63
|
+
};
|
|
64
|
+
export type TreeRequired = TreeNodeRequiredProps & {};
|
|
65
|
+
export type Tree = Partial<TreeNodeProps> & Partial<{
|
|
66
|
+
deep: number;
|
|
67
|
+
collapsedNodeLength: number;
|
|
68
|
+
virtual: boolean;
|
|
69
|
+
itemHeight: number;
|
|
70
|
+
height: number;
|
|
71
|
+
selectedValue: string | Array<any>;
|
|
72
|
+
collapsedOnClickBrackets: boolean;
|
|
73
|
+
style: CSSProperties;
|
|
74
|
+
pathCollapsible: (node: NodeDataType) => boolean;
|
|
75
|
+
/** 超过行数将会自动启用虚拟列表 */
|
|
76
|
+
autoVirtualRow: number;
|
|
77
|
+
} & TreeRequired>;
|
|
78
|
+
export interface ScrollEvent {
|
|
79
|
+
detail: {
|
|
80
|
+
scrollLeft: number;
|
|
81
|
+
scrollTop: number;
|
|
82
|
+
scrollHeight: number;
|
|
83
|
+
scrollWidth: number;
|
|
84
|
+
deltaX: number;
|
|
85
|
+
deltaY: number;
|
|
86
|
+
};
|
|
87
|
+
target: EventTarget;
|
|
88
|
+
currentTarget: EventTarget;
|
|
89
|
+
timeStamp: number;
|
|
90
|
+
type: string;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../dev/v3/JsonPretty/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,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BAAqB,GAAG,EAAE,CAAC;AAEtD,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,GACvC,OAAO,CACL;IACE,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,wBAAwB,EAAE,OAAO,CAAC;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IACjD,qBAAqB;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,YAAY,CACjB,CAAC;AAEJ,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,EAAE,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONDataType, JSONFlattenOptions, JSONFlattenReturnType } from '../type';
|
|
2
|
+
|
|
3
|
+
export declare function emitError(message: string): void;
|
|
4
|
+
export declare function getDataType(value: unknown): string;
|
|
5
|
+
export declare function jsonFlatten(data: JSONDataType, path?: string, level?: number, options?: JSONFlattenOptions): JSONFlattenReturnType[];
|
|
6
|
+
export declare function arrFlat<T extends unknown[]>(arr: T): unknown[];
|
|
7
|
+
export declare function cloneDeep<T extends unknown>(source: T, hash?: WeakMap<object, any>): T;
|
|
8
|
+
export declare function stringToAutoType(source: string): unknown;
|
|
9
|
+
export declare function isFunction(value: unknown): value is Function;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../dev/v3/JsonPretty/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,YAAY,EAClB,IAAI,SAAS,EACb,KAAK,SAAI,EACT,OAAO,CAAC,EAAE,kBAAkB,GAC3B,qBAAqB,EAAE,CAqFzB;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,EAAE,CAe9D;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EACzC,MAAM,EAAE,CAAC,EACT,IAAI,uBAAgB,GACnB,CAAC,CAmBH;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAoBxD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-uni-dev-tool",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"main": "
|
|
22
|
-
"types": "
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
23
|
"files": [
|
|
24
|
-
"./
|
|
24
|
+
"./dist/"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build:lib": "vite build
|
|
27
|
+
"build:lib": "vite build"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"vue": ">=3.4.21",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="app-info-content">
|
|
3
|
-
<JsonPretty v-if="showJson" :data="appInfo" />
|
|
4
|
-
<Empty v-else />
|
|
5
|
-
</view>
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
import JsonPretty from '../JsonPretty/index.vue';
|
|
10
|
-
|
|
11
|
-
import Empty from '../Empty/index.vue';
|
|
12
|
-
const props = defineProps<{
|
|
13
|
-
appInfo: Record<string, any>;
|
|
14
|
-
}>();
|
|
15
|
-
|
|
16
|
-
const showJson = computed(() => {
|
|
17
|
-
try {
|
|
18
|
-
const str = JSON.stringify(props.appInfo);
|
|
19
|
-
if (typeof props.appInfo === 'object' && (str === '' || str === '{}')) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
</script>
|
|
28
|
-
<style scoped>
|
|
29
|
-
.app-info-content {
|
|
30
|
-
padding: 16px;
|
|
31
|
-
font-size: var(--dev-tool-base-font-size);
|
|
32
|
-
|
|
33
|
-
height: calc(100% - 32px);
|
|
34
|
-
overflow: auto;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="auto-sizer">
|
|
3
|
-
<!-- 大小和slot 内容宽度一致 -->
|
|
4
|
-
<view class="listener-slot">
|
|
5
|
-
<slot></slot>
|
|
6
|
-
</view>
|
|
7
|
-
|
|
8
|
-
<!-- 变大监听固定在 listener-slot 右下角大1px位置 变大时 相交触发监听 -->
|
|
9
|
-
<view
|
|
10
|
-
class="anchor-height-add"
|
|
11
|
-
:style="{
|
|
12
|
-
top: listenerSlot.height + 1 + 'px',
|
|
13
|
-
}"
|
|
14
|
-
>
|
|
15
|
-
</view>
|
|
16
|
-
|
|
17
|
-
<!-- 变小监听固定在 listener-slot 右下角小1px位置 减小时 离开触发监听 -->
|
|
18
|
-
<view
|
|
19
|
-
class="anchor-height-sub"
|
|
20
|
-
:style="{
|
|
21
|
-
top: listenerSlot.height - 1 + 'px',
|
|
22
|
-
}"
|
|
23
|
-
>
|
|
24
|
-
</view>
|
|
25
|
-
|
|
26
|
-
<!-- 变大监听固定在 listener-slot 右下角大1px位置 变大时 相交触发监听 -->
|
|
27
|
-
<view
|
|
28
|
-
class="anchor-width-add"
|
|
29
|
-
:style="{
|
|
30
|
-
left: listenerSlot.width + 1 + 'px',
|
|
31
|
-
top: '0px',
|
|
32
|
-
}"
|
|
33
|
-
>
|
|
34
|
-
</view>
|
|
35
|
-
|
|
36
|
-
<!-- 变小监听固定在 listener-slot 右下角小1px位置 减小时 离开触发监听 -->
|
|
37
|
-
<view
|
|
38
|
-
class="anchor-width-sub"
|
|
39
|
-
:style="{
|
|
40
|
-
left: listenerSlot.width - 1 + 'px',
|
|
41
|
-
top: '0px',
|
|
42
|
-
}"
|
|
43
|
-
>
|
|
44
|
-
</view>
|
|
45
|
-
</view>
|
|
46
|
-
</template>
|
|
47
|
-
<script lang="ts" setup>
|
|
48
|
-
import {
|
|
49
|
-
getCurrentInstance,
|
|
50
|
-
onMounted,
|
|
51
|
-
inject,
|
|
52
|
-
reactive,
|
|
53
|
-
onUnmounted,
|
|
54
|
-
} from 'vue';
|
|
55
|
-
import { debounce } from '../../utils';
|
|
56
|
-
|
|
57
|
-
type Size = {
|
|
58
|
-
width: number;
|
|
59
|
-
height: number;
|
|
60
|
-
top: number;
|
|
61
|
-
left: number;
|
|
62
|
-
right: number;
|
|
63
|
-
bottom: number;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const props = defineProps<{
|
|
67
|
-
index: number;
|
|
68
|
-
immediate?: boolean;
|
|
69
|
-
}>();
|
|
70
|
-
|
|
71
|
-
const emit = defineEmits<{ (e: 'resize', size: Size): void }>();
|
|
72
|
-
|
|
73
|
-
let isMounted = false;
|
|
74
|
-
|
|
75
|
-
const listenerSlot = reactive({
|
|
76
|
-
width: 0,
|
|
77
|
-
height: 0,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const size: Size = {
|
|
81
|
-
width: 0,
|
|
82
|
-
height: 0,
|
|
83
|
-
top: 0,
|
|
84
|
-
left: 0,
|
|
85
|
-
right: 0,
|
|
86
|
-
bottom: 0,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const instance = getCurrentInstance();
|
|
90
|
-
|
|
91
|
-
const query = uni.createSelectorQuery().in(instance);
|
|
92
|
-
|
|
93
|
-
const onSizeChange =
|
|
94
|
-
inject<(index: number, height: number) => void>('onSizeChange');
|
|
95
|
-
|
|
96
|
-
/** 外界记录的高度 */
|
|
97
|
-
const itemsHeight = inject<number[]>('itemsHeight');
|
|
98
|
-
|
|
99
|
-
const debounceReact = debounce(
|
|
100
|
-
(rect: UniApp.NodeInfo | UniApp.NodeInfo[]) => {
|
|
101
|
-
if (Array.isArray(rect)) return;
|
|
102
|
-
|
|
103
|
-
// 获取屏幕尺寸
|
|
104
|
-
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
|
|
105
|
-
|
|
106
|
-
// 在尺寸更新时限制最大值
|
|
107
|
-
listenerSlot.height = Math.min(rect.height ?? 0, windowHeight);
|
|
108
|
-
listenerSlot.width = Math.min(rect.width ?? 0, windowWidth);
|
|
109
|
-
|
|
110
|
-
onSizeChange?.(props.index, rect.height ?? 0);
|
|
111
|
-
|
|
112
|
-
size.width = rect.width ?? 0;
|
|
113
|
-
size.height = rect.height ?? 0;
|
|
114
|
-
size.top = rect.top ?? 0;
|
|
115
|
-
size.left = rect.left ?? 0;
|
|
116
|
-
size.right = rect.right ?? 0;
|
|
117
|
-
size.bottom = rect.bottom ?? 0;
|
|
118
|
-
|
|
119
|
-
if (props.immediate && !isMounted) {
|
|
120
|
-
emit('resize', size);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (isMounted) {
|
|
124
|
-
emit('resize', size);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
isMounted = true;
|
|
128
|
-
},
|
|
129
|
-
100,
|
|
130
|
-
true,
|
|
131
|
-
);
|
|
132
|
-
function getSize() {
|
|
133
|
-
query.select('.listener-slot').boundingClientRect(debounceReact).exec();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const debounceGetSize = debounce(getSize, 100, true);
|
|
137
|
-
|
|
138
|
-
let observer: UniNamespace.IntersectionObserver;
|
|
139
|
-
onMounted(() => {
|
|
140
|
-
// 防止重复获取
|
|
141
|
-
// TODO
|
|
142
|
-
// if (itemsHeight && itemsHeight?.[props.index]) return;
|
|
143
|
-
|
|
144
|
-
// 初始大小
|
|
145
|
-
debounceGetSize();
|
|
146
|
-
|
|
147
|
-
// TODO 只有可视范围之内才获取大小
|
|
148
|
-
observer = uni.createIntersectionObserver(instance, { thresholds: [0, 1] });
|
|
149
|
-
// 变大监听
|
|
150
|
-
observer
|
|
151
|
-
.relativeTo('.auto-sizer')
|
|
152
|
-
.observe('.anchor-height-add', debounceGetSize);
|
|
153
|
-
// 变小监听
|
|
154
|
-
observer
|
|
155
|
-
.relativeTo('.auto-sizer')
|
|
156
|
-
.observe('.anchor-height-sub', debounceGetSize);
|
|
157
|
-
|
|
158
|
-
// 变大监听
|
|
159
|
-
observer
|
|
160
|
-
.relativeTo('.auto-sizer')
|
|
161
|
-
.observe('.anchor-width-add', debounceGetSize);
|
|
162
|
-
// 变小监听
|
|
163
|
-
observer
|
|
164
|
-
.relativeTo('.auto-sizer')
|
|
165
|
-
.observe('.anchor-width-sub', debounceGetSize);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
onUnmounted(() => {
|
|
169
|
-
// 销毁监听
|
|
170
|
-
observer.disconnect();
|
|
171
|
-
});
|
|
172
|
-
</script>
|
|
173
|
-
|
|
174
|
-
<style scoped>
|
|
175
|
-
.auto-sizer {
|
|
176
|
-
position: relative;
|
|
177
|
-
overflow: hidden;
|
|
178
|
-
width: min-content;
|
|
179
|
-
height: min-content;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.anchor-height-add,
|
|
183
|
-
.anchor-height-sub,
|
|
184
|
-
.anchor-width-add,
|
|
185
|
-
.anchor-width-sub {
|
|
186
|
-
position: absolute;
|
|
187
|
-
width: 1px;
|
|
188
|
-
height: 1px;
|
|
189
|
-
|
|
190
|
-
background-color: skyblue;
|
|
191
|
-
visibility: hidden;
|
|
192
|
-
}
|
|
193
|
-
</style>
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="l-resize l-class"
|
|
4
|
-
:class="{ 'l-resize-target': hasNoDefaultSlot }"
|
|
5
|
-
:style="[styles, lStyle]"
|
|
6
|
-
>
|
|
7
|
-
<!--插槽需要脱离父容器文档流,防止父容器固宽固高,进而导致插槽大小被被父容器限制-->
|
|
8
|
-
<view
|
|
9
|
-
ref="l-resize__container"
|
|
10
|
-
class="l-resize__container l-container-class"
|
|
11
|
-
:style="[lStyle]"
|
|
12
|
-
>
|
|
13
|
-
<!--被监听的插槽-->
|
|
14
|
-
<slot></slot>
|
|
15
|
-
<!--监听插槽变大-->
|
|
16
|
-
<scroll-view
|
|
17
|
-
class="l-resize__wrapper"
|
|
18
|
-
:scroll-y="true"
|
|
19
|
-
:scroll-x="true"
|
|
20
|
-
:scroll-top="expandScrollTop"
|
|
21
|
-
:scroll-left="expandScrollLeft"
|
|
22
|
-
@scroll="onScrollHandler"
|
|
23
|
-
>
|
|
24
|
-
<view
|
|
25
|
-
class="l-resize__wrapper--placeholder"
|
|
26
|
-
style="height: 100000px; width: 100000px"
|
|
27
|
-
></view>
|
|
28
|
-
</scroll-view>
|
|
29
|
-
<!--监听插槽变小-->
|
|
30
|
-
<scroll-view
|
|
31
|
-
class="l-resize__wrapper"
|
|
32
|
-
:scroll-y="true"
|
|
33
|
-
:scroll-x="true"
|
|
34
|
-
:scroll-top="shrinkScrollTop"
|
|
35
|
-
:scroll-left="shrinkScrollLeft"
|
|
36
|
-
@scroll="onScrollHandler"
|
|
37
|
-
>
|
|
38
|
-
<view
|
|
39
|
-
class="l-resize__wrapper--placeholder"
|
|
40
|
-
style="height: 250%; width: 250%"
|
|
41
|
-
></view>
|
|
42
|
-
</scroll-view>
|
|
43
|
-
</view>
|
|
44
|
-
</view>
|
|
45
|
-
</template>
|
|
46
|
-
<script lang="ts" setup>
|
|
47
|
-
import { ref, onMounted, getCurrentInstance, computed } from 'vue';
|
|
48
|
-
import { getRect, addUnit } from './utils';
|
|
49
|
-
|
|
50
|
-
interface ResizeResult {
|
|
51
|
-
bottom?: number;
|
|
52
|
-
top?: number;
|
|
53
|
-
left?: number;
|
|
54
|
-
right?: number;
|
|
55
|
-
height?: number;
|
|
56
|
-
width?: number;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
defineProps<{
|
|
60
|
-
lStyle?: any;
|
|
61
|
-
}>();
|
|
62
|
-
|
|
63
|
-
const emit = defineEmits(['resize']);
|
|
64
|
-
|
|
65
|
-
const context = getCurrentInstance();
|
|
66
|
-
const width = ref(0);
|
|
67
|
-
const hasNoDefaultSlot = ref(false);
|
|
68
|
-
const height = ref(0);
|
|
69
|
-
const expandScrollTop = ref(0);
|
|
70
|
-
const expandScrollLeft = ref(0);
|
|
71
|
-
const shrinkScrollTop = ref(0);
|
|
72
|
-
const shrinkScrollLeft = ref(0);
|
|
73
|
-
|
|
74
|
-
let scrollEventCount = 0;
|
|
75
|
-
let lastHeight = 0;
|
|
76
|
-
let lastWidth = 0;
|
|
77
|
-
const querySelector = '.l-resize__container';
|
|
78
|
-
let onScrollHandlerClone = () => {
|
|
79
|
-
getRect(querySelector, context).then((res: ResizeResult) => {
|
|
80
|
-
// 前两次滚动事件被触发,说明 created 的修改已渲染,通知用户代码当前容器大小
|
|
81
|
-
if (scrollEventCount++ === 0) {
|
|
82
|
-
resizeEvent(res);
|
|
83
|
-
}
|
|
84
|
-
// 滚动条拉到底部会触发两次多余的事件,屏蔽掉。
|
|
85
|
-
if (scrollEventCount < 3) return;
|
|
86
|
-
// 手动设置父容器高宽,防止父容器坍塌
|
|
87
|
-
// 滚动完,重新获取容器新的高度
|
|
88
|
-
const newHeight = res.height;
|
|
89
|
-
const newWidth = res.width;
|
|
90
|
-
// 立即填充父容器高宽
|
|
91
|
-
height.value = newHeight ?? 0;
|
|
92
|
-
width.value = newWidth ?? 0;
|
|
93
|
-
// 宽高都改变时,只需要触发一次 size 事件
|
|
94
|
-
const emitStack = [];
|
|
95
|
-
if (newHeight !== lastHeight) {
|
|
96
|
-
lastHeight = newHeight ?? 0;
|
|
97
|
-
emitStack.push(1);
|
|
98
|
-
}
|
|
99
|
-
if (newWidth !== lastWidth) {
|
|
100
|
-
lastWidth = newWidth ?? 0;
|
|
101
|
-
emitStack.push(1);
|
|
102
|
-
}
|
|
103
|
-
if (emitStack.length !== 0) {
|
|
104
|
-
resizeEvent(res);
|
|
105
|
-
}
|
|
106
|
-
// 滚动条拉到底部(如果使用 nextTick 效果更佳)
|
|
107
|
-
scrollToBottom({ width: lastWidth, height: lastHeight });
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
let onScrollHandler = () => {
|
|
111
|
-
if (onScrollHandlerClone) {
|
|
112
|
-
onScrollHandlerClone();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const scrollToBottom = (res: Record<string, number>) => {
|
|
116
|
-
expandScrollTop.value = 100000 + res.height;
|
|
117
|
-
shrinkScrollTop.value = 3 * height.value + res.height;
|
|
118
|
-
expandScrollLeft.value = 100000 + res.width;
|
|
119
|
-
shrinkScrollLeft.value = 3 * width.value + res.width;
|
|
120
|
-
};
|
|
121
|
-
const resizeEvent = (res: ResizeResult) => {
|
|
122
|
-
const result: any = {};
|
|
123
|
-
['bottom', 'top', 'left', 'right', 'height', 'width'].forEach((propName) => {
|
|
124
|
-
result[propName] = res[propName as keyof ResizeResult];
|
|
125
|
-
});
|
|
126
|
-
emit('resize', result);
|
|
127
|
-
};
|
|
128
|
-
const styles = computed(() => {
|
|
129
|
-
if (context && context.slots?.default && (width.value || height.value)) {
|
|
130
|
-
return {
|
|
131
|
-
width: addUnit(width.value),
|
|
132
|
-
height: addUnit(height.value),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
return {};
|
|
136
|
-
});
|
|
137
|
-
onMounted(() => {
|
|
138
|
-
// const options = { context };
|
|
139
|
-
hasNoDefaultSlot.value = !context?.slots.default;
|
|
140
|
-
getRect(querySelector, context).then((res) => {
|
|
141
|
-
// 闭包记录容器高度
|
|
142
|
-
lastHeight = res.height ?? 0;
|
|
143
|
-
lastWidth = res.width ?? 0;
|
|
144
|
-
// 立即填充父容器高宽
|
|
145
|
-
width.value = lastWidth;
|
|
146
|
-
height.value = lastHeight;
|
|
147
|
-
|
|
148
|
-
scrollToBottom({ width: lastWidth, height: lastHeight });
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
</script>
|
|
152
|
-
<style lang="scss" scoped>
|
|
153
|
-
.l-resize {
|
|
154
|
-
&__container {
|
|
155
|
-
position: absolute;
|
|
156
|
-
min-width: 1px;
|
|
157
|
-
min-height: 1px;
|
|
158
|
-
}
|
|
159
|
-
&-target,
|
|
160
|
-
&__wrapper {
|
|
161
|
-
background-color: aqua;
|
|
162
|
-
position: absolute;
|
|
163
|
-
top: 0;
|
|
164
|
-
bottom: 0;
|
|
165
|
-
left: 0;
|
|
166
|
-
right: 0;
|
|
167
|
-
z-index: -9999;
|
|
168
|
-
overflow: hidden;
|
|
169
|
-
|
|
170
|
-
visibility: hidden;
|
|
171
|
-
}
|
|
172
|
-
&-target {
|
|
173
|
-
.l-resize__container {
|
|
174
|
-
width: 100%;
|
|
175
|
-
height: 100%;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
&__wrapper {
|
|
179
|
-
&--placeholder {
|
|
180
|
-
transition: 0s;
|
|
181
|
-
|
|
182
|
-
animation: none;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
</style>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ComponentInternalInstance, ComponentPublicInstance } from 'vue';
|
|
2
|
-
|
|
3
|
-
export function getRect(
|
|
4
|
-
selector: string,
|
|
5
|
-
context: ComponentInternalInstance | null | any,
|
|
6
|
-
node: boolean = false,
|
|
7
|
-
) {
|
|
8
|
-
// 之前是个对象,现在改成实例,防止旧版会报错
|
|
9
|
-
if (context == null) {
|
|
10
|
-
return Promise.reject('context is null');
|
|
11
|
-
}
|
|
12
|
-
if (context?.context) {
|
|
13
|
-
context = context.context;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return new Promise<UniNamespace.NodeInfo>((resolve, reject) => {
|
|
17
|
-
const dom = uni.createSelectorQuery().in(context).select(selector);
|
|
18
|
-
const result: any = (rect: UniNamespace.NodeInfo) => {
|
|
19
|
-
if (rect) {
|
|
20
|
-
resolve(rect);
|
|
21
|
-
} else {
|
|
22
|
-
reject('no rect');
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (!node) {
|
|
27
|
-
dom.boundingClientRect(result).exec();
|
|
28
|
-
} else {
|
|
29
|
-
dom
|
|
30
|
-
.fields(
|
|
31
|
-
{
|
|
32
|
-
node: true,
|
|
33
|
-
size: true,
|
|
34
|
-
rect: true,
|
|
35
|
-
},
|
|
36
|
-
result,
|
|
37
|
-
)
|
|
38
|
-
.exec();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function addUnit(value?: string | number): string {
|
|
44
|
-
if (!value) {
|
|
45
|
-
return '0px';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return typeof value === 'number' ? `${value}px` : value;
|
|
49
|
-
}
|