@schukai/monster 1.12.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG +40 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -0
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -0
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -0
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -0
  33. package/dist/modules/i18n/namespace.js +2 -0
  34. package/dist/modules/i18n/provider.js +2 -0
  35. package/dist/modules/i18n/providers/fetch.js +2 -0
  36. package/dist/modules/i18n/providers/namespace.js +2 -0
  37. package/dist/modules/i18n/translations.js +2 -0
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +2 -2
  47. package/dist/modules/namespace.js +1 -1
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -0
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +8692 -6669
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +3 -3
  74. package/package.json +1 -1
  75. package/source/constants.js +22 -0
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +3 -3
  78. package/source/constraints/andoperator.js +7 -7
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +6 -6
  81. package/source/constraints/isobject.js +6 -6
  82. package/source/constraints/namespace.js +2 -0
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +6 -6
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +6 -6
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -0
  89. package/source/data/pathfinder.js +6 -7
  90. package/source/data/pipe.js +5 -5
  91. package/source/data/transformer.js +6 -6
  92. package/source/dom/assembler.js +5 -5
  93. package/source/dom/attributes.js +89 -45
  94. package/source/dom/constants.js +8 -9
  95. package/source/dom/customcontrol.js +301 -0
  96. package/source/dom/customelement.js +149 -31
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +59 -0
  99. package/source/dom/namespace.js +2 -0
  100. package/source/dom/template.js +7 -7
  101. package/source/dom/theme.js +6 -6
  102. package/source/dom/updater.js +38 -11
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +322 -0
  105. package/source/i18n/namespace.js +15 -0
  106. package/source/i18n/provider.js +58 -0
  107. package/source/i18n/providers/fetch.js +121 -0
  108. package/source/i18n/providers/namespace.js +15 -0
  109. package/source/i18n/translations.js +209 -0
  110. package/source/logging/handler/console.js +4 -4
  111. package/source/logging/handler.js +4 -4
  112. package/source/logging/logentry.js +4 -4
  113. package/source/logging/logger.js +4 -4
  114. package/source/logging/namespace.js +2 -0
  115. package/source/math/namespace.js +2 -0
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +26 -16
  118. package/source/namespace.js +10 -8
  119. package/source/text/formatter.js +4 -5
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -7
  122. package/source/types/basewithoptions.js +97 -0
  123. package/source/types/global.js +6 -6
  124. package/source/types/id.js +6 -6
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +3 -1
  127. package/source/types/observer.js +5 -5
  128. package/source/types/observerlist.js +4 -4
  129. package/source/types/proxyobserver.js +32 -26
  130. package/source/types/queue.js +13 -7
  131. package/source/types/randomid.js +5 -5
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +4 -4
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +11 -4
  136. package/source/types/validate.js +22 -22
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +4 -4
  139. package/source/util/comparator.js +6 -6
  140. package/source/util/freeze.js +4 -4
  141. package/source/util/namespace.js +2 -0
  142. package/test/cases/data/extend.js +66 -13
  143. package/test/cases/dom/attributes.js +56 -1
  144. package/test/cases/dom/customcontrol.js +264 -0
  145. package/test/cases/dom/customelement.js +112 -51
  146. package/test/cases/dom/events.js +32 -14
  147. package/test/cases/dom/locale.js +44 -0
  148. package/test/cases/i18n/locale.js +80 -0
  149. package/test/cases/i18n/provider.js +15 -0
  150. package/test/cases/i18n/providers/fetch.js +65 -0
  151. package/test/cases/i18n/translations.js +57 -0
  152. package/test/cases/monster.js +3 -1
  153. package/test/cases/{util → text}/formatter.js +2 -0
  154. package/test/cases/types/basewithoptions.js +25 -0
  155. package/test/cases/types/proxyobserver.js +9 -0
  156. package/test/cases/{text → util}/clone.js +0 -0
  157. package/test/cases/{text → util}/comparator.js +0 -0
  158. package/test/util/jsdom.js +4 -0
  159. package/test/web/import.js +10 -3
  160. package/test/web/monster-dev.html +3 -3
  161. package/test/web/monster.html +3 -3
  162. package/test/web/test.html +3 -3
  163. package/test/web/tests.js +3 -3
