@schukai/monster 3.5.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/package.json +1 -1
  2. package/source/constants.mjs +4 -9
  3. package/source/constraints/abstract.mjs +4 -6
  4. package/source/constraints/abstractoperator.mjs +6 -12
  5. package/source/constraints/andoperator.mjs +3 -6
  6. package/source/constraints/invalid.mjs +3 -6
  7. package/source/constraints/isarray.mjs +6 -9
  8. package/source/constraints/isobject.mjs +4 -7
  9. package/source/constraints/namespace.mjs +1 -3
  10. package/source/constraints/oroperator.mjs +26 -25
  11. package/source/constraints/valid.mjs +3 -6
  12. package/source/data/buildmap.mjs +20 -36
  13. package/source/data/buildtree.mjs +29 -29
  14. package/source/data/datasource/namespace.mjs +1 -1
  15. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  16. package/source/data/datasource/server/restapi.mjs +51 -65
  17. package/source/data/datasource/server/webconnect.mjs +26 -35
  18. package/source/data/datasource/server.mjs +16 -20
  19. package/source/data/datasource/storage/localstorage.mjs +8 -11
  20. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  21. package/source/data/datasource/storage.mjs +18 -22
  22. package/source/data/datasource.mjs +27 -43
  23. package/source/data/diff.mjs +20 -32
  24. package/source/data/extend.mjs +20 -14
  25. package/source/data/namespace.mjs +1 -3
  26. package/source/data/pathfinder.mjs +40 -67
  27. package/source/data/pipe.mjs +6 -10
  28. package/source/data/transformer.mjs +141 -157
  29. package/source/dom/assembler.mjs +6 -9
  30. package/source/dom/attributes.mjs +36 -48
  31. package/source/dom/constants.mjs +55 -71
  32. package/source/dom/customcontrol.mjs +16 -21
  33. package/source/dom/customelement.mjs +140 -164
  34. package/source/dom/events.mjs +17 -24
  35. package/source/dom/focusmanager.mjs +30 -48
  36. package/source/dom/locale.mjs +16 -19
  37. package/source/dom/namespace.mjs +1 -1
  38. package/source/dom/ready.mjs +7 -10
  39. package/source/dom/resource/data.mjs +38 -46
  40. package/source/dom/resource/link/namespace.mjs +1 -3
  41. package/source/dom/resource/link/stylesheet.mjs +7 -11
  42. package/source/dom/resource/link.mjs +36 -17
  43. package/source/dom/resource/namespace.mjs +1 -1
  44. package/source/dom/resource/script.mjs +23 -13
  45. package/source/dom/resource.mjs +47 -60
  46. package/source/dom/resourcemanager.mjs +36 -43
  47. package/source/dom/template.mjs +17 -24
  48. package/source/dom/theme.mjs +8 -12
  49. package/source/dom/updater.mjs +150 -196
  50. package/source/dom/util.mjs +11 -12
  51. package/source/dom/worker/factory.mjs +21 -25
  52. package/source/dom/worker/namespace.mjs +1 -1
  53. package/source/i18n/formatter.mjs +20 -24
  54. package/source/i18n/locale.mjs +40 -42
  55. package/source/i18n/namespace.mjs +1 -1
  56. package/source/i18n/provider.mjs +4 -7
  57. package/source/i18n/providers/embed.mjs +16 -26
  58. package/source/i18n/providers/fetch.mjs +30 -36
  59. package/source/i18n/translations.mjs +15 -22
  60. package/source/logging/handler/console.mjs +6 -10
  61. package/source/logging/handler.mjs +15 -18
  62. package/source/logging/logentry.mjs +8 -9
  63. package/source/logging/logger.mjs +73 -55
  64. package/source/logging/namespace.mjs +1 -1
  65. package/source/math/namespace.mjs +1 -1
  66. package/source/math/random.mjs +13 -14
  67. package/source/monster.mjs +132 -100
  68. package/source/net/namespace.mjs +1 -3
  69. package/source/net/webconnect/message.mjs +6 -8
  70. package/source/net/webconnect/namespace.mjs +1 -3
  71. package/source/net/webconnect.mjs +28 -39
  72. package/source/text/formatter.mjs +44 -55
  73. package/source/types/base.mjs +16 -26
  74. package/source/types/basewithoptions.mjs +8 -14
  75. package/source/types/binary.mjs +4 -5
  76. package/source/types/dataurl.mjs +19 -27
  77. package/source/types/global.mjs +14 -26
  78. package/source/types/id.mjs +4 -6
  79. package/source/types/is.mjs +11 -16
  80. package/source/types/mediatype.mjs +29 -44
  81. package/source/types/namespace.mjs +0 -1
  82. package/source/types/node.mjs +16 -22
  83. package/source/types/nodelist.mjs +10 -14
  84. package/source/types/noderecursiveiterator.mjs +11 -14
  85. package/source/types/observablequeue.mjs +13 -16
  86. package/source/types/observer.mjs +16 -23
  87. package/source/types/observerlist.mjs +18 -21
  88. package/source/types/proxyobserver.mjs +24 -37
  89. package/source/types/queue.mjs +8 -13
  90. package/source/types/randomid.mjs +10 -10
  91. package/source/types/regex.mjs +3 -5
  92. package/source/types/stack.mjs +4 -8
  93. package/source/types/tokenlist.mjs +24 -31
  94. package/source/types/typeof.mjs +5 -7
  95. package/source/types/uniquequeue.mjs +8 -13
  96. package/source/types/uuid.mjs +18 -25
  97. package/source/types/validate.mjs +26 -27
  98. package/source/types/version.mjs +17 -25
  99. package/source/util/clone.mjs +23 -32
  100. package/source/util/comparator.mjs +7 -15
  101. package/source/util/deadmansswitch.mjs +16 -23
  102. package/source/util/freeze.mjs +5 -7
  103. package/source/util/namespace.mjs +1 -1
  104. package/source/util/processing.mjs +33 -39
  105. package/source/util/trimspaces.mjs +17 -24
  106. package/test/cases/monster.mjs +1 -1
