fast-vue-multi-pages 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/README.md +63 -0
  2. package/dist/cjs/FastVueMultiTool.d.ts +60 -0
  3. package/dist/cjs/FastVueMultiTool.js +65 -0
  4. package/dist/cjs/http/FastVueMultiCookie.d.ts +18 -0
  5. package/dist/cjs/http/FastVueMultiCookie.js +30 -0
  6. package/dist/cjs/http/FastVueMultiHttp.d.ts +225 -0
  7. package/dist/cjs/http/FastVueMultiHttp.js +572 -0
  8. package/dist/cjs/index.d.ts +2 -0
  9. package/dist/cjs/index.js +5 -0
  10. package/dist/cjs/loader/FastTagBuilderLoader.d.ts +2 -0
  11. package/dist/cjs/loader/FastTagBuilderLoader.js +89 -0
  12. package/dist/cjs/other/FastVueMultiBoolean.d.ts +13 -0
  13. package/dist/cjs/other/FastVueMultiBoolean.js +56 -0
  14. package/dist/cjs/other/FastVueMultiClipboard.d.ts +21 -0
  15. package/dist/cjs/other/FastVueMultiClipboard.js +38 -0
  16. package/dist/cjs/other/FastVueMultiDate.d.ts +30 -0
  17. package/dist/cjs/other/FastVueMultiDate.js +166 -0
  18. package/dist/cjs/other/FastVueMultiElement.d.ts +46 -0
  19. package/dist/cjs/other/FastVueMultiElement.js +154 -0
  20. package/dist/cjs/other/FastVueMultiFunction.d.ts +19 -0
  21. package/dist/cjs/other/FastVueMultiFunction.js +68 -0
  22. package/dist/cjs/other/FastVueMultiStore.d.ts +13 -0
  23. package/dist/cjs/other/FastVueMultiStore.js +23 -0
  24. package/dist/cjs/other/FastVueMultiWindow.d.ts +21 -0
  25. package/dist/cjs/other/FastVueMultiWindow.js +53 -0
  26. package/dist/cjs/store/FastVueMultiStore.d.ts +13 -0
  27. package/dist/cjs/store/FastVueMultiStore.js +23 -0
  28. package/dist/cjs/vue/FastVueMultiConfig.d.ts +18 -0
  29. package/dist/cjs/vue/FastVueMultiConfig.js +43 -0
  30. package/dist/esm/FastVueMultiTool.d.ts +60 -0
  31. package/dist/esm/FastVueMultiTool.js +59 -0
  32. package/dist/esm/http/FastVueMultiCookie.d.ts +18 -0
  33. package/dist/esm/http/FastVueMultiCookie.js +34 -0
  34. package/dist/esm/http/FastVueMultiHttp.d.ts +225 -0
  35. package/dist/esm/http/FastVueMultiHttp.js +608 -0
  36. package/dist/esm/index.d.ts +2 -0
  37. package/dist/esm/index.js +6 -0
  38. package/dist/esm/loader/FastTagBuilderLoader.d.ts +2 -0
  39. package/dist/esm/loader/FastTagBuilderLoader.js +89 -0
  40. package/dist/esm/other/FastVueMultiBoolean.d.ts +13 -0
  41. package/dist/esm/other/FastVueMultiBoolean.js +60 -0
  42. package/dist/esm/other/FastVueMultiClipboard.d.ts +21 -0
  43. package/dist/esm/other/FastVueMultiClipboard.js +56 -0
  44. package/dist/esm/other/FastVueMultiDate.d.ts +30 -0
  45. package/dist/esm/other/FastVueMultiDate.js +170 -0
  46. package/dist/esm/other/FastVueMultiElement.d.ts +46 -0
  47. package/dist/esm/other/FastVueMultiElement.js +158 -0
  48. package/dist/esm/other/FastVueMultiFunction.d.ts +19 -0
  49. package/dist/esm/other/FastVueMultiFunction.js +97 -0
  50. package/dist/esm/other/FastVueMultiStore.d.ts +13 -0
  51. package/dist/esm/other/FastVueMultiStore.js +27 -0
  52. package/dist/esm/other/FastVueMultiWindow.d.ts +21 -0
  53. package/dist/esm/other/FastVueMultiWindow.js +57 -0
  54. package/dist/esm/store/FastVueMultiStore.d.ts +13 -0
  55. package/dist/esm/store/FastVueMultiStore.js +27 -0
  56. package/dist/esm/vue/FastVueMultiConfig.d.ts +18 -0
  57. package/dist/esm/vue/FastVueMultiConfig.js +48 -0
  58. package/package.json +64 -0
  59. package/vue/FastBuildOption.d.ts +241 -0
  60. package/vue/FastBuildOption.js +249 -0
  61. package/vue/FastInjectJsPlugin.d.ts +11 -0
  62. package/vue/FastInjectJsPlugin.js +101 -0
  63. package/vue/FastPages.d.ts +25 -0
  64. package/vue/FastPages.js +173 -0
  65. package/vue/FastVueMultiConfig.d.ts +18 -0
  66. package/vue/FastVueMultiConfig.js +43 -0
  67. package/vue/FastVueMultiPages.d.ts +62 -0
  68. package/vue/FastVueMultiPages.js +294 -0
  69. package/vue/index.d.ts +2 -0
  70. package/vue/index.js +5 -0
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var htmlparser2 = require("htmlparser2");
3
+ var singleTag = ["br", "hr", "img", "input", "param", "meta", "link", "slot"];
4
+ /**
5
+ * 标签builder插件,用来处理是否排除标签内的代码
6
+ * @author Janesen
7
+ * @param source
8
+ */
9
+ module.exports = function (source) {
10
+ //对应配置的options
11
+ // @ts-ignore
12
+ var legacyLoaderConfig = this.query;
13
+ var parseNewHtml = "";
14
+ var isBreak = false, hasResolve = false;
15
+ var tagName = legacyLoaderConfig.buildLevelTagName;
16
+ var parser = new htmlparser2.Parser({
17
+ onopentag: function (name, attributes) {
18
+ if (isBreak) {
19
+ return;
20
+ }
21
+ var attr = "";
22
+ var buildConfig = {
23
+ level: 1,
24
+ };
25
+ for (var attributesKey in attributes) {
26
+ var attributesValue = attributes[attributesKey];
27
+ if (attributesValue.length === 0) {
28
+ attr += " " + attributesKey;
29
+ continue;
30
+ }
31
+ if (attributesKey === "level") {
32
+ buildConfig.level = parseInt(attributesValue);
33
+ }
34
+ attr += " " + attributesKey + "=\"" + attributesValue + "\"";
35
+ }
36
+ if (name === tagName) {
37
+ hasResolve = true;
38
+ if (legacyLoaderConfig.buildLevel < buildConfig.level) {
39
+ isBreak = true;
40
+ }
41
+ }
42
+ else {
43
+ if (attr.length > 0) {
44
+ parseNewHtml += "<" + name + " " + attr + " ";
45
+ }
46
+ else {
47
+ parseNewHtml += "<" + name;
48
+ }
49
+ if (singleTag.indexOf(name) >= 0) {
50
+ parseNewHtml += "/>";
51
+ }
52
+ else {
53
+ parseNewHtml += ">";
54
+ }
55
+ }
56
+ },
57
+ ontext: function (text) {
58
+ if (isBreak) {
59
+ return;
60
+ }
61
+ parseNewHtml += text;
62
+ },
63
+ onclosetag: function (name) {
64
+ if (name === tagName) {
65
+ isBreak = false;
66
+ }
67
+ if (isBreak) {
68
+ return;
69
+ }
70
+ if (singleTag.indexOf(name) >= 0) {
71
+ return;
72
+ }
73
+ if (name === tagName) {
74
+ return;
75
+ }
76
+ parseNewHtml += "</" + name + ">";
77
+ },
78
+ }, {
79
+ recognizeSelfClosing: true,
80
+ lowerCaseTags: false,
81
+ lowerCaseAttributeNames: false
82
+ });
83
+ parser.write(source);
84
+ parser.end();
85
+ if (hasResolve) {
86
+ return parseNewHtml;
87
+ }
88
+ return source;
89
+ };
@@ -0,0 +1,13 @@
1
+ export declare class FastVueMultiBoolean {
2
+ /**
3
+ * 判断目标值是否为布尔值
4
+ * @param source
5
+ */
6
+ static isBoolean(source: any): boolean;
7
+ /**
8
+ * 转为布尔值
9
+ * @param source 目标值
10
+ * @param defaultValue 默认值,当为空或无效的布尔值时 返回
11
+ */
12
+ static parse(source: any, defaultValue?: boolean): boolean;
13
+ }
@@ -0,0 +1,60 @@
1
+ define(["require", "exports", "tslib", "lodash"], function (require, exports, tslib_1, lodash_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueMultiBoolean = void 0;
5
+ lodash_1 = tslib_1.__importDefault(lodash_1);
6
+ var FastVueMultiBoolean = /** @class */ (function () {
7
+ function FastVueMultiBoolean() {
8
+ }
9
+ /**
10
+ * 判断目标值是否为布尔值
11
+ * @param source
12
+ */
13
+ FastVueMultiBoolean.isBoolean = function (source) {
14
+ if (source == null) {
15
+ return false;
16
+ }
17
+ if (source instanceof Boolean) {
18
+ return true;
19
+ }
20
+ return typeof source === 'boolean';
21
+ };
22
+ /**
23
+ * 转为布尔值
24
+ * @param source 目标值
25
+ * @param defaultValue 默认值,当为空或无效的布尔值时 返回
26
+ */
27
+ FastVueMultiBoolean.parse = function (source, defaultValue) {
28
+ if (lodash_1.default.isEmpty(defaultValue)) {
29
+ defaultValue = false;
30
+ }
31
+ if (lodash_1.default.isEmpty(source)) {
32
+ return defaultValue;
33
+ }
34
+ if (lodash_1.default.isString(source)) {
35
+ if (source === "0" || source.toLowerCase() === "false") {
36
+ return false;
37
+ }
38
+ if (source === "1" || source.toLowerCase() === "true") {
39
+ return true;
40
+ }
41
+ return defaultValue;
42
+ }
43
+ if (lodash_1.default.isNumber(source)) {
44
+ if (source === 0) {
45
+ return false;
46
+ }
47
+ if (source === 1) {
48
+ return true;
49
+ }
50
+ return defaultValue;
51
+ }
52
+ if (this.isBoolean(source)) {
53
+ return source;
54
+ }
55
+ return defaultValue;
56
+ };
57
+ return FastVueMultiBoolean;
58
+ }());
59
+ exports.FastVueMultiBoolean = FastVueMultiBoolean;
60
+ });
@@ -0,0 +1,21 @@
1
+ import * as clipboard from "clipboard-polyfill";
2
+ export declare class FastVueMultiClipboard {
3
+ /**
4
+ * 将内容复制到剪贴板中
5
+ * @param content
6
+ */
7
+ static copy(content: string): Promise<void>;
8
+ /**
9
+ * 将blob复制到剪贴板中
10
+ * @param blob
11
+ */
12
+ static copyBlob(blob: Blob): Promise<void>;
13
+ /**
14
+ * 获取剪贴板的文本内容
15
+ */
16
+ static getText(): Promise<string | undefined>;
17
+ /**
18
+ * 获取剪贴板的ClipboardItem内容
19
+ */
20
+ static getItems(): Promise<clipboard.ClipboardItems | undefined>;
21
+ }
@@ -0,0 +1,56 @@
1
+ define(["require", "exports", "tslib", "clipboard-polyfill"], function (require, exports, tslib_1, clipboard) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueMultiClipboard = void 0;
5
+ clipboard = tslib_1.__importStar(clipboard);
6
+ var FastVueMultiClipboard = /** @class */ (function () {
7
+ function FastVueMultiClipboard() {
8
+ }
9
+ /**
10
+ * 将内容复制到剪贴板中
11
+ * @param content
12
+ */
13
+ FastVueMultiClipboard.copy = function (content) {
14
+ return clipboard.writeText(content);
15
+ };
16
+ /**
17
+ * 将blob复制到剪贴板中
18
+ * @param blob
19
+ */
20
+ FastVueMultiClipboard.copyBlob = function (blob) {
21
+ var contentType = blob.type;
22
+ var items = {};
23
+ items[contentType] = blob;
24
+ var item = new clipboard.ClipboardItem(items);
25
+ return clipboard.write([item]);
26
+ };
27
+ /**
28
+ * 获取剪贴板的文本内容
29
+ */
30
+ FastVueMultiClipboard.getText = function () {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
32
+ return tslib_1.__generator(this, function (_a) {
33
+ switch (_a.label) {
34
+ case 0: return [4 /*yield*/, clipboard.readText()];
35
+ case 1: return [2 /*return*/, _a.sent()];
36
+ }
37
+ });
38
+ });
39
+ };
40
+ /**
41
+ * 获取剪贴板的ClipboardItem内容
42
+ */
43
+ FastVueMultiClipboard.getItems = function () {
44
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
45
+ return tslib_1.__generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, clipboard.read()];
48
+ case 1: return [2 /*return*/, _a.sent()];
49
+ }
50
+ });
51
+ });
52
+ };
53
+ return FastVueMultiClipboard;
54
+ }());
55
+ exports.FastVueMultiClipboard = FastVueMultiClipboard;
56
+ });
@@ -0,0 +1,30 @@
1
+ export declare class FastVueMultiDate {
2
+ /**
3
+ * 判断目标值是否是日期类型
4
+ * @param source
5
+ */
6
+ static isDate(source: any): boolean;
7
+ /**
8
+ * 格式化日期
9
+ * @param source 日期
10
+ * @param pattern 格式类型,例如:yyyy-MM-DD HH:mm:ss,更多查看:https://momentjs.com/docs/#/displaying/
11
+ */
12
+ static format(source: Date, pattern: string): string | null;
13
+ /**
14
+ * 将字符串日期转换为Date对象
15
+ * @param source 日期值
16
+ */
17
+ static parse(source: string): Date | null;
18
+ /**
19
+ * 格式化日期的友好展示,例如:1分钟前,3分钟前
20
+ * @param source
21
+ * @param level 精确级别 1 分钟 2 小时 3 天 4 周 5 月
22
+ */
23
+ static formatNice(source: string, level?: number): string | null;
24
+ /**
25
+ * 将总时间转换为中文描述,最高描述到:天,例如:2天03时45分09秒
26
+ * @param timestamp 时间戳 单位:毫秒
27
+ * @param chinese 是否用中文表达,默认:true
28
+ */
29
+ static toDescription(timestamp: number, chinese: boolean): string;
30
+ }
@@ -0,0 +1,170 @@
1
+ define(["require", "exports", "tslib", "moment", "lodash"], function (require, exports, tslib_1, moment_1, lodash_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueMultiDate = void 0;
5
+ moment_1 = tslib_1.__importDefault(moment_1);
6
+ lodash_1 = tslib_1.__importDefault(lodash_1);
7
+ var FastVueMultiDate = /** @class */ (function () {
8
+ function FastVueMultiDate() {
9
+ }
10
+ /**
11
+ * 判断目标值是否是日期类型
12
+ * @param source
13
+ */
14
+ FastVueMultiDate.isDate = function (source) {
15
+ if (source == null) {
16
+ return false;
17
+ }
18
+ if (source instanceof Date) {
19
+ return true;
20
+ }
21
+ return toString.call(source) === '[object Date]';
22
+ };
23
+ /**
24
+ * 格式化日期
25
+ * @param source 日期
26
+ * @param pattern 格式类型,例如:yyyy-MM-DD HH:mm:ss,更多查看:https://momentjs.com/docs/#/displaying/
27
+ */
28
+ FastVueMultiDate.format = function (source, pattern) {
29
+ if (lodash_1.default.isEmpty(pattern)) {
30
+ return null;
31
+ }
32
+ if (lodash_1.default.isEmpty(source)) {
33
+ return null;
34
+ }
35
+ return (0, moment_1.default)(source).format(pattern);
36
+ };
37
+ /**
38
+ * 将字符串日期转换为Date对象
39
+ * @param source 日期值
40
+ */
41
+ FastVueMultiDate.parse = function (source) {
42
+ if (lodash_1.default.isEmpty(source)) {
43
+ return null;
44
+ }
45
+ return (0, moment_1.default)(source).toDate();
46
+ };
47
+ /**
48
+ * 格式化日期的友好展示,例如:1分钟前,3分钟前
49
+ * @param source
50
+ * @param level 精确级别 1 分钟 2 小时 3 天 4 周 5 月
51
+ */
52
+ FastVueMultiDate.formatNice = function (source, level) {
53
+ if (lodash_1.default.isEmpty(source)) {
54
+ return null;
55
+ }
56
+ if (level === undefined) {
57
+ level = 2;
58
+ }
59
+ var seconds = 1000;
60
+ var minute = seconds * 60;
61
+ var hour = minute * 60;
62
+ var day = hour * 24;
63
+ var week = day * 7;
64
+ var month = day * 30;
65
+ var time1 = new Date().getTime(); //当前的时间戳
66
+ var sourceDate = this.parse(source);
67
+ if (!sourceDate) {
68
+ return null;
69
+ }
70
+ var time2 = sourceDate.getTime();
71
+ var time = time1 - time2;
72
+ if (time <= minute) {
73
+ return "刚刚";
74
+ }
75
+ if (time / month >= 3) {
76
+ return this.format(sourceDate, "yyyy-MM-DD HH:mm");
77
+ }
78
+ var nice = true;
79
+ if (time / month >= 1) {
80
+ if (level >= 5) {
81
+ return parseInt(String(time / month)) + "个月前";
82
+ }
83
+ nice = false;
84
+ }
85
+ if (nice && time / week >= 1) {
86
+ if (level >= 4) {
87
+ return parseInt(String(time / week)) + "周前";
88
+ }
89
+ nice = false;
90
+ }
91
+ if (nice && time / day >= 1) {
92
+ if (level >= 3) {
93
+ return parseInt(String(time / day)) + "天前";
94
+ }
95
+ nice = false;
96
+ }
97
+ if (nice && time / hour >= 1) {
98
+ if (level >= 2) {
99
+ return parseInt(String(time / hour)) + "小时前";
100
+ }
101
+ nice = false;
102
+ }
103
+ if (nice && time / minute >= 1) {
104
+ if (level >= 1) {
105
+ return parseInt(String(time / minute)) + "分钟前";
106
+ }
107
+ }
108
+ return this.format(sourceDate, "yyyy-MM-DD HH:mm");
109
+ };
110
+ /**
111
+ * 将总时间转换为中文描述,最高描述到:天,例如:2天03时45分09秒
112
+ * @param timestamp 时间戳 单位:毫秒
113
+ * @param chinese 是否用中文表达,默认:true
114
+ */
115
+ FastVueMultiDate.toDescription = function (timestamp, chinese) {
116
+ if (chinese === undefined) {
117
+ chinese = true;
118
+ }
119
+ var seconds = 1000, minuteUnit = 1000 * 60, hourUnit = 1000 * 60 * 60, dayUnit = 1000 * 60 * 60 * 24;
120
+ var descriptions = [];
121
+ if (timestamp < seconds) {
122
+ descriptions.push("00" + (chinese ? '秒' : ''));
123
+ return descriptions.join("");
124
+ }
125
+ else if (timestamp < minuteUnit) {
126
+ descriptions.push(lodash_1.default.padStart(String(timestamp / seconds), 2, "0") + (chinese ? '秒' : ''));
127
+ return descriptions.join("");
128
+ }
129
+ if (timestamp < hourUnit) {
130
+ var minute = parseInt(String(timestamp / minuteUnit));
131
+ descriptions.push(lodash_1.default.padStart(String(minute), 2, "0") + (chinese ? '分' : ':'));
132
+ var nextTimestamp_1 = timestamp - parseInt(String(minute * minuteUnit));
133
+ if (nextTimestamp_1 === 0) {
134
+ descriptions.push("00" + (chinese ? '秒' : ''));
135
+ }
136
+ else {
137
+ descriptions.push(this.toDescription(nextTimestamp_1, chinese));
138
+ }
139
+ return descriptions.join("");
140
+ }
141
+ if (timestamp < dayUnit) {
142
+ var hour = parseInt(String(timestamp / hourUnit));
143
+ descriptions.push(lodash_1.default.padStart(String(hour), 2, "0") + (chinese ? '时' : ':'));
144
+ var nextTimestamp_2 = timestamp - parseInt(String(hour * hourUnit));
145
+ if (nextTimestamp_2 === 0) {
146
+ descriptions.push("00" + (chinese ? '分' : ':'));
147
+ descriptions.push("00" + (chinese ? '秒' : ''));
148
+ }
149
+ else {
150
+ descriptions.push(this.toDescription(nextTimestamp_2, chinese));
151
+ }
152
+ return descriptions.join("");
153
+ }
154
+ var day = parseInt(String(timestamp / dayUnit));
155
+ descriptions.push(day + (chinese ? '天' : 'day '));
156
+ var nextTimestamp = timestamp - parseInt(String(day * dayUnit));
157
+ if (nextTimestamp === 0) {
158
+ descriptions.push("00" + (chinese ? '时' : ':'));
159
+ descriptions.push("00" + (chinese ? '分' : ':'));
160
+ descriptions.push("00" + (chinese ? '秒' : ''));
161
+ }
162
+ else {
163
+ descriptions.push(this.toDescription(nextTimestamp, chinese));
164
+ }
165
+ return descriptions.join("");
166
+ };
167
+ return FastVueMultiDate;
168
+ }());
169
+ exports.FastVueMultiDate = FastVueMultiDate;
170
+ });
@@ -0,0 +1,46 @@
1
+ export declare class FastVueMultiElement {
2
+ /**
3
+ * 绑定节点属性变动的监听
4
+ * @param source 节点对象
5
+ * @param attrs 需要监听的属性集合
6
+ * @param callBack 回调
7
+ */
8
+ static onAttributesChange(source: Element, attrs: any[], callBack?: (event: MutationRecord) => void): MutationObserver | null;
9
+ /**
10
+ * 绑定当前节点子节点的变动的监听
11
+ * @param source 节点对象
12
+ * @param callBack 回调
13
+ */
14
+ static onChildrenChange(source: Element, callBack?: (event: MutationRecord) => void): MutationObserver | null;
15
+ /**
16
+ * 在目标节点后追加新的节点
17
+ * @param targetEl 目标节点
18
+ * @param newEl 新的节点
19
+ */
20
+ static insertAfter(targetEl: Element, newEl: Element): void;
21
+ /**
22
+ * 在目标节点前追加新的节点
23
+ * @param targetEl 目标节点
24
+ * @param newEl 新的节点
25
+ */
26
+ static insertBefore(targetEl: Element, newEl: Element): void;
27
+ /**
28
+ * 获取目标节点的实际占位空间,包含的内外边距
29
+ * @param targetEl
30
+ */
31
+ static getRealSize(targetEl: Element): {
32
+ width: number;
33
+ height: number;
34
+ };
35
+ /**
36
+ * 获取目标节点的selector
37
+ * @param targetEl
38
+ */
39
+ static getPath(targetEl: Element): string;
40
+ /**
41
+ * 判断目标元素的滚动条 是否已滚动到底部
42
+ * @param targetEl
43
+ * @param scrollNimble 检测的灵敏度,越大越灵敏
44
+ */
45
+ static isScrollBottom(targetEl: Element, scrollNimble: number): boolean;
46
+ }
@@ -0,0 +1,158 @@
1
+ define(["require", "exports", "tslib", "lodash"], function (require, exports, tslib_1, lodash_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueMultiElement = void 0;
5
+ lodash_1 = tslib_1.__importDefault(lodash_1);
6
+ var FastVueMultiElement = /** @class */ (function () {
7
+ function FastVueMultiElement() {
8
+ }
9
+ /**
10
+ * 绑定节点属性变动的监听
11
+ * @param source 节点对象
12
+ * @param attrs 需要监听的属性集合
13
+ * @param callBack 回调
14
+ */
15
+ FastVueMultiElement.onAttributesChange = function (source, attrs, callBack) {
16
+ if (source) {
17
+ var observe = new MutationObserver(function (mutationsList) {
18
+ mutationsList.forEach(function (item, index) {
19
+ if (callBack) {
20
+ callBack(item);
21
+ }
22
+ });
23
+ });
24
+ observe.observe(source, {
25
+ attributes: true,
26
+ attributeFilter: attrs
27
+ });
28
+ return observe;
29
+ }
30
+ return null;
31
+ };
32
+ /**
33
+ * 绑定当前节点子节点的变动的监听
34
+ * @param source 节点对象
35
+ * @param callBack 回调
36
+ */
37
+ FastVueMultiElement.onChildrenChange = function (source, callBack) {
38
+ if (source) {
39
+ var observe = new MutationObserver(function (mutationsList) {
40
+ mutationsList.forEach(function (item, index) {
41
+ if (callBack) {
42
+ callBack(item);
43
+ }
44
+ });
45
+ });
46
+ observe.observe(source, {
47
+ childList: true,
48
+ subtree: true
49
+ });
50
+ return observe;
51
+ }
52
+ return null;
53
+ };
54
+ /**
55
+ * 在目标节点后追加新的节点
56
+ * @param targetEl 目标节点
57
+ * @param newEl 新的节点
58
+ */
59
+ FastVueMultiElement.insertAfter = function (targetEl, newEl) {
60
+ var parent = targetEl.parentNode;
61
+ if (parent.lastChild === targetEl) {
62
+ parent.appendChild(newEl);
63
+ }
64
+ else {
65
+ parent.insertBefore(newEl, targetEl.nextSibling);
66
+ }
67
+ };
68
+ /**
69
+ * 在目标节点前追加新的节点
70
+ * @param targetEl 目标节点
71
+ * @param newEl 新的节点
72
+ */
73
+ FastVueMultiElement.insertBefore = function (targetEl, newEl) {
74
+ var parent = targetEl.parentNode;
75
+ if (parent.lastChild === targetEl) {
76
+ parent.appendChild(newEl);
77
+ }
78
+ else {
79
+ parent.insertBefore(newEl, targetEl);
80
+ }
81
+ };
82
+ /**
83
+ * 获取目标节点的实际占位空间,包含的内外边距
84
+ * @param targetEl
85
+ */
86
+ FastVueMultiElement.getRealSize = function (targetEl) {
87
+ var childStyle = window.getComputedStyle(targetEl);
88
+ var height = lodash_1.default.parseInt(childStyle.height);
89
+ var width = lodash_1.default.parseInt(childStyle.width);
90
+ var vSpace = lodash_1.default.parseInt(childStyle.marginTop)
91
+ + lodash_1.default.parseInt(childStyle.marginBottom)
92
+ + lodash_1.default.parseInt(childStyle.paddingTop)
93
+ + lodash_1.default.parseInt(childStyle.paddingBottom);
94
+ var hSpace = lodash_1.default.parseInt(childStyle.marginLeft)
95
+ + lodash_1.default.parseInt(childStyle.marginRight)
96
+ + lodash_1.default.parseInt(childStyle.paddingLeft)
97
+ + lodash_1.default.parseInt(childStyle.paddingRight);
98
+ return { width: width + hSpace, height: height + vSpace };
99
+ };
100
+ /**
101
+ * 获取目标节点的selector
102
+ * @param targetEl
103
+ */
104
+ FastVueMultiElement.getPath = function (targetEl) {
105
+ var currEl = targetEl;
106
+ var domPath = [];
107
+ if (currEl.id) {
108
+ domPath.unshift('#' + currEl.id);
109
+ }
110
+ else {
111
+ while (currEl.nodeName.toLowerCase() !== "html") {
112
+ if (currEl.id) {
113
+ domPath.unshift('#' + currEl.id);
114
+ break;
115
+ }
116
+ else if (currEl.tagName.toLocaleLowerCase() === "body") {
117
+ domPath.unshift(currEl.tagName.toLowerCase());
118
+ }
119
+ else {
120
+ for (var i = 0; i < currEl.parentNode.childElementCount; i++) {
121
+ if (currEl.parentNode.children[i] === currEl) {
122
+ var className = currEl.getAttribute('class');
123
+ if (className) {
124
+ var selectors = currEl.className.split(/\s/g), array = [];
125
+ for (var j = 0; j < selectors.length; ++j) {
126
+ if (selectors[j].length > 0) {
127
+ array.push('.' + selectors[j]);
128
+ }
129
+ }
130
+ className = array.join("");
131
+ }
132
+ else {
133
+ className = "";
134
+ }
135
+ domPath.unshift(currEl.tagName.toLowerCase() + className + ':nth-child(' + (i + 1) + ')');
136
+ }
137
+ }
138
+ }
139
+ currEl = currEl.parentNode;
140
+ }
141
+ }
142
+ return domPath.join(' > ');
143
+ };
144
+ /**
145
+ * 判断目标元素的滚动条 是否已滚动到底部
146
+ * @param targetEl
147
+ * @param scrollNimble 检测的灵敏度,越大越灵敏
148
+ */
149
+ FastVueMultiElement.isScrollBottom = function (targetEl, scrollNimble) {
150
+ var scrollTop = targetEl.scrollTop;
151
+ var elHeight = targetEl.getBoundingClientRect().height;
152
+ var scrollHeight = targetEl.scrollHeight;
153
+ return scrollTop + elHeight >= (scrollHeight - scrollNimble);
154
+ };
155
+ return FastVueMultiElement;
156
+ }());
157
+ exports.FastVueMultiElement = FastVueMultiElement;
158
+ });
@@ -0,0 +1,19 @@
1
+ export declare class FastVueMultiFunction {
2
+ /**
3
+ * 判断目标类型是否为函数
4
+ * @param source
5
+ */
6
+ static isFunction(source: any): boolean;
7
+ /**
8
+ * 批量执行函数并获取返回值
9
+ * @param source 单个函数或函数数组
10
+ * @param params 执行函数携带的参数
11
+ */
12
+ static run(source: any, ...params: any[]): any | null;
13
+ /**
14
+ * 按顺序同步执行函数,当其中一个函数返回false时,则终止后续执行
15
+ * @param source 单个函数或函数数组
16
+ * @param params 执行函数携带的参数
17
+ */
18
+ static syncRun(source: any, ...params: any[]): Promise<void>;
19
+ }