@domql/utils 2.5.179 → 2.5.185
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/array.js +2 -2
- package/component.js +4 -9
- package/cookie.js +2 -2
- package/dist/cjs/array.js +2 -2
- package/dist/cjs/component.js +19 -17
- package/dist/cjs/cookie.js +8 -8
- package/dist/cjs/node.js +1 -1
- package/dist/cjs/types.js +1 -1
- package/dist/esm/array.js +2 -2
- package/dist/esm/component.js +3 -9
- package/dist/esm/cookie.js +2 -2
- package/dist/esm/node.js +1 -1
- package/dist/esm/types.js +1 -1
- package/node.js +1 -1
- package/package.json +5 -6
- package/types.js +1 -1
package/array.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { deepClone, deepMerge } from './object'
|
|
4
|
-
import { isArray, isNumber, isString } from './types'
|
|
3
|
+
import { deepClone, deepMerge } from './object.js'
|
|
4
|
+
import { isArray, isNumber, isString } from './types.js'
|
|
5
5
|
|
|
6
6
|
export const arrayContainsOtherArray = (arr1, arr2) => {
|
|
7
7
|
return arr2.every(val => arr1.includes(val))
|
package/component.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
isFunction,
|
|
8
|
-
isObject,
|
|
9
|
-
isString,
|
|
10
|
-
joinArrays
|
|
11
|
-
} from '.'
|
|
3
|
+
import { joinArrays } from './array.js'
|
|
4
|
+
import { deepClone, exec } from './object.js'
|
|
5
|
+
import { isArray, isFunction, isObject, isString } from './types.js'
|
|
6
|
+
|
|
12
7
|
const ENV = process.env.NODE_ENV
|
|
13
8
|
|
|
14
9
|
export const checkIfKeyIsComponent = (key) => {
|
package/cookie.js
CHANGED
package/dist/cjs/array.js
CHANGED
|
@@ -37,8 +37,8 @@ __export(array_exports, {
|
|
|
37
37
|
swapItemsInArray: () => swapItemsInArray
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(array_exports);
|
|
40
|
-
var import_object = require("./object");
|
|
41
|
-
var import_types = require("./types");
|
|
40
|
+
var import_object = require("./object.js");
|
|
41
|
+
var import_types = require("./types.js");
|
|
42
42
|
const arrayContainsOtherArray = (arr1, arr2) => {
|
|
43
43
|
return arr2.every((val) => arr1.includes(val));
|
|
44
44
|
};
|
package/dist/cjs/component.js
CHANGED
|
@@ -35,17 +35,19 @@ __export(component_exports, {
|
|
|
35
35
|
setContentKey: () => setContentKey
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(component_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_array = require("./array.js");
|
|
39
|
+
var import_object = require("./object.js");
|
|
40
|
+
var import_types = require("./types.js");
|
|
39
41
|
const ENV = "development";
|
|
40
42
|
const checkIfKeyIsComponent = (key) => {
|
|
41
|
-
const isFirstKeyString = (0,
|
|
43
|
+
const isFirstKeyString = (0, import_types.isString)(key);
|
|
42
44
|
if (!isFirstKeyString)
|
|
43
45
|
return;
|
|
44
46
|
const firstCharKey = key.slice(0, 1);
|
|
45
47
|
return /^[A-Z]*$/.test(firstCharKey);
|
|
46
48
|
};
|
|
47
49
|
const checkIfKeyIsProperty = (key) => {
|
|
48
|
-
const isFirstKeyString = (0,
|
|
50
|
+
const isFirstKeyString = (0, import_types.isString)(key);
|
|
49
51
|
if (!isFirstKeyString)
|
|
50
52
|
return;
|
|
51
53
|
const firstCharKey = key.slice(0, 1);
|
|
@@ -55,9 +57,9 @@ const addAdditionalExtend = (newExtend, element) => {
|
|
|
55
57
|
if (!newExtend)
|
|
56
58
|
return element;
|
|
57
59
|
const { extend: elementExtend } = element;
|
|
58
|
-
const originalArray = (0,
|
|
59
|
-
const receivedArray = (0,
|
|
60
|
-
const extend = (0,
|
|
60
|
+
const originalArray = (0, import_types.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
61
|
+
const receivedArray = (0, import_types.isArray)(newExtend) ? newExtend : [newExtend];
|
|
62
|
+
const extend = (0, import_array.joinArrays)(receivedArray, originalArray);
|
|
61
63
|
return { ...element, extend };
|
|
62
64
|
};
|
|
63
65
|
const checkIfSugar = (element, parent, key) => {
|
|
@@ -127,11 +129,11 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
127
129
|
};
|
|
128
130
|
} else if (extend) {
|
|
129
131
|
return addAdditionalExtend(extendFromKey, element);
|
|
130
|
-
} else if ((0,
|
|
132
|
+
} else if ((0, import_types.isFunction)(element)) {
|
|
131
133
|
return {
|
|
132
134
|
extend: extendFromKey,
|
|
133
135
|
tag,
|
|
134
|
-
props: { ...(0,
|
|
136
|
+
props: { ...(0, import_object.exec)(element, parent) }
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
139
|
};
|
|
@@ -155,7 +157,7 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
155
157
|
if (newChild === null)
|
|
156
158
|
assignChild(null);
|
|
157
159
|
else if (!childElem)
|
|
158
|
-
assignChild((0,
|
|
160
|
+
assignChild((0, import_object.deepClone)(newChild));
|
|
159
161
|
else {
|
|
160
162
|
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
161
163
|
if (isSugarChildElem)
|
|
@@ -176,8 +178,8 @@ const applyComponentFromContext = (element, parent, options) => {
|
|
|
176
178
|
return;
|
|
177
179
|
const { components } = context;
|
|
178
180
|
const { extend } = element;
|
|
179
|
-
const execExtend = (0,
|
|
180
|
-
if ((0,
|
|
181
|
+
const execExtend = (0, import_object.exec)(extend, element);
|
|
182
|
+
if ((0, import_types.isString)(execExtend)) {
|
|
181
183
|
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
182
184
|
if (componentExists)
|
|
183
185
|
element.extend = componentExists;
|
|
@@ -191,14 +193,14 @@ const applyComponentFromContext = (element, parent, options) => {
|
|
|
191
193
|
}
|
|
192
194
|
};
|
|
193
195
|
const isVariant = (param) => {
|
|
194
|
-
if (!(0,
|
|
196
|
+
if (!(0, import_types.isString)(param))
|
|
195
197
|
return;
|
|
196
198
|
const firstCharKey = param.slice(0, 1);
|
|
197
199
|
return firstCharKey === ".";
|
|
198
200
|
};
|
|
199
201
|
const hasVariantProp = (element) => {
|
|
200
202
|
const { props } = element;
|
|
201
|
-
if ((0,
|
|
203
|
+
if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant))
|
|
202
204
|
return true;
|
|
203
205
|
};
|
|
204
206
|
const getChildrenComponentsByKey = (key, el) => {
|
|
@@ -206,14 +208,14 @@ const getChildrenComponentsByKey = (key, el) => {
|
|
|
206
208
|
return el;
|
|
207
209
|
}
|
|
208
210
|
if (el.extend) {
|
|
209
|
-
const foundString = (0,
|
|
210
|
-
const foundInArray = (0,
|
|
211
|
+
const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
|
|
212
|
+
const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
211
213
|
if (foundString || foundInArray)
|
|
212
214
|
return el;
|
|
213
215
|
}
|
|
214
216
|
if (el.parent && el.parent.childExtend) {
|
|
215
|
-
const foundString = (0,
|
|
216
|
-
const foundInArray = (0,
|
|
217
|
+
const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
218
|
+
const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
217
219
|
if (foundString || foundInArray)
|
|
218
220
|
return el;
|
|
219
221
|
}
|
package/dist/cjs/cookie.js
CHANGED
|
@@ -26,22 +26,22 @@ __export(cookie_exports, {
|
|
|
26
26
|
setLocalStorage: () => setLocalStorage
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(cookie_exports);
|
|
29
|
-
var import_types = require("./types");
|
|
30
|
-
var
|
|
29
|
+
var import_types = require("./types.js");
|
|
30
|
+
var import_globals = require("./globals.js");
|
|
31
31
|
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
32
32
|
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
33
|
-
if ((0, import_types.isUndefined)(
|
|
33
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
34
34
|
return;
|
|
35
35
|
const d = /* @__PURE__ */ new Date();
|
|
36
36
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
37
37
|
const expires = `expires=${d.toUTCString()}`;
|
|
38
|
-
|
|
38
|
+
import_globals.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
39
39
|
};
|
|
40
40
|
const getCookie = (cname) => {
|
|
41
|
-
if ((0, import_types.isUndefined)(
|
|
41
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
42
42
|
return;
|
|
43
43
|
const name = `${cname}=`;
|
|
44
|
-
const decodedCookie = decodeURIComponent(
|
|
44
|
+
const decodedCookie = decodeURIComponent(import_globals.document.cookie);
|
|
45
45
|
const ca = decodedCookie.split(";");
|
|
46
46
|
for (let i = 0; i < ca.length; i++) {
|
|
47
47
|
let c = ca[i];
|
|
@@ -53,9 +53,9 @@ const getCookie = (cname) => {
|
|
|
53
53
|
return "";
|
|
54
54
|
};
|
|
55
55
|
const removeCookie = (cname) => {
|
|
56
|
-
if ((0, import_types.isUndefined)(
|
|
56
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
57
57
|
return;
|
|
58
|
-
|
|
58
|
+
import_globals.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
59
59
|
};
|
|
60
60
|
function getLocalStorage(key) {
|
|
61
61
|
let savedJSON;
|
package/dist/cjs/node.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(node_exports, {
|
|
|
23
23
|
isNode: () => isNode
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(node_exports);
|
|
26
|
-
var import_globals = require("./globals");
|
|
26
|
+
var import_globals = require("./globals.js");
|
|
27
27
|
const isNode = (obj) => {
|
|
28
28
|
return (typeof Node === "object" ? obj instanceof import_globals.window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
|
|
29
29
|
};
|
package/dist/cjs/types.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(types_exports, {
|
|
|
34
34
|
isUndefined: () => isUndefined
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(types_exports);
|
|
37
|
-
var import_node = require("./node");
|
|
37
|
+
var import_node = require("./node.js");
|
|
38
38
|
const isObject = (arg) => {
|
|
39
39
|
if (arg === null)
|
|
40
40
|
return false;
|
package/dist/esm/array.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { deepClone, deepMerge } from "./object";
|
|
2
|
-
import { isArray, isNumber, isString } from "./types";
|
|
1
|
+
import { deepClone, deepMerge } from "./object.js";
|
|
2
|
+
import { isArray, isNumber, isString } from "./types.js";
|
|
3
3
|
const arrayContainsOtherArray = (arr1, arr2) => {
|
|
4
4
|
return arr2.every((val) => arr1.includes(val));
|
|
5
5
|
};
|
package/dist/esm/component.js
CHANGED
|
@@ -17,15 +17,9 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isArray,
|
|
24
|
-
isFunction,
|
|
25
|
-
isObject,
|
|
26
|
-
isString,
|
|
27
|
-
joinArrays
|
|
28
|
-
} from ".";
|
|
20
|
+
import { joinArrays } from "./array.js";
|
|
21
|
+
import { deepClone, exec } from "./object.js";
|
|
22
|
+
import { isArray, isFunction, isObject, isString } from "./types.js";
|
|
29
23
|
const ENV = "development";
|
|
30
24
|
const checkIfKeyIsComponent = (key) => {
|
|
31
25
|
const isFirstKeyString = isString(key);
|
package/dist/esm/cookie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isUndefined } from "./types";
|
|
2
|
-
import { document } from "
|
|
1
|
+
import { isUndefined } from "./types.js";
|
|
2
|
+
import { document } from "./globals.js";
|
|
3
3
|
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
4
4
|
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
5
5
|
if (isUndefined(document) || isUndefined(document.cookie))
|
package/dist/esm/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { window } from "./globals";
|
|
1
|
+
import { window } from "./globals.js";
|
|
2
2
|
const isNode = (obj) => {
|
|
3
3
|
return (typeof Node === "object" ? obj instanceof window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string") || false;
|
|
4
4
|
};
|
package/dist/esm/types.js
CHANGED
package/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.185",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"default": "./dist/cjs/index.js",
|
|
10
|
+
"default": "./dist/esm/index.js",
|
|
12
11
|
"import": "./dist/esm/index.js",
|
|
13
12
|
"require": "./dist/cjs/index.js"
|
|
14
13
|
}
|
|
@@ -22,10 +21,10 @@
|
|
|
22
21
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
23
22
|
"build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
24
23
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
25
|
-
"build": "npm run build:cjs; npm run build:esm",
|
|
26
|
-
"prepublish": "
|
|
24
|
+
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
25
|
+
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
27
26
|
},
|
|
28
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ccab034f188b6a1f55f741c0b29a9d3b0c9bee6f",
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@babel/core": "^7.12.0"
|
|
31
30
|
}
|