@schukai/monster 1.21.1 → 1.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CHANGELOG +48 -1
  2. package/README.md +4 -4
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +1 -1
  5. package/dist/modules/constraints/abstractoperator.js +1 -1
  6. package/dist/modules/constraints/andoperator.js +1 -1
  7. package/dist/modules/constraints/invalid.js +1 -1
  8. package/dist/modules/constraints/isarray.js +1 -1
  9. package/dist/modules/constraints/isobject.js +1 -1
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +1 -1
  12. package/dist/modules/constraints/valid.js +1 -1
  13. package/dist/modules/data/buildmap.js +1 -1
  14. package/dist/modules/data/datasource/namespace.js +2 -0
  15. package/dist/modules/data/datasource/restapi/writeerror.js +2 -0
  16. package/dist/modules/data/datasource/restapi.js +2 -0
  17. package/dist/modules/data/datasource/storage/localstorage.js +2 -0
  18. package/dist/modules/data/datasource/storage/namespace.js +2 -0
  19. package/dist/modules/data/datasource/storage/sessionstorage.js +2 -0
  20. package/dist/modules/data/datasource/storage.js +2 -0
  21. package/dist/modules/data/datasource.js +2 -0
  22. package/dist/modules/data/diff.js +2 -2
  23. package/dist/modules/data/extend.js +1 -1
  24. package/dist/modules/data/namespace.js +1 -1
  25. package/dist/modules/data/pathfinder.js +2 -2
  26. package/dist/modules/data/pipe.js +1 -1
  27. package/dist/modules/data/transformer.js +2 -2
  28. package/dist/modules/dom/assembler.js +1 -1
  29. package/dist/modules/dom/attributes.js +1 -1
  30. package/dist/modules/dom/constants.js +2 -2
  31. package/dist/modules/dom/customcontrol.js +2 -2
  32. package/dist/modules/dom/customelement.js +2 -2
  33. package/dist/modules/dom/events.js +1 -1
  34. package/dist/modules/dom/focusmanager.js +2 -0
  35. package/dist/modules/dom/locale.js +1 -1
  36. package/dist/modules/dom/namespace.js +1 -1
  37. package/dist/modules/dom/resource/data.js +2 -0
  38. package/dist/modules/dom/resource/link/stylesheet.js +2 -0
  39. package/dist/modules/dom/resource/link.js +2 -0
  40. package/dist/modules/dom/resource/script.js +2 -0
  41. package/dist/modules/dom/resource.js +2 -0
  42. package/dist/modules/dom/resourcemanager.js +2 -0
  43. package/dist/modules/dom/template.js +1 -1
  44. package/dist/modules/dom/theme.js +1 -1
  45. package/dist/modules/dom/updater.js +2 -2
  46. package/dist/modules/dom/util.js +1 -1
  47. package/dist/modules/dom/worker/factory.js +2 -0
  48. package/dist/modules/i18n/locale.js +1 -1
  49. package/dist/modules/i18n/namespace.js +1 -1
  50. package/dist/modules/i18n/provider.js +1 -1
  51. package/dist/modules/i18n/providers/fetch.js +2 -2
  52. package/dist/modules/i18n/providers/namespace.js +1 -1
  53. package/dist/modules/i18n/translations.js +1 -1
  54. package/dist/modules/logging/handler/console.js +1 -1
  55. package/dist/modules/logging/handler/namespace.js +1 -1
  56. package/dist/modules/logging/handler.js +1 -1
  57. package/dist/modules/logging/logentry.js +1 -1
  58. package/dist/modules/logging/logger.js +1 -1
  59. package/dist/modules/logging/namespace.js +1 -1
  60. package/dist/modules/math/namespace.js +1 -1
  61. package/dist/modules/math/random.js +2 -2
  62. package/dist/modules/monster.js +1 -1
  63. package/dist/modules/namespace.js +1 -1
  64. package/dist/modules/text/formatter.js +2 -2
  65. package/dist/modules/text/namespace.js +1 -1
  66. package/dist/modules/types/base.js +1 -1
  67. package/dist/modules/types/basewithoptions.js +2 -2
  68. package/dist/modules/types/binary.js +1 -1
  69. package/dist/modules/types/dataurl.js +1 -1
  70. package/dist/modules/types/global.js +1 -1
  71. package/dist/modules/types/id.js +1 -1
  72. package/dist/modules/types/is.js +1 -1
  73. package/dist/modules/types/mediatype.js +1 -1
  74. package/dist/modules/types/namespace.js +1 -1
  75. package/dist/modules/types/observer.js +1 -1
  76. package/dist/modules/types/observerlist.js +2 -2
  77. package/dist/modules/types/proxyobserver.js +2 -2
  78. package/dist/modules/types/queue.js +1 -1
  79. package/dist/modules/types/randomid.js +1 -1
  80. package/dist/modules/types/stack.js +1 -1
  81. package/dist/modules/types/tokenlist.js +2 -2
  82. package/dist/modules/types/typeof.js +1 -1
  83. package/dist/modules/types/uniquequeue.js +1 -1
  84. package/dist/modules/types/uuid.js +2 -0
  85. package/dist/modules/types/validate.js +1 -1
  86. package/dist/modules/types/version.js +2 -2
  87. package/dist/modules/util/clone.js +2 -2
  88. package/dist/modules/util/comparator.js +2 -2
  89. package/dist/modules/util/freeze.js +1 -1
  90. package/dist/modules/util/namespace.js +1 -1
  91. package/dist/modules/util/processing.js +2 -2
  92. package/dist/modules/util/trimspaces.js +2 -0
  93. package/dist/monster.dev.js +1499 -732
  94. package/dist/monster.dev.js.map +1 -1
  95. package/dist/monster.js +2 -2
  96. package/package.json +1 -1
  97. package/source/constants.js +16 -7
  98. package/source/constraints/andoperator.js +5 -5
  99. package/source/constraints/invalid.js +3 -3
  100. package/source/constraints/isarray.js +3 -3
  101. package/source/constraints/isobject.js +3 -3
  102. package/source/constraints/oroperator.js +5 -5
  103. package/source/constraints/valid.js +3 -3
  104. package/source/data/buildmap.js +6 -6
  105. package/source/data/datasource/namespace.js +16 -0
  106. package/source/data/datasource/restapi/writeerror.js +49 -0
  107. package/source/data/datasource/restapi.js +266 -0
  108. package/source/data/datasource/storage/localstorage.js +64 -0
  109. package/source/data/datasource/storage/namespace.js +16 -0
  110. package/source/data/datasource/storage/sessionstorage.js +61 -0
  111. package/source/data/datasource/storage.js +131 -0
  112. package/source/data/datasource.js +246 -0
  113. package/source/data/diff.js +8 -8
  114. package/source/data/extend.js +5 -5
  115. package/source/data/pathfinder.js +12 -6
  116. package/source/data/pipe.js +6 -5
  117. package/source/data/transformer.js +131 -24
  118. package/source/dom/assembler.js +2 -2
  119. package/source/dom/attributes.js +24 -24
  120. package/source/dom/constants.js +305 -12
  121. package/source/dom/customcontrol.js +40 -19
  122. package/source/dom/customelement.js +182 -103
  123. package/source/dom/events.js +6 -6
  124. package/source/dom/focusmanager.js +251 -0
  125. package/source/dom/locale.js +4 -3
  126. package/source/dom/resource/data.js +170 -0
  127. package/source/dom/resource/link/stylesheet.js +54 -0
  128. package/source/dom/resource/link.js +125 -0
  129. package/source/dom/resource/script.js +112 -0
  130. package/source/dom/resource.js +268 -0
  131. package/source/dom/resourcemanager.js +214 -0
  132. package/source/dom/template.js +40 -10
  133. package/source/dom/theme.js +3 -3
  134. package/source/dom/updater.js +114 -58
  135. package/source/dom/util.js +6 -6
  136. package/source/dom/worker/factory.js +134 -0
  137. package/source/i18n/locale.js +8 -8
  138. package/source/i18n/provider.js +4 -4
  139. package/source/i18n/providers/fetch.js +8 -13
  140. package/source/i18n/translations.js +6 -5
  141. package/source/logging/handler/console.js +2 -2
  142. package/source/logging/handler.js +2 -2
  143. package/source/logging/logentry.js +2 -2
  144. package/source/logging/logger.js +4 -4
  145. package/source/math/random.js +11 -5
  146. package/source/namespace.js +1 -1
  147. package/source/text/formatter.js +82 -7
  148. package/source/types/base.js +4 -4
  149. package/source/types/basewithoptions.js +10 -15
  150. package/source/types/binary.js +8 -8
  151. package/source/types/dataurl.js +6 -6
  152. package/source/types/global.js +9 -7
  153. package/source/types/id.js +2 -2
  154. package/source/types/is.js +23 -23
  155. package/source/types/mediatype.js +4 -4
  156. package/source/types/observer.js +3 -3
  157. package/source/types/observerlist.js +3 -3
  158. package/source/types/proxyobserver.js +24 -7
  159. package/source/types/queue.js +5 -5
  160. package/source/types/randomid.js +2 -2
  161. package/source/types/stack.js +2 -2
  162. package/source/types/tokenlist.js +8 -9
  163. package/source/types/typeof.js +3 -3
  164. package/source/types/uniquequeue.js +4 -4
  165. package/source/types/uuid.js +102 -0
  166. package/source/types/validate.js +20 -20
  167. package/source/types/version.js +6 -6
  168. package/source/util/clone.js +5 -6
  169. package/source/util/comparator.js +5 -5
  170. package/source/util/freeze.js +5 -5
  171. package/source/util/processing.js +33 -36
  172. package/source/util/trimspaces.js +85 -0
  173. package/test/cases/data/datasource/restapi.js +89 -0
  174. package/test/cases/data/datasource/storage/localstorage.js +47 -0
  175. package/test/cases/data/datasource/storage/sessionstorage.js +47 -0
  176. package/test/cases/data/datasource.js +60 -0
  177. package/test/cases/data/diff.js +4 -4
  178. package/test/cases/data/pathfinder.js +18 -9
  179. package/test/cases/data/pipe.js +26 -2
  180. package/test/cases/data/transformer.js +41 -10
  181. package/test/cases/dom/customcontrol.js +6 -5
  182. package/test/cases/dom/customelement.js +25 -26
  183. package/test/cases/dom/focusmanager.js +111 -0
  184. package/test/cases/dom/locale.js +1 -4
  185. package/test/cases/dom/resource/data.js +129 -0
  186. package/test/cases/dom/resource/link/stylesheet.js +101 -0
  187. package/test/cases/dom/resource/link.js +101 -0
  188. package/test/cases/dom/resource/script.js +115 -0
  189. package/test/cases/dom/resourcemanager.js +118 -0
  190. package/test/cases/dom/updater.js +42 -19
  191. package/test/cases/dom/worker/factory.js +63 -0
  192. package/test/cases/monster.js +1 -1
  193. package/test/cases/text/formatter.js +38 -6
  194. package/test/cases/types/proxyobserver.js +55 -11
  195. package/test/cases/types/uuid.js +42 -0
  196. package/test/cases/util/freeze.js +30 -4
  197. package/test/cases/util/trimspaces.js +24 -0
  198. package/test/util/cleanupdom.js +48 -0
  199. package/test/util/jsdom.js +23 -9
  200. package/test/util/localstorage.js +81 -0
  201. package/test/web/import.js +13 -0
  202. package/test/web/monster-dev.html +3 -3
  203. package/test/web/monster.html +2 -2
  204. package/test/web/test.html +3 -3
  205. package/test/web/tests.js +7 -7
package/CHANGELOG CHANGED
@@ -2,7 +2,54 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [1.21.1] - 2021-10-23
5
+ ## [1.25.0] - 2021-11-13
6
+
7
+ ## Added
8
+
9
+ - [new class FocusManager](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/93)
10
+ - [new class ResourceManager](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/92)
11
+ - [new class Resource, Link, Stylesheet, Data and Script](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/91)
12
+ - [new class UUID](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/89)
13
+
14
+ ## Changed
15
+
16
+ - [optimization of random](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/90)
17
+
18
+
19
+ ## [1.24.0] - 2021-11-13
20
+
21
+ ## Added
22
+
23
+ - [new class WriteError](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/79)
24
+ - [new transformer commands nth, first, last and nth-last](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/78)
25
+ - [add Proxyobserver.setObject](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/80)
26
+ - [transform: new debug, to-base64, from-base64, path-exists and optimzed default command](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/84)
27
+ - [new function trimSpace](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/86)
28
+
29
+ ## Changed
30
+
31
+ - [changeover to internalSymbol and uniform symbols and keys](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/81)
32
+ - [optimization of the datasources and the restapi](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/82)
33
+ - [optimization attribute monitoring](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/85)
34
+ - [Formatter: marker in marker](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/88)
35
+
36
+ ## [1.23.0] - 2021-10-28
37
+
38
+ ## Added
39
+
40
+ - [add the processing of slotted elements](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/76)
41
+
42
+ ## Changed
43
+
44
+ - [datasource should work with proxy data](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/77)
45
+
46
+ ## [1.22.0] - 2021-10-25
47
+
48
+ ## Added
49
+
50
+ - [new DataSource classes](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/75)
51
+
52
+ ## [1.22.0] - 2021-10-23
6
53
 
