jsf.js_next_gen 4.0.0-beta-23 → 4.0.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 (200) hide show
  1. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  2. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  3. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  4. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/README.md +7 -22
  7. package/dist/docs/assets/main.js +56 -52
  8. package/dist/docs/assets/search.js +1 -1
  9. package/dist/docs/assets/style.css +23 -0
  10. package/dist/docs/functions/faces.ajax.addOnError.html +6 -4
  11. package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
  12. package/dist/docs/functions/faces.ajax.request.html +7 -7
  13. package/dist/docs/functions/faces.ajax.response.html +0 -1
  14. package/dist/docs/functions/faces.push.close.html +4 -2
  15. package/dist/docs/functions/faces.push.init.html +19 -7
  16. package/dist/docs/functions/faces.push.open.html +4 -2
  17. package/dist/docs/functions/faces.util.chain.html +3 -3
  18. package/dist/docs/functions/myfaces.ab.html +9 -4
  19. package/dist/docs/functions/myfaces.onOnDomReady.html +72 -0
  20. package/dist/docs/index.html +7 -18
  21. package/dist/docs/modules/myfaces.html +3 -1
  22. package/dist/docs/variables/myfaces.oam.html +2 -1
  23. package/dist/window/faces-development.js +2147 -1779
  24. package/dist/window/faces-development.js.br +0 -0
  25. package/dist/window/faces-development.js.gz +0 -0
  26. package/dist/window/faces-development.js.map +1 -1
  27. package/dist/window/faces.js +1 -1
  28. package/dist/window/faces.js.LICENSE.txt +17 -2
  29. package/dist/window/faces.js.br +0 -0
  30. package/dist/window/faces.js.gz +0 -0
  31. package/dist/window/faces.js.map +1 -1
  32. package/dist/window/jsf-development.js +2156 -1777
  33. package/dist/window/jsf-development.js.br +0 -0
  34. package/dist/window/jsf-development.js.gz +0 -0
  35. package/dist/window/jsf-development.js.map +1 -1
  36. package/dist/window/jsf.js +1 -1
  37. package/dist/window/jsf.js.LICENSE.txt +17 -2
  38. package/dist/window/jsf.js.br +0 -0
  39. package/dist/window/jsf.js.gz +0 -0
  40. package/dist/window/jsf.js.map +1 -1
  41. package/package.json +19 -18
  42. package/pom.xml +1 -1
  43. package/src/main/test.xml +23 -0
  44. package/src/main/typescript/@types/definitions/index.d.ts +24 -7
  45. package/src/main/typescript/api/_api.ts +79 -37
  46. package/src/main/typescript/api/jsf.ts +18 -0
  47. package/src/main/typescript/impl/AjaxImpl.ts +168 -78
  48. package/src/main/typescript/impl/PushImpl.ts +63 -38
  49. package/src/main/typescript/impl/core/Const.ts +52 -39
  50. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  51. package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
  52. package/src/main/typescript/impl/util/AsyncRunnable.ts +4 -4
  53. package/src/main/typescript/impl/util/ExtDomQuery.ts +58 -45
  54. package/src/main/typescript/impl/util/FileUtils.ts +104 -0
  55. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
  56. package/src/main/typescript/impl/util/Lang.ts +30 -31
  57. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  58. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  59. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
  60. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
  61. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
  62. package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
  63. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +202 -131
  64. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +79 -166
  65. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -68
  66. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  67. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +19 -22
  68. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +108 -1
  69. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  70. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  71. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
  72. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  73. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  74. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  75. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  76. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  77. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +242 -11
  78. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  79. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +373 -35
  80. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  81. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
  82. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  83. package/src/main/typescript/test.xml +6 -0
  84. package/src/main/typescript/tsconfig.json +1 -1
  85. package/src/test/resources/jsf-development.js +1 -1
  86. package/src/tmp/test.html +12 -88
  87. package/target/api/_api.js +72 -31
  88. package/target/api/_api.js.map +1 -1
  89. package/target/api/jsf.js +11 -0
  90. package/target/api/jsf.js.map +1 -1
  91. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  92. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  93. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  94. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  95. package/target/impl/AjaxImpl.js +144 -59
  96. package/target/impl/AjaxImpl.js.map +1 -1
  97. package/target/impl/PushImpl.js +66 -35
  98. package/target/impl/PushImpl.js.map +1 -1
  99. package/target/impl/core/Const.js +51 -38
  100. package/target/impl/core/Const.js.map +1 -1
  101. package/target/impl/core/Context.js +10 -0
  102. package/target/impl/core/Context.js.map +1 -0
  103. package/target/impl/util/Assertions.js +12 -7
  104. package/target/impl/util/Assertions.js.map +1 -1
  105. package/target/impl/util/AsyncQueue.js.map +1 -1
  106. package/target/impl/util/ExtDomQuery.js +58 -40
  107. package/target/impl/util/ExtDomQuery.js.map +1 -1
  108. package/target/impl/util/FileUtils.js +96 -0
  109. package/target/impl/util/FileUtils.js.map +1 -0
  110. package/target/impl/util/HiddenElementBuilder.js +7 -0
  111. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  112. package/target/impl/util/HiddenInputBuilder.js +79 -0
  113. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  114. package/target/impl/util/Lang.js +29 -30
  115. package/target/impl/util/Lang.js.map +1 -1
  116. package/target/impl/util/URLCodec.js +77 -0
  117. package/target/impl/util/URLCodec.js.map +1 -0
  118. package/target/impl/util/XhrQueueController.js +82 -0
  119. package/target/impl/util/XhrQueueController.js.map +1 -0
  120. package/target/impl/xhrCore/ErrorData.js +10 -8
  121. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  122. package/target/impl/xhrCore/EventData.js +1 -1
  123. package/target/impl/xhrCore/EventData.js.map +1 -1
  124. package/target/impl/xhrCore/RequestContext.js +11 -0
  125. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  126. package/target/impl/xhrCore/RequestDataResolver.js +70 -23
  127. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  128. package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
  129. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  130. package/target/impl/xhrCore/Response.js +44 -29
  131. package/target/impl/xhrCore/Response.js.map +1 -1
  132. package/target/impl/xhrCore/ResponseProcessor.js +182 -116
  133. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  134. package/target/impl/xhrCore/XhrFormData.js +68 -156
  135. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  136. package/target/impl/xhrCore/XhrQueHandler.js +11 -0
  137. package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
  138. package/target/impl/xhrCore/XhrQueueController.js +62 -0
  139. package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
  140. package/target/impl/xhrCore/XhrRequest.js +68 -59
  141. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  142. package/target/myfaces/OamSubmit.js +23 -14
  143. package/target/myfaces/OamSubmit.js.map +1 -1
  144. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +16 -16
  145. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  146. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
  147. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
  148. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
  149. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
  150. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
  151. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
  152. package/target/test/frameworkBase/_ext/shared/StandardInits.js +100 -1
  153. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  154. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  155. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  156. package/target/test/impl/ImplTest.spec.js +2 -2
  157. package/target/test/impl/ImplTest.spec.js.map +1 -1
  158. package/target/test/impl/ImplTest_23.spec.js +2 -2
  159. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  160. package/target/test/myfaces/OnLoadSpec.js +57 -0
  161. package/target/test/myfaces/OnLoadSpec.js.map +1 -0
  162. package/target/test/xhrCore/EventTests.spec.js +1 -1
  163. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  164. package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
  165. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  166. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  167. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  168. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  169. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  170. package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
  171. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  172. package/target/test/xhrCore/RequestTest.spec.js +217 -9
  173. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  174. package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
  175. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  176. package/target/test/xhrCore/ResponseTest.spec.js +308 -24
  177. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  178. package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
  179. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  180. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
  181. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
  182. package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
  183. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  184. package/target/test-classes/.gz +0 -0
  185. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  186. package/target/test-classes/fileuploadtest.html +24 -0
  187. package/target/test-classes/jsf-development.js +3559 -0
  188. package/target/test-classes/jsf-development.js.br +0 -0
  189. package/target/test-classes/jsf-development.js.gz +0 -0
  190. package/target/test-classes/jsf-development.js.map +1 -0
  191. package/target/test-classes/jsf.js +3 -0
  192. package/target/test-classes/jsf.js.br +0 -0
  193. package/target/test-classes/jsf.js.gz +0 -0
  194. package/tmp.xml +36 -0
  195. package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  196. package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  197. package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  198. package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  199. package/target/types/index.js +0 -18
  200. package/target/types/index.js.map +0 -1
