@schukai/monster 3.5.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/package.json +1 -1
  2. package/source/constants.mjs +4 -9
  3. package/source/constraints/abstract.mjs +4 -6
  4. package/source/constraints/abstractoperator.mjs +6 -12
  5. package/source/constraints/andoperator.mjs +3 -6
  6. package/source/constraints/invalid.mjs +3 -6
  7. package/source/constraints/isarray.mjs +6 -9
  8. package/source/constraints/isobject.mjs +4 -7
  9. package/source/constraints/namespace.mjs +1 -3
  10. package/source/constraints/oroperator.mjs +26 -25
  11. package/source/constraints/valid.mjs +3 -6
  12. package/source/data/buildmap.mjs +20 -36
  13. package/source/data/buildtree.mjs +29 -29
  14. package/source/data/datasource/namespace.mjs +1 -1
  15. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  16. package/source/data/datasource/server/restapi.mjs +51 -65
  17. package/source/data/datasource/server/webconnect.mjs +26 -35
  18. package/source/data/datasource/server.mjs +16 -20
  19. package/source/data/datasource/storage/localstorage.mjs +8 -11
  20. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  21. package/source/data/datasource/storage.mjs +18 -22
  22. package/source/data/datasource.mjs +27 -43
  23. package/source/data/diff.mjs +20 -32
  24. package/source/data/extend.mjs +20 -14
  25. package/source/data/namespace.mjs +1 -3
  26. package/source/data/pathfinder.mjs +105 -87
  27. package/source/data/pipe.mjs +6 -10
  28. package/source/data/transformer.mjs +141 -157
  29. package/source/dom/assembler.mjs +6 -9
  30. package/source/dom/attributes.mjs +36 -48
  31. package/source/dom/constants.mjs +55 -71
  32. package/source/dom/customcontrol.mjs +16 -21
  33. package/source/dom/customelement.mjs +140 -164
  34. package/source/dom/events.mjs +17 -24
  35. package/source/dom/focusmanager.mjs +31 -49
  36. package/source/dom/locale.mjs +18 -20
  37. package/source/dom/namespace.mjs +1 -1
  38. package/source/dom/ready.mjs +7 -10
  39. package/source/dom/resource/data.mjs +38 -46
  40. package/source/dom/resource/link/namespace.mjs +1 -3
  41. package/source/dom/resource/link/stylesheet.mjs +7 -11
  42. package/source/dom/resource/link.mjs +36 -17
  43. package/source/dom/resource/namespace.mjs +1 -1
  44. package/source/dom/resource/script.mjs +23 -13
  45. package/source/dom/resource.mjs +47 -60
  46. package/source/dom/resourcemanager.mjs +36 -43
  47. package/source/dom/template.mjs +17 -24
  48. package/source/dom/theme.mjs +8 -12
  49. package/source/dom/updater.mjs +150 -196
  50. package/source/dom/util.mjs +11 -12
  51. package/source/dom/worker/factory.mjs +21 -25
  52. package/source/dom/worker/namespace.mjs +1 -1
  53. package/source/i18n/formatter.mjs +20 -24
  54. package/source/i18n/locale.mjs +42 -55
  55. package/source/i18n/namespace.mjs +1 -1
  56. package/source/i18n/provider.mjs +4 -7
  57. package/source/i18n/providers/embed.mjs +16 -26
  58. package/source/i18n/providers/fetch.mjs +30 -36
  59. package/source/i18n/translations.mjs +17 -24
  60. package/source/logging/handler/console.mjs +6 -10
  61. package/source/logging/handler.mjs +15 -18
  62. package/source/logging/logentry.mjs +8 -9
  63. package/source/logging/logger.mjs +73 -55
  64. package/source/logging/namespace.mjs +1 -1
  65. package/source/math/namespace.mjs +1 -1
  66. package/source/math/random.mjs +13 -14
  67. package/source/monster.mjs +132 -100
  68. package/source/net/namespace.mjs +1 -3
  69. package/source/net/webconnect/message.mjs +6 -8
  70. package/source/net/webconnect/namespace.mjs +1 -3
  71. package/source/net/webconnect.mjs +28 -39
  72. package/source/text/formatter.mjs +44 -55
  73. package/source/types/base.mjs +16 -26
  74. package/source/types/basewithoptions.mjs +8 -14
  75. package/source/types/binary.mjs +4 -5
  76. package/source/types/dataurl.mjs +19 -27
  77. package/source/types/global.mjs +14 -26
  78. package/source/types/id.mjs +4 -6
  79. package/source/types/is.mjs +11 -16
  80. package/source/types/mediatype.mjs +29 -44
  81. package/source/types/namespace.mjs +0 -1
  82. package/source/types/node.mjs +16 -22
  83. package/source/types/nodelist.mjs +10 -14
  84. package/source/types/noderecursiveiterator.mjs +11 -14
  85. package/source/types/observablequeue.mjs +13 -16
  86. package/source/types/observer.mjs +16 -23
  87. package/source/types/observerlist.mjs +18 -21
  88. package/source/types/proxyobserver.mjs +24 -37
  89. package/source/types/queue.mjs +8 -13
  90. package/source/types/randomid.mjs +10 -10
  91. package/source/types/regex.mjs +3 -5
  92. package/source/types/stack.mjs +4 -8
  93. package/source/types/tokenlist.mjs +24 -31
  94. package/source/types/typeof.mjs +5 -7
  95. package/source/types/uniquequeue.mjs +8 -13
  96. package/source/types/uuid.mjs +18 -25
  97. package/source/types/validate.mjs +26 -27
  98. package/source/types/version.mjs +17 -25
  99. package/source/util/clone.mjs +23 -32
  100. package/source/util/comparator.mjs +7 -15
  101. package/source/util/deadmansswitch.mjs +16 -23
  102. package/source/util/freeze.mjs +5 -7
  103. package/source/util/namespace.mjs +1 -1
  104. package/source/util/processing.mjs +33 -39
  105. package/source/util/trimspaces.mjs +17 -24
  106. package/test/cases/monster.mjs +1 -1