@@ -5,10 +5,10 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {getGlobalFunction} from "../types/global.mjs";
9
- import {TokenList} from "../types/tokenlist.mjs";
10
- import {validateInstance, validateString, validateSymbol} from "../types/validate.mjs";
11
- import {ATTRIBUTE_OBJECTLINK} from "./constants.mjs";
8
+ import { getGlobalFunction } from "../types/global.mjs";
9
+ import { TokenList } from "../types/tokenlist.mjs";
10
+ import { validateInstance, validateString, validateSymbol } from "../types/validate.mjs";
11
+ import { ATTRIBUTE_OBJECTLINK } from "./constants.mjs";
12
12
 
13
13
  export {
14
14
  findClosestObjectLink,
@@ -23,8 +23,8 @@ export {
23
23
  replaceAttributeToken,
24
24
  clearAttributeTokens,
25
25
  findClosestByAttribute,
26
- findClosestByClass
27
- }
26
+ findClosestByClass,
27
+ };
28
28
 
29
29
  /**
30
30
  * Get the closest object link of a node
@@ -57,18 +57,16 @@ function findClosestObjectLink(element) {
57
57
  * @return {boolean}
58
58
  */
59
59
  function addToObjectLink(element, symbol, object) {
60
-
61
60
  validateInstance(element, HTMLElement);
62
- validateSymbol(symbol)
61
+ validateSymbol(symbol);
63
62
 
64
63
  if (element?.[symbol] === undefined) {
65
- element[symbol] = new Set;
64
+ element[symbol] = new Set();
66
65
  }
67
66
 
68
67
  addAttributeToken(element, ATTRIBUTE_OBJECTLINK, symbol.toString());
69
68
  element[symbol].add(object);
70
69
  return element;
71
-
72
70
  }
73
71
 
74
72
  /**
@@ -83,21 +81,18 @@ function addToObjectLink(element, symbol, object) {
83
81
  * @return {boolean}
84
82
  */