7
54
  ## Fixed
8
55
 
package/README.md CHANGED
@@ -40,7 +40,7 @@ For some functions you need additional [polyfills](#polyfill).
40
40
  <script type="module">
41
41
  import {
42
42
  Monster
43
- } from 'https://unpkg.com/@schukai/monster@1.21.1/dist/modules/monster.js';
43
+ } from 'https://unpkg.com/@schukai/monster@1.25.0/dist/modules/monster.js';
44
44
  let id = document.getElementById('version');
45
45
  id.innerHTML = Monster.getVersion();
46
46
  </script>
@@ -51,8 +51,8 @@ For some functions you need additional [polyfills](#polyfill).
51
51
  `nomodule` for backwards compatibility
52
52
 
53
53
  ```
54
- <script type="module" src="https://unpkg.com/@schukai/monster@1.21.1/dist/modules/monster.js"></script>
55
- <script nomodule src="https://unpkg.com/@schukai/monster@1.21.1/dist/monster.js"></script>
54
+ <script type="module" src="https://unpkg.com/@schukai/monster@1.25.0/dist/modules/monster.js"></script>
55
+ <script nomodule src="https://unpkg.com/@schukai/monster@1.25.0/dist/monster.js"></script>
56
56
  ```
57
57
  ### Polyfill
58
58
 
@@ -61,7 +61,7 @@ We do try to work around some browser bugs, but on the whole we don't use polyfi
61
61
  However, many functions can be mapped via [polyfill.io](https://polyfill.io/) and thus the compatibility can be increased.
62
62
 
63
63
  ```
64
- <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,MutationObserver,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.for,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
64
+ <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
65
65
  crossorigin="anonymous"
66
66
  referrerpolicy="no-referrer"></script>
67
67
  ```
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{Monster}from"./namespace.js";const PROPERTY_KEY_INTERNALDATA="monsterInternalData";export{Monster,PROPERTY_KEY_INTERNALDATA};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{Monster}from"./namespace.js";const internalSymbol=Symbol("internalData"),internalStateSymbol=Symbol("state");export{Monster,internalSymbol,internalStateSymbol};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";class AbstractConstraint extends Base{constructor(){super()}isValid(s){return Promise.reject(s)}}assignToNamespace("Monster.Constraints",AbstractConstraint);export{Monster,AbstractConstraint};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class AbstractOperator extends AbstractConstraint{constructor(t,r){if(super(),!(t instanceof AbstractConstraint&&r instanceof AbstractConstraint))throw new TypeError("parameters must be from type AbstractConstraint");this.operantA=t,this.operantB=r}}assignToNamespace("Monster.Constraints",AbstractOperator);export{Monster,AbstractOperator};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class AndOperator extends AbstractOperator{isValid(r){return Promise.all([this.operantA.isValid(r),this.operantB.isValid(r)])}}assignToNamespace("Monster.Constraints",AndOperator);export{Monster,AndOperator};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Invalid extends AbstractConstraint{isValid(s){return Promise.reject(s)}}assignToNamespace("Monster.Constraints",Invalid);export{Monster,Invalid};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsArray extends AbstractConstraint{isValid(s){return isArray(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsArray);export{Monster,IsArray};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsObject extends AbstractConstraint{isValid(s){return isObject(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsObject);export{Monster,IsObject};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";const namespace="Monster.Constraints";export{namespace};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class OrOperator extends AbstractOperator{isValid(s){var o=this;return new Promise(function(t,r){let a,e;o.operantA.isValid(s).then(function(){t()}).catch(function(){(a=!1)===e&&r()}),o.operantB.isValid(s).then(function(){t()}).catch(function(){(e=!1)===a&&r()})})}}assignToNamespace("Monster.Constraints",OrOperator);export{Monster,OrOperator};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Valid extends AbstractConstraint{isValid(s){return Promise.resolve(s)}}assignToNamespace("Monster.Constraints",Valid);export{Monster,Valid};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isFunction,isObject,isString}from"../types/is.js";import{validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{DELIMITER,Pathfinder,WILDCARD}from"./pathfinder.js";function buildMap(t,e,a,n,r){const o=new Map;let i;if(isFunction(e)){if(i=e(t),!(i instanceof Map))throw new TypeError("the selector callback must return a map")}else{if(!isString(e))throw new TypeError("value is neither a string nor a function");i=new Map,buildFlatMap.call(i,t,e)}return i instanceof Map&&i.forEach((t,e,i)=>{isFunction(r)&&!0!==r.call(i,t,e)||(e=build(t,n,e),t=build(t,a),o.set(e,t))}),o}function buildFlatMap(i,t,a,n){var r=this;const o=new Map;var e=r.size;void 0===a&&(a=[]);let l=t.split(DELIMITER),s,p=[];do{if(s=l.shift(),p.push(s),s===WILDCARD){let t=new Pathfinder(i),e;try{e=t.getVia(p.join(DELIMITER))}catch(t){e=new Map}for(const[d,h]of e){let e=clone(a);p.map(t=>{e.push(t===WILDCARD?d:t)});var c=e.join(DELIMITER);let t=buildFlatMap.call(r,h,l.join(DELIMITER),e,h);isObject(t)&&(t["^"]=n),o.set(c,t)}}}while(0<l.length);if(e===r.size)for(var[f,u]of o)r.set(f,u);return i}function build(t,a,n){if(void 0===a)return n||t;validateString(a);const e=[...a.matchAll(/(?<placeholder>\${(?<path>[a-z\^A-Z.\-_0-9]*)})/gm)];let r=new Pathfinder(t);return 0===e.length?r.getVia(a):(e.forEach(e=>{var i=e?.groups,e=i?.placeholder;if(void 0!==e){i=i?.path;let t=r.getVia(i);void 0===t&&(t=n),a=a.replaceAll(e,t)}}),a)}assignToNamespace("Monster.Data",buildMap);export{Monster,buildMap};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";const namespace="Monster.Data.Datasource";export{namespace};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../../constants.js";import{assignToNamespace,Monster}from"../../../namespace.js";class WriteError extends Error{constructor(r,e,t){super(r),this[internalSymbol]={response:e,validation:t}}getResponse(){return this[internalSymbol].response}getValidation(){return this[internalSymbol].validation}}assignToNamespace("Monster.Data.Datasource.RestAPI",WriteError);export{Monster,WriteError};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../constants.js";import{assignToNamespace,Monster}from"../../namespace.js";import{isObject}from"../../types/is.js";import{Datasource}from"../datasource.js";import{Pathfinder}from"../pathfinder.js";import{Pipe}from"../pipe.js";import{WriteError}from"./restapi/writeerror.js";class RestAPI extends Datasource{constructor(t,e){super();const r={};isObject(t)&&(r.read=t),isObject(e)&&(r.write=e),this.setOptions(r)}get defaults(){return Object.assign({},super.defaults,{write:{init:{method:"POST"},acceptedStatus:[200,201],url:void 0,mapping:{transformer:void 0,callbacks:[]},report:{path:void 0}},read:{init:{method:"GET"},acceptedStatus:[200],url:void 0,mapping:{transformer:void 0,callbacks:[]}}})}read(){const s=this;let n,t=s.getOption("read.init");return isObject(t)||(t={}),fetch(s.getOption("read.url"),t).then(t=>{n=t;const e=s.getOption("read.acceptedStatus",[200]);if(-1===e.indexOf(t.status))throw Error("the data cannot be read (response "+t.status+")");return t.text()}).then(e=>{let t;try{t=JSON.parse(e)}catch(t){throw 100<e.length&&(e=e.substring(0,97)+"..."),new Error("the response does not contain a valid json (actual: "+e+").")}e=s.getOption("read.mapping.transformer");if(void 0!==e){const r=new Pipe(e);t=r.run(t)}return s.set(t),n})}write(){const e=this;let t=e.getOption("write.init");isObject(t)||(t={}),"object"!=typeof t.headers&&(t.headers={"Content-Type":"application/json"});let r=e.get();var s=e.getOption("write.mapping.transformer");if(void 0!==s){const a=new Pipe(s);r=a.run(r)}var n=e.getOption("write.sheathing.object"),i=e.getOption("write.sheathing.path");let o=e.getOption("write.report.path");return n&&i&&(s=r,r=n,new Pathfinder(r).setVia(i,s)),t.body=JSON.stringify(r),fetch(e.getOption("write.url"),t).then(s=>{const t=e.getOption("write.acceptedStatus",[200,2001]);return-1===t.indexOf(s.status)?s.text().then(e=>{let t,r;try{t=JSON.parse(e),r=new Pathfinder(t).getVia(o)}catch(t){throw 100<e.length&&(e=e.substring(0,97)+"..."),new Error("the response does not contain a valid json (actual: "+e+").")}throw new WriteError("the data cannot be written (response "+s.status+")",s,r)}):s})}getClone(){return new RestAPI(this[internalSymbol].getRealSubject().options.read,this[internalSymbol].getRealSubject().options.write)}}assignToNamespace("Monster.Data.Datasource",RestAPI);export{Monster,RestAPI};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../../constants.js";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";class LocalStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("localStorage")}getClone(){return new LocalStorage(this[internalSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource.Storage",LocalStorage);export{Monster,LocalStorage};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";const namespace="Monster.Data.Datasource.Storage";export{namespace};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../../constants.js";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";class SessionStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("sessionStorage")}getClone(){return new SessionStorage(this[internalSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource.Storage",SessionStorage);export{Monster,SessionStorage};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../constants.js";import{assignToNamespace,Monster}from"../../namespace.js";import{validateString}from"../../types/validate.js";import{Datasource}from"../datasource.js";const storageObjectSymbol=Symbol("storageObject");class Storage extends Datasource{constructor(e){super(),this.setOption("key",validateString(e))}get defaults(){return Object.assign({},super.defaults,{key:void 0})}[storageObjectSymbol](){throw new Error("this method must be implemented by derived classes")}read(){const o=this,s=o[storageObjectSymbol]();return new Promise(function(e){var t=JSON.parse(s.getItem(o.getOption("key")));o.set(t??{}),e()})}write(){const o=this,s=o[storageObjectSymbol]();return new Promise(function(e){var t=o.get();void 0===t?s.removeItem(o.getOption("key")):s.setItem(o.getOption("key"),JSON.stringify(t)),e()})}getClone(){return new Storage(this[internalSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource",Storage);export{Monster,Storage,storageObjectSymbol};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{parseDataURL}from"../types/dataurl.js";import{isString}from"../types/is.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateObject}from"../types/validate.js";import{extend}from"./extend.js";import{Pathfinder}from"./pathfinder.js";const internalDataSymbol=Symbol("internalData");class Datasource extends Base{constructor(){super(),this[internalSymbol]=new ProxyObserver({options:extend({},this.defaults)}),this[internalDataSymbol]=new ProxyObserver({})}attachObserver(t){return this[internalDataSymbol].attachObserver(t),this}detachObserver(t){return this[internalDataSymbol].detachObserver(t),this}containsObserver(t){return this[internalDataSymbol].containsObserver(t)}get defaults(){return{}}setOption(t,e){return new Pathfinder(this[internalSymbol].getSubject().options).setVia(t,e),this}setOptions(t){isString(t)&&(t=parseOptionsJSON(t));var e=this;return extend(e[internalSymbol].getSubject().options,e.defaults,t),e}getOption(t,e){let r;try{r=new Pathfinder(this[internalSymbol].getRealSubject().options).getVia(t)}catch(t){}return void 0===r?e:r}read(){throw new Error("this method must be implemented by derived classes")}write(){throw new Error("this method must be implemented by derived classes")}get(){return this[internalDataSymbol].getRealSubject()}set(t){return this[internalDataSymbol].setSubject(t),this}}function parseOptionsJSON(e){if(isString(e)){try{e=parseDataURL(e).content}catch(t){}try{var t=JSON.parse(e);return validateObject(t),t}catch(t){throw new Error("the options does not contain a valid json definition (actual: "+e+").")}}return{}}assignToNamespace("Monster.Data",Datasource);export{Monster,Datasource};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function Diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeOf(t),s=typeOf(n);const a=e||[],i=o||[];return r!==s||"object"!==r&&"array"!==r?void 0!==(s=getOperator(t,n,r,s))&&i.push(buildResult(t,n,s,e)):getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],a.concat(e),i):i.push(buildResult(t[e],n[e],"delete",a.concat(e))):i.push(buildResult(t[e],n[e],"add",a.concat(e)))}),i}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}assignToNamespace("Monster.Data",Diff);export{Monster,Diff};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeOf(t),s=typeOf(n);const a=e||[],i=o||[];return r!==s||"object"!==r&&"array"!==r?void 0!==(s=getOperator(t,n,r,s))&&i.push(buildResult(t,n,s,e)):getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],a.concat(e),i):i.push(buildResult(t[e],n[e],"delete",a.concat(e))):i.push(buildResult(t[e],n[e],"add",a.concat(e)))}),i}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}assignToNamespace("Monster.Data",diff);export{Monster,diff};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function extend(){let e,t;for(t=0;t<arguments.length;t++){var r=arguments[t];if(!isObject(r)&&!isArray(r))throw new Error("unsupported argument "+JSON.stringify(r));if(void 0!==e)for(var s in r){var i=r?.[s];if(i!==e?.[s])if(isObject(i)&&"object"===typeOf(i)||isArray(i)){if(void 0===e[s])isArray(i)?e[s]=[]:e[s]={};else if(typeOf(e[s])!==typeOf(i))throw new Error("type mismatch: "+JSON.stringify(e[s])+"("+typeOf(e[s])+") != "+JSON.stringify(i)+"("+typeOf(i)+")");e[s]=extend(e[s],i)}else e[s]=i}else e=r}return e}assignToNamespace("Monster.Data",extend);export{Monster,extend};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";const namespace="Monster.Data";export{namespace};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInteger,isObject,isPrimitive}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInteger,validateString}from"../types/validate.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){if(super(),isPrimitive(t))throw new Error("the parameter must not be a simple type");this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a&&!e.hasOwnProperty(r))throw Error("unknown value");return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}assignToNamespace("Monster.Data",Pathfinder);export{DELIMITER,WILDCARD,Monster,Pathfinder};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInteger,isObject,isPrimitive}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInteger,validateString}from"../types/validate.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){if(super(),isPrimitive(t))throw new Error("the parameter must not be a simple type");this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a){a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),r);if(!e.hasOwnProperty(r)&&void 0===a)throw Error("unknown value")}return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}assignToNamespace("Monster.Data",Pathfinder);export{DELIMITER,WILDCARD,Monster,Pathfinder};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateString}from"../types/validate.js";import{Transformer}from"./transformer.js";const DELIMITER="|";class Pipe extends Base{constructor(e){super(),validateString(e),this.pipe=e.split(DELIMITER).map(e=>new Transformer(e))}setCallback(e,s,r){for(var[,t]of Object.entries(this.pipe))t.setCallback(e,s,r);return this}run(e){return this.pipe.reduce((e,s,r,t)=>s.run(e),e)}}assignToNamespace("Monster.Data",Pipe);export{Monster,Pipe};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobal}from"../types/global.js";import{ID}from"../types/id.js";import{isArray,isObject,isString}from"../types/is.js";import{validateFunction,validateInteger,validateObject,validatePrimitive,validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{Pathfinder}from"./pathfinder.js";class Transformer extends Base{constructor(e){super(),validateString(e),this.args=disassemble(e),this.command=this.args.shift(),this.callbacks=new Map}setCallback(e,t,r){return validateString(e),validateFunction(t),void 0!==r&&validateObject(r),this.callbacks.set(e,{callback:t,context:r}),this}run(e){return transform.apply(this,[e])}}function disassemble(e){validateString(e);let a=new Map;var t;for(t of e.matchAll(/((?<pattern>\\(?<char>.)){1})/gim)){var r,s,n=t?.groups;isObject(n)&&(s=n?.char,(r=n?.pattern)&&s&&(n="__"+(new ID).toString()+"__",a.set(n,s),e=e.replace(r,n)))}let i=e.split(":");return i=i.map(function(e){let t=e.trim();for(var r of a)t=t.replace(r[0],r[1]);return t}),i}function convertToString(e){return isObject(e)&&e.hasOwnProperty("toString")&&(e=e.toString()),validateString(e),e}function transform(s){let n=clone(this.args),i;switch(this.command){case"static":return this.args.join(":");case"tolower":case"strtolower":case"tolowercase":return validateString(s),s.toLowerCase();case"toupper":case"strtoupper":case"touppercase":return validateString(s),s.toUpperCase();case"tostring":return""+s;case"tointeger":var o=parseInt(s);return validateInteger(o),o;case"tojson":return JSON.stringify(s);case"fromjson":return JSON.parse(s);case"trim":return validateString(s),s.trim();case"rawurlencode":return validateString(s),encodeURIComponent(s).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A");case"call":let e;var c=n.shift();let t=getGlobal();return isObject(s)&&s.hasOwnProperty(c)?e=s[c]:this.callbacks.has(c)?(o=this.callbacks.get(c),e=o?.callback,t=o?.context):"object"==typeof window&&window.hasOwnProperty(c)&&(e=window[c]),validateFunction(e),n.unshift(s),e.call(t,...n);case"plain":case"plaintext":return validateString(s),(new DOMParser).parseFromString(s,"text/html").body.textContent||"";case"if":case"?":validatePrimitive(s);let r=n.shift()||void 0,a=n.shift()||void 0;return"value"===r&&(r=s),"\\value"===r&&(r="value"),"value"===a&&(a=s),"\\value"===a&&(a="value"),void 0!==s&&""!==s&&"off"!==s&&"false"!==s&&!1!==s||"on"===s||"true"===s||!0===s?r:a;case"ucfirst":return validateString(s),s.charAt(0).toUpperCase()+s.substr(1);case"ucwords":return validateString(s),s.replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g,function(e){return e.toUpperCase()});case"count":case"length":if((isString(s)||isObject(s)||isArray(s))&&s.hasOwnProperty("length"))return s.length;throw new TypeError("unsupported type "+typeof s);case"base64":return convertToString(s),btoa(s);case"empty":return"";case"undefined":return;case"prefix":return validateString(s),n?.[0]+s;case"suffix":return validateString(s),s+n?.[0];case"uniqid":return(new ID).toString();case"key":case"property":case"index":i=n.shift()||"undefined";var l=n.shift()||"";if(s instanceof Map)return s.has(i)?s.get(i):l;if(isObject(s)||isArray(s))return s?.[i]||l;throw new Error("type not supported");case"path":return i=n.shift()||"undefined",new Pathfinder(s).getVia(i);case"substring":validateString(s);c=parseInt(n[0])||0,l=(parseInt(n[1])||0)+c;return s.substring(c,l);case"nop":return s;case"default":return void 0!==s?s:n[0];default:throw new Error("unknown command "+this.command)}return s}assignToNamespace("Monster.Data",Transformer);export{Monster,Transformer};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobal,getGlobalObject}from"../types/global.js";import{ID}from"../types/id.js";import{isArray,isObject,isString}from"../types/is.js";import{validateFunction,validateInteger,validateObject,validatePrimitive,validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{Pathfinder}from"./pathfinder.js";class Transformer extends Base{constructor(e){super(),this.args=disassemble(e),this.command=this.args.shift(),this.callbacks=new Map}setCallback(e,t,r){return validateString(e),validateFunction(t),void 0!==r&&validateObject(r),this.callbacks.set(e,{callback:t,context:r}),this}run(e){return transform.apply(this,[e])}}function disassemble(e){validateString(e);let a=new Map;var t;for(t of e.matchAll(/((?<pattern>\\(?<char>.)){1})/gim)){var r,s,n=t?.groups;isObject(n)&&(s=n?.char,(r=n?.pattern)&&s&&(n="__"+(new ID).toString()+"__",a.set(n,s),e=e.replace(r,n)))}let i=e.split(":");return i=i.map(function(e){let t=e.trim();for(var r of a)t=t.replace(r[0],r[1]);return t}),i}function convertToString(e){return isObject(e)&&e.hasOwnProperty("toString")&&(e=e.toString()),validateString(e),e}function transform(i){const o=getGlobalObject("console");let c=clone(this.args),l,u;switch(this.command){case"static":return this.args.join(":");case"tolower":case"strtolower":case"tolowercase":return validateString(i),i.toLowerCase();case"toupper":case"strtoupper":case"touppercase":return validateString(i),i.toUpperCase();case"tostring":return""+i;case"tointeger":var p=parseInt(i);return validateInteger(p),p;case"tojson":return JSON.stringify(i);case"fromjson":return JSON.parse(i);case"trim":return validateString(i),i.trim();case"rawurlencode":return validateString(i),encodeURIComponent(i).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A");case"call":let e;var d=c.shift();let t=getGlobal();return isObject(i)&&i.hasOwnProperty(d)?e=i[d]:this.callbacks.has(d)?(p=this.callbacks.get(d),e=p?.callback,t=p?.context):"object"==typeof window&&window.hasOwnProperty(d)&&(e=window[d]),validateFunction(e),c.unshift(i),e.call(t,...c);case"plain":case"plaintext":return validateString(i),(new DOMParser).parseFromString(i,"text/html").body.textContent||"";case"if":case"?":validatePrimitive(i);let r=c.shift()||void 0,a=c.shift()||void 0;return"value"===r&&(r=i),"\\value"===r&&(r="value"),"value"===a&&(a=i),"\\value"===a&&(a="value"),void 0!==i&&""!==i&&"off"!==i&&"false"!==i&&!1!==i||"on"===i||"true"===i||!0===i?r:a;case"ucfirst":return validateString(i),i.charAt(0).toUpperCase()+i.substr(1);case"ucwords":return validateString(i),i.replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g,function(e){return e.toUpperCase()});case"count":case"length":if((isString(i)||isObject(i)||isArray(i))&&i.hasOwnProperty("length"))return i.length;throw new TypeError("unsupported type "+typeof i);case"to-base64":case"btoa":case"base64":return btoa(convertToString(i));case"atob":case"from-base64":return atob(convertToString(i));case"empty":return"";case"undefined":return;case"debug":return isObject(o)&&o.log(i),i;case"prefix":return validateString(i),c?.[0]+i;case"suffix":return validateString(i),i+c?.[0];case"uniqid":return(new ID).toString();case"first-key":case"last-key":case"nth-last-key":case"nth-key":if(!isObject(i))throw new Error("type not supported");var f=Object.keys(i).sort();"first-key"===this.command?l=0:"last-key"===this.command?l=f.length-1:(l=validateInteger(parseInt(c.shift())),"nth-last-key"===this.command&&(l=f.length-l-1)),u=c.shift()||"";var g=f?.[l];return i?.[g]?i?.[g]:u;case"key":case"property":case"index":if(l=c.shift()||void 0,void 0===l)throw new Error("missing key parameter");if(u=c.shift()||void 0,i instanceof Map)return i.has(l)?i.get(l):u;if(isObject(i)||isArray(i))return i?.[l]||u;throw new Error("type not supported");case"path-exists":if(l=c.shift(),void 0===l)throw new Error("missing key parameter");return new Pathfinder(i).exists(l);case"path":if(l=c.shift(),void 0===l)throw new Error("missing key parameter");let s=new Pathfinder(i);return s.exists(l)?s.getVia(l):void 0;case"substring":validateString(i);f=parseInt(c[0])||0,g=(parseInt(c[1])||0)+f;return i.substring(f,g);case"nop":return i;case"??":case"default":if(null!=i)return i;u=c.shift();let n=c.shift();switch(void 0===n&&(n="string"),n){case"int":case"integer":return parseInt(u);case"float":return parseFloat(u);case"undefined":return;case"bool":case"boolean":return u=u.toLowerCase(),"undefined"!==u&&""!==u&&"off"!==u&&"false"!==u&&"false"!==u||"on"===u||"true"===u||"true"===u;case"string":return""+u;case"object":return JSON.parse(atob(u))}throw new Error("type not supported");default:throw new Error("unknown command "+this.command)}return i}assignToNamespace("Monster.Data",Transformer);export{Monster,Transformer};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateInstance,validateString}from"../types/validate.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{getGlobalFunction}from"../types/global.js";import{TokenList}from"../types/tokenlist.js";import{validateInstance,validateString,validateSymbol}from"../types/validate.js";import{ATTRIBUTE_OBJECTLINK}from"./constants.js";function findClosestObjectLink(t){return findClosestByAttribute(t,ATTRIBUTE_OBJECTLINK)}function addToObjectLink(t,e,n){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]&&(t[e]=new Set),addAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),t[e].add(n),t}function removeObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]||(removeAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),delete t[e]),t}function hasObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0!==t?.[e]&&containsAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString())}function getLinkedObjects(t,e){if(validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e])throw new Error("there is no object link for "+e.toString());return t?.[e][Symbol.iterator]()}function toggleAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).toggle(n).toString()):t.setAttribute(e,n),t}function addAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).add(n).toString()):t.setAttribute(e,n),t}function removeAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).remove(n).toString()),t}function containsAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),!!t.hasAttribute(e)&&new TokenList(t.getAttribute(e)).contains(n)}function replaceAttributeToken(t,e,n,i){return validateInstance(t,HTMLElement),validateString(n),validateString(i),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).replace(n,i).toString()),t}function clearAttributeTokens(t,e){return validateInstance(t,HTMLElement),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,""),t}function findClosestByAttribute(t,e,n){if(validateInstance(t,getGlobalFunction("HTMLElement")),t.hasAttribute(e)&&t.getAttribute(e)===n)return t;let i=validateString(e);void 0!==n&&(i+="="+validateString(n));t=t.closest("["+i+"]");return t instanceof HTMLElement?t:void 0}assignToNamespace("Monster.DOM",getLinkedObjects,addToObjectLink,removeObjectLink,findClosestByAttribute,hasObjectLink,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken);export{Monster,addToObjectLink,removeObjectLink,hasObjectLink,findClosestByAttribute,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken,getLinkedObjects,findClosestObjectLink};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{Monster}from"../namespace.js";const ATTRIBUTE_PREFIX="data-monster-",ATTRIBUTE_OPTIONS=ATTRIBUTE_PREFIX+"options",DEFAULT_THEME="monster",ATTRIBUTE_THEME_PREFIX=ATTRIBUTE_PREFIX+"theme-",ATTRIBUTE_THEME_NAME=ATTRIBUTE_THEME_PREFIX+"name",ATTRIBUTE_UPDATER_ATTRIBUTES=ATTRIBUTE_PREFIX+"attributes",ATTRIBUTE_UPDATER_REPLACE=ATTRIBUTE_PREFIX+"replace",ATTRIBUTE_UPDATER_INSERT=ATTRIBUTE_PREFIX+"insert",ATTRIBUTE_UPDATER_INSERT_REFERENCE=ATTRIBUTE_PREFIX+"insert-reference",ATTRIBUTE_UPDATER_REMOVE=ATTRIBUTE_PREFIX+"remove",ATTRIBUTE_UPDATER_BIND=ATTRIBUTE_PREFIX+"bind",ATTRIBUTE_ROLE=ATTRIBUTE_PREFIX+"role",ATTRIBUTE_OBJECTLINK=ATTRIBUTE_PREFIX+"objectlink",OBJECTLINK_KEY_UPDATER="monsterUpdater";export{Monster,ATTRIBUTE_PREFIX,ATTRIBUTE_OPTIONS,DEFAULT_THEME,ATTRIBUTE_THEME_PREFIX,ATTRIBUTE_ROLE,ATTRIBUTE_THEME_NAME,ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_REPLACE,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_OBJECTLINK,OBJECTLINK_KEY_UPDATER};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{Monster}from"../namespace.js";const DEFAULT_THEME="monster",ATTRIBUTE_PREFIX="data-monster-",ATTRIBUTE_OPTIONS=ATTRIBUTE_PREFIX+"options",ATTRIBUTE_THEME_PREFIX=ATTRIBUTE_PREFIX+"theme-",ATTRIBUTE_THEME_NAME=ATTRIBUTE_THEME_PREFIX+"name",ATTRIBUTE_UPDATER_ATTRIBUTES=ATTRIBUTE_PREFIX+"attributes",ATTRIBUTE_UPDATER_REPLACE=ATTRIBUTE_PREFIX+"replace",ATTRIBUTE_UPDATER_INSERT=ATTRIBUTE_PREFIX+"insert",ATTRIBUTE_UPDATER_INSERT_REFERENCE=ATTRIBUTE_PREFIX+"insert-reference",ATTRIBUTE_UPDATER_REMOVE=ATTRIBUTE_PREFIX+"remove",ATTRIBUTE_UPDATER_BIND=ATTRIBUTE_PREFIX+"bind",ATTRIBUTE_ROLE=ATTRIBUTE_PREFIX+"role",ATTRIBUTE_DISABLED="disabled",ATTRIBUTE_VALUE="value",ATTRIBUTE_OBJECTLINK=ATTRIBUTE_PREFIX+"objectlink",ATTRIBUTE_ERRORMESSAGE=ATTRIBUTE_PREFIX+"error",objectUpdaterLinkSymbol=Symbol("monsterUpdater"),TAG_SCRIPT="script",TAG_STYLE="style",TAG_LINK="link",ATTRIBUTE_ID="id",ATTRIBUTE_CLASS="class",ATTRIBUTE_TITLE="title",ATTRIBUTE_SRC="src",ATTRIBUTE_HREF="href",ATTRIBUTE_TYPE="type",ATTRIBUTE_NONCE="nonce",ATTRIBUTE_TRANSLATE="translate",ATTRIBUTE_TABINDEX="tabindex",ATTRIBUTE_SPELLCHECK="spellcheck",ATTRIBUTE_SLOT="slot",ATTRIBUTE_PART="part",ATTRIBUTE_LANG="lang",ATTRIBUTE_ITEMTYPE="itemtype",ATTRIBUTE_ITEMSCOPE="itemscope",ATTRIBUTE_ITEMREF="itemref",ATTRIBUTE_ITEMID="itemid",ATTRIBUTE_ITEMPROP="itemprop",ATTRIBUTE_IS="is",ATTRIBUTE_INPUTMODE="inputmode",ATTRIBUTE_ACCESSKEY="accesskey",ATTRIBUTE_AUTOCAPITALIZE="autocapitalize",ATTRIBUTE_AUTOFOCUS="autofocus",ATTRIBUTE_CONTENTEDITABLE="contenteditable",ATTRIBUTE_DIR="dir",ATTRIBUTE_DRAGGABLE="draggable",ATTRIBUTE_ENTERKEYHINT="enterkeyhint",ATTRIBUTE_EXPORTPARTS="exportparts",ATTRIBUTE_HIDDEN="hidden";export{Monster,ATTRIBUTE_HIDDEN,ATTRIBUTE_EXPORTPARTS,ATTRIBUTE_ENTERKEYHINT,ATTRIBUTE_DRAGGABLE,ATTRIBUTE_DIR,ATTRIBUTE_CONTENTEDITABLE,ATTRIBUTE_AUTOFOCUS,ATTRIBUTE_AUTOCAPITALIZE,ATTRIBUTE_ACCESSKEY,TAG_SCRIPT,TAG_LINK,ATTRIBUTE_INPUTMODE,ATTRIBUTE_IS,ATTRIBUTE_ITEMPROP,ATTRIBUTE_ITEMID,ATTRIBUTE_ITEMREF,ATTRIBUTE_ITEMSCOPE,TAG_STYLE,ATTRIBUTE_ITEMTYPE,ATTRIBUTE_HREF,ATTRIBUTE_LANG,ATTRIBUTE_PART,ATTRIBUTE_SLOT,ATTRIBUTE_SPELLCHECK,ATTRIBUTE_SRC,ATTRIBUTE_TABINDEX,ATTRIBUTE_TRANSLATE,ATTRIBUTE_NONCE,ATTRIBUTE_TYPE,ATTRIBUTE_TITLE,ATTRIBUTE_CLASS,ATTRIBUTE_ID,ATTRIBUTE_PREFIX,ATTRIBUTE_OPTIONS,DEFAULT_THEME,ATTRIBUTE_THEME_PREFIX,ATTRIBUTE_ROLE,ATTRIBUTE_THEME_NAME,ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_REPLACE,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_OBJECTLINK,ATTRIBUTE_DISABLED,ATTRIBUTE_ERRORMESSAGE,ATTRIBUTE_VALUE,objectUpdaterLinkSymbol};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{extend}from"../data/extend.js";import{assignToNamespace,Monster}from"../namespace.js";import{CustomElement}from"./customelement.js";const internalSymbol=Symbol("internalSymbol");class CustomControl extends CustomElement{constructor(){super(),"function"==typeof this.attachInternals&&(this[internalSymbol]=this.attachInternals())}static get formAssociated(){return!0}get defaults(){return extend({},super.defaults)}get value(){throw Error("the value getter must be overwritten by the derived class")}set value(t){throw Error("the value setter must be overwritten by the derived class")}get labels(){return getInternal.call(this)?.labels}get name(){return this.getAttribute("name")}get type(){return this.constructor.getTag()}get validity(){return getInternal.call(this)?.validity}get validationMessage(){return getInternal.call(this)?.validationMessage}get willValidate(){return getInternal.call(this)?.willValidate}get states(){return getInternal.call(this)?.states}get form(){return getInternal.call(this)?.form}setFormValue(t,e){getInternal.call(this).setFormValue(t,e)}setValidity(t,e,r){getInternal.call(this).setValidity(t,e,r)}checkValidity(){return getInternal.call(this)?.checkValidity()}reportValidity(){return getInternal.call(this)?.reportValidity()}}function getInternal(){if(!(internalSymbol in this))throw new Error("ElementInternals is not supported and a polyfill is necessary");return this[internalSymbol]}assignToNamespace("Monster.DOM",CustomControl);export{Monster,CustomControl};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../data/extend.js";import{assignToNamespace,Monster}from"../namespace.js";import{ATTRIBUTE_VALUE}from"./constants.js";import{CustomElement,attributeObserverSymbol}from"./customelement.js";const attachedInternalSymbol=Symbol("attachedInternal");class CustomControl extends CustomElement{constructor(){super(),"function"==typeof this.attachInternals&&(this[attachedInternalSymbol]=this.attachInternals()),initObserver.call(this)}static get observedAttributes(){const t=super.observedAttributes;return t.push(ATTRIBUTE_VALUE),t}static get formAssociated(){return!0}get defaults(){return extend({},super.defaults)}get value(){throw Error("the value getter must be overwritten by the derived class")}set value(t){throw Error("the value setter must be overwritten by the derived class")}get labels(){return getInternal.call(this)?.labels}get name(){return this.getAttribute("name")}get type(){return this.constructor.getTag()}get validity(){return getInternal.call(this)?.validity}get validationMessage(){return getInternal.call(this)?.validationMessage}get willValidate(){return getInternal.call(this)?.willValidate}get states(){return getInternal.call(this)?.states}get form(){return getInternal.call(this)?.form}setFormValue(t,e){getInternal.call(this).setFormValue(t,e)}setValidity(t,e,r){getInternal.call(this).setValidity(t,e,r)}checkValidity(){return getInternal.call(this)?.checkValidity()}reportValidity(){return getInternal.call(this)?.reportValidity()}}function getInternal(){if(!(attachedInternalSymbol in this))throw new Error("ElementInternals is not supported and a polyfill is necessary");return this[attachedInternalSymbol]}function initObserver(){const t=this;t[attributeObserverSymbol].value=()=>{t.setOption("value",t.getAttribute("value"))}}assignToNamespace("Monster.DOM",CustomControl);export{Monster,CustomControl};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../constants.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{assignToNamespace,Monster}from"../namespace.js";import{parseDataURL}from"../types/dataurl.js";import{getGlobalObject}from"../types/global.js";import{isArray,isObject,isString}from"../types/is.js";import{Observer}from"../types/observer.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateFunction,validateInstance,validateObject}from"../types/validate.js";import{clone}from"../util/clone.js";import{addToObjectLink,getLinkedObjects,hasObjectLink}from"./attributes.js";import{ATTRIBUTE_OPTIONS,OBJECTLINK_KEY_UPDATER}from"./constants.js";import{findDocumentTemplate,Template}from"./template.js";import{Updater}from"./updater.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA),objectLinkSymbol=Symbol.for(OBJECTLINK_KEY_UPDATER),initMethodSymbol=Symbol("initMethodSymbol"),assembleMethodSymbol=Symbol("assembleMethodSymbol");class CustomElement extends HTMLElement{constructor(){super(),this[internalDataSymbol]=new ProxyObserver({options:extend({},this.defaults,getOptionsFromAttributes.call(this))}),initOptionObserver.call(this),this[initMethodSymbol]()}static get observedAttributes(){return[ATTRIBUTE_OPTIONS]}get defaults(){return{disabled:!1,shadowMode:"open",delegatesFocus:!0,templates:{main:void 0}}}static getTag(){throw new Error("the method getTag must be overwritten by the derived class.")}static getCSSStyleSheet(){}attachObserver(t){return this[internalDataSymbol].attachObserver(t),this}detachObserver(t){return this[internalDataSymbol].detachObserver(t),this}containsObserver(t){return this[internalDataSymbol].containsObserver(t)}getOption(t,e){let o;try{o=new Pathfinder(this[internalDataSymbol].getRealSubject().options).getVia(t)}catch(t){}return void 0===o?e:o}setOption(t,e){return new Pathfinder(this[internalDataSymbol].getSubject().options).setVia(t,e),this}setOptions(t){isString(t)&&(t=parseOptionsJSON(t));var e=this;return extend(e[internalDataSymbol].getSubject().options,e.defaults,t),e}[initMethodSymbol](){return this}[assembleMethodSymbol](){var t;let e;if(!1!==this.getOption("shadowMode",!1)){try{initShadowRoot.call(this),e=this.shadowRoot.childNodes}catch(t){}try{initCSSStylesheet.call(this)}catch(t){}}e instanceof NodeList||(initHtmlContent.call(this),e=this.childNodes);const o=new Set;addToObjectLink(this,objectLinkSymbol,o);for([,t]of Object.entries(e))if(t instanceof HTMLElement&&!(t instanceof HTMLTemplateElement)){const i=new Updater(t,clone(this[internalDataSymbol].getRealSubject().options));o.add(i),i.run().then(()=>{i.enableEventProcessing()})}return this.hasAttribute("disabled")&&this.setOption("disabled",!0),this}connectedCallback(){hasObjectLink(this,objectLinkSymbol)||this[assembleMethodSymbol]()}disconnectedCallback(){}adoptedCallback(){}attributeChangedCallback(t,e,o){t===ATTRIBUTE_OPTIONS&&this.setOptions(o)}hasNode(t){var e=this;return!!containChildNode.call(e,validateInstance(t,Node))||e.shadowRoot instanceof ShadowRoot&&containChildNode.call(e.shadowRoot,t)}}function containChildNode(t){var e;if(this.contains(t))return!0;for([,e]of Object.entries(this.childNodes)){if(e.contains(t))return!0;containChildNode.call(e,t)}return!1}function initOptionObserver(){const s=this;let i=void 0;s.attachObserver(new Observer(function(){var t=s.getOption("disabled");if(t!==i){if(s.shadowRoot instanceof ShadowRoot){var e,o=s.shadowRoot.querySelectorAll("button, command, fieldset, keygen, optgroup, option, select, textarea, input, [data-monster-objectlink]");for([,e]of Object.entries(o))!0===t?e.setAttribute("disabled",""):e.removeAttribute("disabled")}i=t}})),s.attachObserver(new Observer(function(){if(hasObjectLink(s,Symbol.for(OBJECTLINK_KEY_UPDATER)))for(const e of getLinkedObjects(s,Symbol.for(OBJECTLINK_KEY_UPDATER)))for(const o of e){var t=clone(s[internalDataSymbol].getRealSubject().options);Object.assign(o.getSubject(),t)}}));const t=new MutationObserver(function(t,e){for(const i of t)if("attributes"===i.type)switch(i?.attributeName){case"disabled":s.setOption("disabled",!!s.hasAttribute("disabled")||void 0);break;case ATTRIBUTE_OPTIONS:var o=getOptionsFromAttributes.call(s);isObject(o)&&s.setOptions(o)}});t.observe(this,{attributes:!0,attributeOldValue:!0,childList:!1,subtree:!1})}function getOptionsFromAttributes(){if(this.hasAttribute(ATTRIBUTE_OPTIONS))try{return parseOptionsJSON(this.getAttribute(ATTRIBUTE_OPTIONS))}catch(t){throw new Error("the options attribute "+ATTRIBUTE_OPTIONS+" does not contain a valid json definition (actual: "+this.getAttribute(ATTRIBUTE_OPTIONS)+").")}return{}}function parseOptionsJSON(e){if(isString(e)){try{e=parseDataURL(e).content}catch(t){}try{var t=JSON.parse(e);return validateObject(t),t}catch(t){throw new Error("the options does not contain a valid json definition (actual: "+e+").")}}return{}}function initHtmlContent(){try{let t=findDocumentTemplate(this.constructor.getTag());this.appendChild(t.createDocumentFragment())}catch(t){var e=this.getOption("templates.main","");isString(e)&&0<e.length&&(this.innerHTML=e)}return this}function initCSSStylesheet(){var t=this;if(!(this.shadowRoot instanceof ShadowRoot))return t;var e=this.constructor.getCSSStyleSheet();if(e instanceof CSSStyleSheet)this.shadowRoot.adoptedStyleSheets=[e];else if(isArray(e))this.shadowRoot.adoptedStyleSheets=e;else if(isString(e)){const o=t.shadowRoot.createElement("<style>");o.innerText=e,this.shadowRoot.adoptedStyleSheets=e}return t}function initShadowRoot(){let t,e;try{t=findDocumentTemplate(this.constructor.getTag())}catch(t){if(e=this.getOption("templates.main",""),!isString(e)||void 0===e||""===e)throw new Error("html is not set.")}return this.attachShadow({mode:this.getOption("shadowMode","open"),delegatesFocus:this.getOption("delegatesFocus",!0)}),t instanceof Template?this.shadowRoot.appendChild(t.createDocumentFragment()):this.shadowRoot.innerHTML=e,this}function registerCustomElement(t){validateFunction(t),getGlobalObject("customElements").define(t.getTag(),t)}assignToNamespace("Monster.DOM",CustomElement,registerCustomElement);export{Monster,registerCustomElement,CustomElement,initMethodSymbol,assembleMethodSymbol};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{assignToNamespace,Monster}from"../namespace.js";import{parseDataURL}from"../types/dataurl.js";import{getGlobalObject}from"../types/global.js";import{isArray,isFunction,isObject,isString}from"../types/is.js";import{Observer}from"../types/observer.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateFunction,validateInstance,validateObject}from"../types/validate.js";import{clone}from"../util/clone.js";import{addToObjectLink,getLinkedObjects,hasObjectLink}from"./attributes.js";import{ATTRIBUTE_DISABLED,ATTRIBUTE_OPTIONS,objectUpdaterLinkSymbol}from"./constants.js";import{findDocumentTemplate,Template}from"./template.js";import{Updater}from"./updater.js";const initMethodSymbol=Symbol("initMethodSymbol"),assembleMethodSymbol=Symbol("assembleMethodSymbol"),attributeObserverSymbol=Symbol("attributeObserver");class CustomElement extends HTMLElement{constructor(){super(),this[internalSymbol]=new ProxyObserver({options:extend({},this.defaults,getOptionsFromAttributes.call(this))}),this[attributeObserverSymbol]={},initOptionObserver.call(this),this[initMethodSymbol]()}static get observedAttributes(){return[ATTRIBUTE_OPTIONS,ATTRIBUTE_DISABLED]}get defaults(){return{ATTRIBUTE_DISABLED:this.getAttribute(ATTRIBUTE_DISABLED),shadowMode:"open",delegatesFocus:!0,templates:{main:void 0}}}static getTag(){throw new Error("the method getTag must be overwritten by the derived class.")}static getCSSStyleSheet(){}attachObserver(t){return this[internalSymbol].attachObserver(t),this}detachObserver(t){return this[internalSymbol].detachObserver(t),this}containsObserver(t){return this[internalSymbol].containsObserver(t)}getOption(t,e){let o;try{o=new Pathfinder(this[internalSymbol].getRealSubject().options).getVia(t)}catch(t){}return void 0===o?e:o}setOption(t,e){return new Pathfinder(this[internalSymbol].getSubject().options).setVia(t,e),this}setOptions(t){isString(t)&&(t=parseOptionsJSON(t));var e=this;return extend(e[internalSymbol].getSubject().options,e.defaults,t),e}[initMethodSymbol](){return this}[assembleMethodSymbol](){var t=this;let e,o;if(!1!==t.getOption("shadowMode",!1)){try{initShadowRoot.call(t),e=t.shadowRoot.childNodes}catch(t){}try{initCSSStylesheet.call(this)}catch(t){}}e instanceof NodeList||e instanceof NodeList||(initHtmlContent.call(this),e=this.childNodes);try{o=new Set([...e,...getSlottedElements.call(t)])}catch(t){o=e}return assignUpdaterToElement.call(t,o,clone(t[internalSymbol].getRealSubject().options)),t}connectedCallback(){hasObjectLink(this,objectUpdaterLinkSymbol)||this[assembleMethodSymbol]()}disconnectedCallback(){}adoptedCallback(){}attributeChangedCallback(t,e,o){const n=this[attributeObserverSymbol]?.[t];isFunction(n)&&n.call(this,o,e)}hasNode(t){var e=this;return!!containChildNode.call(e,validateInstance(t,Node))||e.shadowRoot instanceof ShadowRoot&&containChildNode.call(e.shadowRoot,t)}}function getSlottedElements(e){const o=new Set;if(!(this.shadowRoot instanceof ShadowRoot))return o;var t,n=this.shadowRoot.querySelectorAll("slot");for([,t]of Object.entries(n))t.assignedElements().forEach(function(t){t instanceof HTMLElement&&(void 0!==e?(t.querySelectorAll(e).forEach(function(t){o.add(t)}),t.matches(e)&&o.add(t)):o.add(t))});return o}function containChildNode(t){var e;if(this.contains(t))return!0;for([,e]of Object.entries(this.childNodes)){if(e.contains(t))return!0;containChildNode.call(e,t)}return!1}function initOptionObserver(){const s=this;let e=void 0;s.attachObserver(new Observer(function(){var t=s.getOption("disabled");if(t!==e&&(e=t,s.shadowRoot instanceof ShadowRoot)){var o="button, command, fieldset, keygen, optgroup, option, select, textarea, input, [data-monster-objectlink]",n=s.shadowRoot.querySelectorAll(o);let e;try{e=new Set([...n,...getSlottedElements.call(s,o)])}catch(t){e=n}for(const i of[...e])!0===t?i.setAttribute(ATTRIBUTE_DISABLED,""):i.removeAttribute(ATTRIBUTE_DISABLED)}})),s.attachObserver(new Observer(function(){if(hasObjectLink(s,objectUpdaterLinkSymbol))for(const e of getLinkedObjects(s,objectUpdaterLinkSymbol))for(const o of e){var t=clone(s[internalSymbol].getRealSubject().options);Object.assign(o.getSubject(),t)}})),s[attributeObserverSymbol][ATTRIBUTE_DISABLED]=t=>{s.hasAttribute(ATTRIBUTE_DISABLED)?s.setOption(ATTRIBUTE_DISABLED,!0):s.setOption(ATTRIBUTE_DISABLED,void 0)},s[attributeObserverSymbol][ATTRIBUTE_OPTIONS]=()=>{var t=getOptionsFromAttributes.call(s);isObject(t)&&s.setOptions(t)}}function getOptionsFromAttributes(){if(this.hasAttribute(ATTRIBUTE_OPTIONS))try{return parseOptionsJSON(this.getAttribute(ATTRIBUTE_OPTIONS))}catch(t){throw new Error("the options attribute "+ATTRIBUTE_OPTIONS+" does not contain a valid json definition (actual: "+this.getAttribute(ATTRIBUTE_OPTIONS)+").")}return{}}function parseOptionsJSON(e){if(isString(e)){try{e=parseDataURL(e).content}catch(t){}try{var t=JSON.parse(e);return validateObject(t),t}catch(t){throw new Error("the options does not contain a valid json definition (actual: "+e+").")}}return{}}function initHtmlContent(){try{let t=findDocumentTemplate(this.constructor.getTag());this.appendChild(t.createDocumentFragment())}catch(t){var e=this.getOption("templates.main","");isString(e)&&0<e.length&&(this.innerHTML=e)}return this}function initCSSStylesheet(){if(!(this.shadowRoot instanceof ShadowRoot))return this;var t=this.constructor.getCSSStyleSheet();if(t instanceof CSSStyleSheet)this.shadowRoot.adoptedStyleSheets=[t];else if(isArray(t))this.shadowRoot.adoptedStyleSheets=t;else if(isString(t)){const e=this.shadowRoot.createElement("<style>");e.innerText=t,this.shadowRoot.adoptedStyleSheets=t}return this}function initShadowRoot(){let t,e;try{t=findDocumentTemplate(this.constructor.getTag())}catch(t){if(e=this.getOption("templates.main",""),!isString(e)||void 0===e||""===e)throw new Error("html is not set.")}return this.attachShadow({mode:this.getOption("shadowMode","open"),delegatesFocus:this.getOption("delegatesFocus",!0)}),t instanceof Template?this.shadowRoot.appendChild(t.createDocumentFragment()):this.shadowRoot.innerHTML=e,this}function registerCustomElement(t){validateFunction(t),getGlobalObject("customElements").define(t.getTag(),t)}function assignUpdaterToElement(t,o){const n=new Set;t instanceof NodeList&&(t=new Set([...t]));let i=[];return t.forEach(t=>{if(t instanceof HTMLElement&&!(t instanceof HTMLTemplateElement)){const e=new Updater(t,o);n.add(e),i.push(e.run().then(()=>e.enableEventProcessing()))}}),0<n.size&&addToObjectLink(this,objectUpdaterLinkSymbol,n),i}assignToNamespace("Monster.DOM",CustomElement,registerCustomElement,assignUpdaterToElement);export{Monster,registerCustomElement,CustomElement,initMethodSymbol,assembleMethodSymbol,assignUpdaterToElement,attributeObserverSymbol};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray}from"../types/is.js";import{validateInstance,validateString}from"../types/validate.js";import{getDocument}from"./util.js";function fireEvent(e,t){var n;getDocument();if(e instanceof HTMLElement)"click"!==t?(n=new Event(validateString(t),{bubbles:!0,cancelable:!0}),e.dispatchEvent(n)):e.click();else{if(!(e instanceof HTMLCollection||e instanceof NodeList))throw new TypeError("value is not an instance of HTMLElement or HTMLCollection");for(var o of e)fireEvent(o,t)}}function findTargetElementFromEvent(e,t,n){if(validateInstance(e,Event),"function"!=typeof e.composedPath)throw new Error("unsupported event");var o=e.composedPath();if(isArray(o))for(let e=0;e<o.length;e++){const i=o[e];if(i instanceof HTMLElement&&i.hasAttribute(t)&&(void 0===n||i.getAttribute(t)===n))return i}}assignToNamespace("Monster.DOM",findTargetElementFromEvent,fireEvent);export{Monster,findTargetElementFromEvent,fireEvent};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../data/extend.js";import{assignToNamespace}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{getGlobalObject}from"../types/global.js";import{isArray}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInstance,validateString}from"../types/validate.js";const KEY_DOCUMENT="document",KEY_CONTEXT="context",stackSymbol=Symbol("stack");class FocusManager extends BaseWithOptions{constructor(t){super(t),validateInstance(this.getOption(KEY_DOCUMENT),HTMLDocument),this[stackSymbol]=new Stack}get defaults(){return extend({},super.defaults,{[KEY_DOCUMENT]:getGlobalObject("document"),[KEY_CONTEXT]:void 0})}storeFocus(){var t=this.getActive();return t instanceof Node&&this[stackSymbol].push(t),this}restoreFocus(){var t=this[stackSymbol].pop();return t instanceof Node&&this.focus(t),this}focus(t,e){return validateInstance(t,Node),t.focus({preventScroll:e??!1}),this}getActive(){return this.getOption(KEY_DOCUMENT).activeElement}getFocusable(e){let t=this.getOption(KEY_CONTEXT);return void 0===t&&(t=this.getOption(KEY_DOCUMENT)),validateInstance(t,Node),void 0!==e&&validateString(e),[...t.querySelectorAll('details, button, input, [tabindex]:not([tabindex="-1"]), select, textarea, a[href], body')].filter(t=>{if(void 0!==e&&!t.matches(e))return!1;if(t.hasAttribute("disabled"))return!1;if("true"===t.getAttribute("aria-hidden"))return!1;t=t.getBoundingClientRect();return 0!==t.width&&0!==t.height})}focusNext(t){var e,s=this.getActive();const i=this.getFocusable(t);return isArray(i)&&0!==i.length&&(s instanceof Node&&-1<(e=i.indexOf(s))?this.focus(i[e+1]||i[0]):this.focus(i[0])),this}focusPrev(t){var e,s=this.getActive();const i=this.getFocusable(t);return isArray(i)&&0!==i.length&&(s instanceof Node&&-1<(e=i.indexOf(s))?this.focus(i[e-1]||i[i.length-1]):this.focus(i[i.length-1])),this}}assignToNamespace("Monster.DOM",FocusManager);export{FocusManager};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{parseLocale}from"../i18n/locale.js";import{assignToNamespace,Monster}from"../namespace.js";import{getDocument}from"./util.js";const DEFAULT_LANGUAGE="en";function getLocaleOfDocument(){const e=getDocument();let t=e.querySelector("html");if(t instanceof HTMLElement&&t.hasAttribute("lang")){var o=t.getAttribute("lang");if(o)return new parseLocale(o)}return parseLocale(DEFAULT_LANGUAGE)}assignToNamespace("Monster.DOM",getLocaleOfDocument);export{Monster,getLocaleOfDocument};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";const namespace="Monster.DOM";export{namespace};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalStateSymbol}from"../../constants.js";import{extend}from"../../data/extend.js";import{assignToNamespace,Monster}from"../../namespace.js";import{getGlobalFunction}from"../../types/global.js";import{ATTRIBUTE_CLASS,ATTRIBUTE_ERRORMESSAGE,ATTRIBUTE_ID,ATTRIBUTE_SRC,ATTRIBUTE_TITLE,ATTRIBUTE_TYPE,TAG_SCRIPT}from"../constants.js";import{KEY_DOCUMENT,KEY_QUERY,referenceSymbol,Resource}from"../resource.js";class Data extends Resource{get defaults(){return extend({},super.defaults,{mode:"cors",credentials:"same-origin",type:"application/json"})}create(){return createElement.call(this),this}connect(){return this[referenceSymbol]instanceof HTMLElement||this.create(),appendToDocument.call(this),this}static getURLAttribute(){return ATTRIBUTE_SRC}}function createElement(){var e,t=this;const o=t.getOption(KEY_DOCUMENT);t[referenceSymbol]=o.createElement(TAG_SCRIPT);for(e of[ATTRIBUTE_TYPE,ATTRIBUTE_ID,ATTRIBUTE_CLASS,ATTRIBUTE_TITLE])void 0!==t.getOption(e)&&(t[referenceSymbol][e]=t.getOption(e));return t}function appendToDocument(){const t=this,o=document.querySelector(t.getOption(KEY_QUERY,"head"));if(!(o instanceof HTMLElement))throw new Error("target not found");return o.appendChild(t[referenceSymbol]),getGlobalFunction("fetch")(t.getOption(ATTRIBUTE_SRC),{method:"GET",mode:t.getOption("mode","cors"),cache:"no-cache",credentials:t.getOption("credentials","same-origin"),headers:{Accept:t.getOption("type","application/json")},redirect:"follow",referrerPolicy:"no-referrer"}).then(e=>e.text()).then(e=>{e=document.createTextNode(e);t[referenceSymbol].appendChild(e),t[internalStateSymbol].getSubject().loaded=!0}).catch(e=>{t[internalStateSymbol].setSubject({loaded:!0,error:e.toString()}),o.setAttribute(ATTRIBUTE_ERRORMESSAGE,e.toString())}),t}assignToNamespace("Monster.DOM.Resource",Data);export{Monster,Data};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../../../data/extend.js";import{assignToNamespace,Monster}from"../../../namespace.js";import{Link}from"../link.js";class Stylesheet extends Link{get defaults(){return extend({},super.defaults,{rel:"stylesheet"})}}assignToNamespace("Monster.DOM.Resource.Link",Stylesheet);export{Monster,Stylesheet};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../../data/extend.js";import{assignToNamespace,Monster}from"../../namespace.js";import{ATTRIBUTE_CLASS,ATTRIBUTE_HREF,ATTRIBUTE_ID,ATTRIBUTE_NONCE,ATTRIBUTE_SRC,ATTRIBUTE_TITLE,ATTRIBUTE_TYPE,TAG_LINK}from"../constants.js";import{KEY_DOCUMENT,referenceSymbol,Resource}from"../resource.js";class Link extends Resource{get defaults(){return extend({},super.defaults,{as:void 0,crossOrigin:"anonymous",disabled:void 0,href:void 0,hreflang:void 0,imagesizes:void 0,imagesrcset:void 0,integrity:void 0,media:void 0,prefetch:void 0,referrerpolicy:void 0,rel:void 0,sizes:void 0,type:void 0,nonce:void 0})}create(){return createElement.call(this),this}static getURLAttribute(){return ATTRIBUTE_HREF}}function createElement(){var e,r=this;const t=r.getOption(KEY_DOCUMENT);r[referenceSymbol]=t.createElement(TAG_LINK);for(e of["as","crossOrigin","disabled","href","hreflang","imagesizes","imagesrcset","integrity","media","prefetch","referrerpolicy","sizes","rel","type",ATTRIBUTE_HREF,ATTRIBUTE_ID,ATTRIBUTE_CLASS,ATTRIBUTE_TITLE,ATTRIBUTE_NONCE])void 0!==r.getOption(e)&&(r[referenceSymbol][e]=r.getOption(e));return r}assignToNamespace("Monster.DOM.Resource",Link);export{Monster,Link};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../../data/extend.js";import{assignToNamespace,Monster}from"../../namespace.js";import{ATTRIBUTE_CLASS,ATTRIBUTE_ID,ATTRIBUTE_NONCE,ATTRIBUTE_SRC,ATTRIBUTE_TITLE,ATTRIBUTE_TYPE,TAG_SCRIPT}from"../constants.js";import{KEY_DOCUMENT,referenceSymbol,Resource}from"../resource.js";class Script extends Resource{get defaults(){return extend({},super.defaults,{async:!0,crossOrigin:"anonymous",defer:!1,integrity:void 0,nomodule:!1,nonce:void 0,referrerpolicy:void 0,type:"text/javascript"})}create(){return createElement.call(this),this}static getURLAttribute(){return ATTRIBUTE_SRC}}function createElement(){var e,r=this;const t=r.getOption(KEY_DOCUMENT);r[referenceSymbol]=t.createElement(TAG_SCRIPT);for(e of["crossOrigin","defer","async","integrity","nomodule",ATTRIBUTE_NONCE,"referrerpolicy",ATTRIBUTE_TYPE,ATTRIBUTE_SRC,ATTRIBUTE_ID,ATTRIBUTE_CLASS,ATTRIBUTE_TITLE])void 0!==r.getOption(e)&&(r[referenceSymbol][e]=r.getOption(e));return r}assignToNamespace("Monster.DOM.Resource",Script);export{Monster,Script};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalStateSymbol,internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{assignToNamespace,Monster}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{getGlobalObject}from"../types/global.js";import{ID}from"../types/id.js";import{isString}from"../types/is.js";import{Observer}from"../types/observer.js";import{ProxyObserver}from"../types/proxyobserver.js";import{ATTRIBUTE_CLASS,ATTRIBUTE_ID,ATTRIBUTE_TITLE}from"./constants.js";const KEY_DOCUMENT="document",KEY_QUERY="query",KEY_TIMEOUT="timeout",referenceSymbol=Symbol("reference");class Resource extends BaseWithOptions{constructor(e){super(e);let t=this.getOption(this.constructor.getURLAttribute());if(void 0===t)throw new Error("missing source");if(t instanceof URL)t=t.toString();else if(!isString(t))throw new Error("unsupported url type");this[internalSymbol][this.constructor.getURLAttribute()]=t,this[internalStateSymbol]=new ProxyObserver({loaded:!1,error:void 0}),this[referenceSymbol]=void 0}isConnected(){return this[referenceSymbol]instanceof HTMLElement&&this[referenceSymbol].isConnected}create(){throw new Error("this method must be implemented by derived classes")}connect(){return this[referenceSymbol]instanceof HTMLElement||this.create(),appendToDocument.call(this),this}get defaults(){return extend({},super.defaults,{[this.constructor.getURLAttribute()]:void 0,[KEY_DOCUMENT]:getGlobalObject("document"),[KEY_QUERY]:"head",[KEY_TIMEOUT]:1e4,[ATTRIBUTE_ID]:new ID("resource").toString(),[ATTRIBUTE_CLASS]:void 0,[ATTRIBUTE_TITLE]:void 0})}available(){const n=this;return n[referenceSymbol]instanceof HTMLElement?n.isConnected()?!0===n[internalStateSymbol].getSubject().loaded?void 0!==n[internalStateSymbol].getSubject().error?Promise.reject(n[internalStateSymbol].getSubject().error):Promise.resolve():new Promise(function(e,t){const r=setTimeout(()=>{t("timeout")},n.getOption("timeout")),o=new Observer(()=>{clearTimeout(r),n[internalStateSymbol].detachObserver(o),e()});n[internalStateSymbol].attachObserver(o)}):Promise.reject("element not connected"):Promise.reject("no element")}static getURLAttribute(){throw new Error("this method must be implemented by derived classes")}}function appendToDocument(){var e=this;const t=document.querySelector(e.getOption(KEY_QUERY,"head"));if(!(t instanceof HTMLElement))throw new Error("target not found");return addEvents.call(e),t.appendChild(e[referenceSymbol]),e}function addEvents(){const e=this,t=()=>{e[referenceSymbol].removeEventListener("error",t),e[referenceSymbol].removeEventListener("load",r),e[internalStateSymbol].setSubject({loaded:!0,error:e[referenceSymbol][e.constructor.getURLAttribute()]+" is not available"})},r=()=>{e[referenceSymbol].removeEventListener("error",t),e[referenceSymbol].removeEventListener("load",r),e[internalStateSymbol].getSubject().loaded=!0};return e[referenceSymbol].addEventListener("load",r,!1),e[referenceSymbol].addEventListener("error",t,!1),e}assignToNamespace("Monster.DOM",Resource);export{KEY_DOCUMENT,KEY_QUERY,KEY_TIMEOUT,referenceSymbol,Monster,Resource};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{extend}from"../data/extend.js";import{assignToNamespace,Monster}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{getGlobalObject}from"../types/global.js";import{isArray}from"../types/is.js";import{ATTRIBUTE_HREF,ATTRIBUTE_SRC}from"./constants.js";import{Resource}from"./resource.js";import{Data}from"./resource/data.js";import{Stylesheet}from"./resource/link/stylesheet.js";import{Script}from"./resource/script.js";class ResourceManager extends BaseWithOptions{constructor(e){if(super(e),!(this.getOption("document")instanceof Document))throw new Error("unsupported document type")}getBaseURL(){this.getOption("document")}get defaults(){return Object.assign({},super.defaults,{document:getGlobalObject("document"),resources:{scripts:[],stylesheets:[],data:[]}})}connect(){return runResourceMethod.call(this,"connect"),this}available(){return Promise.all(runResourceMethod.call(this,"available"))}addScript(e,t){return addResource.call(this,"scripts",e,t)}addStylesheet(e,t){return addResource.call(this,"stylesheets",e,t)}addData(e,t){return addResource.call(this,"data",e,t)}}function runResourceMethod(e){const t=[];for(const r of["scripts","stylesheets","data"]){var s=this.getOption("resources."+r);if(isArray(s))for(const o of s){if(!(o instanceof Resource))throw new Error("unsupported resource definition");t.push(o[e]())}}return t}function addResource(e,t,s){t instanceof URL&&(t=t.toString()),s=s||{};let r;switch(e){case"scripts":r=new Script(extend({},s,{[ATTRIBUTE_SRC]:t}));break;case"stylesheets":r=new Stylesheet(extend({},s,{[ATTRIBUTE_HREF]:t}));break;case"data":r=new Data(extend({},s,{[ATTRIBUTE_SRC]:t}));break;default:throw new Error("unsupported type "+e)}return(this.getOption("resources")?.[e]).push(r),this}assignToNamespace("Monster.DOM",ResourceManager);export{Monster,ResourceManager};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction,getGlobalObject}from"../types/global.js";import{validateInstance,validateString}from"../types/validate.js";import{getDocumentTheme}from"./theme.js";class Template extends Base{constructor(e){super();var t=getGlobalFunction("HTMLTemplateElement");validateInstance(e,t),this.template=e}getTemplateElement(){return this.template}createDocumentFragment(){return this.template.content.cloneNode(!0)}}function findDocumentTemplate(e,t){validateString(e),t instanceof Document||t instanceof DocumentFragment||(t instanceof Node&&((t=t.getRootNode())instanceof Document||t instanceof DocumentFragment||(t=t.ownerDocument)),t instanceof Document||t instanceof DocumentFragment||(t=getGlobalObject("document")));var n=getGlobalFunction("HTMLTemplateElement");let o=getDocumentTheme();var a=e+"-"+o.getName();let m=t.getElementById(a);if(m instanceof n)return new Template(m);if(m=t.getElementById(e),m instanceof n)return new Template(m);if(t!==getGlobalObject("document"))return findDocumentTemplate(e);throw new Error("template "+e+" not found.")}assignToNamespace("Monster.DOM",Template,findDocumentTemplate);export{Monster,Template,findDocumentTemplate};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalObject}from"../types/global.js";import{validateString}from"../types/validate.js";import{ATTRIBUTE_THEME_NAME,DEFAULT_THEME}from"./constants.js";class Theme extends Base{constructor(e){super(),validateString(e),this.name=e}getName(){return this.name}}function getDocumentTheme(){let e=getGlobalObject("document"),t=DEFAULT_THEME,s=e.querySelector("html");var m;return s instanceof HTMLElement&&((m=s.getAttribute(ATTRIBUTE_THEME_NAME))&&(t=m)),new Theme(t)}assignToNamespace("Monster.DOM",Theme,getDocumentTheme);export{Monster,Theme,getDocumentTheme};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
- "use strict";import{Diff}from"../data/diff.js";import{Pathfinder}from"../data/pathfinder.js";import{Pipe}from"../data/pipe.js";import{ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_REPLACE}from"../dom/constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInstance,isIterable}from"../types/is.js";import{Observer}from"../types/observer.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateArray,validateInstance}from"../types/validate.js";import{clone}from"../util/clone.js";import{findDocumentTemplate}from"./template.js";import{getDocument}from"./util.js";class Updater extends Base{constructor(e,t){super(),this.element=validateInstance(e,HTMLElement);t=void 0===t?{}:t;isInstance(t,ProxyObserver)||(t=new ProxyObserver(t)),this.last={},this.callbacks=new Map,this.callbacks.set("checkstate",getCheckStateCallback.call(this)),this.subject=t.attachObserver(new Observer(()=>{var e,t=this.subject.getRealSubject(),r=Diff(this.last,t);this.last=clone(t);for([,e]of Object.entries(r))removeElement.call(this,e),insertElement.call(this,e),updateContent.call(this,e),updateAttributes.call(this,e)})),this.eventTypes=["keyup","click","change","drop","touchend","input"]}setEventTypes(e){return this.eventTypes=validateArray(e),this}enableEventProcessing(){this.disableEventProcessing();for(const e of this.eventTypes)this.element.addEventListener(e,getControlEventHandler.call(this));return this}disableEventProcessing(){for(const e of this.eventTypes)this.element.removeEventListener(e,getControlEventHandler.call(this));return this}run(){return this.last={__init__:!0},this.subject.notifyObservers()}getSubject(){return this.subject.getSubject()}setCallback(e,t){return this.callbacks.set(e,t),this}}function getCheckStateCallback(){return function(e){if(this instanceof HTMLInputElement){if(-1!==["radio","checkbox"].indexOf(this.type))return this.value+""==e+""?"true":void 0}else if(this instanceof HTMLOptionElement&&isArray(e)&&-1!==e.indexOf(this.value))return"true"}}const symbol=Symbol("EventHandler");function getControlEventHandler(){const i=this;if(i[symbol])return i[symbol];const a=new Pathfinder(this.subject.getSubject());return i[symbol]=r=>{const s=r.target;if(s.hasAttribute(ATTRIBUTE_UPDATER_BIND)){let e=s.getAttribute(ATTRIBUTE_UPDATER_BIND);if(0!==e.indexOf("path:"))throw new Error("the bind argument must start as a value with a path.");e=e.substr(5);let t;if(s instanceof HTMLInputElement)t="checkbox"!==s.type||s.checked?s.value:void 0;else if(s instanceof HTMLTextAreaElement)t=s.value;else if(s instanceof HTMLSelectElement)switch(s.type){case"select-one":t=s.value;break;case"select-multiple":t=s.value;let e=s?.selectedOptions;void 0===e&&(e=s.querySelectorAll(":scope option:checked")),t=Array.from(e).map(({value:e})=>e)}else{if(!(s?.constructor?.prototype&&Object.getOwnPropertyDescriptor(s.constructor.prototype,"value")?.get||s.hasOwnProperty("value")))throw new Error("unsupported object");t=s?.value}r=clone(i.subject.getRealSubject());const n=new Pathfinder(r);n.setVia(e,t),0<new Diff(r,i.subject.getRealSubject()).length&&a.setVia(e,t)}},i[symbol]}function removeElement(e){for(var[,t]of this.element.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_REMOVE+"]").entries())t.parentNode.removeChild(t)}function insertElement(t){var a=this.subject.getRealSubject();getDocument();let o=new WeakSet,r=0;for(;;){let i=!1;r++;let e=clone(t?.path);if(!isArray(e))return this;for(;0<e.length;){var l,s=e.join(".");for([,l]of this.element.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_INSERT+'*="path:'+s+'"]').entries())if(!o.has(l)){o.add(l),i=!0;const m=l.getAttribute(ATTRIBUTE_UPDATER_INSERT);let e=m.trim();var c=e.indexOf(" "),T=e.substr(0,c).trim(),u=T+"-";let t=e.substr(c).trim();if(0<t.indexOf("|"))throw new Error("pipes are not allowed when cloning a node.");let r=new Pipe(t);this.callbacks.forEach((e,t)=>{r.setCallback(t,e)});var E,p,c=r.run(a),f=t.split(":").pop();let s;if(l.hasChildNodes()&&(s=l.lastChild),!isIterable(c))throw new Error("the value is not iterable");let n=new Set;for([E,p]of Object.entries(c)){var h=u+E,d=f+"."+E;n.add(h);var A=l.querySelector("["+ATTRIBUTE_UPDATER_INSERT_REFERENCE+'="'+h+'"]');A instanceof HTMLElement?s=A:appendNewDocumentFragment(l,T,h,d)}var b,c=l.querySelectorAll("["+ATTRIBUTE_UPDATER_INSERT_REFERENCE+'*="'+u+'"]');for([,b]of Object.entries(c))n.has(b.getAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE))||l.removeChild(b)}e.pop()}if(!1===i)break;if(200<r++)throw new Error("the maximum depth for the recursion is reached.")}}function appendNewDocumentFragment(e,t,r,s){let n=findDocumentTemplate(t,e);var i,a=n.createDocumentFragment();for([,i]of Object.entries(a.childNodes))i instanceof HTMLElement&&(applyRecursive(i,t,s),i.setAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE,r)),e.appendChild(i)}function applyRecursive(t,r,s){if(t instanceof HTMLElement){if(t.hasAttribute(ATTRIBUTE_UPDATER_REPLACE)){let e=t.getAttribute(ATTRIBUTE_UPDATER_REPLACE);t.setAttribute(ATTRIBUTE_UPDATER_REPLACE,e.replace("path:"+r,"path:"+s))}if(t.hasAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES)){let e=t.getAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES);t.setAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES,e.replace("path:"+r,"path:"+s))}for(var[,e]of Object.entries(t.childNodes))applyRecursive(e,r,s)}}function updateContent(e){var t=this.subject.getRealSubject(),e=clone(e?.path);runUpdateContent.call(this,this.element,e,t)}function runUpdateContent(t,r,s){if(isArray(r)){r=clone(r);let e=new WeakSet;for(;0<r.length;){var n,i=r.join(".");r.pop();for([,n]of t.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_REPLACE+'^="path:'+i+'"], ['+ATTRIBUTE_UPDATER_REPLACE+'^="static:"]').entries())if(!e.has(n)){e.add(n);const o=n.getAttribute(ATTRIBUTE_UPDATER_REPLACE);var a=o.trim();let r=new Pipe(a);this.callbacks.forEach((e,t)=>{r.setCallback(t,e)});a=r.run(s);if(a instanceof HTMLElement){for(;n.firstChild;)n.removeChild(n.firstChild);n.addNode(a)}else n.innerHTML=a}}}}function updateAttributes(e){var t=this.subject.getRealSubject(),e=clone(e?.path);runUpdateAttributes.call(this,this.element,e,t)}function runUpdateAttributes(t,r,s){if(isArray(r)){r=clone(r);let e=new WeakSet;for(;0<r.length;){var n=r.join(".");r.pop();for(const[,l]of t.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_ATTRIBUTES+'*="path:'+n+'"]').entries())if(!e.has(l)){e.add(l);const c=l.getAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES);for(var[,i]of Object.entries(c.split(","))){i=i.trim();var a=i.indexOf(" "),o=i.substr(0,a).trim(),a=i.substr(a).trim();let r=new Pipe(a);this.callbacks.forEach((e,t)=>{r.setCallback(t,e,l)});a=r.run(s);void 0===a?l.removeAttribute(o):l.getAttribute(o)!==a&&l.setAttribute(o,a),handleInputControlAttributeUpdate.call(this,l,o,a)}}}}}function handleInputControlAttributeUpdate(e,t,r){if(e instanceof HTMLSelectElement)switch(e.type){case"select-multiple":for(var[s,n]of Object.entries(e.options))-1!==r.indexOf(n.value)?n.selected=!0:n.selected=!1;break;case"select-one":for(var[i,a]of Object.entries(e.options))if(a.value===r){e.selectedIndex=i;break}}else if(e instanceof HTMLInputElement)switch(e.type){case"radio":case"checkbox":e.checked="checked"===t&&void 0!==r;break;default:"value"===t&&(e.value=void 0===r?"":r)}else e instanceof HTMLTextAreaElement&&"value"===t&&(e.value=void 0===r?"":r)}assignToNamespace("Monster.DOM",Updater);export{Monster,Updater};
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{diff}from"../data/diff.js";import{Pathfinder}from"../data/pathfinder.js";import{Pipe}from"../data/pipe.js";import{ATTRIBUTE_ERRORMESSAGE,ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_REPLACE}from"../dom/constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInstance,isIterable}from"../types/is.js";import{Observer}from"../types/observer.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateArray,validateInstance}from"../types/validate.js";import{clone}from"../util/clone.js";import{trimSpaces}from"../util/trimspaces.js";import{findDocumentTemplate}from"./template.js";import{getDocument}from"./util.js";class Updater extends Base{constructor(e,t){super(),this.element=validateInstance(e,HTMLElement);t=void 0===t?{}:t;isInstance(t,ProxyObserver)||(t=new ProxyObserver(t)),this.last={},this.callbacks=new Map,this.callbacks.set("checkstate",getCheckStateCallback.call(this)),this.subject=t.attachObserver(new Observer(()=>{var e,t=this.subject.getRealSubject(),r=diff(this.last,t);this.last=clone(t);for([,e]of Object.entries(r))removeElement.call(this,e),insertElement.call(this,e),updateContent.call(this,e),updateAttributes.call(this,e)})),this.eventTypes=["keyup","click","change","drop","touchend","input"]}setEventTypes(e){return this.eventTypes=validateArray(e),this}enableEventProcessing(){this.disableEventProcessing();for(const e of this.eventTypes)this.element.addEventListener(e,getControlEventHandler.call(this));return this}disableEventProcessing(){for(const e of this.eventTypes)this.element.removeEventListener(e,getControlEventHandler.call(this));return this}run(){return this.last={__init__:!0},this.subject.notifyObservers()}getSubject(){return this.subject.getSubject()}setCallback(e,t){return this.callbacks.set(e,t),this}}function getCheckStateCallback(){return function(e){if(this instanceof HTMLInputElement){if(-1!==["radio","checkbox"].indexOf(this.type))return this.value+""==e+""?"true":void 0}else if(this instanceof HTMLOptionElement&&isArray(e)&&-1!==e.indexOf(this.value))return"true"}}const symbol=Symbol("EventHandler");function getControlEventHandler(){const i=this;if(i[symbol])return i[symbol];const n=new Pathfinder(this.subject.getSubject());return i[symbol]=r=>{const s=r.target;if(s.hasAttribute(ATTRIBUTE_UPDATER_BIND)){let e=s.getAttribute(ATTRIBUTE_UPDATER_BIND);if(0!==e.indexOf("path:"))throw new Error("the bind argument must start as a value with a path.");e=e.substr(5);let t;if(s instanceof HTMLInputElement)t="checkbox"!==s.type||s.checked?s.value:void 0;else if(s instanceof HTMLTextAreaElement)t=s.value;else if(s instanceof HTMLSelectElement)switch(s.type){case"select-one":t=s.value;break;case"select-multiple":t=s.value;let e=s?.selectedOptions;void 0===e&&(e=s.querySelectorAll(":scope option:checked")),t=Array.from(e).map(({value:e})=>e)}else{if(!(s?.constructor?.prototype&&Object.getOwnPropertyDescriptor(s.constructor.prototype,"value")?.get||s.hasOwnProperty("value")))throw new Error("unsupported object");t=s?.value}r=clone(i.subject.getRealSubject());const a=new Pathfinder(r);a.setVia(e,t),0<diff(r,i.subject.getRealSubject()).length&&n.setVia(e,t)}},i[symbol]}function removeElement(e){for(var[,t]of this.element.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_REMOVE+"]").entries())t.parentNode.removeChild(t)}function insertElement(t){var o=this.subject.getRealSubject();getDocument();let l=new WeakSet,r=0;for(;;){let n=!1;r++;let e=clone(t?.path);if(!isArray(e))return this;for(;0<e.length;){var c,s=e.join(".");for([,c]of this.element.querySelectorAll(":scope ["+ATTRIBUTE_UPDATER_INSERT+'*="path:'+s+'"]').entries())if(!l.has(c)){l.add(c),n=!0;var T=c.getAttribute(ATTRIBUTE_UPDATER_INSERT);let e=trimSpaces(T);var T=e.indexOf(" "),E=trimSpaces(e.substr(0,T)),u=E+"-";let t=trimSpaces(e.substr(T));if(0<t.indexOf("|"))throw new Error("pipes are not allowed when cloning a node.");let r=new Pipe(t);this.callbacks.forEach((e,t)=>{r.setCallback(t,e)});let s;try{c.removeAttribute(ATTRIBUTE_ERRORMESSAGE),s=r.run(o)}catch(e){c.setAttribute(ATTRIBUTE_ERRORMESSAGE,e.message)}var p,h,f=t.split(":").pop();let a;if(c.hasChildNodes()&&(a=c.lastChild),!isIterable(s))throw new Error("the value is not iterable");let i=new Set;for([p,h]of Object.entries(s)){var A=u+p,R=f+"."+p;i.add(A);var d=c.querySelector("["+ATTRIBUTE_UPDATER_INSERT_REFERENCE+'="'+A+'"]');d instanceof HTMLElement?a=d:appendNewDocumentFragment(c,E,A,R)}var m,T=c.querySelectorAll("["+ATTRIBUTE_UPDATER_INSERT_REFERENCE+'*="'+u+'"]');for([,m]of Object.entries(T))i.has(m.getAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE))||c.removeChild(m)}e.pop()}if(!1===n)break;if(200<r++)throw new Error("the maximum depth for the recursion is reached.")}}function appendNewDocumentFragment(e,t,r,s){let a=findDocumentTemplate(t,e);var i,n=a.createDocumentFragment();for([,i]of Object.entries(n.childNodes))i instanceof HTMLElement&&(applyRecursive(i,t,s),i.setAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE,r)),e.appendChild(i)}function applyRecursive(t,r,s){if(t instanceof HTMLElement){if(t.hasAttribute(ATTRIBUTE_UPDATER_REPLACE)){let e=t.getAttribute(ATTRIBUTE_UPDATER_REPLACE);t.setAttribute(ATTRIBUTE_UPDATER_REPLACE,e.replace("path:"+r,"path:"+s))}if(t.hasAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES)){let e=t.getAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES);t.setAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES,e.replace("path:"+r,"path:"+s))}for(var[,e]of Object.entries(t.childNodes))applyRecursive(e,r,s)}}function updateContent(e){var t=this.subject.getRealSubject(),r=clone(e?.path);runUpdateContent.call(this,this.element,r,t);e=this.element.querySelectorAll("slot");if(0<e.length)for(var[,s]of Object.entries(e))for(var[,a]of Object.entries(s.assignedNodes()))runUpdateContent.call(this,a,r,t)}function runUpdateContent(e,t,i){if(isArray(t)&&e instanceof HTMLElement){t=clone(t);let a=new WeakSet;for(;0<t.length;){var r=t.join(".");t.pop();var s="["+ATTRIBUTE_UPDATER_REPLACE+'^="path:'+r+'"], ['+ATTRIBUTE_UPDATER_REPLACE+'^="static:"]',r=e.querySelectorAll(s);const n=new Set([...r]);e.matches(s)&&n.add(e),n.forEach((e,t)=>{if(!a.has(t)){a.add(t);var s=t.getAttribute(ATTRIBUTE_UPDATER_REPLACE),s=trimSpaces(s);let r=new Pipe(s);this.callbacks.forEach((e,t)=>{r.setCallback(t,e)});let e;try{t.removeAttribute(ATTRIBUTE_ERRORMESSAGE),e=r.run(i)}catch(e){t.setAttribute(ATTRIBUTE_ERRORMESSAGE,e.message)}if(e instanceof HTMLElement){for(;t.firstChild;)t.removeChild(t.firstChild);t.addNode(e)}else t.innerHTML=e}})}}}function updateAttributes(e){var t=this.subject.getRealSubject(),e=clone(e?.path);runUpdateAttributes.call(this,this.element,e,t)}function runUpdateAttributes(t,r,o){const l=this;if(isArray(r)){r=clone(r);let n=new WeakSet;for(;0<r.length;){var s=r.join(".");r.pop();let e=new Set;var a="["+ATTRIBUTE_UPDATER_ATTRIBUTES+'*="path:'+s+'"], ['+ATTRIBUTE_UPDATER_ATTRIBUTES+'^="static:"]',s=t.querySelectorAll(a);0<s.length&&(e=new Set([...s])),t.matches(a)&&e.add(t),e.forEach((e,s)=>{if(!n.has(s)){n.add(s);const r=s.getAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES);for(var[,t]of Object.entries(r.split(","))){t=trimSpaces(t);var a=t.indexOf(" "),i=trimSpaces(t.substr(0,a)),a=trimSpaces(t.substr(a));let r=new Pipe(a);l.callbacks.forEach((e,t)=>{r.setCallback(t,e,s)});let e;try{s.removeAttribute(ATTRIBUTE_ERRORMESSAGE),e=r.run(o)}catch(e){s.setAttribute(ATTRIBUTE_ERRORMESSAGE,e.message)}void 0===e?s.removeAttribute(i):s.getAttribute(i)!==e&&s.setAttribute(i,e),handleInputControlAttributeUpdate.call(this,s,i,e)}}})}}}function handleInputControlAttributeUpdate(e,t,r){if(e instanceof HTMLSelectElement)switch(e.type){case"select-multiple":for(var[s,a]of Object.entries(e.options))-1!==r.indexOf(a.value)?a.selected=!0:a.selected=!1;break;case"select-one":for(var[i,n]of Object.entries(e.options))if(n.value===r){e.selectedIndex=i;break}}else if(e instanceof HTMLInputElement)switch(e.type){case"radio":case"checkbox":e.checked="checked"===t&&void 0!==r;break;default:"value"===t&&(e.value=void 0===r?"":r)}else e instanceof HTMLTextAreaElement&&"value"===t&&(e.value=void 0===r?"":r)}assignToNamespace("Monster.DOM",Updater);export{Monster,Updater};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"../types/global.js";import{validateString}from"../types/validate.js";function getDocument(){var t=getGlobal()?.document;if("object"!=typeof t)throw new Error("not supported environment");return t}function getWindow(){var t=getGlobal()?.window;if("object"!=typeof t)throw new Error("not supported environment");return t}function getDocumentFragmentFromString(t){validateString(t);const e=getDocument(),n=e.createElement("template");return n.innerHTML=t,n.content}assignToNamespace("Monster.DOM",getWindow,getDocument,getDocumentFragmentFromString);export{Monster,getWindow,getDocument,getDocumentFragmentFromString};
@@ -0,0 +1,2 @@
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
+ "use strict";import{internalSymbol}from"../../constants.js";import{assignToNamespace,Monster}from"../../namespace.js";import{Base}from"../../types/base.js";import{getGlobal,getGlobalFunction}from"../../types/global.js";import{isFunction}from"../../types/is.js";import{validateInstance,validateString}from"../../types/validate.js";class Factory extends Base{constructor(){super(),this[internalSymbol]={worker:new WeakMap}}createFromURL=function(t,e,r){t instanceof URL&&(t=t.toString());const o=getGlobalFunction("Worker");var n=new o(validateString(t));return isFunction(e)&&(n.onmessage=t=>{e.call(n,t)}),isFunction(r)&&(n.onerror=t=>{r.call(n,t)}),n};createFromScript=function(t,e,r){const o=new getGlobalFunction("Blob");t=new o([validateString(t)],{type:"script/javascript"}),t=getGlobalFunction("URL").createObjectURL(t),r=this.createFromURL(t,e,r);return this[internalSymbol].worker.set(r,t),r};terminate(t){var e=getGlobalFunction("Worker");return validateInstance(t,e),t.terminate(),this[internalSymbol].worker.has(t)&&(t=this[internalSymbol].worker.get(t),URL.revokeObjectURL(t)),this}}assignToNamespace("Monster.DOM.Worker",Factory);export{Monster,Factory};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateString}from"../types/validate.js";import{clone}from"../util/clone.js";const propertiesSymbol=Symbol("properties"),localeStringSymbol=Symbol("localeString");class Locale extends Base{constructor(e,i,t,o,a,r){super(),this[propertiesSymbol]={language:void 0===e?void 0:validateString(e),script:void 0===t?void 0:validateString(t),region:void 0===i?void 0:validateString(i),variants:void 0===o?void 0:validateString(o),extlang:void 0===a?void 0:validateString(a),privateUse:void 0===r?void 0:validateString(r)};let n=[];if(void 0!==e&&n.push(e),void 0!==t&&n.push(t),void 0!==i&&n.push(i),void 0!==o&&n.push(o),void 0!==a&&n.push(a),void 0!==r&&n.push(r),0===n.length)throw new Error("unsupported locale");this[localeStringSymbol]=n.join("-")}get localeString(){return this[localeStringSymbol]}get language(){return this[propertiesSymbol].language}get region(){return this[propertiesSymbol].region}get script(){return this[propertiesSymbol].script}get variants(){return this[propertiesSymbol].variants}get extlang(){return this[propertiesSymbol].extlang}get privateUse(){return this[propertiesSymbol].privateValue}toString(){return""+this.localeString}getMap(){return clone(this[propertiesSymbol])}}function parseLocale(e){e=validateString(e).replace(/_/g,"-");let i,t,o,a,r,n,l=new RegExp("^(((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$"),s;if(null!==(s=l.exec(e))&&s.index===l.lastIndex&&l.lastIndex++,null==s)throw new Error("unsupported locale");return void 0!==s[6]&&(i=s[6],1<(a=i.split("-")).length&&(i=a[0],n=a[1])),void 0!==s[14]&&(t=s[14]),void 0!==s[12]&&(r=s[12]),void 0!==s[16]&&(o=s[16]),new Locale(i,t,r,o,n)}assignToNamespace("Monster.I18n",Locale,parseLocale);export{Monster,Locale,parseLocale};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";const namespace="Monster.I18n";export{namespace};
@@ -1,2 +1,2 @@
1
- /** Monster 1.21.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
1
+ /** Monster 1.25.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
2
2
  "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{Locale}from"./locale.js";import{Translations}from"./translations.js";class Provider extends BaseWithOptions{getTranslations(e){return new Promise((s,o)=>{try{s(new Translations(e))}catch(s){o(s)}})}}assignToNamespace("Monster.I18n",Provider);export{Monster,Provider};