jsf.js_next_gen 4.0.0-beta-23 → 4.0.1-alpha.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 (214) 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 +13 -21
  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 +2 -0
  11. package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
  12. package/dist/docs/functions/faces.push.close.html +4 -2
  13. package/dist/docs/functions/faces.push.init.html +19 -7
  14. package/dist/docs/functions/faces.push.open.html +4 -2
  15. package/dist/docs/functions/myfaces.ab.html +9 -4
  16. package/dist/docs/functions/myfaces.onDomReady.html +72 -0
  17. package/dist/docs/index.html +16 -18
  18. package/dist/docs/modules/myfaces.html +3 -1
  19. package/dist/docs/variables/myfaces.oam.html +2 -1
  20. package/dist/window/faces-development.js +2846 -2085
  21. package/dist/window/faces-development.js.br +0 -0
  22. package/dist/window/faces-development.js.gz +0 -0
  23. package/dist/window/faces-development.js.map +1 -1
  24. package/dist/window/faces.js +1 -1
  25. package/dist/window/faces.js.LICENSE.txt +17 -2
  26. package/dist/window/faces.js.br +0 -0
  27. package/dist/window/faces.js.gz +0 -0
  28. package/dist/window/faces.js.map +1 -1
  29. package/dist/window/jsf-development.js +2856 -2084
  30. package/dist/window/jsf-development.js.br +0 -0
  31. package/dist/window/jsf-development.js.gz +0 -0
  32. package/dist/window/jsf-development.js.map +1 -1
  33. package/dist/window/jsf.js +1 -1
  34. package/dist/window/jsf.js.LICENSE.txt +17 -2
  35. package/dist/window/jsf.js.br +0 -0
  36. package/dist/window/jsf.js.gz +0 -0
  37. package/dist/window/jsf.js.map +1 -1
  38. package/package.json +19 -18
  39. package/plans for 4.0.1.txt +8 -0
  40. package/src/main/test.xml +23 -0
  41. package/src/main/typescript/@types/definitions/index.d.ts +19 -2
  42. package/src/main/typescript/api/_api.ts +68 -25
  43. package/src/main/typescript/api/jsf.ts +18 -0
  44. package/src/main/typescript/impl/AjaxImpl.ts +204 -100
  45. package/src/main/typescript/impl/PushImpl.ts +63 -38
  46. package/src/main/typescript/impl/core/Const.ts +56 -40
  47. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  48. package/src/main/typescript/impl/util/AsyncRunnable.ts +85 -10
  49. package/src/main/typescript/impl/util/ExtDomQuery.ts +65 -54
  50. package/src/main/typescript/impl/util/FileUtils.ts +108 -0
  51. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +93 -0
  52. package/src/main/typescript/impl/util/Lang.ts +91 -35
  53. package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
  54. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  55. package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
  56. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
  57. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
  58. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
  59. package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
  60. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +211 -138
  61. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +92 -166
  62. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +111 -120
  63. package/src/main/typescript/myfaces/OamSubmit.ts +30 -14
  64. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +163 -27
  65. package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
  66. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
  67. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +921 -0
  68. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
  69. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +111 -3
  70. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  71. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
  72. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  73. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
  74. package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
  75. package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
  76. package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
  77. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
  78. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  79. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  80. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  81. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  82. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +320 -15
  83. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +45 -4
  84. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +374 -35
  85. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  86. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
  87. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  88. package/src/main/typescript/test.xml +6 -0
  89. package/src/main/typescript/tsconfig.json +1 -1
  90. package/src/test/resources/jsf-development.js +1 -1
  91. package/src/tmp/test.html +12 -88
  92. package/target/api/_api.js +63 -21
  93. package/target/api/_api.js.map +1 -1
  94. package/target/api/jsf.js +11 -0
  95. package/target/api/jsf.js.map +1 -1
  96. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  97. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  98. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  99. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  100. package/target/impl/AjaxImpl.js +177 -81
  101. package/target/impl/AjaxImpl.js.map +1 -1
  102. package/target/impl/PushImpl.js +66 -35
  103. package/target/impl/PushImpl.js.map +1 -1
  104. package/target/impl/core/Const.js +54 -39
  105. package/target/impl/core/Const.js.map +1 -1
  106. package/target/impl/core/Context.js +10 -0
  107. package/target/impl/core/Context.js.map +1 -0
  108. package/target/impl/util/Assertions.js +12 -7
  109. package/target/impl/util/Assertions.js.map +1 -1
  110. package/target/impl/util/AsyncQueue.js.map +1 -1
  111. package/target/impl/util/AsyncRunnable.js +60 -0
  112. package/target/impl/util/AsyncRunnable.js.map +1 -1
  113. package/target/impl/util/ExtDomQuery.js +66 -48
  114. package/target/impl/util/ExtDomQuery.js.map +1 -1
  115. package/target/impl/util/FileUtils.js +97 -0
  116. package/target/impl/util/FileUtils.js.map +1 -0
  117. package/target/impl/util/HiddenElementBuilder.js +7 -0
  118. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  119. package/target/impl/util/HiddenInputBuilder.js +83 -0
  120. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  121. package/target/{types/index.js → impl/util/IAsyncRunnable.js} +11 -2
  122. package/target/impl/util/IAsyncRunnable.js.map +1 -0
  123. package/target/impl/util/Lang.js +81 -31
  124. package/target/impl/util/Lang.js.map +1 -1
  125. package/target/impl/util/URLCodec.js +77 -0
  126. package/target/impl/util/URLCodec.js.map +1 -0
  127. package/target/impl/util/XhrQueueController.js +107 -0
  128. package/target/impl/util/XhrQueueController.js.map +1 -0
  129. package/target/impl/xhrCore/ErrorData.js +10 -8
  130. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  131. package/target/impl/xhrCore/EventData.js +2 -2
  132. package/target/impl/xhrCore/EventData.js.map +1 -1
  133. package/target/impl/xhrCore/RequestContext.js +11 -0
  134. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  135. package/target/impl/xhrCore/RequestDataResolver.js +70 -23
  136. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  137. package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
  138. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  139. package/target/impl/xhrCore/Response.js +44 -29
  140. package/target/impl/xhrCore/Response.js.map +1 -1
  141. package/target/impl/xhrCore/ResponseProcessor.js +187 -119
  142. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  143. package/target/impl/xhrCore/XhrFormData.js +82 -156
  144. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  145. package/target/impl/xhrCore/XhrQueHandler.js +11 -0
  146. package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
  147. package/target/impl/xhrCore/XhrQueueController.js +62 -0
  148. package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
  149. package/target/impl/xhrCore/XhrRequest.js +94 -106
  150. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  151. package/target/myfaces/OamSubmit.js +25 -14
  152. package/target/myfaces/OamSubmit.js.map +1 -1
  153. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +124 -23
  154. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  155. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
  156. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
  157. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
  158. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  159. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
  160. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
  161. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
  162. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
  163. package/target/test/frameworkBase/_ext/shared/StandardInits.js +103 -3
  164. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  165. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  166. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  167. package/target/test/impl/ImplTest.spec.js +2 -2
  168. package/target/test/impl/ImplTest.spec.js.map +1 -1
  169. package/target/test/impl/ImplTest_23.spec.js +2 -2
  170. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  171. package/target/test/myfaces/OnLoadSpec.js +57 -0
  172. package/target/test/myfaces/OnLoadSpec.js.map +1 -0
  173. package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
  174. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  175. package/target/test/xhrCore/EventTests.spec.js +26 -19
  176. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  177. package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
  178. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  179. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  180. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  181. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  182. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  183. package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
  184. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  185. package/target/test/xhrCore/RequestTest.spec.js +288 -11
  186. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  187. package/target/test/xhrCore/RequestTest_23.spec.js +40 -2
  188. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  189. package/target/test/xhrCore/ResponseTest.spec.js +315 -24
  190. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  191. package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
  192. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  193. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
  194. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
  195. package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
  196. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  197. package/target/test-classes/.gz +0 -0
  198. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  199. package/target/test-classes/fileuploadtest.html +24 -0
  200. package/target/test-classes/jsf-development.js +3559 -0
  201. package/target/test-classes/jsf-development.js.br +0 -0
  202. package/target/test-classes/jsf-development.js.gz +0 -0
  203. package/target/test-classes/jsf-development.js.map +1 -0
  204. package/target/test-classes/jsf.js +3 -0
  205. package/target/test-classes/jsf.js.br +0 -0
  206. package/target/test-classes/jsf.js.gz +0 -0
  207. package/tmp.xml +36 -0
  208. package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  209. package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  210. package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  211. package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  212. package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
  213. package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
  214. 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