@@ -10,4 +10,4 @@
10
10
  * @memberOf Monster
11
11
  * @author schukai GmbH
12
12
  */
13
- const ns = {};
13
+ const ns = {};
@@ -5,9 +5,9 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {getGlobal} from '../types/global.mjs';
8
+ import { getGlobal } from "../types/global.mjs";
9
9
 
10
- export {random}
10
+ export { random };
11
11
 
12
12
  /**
13
13
  * this function uses crypt and returns a random number.
@@ -24,8 +24,7 @@ export {random}
24
24
  * @since 1.0.0
25
25
  * @copyright schukai GmbH
26
26
  */
27
- function random(min, max) {
28
-
27
+ function random(min, max) {
29
28
  if (min === undefined) {
30
29
  min = 0;
31
30
  }
@@ -38,7 +37,6 @@ export {random}
38
37
  }
39
38
 
40
39
  return Math.round(create(min, max));
41
-
42
40
  }
43
41
 
44
42
  /**
@@ -47,9 +45,11 @@ export {random}
47
45
  */
48
46
  var MAX = 1000000000;
49
47
 
50
- Math.log2 = Math.log2 || function (n) {
51
- return Math.log(n) / Math.log(2);
52
- };
48
+ Math.log2 =
49
+ Math.log2 ||
50
+ function (n) {
51
+ return Math.log(n) / Math.log(2);
52
+ };
53
53
 
54
54
  /**
55
55
  *
@@ -65,21 +65,21 @@ function create(min, max) {
65
65
  let crypt;
66
66
  let globalReference = getGlobal();
67
67
 
68
- crypt = globalReference?.['crypto'] || globalReference?.['msCrypto'] || globalReference?.['crypto'] || undefined;
68
+ crypt = globalReference?.["crypto"] || globalReference?.["msCrypto"] || globalReference?.["crypto"] || undefined;
69
69
 
70
70
  if (typeof crypt === "undefined") {
71
- throw new Error("missing crypt")
71
+ throw new Error("missing crypt");
72
72
  }
73
73
 
74
74
  let rval = 0;
75
75
  const range = max - min;
76
76
  if (range < 2) {
77
- throw new Error('the distance is too small to create a random number.')
77
+ throw new Error("the distance is too small to create a random number.");
78
78
  }
79
79
 
80
80
  const bitsNeeded = Math.ceil(Math.log2(range));
81
81
  if (bitsNeeded > 53) {
82
- throw new Error("we cannot generate numbers larger than 53 bits.");
82
+ throw new Error("we cannot generate numbers larger than 53 bits.");
83
83
  }
84
84
  const bytesNeeded = Math.ceil(bitsNeeded / 8);
85
85
  const mask = Math.pow(2, bitsNeeded) - 1;
@@ -102,7 +102,6 @@ function create(min, max) {
102
102
  if (rval < min) {
103
103
  rval += min;
104
104
  }
105
-
106
- return rval;
107
105
 
106
+ return rval;
108
107
  }
@@ -14,30 +14,49 @@
14
14
  */
