@schukai/monster 3.4.2 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. package/example/i18n/providers/embed.mjs +5 -0
  2. package/package.json +1 -1
  3. package/source/constants.mjs +4 -9
  4. package/source/constraints/abstract.mjs +4 -6
  5. package/source/constraints/abstractoperator.mjs +6 -12
  6. package/source/constraints/andoperator.mjs +3 -6
  7. package/source/constraints/invalid.mjs +3 -6
  8. package/source/constraints/isarray.mjs +6 -9
  9. package/source/constraints/isobject.mjs +4 -7
  10. package/source/constraints/namespace.mjs +1 -3
  11. package/source/constraints/oroperator.mjs +26 -25
  12. package/source/constraints/valid.mjs +3 -6
  13. package/source/data/buildmap.mjs +20 -36
  14. package/source/data/buildtree.mjs +29 -29
  15. package/source/data/datasource/namespace.mjs +1 -1
  16. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  17. package/source/data/datasource/server/restapi.mjs +51 -65
  18. package/source/data/datasource/server/webconnect.mjs +26 -35
  19. package/source/data/datasource/server.mjs +17 -21
  20. package/source/data/datasource/storage/localstorage.mjs +8 -11
  21. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  22. package/source/data/datasource/storage.mjs +18 -22
  23. package/source/data/datasource.mjs +27 -43
  24. package/source/data/diff.mjs +20 -32
  25. package/source/data/extend.mjs +20 -14
  26. package/source/data/namespace.mjs +1 -3
  27. package/source/data/pathfinder.mjs +40 -67
  28. package/source/data/pipe.mjs +6 -10
  29. package/source/data/transformer.mjs +141 -157
  30. package/source/dom/assembler.mjs +6 -9
  31. package/source/dom/attributes.mjs +36 -48
  32. package/source/dom/constants.mjs +55 -71
  33. package/source/dom/customcontrol.mjs +16 -21
  34. package/source/dom/customelement.mjs +140 -164
  35. package/source/dom/events.mjs +17 -24
  36. package/source/dom/focusmanager.mjs +30 -48
  37. package/source/dom/locale.mjs +41 -10
  38. package/source/dom/namespace.mjs +1 -1
  39. package/source/dom/ready.mjs +7 -10
  40. package/source/dom/resource/data.mjs +38 -46
  41. package/source/dom/resource/link/namespace.mjs +1 -3
  42. package/source/dom/resource/link/stylesheet.mjs +7 -11
  43. package/source/dom/resource/link.mjs +36 -17
  44. package/source/dom/resource/namespace.mjs +1 -1
  45. package/source/dom/resource/script.mjs +23 -13
  46. package/source/dom/resource.mjs +47 -60
  47. package/source/dom/resourcemanager.mjs +36 -43
  48. package/source/dom/template.mjs +17 -24
  49. package/source/dom/theme.mjs +8 -12
  50. package/source/dom/updater.mjs +150 -196
  51. package/source/dom/util.mjs +11 -12
  52. package/source/dom/worker/factory.mjs +21 -25
  53. package/source/dom/worker/namespace.mjs +1 -1
  54. package/source/i18n/formatter.mjs +20 -24
  55. package/source/i18n/locale.mjs +40 -42
  56. package/source/i18n/namespace.mjs +1 -1
  57. package/source/i18n/provider.mjs +4 -7
  58. package/source/i18n/providers/embed.mjs +115 -0
  59. package/source/i18n/providers/fetch.mjs +33 -38
  60. package/source/i18n/translations.mjs +16 -20
  61. package/source/logging/handler/console.mjs +6 -10
  62. package/source/logging/handler.mjs +15 -18
  63. package/source/logging/logentry.mjs +8 -9
  64. package/source/logging/logger.mjs +73 -55
  65. package/source/logging/namespace.mjs +1 -1
  66. package/source/math/namespace.mjs +1 -1
  67. package/source/math/random.mjs +13 -14
  68. package/source/monster.mjs +132 -100
  69. package/source/net/namespace.mjs +1 -3
  70. package/source/net/webconnect/message.mjs +6 -8
  71. package/source/net/webconnect/namespace.mjs +1 -3
  72. package/source/net/webconnect.mjs +28 -39
  73. package/source/text/formatter.mjs +44 -55
  74. package/source/types/base.mjs +16 -26
  75. package/source/types/basewithoptions.mjs +8 -14
  76. package/source/types/binary.mjs +4 -5
  77. package/source/types/dataurl.mjs +19 -27
  78. package/source/types/global.mjs +14 -26
  79. package/source/types/id.mjs +4 -6
  80. package/source/types/is.mjs +11 -16
  81. package/source/types/mediatype.mjs +29 -44
  82. package/source/types/namespace.mjs +0 -1
  83. package/source/types/node.mjs +16 -22
  84. package/source/types/nodelist.mjs +10 -14
  85. package/source/types/noderecursiveiterator.mjs +11 -14
  86. package/source/types/observablequeue.mjs +13 -16
  87. package/source/types/observer.mjs +16 -23
  88. package/source/types/observerlist.mjs +18 -21
  89. package/source/types/proxyobserver.mjs +24 -37
  90. package/source/types/queue.mjs +8 -13
  91. package/source/types/randomid.mjs +10 -10
  92. package/source/types/regex.mjs +3 -5
  93. package/source/types/stack.mjs +4 -8
  94. package/source/types/tokenlist.mjs +24 -31
  95. package/source/types/typeof.mjs +5 -7
  96. package/source/types/uniquequeue.mjs +8 -13
  97. package/source/types/uuid.mjs +18 -25
  98. package/source/types/validate.mjs +26 -27
  99. package/source/types/version.mjs +17 -25
  100. package/source/util/clone.mjs +23 -32
  101. package/source/util/comparator.mjs +7 -15
  102. package/source/util/deadmansswitch.mjs +16 -23
  103. package/source/util/freeze.mjs +5 -7
  104. package/source/util/namespace.mjs +1 -1
  105. package/source/util/processing.mjs +33 -39
  106. package/source/util/trimspaces.mjs +17 -24
  107. package/test/cases/dom/locale.mjs +15 -0
  108. package/test/cases/i18n/providers/embed.mjs +72 -0
  109. package/test/cases/monster.mjs +1 -1
