@schukai/monster 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. package/CHANGELOG +14 -0
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -2
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -2
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -2
  33. package/dist/modules/i18n/namespace.js +1 -1
  34. package/dist/modules/i18n/provider.js +2 -2
  35. package/dist/modules/i18n/providers/fetch.js +2 -2
  36. package/dist/modules/i18n/providers/namespace.js +1 -1
  37. package/dist/modules/i18n/translations.js +2 -2
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +1 -1
  47. package/dist/modules/namespace.js +1 -1
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -2
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +1096 -844
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +3 -3
  74. package/package.json +1 -1
  75. package/source/constants.js +6 -5
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +3 -3
  78. package/source/constraints/andoperator.js +7 -7
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +6 -6
  81. package/source/constraints/isobject.js +6 -6
  82. package/source/constraints/oroperator.js +8 -8
  83. package/source/constraints/valid.js +6 -6
  84. package/source/data/buildmap.js +15 -15
  85. package/source/data/diff.js +6 -6
  86. package/source/data/extend.js +55 -13
  87. package/source/data/pathfinder.js +6 -7
  88. package/source/data/pipe.js +5 -5
  89. package/source/data/transformer.js +5 -6
  90. package/source/dom/assembler.js +5 -5
  91. package/source/dom/attributes.js +26 -26
  92. package/source/dom/constants.js +1 -2
  93. package/source/dom/customcontrol.js +14 -50
  94. package/source/dom/customelement.js +125 -28
  95. package/source/dom/events.js +7 -7
  96. package/source/dom/locale.js +5 -5
  97. package/source/dom/template.js +7 -7
  98. package/source/dom/theme.js +6 -6
  99. package/source/dom/updater.js +35 -13
  100. package/source/dom/util.js +9 -9
  101. package/source/i18n/locale.js +7 -7
  102. package/source/i18n/provider.js +5 -5
  103. package/source/i18n/providers/fetch.js +10 -10
  104. package/source/i18n/translations.js +5 -5
  105. package/source/logging/handler/console.js +4 -4
  106. package/source/logging/handler.js +4 -4
  107. package/source/logging/logentry.js +4 -4
  108. package/source/logging/logger.js +4 -4
  109. package/source/math/random.js +5 -5
  110. package/source/namespace.js +1 -1
  111. package/source/text/formatter.js +4 -5
  112. package/source/types/base.js +4 -5
  113. package/source/types/basewithoptions.js +9 -8
  114. package/source/types/global.js +6 -6
  115. package/source/types/id.js +6 -6
  116. package/source/types/is.js +22 -22
  117. package/source/types/observer.js +5 -5
  118. package/source/types/observerlist.js +4 -4
  119. package/source/types/proxyobserver.js +32 -26
  120. package/source/types/queue.js +13 -7
  121. package/source/types/randomid.js +5 -5
  122. package/source/types/stack.js +11 -4
  123. package/source/types/tokenlist.js +4 -4
  124. package/source/types/typeof.js +5 -5
  125. package/source/types/uniquequeue.js +11 -4
  126. package/source/types/validate.js +22 -22
  127. package/source/types/version.js +9 -9
  128. package/source/util/clone.js +4 -4
  129. package/source/util/comparator.js +6 -6
  130. package/source/util/freeze.js +4 -4
  131. package/test/cases/data/extend.js +66 -13
  132. package/test/cases/dom/customcontrol.js +16 -2
  133. package/test/cases/dom/customelement.js +64 -6
  134. package/test/cases/monster.js +1 -1
  135. package/test/cases/types/proxyobserver.js +9 -0
  136. package/test/web/monster-dev.html +3 -3
  137. package/test/web/monster.html +2 -2
  138. package/test/web/test.html +3 -3
  139. package/test/web/tests.js +3 -3
@@ -3,23 +3,26 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, Updater} from "./updater.js";
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import {Observer} from "../types/observer.js";
8
+ import {ProxyObserver} from "../types/proxyobserver.js";
9
+ import { Updater} from "./updater.js";
8
10
  import {extend} from "../data/extend.js";