15
15
 
16
16
  // development/script/grep-exports.cjs
17
- export {IsObject} from "./constraints/isobject.mjs"
18
- export {Invalid} from "./constraints/invalid.mjs"
19
- export {AndOperator} from "./constraints/andoperator.mjs"
20
- export {OrOperator} from "./constraints/oroperator.mjs"
21
- export {AbstractConstraint} from "./constraints/abstract.mjs"
22
- export {IsArray} from "./constraints/isarray.mjs"
23
- export {AbstractOperator} from "./constraints/abstractoperator.mjs"
24
- export {Valid} from "./constraints/valid.mjs"
25
- export {Logger, ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF} from "./logging/logger.mjs"
26
- export {LogEntry} from "./logging/logentry.mjs"
27
- export {ConsoleHandler} from "./logging/handler/console.mjs"
28
- export {Handler} from "./logging/handler.mjs"
29
- export {Formatter} from "./text/formatter.mjs"
30
- export {Stylesheet} from "./dom/resource/link/stylesheet.mjs"
31
- export {Data} from "./dom/resource/data.mjs"
32
- export {Link} from "./dom/resource/link.mjs"
33
- export {Script} from "./dom/resource/script.mjs"
34
- export {Updater, addObjectWithUpdaterToElement} from "./dom/updater.mjs"
35
- export {CustomControl} from "./dom/customcontrol.mjs"
36
- export {getLocaleOfDocument} from "./dom/locale.mjs"
37
- export {Theme, getDocumentTheme} from "./dom/theme.mjs"
38
- export {Resource, KEY_DOCUMENT, KEY_QUERY, referenceSymbol} from "./dom/resource.mjs"
39
- export {ResourceManager} from "./dom/resourcemanager.mjs"
40
- export {getDocument, getWindow, getDocumentFragmentFromString} from "./dom/util.mjs"
17
+ export { IsObject } from "./constraints/isobject.mjs";
18
+ export { Invalid } from "./constraints/invalid.mjs";
19
+ export { AndOperator } from "./constraints/andoperator.mjs";
20
+ export { OrOperator } from "./constraints/oroperator.mjs";
21
+ export { AbstractConstraint } from "./constraints/abstract.mjs";
22
+ export { IsArray } from "./constraints/isarray.mjs";
23
+ export { AbstractOperator } from "./constraints/abstractoperator.mjs";
24
+ export { Valid } from "./constraints/valid.mjs";
25
+ export {
26
+ Logger,
27
+ ALL,
28
+ TRACE,
29
+ DEBUG,
30
+ INFO,
31
+ WARN,
32
+ ERROR,
33
+ FATAL,
34
+ OFF,
35
+ } from "./logging/logger.mjs";
36
+ export { LogEntry } from "./logging/logentry.mjs";
37
+ export { ConsoleHandler } from "./logging/handler/console.mjs";
38
+ export { Handler } from "./logging/handler.mjs";
39
+ export { Formatter } from "./text/formatter.mjs";
40
+ export { Stylesheet } from "./dom/resource/link/stylesheet.mjs";
41
+ export { Data } from "./dom/resource/data.mjs";
42
+ export { Link } from "./dom/resource/link.mjs";
43
+ export { Script } from "./dom/resource/script.mjs";
44
+ export { Updater, addObjectWithUpdaterToElement } from "./dom/updater.mjs";
45
+ export { CustomControl } from "./dom/customcontrol.mjs";
46
+ export { getLocaleOfDocument } from "./dom/locale.mjs";
47
+ export { Theme, getDocumentTheme } from "./dom/theme.mjs";
48
+ export {
49
+ Resource,
50
+ KEY_DOCUMENT,
51
+ KEY_QUERY,
52
+ referenceSymbol,
53
+ } from "./dom/resource.mjs";
54
+ export { ResourceManager } from "./dom/resourcemanager.mjs";
55
+ export {
56
+ getDocument,
57
+ getWindow,
58
+ getDocumentFragmentFromString,
59
+ } from "./dom/util.mjs";
41
60
  export {
42
61
  DEFAULT_THEME,
43
62
  ATTRIBUTE_PREFIX,
@@ -91,17 +110,16 @@ export {
91
110
  ATTRIBUTE_EXPORTPARTS,
92
111
  ATTRIBUTE_HIDDEN,
93
112
  objectUpdaterLinkSymbol,
94
- customElementUpdaterLinkSymbol
95
-
96
- } from "./dom/constants.mjs"
113
+ customElementUpdaterLinkSymbol,
114
+ } from "./dom/constants.mjs";
97
115
  export {
98
116
  CustomElement,
99
117
  initMethodSymbol,
100
118
  assembleMethodSymbol,
101
119
  attributeObserverSymbol,
102
120
  registerCustomElement,
103
- getSlottedElements
104
- } from "./dom/customelement.mjs"
121
+ getSlottedElements,
122
+ } from "./dom/customelement.mjs";
105
123
  export {
106
124
  findClosestObjectLink,
107
125
  addToObjectLink,
@@ -115,46 +133,54 @@ export {
115
133
  replaceAttributeToken,
116
134
  clearAttributeTokens,
117
135
  findClosestByAttribute,
118
- findClosestByClass
119
- } from "./dom/attributes.mjs"
120
- export {fireEvent, fireCustomEvent, findTargetElementFromEvent} from "./dom/events.mjs"
121
- export {Factory} from "./dom/worker/factory.mjs"
122
- export {Template} from "./dom/template.mjs"
123
- export {domReady, windowReady} from "./dom/ready.mjs"
124
- export {FocusManager} from "./dom/focusmanager.mjs"
125
- export {ATTRIBUTEPREFIX, Assembler} from "./dom/assembler.mjs"
126
- export {Translations} from "./i18n/translations.mjs"
127
- export {Locale, parseLocale} from "./i18n/locale.mjs"
128
- export {Formatter as I18nFormatter} from "./i18n/formatter.mjs"
129
- export {Fetch} from "./i18n/providers/fetch.mjs"
130
- export {Provider} from "./i18n/provider.mjs"
131
- export {Message} from "./net/webconnect/message.mjs"
132
- export {WebConnect as NetWebConnect} from "./net/webconnect.mjs"
136
+ findClosestByClass,
137
+ } from "./dom/attributes.mjs";
138
+ export {
139
+ fireEvent,
140
+ fireCustomEvent,
141
+ findTargetElementFromEvent,
142
+ } from "./dom/events.mjs";
143
+ export { Factory } from "./dom/worker/factory.mjs";
144
+ export { Template } from "./dom/template.mjs";
145
+ export { domReady, windowReady } from "./dom/ready.mjs";
146
+ export { FocusManager } from "./dom/focusmanager.mjs";
147
+ export { ATTRIBUTEPREFIX, Assembler } from "./dom/assembler.mjs";
148
+ export { Translations } from "./i18n/translations.mjs";
149
+ export { Locale, parseLocale } from "./i18n/locale.mjs";
150
+ export { Formatter as I18nFormatter } from "./i18n/formatter.mjs";
151
+ export { Fetch } from "./i18n/providers/fetch.mjs";
152
+ export { Provider } from "./i18n/provider.mjs";
153
+ export { Message } from "./net/webconnect/message.mjs";
154
+ export { WebConnect as NetWebConnect } from "./net/webconnect.mjs";
133
155
  export {
134
156
  internalSymbol,
135
157
  internalStateSymbol,
136
- instanceSymbol
137
- } from "./constants.mjs"
138
- export {MediaType, parseMediaType} from "./types/mediatype.mjs"
139
- export {typeOf} from "./types/typeof.mjs"
140
- export {ObserverList} from "./types/observerlist.mjs"
141
- export {RandomID} from "./types/randomid.mjs"
142
- export {ObservableQueue} from "./types/observablequeue.mjs"
143
- export {UUID} from "./types/uuid.mjs"
144
- export {Observer} from "./types/observer.mjs"
145
- export {TokenList} from "./types/tokenlist.mjs"
146
- export {Queue} from "./types/queue.mjs"
147
- export {Stack} from "./types/stack.mjs"
148
- export {toBinary, fromBinary} from "./types/binary.mjs"
149
- export {BaseWithOptions} from "./types/basewithoptions.mjs"
150
- export {escapeString} from "./types/regex.mjs"
151
- export {ProxyObserver} from "./types/proxyobserver.mjs"
152
- export {NodeList} from "./types/nodelist.mjs"
153
- export {Version, getMonsterVersion} from "./types/version.mjs"
154
- export {Node} from "./types/node.mjs"
155
- export {NodeRecursiveIterator} from "./types/noderecursiveiterator.mjs"
156
- export {getGlobal, getGlobalObject, getGlobalFunction} from "./types/global.mjs"
157
- export {DataUrl, parseDataURL} from "./types/dataurl.mjs"
158
+ instanceSymbol,
159
+ } from "./constants.mjs";
160
+ export { MediaType, parseMediaType } from "./types/mediatype.mjs";
161
+ export { typeOf } from "./types/typeof.mjs";
162
+ export { ObserverList } from "./types/observerlist.mjs";
163
+ export { RandomID } from "./types/randomid.mjs";
164
+ export { ObservableQueue } from "./types/observablequeue.mjs";
165
+ export { UUID } from "./types/uuid.mjs";
166
+ export { Observer } from "./types/observer.mjs";
167
+ export { TokenList } from "./types/tokenlist.mjs";
168
+ export { Queue } from "./types/queue.mjs";
169
+ export { Stack } from "./types/stack.mjs";
170
+ export { toBinary, fromBinary } from "./types/binary.mjs";
171
+ export { BaseWithOptions } from "./types/basewithoptions.mjs";
172
+ export { escapeString } from "./types/regex.mjs";
173
+ export { ProxyObserver } from "./types/proxyobserver.mjs";
174
+ export { NodeList } from "./types/nodelist.mjs";
175
+ export { Version, getMonsterVersion } from "./types/version.mjs";
176
+ export { Node } from "./types/node.mjs";
177
+ export { NodeRecursiveIterator } from "./types/noderecursiveiterator.mjs";
178
+ export {
179
+ getGlobal,
180
+ getGlobalObject,
181
+ getGlobalFunction,
182
+ } from "./types/global.mjs";
183
+ export { DataUrl, parseDataURL } from "./types/dataurl.mjs";
158
184
  export {
159
185
  validateIterable,
160
186
  validatePrimitive,
@@ -165,39 +191,47 @@ export {
165
191
  validateArray,
166
192
  validateSymbol,
167
193
  validateFunction,
168
- validateInteger
169
- } from "./types/validate.mjs"
170
- export {UniqueQueue} from "./types/uniquequeue.mjs"
171
- export {Base} from "./types/base.mjs"
194
+ validateInteger,
195
+ } from "./types/validate.mjs";
196
+ export { UniqueQueue } from "./types/uniquequeue.mjs";
197
+ export { Base } from "./types/base.mjs";
172
198
  export {
173
- isIterable, isPrimitive, isSymbol, isBoolean, isString, isObject, isInstance, isArray, isFunction, isInteger
174
- } from "./types/is.mjs"
175
- export {ID} from "./types/id.mjs"
176
- export {trimSpaces} from "./util/trimspaces.mjs"
177
- export {DeadMansSwitch} from "./util/deadmansswitch.mjs"
178
- export {deepFreeze} from "./util/freeze.mjs"
179
- export {Comparator} from "./util/comparator.mjs"
180
- export {clone} from "./util/clone.mjs"
181
- export {Processing} from "./util/processing.mjs"
182
- export {extend} from "./data/extend.mjs"
183
- export {Pipe} from "./data/pipe.mjs"
184
- export {buildMap, PARENT, assembleParts} from "./data/buildmap.mjs"
185
- export {Datasource} from "./data/datasource.mjs"
186
- export {buildTree} from "./data/buildtree.mjs"
187
- export {Transformer} from "./data/transformer.mjs"
188
- export {Pathfinder, DELIMITER, WILDCARD} from "./data/pathfinder.mjs"
189
- export {diff} from "./data/diff.mjs"
190
- export {Server} from "./data/datasource/server.mjs"
191
- export {SessionStorage} from "./data/datasource/storage/sessionstorage.mjs"
192
- export {LocalStorage} from "./data/datasource/storage/localstorage.mjs"
193
- export {RestAPI} from "./data/datasource/server/restapi.mjs"
194
- export {WebConnect} from "./data/datasource/server/webconnect.mjs"
195
- export {WriteError} from "./data/datasource/server/restapi/writeerror.mjs"
196
- export {Storage, storageObjectSymbol} from "./data/datasource/storage.mjs"
197
- export {random} from "./math/random.mjs"
199
+ isIterable,
200
+ isPrimitive,
201
+ isSymbol,
202
+ isBoolean,
203
+ isString,
204
+ isObject,
205
+ isInstance,
206
+ isArray,
207
+ isFunction,
208
+ isInteger,
209
+ } from "./types/is.mjs";
210
+ export { ID } from "./types/id.mjs";
211
+ export { trimSpaces } from "./util/trimspaces.mjs";
212
+ export { DeadMansSwitch } from "./util/deadmansswitch.mjs";
213
+ export { deepFreeze } from "./util/freeze.mjs";
214
+ export { Comparator } from "./util/comparator.mjs";
215
+ export { clone } from "./util/clone.mjs";
216
+ export { Processing } from "./util/processing.mjs";
217
+ export { extend } from "./data/extend.mjs";
218
+ export { Pipe } from "./data/pipe.mjs";
219
+ export { buildMap, PARENT, assembleParts } from "./data/buildmap.mjs";
220
+ export { Datasource } from "./data/datasource.mjs";
221
+ export { buildTree } from "./data/buildtree.mjs";
222
+ export { Transformer } from "./data/transformer.mjs";
223
+ export { Pathfinder, DELIMITER, WILDCARD } from "./data/pathfinder.mjs";
224
+ export { diff } from "./data/diff.mjs";
225
+ export { Server } from "./data/datasource/server.mjs";
226
+ export { SessionStorage } from "./data/datasource/storage/sessionstorage.mjs";
227
+ export { LocalStorage } from "./data/datasource/storage/localstorage.mjs";
228
+ export { RestAPI } from "./data/datasource/server/restapi.mjs";
229
+ export { WebConnect } from "./data/datasource/server/webconnect.mjs";
230
+ export { WriteError } from "./data/datasource/server/restapi/writeerror.mjs";
231
+ export { Storage, storageObjectSymbol } from "./data/datasource/storage.mjs";
232
+ export { random } from "./math/random.mjs";
198
233
 
