@symbo.ls/utils 3.14.0 → 3.14.1

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 (88) hide show
  1. package/README.md +2 -2
  2. package/assets.js +117 -0
  3. package/cookie.js +20 -13
  4. package/dist/cjs/browser.js +2 -0
  5. package/dist/cjs/date.js +3 -1
  6. package/dist/cjs/detectHeight.js +13 -22
  7. package/dist/cjs/domqlv3hacks.js +3845 -0
  8. package/dist/cjs/fibonacci.js +3 -1
  9. package/dist/cjs/files.js +3 -1
  10. package/dist/cjs/index.js +4084 -38
  11. package/dist/cjs/load.js +7 -5
  12. package/dist/cjs/package.json +4 -0
  13. package/dist/cjs/scaling.js +23 -5
  14. package/dist/cjs/style.js +3 -1
  15. package/index.js +1 -0
  16. package/methods.js +51 -3
  17. package/object.js +36 -2
  18. package/package.json +1 -1
  19. package/dist/cjs/array.js +0 -168
  20. package/dist/cjs/cache.js +0 -26
  21. package/dist/cjs/cdn.js +0 -85
  22. package/dist/cjs/component.js +0 -45
  23. package/dist/cjs/cookie.js +0 -75
  24. package/dist/cjs/element.js +0 -136
  25. package/dist/cjs/env.js +0 -43
  26. package/dist/cjs/events.js +0 -39
  27. package/dist/cjs/extends.js +0 -434
  28. package/dist/cjs/function.js +0 -114
  29. package/dist/cjs/globals.js +0 -30
  30. package/dist/cjs/if.js +0 -48
  31. package/dist/cjs/key.js +0 -38
  32. package/dist/cjs/keys.js +0 -201
  33. package/dist/cjs/log.js +0 -34
  34. package/dist/cjs/metadata.js +0 -310
  35. package/dist/cjs/methods.js +0 -599
  36. package/dist/cjs/node.js +0 -35
  37. package/dist/cjs/object.js +0 -634
  38. package/dist/cjs/projectKeys.js +0 -35
  39. package/dist/cjs/props.js +0 -282
  40. package/dist/cjs/scope.js +0 -44
  41. package/dist/cjs/sharedLibraries.js +0 -146
  42. package/dist/cjs/state.js +0 -173
  43. package/dist/cjs/string-extra.js +0 -72
  44. package/dist/cjs/string.js +0 -183
  45. package/dist/cjs/tags.js +0 -220
  46. package/dist/cjs/triggerEvent.js +0 -112
  47. package/dist/cjs/types.js +0 -74
  48. package/dist/cjs/update.js +0 -42
  49. package/dist/esm/array.js +0 -148
  50. package/dist/esm/browser.js +0 -14
  51. package/dist/esm/cache.js +0 -6
  52. package/dist/esm/cdn.js +0 -65
  53. package/dist/esm/component.js +0 -25
  54. package/dist/esm/cookie.js +0 -55
  55. package/dist/esm/date.js +0 -11
  56. package/dist/esm/detectHeight.js +0 -42
  57. package/dist/esm/element.js +0 -116
  58. package/dist/esm/env.js +0 -23
  59. package/dist/esm/events.js +0 -19
  60. package/dist/esm/extends.js +0 -414
  61. package/dist/esm/fibonacci.js +0 -10
  62. package/dist/esm/files.js +0 -4
  63. package/dist/esm/function.js +0 -94
  64. package/dist/esm/globals.js +0 -10
  65. package/dist/esm/if.js +0 -28
  66. package/dist/esm/index.js +0 -37
  67. package/dist/esm/key.js +0 -18
  68. package/dist/esm/keys.js +0 -181
  69. package/dist/esm/load.js +0 -151
  70. package/dist/esm/log.js +0 -14
  71. package/dist/esm/metadata.js +0 -290
  72. package/dist/esm/methods.js +0 -569
  73. package/dist/esm/node.js +0 -15
  74. package/dist/esm/object.js +0 -621
  75. package/dist/esm/projectKeys.js +0 -16
  76. package/dist/esm/props.js +0 -262
  77. package/dist/esm/scaling.js +0 -15
  78. package/dist/esm/scope.js +0 -24
  79. package/dist/esm/sharedLibraries.js +0 -126
  80. package/dist/esm/state.js +0 -163
  81. package/dist/esm/string-extra.js +0 -52
  82. package/dist/esm/string.js +0 -163
  83. package/dist/esm/style.js +0 -20
  84. package/dist/esm/tags.js +0 -200
  85. package/dist/esm/triggerEvent.js +0 -92
  86. package/dist/esm/types.js +0 -54
  87. package/dist/esm/update.js +0 -22
  88. package/dist/iife/index.js +0 -5818
