@kwiz/common 1.0.126 → 1.0.128
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/.github/workflows/npm-publish.yml +24 -24
- package/.madgerc +2 -2
- package/LICENSE +21 -21
- package/fix-folder-imports.js +26 -26
- package/lib/cjs/types/libs/msal.types.js +26 -26
- package/lib/cjs/utils/auth/common.js +84 -37
- package/lib/cjs/utils/auth/common.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
- package/lib/esm/types/libs/msal.types.js +26 -26
- package/lib/esm/utils/auth/common.js +84 -38
- package/lib/esm/utils/auth/common.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/user.js +11 -11
- package/lib/types/types/auth.d.ts +7 -0
- package/lib/types/utils/auth/common.d.ts +2 -0
- package/package.json +81 -81
- package/readme.md +17 -17
- package/src/_dependencies.ts +12 -12
- package/src/config.ts +17 -17
- package/src/helpers/Guid.ts +181 -181
- package/src/helpers/base64.ts +173 -173
- package/src/helpers/browser.test.js +13 -13
- package/src/helpers/browser.ts +1498 -1498
- package/src/helpers/browserinfo.ts +292 -292
- package/src/helpers/collections.base.test.js +25 -25
- package/src/helpers/collections.base.ts +437 -437
- package/src/helpers/collections.ts +107 -107
- package/src/helpers/color.ts +54 -54
- package/src/helpers/cookies.ts +59 -59
- package/src/helpers/date.test.js +119 -119
- package/src/helpers/date.ts +188 -188
- package/src/helpers/debug.ts +186 -186
- package/src/helpers/diagrams.ts +43 -43
- package/src/helpers/emails.ts +6 -6
- package/src/helpers/eval.ts +5 -5
- package/src/helpers/file.test.js +50 -50
- package/src/helpers/file.ts +63 -63
- package/src/helpers/flatted.ts +149 -149
- package/src/helpers/functions.ts +16 -16
- package/src/helpers/graph/calendar.types.ts +10 -10
- package/src/helpers/http.ts +69 -69
- package/src/helpers/images.ts +22 -22
- package/src/helpers/json.ts +44 -44
- package/src/helpers/md5.ts +189 -189
- package/src/helpers/objects.test.js +33 -33
- package/src/helpers/objects.ts +274 -274
- package/src/helpers/promises.test.js +37 -37
- package/src/helpers/promises.ts +165 -165
- package/src/helpers/random.ts +27 -27
- package/src/helpers/scheduler/scheduler.test.js +103 -103
- package/src/helpers/scheduler/scheduler.ts +131 -131
- package/src/helpers/sharepoint.ts +796 -796
- package/src/helpers/strings.test.js +122 -122
- package/src/helpers/strings.ts +337 -337
- package/src/helpers/typecheckers.test.js +34 -34
- package/src/helpers/typecheckers.ts +266 -266
- package/src/helpers/url.test.js +43 -43
- package/src/helpers/url.ts +207 -207
- package/src/helpers/urlhelper.ts +111 -111
- package/src/index.ts +6 -6
- package/src/types/auth.ts +62 -54
- package/src/types/common.types.ts +15 -15
- package/src/types/flatted.types.ts +59 -59
- package/src/types/globals.types.ts +6 -6
- package/src/types/graph/calendar.types.ts +80 -80
- package/src/types/knownscript.types.ts +18 -18
- package/src/types/libs/datajs.types.ts +28 -28
- package/src/types/libs/ics.types.ts +30 -30
- package/src/types/libs/msal.types.ts +57 -57
- package/src/types/locales.ts +125 -125
- package/src/types/localstoragecache.types.ts +8 -8
- package/src/types/location.types.ts +27 -27
- package/src/types/moment.ts +11 -11
- package/src/types/regex.types.ts +16 -16
- package/src/types/rest.types.ts +95 -95
- package/src/types/sharepoint.types.ts +1466 -1466
- package/src/types/sharepoint.utils.types.ts +306 -306
- package/src/utils/auth/common.ts +119 -74
- package/src/utils/auth/discovery.test.js +12 -12
- package/src/utils/auth/discovery.ts +132 -132
- package/src/utils/base64.ts +27 -27
- package/src/utils/consolelogger.ts +333 -333
- package/src/utils/date.ts +172 -172
- package/src/utils/emails.ts +24 -24
- package/src/utils/knownscript.ts +286 -286
- package/src/utils/localstoragecache.ts +446 -446
- package/src/utils/rest.ts +501 -501
- package/src/utils/script.ts +170 -170
- package/src/utils/sharepoint.rest/common.ts +159 -159
- package/src/utils/sharepoint.rest/date.ts +62 -62
- package/src/utils/sharepoint.rest/file.folder.ts +685 -685
- package/src/utils/sharepoint.rest/item.ts +547 -547
- package/src/utils/sharepoint.rest/list.ts +1572 -1572
- package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
- package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
- package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
- package/src/utils/sharepoint.rest/location.ts +141 -141
- package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
- package/src/utils/sharepoint.rest/user-search.ts +252 -252
- package/src/utils/sharepoint.rest/user.ts +558 -558
- package/src/utils/sharepoint.rest/web.ts +1384 -1384
- package/src/utils/sod.ts +194 -194
package/src/utils/script.ts
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import { isDebug } from "../helpers/debug";
|
|
2
|
-
import { noop } from "../helpers/objects";
|
|
3
|
-
import { isNotEmptyArray, isNullOrEmptyString, isNullOrUndefined } from "../helpers/typecheckers";
|
|
4
|
-
import { IKnownScript, ksGlobal } from "../types/knownscript.types";
|
|
5
|
-
import Sod from "./sod";
|
|
6
|
-
|
|
7
|
-
export interface IScriptUtils {
|
|
8
|
-
/** @deprecated - use wrapFunction instead from helpers/functions */
|
|
9
|
-
wrapFunction3?: (originalFunction: () => void, instance: any, doBefore: () => void, doAfter: () => void) => void;
|
|
10
|
-
loadKnownScript: (script: IKnownScript) => void;
|
|
11
|
-
loadKnownScript_Sync: (script: IKnownScript) => void;
|
|
12
|
-
ensureScript: (scriptUrl: string, global: ksGlobal, callback: () => void, sodName: string) => void;
|
|
13
|
-
ensureScripts: (scripts: { scriptUrl: string; global: ksGlobal; sodName: string; }[], callback: () => void) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default class script implements IScriptUtils {
|
|
17
|
-
private static instance: script = null;
|
|
18
|
-
public isRtl = false;
|
|
19
|
-
public static get Instance() {
|
|
20
|
-
if (script.instance === null) {
|
|
21
|
-
//share single instance between all imports
|
|
22
|
-
if (typeof (window as any).kSingleScripts !== 'undefined')
|
|
23
|
-
script.instance = (window as any).kSingleScripts;//a global instance already exists, use it
|
|
24
|
-
else {
|
|
25
|
-
script.instance = new script();
|
|
26
|
-
(window as any).kSingleScripts = script.instance;//place this instance in the global namespace for others to reuse
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return script.instance;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public async loadKnownScript(knownScript: IKnownScript) {
|
|
33
|
-
var promisesDependencies: Promise<any>[] = [];
|
|
34
|
-
(knownScript.dependencies || []).forEach(dep => {
|
|
35
|
-
promisesDependencies.push(this.loadKnownScript(dep));
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (promisesDependencies.length > 0)
|
|
39
|
-
await Promise.all(promisesDependencies);
|
|
40
|
-
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
this.ensureKnownScriptInternal(knownScript, () => {
|
|
43
|
-
resolve(Sod.getGlobal(knownScript.global));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
public loadKnownScript_Sync(knownScript: IKnownScript) {
|
|
48
|
-
try {
|
|
49
|
-
if (isNotEmptyArray(knownScript.dependencies)) {
|
|
50
|
-
(knownScript.dependencies || []).forEach(dep => {
|
|
51
|
-
this.loadKnownScript_Sync(dep)
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.ensureKnownScriptInternal(knownScript, noop, true);
|
|
58
|
-
return Sod.getGlobal(knownScript.global);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private ensureKnownScriptInternal(knownScript: IKnownScript, callback: () => void, sync = false) {
|
|
62
|
-
let url = isDebug() && !knownScript.forceMin ? knownScript.url.replace('.min.js', '.js') : knownScript.url;
|
|
63
|
-
if (url[0] === '/') url = "https://apps.kwizcom.com" + url;
|
|
64
|
-
|
|
65
|
-
if (sync === true)
|
|
66
|
-
this.ensureScriptSync(url, knownScript.global, callback, knownScript.sodName);
|
|
67
|
-
else
|
|
68
|
-
this.ensureScript(url, knownScript.global, callback, knownScript.sodName);
|
|
69
|
-
|
|
70
|
-
let cssFiles = this.isRtl === true && !isNullOrUndefined(knownScript.rtlCss) ? knownScript.rtlCss : knownScript.css;
|
|
71
|
-
if (!isNullOrUndefined(cssFiles))
|
|
72
|
-
cssFiles.forEach(css => {
|
|
73
|
-
if (!isNullOrEmptyString(css)) {
|
|
74
|
-
let cssurl = isDebug() && !knownScript.forceMin ? css.replace('.min.css', '.css') : css;
|
|
75
|
-
if (cssurl[0] === '/') cssurl = "https://apps.kwizcom.com" + cssurl;
|
|
76
|
-
|
|
77
|
-
let knownStyles = document.getElementsByClassName("kwizcom_known_css");
|
|
78
|
-
let found = false;
|
|
79
|
-
for (let si = 0; si < knownStyles.length; si++) {
|
|
80
|
-
let elm: HTMLLinkElement = knownStyles[si] as HTMLLinkElement;
|
|
81
|
-
if (elm.href && elm.href.toLowerCase() === cssurl.toLowerCase()) {
|
|
82
|
-
found = true;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!found) {
|
|
87
|
-
let link = document.createElement("link");
|
|
88
|
-
link.rel = "stylesheet";
|
|
89
|
-
link.className = "kwizcom_known_css";
|
|
90
|
-
link.type = "text/css";
|
|
91
|
-
link.href = cssurl;
|
|
92
|
-
document.head.appendChild(link);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public loadCss(cssUrl: string) {
|
|
99
|
-
let knownStyles = document.getElementsByClassName("kwizcom_known_css");
|
|
100
|
-
let found = false;
|
|
101
|
-
for (let si = 0; si < knownStyles.length; si++) {
|
|
102
|
-
let elm: HTMLLinkElement = knownStyles[si] as HTMLLinkElement;
|
|
103
|
-
if (elm.href && elm.href.toLowerCase() === cssUrl.toLowerCase()) {
|
|
104
|
-
found = true;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (!found) {
|
|
109
|
-
let link = document.createElement("link");
|
|
110
|
-
link.rel = "stylesheet";
|
|
111
|
-
link.className = "kwizcom_known_css";
|
|
112
|
-
link.type = "text/css";
|
|
113
|
-
link.href = cssUrl;
|
|
114
|
-
document.head.appendChild(link);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public ensureScriptSync(scriptUrl: string, global: ksGlobal, callback?: () => void, sodName?: string) {
|
|
119
|
-
//in IE there is no promise, we cannot use any async functions
|
|
120
|
-
return Sod.ensureScriptNoPromise(scriptUrl, global, callback, sodName, true);
|
|
121
|
-
}
|
|
122
|
-
public async ensureScript(scriptUrl: string, global: ksGlobal, callback?: () => void, sodName?: string) {
|
|
123
|
-
return Sod.ensureScript(scriptUrl, global, callback, sodName, false);
|
|
124
|
-
}
|
|
125
|
-
/** ensure a collection of scripts and call the callback when they are all done */
|
|
126
|
-
public async ensureScripts(scripts: { scriptUrl: string; global: ksGlobal; sodName: string; }[], callback: () => void) {
|
|
127
|
-
let promises: Promise<void>[] = [];
|
|
128
|
-
let length = scripts.length;
|
|
129
|
-
let finished = 0;
|
|
130
|
-
let onFinished = typeof (callback) !== "function" ? null : () => {
|
|
131
|
-
finished++;
|
|
132
|
-
if (finished === length)//all finished
|
|
133
|
-
callback();
|
|
134
|
-
};
|
|
135
|
-
scripts.forEach(scr => {
|
|
136
|
-
promises.push(Sod.ensureScript(scr.scriptUrl, scr.global, onFinished, scr.sodName));
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return Promise.all(promises);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private _WrapFunctionArr: any[] = [];
|
|
143
|
-
|
|
144
|
-
/** @deprecated - use wrapFunction instead from helpers/functions */
|
|
145
|
-
public wrapFunction3(originalFunction: () => void, instance: any, doBefore: () => void, doAfter: () => void) {
|
|
146
|
-
try {
|
|
147
|
-
if (instance !== null) {
|
|
148
|
-
originalFunction.bind(instance);
|
|
149
|
-
}
|
|
150
|
-
var idx = this._WrapFunctionArr.length;
|
|
151
|
-
this._WrapFunctionArr[idx] = originalFunction;
|
|
152
|
-
|
|
153
|
-
originalFunction = function (...args: any[]) {
|
|
154
|
-
if (typeof (doBefore) === "function") {
|
|
155
|
-
doBefore.apply(instance, args);
|
|
156
|
-
}
|
|
157
|
-
var returnValue = this._WrapFunctionArr[idx].apply(instance, args);
|
|
158
|
-
if (typeof (doAfter) === "function") {
|
|
159
|
-
doAfter.apply(instance, args);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return returnValue;
|
|
163
|
-
};
|
|
164
|
-
if (instance !== null) {
|
|
165
|
-
originalFunction.bind(instance);
|
|
166
|
-
}
|
|
167
|
-
} catch (e) {
|
|
168
|
-
if (isDebug()) console.log('unhandled error in wrapFunction3');
|
|
169
|
-
}
|
|
170
|
-
}
|
|
1
|
+
import { isDebug } from "../helpers/debug";
|
|
2
|
+
import { noop } from "../helpers/objects";
|
|
3
|
+
import { isNotEmptyArray, isNullOrEmptyString, isNullOrUndefined } from "../helpers/typecheckers";
|
|
4
|
+
import { IKnownScript, ksGlobal } from "../types/knownscript.types";
|
|
5
|
+
import Sod from "./sod";
|
|
6
|
+
|
|
7
|
+
export interface IScriptUtils {
|
|
8
|
+
/** @deprecated - use wrapFunction instead from helpers/functions */
|
|
9
|
+
wrapFunction3?: (originalFunction: () => void, instance: any, doBefore: () => void, doAfter: () => void) => void;
|
|
10
|
+
loadKnownScript: (script: IKnownScript) => void;
|
|
11
|
+
loadKnownScript_Sync: (script: IKnownScript) => void;
|
|
12
|
+
ensureScript: (scriptUrl: string, global: ksGlobal, callback: () => void, sodName: string) => void;
|
|
13
|
+
ensureScripts: (scripts: { scriptUrl: string; global: ksGlobal; sodName: string; }[], callback: () => void) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class script implements IScriptUtils {
|
|
17
|
+
private static instance: script = null;
|
|
18
|
+
public isRtl = false;
|
|
19
|
+
public static get Instance() {
|
|
20
|
+
if (script.instance === null) {
|
|
21
|
+
//share single instance between all imports
|
|
22
|
+
if (typeof (window as any).kSingleScripts !== 'undefined')
|
|
23
|
+
script.instance = (window as any).kSingleScripts;//a global instance already exists, use it
|
|
24
|
+
else {
|
|
25
|
+
script.instance = new script();
|
|
26
|
+
(window as any).kSingleScripts = script.instance;//place this instance in the global namespace for others to reuse
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return script.instance;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async loadKnownScript(knownScript: IKnownScript) {
|
|
33
|
+
var promisesDependencies: Promise<any>[] = [];
|
|
34
|
+
(knownScript.dependencies || []).forEach(dep => {
|
|
35
|
+
promisesDependencies.push(this.loadKnownScript(dep));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (promisesDependencies.length > 0)
|
|
39
|
+
await Promise.all(promisesDependencies);
|
|
40
|
+
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
this.ensureKnownScriptInternal(knownScript, () => {
|
|
43
|
+
resolve(Sod.getGlobal(knownScript.global));
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
public loadKnownScript_Sync(knownScript: IKnownScript) {
|
|
48
|
+
try {
|
|
49
|
+
if (isNotEmptyArray(knownScript.dependencies)) {
|
|
50
|
+
(knownScript.dependencies || []).forEach(dep => {
|
|
51
|
+
this.loadKnownScript_Sync(dep)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.ensureKnownScriptInternal(knownScript, noop, true);
|
|
58
|
+
return Sod.getGlobal(knownScript.global);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private ensureKnownScriptInternal(knownScript: IKnownScript, callback: () => void, sync = false) {
|
|
62
|
+
let url = isDebug() && !knownScript.forceMin ? knownScript.url.replace('.min.js', '.js') : knownScript.url;
|
|
63
|
+
if (url[0] === '/') url = "https://apps.kwizcom.com" + url;
|
|
64
|
+
|
|
65
|
+
if (sync === true)
|
|
66
|
+
this.ensureScriptSync(url, knownScript.global, callback, knownScript.sodName);
|
|
67
|
+
else
|
|
68
|
+
this.ensureScript(url, knownScript.global, callback, knownScript.sodName);
|
|
69
|
+
|
|
70
|
+
let cssFiles = this.isRtl === true && !isNullOrUndefined(knownScript.rtlCss) ? knownScript.rtlCss : knownScript.css;
|
|
71
|
+
if (!isNullOrUndefined(cssFiles))
|
|
72
|
+
cssFiles.forEach(css => {
|
|
73
|
+
if (!isNullOrEmptyString(css)) {
|
|
74
|
+
let cssurl = isDebug() && !knownScript.forceMin ? css.replace('.min.css', '.css') : css;
|
|
75
|
+
if (cssurl[0] === '/') cssurl = "https://apps.kwizcom.com" + cssurl;
|
|
76
|
+
|
|
77
|
+
let knownStyles = document.getElementsByClassName("kwizcom_known_css");
|
|
78
|
+
let found = false;
|
|
79
|
+
for (let si = 0; si < knownStyles.length; si++) {
|
|
80
|
+
let elm: HTMLLinkElement = knownStyles[si] as HTMLLinkElement;
|
|
81
|
+
if (elm.href && elm.href.toLowerCase() === cssurl.toLowerCase()) {
|
|
82
|
+
found = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!found) {
|
|
87
|
+
let link = document.createElement("link");
|
|
88
|
+
link.rel = "stylesheet";
|
|
89
|
+
link.className = "kwizcom_known_css";
|
|
90
|
+
link.type = "text/css";
|
|
91
|
+
link.href = cssurl;
|
|
92
|
+
document.head.appendChild(link);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public loadCss(cssUrl: string) {
|
|
99
|
+
let knownStyles = document.getElementsByClassName("kwizcom_known_css");
|
|
100
|
+
let found = false;
|
|
101
|
+
for (let si = 0; si < knownStyles.length; si++) {
|
|
102
|
+
let elm: HTMLLinkElement = knownStyles[si] as HTMLLinkElement;
|
|
103
|
+
if (elm.href && elm.href.toLowerCase() === cssUrl.toLowerCase()) {
|
|
104
|
+
found = true;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!found) {
|
|
109
|
+
let link = document.createElement("link");
|
|
110
|
+
link.rel = "stylesheet";
|
|
111
|
+
link.className = "kwizcom_known_css";
|
|
112
|
+
link.type = "text/css";
|
|
113
|
+
link.href = cssUrl;
|
|
114
|
+
document.head.appendChild(link);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public ensureScriptSync(scriptUrl: string, global: ksGlobal, callback?: () => void, sodName?: string) {
|
|
119
|
+
//in IE there is no promise, we cannot use any async functions
|
|
120
|
+
return Sod.ensureScriptNoPromise(scriptUrl, global, callback, sodName, true);
|
|
121
|
+
}
|
|
122
|
+
public async ensureScript(scriptUrl: string, global: ksGlobal, callback?: () => void, sodName?: string) {
|
|
123
|
+
return Sod.ensureScript(scriptUrl, global, callback, sodName, false);
|
|
124
|
+
}
|
|
125
|
+
/** ensure a collection of scripts and call the callback when they are all done */
|
|
126
|
+
public async ensureScripts(scripts: { scriptUrl: string; global: ksGlobal; sodName: string; }[], callback: () => void) {
|
|
127
|
+
let promises: Promise<void>[] = [];
|
|
128
|
+
let length = scripts.length;
|
|
129
|
+
let finished = 0;
|
|
130
|
+
let onFinished = typeof (callback) !== "function" ? null : () => {
|
|
131
|
+
finished++;
|
|
132
|
+
if (finished === length)//all finished
|
|
133
|
+
callback();
|
|
134
|
+
};
|
|
135
|
+
scripts.forEach(scr => {
|
|
136
|
+
promises.push(Sod.ensureScript(scr.scriptUrl, scr.global, onFinished, scr.sodName));
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return Promise.all(promises);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private _WrapFunctionArr: any[] = [];
|
|
143
|
+
|
|
144
|
+
/** @deprecated - use wrapFunction instead from helpers/functions */
|
|
145
|
+
public wrapFunction3(originalFunction: () => void, instance: any, doBefore: () => void, doAfter: () => void) {
|
|
146
|
+
try {
|
|
147
|
+
if (instance !== null) {
|
|
148
|
+
originalFunction.bind(instance);
|
|
149
|
+
}
|
|
150
|
+
var idx = this._WrapFunctionArr.length;
|
|
151
|
+
this._WrapFunctionArr[idx] = originalFunction;
|
|
152
|
+
|
|
153
|
+
originalFunction = function (...args: any[]) {
|
|
154
|
+
if (typeof (doBefore) === "function") {
|
|
155
|
+
doBefore.apply(instance, args);
|
|
156
|
+
}
|
|
157
|
+
var returnValue = this._WrapFunctionArr[idx].apply(instance, args);
|
|
158
|
+
if (typeof (doAfter) === "function") {
|
|
159
|
+
doAfter.apply(instance, args);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return returnValue;
|
|
163
|
+
};
|
|
164
|
+
if (instance !== null) {
|
|
165
|
+
originalFunction.bind(instance);
|
|
166
|
+
}
|
|
167
|
+
} catch (e) {
|
|
168
|
+
if (isDebug()) console.log('unhandled error in wrapFunction3');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
171
|
}
|