199
-
200
- export {Monster}
234
+ export { Monster };
201
235
 
202
236
  /**
203
237
  * This class has no other purpose than to exist.
@@ -207,6 +241,4 @@ export {Monster}
207
241
  * @copyright schukai GmbH
208
242
  * @memberOf Monster
209
243
  */
210
- class Monster {
211
-
212
- }
244
+ class Monster {}
@@ -3,8 +3,6 @@
3
3
  * SPDX-License-Identifier: AGPL-3.0
4
4
  */
5
5
 
6
-
7
-
8
6
  /**
9
7
  * In this namespace you will find classes and methods for handling connections.
10
8
  *
@@ -12,4 +10,4 @@
12
10
  * @memberOf Monster
13
11
  * @author schukai GmbH
14
12
  */
15
- const ns = {};
13
+ const ns = {};
@@ -5,10 +5,10 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from "../../types/base.mjs";
9
- import {validateObject, validateString} from "../../types/validate.mjs";
8
+ import { Base } from "../../types/base.mjs";
9
+ import { validateObject, validateString } from "../../types/validate.mjs";
10
10
 
11
- export {Message}
11
+ export { Message };
12
12
 
13
13
  const dataSymbol = Symbol("@@data");
14
14
 
@@ -22,7 +22,6 @@ const dataSymbol = Symbol("@@data");
22
22
  * @summary The Message class encapsulates a WebSocket message.