@@ -15,25 +15,21 @@
15
15
  */
16
16
 
17
17
  /**
18
- * Typescript port of the faces.push part in the myfaces implementation
18
+ * Typescript port of the faces\.push part in the myfaces implementation
19
19
  */
20
-
21
- //TODO still work in progress
22
- //this is a 1:1 port for the time being
23
20
  import {MAX_RECONNECT_ATTEMPTS, REASON_EXPIRED, RECONNECT_INTERVAL} from "./core/Const";
24
- ;
25
-
21
+ import {DQ} from "mona-dish";
26
22
 
27
23
  /**
28
24
  * Implementation class for the push functionality
29
25
  */
30
26
  export module PushImpl {
31
27
 
32
- const URL_PROTOCOL = window.location.protocol.replace("http", "ws") + "//";
28
+ const URL_PROTOCOL = DQ.global().location.protocol.replace("http", "ws") + "//";
33
29
 
34
30
 
35
- //we expose the member variables for testing purposes
36
- //they are not directly touched outside of tests
31
+ // we expose the member variables for testing purposes
32
+ // they are not directly touched outside of tests
37
33
 
38
34
  /* socket map by token */
39
35
  export let sockets = {};
@@ -43,7 +39,7 @@ export module PushImpl {
43
39
  export let clientIdsByTokens = {};
44
40
 
45
41
 
46
- //needed for testing
42
+ // needed for testing
47
43
  export function reset() {
48
44
  sockets = {};
49
45
  components = {}
@@ -55,58 +51,64 @@ export module PushImpl {
55
51
  */
56
52
 
57
53
  /**
58
- *
59
- * @param {function} onopen The function to be invoked when the web socket is opened.
60
- * @param {function} onmessage The function to be invoked when a message is received.
61
- * @param {function} onclose The function to be invoked when the web socket is closed.
62
- * @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.
54
+ * @param socketClientId the sockets client identifier
55
+ * @param url the uri to reach the socket
56
+ * @param channel the channel name/id
57
+ * @param onopen The function to be invoked when the web socket is opened.
58
+ * @param onmessage The function to be invoked when a message is received.
59
+ * @param onerror The function to be invoked when an error occurs.
60
+ * @param onclose The function to be invoked when the web socket is closed.
61
+ * @param behaviors functions which are invoked whenever a message is received
62
+ * @param autoConnect Whether or not to automatically open the socket. Defaults to <code>false</code>.
63
63
  */
64
64
  export function init(socketClientId: string,
65
- uri: string,
65
+ url: string,
66
66
  channel: string,
67
67
  onopen: Function,
68
68
  onmessage: Function,
69
+ onerror: Function,
69
70
  onclose: Function,
70
- behaviorScripts: any,
71
- autoconnect: boolean) {
71
+ behaviors: any,
72
+ autoConnect: boolean) {
72
73
  onclose = resolveFunction(onclose);
73
74
 
74
- if (!window.WebSocket) { // IE6-9.
75
+ if (!DQ.global().WebSocket) { // IE6-9.
75
76
  onclose(-1, channel);
76
77
  return;
77
78
  }
78
79
 
79
- let channelToken = uri.substr(uri.indexOf('?') + 1);
80
+ let channelToken = url.substr(url.indexOf('?') + 1);
80
81
 
81
82
  if (!components[socketClientId]) {
82
83
  components[socketClientId] = {
83
84
  'channelToken': channelToken,
84
85
  'onopen': resolveFunction(onopen),
85
86
  'onmessage' : resolveFunction(onmessage),
87
+ 'onerror' : resolveFunction(onerror),
86
88
  'onclose': onclose,
87
- 'behaviors': behaviorScripts,
88
- 'autoconnect': autoconnect};
89
+ 'behaviors': behaviors,
90
+ 'autoconnect': autoConnect};
89
91
  if (!clientIdsByTokens[channelToken]) {
90
92
  clientIdsByTokens[channelToken] = [];
91
93
  }
92
94
  clientIdsByTokens[channelToken].push(socketClientId);
93
95
  if (!sockets[channelToken]){
94
96
  sockets[channelToken] = new Socket(channelToken,
95
- getBaseURL(uri), channel);
97
+ getBaseURL(url), channel);
96
98
  }
97
99
  }
98
100
 
99
- if (autoconnect) {
100
- (window?.faces ?? window?.jsf).push.open(socketClientId);
101
+ if (autoConnect) {
102
+ (DQ.global()?.faces ?? DQ.global()?.jsf).push.open(socketClientId);
101
103
  }
102
104
  }
103
105
 
104
106
  export function open(socketClientId: string) {
105
- getSocket(components?.[socketClientId]?.channelToken).open();
107
+ getSocket(components[socketClientId]?.channelToken).open();
106
108
  }
107
109
 
108
110
  export function close(socketClientId: string) {
109
- getSocket(components?.[socketClientId].channelToken).close();
111
+ getSocket(components[socketClientId].channelToken).close();
110
112
  }
111
113
 
112
114
  // Private helper classes
@@ -138,29 +140,51 @@ export module PushImpl {
138
140
  this.bindCallbacks();
139
141
  }
140
142
 
143
+ // noinspection JSUnusedLocalSymbols
141
144
  onopen(event: any) {
142
145
  if (!this.reconnectAttempts) {
143
146
  let clientIds = clientIdsByTokens[this.channelToken];
144
147
  for (let i = clientIds.length - 1; i >= 0; i--) {
145
148
  let socketClientId = clientIds[i];
146
- components[socketClientId]['onopen'](this.channel);
149
+ components[socketClientId]?.['onopen']?.(this.channel);
147
150
  }
148
151
  }
149
152
  this.reconnectAttempts = 0;
150
153
  }
151
154
 
155
+ onerror(event: any) {
156
+ let message = JSON.parse(event.data);
157
+ //TODO replace this with a more readable Stream code
158
+ for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
159
+ let socketClientId = clientIdsByTokens[this.channelToken][i];
160
+ if (document.getElementById(socketClientId)) {
161
+ try {
162
+ components[socketClientId]?.['onerror']?.(message, this.channel, event);
163
+ } catch (e) {
164
+ //Ignore
165
+ }
166
+ } else {
167
+ clientIdsByTokens[this.channelToken].splice(i, 1);
168
+ }
169
+ }
170
+ if (clientIdsByTokens[this.channelToken].length == 0) {
171
+ // tag disappeared
172
+ this.close();
173
+ }
174
+ }
175
+
152
176
  onmmessage(event: any) {
153
177
  let message = JSON.parse(event.data);
154
178
  for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
155
179
  let socketClientId = clientIdsByTokens[this.channelToken][i];
156
180
  if (document.getElementById(socketClientId)) {
157
181
  try {
158
- components[socketClientId]['onmessage'](message, this.channel, event);
182
+ components[socketClientId]?.['onmessage']?.(message, this.channel, event);
159
183
  } catch (e) {
160
184
  //Ignore
161
185
  }
162
- let behaviors = components[socketClientId]['behaviors'];
163
- let functions = behaviors[message];
186
+ let behaviors = components?.[socketClientId]?.['behaviors'];
187
+ let functions = behaviors?.[message];
164
188
  if (functions && functions.length) {
165
189
  for (let j = 0; j < functions.length; j++) {
166
190
  try {
@@ -175,7 +199,7 @@ export module PushImpl {
175
199
  }
176
200
  }
177
201
  if (clientIdsByTokens[this.channelToken].length == 0) {
178
- //tag dissapeared
202
+ // tag disappeared
179
203
  this.close();
180
204
  }
181
205
  }
@@ -189,7 +213,7 @@ export module PushImpl {
189
213
  let clientIds = clientIdsByTokens[this.channelToken];
190
214
  for (let i = clientIds.length - 1; i >= 0; i--) {
191
215
  let socketClientId = clientIds[i];
192
- components[socketClientId]['onclose'](event?.code, this?.channel, event);
216
+ components?.[socketClientId]?.['onclose']?.(event?.code, this?.channel, event);
193
217
  }
194
218
  } else {
195
219
  setTimeout(this.open, RECONNECT_INTERVAL * this.reconnectAttempts++);
@@ -211,6 +235,7 @@ export module PushImpl {
211
235
  this.socket.onopen = (event: Event) => this.onopen(event);
212
236
  this.socket.onmessage = (event: Event) => this.onmmessage(event);
213
237
  this.socket.onclose = (event: Event) => this.onclose(event);
238
+ this.socket.onerror = (event: Event) => this.onerror(event);
214
239
  }
215
240
  }
216
241
 
@@ -218,7 +243,7 @@ export module PushImpl {
218
243
 
219
244
  function getBaseURL(url: string) {
220
245
  if (url.indexOf("://") < 0) {
221
- let base = window.location.hostname + ":" + window.location.port;
246
+ let base = DQ.global().location.hostname + ":" + DQ.global().location.port;
222
247
  return URL_PROTOCOL + base + url;
223
248
  } else {
224
249
  return url;
@@ -227,9 +252,9 @@ export module PushImpl {
227
252
 
228
253
  /**
229
254
  * Get socket associated with given channelToken.
230
- * @param {string} channelToken The name of the web socket channelToken.
231
- * @return {Socket} Socket associated with given channelToken.
232
- * @throws {Error} When channelToken is unknown, you may need to initialize
255
+ * @param channelToken The name of the web socket channelToken.
256
+ * @return Socket associated with given channelToken.
257
+ * @throws Error, when the channelToken is unknown, you may need to initialize
233
258
  * it first via <code>init()</code> function.
234
259
  */
235
260
  function getSocket(channelToken: string): Socket {
@@ -243,7 +268,7 @@ export module PushImpl {
243
268
 
244
269
  function resolveFunction(fn: Function | string = () => {
245
270
  }): Function {
246
- return <Function>((typeof fn !== "function") && (fn = window[fn]), fn);
271
+ return <Function>((typeof fn !== "function") && (fn = DQ.global()[fn]), fn);
247
272
  }
248
273
 
249
274
  }
@@ -17,9 +17,16 @@
17
17
  /*
18
18
  * [export const] constants
19
19
  */
20
+
21
+ export const XML_ATTR_NAMED_VIEWROOT = "namedViewRoot";
22
+ export const NAMED_VIEWROOT = "namedViewRoot";
23
+
20
24
  export const P_PARTIAL_SOURCE = "jakarta.faces.source";
21
- export const PARTIAL_ID = "partialId";
25
+ export const NAMING_CONTAINER_ID = "myfaces.partialId";
26
+
27
+ export const VIEW_ID = "myfaces.viewId";
22
28
  export const P_VIEWSTATE = "jakarta.faces.ViewState";
29
+ export const P_CLIENT_WINDOW = "jakarta.faces.ClientWindow";
23
30
  export const P_VIEWROOT = "jakarta.faces.ViewRoot";
24
31
  export const P_VIEWHEAD = "jakarta.faces.ViewHead";
25
32
  export const P_VIEWBODY = "jakarta.faces.ViewBody";
@@ -33,7 +40,8 @@ export const EMPTY_FUNC = Object.freeze(() => {
33
40
  export const EMPTY_STR = "";
34
41
  export const EMPTY_MAP = Object.freeze({});
35
42
 
36
- export const HTML_VIEWSTATE = ["<input type='hidden'", "id='", P_VIEWSTATE, "' name='", P_VIEWSTATE, "' value='' />"].join(EMPTY_STR);
43
+ export const HTML_VIEWSTATE = ["<input type='hidden'", "name='", P_VIEWSTATE, "' value='' />"].join(EMPTY_STR);
44
+ export const HTML_CLIENT_WINDOW = ["<input type='hidden'", "' name='", P_CLIENT_WINDOW, "' value='' />"].join(EMPTY_STR);
37
45
 
38
46
 
39
47
  /*internal identifiers for options*/
@@ -46,8 +54,10 @@ export const IDENT_FORM = "@form";
46
54
  export const P_AJAX = "jakarta.faces.partial.ajax";
47
55
  export const P_EXECUTE = "jakarta.faces.partial.execute";
48
56
  export const P_RENDER = "jakarta.faces.partial.render";
57
+ /*render override for viewbody or viewroot, in both cases an all is performed*/
58
+ export const P_RENDER_OVERRIDE = "_myfaces.rendeOverride";
49
59
  export const P_EVT = "jakarta.faces.partial.event";
50
- export const P_CLIENT_WINDOW = "jakarta.faces.ClientWindow";
60
+
51
61
  export const P_RESET_VALUES = "jakarta.faces.partial.resetValues";
52
62
  export const P_WINDOW_ID = "jakarta.faces.windowId";
53
63
 
@@ -87,19 +97,17 @@ export const SERVER_ERROR = "serverError";
87
97
  export const CLIENT_ERROR = "clientError";
88
98
  export const TIMEOUT_EVENT = "timeout";
89
99
 
90
- export const CTX_PARAM_MF_INTERNAL = "_mfInternal";
91
-
92
- export const CTX_PARAM_SRC_FRM_ID = "_mfSourceFormId";
93
- export const CTX_PARAM_SRC_CTL_ID = "_mfSourceControlId";
94
- export const CTX_PARAM_TR_TYPE = "_mfTransportType";
95
- export const CTX_PARAM_PASS_THR = "passThrgh";
96
- export const CTX_PARAM_DELAY = "delay";
97
- export const CTX_PARAM_TIMEOUT = "timeout";
98
- export const CTX_PARAM_RST = "resetValues";
99
- export const CTX_PARAM_EXECUTE = "execute";
100
-
101
- export const STAGE_DEVELOPMENT = "Development";
100
+ export const CTX_OPTIONS_PARAMS = "params";
101
+ export const CTX_OPTIONS_DELAY = "delay";
102
+ export const DELAY_NONE = 'none';
103
+ export const CTX_OPTIONS_TIMEOUT = "timeout";
104
+ export const CTX_OPTIONS_RESET = "resetValues";
105
+ export const CTX_OPTIONS_EXECUTE = "execute";
102
106
 
107
+ export const CTX_PARAM_MF_INTERNAL = "myfaces.internal";
108
+ export const CTX_PARAM_SRC_FRM_ID = "myfaces.source.formId";
109
+ export const CTX_PARAM_SRC_CTL_ID = "myfaces.source.controlId";
110
+ export const CTX_PARAM_REQ_PASS_THR = "myfaces.request.passThrough";
103
111
 
104
112
  export const CONTENT_TYPE = "Content-Type";
105
113
  export const HEAD_FACES_REQ = "Faces-Request";
@@ -116,13 +124,12 @@ export const MULTIPART = "multipart/form-data";
116
124
  export const NO_TIMEOUT = 0;
117
125
  export const STD_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
118
126
 
119
- export const TAG_HEAD = "head";
120
- export const TAG_FORM = "form";
121
- export const TAG_BODY = "body";
122
- export const TAG_BEFORE = "before";
123
- export const TAG_AFTER = "after";
124
-
125
- export const TAG_ATTR = "attribute";
127
+ export const HTML_TAG_HEAD = "HEAD";
128
+ export const HTML_TAG_FORM = "FORM";
129
+ export const HTML_TAG_BODY = "BODY";
130
+ export const HTML_TAG_LINK = "LINK";
131
+ export const HTML_TAG_SCRIPT = "SCRIPT";
132
+ export const HTML_TAG_STYLE = "STYLE";
126
133
 
127
134
 
128
135
  export const SEL_VIEWSTATE_ELEM = "[name='" + P_VIEWSTATE + "']";
@@ -140,38 +147,40 @@ export const ATTR_VALUE = "value";
140
147
  export const ATTR_ID = "id";
141
148
 
142
149
  /*partial response types*/
143
- export const RESP_PARTIAL = "partial-response";
150
+ export const XML_TAG_PARTIAL_RESP = "partial-response";
144
151
 
145
152
  /*partial commands*/
146
- export const CMD_CHANGES = "changes";
147
- export const CMD_UPDATE = "update";
148
- export const CMD_DELETE = "delete";
149
- export const CMD_INSERT = "insert";
150
- export const CMD_EVAL = "eval";
151
- export const CMD_ERROR = "error";
152
- export const CMD_ATTRIBUTES = "attributes";
153
- export const CMD_EXTENSION = "extension";
154
- export const CMD_REDIRECT = "redirect";
153
+ export const XML_TAG_CHANGES = "changes";
154
+ export const XML_TAG_UPDATE = "update";
155
+ export const XML_TAG_DELETE = "delete";
156
+ export const XML_TAG_INSERT = "insert";
157
+ export const XML_TAG_EVAL = "eval";
158
+ export const XML_TAG_ERROR = "error";
159
+ export const XML_TAG_ATTRIBUTES = "attributes";
160
+ export const XML_TAG_EXTENSION = "extension";
161
+ export const XML_TAG_REDIRECT = "redirect";
162
+ export const XML_TAG_BEFORE = "before";
163
+ export const XML_TAG_AFTER = "after";
164
+ export const XML_TAG_ATTR = "attribute";
165
+
155
166
 
156
167
  /*other constants*/
157
168
 
158
- export const UPDATE_FORMS = "_updateForms";
159
- export const UPDATE_ELEMS = "_updateElems";
169
+ export const UPDATE_FORMS = "myfaces.updateForms";
170
+ export const UPDATE_ELEMS = "myfaces.updateElems";
160
171
 
161
172
  //we want the head elements to be processed before we process the body
162
173
  //but after the inner html is done
163
- export const DEFERRED_HEAD_INSERTS = "_headElems";
174
+ export const DEFERRED_HEAD_INSERTS = "myfaces.headElems";
164
175
 
165
176
  export const MYFACES = "myfaces";
166
177
 
167
- export const SEL_SCRIPTS_STYLES = "script, style, link";
168
-
169
178
  export const MF_NONE = "__mf_none__";
170
179
 
171
180
  export const REASON_EXPIRED = "Expired";
172
181
 
173
- export const APPLIED_VST = "appliedViewState";
174
- export const APPLIED_CLIENT_WINDOW = "appliedClientWindow";
182
+ export const APPLIED_VST = "myfaces.appliedViewState";
183
+ export const APPLIED_CLIENT_WINDOW = "myfaces.appliedClientWindow";
175
184
 
176
185
  export const RECONNECT_INTERVAL = 500;
177
186
  export const MAX_RECONNECT_ATTEMPTS = 25;
@@ -186,6 +195,10 @@ export const UNKNOWN = "UNKNOWN";
186
195
  * changed to a simple value passthrough
187
196
  */
188
197
 
198
+ export function $faces(): FacesAPI {
199
+ return (window?.faces ?? window?.jsf) as FacesAPI;
200
+ }
201
+
189
202
  export function $nsp(inputNamespace?: any): any {
190
203
  if((!inputNamespace) || !inputNamespace?.replace) {
191
204
  return inputNamespace;
@@ -16,9 +16,6 @@
16
16
  import {Config, Lang, XMLQuery} from "mona-dish";
17
17
 
18
18
  import {DQ} from "mona-dish";
19
- import {ExtLang} from "./Lang";
20
- import getMessage = ExtLang.getMessage;
21
- import makeException = ExtLang.makeException;
22
19
  import {
23
20
  ATTR_URL,
24
21
  EMPTY_RESPONSE,
@@ -26,8 +23,10 @@ import {
26
23
  ON_ERROR,
27
24
  ON_EVENT,
28
25
  PHASE_PROCESS_RESPONSE,
29
- RESP_PARTIAL
26
+ XML_TAG_PARTIAL_RESP
30
27
  } from "../core/Const";
28
+ import {ExtLang} from "./Lang";
29
+
31
30
 
32
31
  /**
33
32
  * a set of internal code assertions
@@ -36,6 +35,8 @@ import {
36
35
  */
37
36
  export module Assertions {
38
37
 
38
+
39
+
39
40
  export function assertRequestIntegrity(options: Config, elem: DQ): void | never {
40
41
  /*assert if the onerror is set and once if it is set it must be of type function*/
41
42
  assertFunction(options.getIf(ON_ERROR).value);
@@ -43,12 +44,12 @@ export module Assertions {
43
44
  assertFunction(options.getIf(ON_EVENT).value);
44
45
  //improve the error messages if an empty elem is passed
45
46
  //Assertions.assertElementExists(elem);
46
- assert(elem.isPresent(), getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet", )
47
+ assert(elem.isPresent(), ExtLang.getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet", )
47
48
  }
48
49
 
49
50
  export function assertUrlExists(node: XMLQuery): void | never {
50
51
  if (node.attr(ATTR_URL).isAbsent()) {
51
- throw Assertions.raiseError(new Error(), getMessage("ERR_RED_URL", null, "_Ajaxthis.processRedirect"), "processRedirect");
52
+ throw Assertions.raiseError(new Error(), ExtLang.getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
52
53
  }
53
54
  }
54
55
 
@@ -59,7 +60,7 @@ export module Assertions {
59
60
  export function assertValidXMLResponse(responseXML: XMLQuery) : void | never {
60
61
  assert(!responseXML.isAbsent(), EMPTY_RESPONSE, PHASE_PROCESS_RESPONSE);
61
62
  assert(!responseXML.isXMLParserError(), responseXML.parserErrorText(EMPTY_STR), PHASE_PROCESS_RESPONSE);
62
- assert(responseXML.querySelectorAll(RESP_PARTIAL).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);
63
+ assert(responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);
63
64
  }
64
65
 
65
66
  /**
@@ -79,7 +80,7 @@ export module Assertions {
79
80
  let finalMessage = message ?? EMPTY_STR;
80
81
 
81
82
  //TODO clean up the messy makeException, this is a perfect case for encapsulation and sane defaults
82
- return makeException(error, finalTitle, finalName, "Response", caller || (((<any>arguments).caller) ? (<any>arguments).caller.toString() : "_raiseError"), finalMessage);
83
+ return ExtLang.makeException(error, finalTitle, finalName, "Response", caller || (((<any>arguments).caller) ? (<any>arguments).caller.toString() : "_raiseError"), finalMessage);
83
84
  }
84
85
 
85
86
  /*
@@ -103,6 +104,13 @@ export module Assertions {
103
104
  export function assertFunction(value: any, msg = EMPTY_STR, caller=EMPTY_STR, title="Assertion Error"): asserts value is Function {
104
105
  assertType(value, "function", msg, caller, title);
105
106
  }
107
+
108
+ export function assertDelay(value: any) {
109
+ if(!(value >= 0)) { // >= 0 abbreviation which covers all cases of non positive values,
110
+ // including NaN and non numeric strings, no type equality is deliberate here,
111
+ throw new Error("Invalid delay value: " + value);
112
+ }
113
+ }
106
114
  }
107
115
 
108
116
 
@@ -58,7 +58,7 @@ export class AsynchronousQueue<T extends AsyncRunnable<any>> {
58
58
  if (delay) {
59
59
  this.delayTimeout = setTimeout(() => {
60
60
  this.appendElement(element);
61
- });
61
+ }) as any;
62
62
  } else {
63
63
  this.appendElement(element);
64
64
  }
@@ -18,7 +18,7 @@
18
18
  * Asynchronous queue member for our asynchronous queue
19
19
  * Ever object in the asynchronous queue needs to implement this interface
20
20
  *
21
- * the usage should be similar as a Promise from the outside.
21
+ * the usage should be similar as Promise. from the outside.
22
22
  * but with a dedicated start point. The problem why we cannot use
23
23
  * promises here, is mostly related to the needed cancel functionality
24
24
  * and that the queue expects a runnable as entry.
@@ -42,7 +42,7 @@ export interface AsyncRunnable<T> {
42
42
  * triggered when the async run is complete
43
43
  *
44
44
  * the async runnable must register the passed function
45
- * and then triggers all the registered thens
45
+ * and then triggers all the registered then functions
46
46
  * when it is complete
47
47
  *
48
48
  * @param func
@@ -51,10 +51,10 @@ export interface AsyncRunnable<T> {
51
51
 
52
52
  /**
53
53
  * callback for catch functionality
54
- * triggered when the asynch run is complete
54
+ * triggered when the async run is complete
55
55
  *
56
56
  * the async runnable must register the passed function
57
- * and then triggers all the registered catchs
57
+ * and then triggers all the registered catch handlers
58
58
  * when an error has occurred
59
59
  *
60
60
  * @param func