- export const P_PARTIAL_SOURCE = "jakarta.faces.source";
21
- export const PARTIAL_ID = "partialId";
20
+
21
+ export const XML_ATTR_NAMED_VIEWROOT = "namedViewRoot";
22
+ export const NAMED_VIEWROOT = "namedViewRoot";
23
+
24
+ export const P_AJAX_SOURCE = "jakarta.faces.source";
25
+ export const NAMING_CONTAINER_ID = "myfaces.NamingContainerId";
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,18 @@ 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";
111
+ export const CTX_PARAM_PPS = "myfaces.request.pps";
103
112
 
104
113
  export const CONTENT_TYPE = "Content-Type";
105
114
  export const HEAD_FACES_REQ = "Faces-Request";
@@ -116,13 +125,12 @@ export const MULTIPART = "multipart/form-data";
116
125
  export const NO_TIMEOUT = 0;
117
126
  export const STD_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
118
127
 
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";
128
+ export const HTML_TAG_HEAD = "HEAD";
129
+ export const HTML_TAG_FORM = "FORM";
130
+ export const HTML_TAG_BODY = "BODY";
131
+ export const HTML_TAG_LINK = "LINK";
132
+ export const HTML_TAG_SCRIPT = "SCRIPT";
133
+ export const HTML_TAG_STYLE = "STYLE";
126
134
 
