@symbo.ls/utils 3.14.0 → 3.14.2

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