@@ -5,13 +5,13 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from '../types/base.mjs';
9
- import {getGlobalFunction, getGlobalObject} from '../types/global.mjs';
10
- import {validateInstance, validateString} from "../types/validate.mjs";
11
- import {ATTRIBUTE_TEMPLATE_PREFIX} from "./constants.mjs";
12
- import {getDocumentTheme} from "./theme.mjs";
13
- import {instanceSymbol} from '../constants.mjs';
14
- export {Template}
8
+ import { Base } from "../types/base.mjs";
9
+ import { getGlobalFunction, getGlobalObject } from "../types/global.mjs";
10
+ import { validateInstance, validateString } from "../types/validate.mjs";
11
+ import { ATTRIBUTE_TEMPLATE_PREFIX } from "./constants.mjs";
12
+ import { getDocumentTheme } from "./theme.mjs";
13
+ import { instanceSymbol } from "../constants.mjs";
14
+ export { Template };
15
15
 
16
16
  /**
17
17
  * The template class provides methods for creating templates.
@@ -32,7 +32,7 @@ class Template extends Base {
32
32
  */
33
33
  constructor(template) {
34
34
  super();
35
- const HTMLTemplateElement = getGlobalFunction('HTMLTemplateElement');
35
+ const HTMLTemplateElement = getGlobalFunction("HTMLTemplateElement");
36
36
  validateInstance(template, HTMLTemplateElement);
37
37
  this.template = template;
38
38
  }
@@ -46,7 +46,6 @@ class Template extends Base {
46
46
  return Symbol.for("@schukai/monster/dom/resource/template");
47
47
  }
48
48
 