127
135
 
128
136
  export const SEL_VIEWSTATE_ELEM = "[name='" + P_VIEWSTATE + "']";
@@ -134,44 +142,48 @@ export const PHASE_PROCESS_RESPONSE = "processResponse";
134
142
 
135
143
  export const ERR_NO_PARTIAL_RESPONSE = "Partial response not set";
136
144
 
145
+ export const MYFACES_OPTION_PPS = "pps";
146
+
137
147
  export const ATTR_URL = "url";
138
148
  export const ATTR_NAME = "name";
139
149
  export const ATTR_VALUE = "value";
140
150
  export const ATTR_ID = "id";
141
151
 
142
152
  /*partial response types*/
143
- export const RESP_PARTIAL = "partial-response";
153
+ export const XML_TAG_PARTIAL_RESP = "partial-response";
144
154
 
145
155
  /*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";
156
+ export const XML_TAG_CHANGES = "changes";
157
+ export const XML_TAG_UPDATE = "update";
158
+ export const XML_TAG_DELETE = "delete";
159
+ export const XML_TAG_INSERT = "insert";
160
+ export const XML_TAG_EVAL = "eval";
161
+ export const XML_TAG_ERROR = "error";
162
+ export const XML_TAG_ATTRIBUTES = "attributes";
163
+ export const XML_TAG_EXTENSION = "extension";
164
+ export const XML_TAG_REDIRECT = "redirect";
165
+ export const XML_TAG_BEFORE = "before";
166
+ export const XML_TAG_AFTER = "after";
167
+ export const XML_TAG_ATTR = "attribute";
168
+
155
169
 
156
170
  /*other constants*/
157
171
 
158
- export const UPDATE_FORMS = "_updateForms";
159
- export const UPDATE_ELEMS = "_updateElems";
172
+ export const UPDATE_FORMS = "myfaces.updateForms";
173
+ export const UPDATE_ELEMS = "myfaces.updateElems";
160
174
 
161
175
  //we want the head elements to be processed before we process the body
162
176
  //but after the inner html is done
163
- export const DEFERRED_HEAD_INSERTS = "_headElems";
177
+ export const DEFERRED_HEAD_INSERTS = "myfaces.headElems";
164
178
 
165
179
  export const MYFACES = "myfaces";
166
180
 
167
- export const SEL_SCRIPTS_STYLES = "script, style, link";
168
-
169
181
  export const MF_NONE = "__mf_none__";
170
182
 
171
183
  export const REASON_EXPIRED = "Expired";
172
184
 
173
- export const APPLIED_VST = "appliedViewState";
174
- export const APPLIED_CLIENT_WINDOW = "appliedClientWindow";
185
+ export const APPLIED_VST = "myfaces.appliedViewState";
186
+ export const APPLIED_CLIENT_WINDOW = "myfaces.appliedClientWindow";
175
187
 
