@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.
Files changed (133) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/array.cjs +1 -0
  3. package/dist/cjs/assets.cjs +1 -0
  4. package/dist/cjs/browser.cjs +1 -0
  5. package/dist/cjs/cache.cjs +1 -0
  6. package/dist/cjs/cdn.cjs +3 -0
  7. package/dist/cjs/component.cjs +1 -0
  8. package/dist/cjs/cookie.cjs +1 -0
  9. package/dist/cjs/date.cjs +1 -0
  10. package/dist/cjs/detectHeight.cjs +1 -0
  11. package/dist/cjs/element.cjs +1 -0
  12. package/dist/cjs/env.cjs +2 -0
  13. package/dist/cjs/events.cjs +1 -0
  14. package/dist/cjs/extends.cjs +1 -0
  15. package/dist/cjs/fibonacci.cjs +1 -0
  16. package/dist/cjs/files.cjs +1 -0
  17. package/dist/cjs/function.cjs +1 -0
  18. package/dist/cjs/globals.cjs +1 -0
  19. package/dist/cjs/if.cjs +1 -0
  20. package/dist/cjs/index.cjs +1 -0
  21. package/dist/cjs/key.cjs +1 -0
  22. package/dist/cjs/keys.cjs +1 -0
  23. package/dist/cjs/load.cjs +1 -0
  24. package/dist/cjs/log.cjs +1 -0
  25. package/dist/cjs/metadata.cjs +2 -0
  26. package/dist/cjs/methods.cjs +10 -0
  27. package/dist/cjs/node.cjs +1 -0
  28. package/dist/cjs/object.cjs +12 -0
  29. package/dist/cjs/projectKeys.cjs +1 -0
  30. package/dist/cjs/props.cjs +1 -0
  31. package/dist/cjs/scaling.cjs +1 -0
  32. package/dist/cjs/scope.cjs +1 -0
  33. package/dist/cjs/sharedLibraries.cjs +1 -0
  34. package/dist/cjs/state.cjs +1 -0
  35. package/dist/cjs/string-extra.cjs +1 -0
  36. package/dist/cjs/string.cjs +3 -0
  37. package/dist/cjs/style.cjs +1 -0
  38. package/dist/cjs/tags.cjs +1 -0
  39. package/dist/cjs/triggerEvent.cjs +1 -0
  40. package/dist/cjs/types.cjs +1 -0
  41. package/dist/cjs/update.cjs +1 -0
  42. package/dist/esm/array.js +1 -0
  43. package/dist/esm/assets.js +1 -0
  44. package/dist/esm/browser.js +1 -0
  45. package/dist/esm/cache.js +1 -0
  46. package/dist/esm/cdn.js +3 -0
  47. package/dist/esm/component.js +1 -0
  48. package/dist/esm/cookie.js +1 -0
  49. package/dist/esm/date.js +1 -0
  50. package/dist/esm/detectHeight.js +1 -0
  51. package/dist/esm/element.js +1 -0
  52. package/dist/esm/env.js +2 -0
  53. package/dist/esm/events.js +1 -0
  54. package/dist/esm/extends.js +1 -0
  55. package/dist/esm/fibonacci.js +1 -0
  56. package/dist/esm/files.js +1 -0
  57. package/dist/esm/function.js +1 -0
  58. package/dist/esm/globals.js +1 -0
  59. package/dist/esm/if.js +1 -0
  60. package/dist/esm/index.js +1 -0
  61. package/dist/esm/key.js +1 -0
  62. package/dist/esm/keys.js +1 -0
  63. package/dist/esm/load.js +1 -0
  64. package/dist/esm/log.js +1 -0
  65. package/dist/esm/metadata.js +2 -0
  66. package/dist/esm/methods.js +10 -0
  67. package/dist/esm/node.js +1 -0
  68. package/dist/esm/object.js +12 -0
  69. package/dist/esm/projectKeys.js +1 -0
  70. package/dist/esm/props.js +1 -0
  71. package/dist/esm/scaling.js +1 -0
  72. package/dist/esm/scope.js +1 -0
  73. package/dist/esm/sharedLibraries.js +1 -0
  74. package/dist/esm/state.js +1 -0
  75. package/dist/esm/string-extra.js +1 -0
  76. package/dist/esm/string.js +3 -0
  77. package/dist/esm/style.js +1 -0
  78. package/dist/esm/tags.js +1 -0
  79. package/dist/esm/triggerEvent.js +1 -0
  80. package/dist/esm/types.js +1 -0
  81. package/dist/esm/update.js +1 -0
  82. package/package.json +35 -18
  83. package/array.js +0 -162
  84. package/assets.js +0 -117
  85. package/browser.js +0 -13
  86. package/cache.js +0 -7
  87. package/cdn.js +0 -83
  88. package/component.js +0 -25
  89. package/cookie.js +0 -78
  90. package/date.js +0 -10
  91. package/detectHeight.js +0 -42
  92. package/dist/cjs/browser.js +0 -36
  93. package/dist/cjs/date.js +0 -33
  94. package/dist/cjs/detectHeight.js +0 -53
  95. package/dist/cjs/domqlv3hacks.js +0 -3845
  96. package/dist/cjs/fibonacci.js +0 -32
  97. package/dist/cjs/files.js +0 -26
  98. package/dist/cjs/index.js +0 -4100
  99. package/dist/cjs/load.js +0 -173
  100. package/dist/cjs/package.json +0 -4
  101. package/dist/cjs/scaling.js +0 -53
  102. package/dist/cjs/style.js +0 -42
  103. package/element.js +0 -148
  104. package/env.js +0 -15
  105. package/events.js +0 -19
  106. package/extends.js +0 -519
  107. package/fibonacci.js +0 -9
  108. package/files.js +0 -3
  109. package/function.js +0 -145
  110. package/globals.js +0 -8
  111. package/if.js +0 -30
  112. package/index.js +0 -42
  113. package/key.js +0 -20
  114. package/keys.js +0 -176
  115. package/load.js +0 -236
  116. package/log.js +0 -12
  117. package/metadata.js +0 -392
  118. package/methods.js +0 -684
  119. package/node.js +0 -37
  120. package/object.js +0 -837
  121. package/projectKeys.js +0 -30
  122. package/props.js +0 -327
  123. package/scaling.js +0 -15
  124. package/scope.js +0 -32
  125. package/sharedLibraries.js +0 -184
  126. package/state.js +0 -203
  127. package/string-extra.js +0 -69
  128. package/string.js +0 -206
  129. package/style.js +0 -23
  130. package/tags.js +0 -176
  131. package/triggerEvent.js +0 -102
  132. package/types.js +0 -55
  133. 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
- }
@@ -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
- };
@@ -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
- };