23
23
  */
24
24
  class Message extends Base {
25
-
26
25
  /**
27
26
  * @param {Object} data
28
27
  * @throws {TypeError} value is not a object
@@ -31,10 +30,10 @@ class Message extends Base {
31
30
  super();
32
31
  this[dataSymbol] = validateObject(data);
33
32
  }
34
-
33
+
35
34
  /**
36
35
  * Returns the raw message.
37
- *
36
+ *
38
37
  * @returns {object}
39
38
  */
40
39
  getData() {
@@ -57,5 +56,4 @@ class Message extends Base {
57
56
  validateString(json);
58
57
  return new Message(JSON.parse(json));
59
58
  }
60
-
61
- }
59
+ }
@@ -3,8 +3,6 @@
3
3
  * SPDX-License-Identifier: AGPL-3.0
4
4
  */
5
5
 
6
-
7
-
8
6
  /**
9
7
  * In this namespace you will find classes and methods for handling data.
10
8
  *
@@ -12,4 +10,4 @@
12
10
  * @memberOf Monster.Net
13
11
  * @author schukai GmbH
14
12
  */
15
- const ns = {};
13
+ const ns = {};
@@ -5,14 +5,13 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {instanceSymbol} from "../constants.mjs";
9
- import {isInteger, isString, isObject} from "../types/is.mjs";
10
- import {BaseWithOptions} from "../types/basewithoptions.mjs";
11
- import {ObservableQueue} from "../types/observablequeue.mjs";
12
- import {Message} from "./webconnect/message.mjs";
8
+ import { instanceSymbol } from "../constants.mjs";
9
+ import { isInteger, isString, isObject } from "../types/is.mjs";
10
+ import { BaseWithOptions } from "../types/basewithoptions.mjs";
11
+ import { ObservableQueue } from "../types/observablequeue.mjs";
12
+ import { Message } from "./webconnect/message.mjs";
13
13
 