@@ -0,0 +1,209 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @author schukai GmbH
5
+ */
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from "../types/base.js";
8
+ import {isObject, isString} from "../types/is.js";
9
+ import {validateInstance, validateInteger, validateObject, validateString} from "../types/validate.js";
10
+ import {Locale, parseLocale} from "./locale.js";
11
+
12
+
13
+ /**
14
+ * With this class you can manage translations and access the keys.
15
+ *
16
+ * You can call the method via the monster namespace `new Monster.I18n.Translations()`.
17
+ *
18
+ * ```
19
+ * <script type="module">
20
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/i18n/translations.js';
21
+ * console.log(new Monster.I18n.Translations())
22
+ * </script>
23
+ * ```
24
+ *
25
+ * Alternatively, you can also integrate this function individually.
26
+ *
27
+ * ```
28
+ * <script type="module">
29
+ * import {Translations} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/i18n/translations.js';
30
+ * console.log(new Translations())
31
+ * </script>
32
+ * ```
33
+ *
34
+ * @example
35
+ *
36
+ * const translation = new Translations(parseLocale('en-GB'));
37
+ *
38
+ * translation.assignTranslations({
39
+ * text1: "abc",
40
+ * text2: {'other': 'xyz'}
41
+ * });
42
+ *
43
+ * translation.getText('text1);
44
+ * translation.getPluralRuleText('text1',2);
45
+ *
46
+ * @since 1.13.0
47
+ * @copyright schukai GmbH
48
+ * @memberOf Monster/I18n
49
+ * @see https://datatracker.ietf.org/doc/html/rfc3066
50
+ */
51
+ class Translations extends Base {
52
+
53
+ /**
54
+ *
55
+ * @param {Locale} locale
56
+ */
57
+ constructor(locale) {
58
+ super();
59
+
60
+ if (isString(locale)) {
61
+ locale = parseLocale(locale);
62
+ }
63
+
64
+ this.locale = validateInstance(locale, Locale);
65
+ this.storage = new Map();
66
+
67
+ }
68
+
69
+
70
+ /**
71
+ * Fetches a text using the specified key.
72
+ * If no suitable key is found, `defaultText` is taken.
73
+ *
74
+ * @param {string} key
75
+ * @param {string|undefined} defaultText
76
+ * @return {string}
77
+ * @throws {Error} key not found
78
+ */
79
+ getText(key, defaultText) {
80
+ if (!this.storage.has(key)) {
81
+ if (defaultText === undefined) {
82
+ throw new Error('key ' + key + ' not found');
83
+ }
84
+
85
+ return validateString(defaultText);
86
+ }
87
+
88
+ let r = this.storage.get(key);
89
+ if (isObject(r)) {
90
+ return this.getPluralRuleText(key, 'other', defaultText);
91
+ }
92
+
93
+ return this.storage.get(key);
94
+ }
95
+
96
+ /**
97
+ * A number `count` can be passed to this method. In addition to a number, one of the keywords can also be passed directly.
98
+ * "zero", "one", "two", "few", "many" and "other". Remember: not every language has all rules.
99
+ *
100
+ * The appropriate text for this number is then selected. If no suitable key is found, `defaultText` is taken.
101
+ *
102
+ * @param {string} key
103
+ * @param {integer|count} count
104
+ * @param {string|undefined} defaultText
105
+ * @return {string}
106
+ */
107
+ getPluralRuleText(key, count, defaultText) {
108
+ if (!this.storage.has(key)) {
109
+ return validateString(defaultText);
110
+ }
111
+
112
+ let r = validateObject(this.storage.get(key));
113
+
114
+ let keyword;
115
+ if (isString(count)) {
116
+ keyword = count.toLocaleString();
117
+ } else {
118
+ count = validateInteger(count);
119
+ if (count === 0) {
120
+ // special handlig for zero count
121
+ if (r.hasOwnProperty('zero')) {
122
+ return validateString(r['zero']);
123
+ }
124
+ }
125
+
126
+ keyword = new Intl.PluralRules(this.locale.toString()).select(validateInteger(count));
127
+ }
128
+
129
+ if (r.hasOwnProperty(keyword)) {
130
+ return validateString(r[keyword]);
131
+ }
132
+
133
+ if (r.hasOwnProperty(DEFAULT_KEY)) {
134
+ return validateString(r[DEFAULT_KEY]);
135
+ }
136
+
137
+ return validateString(defaultText);
138
+ }
139
+
140
+ /**
141
+ * Set a text for a key
142
+ *
143
+ * ```
144
+ * translations.setText("text1": "Make my day!");
145
+ * // plural rules
146
+ * translations.setText("text6": {
147
+ * "zero": "There are no files on Disk.",
148
+ * "one": "There is one file on Disk.",
149
+ * "other": "There are files on Disk."
150
+ * "default": "There are files on Disk."
151
+ * });
152
+ * ```
153
+ *
154
+ * @param {string} key
155
+ * @param {string|object} text
156
+ * @return {Translations}
157
+ * @throws {TypeError} value is not a string or object
158
+ */
159
+ setText(key, text) {
160
+
161
+ if (isString(text) || isObject(text)) {
162
+ this.storage.set(validateString(key), text);
163
+ return this;
164
+ }
165
+
166
+ throw new TypeError('value is not a string or object');
167
+
168
+ }
169
+
170
+ /**
171
+ * This method can be used to transfer overlays from an object. The keys are transferred and the values are entered as text.
172
+ *
173
+ * The values can either be character strings or, in the case of texts with plural forms, objects. The plural forms must be stored as text via a standard key "zero", "one", "two", "few", "many" and "other".
174
+ *
175
+ * Additionally, the key default can be specified, which will be used if no other key fits.
176
+ *
177
+ * In some languages, like for example in german, there is no own more number at the value 0. In these languages the function applies additionally zero.
178
+ *
179
+ * ```
180
+ * translations.assignTranslations({
181
+ * "text1": "Make my day!",
182
+ * "text2": "I'll be back!",
183
+ * "text6": {
184
+ * "zero": "There are no files on Disk.",
185
+ * "one": "There is one file on Disk.",
186
+ * "other": "There are files on Disk."
187
+ * "default": "There are files on Disk."
188
+ * });
189
+ * ```
190
+ *
191
+ * @param {object} translations
192
+ * @return {Translations}
193
+ */
194
+ assignTranslations(translations) {
195
+ validateObject(translations);
196
+
197
+ for (const [k, v] of Object.entries(translations)) {
198
+ this.setText(k, v);
199
+ }
200
+
201
+ return this;
202
+
203
+ }
204
+
205
+ }
206
+
207
+
208
+ assignToNamespace('Monster.I18n', Translations);
209
+ export {Monster, Translations}
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {Base} from '../../types/base.js';
9
9
  import {Handler} from '../../logging/handler.js';