49
-
50
49
  /**
51
50
  *
52
51
  * @returns {HTMLTemplateElement}
@@ -63,7 +62,6 @@ class Template extends Base {
63
62
  createDocumentFragment() {
64
63
  return this.template.content.cloneNode(true);
65
64
  }
66
-
67
65
  }
68
66
 
69
67
  /**
@@ -132,20 +130,17 @@ class Template extends Base {
132
130
  export function findDocumentTemplate(id, currentNode) {
133
131
  validateString(id);
134
132
 
135
- const document = getGlobalObject('document');
136
- const HTMLTemplateElement = getGlobalFunction('HTMLTemplateElement');
137
- const DocumentFragment = getGlobalFunction('DocumentFragment');
138
- const Document = getGlobalFunction('Document');
139
-
133
+ const document = getGlobalObject("document");
134
+ const HTMLTemplateElement = getGlobalFunction("HTMLTemplateElement");
135
+ const DocumentFragment = getGlobalFunction("DocumentFragment");
136
+ const Document = getGlobalFunction("Document");
140
137
 
141
138
  let prefixID;
142
139
 
143
140
  if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
144
-
145
141
  if (currentNode instanceof Node) {
146
-
147
142
  if (currentNode.hasAttribute(ATTRIBUTE_TEMPLATE_PREFIX)) {
148
- prefixID = currentNode.getAttribute(ATTRIBUTE_TEMPLATE_PREFIX)
143
+ prefixID = currentNode.getAttribute(ATTRIBUTE_TEMPLATE_PREFIX);
149
144
  }
150
145
 
151
146
  currentNode = currentNode.getRootNode();
@@ -153,7 +148,6 @@ export function findDocumentTemplate(id, currentNode) {
153
148
  if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
154
149
  currentNode = currentNode.ownerDocument;
155
150
  }
156
-
157
151
  }
158
152
 
159
153
  if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
@@ -162,10 +156,10 @@ export function findDocumentTemplate(id, currentNode) {
162
156
  }
163
157
 
164
158
  let template;
165
- let theme = getDocumentTheme()
159
+ let theme = getDocumentTheme();
166
160
 
167
161
  if (prefixID) {
168
- let themedPrefixID = prefixID + '-' + id + '-' + theme.getName();
162
+ let themedPrefixID = `${prefixID}-${id}-${theme.getName()}`;
169
163
 
170
164
  // current + themedPrefixID
171
165
  template = currentNode.getElementById(themedPrefixID);
@@ -180,7 +174,7 @@ export function findDocumentTemplate(id, currentNode) {
180
174
  }
181
175
  }
182
176
 
183
- let themedID = id + '-' + theme.getName();
177
+ let themedID = `${id}-${theme.getName()}`;
184
178
 
185
179
  // current + themedID
186
180
  template = currentNode.getElementById(themedID);
@@ -206,6 +200,5 @@ export function findDocumentTemplate(id, currentNode) {
206
200
  return new Template(template);
207
201
  }
208
202
 
209
- throw new Error("template " + id + " not found.")
203
+ throw new Error(`template ${id} not found.`);
210
204
  }
211
-
@@ -5,12 +5,12 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from '../types/base.mjs';
9
- import {getGlobalObject} from '../types/global.mjs';
10
- import {validateString} from "../types/validate.mjs";
11
- import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.mjs";
12
- import {instanceSymbol} from '../constants.mjs';
13
- export {Theme, getDocumentTheme}
8
+ import { Base } from "../types/base.mjs";
9
+ import { getGlobalObject } from "../types/global.mjs";
10
+ import { validateString } from "../types/validate.mjs";
11
+ import { ATTRIBUTE_THEME_NAME, DEFAULT_THEME } from "./constants.mjs";
12
+ import { instanceSymbol } from "../constants.mjs";
13
+ export { Theme, getDocumentTheme };
14
14
 
15
15
  /**
16
16
  * The Theme class provides the functionality for the theme.
@@ -23,7 +23,6 @@ export {Theme, getDocumentTheme}
23
23
  * @summary A theme class
24
24
  */
25
25
  class Theme extends Base {
26
-
27
26
  /**
28
27
  *
29
28
  * @param name
@@ -44,7 +43,6 @@ class Theme extends Base {
44
43
  return Symbol.for("@schukai/monster/dom/theme");
45
44
  }
46
45
 
47
-
48
46
  /**
49
47
  *
50
48
  * @returns {string}
@@ -52,7 +50,6 @@ class Theme extends Base {
52
50
  getName() {
53
51
  return this.name;
54
52
  }
55
-
56
53
  }
57
54
 
58
55
  /**
@@ -73,10 +70,10 @@ class Theme extends Base {
73
70
  * @since 1.7.0
74
71
  */
75
72
  function getDocumentTheme() {
76
- let document = getGlobalObject('document');
73
+ let document = getGlobalObject("document");
77
74
  let name = DEFAULT_THEME;
78
75
 
79
- let element = document.querySelector('html');
76
+ let element = document.querySelector("html");
80
77
  if (element instanceof HTMLElement) {
81
78
  let theme = element.getAttribute(ATTRIBUTE_THEME_NAME);
82
79
  if (theme) {
@@ -85,5 +82,4 @@ function getDocumentTheme() {
85
82
  }
86
83
 
87
84
  return new Theme(name);
88
-
89
85
  }