14
-
15
- export {WebConnect}
14
+ export { WebConnect };
16
15
 
17
16
  /**
18
17
  * @private
@@ -57,7 +56,7 @@ const connectionStatusCode = {
57
56
  1009: "Message too big",
58
57
  1010: "Mandatory extension",
59
58
  1011: "Internal server error",
60
- 1015: "TLS handshake"
59
+ 1015: "TLS handshake",
61
60
  };
62
61
 
63
62
  /**
@@ -68,15 +67,15 @@ const connectionStatusCode = {
68
67
  function connectServer(resolve, reject) {
69
68
  const self = this;
70
69
 
71
- const url = self.getOption('url');
70
+ const url = self.getOption("url");
72
71
  if (!url) {
73
- reject('No url defined for webconnect.');
72
+ reject("No url defined for webconnect.");
74
73
  return;
75
74
  }
76
75
 
77
76
  let promiseAllredyResolved = false;
78
77
 
79
- let connectionTimeout = self.getOption('connection.timeout');
78
+ let connectionTimeout = self.getOption("connection.timeout");
80
79
  if (!isInteger(connectionTimeout) || connectionTimeout < 100) {
81
80
  connectionTimeout = 5000;
82
81
  }
@@ -88,11 +87,11 @@ function connectServer(resolve, reject) {
88
87
  reject(new Error("Connection timeout"));
89
88
  }, connectionTimeout);
90
89
 
91
- let reconnectTimeout = self.getOption('connection.reconnect.timeout');
90
+ let reconnectTimeout = self.getOption("connection.reconnect.timeout");
92
91
  if (!isInteger(reconnectTimeout) || reconnectTimeout < 1000) reconnectTimeout = 1000;
93
- let reconnectAttempts = self.getOption('connection.reconnect.attempts');
92
+ let reconnectAttempts = self.getOption("connection.reconnect.attempts");
94
93
  if (!isInteger(reconnectAttempts) || reconnectAttempts < 1) reconnectAttempts = 1;
95
- let reconnectEnabled = self.getOption('connection.reconnect.enabled');
94
+ let reconnectEnabled = self.getOption("connection.reconnect.enabled");
96
95
  if (reconnectEnabled !== true) reconnectEnabled = false;
97
96
 
98
97
  self[manualCloseSymbol] = false;
@@ -108,7 +107,7 @@ function connectServer(resolve, reject) {
108
107
  if (event.data instanceof Blob) {
109
108
  const reader = new FileReader();
110
109
  reader.addEventListener("loadend", function () {
111
- self[receiveQueueSymbol].add(new Message(reader.result))
110
+ self[receiveQueueSymbol].add(new Message(reader.result));
112
111
  });
113
112
  reader.readAsText(new Message(event.data));
114
113
  } else {
@@ -118,14 +117,13 @@ function connectServer(resolve, reject) {
118
117
 
119
118
  self[connectionSymbol].socket.onopen = function () {
120
119
  self[connectionSymbol].reconnectCounter = 0;
121
- if (typeof resolve === 'function' && !promiseAllredyResolved) {
120
+ if (typeof resolve === "function" && !promiseAllredyResolved) {
122
121
  promiseAllredyResolved = true;
123
122
  resolve();
124
123
  }
125
124
  };
126
125
 
127
126
  self[connectionSymbol].socket.close = function (event) {
128
-
129
127
  if (self[manualCloseSymbol]) {
130
128
  self[manualCloseSymbol] = false;
131
129
  return;
@@ -136,22 +134,19 @@ function connectServer(resolve, reject) {
136
134
  self.connect();
137
135
  }, reconnectTimeout * this[connectionSymbol].reconnectCounter);
138
136
  }
139
-
140
137
  };
141
138
 
142
139
  self[connectionSymbol].socket.onerror = (error) => {
143
-
144
140
  if (reconnectEnabled && self[connectionSymbol].reconnectCounter < reconnectAttempts) {
145
141
  setTimeout(() => {
146
142
  self.connect();
147
143
  }, reconnectTimeout * this[connectionSymbol].reconnectCounter);
148
144
  } else {
149
- if (typeof reject === 'function' && !promiseAllredyResolved) {
145
+ if (typeof reject === "function" && !promiseAllredyResolved) {
150
146
  promiseAllredyResolved = true;
151
147
  reject(error);
152
148
  }
153
149
  }
154
-
155
150
  };
156
151
  }
157
152
 
@@ -166,17 +161,15 @@ function connectServer(resolve, reject) {
166
161
  * @summary The LocalStorage class encapsulates the access to data objects.
167
162
  */