11
+ import {clone} from "../util/clone.js";
9
12
  import {Pathfinder} from "../data/pathfinder.js";
10
13
  import {ATTRIBUTE_OPTIONS, OBJECTLINK_KEY_UPDATER} from "./constants.js";
11
14
  import {findDocumentTemplate, Template} from "./template.js";
12
- import {addToObjectLink,getLinkedObjects, hasObjectLink} from "./attributes.js";
15
+ import {addToObjectLink, getLinkedObjects, hasObjectLink} from "./attributes.js";
13
16
  import {getGlobalObject} from "../types/global.js";
14
17
  import {validateFunction, validateObject} from "../types/validate.js";
15
18
  import {isString} from "../types/is.js";
16
- import {PROPERTY_KEY_OPTIONS} from "../constants.js";
19
+ import {PROPERTY_KEY_INTERNALDATA} from "../constants.js";
17
20
 
18
21
  /**
19
22
  * @private
20
23
  * @type {symbol}
21
24
  */
22
- const optionsSymbol = Symbol.for(PROPERTY_KEY_OPTIONS);
25
+ const internalDataSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
23
26
 
24
27
  /**
25
28
  * @private
@@ -37,7 +40,6 @@ const initMethodSymbol = Symbol('initMethodSymbol');
37
40
  */
38
41
  const assembleMethodSymbol = Symbol('assembleMethodSymbol');
39
42
 
40
-
41
43
  /**
42
44
  * To define a new HTML element we need the power of CustomElement
43
45
  *
@@ -48,7 +50,7 @@ const assembleMethodSymbol = Symbol('assembleMethodSymbol');
48
50
  *
49
51
  * ```
50
52
  * <script type="module">
51
- * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/customelement.js';
53
+ * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/customelement.js';
52
54
  * console.log(new Monster.DOM.CustomElement())
53
55
  * </script>
54
56
  * ```
@@ -57,7 +59,7 @@ const assembleMethodSymbol = Symbol('assembleMethodSymbol');
57
59
  *
58
60
  * ```
59
61
  * <script type="module">
60
- * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/customelement.js';
62
+ * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/customelement.js';
61
63
  * console.log(new CustomElement())
62
64
  * </script>
63
65
  * ```
@@ -155,10 +157,41 @@ class CustomElement extends HTMLElement {
155
157
  */
156
158
  constructor() {
157
159
  super();
158
- this[optionsSymbol] = extend({}, this.defaults, getOptionsFromAttributes.call(this));
160
+ this[internalDataSymbol] = new ProxyObserver({'options': extend({}, this.defaults, getOptionsFromAttributes.call(this))});
161
+ initOptionObserver.call(this);
159
162
  this[initMethodSymbol]();
160
163
  }
161
164
 
165
+ /**
166
+ * attach a new observer
167
+ *
168
+ * @param {Observer} observer
169
+ * @returns {CustomElement}
170
+ */
171
+ attachObserver(observer) {
172
+ this[internalDataSymbol].attachObserver(observer)
173
+ return this;
174
+ }
175
+
176
+ /**
177
+ * detach a observer
178
+ *
179
+ * @param {Observer} observer
180
+ * @returns {CustomElement}
181
+ */
182
+ detachObserver(observer) {
183
+ this[internalDataSymbol].detachObserver(observer)
184
+ return this;
185
+ }
186
+
187
+ /**
188
+ * @param {Observer} observer
189
+ * @returns {ProxyObserver}
190
+ */
191
+ containsObserver(observer) {
192
+ return this[internalDataSymbol].containsObserver(observer)
193
+ }
194
+
162
195
  /**
163
196
  * | option | description |
164
197
  * |----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -202,7 +235,7 @@ class CustomElement extends HTMLElement {
202
235
  let value;
203
236
 
204
237
  try {
205
- value = new Pathfinder(this[optionsSymbol]).getVia(path);
238
+ value = new Pathfinder(this[internalDataSymbol].getRealSubject()['options']).getVia(path);
206
239
  } catch (e) {
207
240
 
208
241
  }
@@ -220,20 +253,27 @@ class CustomElement extends HTMLElement {
220
253
  * @since 1.14.0
221
254
  */
