@olenbetong/appframe-core 1.2.2 → 1.3.1

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/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.2";
14
+ export const version = "1.3.1";
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-core",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
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
  ".": {
@@ -16,6 +19,11 @@
16
19
  "build:esbuild": "node --loader ts-node/esm.mjs ../../shared/esbuild.ts",
17
20
  "build:tsc": " rm -rf ./es && tsc && node ./scripts/replace-version.js"
18
21
  },
22
+ "files": [
23
+ "dist",
24
+ "es",
25
+ "src"
26
+ ],
19
27
  "author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
20
28
  "repository": {
21
29
  "type": "git",
@@ -35,5 +43,5 @@
35
43
  "devDependencies": {
36
44
  "chalk": "^5.0.1"
37
45
  },
38
- "gitHead": "110516c6cd639ad0a5d593be42bddcfba5a60cc6"
46
+ "gitHead": "6ff17c607d613192d1b6cf615fcc1c6bc7fd3d4e"
39
47
  }
@@ -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
@@ -1,4 +1,4 @@
1
- export default function has(
1
+ export function has(
2
2
  obj: any,
3
3
  key: string | number | symbol
4
4
  ): boolean {
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__;
@@ -1,5 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
-
3
- export default async function importJson(url) {
4
- return JSON.parse(await readFile(new URL(url, import.meta.url)));
5
- }
@@ -1,37 +0,0 @@
1
- import chalk from "chalk";
2
- import fs from "node:fs/promises";
3
- import { resolve } from "node:path";
4
- import importJson from "./import-json.js";
5
-
6
- async function* getFiles(dir) {
7
- const dirents = await fs.readdir(dir, { withFileTypes: true });
8
- for (const dirent of dirents) {
9
- const res = resolve(dir, dirent.name);
10
- if (dirent.isDirectory()) {
11
- yield* getFiles(res);
12
- } else {
13
- yield res;
14
- }
15
- }
16
- }
17
-
18
- try {
19
- let packageConfig = await importJson("../package.json");
20
- for await (let file of getFiles("./es")) {
21
- if (file.endsWith(".js")) {
22
- let fileContent = await fs.readFile(file, "utf-8");
23
- let result = fileContent
24
- .replace("__VERSION__", `"${packageConfig.version}"`)
25
- .replace("process.env.NODE_ENV", '"production"');
26
- if (result !== fileContent) {
27
- await fs.writeFile(file, result, "utf-8");
28
- console.log(file.substring(file.indexOf("/es/")));
29
- } else {
30
- console.log(chalk.dim(file.substring(file.indexOf("/es/"))));
31
- }
32
- }
33
- }
34
- } catch (error) {
35
- console.error(error.message);
36
- process.exit(1);
37
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2021",
4
- "module": "esnext",
5
- "rootDir": "./src",
6
- "strict": true,
7
- "strictNullChecks": true,
8
- "baseUrl": "./",
9
- "esModuleInterop": true,
10
- "moduleResolution": "node",
11
- "resolveJsonModule": true,
12
- "declaration": true,
13
- "outDir": "./es",
14
- "skipLibCheck": true
15
- },
16
- "exclude": [
17
- "test",
18
- "dist",
19
- "es",
20
- "node_modules",
21
- "**/*.test.ts",
22
- "__tests__/*",
23
- "scripts/*"
24
- ],
25
- "include": ["./src/*"]
26
- }