@@ -1,72 +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 string_extra_exports = {};
20
- __export(string_extra_exports, {
21
- arrayzeValue: () => arrayzeValue,
22
- copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
23
- copyStringToClipboard: () => copyStringToClipboard,
24
- removeChars: () => removeChars,
25
- toCamelCase: () => toCamelCase,
26
- toDashCase: () => toDashCase,
27
- toDescriptionCase: () => toDescriptionCase,
28
- toTitleCase: () => toTitleCase
29
- });
30
- module.exports = __toCommonJS(string_extra_exports);
31
- var import_types = require("./types.js");
32
- const copyStringToClipboard = async (str) => {
33
- try {
34
- await navigator.clipboard.writeText(str);
35
- } catch (err) {
36
- console.warn("Failed to copy text: ", err);
37
- }
38
- };
39
- const copyJavaScriptToClipboard = async (jsCode) => {
40
- try {
41
- const blob = new Blob([jsCode], { type: "text/javascript" });
42
- const clipboardItem = new window.ClipboardItem({ "text/plain": blob });
43
- await navigator.clipboard.write([clipboardItem]);
44
- console.log("JavaScript code copied to clipboard as text/javascript");
45
- } catch (err) {
46
- console.error("Failed to copy JavaScript code: ", err);
47
- }
48
- };
49
- const removeChars = (str) => {
50
- return str.replace(/[^a-zA-Z0-9_]/g, "");
51
- };
52
- const toCamelCase = (str) => {
53
- if (typeof str !== "string") str = String(str || "");
54
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
55
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
56
- }).replace(/\s+/g, "");
57
- };
58
- const toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
59
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
60
- });
61
- const toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
62
- const toDescriptionCase = (str = "") => {
63
- if (typeof str !== "string") return;
64
- const result = str.replace(/([A-Z])/g, " $1");
65
- return result.charAt(0).toUpperCase() + result.slice(1);
66
- };
67
- const arrayzeValue = (val) => {
68
- if ((0, import_types.isArray)(val)) return val;
69
- if ((0, import_types.isString)(val)) return val.split(" ");
70
- if ((0, import_types.isObject)(val)) return Object.values(val);
71
- if ((0, import_types.isNumber)(val)) return [val];
72
- };
@@ -1,183 +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 string_exports = {};
20
- __export(string_exports, {
21
- customDecodeURIComponent: () => customDecodeURIComponent,
22
- customEncodeURIComponent: () => customEncodeURIComponent,
23
- decodeNewlines: () => decodeNewlines,
24
- encodeNewlines: () => encodeNewlines,
25
- findKeyPosition: () => findKeyPosition,
26
- lowercaseFirstLetter: () => lowercaseFirstLetter,
27
- replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
28
- replaceOctalEscapeSequences: () => replaceOctalEscapeSequences,
29
- stringIncludesAny: () => stringIncludesAny,
30
- trimStringFromSymbols: () => trimStringFromSymbols
31
- });
32
- module.exports = __toCommonJS(string_exports);
33
- const stringIncludesAny = (str, characters) => {
34
- for (const char of characters) {
35
- if (str.includes(char)) {
36
- return true;
37
- }
38
- }
39
- return false;
40
- };
41
- const trimStringFromSymbols = (str, characters) => {
42
- const pattern = new RegExp(`[${characters.join("\\")}]`, "g");
43
- return str.replace(pattern, "");
44
- };
45
- const brackRegex = {
46
- 2: /{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,
47
- 3: /{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g
48
- };
49
- const getNestedValue = (obj, path) => {
50
- return path.split(".").reduce((acc, part) => {
51
- return acc?.[part];
52
- }, obj);
53
- };
54
- function replaceLiteralsWithObjectFields(str, state, options = {}) {
55
- const { bracketsLength = 2 } = options;
56
- const bracketPattern = bracketsLength === 3 ? "{{{" : "{{";
57
- if (!str.includes(bracketPattern)) return str;
58
- const reg = brackRegex[bracketsLength];
59
- const obj = state || this.state || {};
60
- const element = this;
61
- return str.replace(reg, (_, parentPath, variable, filter) => {
62
- const key = variable.trim();
63
- if (filter) {
64
- const ctx = element?.context;
65
- const filterFn = ctx?.functions?.[filter] || ctx?.utils?.[filter] || ctx?.methods?.[filter] || ctx?.snippets?.[filter] || element?.[filter];
66
- if (filterFn && typeof filterFn === "function") {
67
- try {
68
- return String(filterFn.call(element, key) ?? "");
69
- } catch (e) {
70
- return "";
71
- }
72
- }
73
- return "";
74
- }
75
- if (parentPath) {
76
- const parentLevels = (parentPath.match(/\.\.\//g) || []).length;
77
- let parentState = obj;
78
- for (let i = 0; i < parentLevels; i++) {
79
- if (!parentState || !parentState.parent) return "";
80
- parentState = parentState.parent;
81
- }
82
- if (key === "parent") {
83
- return String(parentState.value ?? "");
84
- }
85
- const value = getNestedValue(parentState, key);
86
- return String(value ?? "");
87
- } else {
88
- const value = getNestedValue(obj, key);
89
- if (value != null) return String(value);
90
- const poly = element?.context?.polyglot;
91
- if (poly?.translations) {
92
- const lang = obj?.root?.lang || obj?.lang || element?.context?.state?.lang || poly.defaultLang || "en";
93
- const langT = poly.translations[lang];
94
- if (langT) {
95
- const tValue = getNestedValue(langT, key);
96
- if (tValue != null && typeof tValue !== "object") return String(tValue);
97
- for (const section in langT) {
98
- const sectionData = langT[section];
99
- if (sectionData && typeof sectionData === "object" && !Array.isArray(sectionData)) {
100
- const nested = getNestedValue(sectionData, key);
101
- if (nested != null && typeof nested !== "object") return String(nested);
102
- }
103
- }
104
- }
105
- const topValue = getNestedValue(poly.translations, key);
106
- if (topValue != null && typeof topValue !== "object") return String(topValue);
107
- }
108
- return "";
109
- }
110
- });
111
- }
112
- const lowercaseFirstLetter = (inputString) => {
113
- return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
114
- };
115
- const findKeyPosition = (str, key) => {
116
- const lines = str.split("\n");
117
- let startLineNumber = -1;
118
- let endLineNumber = -1;
119
- let startColumn = -1;
120
- let endColumn = -1;
121
- const keyPattern = new RegExp(`\\b${key}\\b\\s*:\\s*`);
122
- let braceCount = 0;
123
- let foundKey = false;
124
- for (let i = 0; i < lines.length; i++) {
125
- if (keyPattern.test(lines[i]) && !foundKey) {
126
- foundKey = true;
127
- startLineNumber = i + 1;
128
- startColumn = lines[i].indexOf(key) + 1;
129
- if (lines[i].includes("{}")) {
130
- endLineNumber = startLineNumber;
131
- endColumn = lines[i].indexOf("{}") + 3;
132
- break;
133
- }
134
- const line = lines[i].slice(startColumn + key.length);
135
- if (line.includes("{") || line.includes("[")) {
136
- braceCount = 1;
137
- } else {
138
- endLineNumber = i + 1;
139
- endColumn = lines[i].length + 1;
140
- break;
141
- }
142
- } else if (foundKey) {
143
- braceCount += (lines[i].match(/{/g) || []).length;
144
- braceCount += (lines[i].match(/\[/g) || []).length;
145
- braceCount -= (lines[i].match(/}/g) || []).length;
146
- braceCount -= (lines[i].match(/]/g) || []).length;
147
- if (braceCount === 0) {
148
- endLineNumber = i + 1;
149
- endColumn = lines[i].lastIndexOf("}") !== -1 ? lines[i].lastIndexOf("}") + 2 : lines[i].length + 1;
150
- break;
151
- }
152
- }
153
- }
154
- return {
155
- startColumn,
156
- endColumn,
157
- startLineNumber,
158
- endLineNumber
159
- };
160
- };
161
- const RE_OCTAL = /\\([0-7]{1,3})/g;
162
- const replaceOctalEscapeSequences = (str) => {
163
- return str.replace(RE_OCTAL, (_, p1) => String.fromCharCode(parseInt(p1, 8)));
164
- };
165
- const encodeNewlines = (str) => {
166
- return str.replace(/\n/g, "/////n").replace(/`/g, "/////tilde").replace(/\$/g, "/////dlrsgn");
167
- };
168
- const decodeNewlines = (encodedStr) => {
169
- return encodedStr.replace(/\/\/\/\/\/n/g, "\n").replace(/\/\/\/\/\/tilde/g, "`").replace(/\/\/\/\/\/dlrsgn/g, "$");
170
- };
171
- const RE_NON_ALNUM = /[^a-zA-Z0-9\s]/g;
172
- const customEncodeURIComponent = (str) => {
173
- return str.replace(
174
- RE_NON_ALNUM,
175
- (char) => "%" + char.charCodeAt(0).toString(16).toUpperCase()
176
- );
177
- };
178
- const customDecodeURIComponent = (encodedStr) => {
179
- return encodedStr.replace(
180
- /%[0-9A-Fa-f]{2}/g,
181
- (match) => String.fromCharCode(parseInt(match.slice(1), 16))
182
- );
183
- };
package/dist/cjs/tags.js DELETED
@@ -1,220 +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 tags_exports = {};
20
- __export(tags_exports, {
21
- HTML_TAGS: () => HTML_TAGS,
22
- SVG_TAGS: () => SVG_TAGS,
23
- isValidHtmlTag: () => isValidHtmlTag
24
- });
25
- module.exports = __toCommonJS(tags_exports);
26
- const HTML_TAGS = {
27
- root: ["body", "html"],
28
- head: ["title", "base", "meta", "style", "noscript", "script"],
29
- body: /* @__PURE__ */ new Set([
30
- "string",
31
- "style",
32
- "fragment",
33
- "a",
34
- "abbr",
35
- "acronym",
36
- "address",
37
- "applet",
38
- "area",
39
- "article",
40
- "aside",
41
- "audio",
42
- "b",
43
- "basefont",
44
- "bdi",
45
- "bdo",
46
- "big",
47
- "blockquote",
48
- "br",
49
- "button",
50
- "canvas",
51
- "caption",
52
- "center",
53
- "cite",
54
- "code",
55
- "search",
56
- "col",
57
- "colgroup",
58
- "data",
59
- "datalist",
60
- "dd",
61
- "del",
62
- "details",
63
- "dfn",
64
- "dialog",
65
- "dir",
66
- "div",
67
- "dl",
68
- "dt",
69
- "em",
70
- "embed",
71
- "fieldset",
72
- "figcaption",
73
- "figure",
74
- "font",
75
- "footer",
76
- "form",
77
- "frame",
78
- "frameset",
79
- "h1",
80
- "h2",
81
- "h3",
82
- "h4",
83
- "h5",
84
- "h6",
85
- "head",
86
- "header",
87
- "hr",
88
- "i",
89
- "iframe",
90
- "img",
91
- "input",
92
- "ins",
93
- "kbd",
94
- "label",
95
- "legend",
96
- "li",
97
- "link",
98
- "main",
99
- "map",
100
- "mark",
101
- "meter",
102
- "nav",
103
- "noframes",
104
- "noscript",
105
- "object",
106
- "ol",
107
- "optgroup",
108
- "option",
109
- "output",
110
- "p",
111
- "param",
112
- "picture",
113
- "pre",
114
- "progress",
115
- "hgroup",
116
- "q",
117
- "rp",
118
- "rt",
119
- "ruby",
120
- "s",
121
- "samp",
122
- "script",
123
- "section",
124
- "select",
125
- "small",
126
- "source",
127
- "span",
128
- "strike",
129
- "strong",
130
- "sub",
131
- "summary",
132
- "sup",
133
- "table",
134
- "tbody",
135
- "td",
136
- "template",
137
- "hgroup",
138
- "textarea",
139
- "tfoot",
140
- "th",
141
- "thead",
142
- "time",
143
- "tr",
144
- "track",
145
- "tt",
146
- "u",
147
- "ul",
148
- "var",
149
- "video",
150
- "wbr",
151
- // SVG
152
- "svg",
153
- "path",
154
- "circle",
155
- "ellipse",
156
- "line",
157
- "polygon",
158
- "polyline",
159
- "rect",
160
- "g",
161
- "defs",
162
- "symbol",
163
- "use",
164
- "text",
165
- "tspan",
166
- "image",
167
- "clipPath",
168
- "mask",
169
- "pattern",
170
- "marker",
171
- "linearGradient",
172
- "radialGradient",
173
- "stop",
174
- "filter",
175
- "feGaussianBlur",
176
- "feOffset",
177
- "feMerge",
178
- "feMergeNode",
179
- "feBlend",
180
- "feColorMatrix",
181
- "feFlood",
182
- "feComposite",
183
- "foreignObject"
184
- ])
185
- };
186
- const SVG_TAGS = /* @__PURE__ */ new Set([
187
- "svg",
188
- "path",
189
- "circle",
190
- "ellipse",
191
- "line",
192
- "polygon",
193
- "polyline",
194
- "rect",
195
- "g",
196
- "defs",
197
- "symbol",
198
- "use",
199
- "text",
200
- "tspan",
201
- "image",
202
- "clipPath",
203
- "mask",
204
- "pattern",
205
- "marker",
206
- "linearGradient",
207
- "radialGradient",
208
- "stop",
209
- "filter",
210
- "feGaussianBlur",
211
- "feOffset",
212
- "feMerge",
213
- "feMergeNode",
214
- "feBlend",
215
- "feColorMatrix",
216
- "feFlood",
217
- "feComposite",
218
- "foreignObject"
219
- ]);
220
- const isValidHtmlTag = (arg) => HTML_TAGS.body.has(arg);
@@ -1,112 +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 triggerEvent_exports = {};
20
- __export(triggerEvent_exports, {
21
- applyEvent: () => applyEvent,
22
- applyEventUpdate: () => applyEventUpdate,
23
- triggerEventOn: () => triggerEventOn,
24
- triggerEventOnUpdate: () => triggerEventOnUpdate
25
- });
26
- module.exports = __toCommonJS(triggerEvent_exports);
27
- var import_types = require("./types.js");
28
- var import_function = require("./function.js");
29
- const getOnOrPropsEvent = (param, element) => {
30
- const propKey = "on" + param.charAt(0).toUpperCase() + param.slice(1);
31
- return element[propKey];
32
- };
33
- const applyEvent = (param, element, state, context, options) => {
34
- param = (0, import_function.resolveHandler)(param, element);
35
- if (!(0, import_types.isFunction)(param)) return;
36
- try {
37
- const result = param.call(
38
- element,
39
- element,
40
- state || element.state,
41
- context || element.context,
42
- options
43
- );
44
- if (result && typeof result.then === "function") {
45
- result.catch((err) => {
46
- element.error = err;
47
- if (err instanceof ReferenceError) console.warn("[DOMQL] Async event warning:", err.message);
48
- else console.error("[DOMQL] Async event error:", err);
49
- });
50
- }
51
- return result;
52
- } catch (err) {
53
- element.error = err;
54
- if (err instanceof ReferenceError) {
55
- console.warn("[DOMQL] Event handler warning:", err.message);
56
- } else {
57
- console.error("[DOMQL] Event handler error:", err);
58
- }
59
- if (element.context?.strictMode) throw err;
60
- }
61
- };
62
- const triggerEventOn = (param, element, options) => {
63
- if (!element) {
64
- throw new Error("Element is required");
65
- }
66
- (0, import_function.runPluginHook)(param, element, options);
67
- const appliedFunction = getOnOrPropsEvent(param, element);
68
- if (appliedFunction) {
69
- const { state, context } = element;
70
- return applyEvent(appliedFunction, element, state, context, options);
71
- }
72
- };
73
- const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
74
- param = (0, import_function.resolveHandler)(param, element);
75
- if (!(0, import_types.isFunction)(param)) return;
76
- try {
77
- const result = param.call(
78
- element,
79
- updatedObj,
80
- element,
81
- state || element.state,
82
- context || element.context,
83
- options
84
- );
85
- if (result && typeof result.then === "function") {
86
- result.catch((err) => {
87
- element.error = err;
88
- console.error("[DOMQL] Async event update error:", err);
89
- });
90
- }
91
- return result;
92
- } catch (err) {
93
- element.error = err;
94
- console.error("[DOMQL] Event update error:", err);
95
- if (element.context?.strictMode) throw err;
96
- }
97
- };
98
- const triggerEventOnUpdate = (param, updatedObj, element, options) => {
99
- (0, import_function.runPluginHook)(param, element, updatedObj, options);
100
- const appliedFunction = getOnOrPropsEvent(param, element);
101
- if (appliedFunction) {
102
- const { state, context } = element;
103
- return applyEventUpdate(
104
- appliedFunction,
105
- updatedObj,
106
- element,
107
- state,
108
- context,
109
- options
110
- );
111
- }
112
- };
package/dist/cjs/types.js DELETED
@@ -1,74 +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 types_exports = {};
20
- __export(types_exports, {
21
- TYPES: () => TYPES,
22
- is: () => is,
23
- isArray: () => isArray,
24
- isBoolean: () => isBoolean,
25
- isDate: () => isDate,
26
- isDefined: () => isDefined,
27
- isFunction: () => isFunction,
28
- isNot: () => isNot,
29
- isNull: () => isNull,
30
- isNumber: () => isNumber,
31
- isObject: () => isObject,
32
- isObjectLike: () => isObjectLike,
33
- isString: () => isString,
34
- isUndefined: () => isUndefined
35
- });
36
- module.exports = __toCommonJS(types_exports);
37
- var import_node = require("./node.js");
38
- const isObject = (arg) => {
39
- if (arg === null) return false;
40
- return typeof arg === "object" && arg.constructor === Object;
41
- };
42
- const isString = (arg) => typeof arg === "string";
43
- const isNumber = (arg) => typeof arg === "number";
44
- const isFunction = (arg) => typeof arg === "function";
45
- const isBoolean = (arg) => arg === true || arg === false;
46
- const isNull = (arg) => arg === null;
47
- const isArray = (arg) => Array.isArray(arg);
48
- const isDate = (d) => d instanceof Date;
49
- const isObjectLike = (arg) => {
50
- if (arg === null) return false;
51
- return typeof arg === "object";
52
- };
53
- const isDefined = (arg) => arg !== void 0;
54
- const isUndefined = (arg) => arg === void 0;
55
- const TYPES = {
56
- boolean: isBoolean,
57
- array: isArray,
58
- object: isObject,
59
- string: isString,
60
- date: isDate,
61
- number: isNumber,
62
- null: isNull,
63
- function: isFunction,
64
- objectLike: isObjectLike,
65
- node: import_node.isNode,
66
- htmlElement: import_node.isHtmlElement,
67
- defined: isDefined
68
- };
69
- const is = (arg) => {
70
- return (...args) => args.some((val) => TYPES[val](arg));
71
- };
72
- const isNot = (arg) => {
73
- return (...args) => !args.some((val) => TYPES[val](arg));
74
- };
@@ -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
- };