@domql/report 3.2.3 → 3.3.0

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/cjs/index.js CHANGED
@@ -78,13 +78,11 @@ const report = (err, arg, element) => {
78
78
  const currentLang = "en";
79
79
  let errObj;
80
80
  if (err && typeof err === "string") errObj = ERRORS_REGISTRY[currentLang][err];
81
- return new Error(
82
- `"${err}", "${arg}"
81
+ const description = errObj ? `
83
82
 
84
- `,
85
- `${errObj.description}`,
86
- element ? `
83
+ ${errObj.description}` : "";
84
+ const context = element ? `
87
85
 
88
- ${element}` : ""
89
- );
86
+ ${element}` : "";
87
+ return new Error(`"${err}", "${arg}"${description}${context}`);
90
88
  };
package/dist/esm/index.js CHANGED
@@ -54,15 +54,13 @@ const report = (err, arg, element) => {
54
54
  const currentLang = "en";
55
55
  let errObj;
56
56
  if (err && typeof err === "string") errObj = ERRORS_REGISTRY[currentLang][err];
57
- return new Error(
58
- `"${err}", "${arg}"
57
+ const description = errObj ? `
59
58
 
60
- `,
61
- `${errObj.description}`,
62
- element ? `
59
+ ${errObj.description}` : "";
60
+ const context = element ? `
63
61
 
64
- ${element}` : ""
65
- );
62
+ ${element}` : "";
63
+ return new Error(`"${err}", "${arg}"${description}${context}`);
66
64
  };
67
65
  export {
68
66
  ERRORS_REGISTRY,
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var DomqlReport = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // index.js
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ ERRORS_REGISTRY: () => ERRORS_REGISTRY,
25
+ report: () => report
26
+ });
27
+ var ERRORS_REGISTRY = {
28
+ en: {
29
+ DocumentNotDefined: {
30
+ title: "Document is undefined",
31
+ description: "To tweak with DOM, you should use browser."
32
+ },
33
+ OverwriteToBuiltin: {
34
+ title: "Overwriting to builtin method",
35
+ description: "Overwriting a builtin method in the window define is not possible, please choose different name"
36
+ },
37
+ BrowserNotDefined: {
38
+ title: "Can't recognize environment",
39
+ description: "Environment should be browser application, that can run Javascript"
40
+ },
41
+ SetQuickPreferancesIsNotObject: {
42
+ title: "Quick preferances object is required",
43
+ description: 'Please pass a plain object with "lang", "culture" and "area" properties'
44
+ },
45
+ InvalidParams: {
46
+ title: "Params are invalid",
47
+ description: 'Please pass a plain object with "lang", "culture" and "area" properties'
48
+ },
49
+ CantCreateWithoutNode: {
50
+ title: "You must provide node",
51
+ description: "Can't create DOM element without setting node or text"
52
+ },
53
+ HTMLInvalidTag: {
54
+ title: "Element tag name (or DOM nodeName) is invalid",
55
+ description: "To create element, you must provide valid DOM node. See full list of them at here: http://www.w3schools.com/tags/"
56
+ },
57
+ HTMLInvalidAttr: {
58
+ title: "Attibutes object is invalid",
59
+ description: "Please pass a valid plain object to apply as an attributes for a DOM node"
60
+ },
61
+ HTMLInvalidData: {
62
+ title: "Data object is invalid",
63
+ description: "Please pass a valid plain object to apply as an dataset for a DOM node"
64
+ },
65
+ HTMLInvalidStyles: {
66
+ title: "Styles object is invalid",
67
+ description: "Please pass a valid plain object to apply as an style for a DOM node"
68
+ },
69
+ HTMLInvalidText: {
70
+ title: "Text string is invalid",
71
+ description: "Please pass a valid string to apply text to DOM node"
72
+ },
73
+ ElementOnStateIsNotDefined: {
74
+ title: "Element on state is not defined",
75
+ description: "Please check the element object"
76
+ }
77
+ }
78
+ };
79
+ var report = (err, arg, element) => {
80
+ const currentLang = "en";
81
+ let errObj;
82
+ if (err && typeof err === "string") errObj = ERRORS_REGISTRY[currentLang][err];
83
+ const description = errObj ? `
84
+
85
+ ${errObj.description}` : "";
86
+ const context = element ? `
87
+
88
+ ${element}` : "";
89
+ return new Error(`"${err}", "${arg}"${description}${context}`);
90
+ };
91
+ return __toCommonJS(index_exports);
92
+ })();
package/index.js CHANGED
@@ -66,9 +66,7 @@ export const report = (err, arg, element) => {
66
66
  let errObj
67
67
  if (err && typeof err === 'string') errObj = ERRORS_REGISTRY[currentLang][err]
68
68
 
69
- return new Error(
70
- `"${err}", "${arg}"\n\n`,
71
- `${errObj.description}`,
72
- element ? `\n\n${element}` : ''
73
- )
69
+ const description = errObj ? `\n\n${errObj.description}` : ''
70
+ const context = element ? `\n\n${element}` : ''
71
+ return new Error(`"${err}", "${arg}"${description}${context}`)
74
72
  }
package/package.json CHANGED
@@ -1,29 +1,34 @@
1
1
  {
2
2
  "name": "@domql/report",
3
- "version": "3.2.3",
3
+ "version": "3.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "module": "index.js",
7
- "main": "index.js",
6
+ "module": "./index.js",
7
+ "main": "./index.js",
8
8
  "source": "index.js",
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./dist/esm/index.js",
12
- "require": "./dist/cjs/index.js",
13
- "default": "./dist/esm/index.js"
11
+ "import": "./index.js",
12
+ "require": "./index.js",
13
+ "browser": "./index.js",
14
+ "default": "./index.js"
14
15
  }
15
16
  },
16
17
  "files": [
17
- "*.js",
18
- "dist"
18
+ "dist",
19
+ "*.js"
19
20
  ],
20
21
  "scripts": {
21
22
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
22
- "build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
23
- "build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
24
- "build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
25
- "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
26
- "prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
23
+ "build:esm": "cross-env NODE_ENV=$NODE_ENV esbuild *.js --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
24
+ "build:cjs": "cross-env NODE_ENV=$NODE_ENV esbuild *.js --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
25
+ "build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=DomqlReport --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV",
26
+ "build": "node ../../build/build.js",
27
+ "prepublish": "npm run build && npm run copy:package:cjs"
27
28
  },
28
- "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681"
29
+ "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
30
+ "browser": "./dist/iife/index.js",
31
+ "unpkg": "./dist/iife/index.js",
32
+ "jsdelivr": "./dist/iife/index.js",
33
+ "sideEffects": false
29
34
  }
@@ -1,4 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "main": "index.js"
4
- }