10
10
 
@@ -13,7 +13,7 @@ import {Handler} from '../../logging/handler.js';
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/handler/console.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/handler/console.js';
17
17
  * console.log(new Monster.Logging.Handler.ConsoleHandler())
18
18
  * </script>
19
19
  * ```
@@ -22,7 +22,7 @@ import {Handler} from '../../logging/handler.js';
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/handler/console.js';
25
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/handler/console.js';
26
26
  * console.log(new ConsoleHandler())
27
27
  * </script>
28
28
  * ```
@@ -38,5 +38,5 @@ class ConsoleHandler extends Base {
38
38
  }
39
39
 
40
40
 
41
- Monster.assignToNamespace('Monster.Logging', ConsoleHandler);
41
+ assignToNamespace('Monster.Logging', ConsoleHandler);
42
42
  export {Monster, Handler};
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {Base} from '../types/base.js';
9
9
  import {ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN} from "./logger.js";
10
10
  import {LogEntry} from "./logentry.js";
@@ -15,7 +15,7 @@ import {validateInstance, validateInteger} from "../types/validate.js";
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/handler.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/handler.js';
19
19
  * console.log(new Monster.Logging.Handler())
20
20
  * </script>
21
21
  * ```
@@ -24,7 +24,7 @@ import {validateInstance, validateInteger} from "../types/validate.js";
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/handler.js';
27
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/handler.js';
28
28
  * console.log(new Handler())
29
29
  * </script>
30
30
  * ```
