@domql/utils 2.3.154 → 2.4.7
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/LICENSE +1 -1
- package/cookie.js +28 -0
- package/dist/cjs/cookie.js +50 -0
- package/dist/cjs/env.js +32 -0
- package/dist/cjs/globals.js +30 -0
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/key.js +33 -0
- package/dist/cjs/node.js +1 -1
- package/dist/cjs/object.js +11 -10
- package/dist/cjs/string.js +2 -1
- package/dist/cjs/tags.js +159 -0
- package/dist/cjs/types.js +1 -4
- package/env.js +10 -0
- package/globals.js +8 -0
- package/index.js +5 -1
- package/key.js +14 -0
- package/node.js +1 -1
- package/object.js +11 -8
- package/package.json +9 -9
- package/string.js +2 -1
- package/tags.js +141 -0
- package/types.js +0 -3
package/LICENSE
CHANGED
package/cookie.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { isUndefined } from './types'
|
|
4
|
+
|
|
5
|
+
export const isMobile = (() => typeof navigator === 'undefined'
|
|
6
|
+
? false
|
|
7
|
+
: /Mobi/.test(navigator.userAgent))()
|
|
8
|
+
|
|
9
|
+
export const setCookie = (cname, cvalue, exdays = 365) => {
|
|
10
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
11
|
+
const d = new Date()
|
|
12
|
+
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
|
|
13
|
+
const expires = `expires=${d.toUTCString()}`
|
|
14
|
+
document.cookie = `${cname}=${cvalue};${expires};path=/`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getCookie = (cname) => {
|
|
18
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
19
|
+
const name = `${cname}=`
|
|
20
|
+
const decodedCookie = decodeURIComponent(document.cookie)
|
|
21
|
+
const ca = decodedCookie.split(';')
|
|
22
|
+
for (let i = 0; i < ca.length; i++) {
|
|
23
|
+
let c = ca[i]
|
|
24
|
+
while (c.charAt(0) === ' ') c = c.substring(1)
|
|
25
|
+
if (c.indexOf(name) === 0) return c.substring(name.length, c.length)
|
|
26
|
+
}
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cookie_exports = {};
|
|
20
|
+
__export(cookie_exports, {
|
|
21
|
+
getCookie: () => getCookie,
|
|
22
|
+
isMobile: () => isMobile,
|
|
23
|
+
setCookie: () => setCookie
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
26
|
+
var import_types = require("./types");
|
|
27
|
+
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
28
|
+
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
29
|
+
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
30
|
+
return;
|
|
31
|
+
const d = /* @__PURE__ */ new Date();
|
|
32
|
+
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
33
|
+
const expires = `expires=${d.toUTCString()}`;
|
|
34
|
+
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
35
|
+
};
|
|
36
|
+
const getCookie = (cname) => {
|
|
37
|
+
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
38
|
+
return;
|
|
39
|
+
const name = `${cname}=`;
|
|
40
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
|
41
|
+
const ca = decodedCookie.split(";");
|
|
42
|
+
for (let i = 0; i < ca.length; i++) {
|
|
43
|
+
let c = ca[i];
|
|
44
|
+
while (c.charAt(0) === " ")
|
|
45
|
+
c = c.substring(1);
|
|
46
|
+
if (c.indexOf(name) === 0)
|
|
47
|
+
return c.substring(name.length, c.length);
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
};
|
package/dist/cjs/env.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var env_exports = {};
|
|
20
|
+
__export(env_exports, {
|
|
21
|
+
NODE_ENV: () => NODE_ENV,
|
|
22
|
+
getNev: () => getNev,
|
|
23
|
+
isDevelopment: () => isDevelopment,
|
|
24
|
+
isProduction: () => isProduction,
|
|
25
|
+
isTest: () => isTest
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(env_exports);
|
|
28
|
+
const NODE_ENV = "development";
|
|
29
|
+
const isProduction = (env = NODE_ENV) => env === "production" || env === "prod" || env !== "development" && env !== "dev" && env !== "test";
|
|
30
|
+
const isTest = (env = NODE_ENV) => env === "test";
|
|
31
|
+
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev";
|
|
32
|
+
const getNev = (key, env = NODE_ENV) => env[key];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var globals_exports = {};
|
|
20
|
+
__export(globals_exports, {
|
|
21
|
+
document: () => document,
|
|
22
|
+
global: () => global,
|
|
23
|
+
self: () => self,
|
|
24
|
+
window: () => window
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(globals_exports);
|
|
27
|
+
const global = globalThis;
|
|
28
|
+
const self = globalThis;
|
|
29
|
+
const window = globalThis;
|
|
30
|
+
const document = window.document;
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var utils_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(utils_exports);
|
|
18
|
-
__reExport(utils_exports, require("
|
|
18
|
+
__reExport(utils_exports, require("./key.js"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./env.js"), module.exports);
|
|
19
20
|
__reExport(utils_exports, require("./types.js"), module.exports);
|
|
20
21
|
__reExport(utils_exports, require("./object.js"), module.exports);
|
|
21
22
|
__reExport(utils_exports, require("./function.js"), module.exports);
|
|
@@ -23,3 +24,6 @@ __reExport(utils_exports, require("./array.js"), module.exports);
|
|
|
23
24
|
__reExport(utils_exports, require("./node.js"), module.exports);
|
|
24
25
|
__reExport(utils_exports, require("./log.js"), module.exports);
|
|
25
26
|
__reExport(utils_exports, require("./string.js"), module.exports);
|
|
27
|
+
__reExport(utils_exports, require("./globals.js"), module.exports);
|
|
28
|
+
__reExport(utils_exports, require("./cookie.js"), module.exports);
|
|
29
|
+
__reExport(utils_exports, require("./tags.js"), module.exports);
|
package/dist/cjs/key.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var key_exports = {};
|
|
20
|
+
__export(key_exports, {
|
|
21
|
+
createKey: () => createKey,
|
|
22
|
+
createSnapshotId: () => createSnapshotId
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(key_exports);
|
|
25
|
+
const createKey = function() {
|
|
26
|
+
let index = 0;
|
|
27
|
+
function newId() {
|
|
28
|
+
index++;
|
|
29
|
+
return index;
|
|
30
|
+
}
|
|
31
|
+
return newId;
|
|
32
|
+
}();
|
|
33
|
+
const createSnapshotId = createKey;
|
package/dist/cjs/node.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(node_exports, {
|
|
|
22
22
|
isNode: () => isNode
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(node_exports);
|
|
25
|
-
var import_globals = require("
|
|
25
|
+
var import_globals = require("./globals");
|
|
26
26
|
const isNode = (obj) => {
|
|
27
27
|
return (typeof Node === "object" ? obj instanceof import_globals.window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
|
|
28
28
|
};
|
package/dist/cjs/object.js
CHANGED
|
@@ -43,7 +43,7 @@ __export(object_exports, {
|
|
|
43
43
|
stringToObject: () => stringToObject
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(object_exports);
|
|
46
|
-
var import_globals = require("
|
|
46
|
+
var import_globals = require("./globals.js");
|
|
47
47
|
var import_types = require("./types.js");
|
|
48
48
|
var import_array = require("./array.js");
|
|
49
49
|
var import_string = require("./string.js");
|
|
@@ -64,9 +64,8 @@ const map = (obj, extention, element) => {
|
|
|
64
64
|
};
|
|
65
65
|
const merge = (element, obj, excludeFrom = []) => {
|
|
66
66
|
for (const e in obj) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
67
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e);
|
|
68
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__"))
|
|
70
69
|
continue;
|
|
71
70
|
const elementProp = element[e];
|
|
72
71
|
const objProp = obj[e];
|
|
@@ -78,9 +77,8 @@ const merge = (element, obj, excludeFrom = []) => {
|
|
|
78
77
|
};
|
|
79
78
|
const deepMerge = (element, extend, excludeFrom = []) => {
|
|
80
79
|
for (const e in extend) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
80
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
81
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__"))
|
|
84
82
|
continue;
|
|
85
83
|
const elementProp = element[e];
|
|
86
84
|
const extendProp = extend[e];
|
|
@@ -95,7 +93,8 @@ const deepMerge = (element, extend, excludeFrom = []) => {
|
|
|
95
93
|
const clone = (obj, excludeFrom = []) => {
|
|
96
94
|
const o = {};
|
|
97
95
|
for (const prop in obj) {
|
|
98
|
-
|
|
96
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
97
|
+
if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
99
98
|
continue;
|
|
100
99
|
o[prop] = obj[prop];
|
|
101
100
|
}
|
|
@@ -107,7 +106,8 @@ const deepCloneExclude = (obj, excludeFrom = []) => {
|
|
|
107
106
|
}
|
|
108
107
|
const o = {};
|
|
109
108
|
for (const k in obj) {
|
|
110
|
-
|
|
109
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, k);
|
|
110
|
+
if (!hasOwnProperty || excludeFrom.includes(k) || k.startsWith("__"))
|
|
111
111
|
continue;
|
|
112
112
|
let v = obj[k];
|
|
113
113
|
if (k === "extend" && (0, import_types.isArray)(v)) {
|
|
@@ -231,7 +231,8 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
231
231
|
};
|
|
232
232
|
const deepDestringify = (obj, stringified = {}) => {
|
|
233
233
|
for (const prop in obj) {
|
|
234
|
-
|
|
234
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
235
|
+
if (!hasOwnProperty)
|
|
235
236
|
continue;
|
|
236
237
|
const objProp = obj[prop];
|
|
237
238
|
if ((0, import_types.isString)(objProp)) {
|
package/dist/cjs/string.js
CHANGED
|
@@ -30,10 +30,11 @@ const stringIncludesAny = (str, characters) => {
|
|
|
30
30
|
}
|
|
31
31
|
return false;
|
|
32
32
|
};
|
|
33
|
+
const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g;
|
|
33
34
|
const replaceLiteralsWithObjectFields = (str, state) => {
|
|
34
35
|
if (!str.includes("{{"))
|
|
35
36
|
return str;
|
|
36
|
-
return str.replace(
|
|
37
|
+
return str.replace(brackRegex, (_, parentPath, variable) => {
|
|
37
38
|
if (parentPath) {
|
|
38
39
|
const parentLevels = parentPath.match(/\.\.\//g).length;
|
|
39
40
|
let parentState = state;
|
package/dist/cjs/tags.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tags_exports = {};
|
|
20
|
+
__export(tags_exports, {
|
|
21
|
+
HTML_TAGS: () => HTML_TAGS,
|
|
22
|
+
isValidHtmlTag: () => isValidHtmlTag
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tags_exports);
|
|
25
|
+
const HTML_TAGS = {
|
|
26
|
+
root: [
|
|
27
|
+
"body",
|
|
28
|
+
"html"
|
|
29
|
+
],
|
|
30
|
+
head: [
|
|
31
|
+
"title",
|
|
32
|
+
"base",
|
|
33
|
+
"meta",
|
|
34
|
+
"style"
|
|
35
|
+
],
|
|
36
|
+
body: [
|
|
37
|
+
"string",
|
|
38
|
+
"fragment",
|
|
39
|
+
"a",
|
|
40
|
+
"abbr",
|
|
41
|
+
"acronym",
|
|
42
|
+
"address",
|
|
43
|
+
"applet",
|
|
44
|
+
"area",
|
|
45
|
+
"article",
|
|
46
|
+
"aside",
|
|
47
|
+
"audio",
|
|
48
|
+
"b",
|
|
49
|
+
"basefont",
|
|
50
|
+
"bdi",
|
|
51
|
+
"bdo",
|
|
52
|
+
"big",
|
|
53
|
+
"blockquote",
|
|
54
|
+
"br",
|
|
55
|
+
"button",
|
|
56
|
+
"canvas",
|
|
57
|
+
"caption",
|
|
58
|
+
"center",
|
|
59
|
+
"cite",
|
|
60
|
+
"code",
|
|
61
|
+
"col",
|
|
62
|
+
"colgroup",
|
|
63
|
+
"data",
|
|
64
|
+
"datalist",
|
|
65
|
+
"dd",
|
|
66
|
+
"del",
|
|
67
|
+
"details",
|
|
68
|
+
"dfn",
|
|
69
|
+
"dialog",
|
|
70
|
+
"dir",
|
|
71
|
+
"div",
|
|
72
|
+
"dl",
|
|
73
|
+
"dt",
|
|
74
|
+
"em",
|
|
75
|
+
"embed",
|
|
76
|
+
"fieldset",
|
|
77
|
+
"figcaption",
|
|
78
|
+
"figure",
|
|
79
|
+
"font",
|
|
80
|
+
"footer",
|
|
81
|
+
"form",
|
|
82
|
+
"frame",
|
|
83
|
+
"frameset",
|
|
84
|
+
"h1",
|
|
85
|
+
"h2",
|
|
86
|
+
"h3",
|
|
87
|
+
"h4",
|
|
88
|
+
"h5",
|
|
89
|
+
"h6",
|
|
90
|
+
"head",
|
|
91
|
+
"header",
|
|
92
|
+
"hr",
|
|
93
|
+
"i",
|
|
94
|
+
"iframe",
|
|
95
|
+
"img",
|
|
96
|
+
"input",
|
|
97
|
+
"ins",
|
|
98
|
+
"kbd",
|
|
99
|
+
"label",
|
|
100
|
+
"legend",
|
|
101
|
+
"li",
|
|
102
|
+
"link",
|
|
103
|
+
"main",
|
|
104
|
+
"map",
|
|
105
|
+
"mark",
|
|
106
|
+
"meter",
|
|
107
|
+
"nav",
|
|
108
|
+
"noframes",
|
|
109
|
+
"noscript",
|
|
110
|
+
"object",
|
|
111
|
+
"ol",
|
|
112
|
+
"optgroup",
|
|
113
|
+
"option",
|
|
114
|
+
"output",
|
|
115
|
+
"p",
|
|
116
|
+
"param",
|
|
117
|
+
"picture",
|
|
118
|
+
"pre",
|
|
119
|
+
"progress",
|
|
120
|
+
"q",
|
|
121
|
+
"rp",
|
|
122
|
+
"rt",
|
|
123
|
+
"ruby",
|
|
124
|
+
"s",
|
|
125
|
+
"samp",
|
|
126
|
+
"script",
|
|
127
|
+
"section",
|
|
128
|
+
"select",
|
|
129
|
+
"small",
|
|
130
|
+
"source",
|
|
131
|
+
"span",
|
|
132
|
+
"strike",
|
|
133
|
+
"strong",
|
|
134
|
+
"sub",
|
|
135
|
+
"summary",
|
|
136
|
+
"sup",
|
|
137
|
+
"table",
|
|
138
|
+
"tbody",
|
|
139
|
+
"td",
|
|
140
|
+
"template",
|
|
141
|
+
"textarea",
|
|
142
|
+
"tfoot",
|
|
143
|
+
"th",
|
|
144
|
+
"thead",
|
|
145
|
+
"time",
|
|
146
|
+
"tr",
|
|
147
|
+
"track",
|
|
148
|
+
"tt",
|
|
149
|
+
"u",
|
|
150
|
+
"ul",
|
|
151
|
+
"var",
|
|
152
|
+
"video",
|
|
153
|
+
"wbr",
|
|
154
|
+
// SVG
|
|
155
|
+
"svg",
|
|
156
|
+
"path"
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
const isValidHtmlTag = (arg) => HTML_TAGS.body.includes(arg);
|
package/dist/cjs/types.js
CHANGED
|
@@ -30,13 +30,10 @@ __export(types_exports, {
|
|
|
30
30
|
isObject: () => isObject,
|
|
31
31
|
isObjectLike: () => isObjectLike,
|
|
32
32
|
isString: () => isString,
|
|
33
|
-
isUndefined: () => isUndefined
|
|
34
|
-
isValidHtmlTag: () => isValidHtmlTag
|
|
33
|
+
isUndefined: () => isUndefined
|
|
35
34
|
});
|
|
36
35
|
module.exports = __toCommonJS(types_exports);
|
|
37
|
-
var import_tags = require("@domql/tags");
|
|
38
36
|
var import_node = require("./node");
|
|
39
|
-
const isValidHtmlTag = (arg) => import_tags.HTML_TAGS.body.includes(arg);
|
|
40
37
|
const isObject = (arg) => {
|
|
41
38
|
if (arg === null)
|
|
42
39
|
return false;
|
package/env.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const NODE_ENV = process.env.NODE_ENV
|
|
4
|
+
|
|
5
|
+
export const isProduction = (env = NODE_ENV) => (env === 'production' || env === 'prod') ||
|
|
6
|
+
(env !== 'development' && env !== 'dev' && env !== 'test')
|
|
7
|
+
export const isTest = (env = NODE_ENV) => env === 'test'
|
|
8
|
+
export const isDevelopment = (env = NODE_ENV) => env === 'development' || env === 'dev'
|
|
9
|
+
|
|
10
|
+
export const getNev = (key, env = NODE_ENV) => env[key]
|
package/globals.js
ADDED
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
export * from '
|
|
3
|
+
export * from './key.js'
|
|
4
|
+
export * from './env.js'
|
|
4
5
|
export * from './types.js'
|
|
5
6
|
export * from './object.js'
|
|
6
7
|
export * from './function.js'
|
|
@@ -8,3 +9,6 @@ export * from './array.js'
|
|
|
8
9
|
export * from './node.js'
|
|
9
10
|
export * from './log.js'
|
|
10
11
|
export * from './string.js'
|
|
12
|
+
export * from './globals.js'
|
|
13
|
+
export * from './cookie.js'
|
|
14
|
+
export * from './tags.js'
|
package/key.js
ADDED
package/node.js
CHANGED
package/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { window } from '
|
|
3
|
+
import { window } from './globals.js'
|
|
4
4
|
import { isFunction, isObjectLike, isObject, isArray, isString, is } from './types.js'
|
|
5
5
|
import { mergeAndCloneIfArray, mergeArray } from './array.js'
|
|
6
6
|
import { stringIncludesAny } from './string.js'
|
|
@@ -24,8 +24,8 @@ export const map = (obj, extention, element) => {
|
|
|
24
24
|
|
|
25
25
|
export const merge = (element, obj, excludeFrom = []) => {
|
|
26
26
|
for (const e in obj) {
|
|
27
|
-
|
|
28
|
-
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
27
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e)
|
|
28
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
29
29
|
const elementProp = element[e]
|
|
30
30
|
const objProp = obj[e]
|
|
31
31
|
if (elementProp === undefined) {
|
|
@@ -37,8 +37,8 @@ export const merge = (element, obj, excludeFrom = []) => {
|
|
|
37
37
|
|
|
38
38
|
export const deepMerge = (element, extend, excludeFrom = []) => {
|
|
39
39
|
for (const e in extend) {
|
|
40
|
-
|
|
41
|
-
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
40
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e)
|
|
41
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
42
42
|
const elementProp = element[e]
|
|
43
43
|
const extendProp = extend[e]
|
|
44
44
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -53,7 +53,8 @@ export const deepMerge = (element, extend, excludeFrom = []) => {
|
|
|
53
53
|
export const clone = (obj, excludeFrom = []) => {
|
|
54
54
|
const o = {}
|
|
55
55
|
for (const prop in obj) {
|
|
56
|
-
|
|
56
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
|
|
57
|
+
if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__')) continue
|
|
57
58
|
o[prop] = obj[prop]
|
|
58
59
|
}
|
|
59
60
|
return o
|
|
@@ -67,7 +68,8 @@ export const deepCloneExclude = (obj, excludeFrom = []) => {
|
|
|
67
68
|
|
|
68
69
|
const o = {}
|
|
69
70
|
for (const k in obj) {
|
|
70
|
-
|
|
71
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, k)
|
|
72
|
+
if (!hasOwnProperty || excludeFrom.includes(k) || k.startsWith('__')) continue
|
|
71
73
|
|
|
72
74
|
let v = obj[k]
|
|
73
75
|
|
|
@@ -208,7 +210,8 @@ export const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
208
210
|
*/
|
|
209
211
|
export const deepDestringify = (obj, stringified = {}) => {
|
|
210
212
|
for (const prop in obj) {
|
|
211
|
-
|
|
213
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
|
|
214
|
+
if (!hasOwnProperty) continue
|
|
212
215
|
const objProp = obj[prop]
|
|
213
216
|
if (isString(objProp)) {
|
|
214
217
|
if (objProp.includes('=>') || objProp.includes('function') || objProp.startsWith('(')) {
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
|
-
"exports":
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"kalduna": "./index.js",
|
|
11
|
+
"default": "./dist/cjs/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
9
14
|
"source": "index.js",
|
|
10
15
|
"files": [
|
|
11
16
|
"*.js",
|
|
12
17
|
"dist"
|
|
13
18
|
],
|
|
14
19
|
"scripts": {
|
|
15
|
-
"copy:package:cjs": "cp
|
|
20
|
+
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
16
21
|
"build:esm": "npx esbuild *.js --target=es2019 --format=esm --outdir=dist/esm",
|
|
17
22
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
18
23
|
"build": "yarn build:cjs",
|
|
19
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
20
25
|
},
|
|
21
|
-
"
|
|
22
|
-
"@domql/globals": "latest",
|
|
23
|
-
"@domql/key": "latest",
|
|
24
|
-
"@domql/tags": "latest"
|
|
25
|
-
},
|
|
26
|
-
"gitHead": "6c166817b0c218f1b3f3f0860ae9147a07e7dabc",
|
|
26
|
+
"gitHead": "fd9683a7d42893983463967fa512ac095a6a36e9",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|
package/string.js
CHANGED
|
@@ -15,9 +15,10 @@ export const stringIncludesAny = (str, characters) => {
|
|
|
15
15
|
* @param {object} state - The object containing the values to substitute.
|
|
16
16
|
* @returns {string} The modified string with placeholders replaced by values from the object.
|
|
17
17
|
*/
|
|
18
|
+
const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g
|
|
18
19
|
export const replaceLiteralsWithObjectFields = (str, state) => {
|
|
19
20
|
if (!str.includes('{{')) return str
|
|
20
|
-
return str.replace(
|
|
21
|
+
return str.replace(brackRegex, (_, parentPath, variable) => {
|
|
21
22
|
if (parentPath) {
|
|
22
23
|
const parentLevels = parentPath.match(/\.\.\//g).length
|
|
23
24
|
let parentState = state
|
package/tags.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const HTML_TAGS = {
|
|
4
|
+
root: [
|
|
5
|
+
'body',
|
|
6
|
+
'html'
|
|
7
|
+
],
|
|
8
|
+
|
|
9
|
+
head: [
|
|
10
|
+
'title',
|
|
11
|
+
'base',
|
|
12
|
+
'meta',
|
|
13
|
+
'style'
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
body: [
|
|
17
|
+
'string',
|
|
18
|
+
'fragment',
|
|
19
|
+
'a',
|
|
20
|
+
'abbr',
|
|
21
|
+
'acronym',
|
|
22
|
+
'address',
|
|
23
|
+
'applet',
|
|
24
|
+
'area',
|
|
25
|
+
'article',
|
|
26
|
+
'aside',
|
|
27
|
+
'audio',
|
|
28
|
+
'b',
|
|
29
|
+
'basefont',
|
|
30
|
+
'bdi',
|
|
31
|
+
'bdo',
|
|
32
|
+
'big',
|
|
33
|
+
'blockquote',
|
|
34
|
+
'br',
|
|
35
|
+
'button',
|
|
36
|
+
'canvas',
|
|
37
|
+
'caption',
|
|
38
|
+
'center',
|
|
39
|
+
'cite',
|
|
40
|
+
'code',
|
|
41
|
+
'col',
|
|
42
|
+
'colgroup',
|
|
43
|
+
'data',
|
|
44
|
+
'datalist',
|
|
45
|
+
'dd',
|
|
46
|
+
'del',
|
|
47
|
+
'details',
|
|
48
|
+
'dfn',
|
|
49
|
+
'dialog',
|
|
50
|
+
'dir',
|
|
51
|
+
'div',
|
|
52
|
+
'dl',
|
|
53
|
+
'dt',
|
|
54
|
+
'em',
|
|
55
|
+
'embed',
|
|
56
|
+
'fieldset',
|
|
57
|
+
'figcaption',
|
|
58
|
+
'figure',
|
|
59
|
+
'font',
|
|
60
|
+
'footer',
|
|
61
|
+
'form',
|
|
62
|
+
'frame',
|
|
63
|
+
'frameset',
|
|
64
|
+
'h1',
|
|
65
|
+
'h2',
|
|
66
|
+
'h3',
|
|
67
|
+
'h4',
|
|
68
|
+
'h5',
|
|
69
|
+
'h6',
|
|
70
|
+
'head',
|
|
71
|
+
'header',
|
|
72
|
+
'hr',
|
|
73
|
+
'i',
|
|
74
|
+
'iframe',
|
|
75
|
+
'img',
|
|
76
|
+
'input',
|
|
77
|
+
'ins',
|
|
78
|
+
'kbd',
|
|
79
|
+
'label',
|
|
80
|
+
'legend',
|
|
81
|
+
'li',
|
|
82
|
+
'link',
|
|
83
|
+
'main',
|
|
84
|
+
'map',
|
|
85
|
+
'mark',
|
|
86
|
+
'meter',
|
|
87
|
+
'nav',
|
|
88
|
+
'noframes',
|
|
89
|
+
'noscript',
|
|
90
|
+
'object',
|
|
91
|
+
'ol',
|
|
92
|
+
'optgroup',
|
|
93
|
+
'option',
|
|
94
|
+
'output',
|
|
95
|
+
'p',
|
|
96
|
+
'param',
|
|
97
|
+
'picture',
|
|
98
|
+
'pre',
|
|
99
|
+
'progress',
|
|
100
|
+
'q',
|
|
101
|
+
'rp',
|
|
102
|
+
'rt',
|
|
103
|
+
'ruby',
|
|
104
|
+
's',
|
|
105
|
+
'samp',
|
|
106
|
+
'script',
|
|
107
|
+
'section',
|
|
108
|
+
'select',
|
|
109
|
+
'small',
|
|
110
|
+
'source',
|
|
111
|
+
'span',
|
|
112
|
+
'strike',
|
|
113
|
+
'strong',
|
|
114
|
+
'sub',
|
|
115
|
+
'summary',
|
|
116
|
+
'sup',
|
|
117
|
+
'table',
|
|
118
|
+
'tbody',
|
|
119
|
+
'td',
|
|
120
|
+
'template',
|
|
121
|
+
'textarea',
|
|
122
|
+
'tfoot',
|
|
123
|
+
'th',
|
|
124
|
+
'thead',
|
|
125
|
+
'time',
|
|
126
|
+
'tr',
|
|
127
|
+
'track',
|
|
128
|
+
'tt',
|
|
129
|
+
'u',
|
|
130
|
+
'ul',
|
|
131
|
+
'var',
|
|
132
|
+
'video',
|
|
133
|
+
'wbr',
|
|
134
|
+
|
|
135
|
+
// SVG
|
|
136
|
+
'svg',
|
|
137
|
+
'path'
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const isValidHtmlTag = arg => HTML_TAGS.body.includes(arg)
|
package/types.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { HTML_TAGS } from '@domql/tags'
|
|
4
3
|
import { isHtmlElement, isNode } from './node'
|
|
5
4
|
|
|
6
|
-
export const isValidHtmlTag = arg => HTML_TAGS.body.includes(arg)
|
|
7
|
-
|
|
8
5
|
export const isObject = arg => {
|
|
9
6
|
if (arg === null) return false
|
|
10
7
|
return (typeof arg === 'object') && (arg.constructor === Object)
|