pixuireactcomponents 1.1.21 → 1.1.22

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.
Files changed (37) hide show
  1. package/README.md +5 -5
  2. package/index.d.ts +15 -15
  3. package/index.js +16 -16
  4. package/package.json +11 -11
  5. package/tools/EventDispatcherJs.d.ts +10 -10
  6. package/tools/EventDispatcherJs.js +71 -71
  7. package/tools/Logger.d.ts +6 -6
  8. package/tools/Logger.js +138 -138
  9. package/tools/tools.md +21 -21
  10. package/ui/components/button/Button.d.ts +5 -5
  11. package/ui/components/button/Button.js +37 -37
  12. package/ui/components/carousel/Carousel.d.ts +5 -5
  13. package/ui/components/carousel/Carousel.js +219 -219
  14. package/ui/components/dropdown/Dropdown.d.ts +30 -30
  15. package/ui/components/dropdown/Dropdown.js +92 -92
  16. package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -11
  17. package/ui/components/dropdown/DropdownOptionUI.js +28 -28
  18. package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -9
  19. package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -27
  20. package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -9
  21. package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -27
  22. package/ui/components/gradient/GradientText.d.ts +63 -63
  23. package/ui/components/gradient/GradientText.js +329 -329
  24. package/ui/components/outlinetext/OutlineText.d.ts +73 -73
  25. package/ui/components/outlinetext/OutlineText.js +157 -157
  26. package/ui/components/progress/Progress.d.ts +34 -34
  27. package/ui/components/progress/Progress.js +142 -142
  28. package/ui/components/slapface/Slapface.d.ts +12 -12
  29. package/ui/components/slapface/Slapface.js +224 -227
  30. package/ui/components/slapface/less/Slapface.less +125 -0
  31. package/ui/components/slider/Slider.d.ts +57 -57
  32. package/ui/components/slider/Slider.js +289 -289
  33. package/ui/components/tab/Tab.d.ts +6 -6
  34. package/ui/components/tab/Tab.js +27 -27
  35. package/ui/components/tab/Tabs.d.ts +12 -12
  36. package/ui/components/tab/Tabs.js +54 -54
  37. package/ui/ui.md +1 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # 组件库