@@ -180,5 +180,5 @@ class Handler extends Base {
180
180
  }
181
181
 
182
182
 
183
- Monster.assignToNamespace('Monster.Logging', Handler);
183
+ assignToNamespace('Monster.Logging', Handler);
184
184
  export {Monster, Handler};
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {validateInteger} from '../types/validate.js';
9
9
  import {Base} from '../types/base.js';
10
10
 
@@ -14,7 +14,7 @@ import {Base} from '../types/base.js';
14
14
  *
15
15
  * ```
16
16
  * <script type="module">
17
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/logentry.js';
17
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/logentry.js';
18
18
  * console.log(new Monster.Logging.LogEntry())
19
19
  * </script>
20
20
  * ```
@@ -23,7 +23,7 @@ import {Base} from '../types/base.js';
23
23
  *
24
24
  * ```
25
25
  * <script type="module">
26
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/logentry.js';
26
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/logentry.js';
27
27
  * console.log(new LogEntry())
28
28
  * </script>
29
29
  * ```
@@ -64,5 +64,5 @@ class LogEntry extends Base {
64
64
 
65
65
  }
66
66
 
67
- Monster.assignToNamespace('Monster.Logging', LogEntry);
67
+ assignToNamespace('Monster.Logging', LogEntry);
68
68
  export {Monster, LogEntry}
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {validateInteger, validateObject, validateString} from '../types/validate.js';
9
9
  import {Handler} from '../logging/handler.js';
10
10
  import {LogEntry} from '../logging/logentry.js';
@@ -65,7 +65,7 @@ const OFF = 0;
65
65
  *
66
66
  * ```
67
67
  * <script type="module">
68
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/logger.js';
68
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/logger.js';
69
69
  * console.log(new Monster.Logging.Logger())
70
70
  * </script>
71
71
  * ```
@@ -74,7 +74,7 @@ const OFF = 0;
74
74
  *
75
75
  * ```
76
76
  * <script type="module">
77
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/logging/logger.js';
77
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/logging/logger.js';
78
78
  * console.log(new Logger())
79
79
  * </script>
80
80
  * ```
@@ -256,7 +256,7 @@ class Logger extends Base {
256
256
 
257
257
  }
258
258
 
259
- Monster.assignToNamespace('Monster.Logging', Logger);
259
+ assignToNamespace('Monster.Logging', Logger);
260
260
  export {Monster, Logger, ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF};
261
261
 
262
262
 
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
+ * Namespace for logging.
5
+ *
4
6
  * @namespace Monster/Logging
5
7
  * @author schukai GmbH
6
8
  */
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
+ * Namespace for math.
5
+ *
4
6
  * @namespace Monster/Math
5
7
  * @author schukai GmbH
6
8
  */
@@ -4,8 +4,8 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
-
8
- import {Monster, getGlobal} from '../types/global.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
+ import { getGlobal} from '../types/global.js';
9
9
 
10
10
 
