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
@@ -13,13 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  *
16
- * todo replace singleton with module definition
17
- *
18
16
  */
19
17
 
20
- import {Lang as LangBase, Config, Optional, DomQuery, DQ, Stream} from "mona-dish";
18
+ import {Lang as LangBase, Config, Optional, DomQuery, DQ} from "mona-dish";
21
19
  import {Messages} from "../i18n/Messages";
22
- import {EMPTY_STR, TAG_FORM} from "../core/Const";
20
+ import {EMPTY_STR, HTML_TAG_FORM} from "../core/Const";
23
21
  import {getEventTarget} from "../xhrCore/RequestDataResolver";
24
22
 
25
23
 
@@ -38,11 +36,11 @@ export module ExtLang {
38
36
 
39
37
  //should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those
40
38
  /**
41
- * helper function to savely resolve anything
39
+ * helper function to safely resolve anything
42
40
  * this is not an elvis operator, it resolves
43
41
  * a value without exception in a tree and if
44
42
  * it is not resolvable then an optional of
45
- * a default value is restored or Optional.empty
43
+ * a default value is restored or Optional\.empty
46
44
  * if none is given
47
45
  *
48
46
  * usage
@@ -51,7 +49,7 @@ export module ExtLang {
51
49
  * </code>
52
50
  *
53
51
  * @param resolverProducer a lambda which can produce the value
54
- * @param defaultValue an optional default value if the producer failes to produce anything
52
+ * @param defaultValue an optional default value if the producer fails to produce anything
55
53
  * @returns an Optional of the produced value
56
54
  */
57
55
  export function failSaveResolve<T>(resolverProducer: () => T, defaultValue: T = null): Optional<T> {
@@ -75,10 +73,10 @@ export module ExtLang {
75
73
  * returns a given localized message upon a given key
76
74
  * basic java log like templating functionality is included
77
75
  *
78
- * @param {String} key the key for the message
79
- * @param {String} defaultMessage optional default message if none was found
76
+ * @param key the key for the message
77
+ * @param defaultMessage optional default message if none was found
80
78
  *
81
- * Additionally you can pass additional arguments, which are used
79
+ * Additionally, you can pass additional arguments, which are used
82
80
  * in the same way java log templates use the params
83
81
  *
84
82
  * @param templateParams the param list to be filled in
@@ -87,10 +85,10 @@ export module ExtLang {
87
85
  installedLocale = installedLocale ?? new Messages();
88
86
 
89
87
  let msg = installedLocale[key] ?? defaultMessage ?? key;
90
-
91
- Stream.of(...templateParams).each((param, cnt) => {
88
+ templateParams.forEach((param, cnt) => {
92
89
  msg = msg.replace(new RegExp(["\\{", cnt, "\\}"].join(EMPTY_STR), "g"), param);
93
- });
90
+ })
91
+
94
92
 
95
93
  return msg;
96
94
  }
@@ -106,15 +104,15 @@ export module ExtLang {
106
104
  }
107
105
 
108
106
  /**
109
- * creates an exeption with additional internal parameters
107
+ * creates an exception with additional internal parameters
110
108
  * for extra information
111
109
  *
112
110
  * @param error
113
- * @param {String} title the exception title
114
- * @param {String} name the exception name
115
- * @param {String} callerCls the caller class
116
- * @param {String} callFunc the caller function
117
- * @param {String} message the message for the exception
111
+ * @param title the exception title
112
+ * @param name the exception name
113
+ * @param callerCls the caller class
114
+ * @param callFunc the caller function
115
+ * @param message the message for the exception
118
116
  */
119
117
  export function makeException(error: Error, title: string, name: string, callerCls: string, callFunc: string, message: string): Error {
120
118
 
@@ -124,14 +122,14 @@ export module ExtLang {
124
122
 
125
123
  /**
126
124
  * fetches a global config entry
127
- * @param {String} configName the name of the configuration entry
128
- * @param {Object} defaultValue
125
+ * @param configName the name of the configuration entry
126
+ * @param defaultValue
129
127
  *
130
128
  * @return either the config entry or if none is given the default value
131
129
  */
132
130
  export function getGlobalConfig(configName: string, defaultValue: any): any {
133
131
  /**
134
- * note we could use exists but this is an heavy operation, since the config name usually
132
+ * note we could use exists but this is a heavy operation, since the config name usually
135
133
  * given this function here is called very often
136
134
  * is a single entry without . in between we can do the lighter shortcut
137
135
  */
@@ -139,7 +137,7 @@ export module ExtLang {
139
137
  }
140
138
 
141
139
  /**
142
- * fetches the form in an fuzzy manner depending
140
+ * fetches the form in a fuzzy manner depending
143
141
  * on an element or event target.
144
142
  *
145
143
  * The idea is that according to the jsf spec
@@ -148,7 +146,7 @@ export module ExtLang {
148
146
  * This is fine, but since then html5 came into the picture with the form attribute the element
149
147
  * can be anywhere referencing its parent form.
150
148
  *
151
- * Also theoretically you can have the case of an issuing element enclosing a set of forms
149
+ * Also, theoretically you can have the case of an issuing element enclosing a set of forms
152
150
  * (not really often used, but theoretically it could be input button allows to embed html for instance)
153
151
  *
154
152
  * So the idea is not to limit the issuing form determination to the spec case
@@ -160,25 +158,25 @@ export module ExtLang {
160
158
  export function getForm(elem: Element, event ?: Event): DQ | never {
161
159
 
162
160
  let queryElem = new DQ(elem);
163
- let eventTarget = new DQ(getEventTarget(event));
161
+ let eventTarget = (event) ? new DQ(getEventTarget(event)) : DomQuery.absent;
164
162
 
165
- if (queryElem.isTag(TAG_FORM)) {
163
+ if (queryElem.isTag(HTML_TAG_FORM)) {
166
164
  return queryElem;
167
165
  }
168
166
 
169
167
  //html 5 for handling
170
- if (queryElem.attr(TAG_FORM).isPresent()) {
171
- let formId = queryElem.attr(TAG_FORM).value;
168
+ if (queryElem.attr(HTML_TAG_FORM).isPresent()) {
169
+ let formId = queryElem.attr(HTML_TAG_FORM).value;
172
170
  let foundForm = DQ.byId(formId, true);
173
171
  if (foundForm.isPresent()) {
174
172
  return foundForm;
175
173
  }
176
174
  }
177
175
 
178
- let form = queryElem.parents(TAG_FORM)
179
- .orElseLazy(() => queryElem.byTagName(TAG_FORM, true))
180
- .orElseLazy(() => eventTarget.parents(TAG_FORM))
181
- .orElseLazy(() => eventTarget.byTagName(TAG_FORM))
176
+ let form = queryElem.firstParent(HTML_TAG_FORM)
177
+ .orElseLazy(() => queryElem.byTagName(HTML_TAG_FORM, true))
178
+ .orElseLazy(() => eventTarget.firstParent(HTML_TAG_FORM))
179
+ .orElseLazy(() => eventTarget.byTagName(HTML_TAG_FORM))
182
180
  .first();
183
181
 
184
182
  assertFormExists(form);
@@ -190,10 +188,11 @@ export module ExtLang {
190
188
  * gets the local or global options with local ones having higher priority
191
189
  * if no local or global one was found then the default value is given back
192
190
  *
193
- * @param {String} configName the name of the configuration entry
194
- * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
191
+ * @param configName the name of the configuration entry
192
+ * @param localOptions the local options root for the configuration myfaces as default marker is added
193
+ * implicitly
195
194
  *
196
- * @param {Object} defaultValue
195
+ * @param defaultValue
197
196
  *
198
197
  * @return either the config entry or if none is given the default value
199
198
  */
@@ -203,6 +202,61 @@ export module ExtLang {
203
202
  defaultValue;
204
203
  }
205
204
 
205
+ /**
206
+ * expands an associative array into an array of key value tuples
207
+ * @param value
208
+ */
209
+ export function ofAssoc(value: {[key: string]: any}) {
210
+ return Object.keys(value)
211
+ .map(key => [key, value[key]]);
212
+ }
213
+
214
+ export function collectAssoc(target: any, item: any) {
215
+ target[item[0]] = item[1];
216
+ return target;
217
+ }
218
+
219
+ /**
220
+ * The active timeout for the "debounce".
221
+ * Since we only use it in the XhrController
222
+ * we can use a local module variable here
223
+ */
224
+ let activeTimeouts = {};
225
+
226
+
227
+
228
+
229
+ /**
230
+ * a simple debounce function
231
+ * which waits until a timeout is reached and
232
+ * if something comes in in between debounces
233
+ *
234
+ * @param runnable a runnable which should go under debounce control
235
+ * @param timeout a timeout for the debounce window
236
+ */
237
+ export function debounce(key, runnable, timeout) {
238
+ function clearActiveTimeout() {
239
+ clearTimeout(activeTimeouts[key]);
240
+ delete activeTimeouts[key];
241
+ }
242
+
243
+ if (!!(activeTimeouts?.[key])) {
244
+ clearActiveTimeout();
245
+ }
246
+ if (timeout > 0) {
247
+ activeTimeouts[key] = setTimeout(() => {
248
+ try {
249
+ runnable();
250
+ } finally {
251
+ clearActiveTimeout();
252
+ }
253
+ }, timeout);
254
+ } else {
255
+ runnable();
256
+ }
257
+ }
258
+
259
+
206
260
  /**
207
261
  * assert that the form exists and throw an exception in the case it does not
208
262
  *
@@ -213,4 +267,6 @@ export module ExtLang {
213
267
  throw makeException(new Error(), null, null, "Impl", "getForm", getMessage("ERR_FORM"));
214
268
  }
215
269
  }
270
+
271
+
216
272
  }
@@ -0,0 +1,112 @@
1
+ import {IAsyncRunnable} from "./AsyncRunnable";
2
+ import {ExtLang} from "./Lang";
3
+ import debounce = ExtLang.debounce;
4
+
5
+ /**
6
+ * A simple XHR queue controller
7
+ * following the async op -> next pattern
8
+ * Faces enforces for the XHR handling
9
+ */
10
+ export class XhrQueueController<T extends IAsyncRunnable<any>> {
11
+ queue = [];
12
+ taskRunning = false;
13
+
14
+ constructor() {
15
+ }
16
+
17
+ /**
18
+ * executes or enqueues an element
19
+ * @param runnable the runnable (request) to be enqueued
20
+ * @param timeOut timeout if > 0 which defers the execution
21
+ * until the debounce window for the timeout is closed.
22
+ */
23
+ enqueue(runnable: T, timeOut: number = 0) {
24
+ debounce("xhrQueue", () => {
25
+ const requestHandler = this.enrichRunnable(runnable);
26
+ if (!this.taskRunning) {
27
+ this.signalTaskRunning();
28
+ requestHandler.start();
29
+ } else {
30
+ this.queue.push(requestHandler);
31
+ }
32
+ }, timeOut);
33
+ }
34
+
35
+ /**
36
+ * trigger the next element in the queue
37
+ * to be started!
38
+ */
39
+ next() {
40
+ this.updateTaskRunning();
41
+ const next = this.queue.shift();
42
+ next?.start();
43
+ }
44
+
45
+ /**
46
+ * clears and resets the queue
47
+ */
48
+ clear() {
49
+ this.queue.length = 0;
50
+ this.updateTaskRunning();
51
+ }
52
+
53
+ /**
54
+ * true if queue is empty
55
+ */
56
+ get isEmpty(): boolean {
57
+ return !this.queue.length;
58
+ }
59
+
60
+ /**
61
+ * Enriches the incoming async asyncRunnable
62
+ * with the error and next handling
63
+ * (aka: asyncRunnable is done -> next
64
+ * error -> clear queue
65
+ * @param asyncRunnable the async runnable which needs enrichment
66
+ * @private
67
+ */
68
+ private enrichRunnable(asyncRunnable: T) {
69
+ /**
70
+ * we can use the Promise pattern asyncrunnable uses
71
+ * to trigger queue control callbacks of next element
72
+ * and clear the queue (theoretically this
73
+ * would work with any promise)
74
+ */
75
+ try {
76
+ return asyncRunnable
77
+ .then(() => this.next())
78
+ .catch((e) => this.handleError(e));
79
+ } catch (e) {
80
+ this.handleError(e);
81
+ }
82
+ }
83
+
84
+
85
+ /**
86
+ * alerts the queue that a task is running
87
+ *
88
+ * @private
89
+ */
90
+ private signalTaskRunning() {
91
+ this.taskRunning = true;
92
+ }
93
+
94
+ /**
95
+ * updates the task running status according to the current queue
96
+ * @private
97
+ */
98
+ private updateTaskRunning() {
99
+ this.taskRunning = !this.isEmpty;
100
+ }
101
+
102
+ /**
103
+ * standard error handling
104
+ * we clear the queue and then bomb out
105
+ * @param e
106
+ * @private
107
+ */
108
+ private handleError(e) {
109
+ this.clear();
110
+ throw e;
111
+ }
112
+ }
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import {
17
- EMPTY_STR,
17
+ EMPTY_STR, ERROR,
18
18
  ERROR_MESSAGE,
19
19
  ERROR_NAME,
20
20
  RESPONSE_TEXT,
21
- RESPONSE_XML,
21
+ RESPONSE_XML, SERVER_ERROR,
22
22
  SOURCE,
23
23
  STATUS,
24
24
  UNKNOWN
@@ -49,7 +49,8 @@ export enum ErrorType {
49
49
  export class ErrorData extends EventData implements IErrorData {
50
50
 
51
51
  type: string = "error";
52
- source: string;
52
+ source: HTMLElement;
53
+ sourceId: string;
53
54
  errorName: string;
54
55
  errorMessage: string;
55
56
 
@@ -63,12 +64,14 @@ export class ErrorData extends EventData implements IErrorData {
63
64
  serverErrorMessage: string;
64
65
  message: string;
65
66
 
66
- constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "UNKNOWN", type = ErrorType.CLIENT_ERROR) {
67
+ constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "", type = ErrorType.CLIENT_ERROR) {
67
68
  super();
68
- this.source = source;
69
- this.type = "error";
69
+ this.source = document.getElementById(source);
70
+ this.sourceId = source;
71
+ this.type = ERROR;
70
72
  this.errorName = errorName;
71
- this.message = this.errorMessage = errorMessage;
73
+ //tck requires that the type is prefixed to the message itself (jsdoc also) in case of a server error
74
+ this.message = this.errorMessage = (type == SERVER_ERROR) ? type + ": " + errorMessage : errorMessage;
72
75
  this.responseCode = responseCode;
73
76
  this.responseText = responseText;
74
77
  this.status = status;
@@ -81,10 +84,10 @@ export class ErrorData extends EventData implements IErrorData {
81
84
  }
82
85
 
83
86
  static fromClient(e: Error): ErrorData {
84
- return new ErrorData("client", e?.name ?? '', e?.message ?? '', e?.stack ?? '');
87
+ return new ErrorData((e as any)?.source ?? "client", e?.name ?? EMPTY_STR, e?.message ?? EMPTY_STR, e?.stack ?? EMPTY_STR);
85
88
  }
86
89
 
87
- static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string = 'UNKNOWN'): ErrorData {
90
+ static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string = EMPTY_STR): ErrorData {
88
91
  return new ErrorData(source, name, message, responseText, responseCode, `${responseCode}`, status, ErrorType.HTTP_ERROR);
89
92
  }
90
93
 
@@ -98,11 +101,13 @@ export class ErrorData extends EventData implements IErrorData {
98
101
  let status = getMsg(context, STATUS);
99
102
  let responseText = getMsg(context, RESPONSE_TEXT);
100
103
  let responseXML = getMsg(context, RESPONSE_XML);
104
+
105
+
101
106
  return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode + EMPTY_STR, status, errorType);
102
107
  }
103
108
 
104
109
  private static getMsg(context, param) {
105
- return getMessage(context.getIf(param).orElse(UNKNOWN).value);
110
+ return getMessage(context.getIf(param).orElse(EMPTY_STR).value);
106
111
  }
107
112
 
108
113
  static fromServerError(context: Config): ErrorData {
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import {Config, DQ} from "mona-dish";
17
- import {BEGIN, CTX_PARAM_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
17
+ import {BEGIN, CTX_PARAM_REQ_PASS_THR, EVENT, P_AJAX_SOURCE, SOURCE} from "../core/Const";
18
18
 
19
19
  export class EventData implements IEventData{
20
20
  type: string;
@@ -32,8 +32,8 @@ export class EventData implements IEventData{
32
32
  eventData.status = name;
33
33
 
34
34
  let sourceId: string = context.getIf(SOURCE)
35
- .orElseLazy(() => context.getIf(P_PARTIAL_SOURCE).value)
36
- .orElseLazy(() => context.getIf(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value)
35
+ .orElseLazy(() => context.getIf(P_AJAX_SOURCE).value)
36
+ .orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_AJAX_SOURCE).value)
37
37
  .value;
38
38
  if (sourceId) {
39
39
  eventData.source = DQ.byId(sourceId, true).first().value.value;
@@ -32,7 +32,6 @@ export interface IResponseProcessor {
32
32
  */
33
33
  replaceHead(shadowHead: XMLQuery | DQ): void;
34
34
 
35
-
36
35
  /**
37
36
  * adds new elements to the head
38
37
  *
@@ -40,6 +39,14 @@ export interface IResponseProcessor {
40
39
  */
41
40
  addToHead(newElements: XMLQuery | DQ): void;
42
41
 
42
+
43
+ /**
44
+ * adds new elements to the head in a deferred manner
45
+ *
46
+ * @param newElements the elements which need addition
47
+ */
48
+ addToHeadDeferred(newElements: XMLQuery | DQ): void;
49
+
43
50
  /**
44
51
  * replace the body
45
52
  *
@@ -48,7 +55,7 @@ export interface IResponseProcessor {
48
55
  replaceBody(shadowBody: XMLQuery | DQ): void;
49
56
 
50
57
  /**
51
- * Leaf Tag eval... process whatever is in the evals cdata block
58
+ * Leaf Tag eval... process whatever is in the evaluated cdata block
52
59
  *
53
60
  * @param node
54
61
  */
@@ -91,11 +98,11 @@ export interface IResponseProcessor {
91
98
  attributes(node: XMLQuery): void;
92
99
 
93
100
  /**
94
- * replace the entire viewroot
101
+ * replace the entire viewRoot
95
102
  * with shadowResponse
96
- * @param shadownResponse
103
+ * @param shadowResponse
97
104
  */
98
- replaceViewRoot(shadownResponse: XMLQuery | DQ): void;
105
+ replaceViewRoot(shadowResponse: XMLQuery | DQ): void;
99
106
 
100
107
  /**
101
108
  * jsf insert resolution
@@ -106,34 +113,34 @@ export interface IResponseProcessor {
106
113
  insert(node: XMLQuery): void;
107
114
 
108
115
  /**
109
- * insert with before, after subtags
116
+ * insert with before, after sub-tags
110
117
  * @param node
111
118
  */
112
- insertWithSubtags(node: XMLQuery);
119
+ insertWithSubTags(node: XMLQuery);
113
120
 
114
121
  /**
115
122
  * process the viewState update, update the affected
116
- * forms with their respective new viewstate values
123
+ * forms with their respective new viewState values
117
124
  *
118
125
  */
119
126
  processViewState(node: XMLQuery): boolean;
120
127
 
121
128
  /**
122
129
  * process the viewState update, update the affected
123
- * forms with their respective new viewstate values
130
+ * forms with their respective new viewState values
124
131
  *
125
132
  */
126
133
  processClientWindow(node: XMLQuery): boolean;
127
134
 
128
135
 
129
136
  /**
130
- * evals all processed elements of so far
137
+ * Eval - all processed elements so far
131
138
  * and executes the embedded scripts
132
139
  */
133
140
  globalEval(): void;
134
141
 
135
142
  /**
136
- * fix the viewstates of all processed forms
143
+ * fix the viewStates of all processed forms
137
144
  */
138
145
  fixViewStates(): void;
139
146
 
@@ -142,4 +149,11 @@ export interface IResponseProcessor {
142
149
  * send last event
143
150
  */
144
151
  done(): void;
152
+
153
+ /**
154
+ * update internal state to
155
+ * check whether we still are in a named view root
156
+ * (can change after a navigation)
157
+ */
158
+ updateNamedViewRootState();
145
159
  }