@symbo.ls/utils 3.2.3 → 3.14.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/LICENSE +25 -12
- package/README.md +106 -0
- package/array.js +162 -0
- package/cache.js +7 -0
- package/cdn.js +83 -0
- package/component.js +25 -0
- package/cookie.js +71 -0
- package/{src/detectHeight.js → detectHeight.js} +3 -3
- package/dist/cjs/array.js +168 -0
- package/dist/cjs/browser.js +0 -2
- package/dist/cjs/cache.js +26 -0
- package/dist/cjs/cdn.js +85 -0
- package/dist/cjs/component.js +45 -0
- package/dist/cjs/cookie.js +75 -0
- package/dist/cjs/date.js +1 -3
- package/dist/cjs/detectHeight.js +4 -6
- package/dist/cjs/element.js +136 -0
- package/dist/cjs/env.js +43 -0
- package/dist/cjs/events.js +39 -0
- package/dist/cjs/extends.js +434 -0
- package/dist/cjs/fibonacci.js +1 -3
- package/dist/cjs/files.js +1 -3
- package/dist/cjs/function.js +114 -0
- package/dist/cjs/globals.js +30 -0
- package/dist/cjs/if.js +48 -0
- package/dist/cjs/index.js +38 -425
- package/dist/cjs/key.js +38 -0
- package/dist/cjs/keys.js +201 -0
- package/dist/cjs/load.js +5 -7
- package/dist/cjs/log.js +34 -0
- package/dist/cjs/metadata.js +310 -0
- package/dist/cjs/methods.js +599 -0
- package/dist/cjs/node.js +35 -0
- package/dist/cjs/object.js +634 -0
- package/dist/cjs/projectKeys.js +35 -0
- package/dist/cjs/props.js +282 -0
- package/dist/cjs/scaling.js +5 -169
- package/dist/cjs/scope.js +44 -0
- package/dist/cjs/sharedLibraries.js +146 -0
- package/dist/cjs/state.js +173 -0
- package/dist/cjs/string-extra.js +72 -0
- package/dist/cjs/string.js +183 -0
- package/dist/cjs/style.js +1 -3
- package/dist/cjs/tags.js +220 -0
- package/dist/cjs/triggerEvent.js +112 -0
- package/dist/cjs/types.js +74 -0
- package/dist/cjs/update.js +42 -0
- package/dist/esm/array.js +148 -0
- package/dist/esm/browser.js +14 -0
- package/dist/esm/cache.js +6 -0
- package/dist/esm/cdn.js +65 -0
- package/dist/esm/component.js +25 -0
- package/dist/esm/cookie.js +55 -0
- package/dist/esm/date.js +11 -0
- package/dist/esm/detectHeight.js +42 -0
- package/dist/esm/element.js +116 -0
- package/dist/esm/env.js +23 -0
- package/dist/esm/events.js +19 -0
- package/dist/esm/extends.js +414 -0
- package/dist/esm/fibonacci.js +10 -0
- package/dist/esm/files.js +4 -0
- package/dist/esm/function.js +94 -0
- package/dist/esm/globals.js +10 -0
- package/dist/esm/if.js +28 -0
- package/dist/esm/index.js +37 -0
- package/dist/esm/key.js +18 -0
- package/dist/esm/keys.js +181 -0
- package/dist/esm/load.js +151 -0
- package/dist/esm/log.js +14 -0
- package/dist/esm/metadata.js +290 -0
- package/dist/esm/methods.js +569 -0
- package/dist/esm/node.js +15 -0
- package/dist/esm/object.js +621 -0
- package/dist/esm/projectKeys.js +16 -0
- package/dist/esm/props.js +262 -0
- package/dist/esm/scaling.js +15 -0
- package/dist/esm/scope.js +24 -0
- package/dist/esm/sharedLibraries.js +126 -0
- package/dist/esm/state.js +163 -0
- package/dist/esm/string-extra.js +52 -0
- package/dist/esm/string.js +163 -0
- package/dist/esm/style.js +20 -0
- package/dist/esm/tags.js +200 -0
- package/dist/esm/triggerEvent.js +92 -0
- package/dist/esm/types.js +54 -0
- package/dist/esm/update.js +22 -0
- package/dist/iife/index.js +5818 -0
- package/element.js +148 -0
- package/env.js +15 -0
- package/events.js +19 -0
- package/extends.js +519 -0
- package/function.js +145 -0
- package/globals.js +8 -0
- package/if.js +30 -0
- package/index.js +41 -0
- package/key.js +20 -0
- package/keys.js +176 -0
- package/log.js +12 -0
- package/metadata.js +392 -0
- package/methods.js +636 -0
- package/node.js +37 -0
- package/object.js +803 -0
- package/package.json +38 -22
- package/projectKeys.js +30 -0
- package/props.js +327 -0
- package/{src/scaling.js → scaling.js} +1 -1
- package/scope.js +32 -0
- package/sharedLibraries.js +184 -0
- package/state.js +203 -0
- package/{src/index.js → string-extra.js} +11 -17
- package/string.js +206 -0
- package/tags.js +176 -0
- package/triggerEvent.js +102 -0
- package/types.js +55 -0
- package/update.js +27 -0
- package/dist/cjs/package.json +0 -4
- /package/{src/browser.js → browser.js} +0 -0
- /package/{src/date.js → date.js} +0 -0
- /package/{src/fibonacci.js → fibonacci.js} +0 -0
- /package/{src/files.js → files.js} +0 -0
- /package/{src/load.js → load.js} +0 -0
- /package/{src/style.js → style.js} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
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 array_exports = {};
|
|
20
|
+
__export(array_exports, {
|
|
21
|
+
addItemAfterEveryElement: () => addItemAfterEveryElement,
|
|
22
|
+
addProtoToArray: () => addProtoToArray,
|
|
23
|
+
arrayContainsOtherArray: () => arrayContainsOtherArray,
|
|
24
|
+
arraysEqual: () => arraysEqual,
|
|
25
|
+
checkIfStringIsInArray: () => checkIfStringIsInArray,
|
|
26
|
+
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
27
|
+
cutArrayBeforeValue: () => cutArrayBeforeValue,
|
|
28
|
+
filterArrays: () => filterArrays,
|
|
29
|
+
filterArraysFast: () => filterArraysFast,
|
|
30
|
+
getFrequencyInArray: () => getFrequencyInArray,
|
|
31
|
+
joinArrays: () => joinArrays,
|
|
32
|
+
removeDuplicatesInArray: () => removeDuplicatesInArray,
|
|
33
|
+
removeFromArray: () => removeFromArray,
|
|
34
|
+
removeValueFromArray: () => removeValueFromArray,
|
|
35
|
+
removeValueFromArrayAll: () => removeValueFromArrayAll,
|
|
36
|
+
reorderArrayByValues: () => reorderArrayByValues,
|
|
37
|
+
swapItemsInArray: () => swapItemsInArray,
|
|
38
|
+
unstackArrayOfObjects: () => unstackArrayOfObjects
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(array_exports);
|
|
41
|
+
var import_object = require("./object.js");
|
|
42
|
+
var import_types = require("./types.js");
|
|
43
|
+
const arrayContainsOtherArray = (arr1, arr2) => {
|
|
44
|
+
return arr2.every((val) => arr1.includes(val));
|
|
45
|
+
};
|
|
46
|
+
const getFrequencyInArray = (arr, value) => {
|
|
47
|
+
let count = 0;
|
|
48
|
+
for (let i = 0; i < arr.length; i++) {
|
|
49
|
+
if (arr[i] === value) count++;
|
|
50
|
+
}
|
|
51
|
+
return count;
|
|
52
|
+
};
|
|
53
|
+
const removeFromArray = (arr, index) => {
|
|
54
|
+
if ((0, import_types.isString)(index)) index = parseInt(index);
|
|
55
|
+
if ((0, import_types.isNumber)(index)) {
|
|
56
|
+
if (index < 0 || index >= arr.length || isNaN(index)) {
|
|
57
|
+
throw new Error("Invalid index");
|
|
58
|
+
}
|
|
59
|
+
arr.splice(index, 1);
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error("Invalid index");
|
|
62
|
+
}
|
|
63
|
+
return arr;
|
|
64
|
+
};
|
|
65
|
+
const swapItemsInArray = (arr, i, j) => {
|
|
66
|
+
if (i < 0 || j < 0 || i >= arr.length || j >= arr.length) return;
|
|
67
|
+
[arr[i], arr[j]] = [arr[j], arr[i]];
|
|
68
|
+
};
|
|
69
|
+
const joinArrays = (...arrays) => {
|
|
70
|
+
return [].concat(...arrays);
|
|
71
|
+
};
|
|
72
|
+
const unstackArrayOfObjects = (arr, exclude = []) => {
|
|
73
|
+
return arr.reduce(
|
|
74
|
+
(a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, { exclude }), exclude),
|
|
75
|
+
{}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
const cutArrayBeforeValue = (arr, value) => {
|
|
79
|
+
const index = arr.indexOf(value);
|
|
80
|
+
if (index !== -1) {
|
|
81
|
+
return arr.slice(0, index);
|
|
82
|
+
}
|
|
83
|
+
return arr;
|
|
84
|
+
};
|
|
85
|
+
const cutArrayAfterValue = (arr, value) => {
|
|
86
|
+
if (!(0, import_types.isArray)(arr)) return;
|
|
87
|
+
const index = arr.indexOf(value);
|
|
88
|
+
if (index !== -1) {
|
|
89
|
+
return arr.slice(index + 1);
|
|
90
|
+
}
|
|
91
|
+
return arr;
|
|
92
|
+
};
|
|
93
|
+
const removeValueFromArray = (arr, value) => {
|
|
94
|
+
const index = arr.indexOf(value);
|
|
95
|
+
if (index > -1) {
|
|
96
|
+
const newArray = [...arr];
|
|
97
|
+
newArray.splice(index, 1);
|
|
98
|
+
return newArray;
|
|
99
|
+
}
|
|
100
|
+
return arr;
|
|
101
|
+
};
|
|
102
|
+
const removeValueFromArrayAll = (arr, value) => {
|
|
103
|
+
return arr.filter((item) => item !== value);
|
|
104
|
+
};
|
|
105
|
+
const addItemAfterEveryElement = (array, item) => {
|
|
106
|
+
const result = [];
|
|
107
|
+
for (let i = 0; i < array.length; i++) {
|
|
108
|
+
result.push(array[i]);
|
|
109
|
+
if (i < array.length - 1) {
|
|
110
|
+
result.push(item);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
const reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
|
|
116
|
+
const newArray = [...array];
|
|
117
|
+
const indexToMove = newArray.indexOf(valueToMove);
|
|
118
|
+
const indexToInsertBefore = newArray.indexOf(insertBeforeValue);
|
|
119
|
+
if (indexToMove !== -1 && indexToInsertBefore !== -1) {
|
|
120
|
+
const removedItem = newArray.splice(indexToMove, 1)[0];
|
|
121
|
+
const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1;
|
|
122
|
+
newArray.splice(insertIndex, 0, removedItem);
|
|
123
|
+
}
|
|
124
|
+
return newArray;
|
|
125
|
+
};
|
|
126
|
+
const arraysEqual = (arr1, arr2) => {
|
|
127
|
+
if (arr1.length !== arr2.length) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
131
|
+
if (arr1[i] !== arr2[i]) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
const filterArrays = (sourceArr, excludeArr) => {
|
|
138
|
+
return sourceArr.filter((item) => !excludeArr.includes(item));
|
|
139
|
+
};
|
|
140
|
+
const filterArraysFast = (sourceArr, excludeArr) => {
|
|
141
|
+
const excludeSet = new Set(excludeArr);
|
|
142
|
+
return sourceArr.filter((item) => !excludeSet.has(item));
|
|
143
|
+
};
|
|
144
|
+
const checkIfStringIsInArray = (string, arr) => {
|
|
145
|
+
if (!string) return 0;
|
|
146
|
+
let count = 0;
|
|
147
|
+
for (let i = 0; i < arr.length; i++) {
|
|
148
|
+
if (string.includes(arr[i])) count++;
|
|
149
|
+
}
|
|
150
|
+
return count;
|
|
151
|
+
};
|
|
152
|
+
const removeDuplicatesInArray = (arr) => {
|
|
153
|
+
if (!(0, import_types.isArray)(arr)) return arr;
|
|
154
|
+
return [...new Set(arr)];
|
|
155
|
+
};
|
|
156
|
+
const addProtoToArray = (state, proto) => {
|
|
157
|
+
for (const key in proto) {
|
|
158
|
+
Object.defineProperty(state, key, {
|
|
159
|
+
value: proto[key],
|
|
160
|
+
enumerable: false,
|
|
161
|
+
// Set this to true if you want the method to appear in for...in loops
|
|
162
|
+
configurable: true,
|
|
163
|
+
// Set this to true if you want to allow redefining/removing the property later
|
|
164
|
+
writable: true
|
|
165
|
+
// Set this to true if you want to allow changing the function later
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
package/dist/cjs/browser.js
CHANGED
|
@@ -16,8 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/browser.js
|
|
21
19
|
var browser_exports = {};
|
|
22
20
|
__export(browser_exports, {
|
|
23
21
|
toggleFullscreen: () => toggleFullscreen
|
|
@@ -0,0 +1,26 @@
|
|
|
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 cache_exports = {};
|
|
20
|
+
__export(cache_exports, {
|
|
21
|
+
OPTIONS: () => OPTIONS,
|
|
22
|
+
cache: () => cache
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cache_exports);
|
|
25
|
+
const cache = {};
|
|
26
|
+
const OPTIONS = {};
|
package/dist/cjs/cdn.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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 cdn_exports = {};
|
|
20
|
+
__export(cdn_exports, {
|
|
21
|
+
CDN_PROVIDERS: () => CDN_PROVIDERS,
|
|
22
|
+
PACKAGE_MANAGER_TO_CDN: () => PACKAGE_MANAGER_TO_CDN,
|
|
23
|
+
getCDNUrl: () => getCDNUrl,
|
|
24
|
+
getCdnProviderFromConfig: () => getCdnProviderFromConfig,
|
|
25
|
+
getImportMapScript: () => getImportMapScript
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(cdn_exports);
|
|
28
|
+
function onlyDotsAndNumbers(str) {
|
|
29
|
+
return /^[0-9.]+$/.test(str) && str !== "";
|
|
30
|
+
}
|
|
31
|
+
const CDN_PROVIDERS = {
|
|
32
|
+
skypack: {
|
|
33
|
+
url: "https://cdn.skypack.dev",
|
|
34
|
+
formatUrl: (pkg, version) => `${CDN_PROVIDERS.skypack.url}/${pkg}${version !== "latest" ? `@${version}` : ""}`
|
|
35
|
+
},
|
|
36
|
+
esmsh: {
|
|
37
|
+
url: "https://esm.sh",
|
|
38
|
+
formatUrl: (pkg, version) => `${CDN_PROVIDERS.esmsh.url}/${pkg}${version !== "latest" ? `@${version}` : ""}`
|
|
39
|
+
},
|
|
40
|
+
unpkg: {
|
|
41
|
+
url: "https://unpkg.com",
|
|
42
|
+
formatUrl: (pkg, version) => `${CDN_PROVIDERS.unpkg.url}/${pkg}${version !== "latest" ? `@${version}` : ""}?module`
|
|
43
|
+
},
|
|
44
|
+
jsdelivr: {
|
|
45
|
+
url: "https://cdn.jsdelivr.net/npm",
|
|
46
|
+
formatUrl: (pkg, version) => `${CDN_PROVIDERS.jsdelivr.url}/${pkg}${version !== "latest" ? `@${version}` : ""}/+esm`
|
|
47
|
+
},
|
|
48
|
+
symbols: {
|
|
49
|
+
url: "https://pkg.symbo.ls",
|
|
50
|
+
formatUrl: (pkg, version) => {
|
|
51
|
+
if (pkg.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
|
|
52
|
+
return `${CDN_PROVIDERS.symbols.url}/${pkg}`;
|
|
53
|
+
}
|
|
54
|
+
return `${CDN_PROVIDERS.symbols.url}/${pkg}/${version}.js`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const PACKAGE_MANAGER_TO_CDN = {
|
|
59
|
+
"esm.sh": "esmsh",
|
|
60
|
+
"unpkg": "unpkg",
|
|
61
|
+
"skypack": "skypack",
|
|
62
|
+
"jsdelivr": "jsdelivr",
|
|
63
|
+
"pkg.symbo.ls": "symbols"
|
|
64
|
+
};
|
|
65
|
+
const getCdnProviderFromConfig = (symbolsConfig = {}) => {
|
|
66
|
+
const { packageManager } = symbolsConfig;
|
|
67
|
+
return PACKAGE_MANAGER_TO_CDN[packageManager] || null;
|
|
68
|
+
};
|
|
69
|
+
const getCDNUrl = (packageName, version = "latest", provider = "esmsh") => {
|
|
70
|
+
const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh;
|
|
71
|
+
return cdnConfig.formatUrl(packageName, version);
|
|
72
|
+
};
|
|
73
|
+
const getImportMapScript = (data, defaultProvider = "skypack") => {
|
|
74
|
+
const dependencies = data.dependencies || {};
|
|
75
|
+
const keys = Object.keys(dependencies);
|
|
76
|
+
if (!keys.length) return "";
|
|
77
|
+
const imports = {};
|
|
78
|
+
for (const pkgName of keys) {
|
|
79
|
+
const version = dependencies[pkgName] || "latest";
|
|
80
|
+
imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider);
|
|
81
|
+
}
|
|
82
|
+
return `<script type="importmap">{
|
|
83
|
+
"imports": ${JSON.stringify(imports, null, 2)}
|
|
84
|
+
}<\/script>`;
|
|
85
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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 component_exports = {};
|
|
20
|
+
__export(component_exports, {
|
|
21
|
+
getCapitalCaseKeys: () => getCapitalCaseKeys,
|
|
22
|
+
getSpreadChildren: () => getSpreadChildren,
|
|
23
|
+
isContextComponent: () => isContextComponent,
|
|
24
|
+
matchesComponentNaming: () => matchesComponentNaming
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(component_exports);
|
|
27
|
+
var import_extends = require("./extends.js");
|
|
28
|
+
var import_types = require("./types.js");
|
|
29
|
+
const matchesComponentNaming = (key) => {
|
|
30
|
+
if (!(0, import_types.isString)(key) || !key.length) return false;
|
|
31
|
+
const code = key.charCodeAt(0);
|
|
32
|
+
return code >= 65 && code <= 90;
|
|
33
|
+
};
|
|
34
|
+
function getCapitalCaseKeys(obj) {
|
|
35
|
+
return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
|
|
36
|
+
}
|
|
37
|
+
function getSpreadChildren(obj) {
|
|
38
|
+
return Object.keys(obj).filter((key) => /^\d+$/.test(key));
|
|
39
|
+
}
|
|
40
|
+
function isContextComponent(element, parent, passedKey) {
|
|
41
|
+
const { context } = parent || {};
|
|
42
|
+
const [extendsKey] = (0, import_extends.createExtendsFromKeys)(passedKey);
|
|
43
|
+
const key = passedKey || extendsKey;
|
|
44
|
+
return context?.components?.[key] || context?.pages?.[key];
|
|
45
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
getLocalStorage: () => getLocalStorage,
|
|
23
|
+
isMobile: () => isMobile,
|
|
24
|
+
removeCookie: () => removeCookie,
|
|
25
|
+
setCookie: () => setCookie,
|
|
26
|
+
setLocalStorage: () => setLocalStorage
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
29
|
+
var import_types = require("./types.js");
|
|
30
|
+
var import_globals = require("./globals.js");
|
|
31
|
+
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
32
|
+
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
33
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
34
|
+
const d = /* @__PURE__ */ new Date();
|
|
35
|
+
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
36
|
+
const expires = `expires=${d.toUTCString()}`;
|
|
37
|
+
import_globals.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
38
|
+
};
|
|
39
|
+
const getCookie = (cname) => {
|
|
40
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
41
|
+
const name = `${cname}=`;
|
|
42
|
+
const decodedCookie = decodeURIComponent(import_globals.document.cookie);
|
|
43
|
+
const ca = decodedCookie.split(";");
|
|
44
|
+
for (let i = 0; i < ca.length; i++) {
|
|
45
|
+
let c = ca[i];
|
|
46
|
+
while (c.charAt(0) === " ") c = c.substring(1);
|
|
47
|
+
if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
};
|
|
51
|
+
const removeCookie = (cname) => {
|
|
52
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
53
|
+
import_globals.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
54
|
+
};
|
|
55
|
+
function getLocalStorage(key) {
|
|
56
|
+
if (!window.localStorage) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
const item = window.localStorage.getItem(key);
|
|
60
|
+
if (item === null) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(item);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function setLocalStorage(key, data) {
|
|
70
|
+
if (!window.localStorage || data === void 0 || data === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const value = typeof data === "object" ? JSON.stringify(data) : data;
|
|
74
|
+
window.localStorage.setItem(key, value);
|
|
75
|
+
}
|
package/dist/cjs/date.js
CHANGED
|
@@ -16,14 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/date.js
|
|
21
19
|
var date_exports = {};
|
|
22
20
|
__export(date_exports, {
|
|
23
21
|
formatDate: () => formatDate
|
|
24
22
|
});
|
|
25
23
|
module.exports = __toCommonJS(date_exports);
|
|
26
|
-
|
|
24
|
+
const formatDate = (timestamp) => {
|
|
27
25
|
if (!timestamp) return "";
|
|
28
26
|
const d = new Date(timestamp);
|
|
29
27
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
package/dist/cjs/detectHeight.js
CHANGED
|
@@ -16,14 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/detectHeight.js
|
|
21
19
|
var detectHeight_exports = {};
|
|
22
20
|
__export(detectHeight_exports, {
|
|
23
21
|
detectHeightOnInit: () => detectHeightOnInit
|
|
24
22
|
});
|
|
25
23
|
module.exports = __toCommonJS(detectHeight_exports);
|
|
26
|
-
|
|
24
|
+
const detectHeightOnInit = (element, state) => {
|
|
27
25
|
const heightTimeout = setTimeout(() => {
|
|
28
26
|
const { props } = element;
|
|
29
27
|
if (!state.clientHeight) {
|
|
@@ -36,14 +34,14 @@ var detectHeightOnInit = (element, state) => {
|
|
|
36
34
|
}
|
|
37
35
|
if (state.active) {
|
|
38
36
|
if (props.height === "auto") return;
|
|
39
|
-
element.
|
|
37
|
+
element.update(
|
|
40
38
|
{
|
|
41
39
|
height: state.clientHeight
|
|
42
40
|
},
|
|
43
41
|
{ preventBeforeUpdateListener: true, preventChildrenUpdate: true }
|
|
44
42
|
);
|
|
45
43
|
const setAutoTimeout = setTimeout(() => {
|
|
46
|
-
element.
|
|
44
|
+
element.update(
|
|
47
45
|
{
|
|
48
46
|
height: "auto"
|
|
49
47
|
},
|
|
@@ -52,7 +50,7 @@ var detectHeightOnInit = (element, state) => {
|
|
|
52
50
|
clearTimeout(setAutoTimeout);
|
|
53
51
|
}, 450);
|
|
54
52
|
} else {
|
|
55
|
-
element.
|
|
53
|
+
element.update(
|
|
56
54
|
{
|
|
57
55
|
height: "0"
|
|
58
56
|
},
|
|
@@ -0,0 +1,136 @@
|
|
|
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 element_exports = {};
|
|
20
|
+
__export(element_exports, {
|
|
21
|
+
addCaching: () => addCaching,
|
|
22
|
+
addContext: () => addContext,
|
|
23
|
+
addRef: () => addRef,
|
|
24
|
+
createBasedOnType: () => createBasedOnType,
|
|
25
|
+
createElement: () => createElement,
|
|
26
|
+
createParent: () => createParent,
|
|
27
|
+
createPath: () => createPath,
|
|
28
|
+
createRoot: () => createRoot,
|
|
29
|
+
returnValueAsText: () => returnValueAsText
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(element_exports);
|
|
32
|
+
var import_extends = require("./extends.js");
|
|
33
|
+
var import_key = require("./key.js");
|
|
34
|
+
var import_node = require("./node.js");
|
|
35
|
+
var import_props = require("./props.js");
|
|
36
|
+
var import_tags = require("./tags.js");
|
|
37
|
+
var import_types = require("./types.js");
|
|
38
|
+
const ENV = process.env.NODE_ENV;
|
|
39
|
+
const returnValueAsText = (element, parent, key) => {
|
|
40
|
+
const childExtendsTag = parent.childExtends && parent.childExtends.tag;
|
|
41
|
+
const childPropsTag = parent.childProps && parent.childProps.tag;
|
|
42
|
+
const isKeyValidHTMLTag = import_tags.HTML_TAGS.body.has(key) && key;
|
|
43
|
+
return {
|
|
44
|
+
text: element,
|
|
45
|
+
tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || "string"
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const createBasedOnType = (element, parent, key) => {
|
|
49
|
+
if (element === void 0) {
|
|
50
|
+
if (ENV === "test" || ENV === "development") {
|
|
51
|
+
console.warn(
|
|
52
|
+
key,
|
|
53
|
+
"element is undefined in",
|
|
54
|
+
parent?.__ref?.path
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
if (element === null) return;
|
|
60
|
+
if (element === true) return {};
|
|
61
|
+
if ((0, import_types.is)(element)("string", "number")) {
|
|
62
|
+
return returnValueAsText(element, parent, key);
|
|
63
|
+
}
|
|
64
|
+
if ((0, import_types.isFunction)(element)) {
|
|
65
|
+
return { props: element };
|
|
66
|
+
}
|
|
67
|
+
return element;
|
|
68
|
+
};
|
|
69
|
+
const addRef = (element, parent) => {
|
|
70
|
+
const ref = {};
|
|
71
|
+
ref.origin = element;
|
|
72
|
+
ref.parent = parent;
|
|
73
|
+
return ref;
|
|
74
|
+
};
|
|
75
|
+
const createParent = (element, parent, key, options, root) => {
|
|
76
|
+
if (!parent) return root;
|
|
77
|
+
if ((0, import_node.isNode)(parent)) {
|
|
78
|
+
const parentNodeWrapper = { key: ":root", node: parent };
|
|
79
|
+
root[`${key}_parent`] = parentNodeWrapper;
|
|
80
|
+
return parentNodeWrapper;
|
|
81
|
+
}
|
|
82
|
+
return parent;
|
|
83
|
+
};
|
|
84
|
+
const createRoot = (element, parent) => {
|
|
85
|
+
const { __ref: ref } = element;
|
|
86
|
+
const { __ref: parentRef } = parent;
|
|
87
|
+
const hasRoot = parent && parent.key === ":root";
|
|
88
|
+
if (!ref?.root) {
|
|
89
|
+
ref.root = hasRoot ? element : parentRef?.root;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const createPath = (element, parent, key) => {
|
|
93
|
+
let { __ref: parentRef } = parent;
|
|
94
|
+
if (!parentRef) parentRef = parent.ref = {};
|
|
95
|
+
if (!parentRef.path) parentRef.path = [];
|
|
96
|
+
return parentRef.path.concat(key);
|
|
97
|
+
};
|
|
98
|
+
const addContext = (element, parent, key, options, root) => {
|
|
99
|
+
const forcedOptionsContext = options.context && !root.context && !element.context;
|
|
100
|
+
if (forcedOptionsContext) root.context = options.context;
|
|
101
|
+
return options.context || parent.context || root.context || element.context;
|
|
102
|
+
};
|
|
103
|
+
const addCaching = (element, parent, key) => {
|
|
104
|
+
const ref = addRef(element, parent);
|
|
105
|
+
element.__ref = ref;
|
|
106
|
+
if (!ref.__defineCache) ref.__defineCache = {};
|
|
107
|
+
if (!ref.__exec) ref.__exec = {};
|
|
108
|
+
if (!ref.__execProps) ref.__execProps = {};
|
|
109
|
+
if (!ref.__class) ref.__class = {};
|
|
110
|
+
if (!ref.__classNames) ref.__classNames = {};
|
|
111
|
+
if (!ref.__attr) ref.__attr = {};
|
|
112
|
+
if (!ref.__changes) ref.__changes = [];
|
|
113
|
+
if (!ref.__children) ref.__children = [];
|
|
114
|
+
ref.__extends = (0, import_extends.createExtends)(element, parent, key);
|
|
115
|
+
ref.path = createPath(element, parent, key);
|
|
116
|
+
return ref;
|
|
117
|
+
};
|
|
118
|
+
const createElement = (passedProps, parentEl, passedKey, opts, root) => {
|
|
119
|
+
const hashed = passedProps?.__hash;
|
|
120
|
+
const element = hashed ? { extends: [passedProps] } : createBasedOnType(passedProps, parentEl, passedKey);
|
|
121
|
+
if (!element) return;
|
|
122
|
+
const parent = createParent(element, parentEl, passedKey, opts, root);
|
|
123
|
+
const key = (0, import_key.createKey)(element, parent, passedKey);
|
|
124
|
+
addCaching(element, parent, key);
|
|
125
|
+
const props = (0, import_props.createProps)(element, parent, key);
|
|
126
|
+
const context = addContext(element, parent, key, opts, root);
|
|
127
|
+
const on = element.on || {};
|
|
128
|
+
return {
|
|
129
|
+
...element,
|
|
130
|
+
key,
|
|
131
|
+
props,
|
|
132
|
+
parent,
|
|
133
|
+
context,
|
|
134
|
+
on
|
|
135
|
+
};
|
|
136
|
+
};
|
package/dist/cjs/env.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
ENV: () => ENV,
|
|
22
|
+
NODE_ENV: () => NODE_ENV,
|
|
23
|
+
getNev: () => getNev,
|
|
24
|
+
isDevelopment: () => isDevelopment,
|
|
25
|
+
isLocal: () => isLocal,
|
|
26
|
+
isNotProduction: () => isNotProduction,
|
|
27
|
+
isProduction: () => isProduction,
|
|
28
|
+
isStaging: () => isStaging,
|
|
29
|
+
isTest: () => isTest,
|
|
30
|
+
isTesting: () => isTesting
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(env_exports);
|
|
33
|
+
// @preserve-env
|
|
34
|
+
const NODE_ENV = process.env.NODE_ENV;
|
|
35
|
+
const ENV = NODE_ENV;
|
|
36
|
+
const isProduction = (env = NODE_ENV) => env === "production";
|
|
37
|
+
const isTest = (env = NODE_ENV) => env === "testing" || env === "test";
|
|
38
|
+
const isTesting = isTest;
|
|
39
|
+
const isStaging = (env = NODE_ENV) => env === "staging";
|
|
40
|
+
const isLocal = (env = NODE_ENV) => env === "local";
|
|
41
|
+
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev" || env === "local";
|
|
42
|
+
const getNev = (key, env = NODE_ENV) => env[key];
|
|
43
|
+
const isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
@@ -0,0 +1,39 @@
|
|
|
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 events_exports = {};
|
|
20
|
+
__export(events_exports, {
|
|
21
|
+
addEventFromProps: () => addEventFromProps
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(events_exports);
|
|
24
|
+
var import_string = require("./string.js");
|
|
25
|
+
var import_types = require("./types.js");
|
|
26
|
+
function addEventFromProps(key, obj) {
|
|
27
|
+
const { props, on } = obj;
|
|
28
|
+
const eventName = (0, import_string.lowercaseFirstLetter)(key.split("on")[1]);
|
|
29
|
+
const origEvent = on[eventName];
|
|
30
|
+
const funcFromProps = props[key];
|
|
31
|
+
if ((0, import_types.isFunction)(origEvent)) {
|
|
32
|
+
on[eventName] = (...args) => {
|
|
33
|
+
const originalEventRetunrs = origEvent(...args);
|
|
34
|
+
if (originalEventRetunrs !== false) {
|
|
35
|
+
if ((0, import_types.isFunction)(funcFromProps)) return funcFromProps(...args);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
} else on[eventName] = funcFromProps;
|
|
39
|
+
}
|