11
11
  /**
@@ -15,7 +15,7 @@ import {Monster, getGlobal} from '../types/global.js';
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/math/random.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/math/random.js';
19
19
  * console.log(Monster.Math.random(1,10)) // ↦ 5
20
20
  * </script>
21
21
  * ```
@@ -24,7 +24,7 @@ import {Monster, getGlobal} from '../types/global.js';
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {random} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/math/random.js';
27
+ * import {random} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/math/random.js';
28
28
  * console.log(random(1,10)) // ↦ 5
29
29
  * </script>
30
30
  * ```
@@ -120,7 +120,7 @@ function create(min, max) {
120
120
 
121
121
  }
122
122
 
123
- Monster.assignToNamespace('Monster.Math', random);
123
+ assignToNamespace('Monster.Math', random);
124
124
  export {Monster, random}
125
125
 
126
126
 
package/source/monster.js CHANGED
@@ -9,21 +9,8 @@
9
9
 
10
10
  import {Monster} from './namespace.js';
11
11
 
12
- import './types/base.js';
13
- import './types/queue.js';
14
- import './types/observer.js';
15
- import './types/global.js';
16
- import './types/observerlist.js';
17
- import './types/is.js';
18
- import './types/proxyobserver.js';
19
- import './types/uniquequeue.js';
20
- import './types/tokenlist.js';
21
- import './types/typeof.js';
22
- import './types/version.js';
23
- import './types/id.js';
24
- import './types/randomid.js';
25
- import './types/validate.js';
26
- import './types/stack.js';
12
+ // find . -type f -name "*.js" -not -name "*namespace*" -not -iname "monster.js"
13
+
27
14
  import './constraints/isobject.js';
28
15
  import './constraints/valid.js';
29
16
  import './constraints/invalid.js';
@@ -36,18 +23,42 @@ import './logging/logger.js';
36
23
  import './logging/handler.js';
37
24
  import './logging/logentry.js';
38
25
  import './logging/handler/console.js';
26
+ import './text/formatter.js';
39
27
  import './dom/updater.js';
40
28
  import './dom/attributes.js';
41
29
  import './dom/template.js';
42
30
  import './dom/util.js';
31
+ import './dom/locale.js';
32
+ import './dom/customcontrol.js';
43
33
  import './dom/constants.js';
44
34
  import './dom/assembler.js';
45
35
  import './dom/theme.js';
46
36
  import './dom/events.js';
47
37
  import './dom/customelement.js';
38
+ import './i18n/providers/fetch.js';
39
+ import './i18n/translations.js';
40
+ import './i18n/locale.js';
41
+ import './i18n/provider.js';
42
+ import './types/queue.js';
43
+ import './types/observer.js';
44
+ import './types/global.js';
45
+ import './types/observerlist.js';
46
+ import './types/basewithoptions.js';
47
+ import './types/is.js';
48
+ import './types/proxyobserver.js';
49
+ import './types/uniquequeue.js';
50
+ import './types/tokenlist.js';
51
+ import './types/typeof.js';
52
+ import './types/base.js';
53
+ import './types/version.js';
54
+ import './types/id.js';
55
+ import './types/randomid.js';
56
+ import './types/validate.js';
57
+ import './types/stack.js';
48
58
  import './util/comparator.js';
49
59
  import './util/clone.js';
50
60
  import './util/freeze.js';
61
+ import './constants.js';
51
62
  import './data/pathfinder.js';
52
63
  import './data/pipe.js';
53
64
  import './data/extend.js';
@@ -55,7 +66,6 @@ import './data/diff.js';
55
66
  import './data/buildmap.js';
56
67
  import './data/transformer.js';
57
68
  import './math/random.js';
58
- import './text/formatter.js';
59
69
 
60
70
  Monster.Util.deepFreeze(Monster);
61
71
 
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
+ * Main namespace for Monster.
5
+ *
4
6
  * @namespace Monster
5
7
  * @author schukai GmbH
6
8
  */
