@olenbetong/appframe-core 1.2.3 → 1.3.2
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/dist/esm/af.common.js +44 -45
- package/dist/esm/af.common.min.js +5 -5
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +45 -43
- package/dist/iife/af.common.min.js +8 -8
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/downloadRequest.d.ts +2 -2
- package/es/downloadRequest.js +3 -3
- package/es/errorHandler.d.ts +0 -0
- package/es/errorHandler.js +25 -0
- package/es/expose.js +2 -3
- package/es/has.d.ts +1 -1
- package/es/has.js +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/package.json +5 -2
- package/src/downloadRequest.ts +4 -4
- package/src/errorHandler.ts +24 -0
- package/src/expose.ts +5 -15
- package/src/has.ts +1 -1
- package/src/index.ts +4 -0
package/es/downloadRequest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { downloadBlob } from "./downloadBlob.js";
|
|
2
|
-
export async function downloadRequest(request, { fileName,
|
|
2
|
+
export async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
3
3
|
function reportProgress(progress) {
|
|
4
4
|
if (typeof onProgress === "function") {
|
|
5
5
|
onProgress({ ...progress });
|
|
@@ -16,7 +16,7 @@ export async function downloadRequest(request, { fileName, controller, onProgres
|
|
|
16
16
|
throw new Error(data.error);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
throw new Error(response.status
|
|
19
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
22
|
const reader = response.body.getReader();
|
|
@@ -49,7 +49,7 @@ export async function downloadRequest(request, { fileName, controller, onProgres
|
|
|
49
49
|
reportProgress({ bytesReceived, status: "completed" });
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
|
-
if (
|
|
52
|
+
if (signal?.aborted) {
|
|
53
53
|
reportProgress({ status: "cancelled" });
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
window.addEventListener("error", (event) => {
|
|
3
|
+
try {
|
|
4
|
+
// Try to avoid error-logging-loop
|
|
5
|
+
const data = {
|
|
6
|
+
error: event.error?.message ?? event.message ?? null,
|
|
7
|
+
file: event.filename,
|
|
8
|
+
line: event.lineno ?? 0,
|
|
9
|
+
column: event.colno ?? 0,
|
|
10
|
+
stack: event.error?.stack ?? null,
|
|
11
|
+
};
|
|
12
|
+
fetch("/data/Logger/LogError", {
|
|
13
|
+
body: JSON.stringify(data),
|
|
14
|
+
headers: {
|
|
15
|
+
Accept: "application/json",
|
|
16
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
17
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
18
|
+
},
|
|
19
|
+
method: "POST",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (ex) {
|
|
23
|
+
// ignore
|
|
24
|
+
}
|
|
25
|
+
});
|
package/es/expose.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import has from "./has.js";
|
|
1
|
+
import { has } from "./has.js";
|
|
2
2
|
import parseFunc from "./parseFunc.js";
|
|
3
3
|
import requireNamespace from "./requireNamespace.js";
|
|
4
4
|
import warn from "./warn.js";
|
|
@@ -36,8 +36,7 @@ export default function expose(name, value) {
|
|
|
36
36
|
}
|
|
37
37
|
namespace = requireNamespace(window, pathParts);
|
|
38
38
|
}
|
|
39
|
-
else if (keyName &&
|
|
40
|
-
(typeof name === "object" || typeof name === "function")) {
|
|
39
|
+
else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
41
40
|
namespace = name;
|
|
42
41
|
}
|
|
43
42
|
else {
|
package/es/has.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function has(obj: any, key: string | number | symbol): boolean;
|
package/es/has.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import "./errorHandler.js";
|
|
1
2
|
export { default as mitt } from "mitt";
|
|
2
3
|
export { downloadBlob } from "./downloadBlob.js";
|
|
3
4
|
export * from "./downloadRequest.js";
|
|
4
5
|
export * from "./exportDataObject.js";
|
|
5
6
|
export { default as expose } from "./expose.js";
|
|
6
7
|
export { getLocalizedString } from "./getLocalizedString.js";
|
|
8
|
+
export * from "./has.js";
|
|
7
9
|
export { default as localStorage } from "./localStorage.js";
|
|
8
10
|
export { default as SessionHandler } from "./SessionHandler.js";
|
|
9
11
|
export { default as UserSession } from "./UserSession.js";
|
package/es/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import "./errorHandler.js";
|
|
1
2
|
export { default as mitt } from "mitt";
|
|
2
3
|
export { downloadBlob } from "./downloadBlob.js";
|
|
3
4
|
export * from "./downloadRequest.js";
|
|
4
5
|
export * from "./exportDataObject.js";
|
|
5
6
|
export { default as expose } from "./expose.js";
|
|
6
7
|
export { getLocalizedString } from "./getLocalizedString.js";
|
|
8
|
+
export * from "./has.js";
|
|
7
9
|
export { default as localStorage } from "./localStorage.js";
|
|
8
10
|
export { default as SessionHandler } from "./SessionHandler.js";
|
|
9
11
|
export { default as UserSession } from "./UserSession.js";
|
|
10
12
|
export { formDataToDataObjectRecord, formDataToObject, formDataToProcedureParameters } from "./formDataToObject.js";
|
|
11
13
|
export * from "./settings.js";
|
|
12
|
-
export const version = "1.2
|
|
14
|
+
export const version = "1.3.2";
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-core",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Javascript libraries to utilize the Appframe framework",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"/src/errorHandler.ts"
|
|
8
|
+
],
|
|
6
9
|
"main": "./es/index.js",
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
@@ -40,5 +43,5 @@
|
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"chalk": "^5.0.1"
|
|
42
45
|
},
|
|
43
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "268422b9ac7ddbef0853e0a7f6d8ae0fbae1b09c"
|
|
44
47
|
}
|
package/src/downloadRequest.ts
CHANGED
|
@@ -7,12 +7,12 @@ export type DownloadItem = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export type DownloadParameters = {
|
|
10
|
-
|
|
10
|
+
signal?: AbortSignal;
|
|
11
11
|
fileName: string;
|
|
12
12
|
onProgress?: (progress: DownloadItem) => void;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export async function downloadRequest(request: Request, { fileName,
|
|
15
|
+
export async function downloadRequest(request: Request, { fileName, signal, onProgress }: DownloadParameters) {
|
|
16
16
|
function reportProgress(progress: DownloadItem) {
|
|
17
17
|
if (typeof onProgress === "function") {
|
|
18
18
|
onProgress({ ...progress });
|
|
@@ -33,7 +33,7 @@ export async function downloadRequest(request: Request, { fileName, controller,
|
|
|
33
33
|
throw new Error(data.error);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
throw new Error(response.status
|
|
36
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
try {
|
|
@@ -73,7 +73,7 @@ export async function downloadRequest(request: Request, { fileName, controller,
|
|
|
73
73
|
|
|
74
74
|
reportProgress({ bytesReceived, status: "completed" });
|
|
75
75
|
} catch (err) {
|
|
76
|
-
if (
|
|
76
|
+
if (signal?.aborted) {
|
|
77
77
|
reportProgress({ status: "cancelled" });
|
|
78
78
|
} else {
|
|
79
79
|
reportProgress({ error: (err as Error).message, status: "error" });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
window.addEventListener("error", (event) => {
|
|
2
|
+
try {
|
|
3
|
+
// Try to avoid error-logging-loop
|
|
4
|
+
const data = {
|
|
5
|
+
error: event.error?.message ?? event.message ?? null,
|
|
6
|
+
file: event.filename,
|
|
7
|
+
line: event.lineno ?? 0,
|
|
8
|
+
column: event.colno ?? 0,
|
|
9
|
+
stack: event.error?.stack ?? null,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
fetch("/data/Logger/LogError", {
|
|
13
|
+
body: JSON.stringify(data),
|
|
14
|
+
headers: {
|
|
15
|
+
Accept: "application/json",
|
|
16
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
17
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
18
|
+
},
|
|
19
|
+
method: "POST",
|
|
20
|
+
});
|
|
21
|
+
} catch (ex) {
|
|
22
|
+
// ignore
|
|
23
|
+
}
|
|
24
|
+
});
|
package/src/expose.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import has from "./has.js";
|
|
1
|
+
import { has } from "./has.js";
|
|
2
2
|
import parseFunc from "./parseFunc.js";
|
|
3
3
|
import requireNamespace from "./requireNamespace.js";
|
|
4
4
|
import warn from "./warn.js";
|
|
@@ -8,14 +8,9 @@ import warn from "./warn.js";
|
|
|
8
8
|
* @param name {string | object} Either a dot-separated path to the global variable, or an object to expose the value on
|
|
9
9
|
* @param value {object | Function | Function[]} The value(s) to expose
|
|
10
10
|
*/
|
|
11
|
-
export default function expose(
|
|
12
|
-
name: object | string,
|
|
13
|
-
value: object | Function | Function[]
|
|
14
|
-
): void {
|
|
11
|
+
export default function expose(name: object | string, value: object | Function | Function[]): void {
|
|
15
12
|
if (arguments.length !== 2) {
|
|
16
|
-
throw new Error(
|
|
17
|
-
"Incorrect number of arguments passed to the expose function!"
|
|
18
|
-
);
|
|
13
|
+
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
19
14
|
}
|
|
20
15
|
|
|
21
16
|
if (Array.isArray(value)) {
|
|
@@ -47,15 +42,10 @@ export default function expose(
|
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
namespace = requireNamespace(window, pathParts);
|
|
50
|
-
} else if (
|
|
51
|
-
keyName &&
|
|
52
|
-
(typeof name === "object" || typeof name === "function")
|
|
53
|
-
) {
|
|
45
|
+
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
54
46
|
namespace = name;
|
|
55
47
|
} else {
|
|
56
|
-
throw new TypeError(
|
|
57
|
-
"Invalid typeof parameter 'name', or unable to parse pValue!"
|
|
58
|
-
);
|
|
48
|
+
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
if (has(namespace, keyName)) {
|
package/src/has.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import "./errorHandler.js";
|
|
2
|
+
|
|
1
3
|
export { default as mitt } from "mitt";
|
|
2
4
|
export { downloadBlob } from "./downloadBlob.js";
|
|
3
5
|
export * from "./downloadRequest.js";
|
|
4
6
|
export * from "./exportDataObject.js";
|
|
5
7
|
export { default as expose } from "./expose.js";
|
|
6
8
|
export { getLocalizedString } from "./getLocalizedString.js";
|
|
9
|
+
export * from "./has.js";
|
|
7
10
|
export { default as localStorage } from "./localStorage.js";
|
|
8
11
|
export { default as SessionHandler } from "./SessionHandler.js";
|
|
9
12
|
export { default as UserSession } from "./UserSession.js";
|
|
10
13
|
export { formDataToDataObjectRecord, formDataToObject, formDataToProcedureParameters } from "./formDataToObject.js";
|
|
11
14
|
export * from "./settings.js";
|
|
15
|
+
|
|
12
16
|
export const version = __VERSION__;
|