222
255
  setOption(path, value) {
256
+ new Pathfinder(this[internalDataSymbol].getSubject()['options']).setVia(path, value);
257
+ //this[internalDataSymbol].notifyObservers();
258
+ return this;
259
+ }
223
260
 
224
- // inform every element
225
- const updaters = getLinkedObjects(this, Symbol.for(OBJECTLINK_KEY_UPDATER));
261
+ /**
262
+ * @since 1.15.0
263
+ * @param {string|object} options
264
+ * @return {CustomElement}
265
+ */
266
+ setOptions(options) {
226
267
 
227
- for (const list of updaters) {
228
- for (const updater of list) {
229
- // reset value so that a change occurs
230
- new Pathfinder(this[optionsSymbol]).setVia(path, false);
231
- new Pathfinder(updater.getSubject()).setVia(path, value);
232
- }
268
+ if (isString(options)) {
269
+ options = parseOptionsJSON(options)
233
270
  }
234
271
 
235
- return this;
236
-
272
+ const self = this;
273
+ extend(self[internalDataSymbol].getSubject()['options'], self.defaults, options);
274
+ //this[internalDataSymbol].notifyObservers();
275
+
276
+ return self;
237
277
  }
238
278
 
239
279
  /**
@@ -275,8 +315,8 @@ class CustomElement extends HTMLElement {
275
315
  for (const [, element] of Object.entries(elements)) {
276
316
 
277
317
  if (!(element instanceof HTMLElement)) continue;
278
-
279
- const u = new Updater(element, this[optionsSymbol])
318
+ if ((element instanceof HTMLTemplateElement)) continue;
319
+ const u = new Updater(element, clone(self[internalDataSymbol].getRealSubject()['options']))
280
320
  updater.add(u);
281
321
 
282
322
  u.run().then(() => {
@@ -324,22 +364,39 @@ class CustomElement extends HTMLElement {
324
364
 
325
365
  }
326
366
 
367
+ /**
368
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
369
+ *
370
+ * @return {string[]}
371
+ * @since 1.15.0
372
+ */
373
+ static get observedAttributes() {
374
+ return [ATTRIBUTE_OPTIONS];
375
+ }
376
+
327
377
  /**
328
378
  * Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial
329
- * values when an element is created by the parser, or upgraded. Note: only attributes listed in the observedAttributes property will receive this callback.
379
+ * values when an element is created by the parser, or upgraded. Note: only attributes listed in the observedAttributes
380
+ * property will receive this callback.
330
381
  *
331
382
  * @param {string} attrName
332
383
  * @param {string} oldVal
333
384
  * @param {string} newVal
334
385
  * @return {void}
335
- * @since 1.7.0
386
+ * @since 1.15.0
336
387
  */
337
388
  attributeChangedCallback(attrName, oldVal, newVal) {
389
+ const self = this;
390
+
391
+ if (attrName === ATTRIBUTE_OPTIONS) {
392
+ self.setOptions(newVal);
393
+ }
394
+
338
395
  }
339
396
 
340
397
  /**
341
398
  * There is no check on the name by this class. the developer is responsible for assigning an appropriate tag.
342
- * if the name is not valid, registerCustomElement() will issue an erro
399
+ * if the name is not valid, registerCustomElement() will issue an error
343
400
  *
344
401
  * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
345
402
  * @return {string}
@@ -378,6 +435,33 @@ class CustomElement extends HTMLElement {
378
435
 
379
436
  }
380
437
 
438
+ /**
439
+ * @since 1.15.0
440
+ * @private
441
+ */
442
+ function initOptionObserver() {
443
+ const self = this;
444
+
445
+ self.attachObserver(new Observer(function () {
446
+
447
+ // not initialised
448
+ if (!hasObjectLink(self, Symbol.for(OBJECTLINK_KEY_UPDATER))) {
449
+ return;
450
+ }
451
+ // inform every element
452
+ const updaters = getLinkedObjects(self, Symbol.for(OBJECTLINK_KEY_UPDATER));
453
+
454
+ for (const list of updaters) {
455
+ for (const updater of list) {
456
+ let d = clone(self[internalDataSymbol].getRealSubject()['options']);
457
+ Object.assign(updater.getSubject(), d);
458
+ }
459
+ }
460
+
461
+ }));
462
+
463
+ }
464
+
381
465
  /**
382
466
  * @private
383
467
  * @return {object}
@@ -386,11 +470,24 @@ class CustomElement extends HTMLElement {
386
470
  function getOptionsFromAttributes() {
387
471
  if (this.hasAttribute(ATTRIBUTE_OPTIONS)) {
388
472
  try {
389
- let obj = JSON.parse(this.getAttribute(ATTRIBUTE_OPTIONS))
473
+ return parseOptionsJSON(this.getAttribute(ATTRIBUTE_OPTIONS))
474
+ } catch (e) {
475
+ throw new Error('the options attribute ' + ATTRIBUTE_OPTIONS + ' does not contain a valid json definition (actual: ' + this.getAttribute(ATTRIBUTE_OPTIONS) + ').');
476
+ }
477
+ }
478
+
479
+ return {};
480
+ }
481
+
482
+
483
+ function parseOptionsJSON(data) {
484
+ if (isString(data)) {
485
+ try {
486
+ let obj = JSON.parse(data);
390
487
  validateObject(obj);
391
488
  return obj;
392
489
  } catch (e) {
393
- throw new Error('the options attribute ' + ATTRIBUTE_OPTIONS + ' does not contain a valid json definition (actual: ' + this.getAttribute(ATTRIBUTE_OPTIONS) + ').');
490
+ throw new Error('the options does not contain a valid json definition (actual: ' + data + ').');
394
491
  }
395
492
  }
396
493
 
@@ -476,5 +573,5 @@ function registerCustomElement(element) {
476
573
  getGlobalObject('customElements').define(element.getTag(), element);
477
574
  }
478
575
 
479
- Monster.assignToNamespace('Monster.DOM', CustomElement, registerCustomElement);
576
+ assignToNamespace('Monster.DOM', CustomElement, registerCustomElement);
480
577
  export {Monster, registerCustomElement, CustomElement, initMethodSymbol, assembleMethodSymbol}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, validateInstance, validateString} from "../types/validate.js";
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import {validateInstance, validateString} from "../types/validate.js";
8
8
  import {findClosestByAttribute} from "./attributes.js";
9
9
  import {getDocument} from "./util.js";
10
10
 
@@ -13,7 +13,7 @@ import {getDocument} from "./util.js";
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/events.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
17
17
  * console.log(new Monster.DOM.fireEvent())
18
18
  * </script>
19
19
  * ```
@@ -22,7 +22,7 @@ import {getDocument} from "./util.js";
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/events.js';
25
+ * import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
26
26
  * console.log(fireEvent())
27
27
  * </script>
28
28
  * ```
@@ -71,7 +71,7 @@ function fireEvent(element, type) {
71
71
  *
72
72
  * ```
73
73
  * <script type="module">
74
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/events.js';
74
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
75
75
  * console.log(new Monster.DOM.findTargetElementFromEvent())
76
76
  * </script>
77
77
  * ```
@@ -80,7 +80,7 @@ function fireEvent(element, type) {
80
80
  *
81
81
  * ```
82
82
  * <script type="module">
83
- * import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/events.js';
83
+ * import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
84
84
  * console.log(findTargetElementFromEvent())
85
85
  * </script>
86
86
  * ```
@@ -113,5 +113,5 @@ function findTargetElementFromEvent(event, attributeName, attributeValue) {
113
113
  }
114
114
 
115
115
 
116
- Monster.assignToNamespace('Monster.DOM', findTargetElementFromEvent, fireEvent);
116
+ assignToNamespace('Monster.DOM', findTargetElementFromEvent, fireEvent);
117
117
  export {Monster, findTargetElementFromEvent, fireEvent}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, parseLocale} from "../i18n/locale.js";
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { parseLocale} from "../i18n/locale.js";
8
8
  import {getDocument} from "./util.js";
9
9
 
10
10
  /**
@@ -20,7 +20,7 @@ const DEFAULT_LANGUAGE = 'en';
20
20
  *
21
21
  * ```
22
22
  * <script type="module">
23
- * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/locale.js';
23
+ * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/locale.js';
24
24
  * console.log(new Monster.DOM.getLocaleOfDocument())
25
25
  * </script>
26
26
  * ```
@@ -29,7 +29,7 @@ const DEFAULT_LANGUAGE = 'en';
29
29
  *
30
30
  * ```
31
31
  * <script type="module">
32
- * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/locale.js';
32
+ * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/locale.js';
33
33
  * console.log(new getLocaleOfDocument())
34
34
  * </script>
35
35
  * ```
@@ -55,5 +55,5 @@ function getLocaleOfDocument() {
55
55
  return parseLocale(DEFAULT_LANGUAGE);
56
56
  }
57
57
 
58
- Monster.assignToNamespace('Monster.DOM', getLocaleOfDocument);
58
+ assignToNamespace('Monster.DOM', getLocaleOfDocument);
59
59
  export {Monster, getLocaleOfDocument}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, Base} from '../types/base.js';
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from '../types/base.js';
8
8
  import {validateString} from "../types/validate.js";
9
9
  import {getGlobalFunction, getGlobalObject} from '../types/global.js';
10
10
  import {validateInstance} from "../types/validate.js";
@@ -15,7 +15,7 @@ import {getDocumentTheme} from "./theme.js";
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/template.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
19
19
  * console.log(new Monster.DOM.Template())
20
20
  * </script>
21
21
  * ```
@@ -24,7 +24,7 @@ import {getDocumentTheme} from "./theme.js";
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/template.js';
27
+ * import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
28
28
  * console.log(new Template())
29
29
  * </script>
30
30
  * ```
@@ -74,7 +74,7 @@ class Template extends Base {
74
74
  *
75
75
  * ```
76
76
  * <script type="module">
77
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/template.js';
77
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
78
78
  * console.log(Monster.DOM.findDocumentTemplate())
79
79
  * </script>
80
80
  * ```
@@ -83,7 +83,7 @@ class Template extends Base {
83
83
  *
84
84
  * ```
85
85
  * <script type="module">
86
- * import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/template.js';
86
+ * import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
87
87
  * console.log(findDocumentTemplate())
88
88
  * </script>
89
89
  * ```
@@ -127,7 +127,7 @@ function findDocumentTemplate(id, root) {
127
127
  }
128
128
 
129
129
 
130
- Monster.assignToNamespace('Monster.DOM', Template, findDocumentTemplate);
130
+ assignToNamespace('Monster.DOM', Template, findDocumentTemplate);
131
131
  export {Monster, Template, findDocumentTemplate}
132
132
 
133
133
 
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, Base} from '../types/base.js';
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from '../types/base.js';
8
8
  import {validateString} from "../types/validate.js";
9
9
  import {getGlobalObject} from '../types/global.js';
10
10
  import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
@@ -16,7 +16,7 @@ import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
16
16
  *
17
17
  * ```
18
18
  * <script type="module">
19
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/theme.js';
19
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
20
20
  * console.log(new Monster.DOM.Theme())
21
21
  * </script>
22
22
  * ```
@@ -25,14 +25,14 @@ import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
25
25
  *
26
26
  * ```
27
27
  * <script type="module">
28
- * import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/theme.js';
28
+ * import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
29
29
  * console.log(new Theme())
30
30
  * </script>
31
31
  * ```
32
32
  *
33
33
  * @example
34
34
  *
35
- * import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/theme.js';
35
+ * import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
36
36
  *
37
37
  * const theme = getDocumentTheme();
38
38
  * console.log(theme.getName());
@@ -96,5 +96,5 @@ function getDocumentTheme() {
96
96
 
97
97
  }
98
98
 
99
- Monster.assignToNamespace('Monster.DOM', Theme, getDocumentTheme);
99
+ assignToNamespace('Monster.DOM', Theme, getDocumentTheme);
100
100
  export {Monster, Theme, getDocumentTheme}
@@ -1,9 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * @author schukai GmbH
5
+ */
6
+ import {Monster, assignToNamespace} from '../namespace.js';
3
7
  import {Pathfinder} from "../data/pathfinder.js";
4
8
  import {Pipe} from "../data/pipe.js";
5
- import {Base, Monster} from "../types/base.js";
6
- import {isInstance, isArray} from "../types/is.js";
9
+ import {Base} from "../types/base.js";
10
+ import {isInstance, isArray, isIterable} from "../types/is.js";
7
11
  import {Observer} from "../types/observer.js";
8
12
  import {ProxyObserver} from "../types/proxyobserver.js";
9
13
  import {validateInstance, validateArray} from "../types/validate.js";
@@ -20,10 +24,6 @@ import {
20
24
  import {findDocumentTemplate} from "./template.js";
21
25
  import {getDocument} from "./util.js";
22
26
 
23
- /**
24
- * @author schukai GmbH
25
- */
26
-
27
27
 
28
28
  /**
29
29
  * The updater class connects an object with the dom. in this way, structures and contents in the DOM can be programmatically adapted via attributes.
@@ -34,7 +34,7 @@ import {getDocument} from "./util.js";
34
34
  *
35
35
  * ```
36
36
  * <script type="module">
37
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/updater.js';
37
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
38
38
  * console.log(new Monster.DOM.Updater())
39
39
  * </script>
40
40
  * ```
@@ -43,14 +43,14 @@ import {getDocument} from "./util.js";
43
43
  *
44
44
  * ```
45
45
  * <script type="module">
46
- * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/updater.js';
46
+ * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
47
47
  * console.log(new Updater())
48
48
  * </script>
49
49
  * ```
50
50
  *
51
51
  * @example
52
52
  *
53
- * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/updater.js';
53
+ * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
54
54
  *
55
55
  * // First we prepare the html document.
56
56
  * // This is done here via script, but can also be inserted into the document as pure html.
@@ -102,6 +102,7 @@ class Updater extends Base {
102
102
  this.element = validateInstance(element, HTMLElement);
103
103
 
104
104
  if (subject === undefined) subject = {}
105
+ let a = subject;
105
106
  if (!isInstance(subject, ProxyObserver)) {
106
107
  subject = new ProxyObserver(subject);
107
108
  }
@@ -114,7 +115,9 @@ class Updater extends Base {
114
115
  * @type {object}
115
116
  */
116
117
  this.subject = subject.attachObserver(new Observer(() => {
118
+
117
119
  const s = this.subject.getRealSubject();
120
+
118
121
  const diff = Diff(this.last, s)
119
122
  this.last = clone(s);
120
123
 
@@ -174,6 +177,26 @@ class Updater extends Base {
174
177
 
175
178
  }
176
179
 
180
+ // /**
181
+ // *
182
+ // * @param {string} path
183
+ // * @param {*} value
184
+ // * @param {boolean} notifyAnyway
185
+ // * @return {Updater}
186
+ // * @since 1.15.0
187
+ // */
188
+ // setVia(path, value, notifyAnyway) {
189
+ // if(isBoolean(notifyAnyway)&&notifyAnyway===true) {
190
+ // // the key __init__has no further meaning and is only
191
+ // // used to create the diff for empty objects.
192
+ // new Pathfinder(this.last).setVia(path, {'__init__': true});
193
+ //
194
+ // }
195
+ //
196
+ // new Pathfinder(this.subject.getSubject()).setVia(path, value);
197
+ // return this;
198
+ // }
199
+
177
200
  /**
178
201
  * Let the magic begin
179
202
  *
@@ -318,10 +341,9 @@ function getControlEventHandler() {
318
341
 
319
342
 
320
343
  // values from customelements
321
- } else if ((element?.constructor?.prototype && !!Object.getOwnPropertyDescriptor(element.constructor.prototype, 'value')?.['get'])|| element.hasOwnProperty('value')) {
344
+ } else if ((element?.constructor?.prototype && !!Object.getOwnPropertyDescriptor(element.constructor.prototype, 'value')?.['get']) || element.hasOwnProperty('value')) {
322
345
  value = element?.['value'];
323
346
  } else {
324
- console.log(element);
325
347
  throw new Error("unsupported object");
326
348
  }
327
349
 
@@ -416,7 +438,7 @@ function insertElement(change) {
416
438
  insertPoint = containerElement.lastChild;
417
439
  }
418
440
 
419
- if (!isArray(value)) {
441
+ if (!isIterable(value)) {
420
442
  throw new Error('the value is not iterable');
421
443
  }
422
444
 
@@ -728,5 +750,5 @@ function handleInputControlAttributeUpdate(element, name, value) {
728
750
 
729
751
  }
730
752
 
731
- Monster.assignToNamespace('Monster.DOM', Updater);
753
+ assignToNamespace('Monster.DOM', Updater);
732
754
  export {Monster, Updater}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, getGlobal} from "../types/global.js";
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { getGlobal} from "../types/global.js";
8
8
  import {validateString} from "../types/validate.js";
9
9
 
10
10
 
@@ -13,7 +13,7 @@ import {validateString} from "../types/validate.js";
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
17
17
  * console.log(Monster.DOM.getDocument())
18
18
  * </script>
19
19
  * ```
@@ -22,7 +22,7 @@ import {validateString} from "../types/validate.js";
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
25
+ * import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
26
26
  * console.log(getDocument())
27
27
  * </script>
28
28
  * ```
@@ -74,7 +74,7 @@ function getDocument() {
74
74
  *
75
75
  * ```
76
76
  * <script type="module">
77
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
77
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
78
78
  * console.log(Monster.DOM.getWindow())
79
79
  * </script>
80
80
  * ```
@@ -83,7 +83,7 @@ function getDocument() {
83
83
  *
84
84
  * ```
85
85
  * <script type="module">
86
- * import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
86
+ * import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
87
87
  * console.log(getWindow(null))
88
88
  * </script>
89
89
  * ```
@@ -140,7 +140,7 @@ function getWindow() {
140
140
  *
141
141
  * ```
142
142
  * <script type="module">
143
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
143
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
144
144
  * console.log(Monster.DOM.getDocumentFragmentFromString())
145
145
  * </script>
146
146
  * ```
@@ -149,7 +149,7 @@ function getWindow() {
149
149
  *
150
150
  * ```
151
151
  * <script type="module">
152
- * import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.14.1/dist/modules/dom/util.js';
152
+ * import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
153
153
  * console.log(getDocumentFragmentFromString('<div></div>'))
154
154
  * </script>
155
155
  * ```
@@ -199,5 +199,5 @@ function getDocumentFragmentFromString(html) {
199
199
  }
200
200
 
201
201
 
202
- Monster.assignToNamespace('Monster.DOM', getWindow, getDocument, getDocumentFragmentFromString);
202
+ assignToNamespace('Monster.DOM', getWindow, getDocument, getDocumentFragmentFromString);
203
203
  export {Monster, getWindow, getDocument, getDocumentFragmentFromString}