176
188
  export const RECONNECT_INTERVAL = 500;
177
189
  export const MAX_RECONNECT_ATTEMPTS = 25;
@@ -186,6 +198,10 @@ export const UNKNOWN = "UNKNOWN";
186
198
  * changed to a simple value passthrough
187
199
  */
188
200
 
201
+ export function $faces(): FacesAPI {
202
+ return (window?.faces ?? window?.jsf) as FacesAPI;
203
+ }
204
+
189
205
  export function $nsp(inputNamespace?: any): any {
190
206
  if((!inputNamespace) || !inputNamespace?.replace) {
191
207
  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
 
@@ -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.
@@ -26,7 +26,7 @@
26
26
  * from the implementation side it is mostly registering callbacks
27
27
  * and calling them at the appropriate time.
28
28
  */
29
- export interface AsyncRunnable<T> {
29
+ export interface IAsyncRunnable<T> {
30
30
  /**
31
31
  * starts the runnable
32
32
  */
@@ -42,24 +42,24 @@ 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
- * @param func
48
+ * @param func the then functor
49
49
  */
50
- then(func: (data: any) => any): AsyncRunnable<T>;
50
+ then(func: (data: any) => any): IAsyncRunnable<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
61
61
  */
62
- catch(func: (data: any) => any): AsyncRunnable<T>;
62
+ catch(func: (data: any) => any): IAsyncRunnable<T>;
63
63
 
64
64
 
65
65
  /**
@@ -68,5 +68,80 @@ export interface AsyncRunnable<T> {
68
68
  * and once the finally time for the promise has
69
69
  * come the finally functions must be performed
70
70
  */
71
- finally(func: () => void): AsyncRunnable<T>;
72
- }
71
+ finally(func: () => void): IAsyncRunnable<T>;
72
+ }
73
+
74
+
75
+ /**
76
+ * pretty much the same as cancellable Promise, but given
77
+ * we do not have that on browser level yet this is sort
78
+ * of a non - intrusive Shim!
79
+ */
80
+ export abstract class AsyncRunnable<T> implements IAsyncRunnable<T>{
81
+ /**
82
+ * helper support so that we do not have to drag in Promise shims
83
+ */
84
+ private catchFunctions: Array<Function> = [];
85
+ private thenFunctions: Array<Function> = [];
86
+
87
+ /**
88
+ * cancel the run of the runnable (which then depending on the implementation
89
+ * either triggers indirectly resolve or reject)
90
+ */
91
+ abstract cancel(): void;
92
+
93
+ /**
94
+ * extended functionality start to trigger the runnable
95
+ */
96
+ abstract start(): void;
97
+
98
+ /**
99
+ * resolve handler function which calls the then chain
100
+ * and after that finally
101
+ * @param data
102
+ */
103
+ resolve(data: any) {
104
+ this.thenFunctions.reduce((inputVal: any, thenFunc: any) => {
105
+ return thenFunc(inputVal);
106
+ }, data)
107
+ }
108
+
109
+ /**
110
+ * reject handler function which triggers the catch chain
111
+ * @param data
112
+ */
113
+ reject(data: any) {
114
+ this.catchFunctions.reduce((inputVal: any, catchFunc: any) => {
115
+ return catchFunc(inputVal);
116
+ }, data);
117
+ }
118
+
119
+ /**
120
+ * register a catch functor
121
+ * @param func the functor for the catch monad
122
+ */
123
+ catch(func: (data: any) => any): IAsyncRunnable<T> {
124
+ this.catchFunctions.push(func);
125
+ return this;
126
+ }
127
+
128
+ /**
129
+ * registers a finally functor
130
+ * @param func the functor for the finally handling chanin
131
+ */
132
+ finally(func: () => void): IAsyncRunnable<T> {
133
+ // no ie11 support we probably are going to revert to shims for that one
134
+ this.catchFunctions.push(func);
135
+ this.thenFunctions.push(func);
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ * @param func then functor similar to promise
141
+ */
142
+ then(func: (data: any) => any): IAsyncRunnable<T> {
143
+ this.thenFunctions.push(func);
144
+ return this;
145
+ }
146
+ }
147
+