85
83
  function removeObjectLink(element, symbol) {
86
-
87
84
  validateInstance(element, HTMLElement);
88
- validateSymbol(symbol)
85
+ validateSymbol(symbol);
89
86
 
90
87
  if (element?.[symbol] === undefined) {
91
- return element
88
+ return element;
92
89
  }
93
90
 
94
91
  removeAttributeToken(element, ATTRIBUTE_OBJECTLINK, symbol.toString());
95
92
  delete element[symbol];
96
93
  return element;
97
-
98
94
  }
99
95
 
100
-
101
96
  /**
102
97
  * Checks if an element has an object link
103
98
  *
@@ -110,16 +105,14 @@ function removeObjectLink(element, symbol) {
110
105
  * @return {boolean}
111
106
  */
112
107
  function hasObjectLink(element, symbol) {
113
-
114
108
  validateInstance(element, HTMLElement);
115
- validateSymbol(symbol)
109
+ validateSymbol(symbol);
116
110
 
117
111
  if (element?.[symbol] === undefined) {
118
- return false
112
+ return false;
119
113
  }
120
114
 
121
115
  return containsAttributeToken(element, ATTRIBUTE_OBJECTLINK, symbol.toString());
122
-
123
116
  }
124
117
 
125
118
  /**
@@ -140,19 +133,16 @@ function hasObjectLink(element, symbol) {
140
133
  * @throws {Error} there is no object link for symbol
141
134
  */
142
135
  function getLinkedObjects(element, symbol) {
143
-
144
136
  validateInstance(element, HTMLElement);
145
- validateSymbol(symbol)
137
+ validateSymbol(symbol);
146
138
 
147
139
  if (element?.[symbol] === undefined) {
148
- throw new Error('there is no object link for ' + symbol.toString());
140
+ throw new Error(`there is no object link for ${symbol.toString()}`);
149
141
  }
150
142
 
151
143
  return element?.[symbol][Symbol.iterator]();
152
-
153
144
  }
154
145
 
155
-
156
146
  /**
157
147
  * With this method tokens in an attribute can be switched on or off. For example, classes can be switched on and off in the elements class attribute.
158
148
  *
@@ -169,8 +159,8 @@ function getLinkedObjects(element, symbol) {
169
159
  */
