@symbo.ls/utils 3.14.1 → 3.14.3
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/CHANGELOG.md +7 -0
- package/dist/cjs/array.cjs +1 -0
- package/dist/cjs/assets.cjs +1 -0
- package/dist/cjs/browser.cjs +1 -0
- package/dist/cjs/cache.cjs +1 -0
- package/dist/cjs/cdn.cjs +3 -0
- package/dist/cjs/component.cjs +1 -0
- package/dist/cjs/cookie.cjs +1 -0
- package/dist/cjs/date.cjs +1 -0
- package/dist/cjs/detectHeight.cjs +1 -0
- package/dist/cjs/element.cjs +1 -0
- package/dist/cjs/env.cjs +2 -0
- package/dist/cjs/events.cjs +1 -0
- package/dist/cjs/extends.cjs +1 -0
- package/dist/cjs/fibonacci.cjs +1 -0
- package/dist/cjs/files.cjs +1 -0
- package/dist/cjs/function.cjs +1 -0
- package/dist/cjs/globals.cjs +1 -0
- package/dist/cjs/if.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/key.cjs +1 -0
- package/dist/cjs/keys.cjs +1 -0
- package/dist/cjs/load.cjs +1 -0
- package/dist/cjs/log.cjs +1 -0
- package/dist/cjs/metadata.cjs +2 -0
- package/dist/cjs/methods.cjs +10 -0
- package/dist/cjs/node.cjs +1 -0
- package/dist/cjs/object.cjs +12 -0
- package/dist/cjs/projectKeys.cjs +1 -0
- package/dist/cjs/props.cjs +1 -0
- package/dist/cjs/scaling.cjs +1 -0
- package/dist/cjs/scope.cjs +1 -0
- package/dist/cjs/sharedLibraries.cjs +1 -0
- package/dist/cjs/state.cjs +1 -0
- package/dist/cjs/string-extra.cjs +1 -0
- package/dist/cjs/string.cjs +3 -0
- package/dist/cjs/style.cjs +1 -0
- package/dist/cjs/tags.cjs +1 -0
- package/dist/cjs/triggerEvent.cjs +1 -0
- package/dist/cjs/types.cjs +1 -0
- package/dist/cjs/update.cjs +1 -0
- package/dist/esm/array.js +1 -0
- package/dist/esm/assets.js +1 -0
- package/dist/esm/browser.js +1 -0
- package/dist/esm/cache.js +1 -0
- package/dist/esm/cdn.js +3 -0
- package/dist/esm/component.js +1 -0
- package/dist/esm/cookie.js +1 -0
- package/dist/esm/date.js +1 -0
- package/dist/esm/detectHeight.js +1 -0
- package/dist/esm/element.js +1 -0
- package/dist/esm/env.js +2 -0
- package/dist/esm/events.js +1 -0
- package/dist/esm/extends.js +1 -0
- package/dist/esm/fibonacci.js +1 -0
- package/dist/esm/files.js +1 -0
- package/dist/esm/function.js +1 -0
- package/dist/esm/globals.js +1 -0
- package/dist/esm/if.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/key.js +1 -0
- package/dist/esm/keys.js +1 -0
- package/dist/esm/load.js +1 -0
- package/dist/esm/log.js +1 -0
- package/dist/esm/metadata.js +2 -0
- package/dist/esm/methods.js +10 -0
- package/dist/esm/node.js +1 -0
- package/dist/esm/object.js +12 -0
- package/dist/esm/projectKeys.js +1 -0
- package/dist/esm/props.js +1 -0
- package/dist/esm/scaling.js +1 -0
- package/dist/esm/scope.js +1 -0
- package/dist/esm/sharedLibraries.js +1 -0
- package/dist/esm/state.js +1 -0
- package/dist/esm/string-extra.js +1 -0
- package/dist/esm/string.js +3 -0
- package/dist/esm/style.js +1 -0
- package/dist/esm/tags.js +1 -0
- package/dist/esm/triggerEvent.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/update.js +1 -0
- package/package.json +35 -18
- package/array.js +0 -162
- package/assets.js +0 -117
- package/browser.js +0 -13
- package/cache.js +0 -7
- package/cdn.js +0 -83
- package/component.js +0 -25
- package/cookie.js +0 -78
- package/date.js +0 -10
- package/detectHeight.js +0 -42
- package/dist/cjs/browser.js +0 -36
- package/dist/cjs/date.js +0 -33
- package/dist/cjs/detectHeight.js +0 -53
- package/dist/cjs/domqlv3hacks.js +0 -3845
- package/dist/cjs/fibonacci.js +0 -32
- package/dist/cjs/files.js +0 -26
- package/dist/cjs/index.js +0 -4100
- package/dist/cjs/load.js +0 -173
- package/dist/cjs/package.json +0 -4
- package/dist/cjs/scaling.js +0 -53
- package/dist/cjs/style.js +0 -42
- package/element.js +0 -148
- package/env.js +0 -15
- package/events.js +0 -19
- package/extends.js +0 -519
- package/fibonacci.js +0 -9
- package/files.js +0 -3
- package/function.js +0 -145
- package/globals.js +0 -8
- package/if.js +0 -30
- package/index.js +0 -42
- package/key.js +0 -20
- package/keys.js +0 -176
- package/load.js +0 -236
- package/log.js +0 -12
- package/metadata.js +0 -392
- package/methods.js +0 -684
- package/node.js +0 -37
- package/object.js +0 -837
- package/projectKeys.js +0 -30
- package/props.js +0 -327
- package/scaling.js +0 -15
- package/scope.js +0 -32
- package/sharedLibraries.js +0 -184
- package/state.js +0 -203
- package/string-extra.js +0 -69
- package/string.js +0 -206
- package/style.js +0 -23
- package/tags.js +0 -176
- package/triggerEvent.js +0 -102
- package/types.js +0 -55
- package/update.js +0 -27
package/cookie.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isUndefined } from './types.js'
|
|
4
|
-
import { document } from './globals.js'
|
|
5
|
-
|
|
6
|
-
export const isMobile = (() =>
|
|
7
|
-
typeof navigator === 'undefined' ? false : /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
|
-
}
|
|
29
|
-
|
|
30
|
-
export const removeCookie = cname => {
|
|
31
|
-
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
32
|
-
document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Load item from the localStorage
|
|
36
|
-
*
|
|
37
|
-
* @param key -- string to identify the storage item
|
|
38
|
-
* @returns {*} -- parsed data or undefined
|
|
39
|
-
*/
|
|
40
|
-
export function getLocalStorage (key) {
|
|
41
|
-
// localStorage access throws in: Safari private mode (quota), sandboxed
|
|
42
|
-
// iframes without `allow-storage-access-by-user-activation`, Firefox with
|
|
43
|
-
// `dom.storage.enabled=false`. Wrap the access itself, not just the
|
|
44
|
-
// JSON.parse — the existing try only covered parse and let the read
|
|
45
|
-
// crash the host.
|
|
46
|
-
let item
|
|
47
|
-
try {
|
|
48
|
-
if (!window.localStorage) return undefined
|
|
49
|
-
item = window.localStorage.getItem(key)
|
|
50
|
-
} catch (e) {
|
|
51
|
-
return undefined
|
|
52
|
-
}
|
|
53
|
-
if (item === null) return undefined
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(item)
|
|
56
|
-
} catch (e) {
|
|
57
|
-
return undefined
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Save the data to window.localStorage
|
|
63
|
-
*
|
|
64
|
-
* @param key - local storage key to save the data under
|
|
65
|
-
* @param data - the data to save
|
|
66
|
-
*/
|
|
67
|
-
export function setLocalStorage (key, data) {
|
|
68
|
-
if (data === undefined || data === null) return
|
|
69
|
-
try {
|
|
70
|
-
if (!window.localStorage) return
|
|
71
|
-
const value = typeof data === 'object' ? JSON.stringify(data) : data
|
|
72
|
-
window.localStorage.setItem(key, value)
|
|
73
|
-
} catch (e) {
|
|
74
|
-
// QuotaExceededError (Safari private + over quota), SecurityError
|
|
75
|
-
// (sandboxed iframe / disabled storage). Silent fail — caller doesn't
|
|
76
|
-
// expect an exception out of a "save best-effort" helper.
|
|
77
|
-
}
|
|
78
|
-
}
|
package/date.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const formatDate = (timestamp) => {
|
|
4
|
-
if (!timestamp) return ''
|
|
5
|
-
const d = new Date(timestamp)
|
|
6
|
-
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d)
|
|
7
|
-
const mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d)
|
|
8
|
-
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d)
|
|
9
|
-
return `${da} ${mo}, ${ye}`
|
|
10
|
-
}
|
package/detectHeight.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const detectHeightOnInit = (element, state) => {
|
|
4
|
-
const heightTimeout = setTimeout(() => {
|
|
5
|
-
const { props } = element
|
|
6
|
-
if (!state.clientHeight) {
|
|
7
|
-
const {
|
|
8
|
-
node: { clientHeight }
|
|
9
|
-
} = element
|
|
10
|
-
if (clientHeight) {
|
|
11
|
-
state.clientHeight = clientHeight
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (state.active) {
|
|
16
|
-
if (props.height === 'auto') return
|
|
17
|
-
element.update(
|
|
18
|
-
{
|
|
19
|
-
height: state.clientHeight
|
|
20
|
-
},
|
|
21
|
-
{ preventBeforeUpdateListener: true, preventChildrenUpdate: true }
|
|
22
|
-
)
|
|
23
|
-
const setAutoTimeout = setTimeout(() => {
|
|
24
|
-
element.update(
|
|
25
|
-
{
|
|
26
|
-
height: 'auto'
|
|
27
|
-
},
|
|
28
|
-
{ preventBeforeUpdateListener: true, preventChildrenUpdate: true }
|
|
29
|
-
)
|
|
30
|
-
clearTimeout(setAutoTimeout)
|
|
31
|
-
}, 450)
|
|
32
|
-
} else {
|
|
33
|
-
element.update(
|
|
34
|
-
{
|
|
35
|
-
height: '0'
|
|
36
|
-
},
|
|
37
|
-
{ preventBeforeUpdateListener: true, preventChildrenUpdate: true }
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
clearTimeout(heightTimeout)
|
|
41
|
-
})
|
|
42
|
-
}
|
package/dist/cjs/browser.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
// src/browser.js
|
|
21
|
-
var browser_exports = {};
|
|
22
|
-
__export(browser_exports, {
|
|
23
|
-
toggleFullscreen: () => toggleFullscreen
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(browser_exports);
|
|
26
|
-
async function toggleFullscreen(opts) {
|
|
27
|
-
if (!document.fullscreenElement) {
|
|
28
|
-
try {
|
|
29
|
-
await (this.node || document).requestFullscreen();
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.warn(`Error attempting to enable fullscreen mode: ${err.message} (${err.name})`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
await document.exitFullscreen();
|
|
35
|
-
}
|
|
36
|
-
}
|
package/dist/cjs/date.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
// src/date.js
|
|
21
|
-
var date_exports = {};
|
|
22
|
-
__export(date_exports, {
|
|
23
|
-
formatDate: () => formatDate
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(date_exports);
|
|
26
|
-
var formatDate = (timestamp) => {
|
|
27
|
-
if (!timestamp) return "";
|
|
28
|
-
const d = new Date(timestamp);
|
|
29
|
-
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
30
|
-
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
31
|
-
const da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d);
|
|
32
|
-
return `${da} ${mo}, ${ye}`;
|
|
33
|
-
};
|
package/dist/cjs/detectHeight.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
// src/detectHeight.js
|
|
21
|
-
var detectHeight_exports = {};
|
|
22
|
-
__export(detectHeight_exports, {
|
|
23
|
-
detectHeightOnInit: () => detectHeightOnInit
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(detectHeight_exports);
|
|
26
|
-
var detectHeightOnInit = (element, state) => {
|
|
27
|
-
const heightTimeout = setTimeout(() => {
|
|
28
|
-
const { props } = element;
|
|
29
|
-
if (!state.clientHeight) {
|
|
30
|
-
const { node: { clientHeight } } = element;
|
|
31
|
-
if (clientHeight) {
|
|
32
|
-
state.clientHeight = clientHeight;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (state.active) {
|
|
36
|
-
if (props.height === "auto") return;
|
|
37
|
-
element.update({
|
|
38
|
-
props: { height: state.clientHeight }
|
|
39
|
-
}, { preventBeforeUpdateListener: true, preventChildrenUpdate: true });
|
|
40
|
-
const setAutoTimeout = setTimeout(() => {
|
|
41
|
-
element.update({
|
|
42
|
-
props: { height: "auto" }
|
|
43
|
-
}, { preventBeforeUpdateListener: true, preventChildrenUpdate: true });
|
|
44
|
-
clearTimeout(setAutoTimeout);
|
|
45
|
-
}, 450);
|
|
46
|
-
} else {
|
|
47
|
-
element.update({
|
|
48
|
-
props: { height: "0" }
|
|
49
|
-
}, { preventBeforeUpdateListener: true, preventChildrenUpdate: true });
|
|
50
|
-
}
|
|
51
|
-
clearTimeout(heightTimeout);
|
|
52
|
-
});
|
|
53
|
-
};
|