2
-
3
- 本组件库目前分为2大类:ui组件和工具组件。分别参见目录ui/和目录tools。
4
- 具体组件说明,参见对应类别目录下的md文档
5
-
1
+ # 组件库
2
+
3
+ 本组件库目前分为2大类:ui组件和工具组件。分别参见目录ui/和目录tools。
4
+ 具体组件说明,参见对应类别目录下的md文档
5
+
package/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export { Tabs } from "./ui/components/tab/Tabs";
2
- export { Tab } from "./ui/components/tab/Tab";
3
- export { Slider } from "./ui/components/slider/Slider";
4
- export { Progress } from "./ui/components/progress/Progress";
5
- export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
6
- export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
7
- export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
8
- export { GradientText } from "./ui/components/gradient/GradientText";
9
- export { OutlineText } from "./ui/components/outlinetext/OutlineText";
10
- export { Logger } from "./tools/Logger";
11
- export { EventDispatcherJs } from "./tools/EventDispatcherJs";
12
- export { Carousel } from "./ui/components/carousel/Carousel";
13
- export { Slapface } from "./ui/components/slapface/Slapface";
14
- export { Button } from "./ui/components/button/Button";
15
- export { Dropdown, DropdownConfig } from "./ui/components/dropdown/Dropdown";
1
+ export { Tabs } from "./ui/components/tab/Tabs";
2
+ export { Tab } from "./ui/components/tab/Tab";
3
+ export { Slider } from "./ui/components/slider/Slider";
4
+ export { Progress } from "./ui/components/progress/Progress";
5
+ export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
6
+ export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
7
+ export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
8
+ export { GradientText } from "./ui/components/gradient/GradientText";
9
+ export { OutlineText } from "./ui/components/outlinetext/OutlineText";
10
+ export { Logger } from "./tools/Logger";
11
+ export { EventDispatcherJs } from "./tools/EventDispatcherJs";
12
+ export { Carousel } from "./ui/components/carousel/Carousel";
13
+ export { Slapface } from "./ui/components/slapface/Slapface";
14
+ export { Button } from "./ui/components/button/Button";
15
+ export { Dropdown, DropdownConfig } from "./ui/components/dropdown/Dropdown";
package/index.js CHANGED
@@ -1,16 +1,16 @@
1
- export { Tabs } from "./ui/components/tab/Tabs";
2
- export { Tab } from "./ui/components/tab/Tab";
3
- export { Slider } from "./ui/components/slider/Slider";
4
- export { Progress } from "./ui/components/progress/Progress";
5
- export { Dropdown } from "./ui/components/dropdown/Dropdown";
6
- export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
7
- export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
8
- export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
9
- export { GradientText } from "./ui/components/gradient/GradientText";
10
- export { OutlineText } from "./ui/components/outlinetext/OutlineText";
11
- export { Logger } from "./tools/Logger";
12
- export { EventDispatcherJs } from "./tools/EventDispatcherJs";
13
- export { Carousel } from "./ui/components/carousel/Carousel";
14
- export { Slapface } from "./ui/components/slapface/Slapface";
15
- export { Button } from "./ui/components/button/Button";
16
- console.log("Hello, 欢迎使用PixUI React Components");
1
+ export { Tabs } from "./ui/components/tab/Tabs";
2
+ export { Tab } from "./ui/components/tab/Tab";
3
+ export { Slider } from "./ui/components/slider/Slider";
4
+ export { Progress } from "./ui/components/progress/Progress";
5
+ export { Dropdown } from "./ui/components/dropdown/Dropdown";
6
+ export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
7
+ export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
8
+ export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
9
+ export { GradientText } from "./ui/components/gradient/GradientText";
10
+ export { OutlineText } from "./ui/components/outlinetext/OutlineText";
11
+ export { Logger } from "./tools/Logger";
12
+ export { EventDispatcherJs } from "./tools/EventDispatcherJs";
13
+ export { Carousel } from "./ui/components/carousel/Carousel";
14
+ export { Slapface } from "./ui/components/slapface/Slapface";
15
+ export { Button } from "./ui/components/button/Button";
16
+ console.log("Hello, 欢迎使用PixUI React Components");
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
- {
2
- "name": "pixuireactcomponents",
3
- "version": "1.1.21",
4
- "description": "pixui react components",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "hardenzheng",
10
- "license": "ISC"
11
- }
1
+ {
2
+ "name": "pixuireactcomponents",
3
+ "version": "1.1.22",
4
+ "description": "pixui react components",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "hardenzheng",
10
+ "license": "ISC"
11
+ }
@@ -1,10 +1,10 @@
1
- declare class EventDispatcherCls {
2
- private listeners;
3
- AddEventListener(eventName: string, listener: any, ...args: any[]): void;
4
- HasEventListener(eventName: string): boolean;
5
- RemoveEventListener(eventName: string, listener: any): void;
6
- RemoveEventAllListener(eventName: string): void;
7
- DispatchEvent(eventName: string, ...args: any[]): void;
8
- }
9
- export declare let EventDispatcherJs: Readonly<EventDispatcherCls>;
10
- export {};
1
+ declare class EventDispatcherCls {
2
+ private listeners;
3
+ AddEventListener(eventName: string, listener: any, ...args: any[]): void;
4
+ HasEventListener(eventName: string): boolean;
5
+ RemoveEventListener(eventName: string, listener: any): void;
6
+ RemoveEventAllListener(eventName: string): void;
7
+ DispatchEvent(eventName: string, ...args: any[]): void;
8
+ }
9
+ export declare let EventDispatcherJs: Readonly<EventDispatcherCls>;
10
+ export {};
@@ -1,71 +1,71 @@
1
- var EventDispatcherCls = /** @class */ (function () {
2
- function EventDispatcherCls() {
3
- this.listeners = {};
4
- }
5
- EventDispatcherCls.prototype.AddEventListener = function (eventName, listener) {
6
- var args = [];
7
- for (var _i = 2; _i < arguments.length; _i++) {
8
- args[_i - 2] = arguments[_i];
9
- }
10
- if (listener == undefined) {
11
- console.warn("listener为空, eventName: " + eventName);
12
- return;
13
- }
14
- var listeners = this.listeners;
15
- if (listeners[eventName] == undefined) {
16
- listeners[eventName] = [];
17
- }
18
- var eventList = listeners[eventName];
19
- eventList.forEach(function (v) {
20
- if (v.eventName == eventName && v.listener == listener) {
21
- console.warn("重复添加的事件监听, eventName: " + eventName);
22
- return;
23
- }
24
- });
25
- eventList.push({ "eventName": eventName, "listener": listener, "args": args, });
26
- };
27
- EventDispatcherCls.prototype.HasEventListener = function (eventName) {
28
- if (this.listeners[eventName] == undefined || this.listeners[eventName].length == 0) {
29
- return false;
30
- }
31
- return true;
32
- };
33
- EventDispatcherCls.prototype.RemoveEventListener = function (eventName, listener) {
34
- if (this.HasEventListener(eventName) == false) {
35
- return;
36
- }
37
- var eventList = this.listeners[eventName];
38
- for (var i = eventList.length - 1; i >= 0; --i) {
39
- var event_1 = eventList[i];
40
- if (event_1.eventName == eventName && event_1.listener == listener) {
41
- eventList.splice(i, 1);
42
- }
43
- }
44
- if (eventList.length == 0) {
45
- this.listeners[eventName] = null;
46
- }
47
- };
48
- EventDispatcherCls.prototype.RemoveEventAllListener = function (eventName) {
49
- if (this.HasEventListener(eventName)) {
50
- this.listeners[eventName] = null;
51
- }
52
- };
53
- EventDispatcherCls.prototype.DispatchEvent = function (eventName) {
54
- var args = [];
55
- for (var _i = 1; _i < arguments.length; _i++) {
56
- args[_i - 1] = arguments[_i];
57
- }
58
- if (eventName == undefined || this.HasEventListener(eventName) == false) {
59
- return;
60
- }
61
- var eventList = this.listeners[eventName].slice(0);
62
- for (var i = 0; i < eventList.length; ++i) {
63
- var obj = eventList[i];
64
- var listener = obj.listener;
65
- // listener.apply(this, obj.args.concat(args));
66
- listener.apply(void 0, obj.args.concat(args));
67
- }
68
- };
69
- return EventDispatcherCls;
70
- }());
71
- export var EventDispatcherJs = Object.freeze(new EventDispatcherCls());
1
+ var EventDispatcherCls = /** @class */ (function () {
2
+ function EventDispatcherCls() {
3
+ this.listeners = {};
4
+ }
5
+ EventDispatcherCls.prototype.AddEventListener = function (eventName, listener) {
6
+ var args = [];
7
+ for (var _i = 2; _i < arguments.length; _i++) {
8
+ args[_i - 2] = arguments[_i];
9
+ }
10
+ if (listener == undefined) {
11
+ console.warn("listener为空, eventName: " + eventName);
12
+ return;
13
+ }
14
+ var listeners = this.listeners;
15
+ if (listeners[eventName] == undefined) {
16
+ listeners[eventName] = [];
17
+ }
18
+ var eventList = listeners[eventName];
19
+ eventList.forEach(function (v) {
20
+ if (v.eventName == eventName && v.listener == listener) {
21
+ console.warn("重复添加的事件监听, eventName: " + eventName);
22
+ return;
23
+ }
24
+ });
25
+ eventList.push({ "eventName": eventName, "listener": listener, "args": args, });
26
+ };
27
+ EventDispatcherCls.prototype.HasEventListener = function (eventName) {
28
+ if (this.listeners[eventName] == undefined || this.listeners[eventName].length == 0) {
29
+ return false;
30
+ }
31
+ return true;
32
+ };
33
+ EventDispatcherCls.prototype.RemoveEventListener = function (eventName, listener) {
34
+ if (this.HasEventListener(eventName) == false) {
35
+ return;
36
+ }
37
+ var eventList = this.listeners[eventName];
38
+ for (var i = eventList.length - 1; i >= 0; --i) {
39
+ var event_1 = eventList[i];
40
+ if (event_1.eventName == eventName && event_1.listener == listener) {
41
+ eventList.splice(i, 1);
42
+ }
43
+ }
44
+ if (eventList.length == 0) {
45
+ this.listeners[eventName] = null;
46
+ }
47
+ };
48
+ EventDispatcherCls.prototype.RemoveEventAllListener = function (eventName) {
49
+ if (this.HasEventListener(eventName)) {
50
+ this.listeners[eventName] = null;
51
+ }
52
+ };
53
+ EventDispatcherCls.prototype.DispatchEvent = function (eventName) {
54
+ var args = [];
55
+ for (var _i = 1; _i < arguments.length; _i++) {
56
+ args[_i - 1] = arguments[_i];
57
+ }
58
+ if (eventName == undefined || this.HasEventListener(eventName) == false) {
59
+ return;
60
+ }
61
+ var eventList = this.listeners[eventName].slice(0);
62
+ for (var i = 0; i < eventList.length; ++i) {
63
+ var obj = eventList[i];
64
+ var listener = obj.listener;
65
+ // listener.apply(this, obj.args.concat(args));
66
+ listener.apply(void 0, obj.args.concat(args));
67
+ }
68
+ };
69
+ return EventDispatcherCls;
70
+ }());
71
+ export var EventDispatcherJs = Object.freeze(new EventDispatcherCls());
package/tools/Logger.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export declare function Logger(): void;
2
- export declare namespace Logger {
3
- var ObjectPrinter: (object: any, name: any) => void;
4
- var ObjectPrinter2: (object: any, name: any) => void;
5
- var HierarchyPrinter: (object: any, name: any) => void;
6
- }
1
+ export declare function Logger(): void;
2
+ export declare namespace Logger {
3
+ var ObjectPrinter: (object: any, name: any) => void;
4
+ var ObjectPrinter2: (object: any, name: any) => void;
5
+ var HierarchyPrinter: (object: any, name: any) => void;
6
+ }
package/tools/Logger.js CHANGED
@@ -1,138 +1,138 @@
1
- export function Logger() {
2
- }
3
- // 移除最后一个(key, value)后面的 ','
4
- var regex = new RegExp("(,)(\n$)");
5
- /**
6
- * printer1: 完整打印,用4个空格缩进
7
- * @param object Object
8
- * @param name string
9
- */
10
- Logger.ObjectPrinter = function (object, name) {
11
- var strResult = "";
12
- strResult += name + " = ";
13
- strResult += getTreeStyleStr(object, 1);
14
- strResult = strResult.replace(regex, "$2");
15
- console.warn(strResult);
16
- };
17
- function getTreeStyleStr(object, level) {
18
- var isArray = object instanceof Array;
19
- var str = isArray ? "[\n" : "{\n";
20
- for (var key in object) {
21
- var value = object[key];
22
- var curSeparation = getSeparation1(level);
23
- if (typeof (value) != 'object') {
24
- str += curSeparation + key + " : " + value + ",\n";
25
- }
26
- else {
27
- str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
28
- }
29
- }
30
- str = str.replace(regex, "$2");
31
- str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
32
- return str;
33
- }
34
- var SEPARARION1 = " ";
35
- function getSeparation1(level) {
36
- var totalSeparation = "";
37
- while (level > 0) {
38
- totalSeparation += SEPARARION1;
39
- level--;
40
- }
41
- return totalSeparation;
42
- }
43
- var regexForLine = new RegExp(",$");
44
- /**
45
- * printer2: 完整打印,用\t
46
- * @param object Object
47
- * @param name sring
48
- */
49
- Logger.ObjectPrinter2 = function (object, name) {
50
- var lines = [];
51
- lines.push("".concat(name, " = "));
52
- getTreeStyleLines(object, 1, lines);
53
- console.warn(lines.join("\n"));
54
- };
55
- function getTreeStyleLines(object, level, lines) {
56
- var isArray = object instanceof Array;
57
- var linePostFix = isArray ? "[" : "{";
58
- var lastLine = lines.pop();
59
- lines.push(lastLine + linePostFix);
60
- for (var key in object) {
61
- var value = object[key];
62
- var curSeparation = getSeparation2(level);
63
- if (typeof (value) != 'object') {
64
- var curLine = curSeparation + key + " : " + value + ",";
65
- lines.push(curLine);
66
- }
67
- else {
68
- var curLinePreFix = curSeparation + key + " : ";
69
- lines.push(curLinePreFix);
70
- getTreeStyleLines(value, level + 1, lines);
71
- }
72
- }
73
- lastLine = lines.pop();
74
- if (lastLine)
75
- lines.push(lastLine.replace(regexForLine, "")); // 一定执行
76
- lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
77
- }
78
- var SEPARARION2 = "\t";
79
- function getSeparation2(level) {
80
- var totalSeparation = "";
81
- while (level > 0) {
82
- totalSeparation += SEPARARION2;
83
- level--;
84
- }
85
- return totalSeparation;
86
- }
87
- /**
88
- *
89
- printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
90
- * @param object Object
91
- * @param name string
92
- */
93
- Logger.HierarchyPrinter = function (object, name) {
94
- var lines = [];
95
- lines.push("".concat(name, " = "));
96
- getTreeStyleHierarchyLines(object, 1, lines);
97
- console.warn(lines.join("\n"));
98
- };
99
- function getTreeStyleHierarchyLines(object, level, lines) {
100
- var isArray = object instanceof Array;
101
- var linePostFix = isArray ? "[" : "{";
102
- var lastLine = lines.pop();
103
- lines.push(lastLine + linePostFix);
104
- if (isArray) {
105
- var key = 0;
106
- var value = object[key];
107
- var curSeparation = getSeparation2(level);
108
- if (typeof (value) != 'object') {
109
- var curLine = curSeparation + key + " : " + value + ",";
110
- lines.push(curLine);
111
- }
112
- else {
113
- var curLinePreFix = curSeparation + key + " : ";
114
- lines.push(curLinePreFix);
115
- getTreeStyleHierarchyLines(value, level + 1, lines);
116
- }
117
- lines.push(curSeparation + "...len=" + object.length);
118
- }
119
- else {
120
- for (var key in object) {
121
- var value = object[key];
122
- var curSeparation = getSeparation2(level);
123
- if (typeof (value) != 'object') {
124
- var curLine = curSeparation + key + " : " + value + ",";
125
- lines.push(curLine);
126
- }
127
- else {
128
- var curLinePreFix = curSeparation + key + " : ";
129
- lines.push(curLinePreFix);
130
- getTreeStyleHierarchyLines(value, level + 1, lines);
131
- }
132
- }
133
- lastLine = lines.pop();
134
- if (lastLine)
135
- lines.push(lastLine.replace(regexForLine, "")); // 一定执行
136
- }
137
- lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
138
- }
1
+ export function Logger() {
2
+ }
3
+ // 移除最后一个(key, value)后面的 ','
4
+ var regex = new RegExp("(,)(\n$)");
5
+ /**
6
+ * printer1: 完整打印,用4个空格缩进
7
+ * @param object Object
8
+ * @param name string
9
+ */
10
+ Logger.ObjectPrinter = function (object, name) {
11
+ var strResult = "";
12
+ strResult += name + " = ";
13
+ strResult += getTreeStyleStr(object, 1);
14
+ strResult = strResult.replace(regex, "$2");
15
+ console.warn(strResult);
16
+ };
17
+ function getTreeStyleStr(object, level) {
18
+ var isArray = object instanceof Array;
19
+ var str = isArray ? "[\n" : "{\n";
20
+ for (var key in object) {
21
+ var value = object[key];
22
+ var curSeparation = getSeparation1(level);
23
+ if (typeof (value) != 'object') {
24
+ str += curSeparation + key + " : " + value + ",\n";
25
+ }
26
+ else {
27
+ str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
28
+ }
29
+ }
30
+ str = str.replace(regex, "$2");
31
+ str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
32
+ return str;
33
+ }
34
+ var SEPARARION1 = " ";
35
+ function getSeparation1(level) {
36
+ var totalSeparation = "";
37
+ while (level > 0) {
38
+ totalSeparation += SEPARARION1;
39
+ level--;
40
+ }
41
+ return totalSeparation;
42
+ }
43
+ var regexForLine = new RegExp(",$");
44
+ /**
45
+ * printer2: 完整打印,用\t
46
+ * @param object Object
47
+ * @param name sring
48
+ */
49
+ Logger.ObjectPrinter2 = function (object, name) {
50
+ var lines = [];
51
+ lines.push("".concat(name, " = "));
52
+ getTreeStyleLines(object, 1, lines);
53
+ console.warn(lines.join("\n"));
54
+ };
55
+ function getTreeStyleLines(object, level, lines) {
56
+ var isArray = object instanceof Array;
57
+ var linePostFix = isArray ? "[" : "{";
58
+ var lastLine = lines.pop();
59
+ lines.push(lastLine + linePostFix);
60
+ for (var key in object) {
61
+ var value = object[key];
62
+ var curSeparation = getSeparation2(level);
63
+ if (typeof (value) != 'object') {
64
+ var curLine = curSeparation + key + " : " + value + ",";
65
+ lines.push(curLine);
66
+ }
67
+ else {
68
+ var curLinePreFix = curSeparation + key + " : ";
69
+ lines.push(curLinePreFix);
70
+ getTreeStyleLines(value, level + 1, lines);
71
+ }
72
+ }
73
+ lastLine = lines.pop();
74
+ if (lastLine)
75
+ lines.push(lastLine.replace(regexForLine, "")); // 一定执行
76
+ lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
77
+ }
78
+ var SEPARARION2 = "\t";
79
+ function getSeparation2(level) {
80
+ var totalSeparation = "";
81
+ while (level > 0) {
82
+ totalSeparation += SEPARARION2;
83
+ level--;
84
+ }
85
+ return totalSeparation;
86
+ }
87
+ /**
88
+ *
89
+ printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
90
+ * @param object Object
91
+ * @param name string
92
+ */
93
+ Logger.HierarchyPrinter = function (object, name) {
94
+ var lines = [];
95
+ lines.push("".concat(name, " = "));
96
+ getTreeStyleHierarchyLines(object, 1, lines);
97
+ console.warn(lines.join("\n"));
98
+ };
99
+ function getTreeStyleHierarchyLines(object, level, lines) {
100
+ var isArray = object instanceof Array;
101
+ var linePostFix = isArray ? "[" : "{";
102
+ var lastLine = lines.pop();
103
+ lines.push(lastLine + linePostFix);
104
+ if (isArray) {
105
+ var key = 0;
106
+ var value = object[key];
107
+ var curSeparation = getSeparation2(level);
108
+ if (typeof (value) != 'object') {
109
+ var curLine = curSeparation + key + " : " + value + ",";
110
+ lines.push(curLine);
111
+ }
112
+ else {
113
+ var curLinePreFix = curSeparation + key + " : ";
114
+ lines.push(curLinePreFix);
115
+ getTreeStyleHierarchyLines(value, level + 1, lines);
116
+ }
117
+ lines.push(curSeparation + "...len=" + object.length);
118
+ }
119
+ else {
120
+ for (var key in object) {
121
+ var value = object[key];
122
+ var curSeparation = getSeparation2(level);
123
+ if (typeof (value) != 'object') {
124
+ var curLine = curSeparation + key + " : " + value + ",";
125
+ lines.push(curLine);
126
+ }
127
+ else {
128
+ var curLinePreFix = curSeparation + key + " : ";
129
+ lines.push(curLinePreFix);
130
+ getTreeStyleHierarchyLines(value, level + 1, lines);
131
+ }
132
+ }
133
+ lastLine = lines.pop();
134
+ if (lastLine)
135
+ lines.push(lastLine.replace(regexForLine, "")); // 一定执行
136
+ }
137
+ lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
138
+ }
package/tools/tools.md CHANGED
@@ -1,22 +1,22 @@
1
- # 工具类组件
2
- ### 1. EventDispatcherJs.tsx
3
- React里可供使用的事件派发器,类似Pandora Lua里的EventDispatcher。
4
-
5
- 用法主要就3个接口:
6
-
7
- * AddEventListener: 添加监听事件
8
- * DispatchEvent: 分发监听事件
9
- * RemoveEventListener: 移除监听事件
10
-
11
- ### 2. Logger.tsx
12
- React里可供使用的对象(数组)打印器。
13
-
14
- 直接console.log一个对象时,在游戏引擎中,无法打印出这个对象里的东西。而实际开发时,前后端联调时,需要方便的确认各种对象里的细节。
15
-
16
- 用法一共3个接口,打印粒度有差异。
17
-
18
- * ObjectPrinter: 打印一个对象的内部细节,效果如下
19
- ![](./img/logger.png)
20
-
21
- * ObjectPrinter2:比上一个打印的信息更多
1
+ # 工具类组件
2
+ ### 1. EventDispatcherJs.tsx
3
+ React里可供使用的事件派发器,类似Pandora Lua里的EventDispatcher。
4
+
5
+ 用法主要就3个接口:
6
+
7
+ * AddEventListener: 添加监听事件
8
+ * DispatchEvent: 分发监听事件
9
+ * RemoveEventListener: 移除监听事件
10
+
11
+ ### 2. Logger.tsx
12
+ React里可供使用的对象(数组)打印器。
13
+
14
+ 直接console.log一个对象时,在游戏引擎中,无法打印出这个对象里的东西。而实际开发时,前后端联调时,需要方便的确认各种对象里的细节。
15
+
16
+ 用法一共3个接口,打印粒度有差异。
17
+
18
+ * ObjectPrinter: 打印一个对象的内部细节,效果如下
19
+ ![](./img/logger.png)
20
+
21
+ * ObjectPrinter2:比上一个打印的信息更多
22
22
  * HierarchyPrinter: 采样打印,对数组进行采样,能打印最多的信息
@@ -1,5 +1,5 @@
1
- import { h, Component } from "preact";
2
- export declare class Button extends Component<any, any> {
3
- private btnImg;
4
- render(props: any): h.JSX.Element;
5
- }
1
+ import { h, Component } from "preact";
2
+ export declare class Button extends Component<any, any> {
3
+ private btnImg;
4
+ render(props: any): h.JSX.Element;
5
+ }