170
160
  function toggleAttributeToken(element, key, token) {
171
161
  validateInstance(element, HTMLElement);
172
- validateString(token)
173
- validateString(key)
162
+ validateString(token);
163
+ validateString(key);
174
164
 
175
165
  if (!element.hasAttribute(key)) {
176
166
  element.setAttribute(key, token);
@@ -179,7 +169,7 @@ function toggleAttributeToken(element, key, token) {
179
169
 
180
170
  element.setAttribute(key, new TokenList(element.getAttribute(key)).toggle(token).toString());
181
171
 
182
- return element
172
+ return element;
183
173
  }
184
174
 
185
175
  /**
@@ -196,8 +186,8 @@ function toggleAttributeToken(element, key, token) {
196
186
  */
197
187
  function addAttributeToken(element, key, token) {
198
188
  validateInstance(element, HTMLElement);
199
- validateString(token)
200
- validateString(key)
189
+ validateString(token);
190
+ validateString(key);
201
191
 
202
192
  if (!element.hasAttribute(key)) {
203
193
  element.setAttribute(key, token);
@@ -206,7 +196,7 @@ function addAttributeToken(element, key, token) {
206
196
 
207
197
  element.setAttribute(key, new TokenList(element.getAttribute(key)).add(token).toString());
208
198
 
209
- return element
199
+ return element;
210
200
  }
211
201
 
212
202
  /**
@@ -225,8 +215,8 @@ function addAttributeToken(element, key, token) {
225
215
  */
226
216
  function removeAttributeToken(element, key, token) {
227
217
  validateInstance(element, HTMLElement);
228
- validateString(token)
229
- validateString(key)
218
+ validateString(token);
219
+ validateString(key);
230
220
 
231
221
  if (!element.hasAttribute(key)) {
232
222
  return element;
@@ -234,7 +224,7 @@ function removeAttributeToken(element, key, token) {
234
224
 
235
225
  element.setAttribute(key, new TokenList(element.getAttribute(key)).remove(token).toString());
236
226
 
237
- return element
227
+ return element;
238
228
  }
239
229
 
240
230
  /**
@@ -253,15 +243,14 @@ function removeAttributeToken(element, key, token) {
253
243
  */
254
244
  function containsAttributeToken(element, key, token) {
255
245
  validateInstance(element, HTMLElement);
256
- validateString(token)
257
- validateString(key)
246
+ validateString(token);
247
+ validateString(key);
258
248
 
259
249
  if (!element.hasAttribute(key)) {
260
250
  return false;
261
251
  }
262
252
 
263
253
  return new TokenList(element.getAttribute(key)).contains(token);
264
-
265
254
  }
266
255
 
267
256
  /**
@@ -279,9 +268,9 @@ function containsAttributeToken(element, key, token) {
279
268
  */
280
269
  function replaceAttributeToken(element, key, from, to) {
281
270
  validateInstance(element, HTMLElement);
282
- validateString(from)
283
- validateString(to)
284
- validateString(key)
271
+ validateString(from);
272
+ validateString(to);
273
+ validateString(key);
285
274
 
286
275
  if (!element.hasAttribute(key)) {
287
276
  return element;
@@ -289,7 +278,7 @@ function replaceAttributeToken(element, key, from, to) {
289
278
 
290
279
  element.setAttribute(key, new TokenList(element.getAttribute(key)).replace(from, to).toString());
291
280
 
292
- return element
281
+ return element;
293
282
  }
294
283
 
295
284
  /**
@@ -305,7 +294,7 @@ function replaceAttributeToken(element, key, from, to) {
305
294
  */
306
295
  function clearAttributeTokens(element, key) {
307
296
  validateInstance(element, HTMLElement);
308
- validateString(key)
297
+ validateString(key);
309
298
 
310
299
  if (!element.hasAttribute(key)) {
311
300
  return element;
@@ -313,7 +302,7 @@ function clearAttributeTokens(element, key) {
313
302
 
314
303
  element.setAttribute(key, "");
315
304
 
316
- return element
305
+ return element;
317
306
  }
318
307
 
319
308
  /**
@@ -346,7 +335,7 @@ function clearAttributeTokens(element, key) {
346
335
  * @summary find closest node
347
336
  */
348
337
  function findClosestByAttribute(element, key, value) {
349
- validateInstance(element, getGlobalFunction('HTMLElement'));
338
+ validateInstance(element, getGlobalFunction("HTMLElement"));
350
339
 
351
340
  if (element.hasAttribute(key)) {
352
341
  if (value === undefined) {
@@ -356,12 +345,11 @@ function findClosestByAttribute(element, key, value) {
356
345
  if (element.getAttribute(key) === value) {
357
346
  return element;
358
347
  }
359
-
360
348
  }
361
349
 
362
350
  let selector = validateString(key);
363
- if (value !== undefined) selector += "=" + validateString(value);
364
- let result = element.closest('[' + selector + ']');
351
+ if (value !== undefined) selector += `=${validateString(value)}`;
352
+ let result = element.closest(`[${selector}]`);
365
353
  if (result instanceof HTMLElement) {
366
354
  return result;
367
355
  }
@@ -400,13 +388,13 @@ function findClosestByAttribute(element, key, value) {
400
388
  * @summary find closest node
401
389
  */
402
390
  function findClosestByClass(element, className) {
403
- validateInstance(element, getGlobalFunction('HTMLElement'));
391
+ validateInstance(element, getGlobalFunction("HTMLElement"));
404
392
 
405
393
  if (element?.classList?.contains(validateString(className))) {
406
394
  return element;
407
395
  }
408
396
 
409
- let result = element.closest('.' + className);
397
+ let result = element.closest(`.${className}`);
410
398
  if (result instanceof HTMLElement) {
411
399
  return result;
412
400
  }