168
163
  class WebConnect extends BaseWithOptions {
169
-
170
164
  /**
171
165
  *
172
166
  * @param {Object} [options] options contains definitions for the webconnect.
173
167
  */
174
168
  constructor(options) {
175
-
176
169
  if (isString(options)) {
177
- options = {url: options};
170
+ options = { url: options };
178
171
  }
179
-
172
+
180
173
  super(options);
181
174
 
182
175
  this[receiveQueueSymbol] = new ObservableQueue();
@@ -232,8 +225,8 @@ class WebConnect extends BaseWithOptions {
232
225
  timeout: 1000,
233
226
  attempts: 1,
234
227
  enabled: false,
235
- }
236
- }
228
+ },
229
+ },
237
230
  });
238
231
  }
239
232
 
@@ -245,12 +238,12 @@ class WebConnect extends BaseWithOptions {
245
238
  * @returns {Promise}
246
239
  * @see https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
247
240
  */
248
- close(statusCode, reason ) {
241
+ close(statusCode, reason) {
249
242
  if (!isInteger(statusCode) || statusCode < 1000 || statusCode > 4999) {
250
243
  statusCode = 1000;
251
244
  }
252
245
  if (!isString(reason)) {
253
- reason = '';
246
+ reason = "";
254
247
  }
255
248
 
256
249
  return new Promise((resolve, reject) => {
@@ -264,12 +257,11 @@ class WebConnect extends BaseWithOptions {
264
257
  }
265
258
  resolve();
266
259
  });
267
-
268
260
  }
269
261
 
270
262
  /**
271
263
  * Polls the receive queue for new messages.
272
- *
264
+ *
273
265
  * @returns {Message}
274
266
  */
275
267
  poll() {
@@ -277,8 +269,8 @@ class WebConnect extends BaseWithOptions {
277
269
  }
278
270
 
279
271
  /**
280
- * Are there any messages in the receive queue?
281
- *
272
+ * Are there any messages in the receive queue?
273
+ *
282
274
  * @returns {boolean}
283
275
  */
284
276
  dataReceived() {
@@ -287,7 +279,7 @@ class WebConnect extends BaseWithOptions {
287
279
 
288
280
  /**
289
281
  * Get Message from the receive queue, but do not remove it.
290
- *
282
+ *
291
283
  * @returns {Object}
292
284
  */
293
285
  peek() {
@@ -332,15 +324,12 @@ class WebConnect extends BaseWithOptions {
332
324
  const self = this;
333
325
 
334
326
  return new Promise((resolve, reject) => {
335
-
336
327
  if (self[connectionSymbol].socket.readyState !== 1) {
337
- reject('the socket is not ready');
328
+ reject("the socket is not ready");
338
329
  }
339
330
 
340
- self[connectionSymbol].socket.send(JSON.stringify(message))
331
+ self[connectionSymbol].socket.send(JSON.stringify(message));
341
332
  resolve();
342
333
  });
343
334
  }
344
-
345
335
  }
346
-