@@ -55,27 +57,27 @@ class Namespace {
55
57
  export const Monster = new Namespace("Monster");
56
58
 
57
59
  /**
58
- * To expand monster, the `Monster.assignToNamespace()` method can be used.
60
+ * To expand monster, the `Monster.assignToNamespace()` method can be used.
59
61
  *
60
62
  * you must call the method in the monster namespace. this allows you to mount your own classes, objects and functions into the namespace.
61
- *
63
+ *
62
64
  * To avoid confusion and so that you do not accidentally overwrite existing functions, you should use the custom namespace `X`.
63
65
  *
64
66
  * ```
65
67
  * <script type="module">
66
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/namespace.js';
68
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/namespace.js';
67
69
  * function hello() {
68
70
  * console.log('Hello World!');
69
71
  * }
70
72
  * Monster.assignToNamespace("Monster.X", hello)
71
73
  * Monster.X.hello(); // ↦ Hello World!
72
74
  * </script>
73
- *
75
+ *
74
76
  * ```
75
77
  *
76
78
  * @param {string} ns
77
79
  * @param {function} obj
78
- * @return {current}
80
+ * @return {current}
79
81
  * @memberOf Monster
80
82
  * @throws {Error} no functions have been passed.
81
83
  * @throws {Error} the name of the class or function cannot be resolved.
@@ -86,14 +88,14 @@ export const Monster = new Namespace("Monster");
86
88
  function assignToNamespace(ns, ...obj) {
87
89
  let current = namespaceFor(ns.split("."));
88
90
 
89
- if(obj.length===0) {
91
+ if (obj.length === 0) {
90
92
  throw new Error('no functions have been passed.');
91
93
  }
92
-
94
+
93
95
  for (let i = 0, l = obj.length; i < l; i++) {
94
96
  current[objectName(obj[i])] = obj[i];
95
97
  }
96
-
98
+
97
99
  return current
98
100
  }
99
101
 
@@ -3,9 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
7
  import {Pipe} from "../data/pipe.js";
8
- import {Monster} from '../namespace.js';
9
8
  import {Base} from "../types/base.js";
10
9
  import {validateObject, validateString} from "../types/validate.js";
11
10
 
@@ -19,7 +18,7 @@ import {validateObject, validateString} from "../types/validate.js";
19
18
  *
20
19
  * ```
21
20
  * <script type="module">
22
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/text/formatter.js';
21
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/text/formatter.js';
23
22
  * console.log(new Monster.Text.Formatter())
24
23
  * </script>
25
24
  * ```
@@ -28,7 +27,7 @@ import {validateObject, validateString} from "../types/validate.js";
28
27
  *
29
28
  * ```
30
29
  * <script type="module">
31
- * import {Object} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/text/formatter.js';
30
+ * import {Formatter} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/text/formatter.js';
32
31
  * console.log(new Formatter())
33
32
  * </script>
34
33
  * ```
@@ -147,5 +146,5 @@ function tokenizer(text) {
147
146
  return formatted.join('');
148
147
  }
149
148
 
150
- Monster.assignToNamespace('Monster.Text', Formatter);
149
+ assignToNamespace('Monster.Text', Formatter);
151
150
  export {Monster, Formatter}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * lorem ipsum
4
+ * Namespace for texts.
5
5
  *
6
6
  * @namespace Monster/Text
7
7
  * @author schukai GmbH
@@ -4,8 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
8
-
7
+ import {Monster, assignToNamespace} from '../namespace.js';
9
8
 
10
9
  /**
11
10
  * This is the base class from which all monster classes are derived.
@@ -14,8 +13,7 @@ import {Monster} from '../namespace.js';
14
13
  *
15
14
  * ```
16
15
  * <script type="module">
17
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/base.js';
18
- * console.log(new Monster.Types.Base())
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/base.js';
19
17
  * console.log(new Monster.Types.Base())
20
18
  * </script>
21
19
  * ```
@@ -24,8 +22,7 @@ import {Monster} from '../namespace.js';
24
22
  *
25
23
  * ```
26
24
  * <script type="module">
27
- * import {Object} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/base.js';
28
- * console.log(new Base())
25
+ * import {Base} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/base.js';
29
26
  * console.log(new Base())
30
27
  * </script>
31
28
  * ```
@@ -49,5 +46,5 @@ class Base extends Object {
49
46
 
50
47
  }
51
48
 
52
- Monster.assignToNamespace('Monster.Types', Base);
49
+ assignToNamespace('Monster.Types', Base);
53
50
  export {Monster, Base}