jsf.js_next_gen 4.1.0-beta.2 → 4.1.0-beta.21

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 (413) hide show
  1. package/AI_CONTRIBUTIONS.md +71 -0
  2. package/README.md +254 -78
  3. package/api-extractor.faces.json +38 -0
  4. package/dist/docs/assets/hierarchy.js +1 -1
  5. package/dist/docs/assets/navigation.js +1 -1
  6. package/dist/docs/assets/search.js +1 -1
  7. package/dist/docs/functions/faces.ajax.addOnError.html +2 -2
  8. package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -2
  9. package/dist/docs/functions/faces.ajax.request.html +2 -2
  10. package/dist/docs/functions/faces.ajax.response.html +2 -2
  11. package/dist/docs/functions/faces.getClientWindow.html +2 -2
  12. package/dist/docs/functions/faces.getProjectStage.html +2 -2
  13. package/dist/docs/functions/faces.getViewState.html +1 -1
  14. package/dist/docs/functions/faces.push.close.html +1 -1
  15. package/dist/docs/functions/faces.push.init.html +6 -6
  16. package/dist/docs/functions/faces.push.open.html +1 -1
  17. package/dist/docs/functions/faces.util.chain.html +2 -2
  18. package/dist/docs/functions/myfaces.ab.html +3 -3
  19. package/dist/docs/functions/myfaces.onDomReady.html +1 -1
  20. package/dist/docs/functions/myfaces.reserveNamespace.html +1 -1
  21. package/dist/docs/hierarchy.html +1 -1
  22. package/dist/docs/index.html +292 -71
  23. package/dist/docs/interfaces/faces.AjaxData.html +6 -0
  24. package/dist/docs/interfaces/faces.AjaxError.html +18 -0
  25. package/dist/docs/interfaces/faces.AjaxEvent.html +8 -0
  26. package/dist/docs/interfaces/faces.ajax.RequestContext.html +6 -0
  27. package/dist/docs/interfaces/faces.ajax.RequestOptions.html +10 -0
  28. package/dist/docs/modules/faces.ajax.html +1 -1
  29. package/dist/docs/modules/faces.html +1 -1
  30. package/dist/docs/modules/faces.push.html +1 -1
  31. package/dist/docs/modules/faces.util.html +1 -1
  32. package/dist/docs/modules/myfaces.html +1 -1
  33. package/dist/docs/modules.html +1 -1
  34. package/dist/docs/types/faces.AjaxErrorStatus.html +2 -0
  35. package/dist/docs/types/faces.AjaxEventStatus.html +2 -0
  36. package/dist/docs/types/faces.ProjectStage.html +2 -0
  37. package/dist/docs/types/faces.ajax.OnErrorCallback.html +2 -0
  38. package/dist/docs/types/faces.ajax.OnEventCallback.html +2 -0
  39. package/dist/docs/types/faces.push.OnCloseHandler.html +2 -0
  40. package/dist/docs/types/faces.push.OnErrorHandler.html +2 -0
  41. package/dist/docs/types/faces.push.OnMessageHandler.html +2 -0
  42. package/dist/docs/types/faces.push.OnOpenHandler.html +2 -0
  43. package/dist/docs/variables/faces.contextpath.html +1 -1
  44. package/dist/docs/variables/faces.implversion.html +1 -1
  45. package/dist/docs/variables/faces.separatorchar.html +1 -1
  46. package/dist/docs/variables/faces.specversion.html +1 -1
  47. package/dist/docs/variables/myfaces.oam.html +1 -1
  48. package/dist/window/faces-development.js +1801 -499
  49. package/dist/window/faces-development.js.map +1 -1
  50. package/{target/api/_api.js → dist/window/faces.d.ts} +124 -151
  51. package/dist/window/faces.js +1 -1
  52. package/dist/window/faces.js.LICENSE.txt +0 -17
  53. package/dist/window/faces.js.map +1 -1
  54. package/dist/window/jsf-development.js +1806 -513
  55. package/dist/window/jsf-development.js.map +1 -1
  56. package/{target/src/main/typescript/api/_api.js → dist/window/jsf.d.ts} +125 -153
  57. package/dist/window/jsf.js +1 -1
  58. package/dist/window/jsf.js.LICENSE.txt +0 -17
  59. package/dist/window/jsf.js.map +1 -1
  60. package/package.json +22 -18
  61. package/scripts/build-dts.mjs +239 -0
  62. package/src/main/typescript/@types/definitions/index.d.ts +22 -122
  63. package/{target/test/frameworkBase/_ext/monadish/fixtures/test2.js → src/main/typescript/@types/definitions/modules.d.ts} +18 -2
  64. package/src/main/typescript/api/_api.ts +132 -29
  65. package/{target/test/frameworkBase/_ext/monadish/fixtures/test.js → src/main/typescript/api/_api_ae_stub.d.ts} +6 -2
  66. package/src/main/typescript/api/faces.ts +2 -2
  67. package/src/main/typescript/api/jsf.ts +15 -23
  68. package/src/main/typescript/impl/AjaxImpl.ts +15 -15
  69. package/src/main/typescript/impl/PushImpl.ts +139 -69
  70. package/src/main/typescript/impl/core/Const.ts +2 -2
  71. package/src/main/typescript/impl/i18n/Messages.ts +1 -1
  72. package/src/main/typescript/impl/util/Assertions.ts +1 -2
  73. package/src/main/typescript/impl/util/AsyncRunnable.ts +3 -4
  74. package/src/main/typescript/impl/util/ExtDomQuery.ts +19 -19
  75. package/src/main/typescript/impl/util/FileUtils.ts +30 -14
  76. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +34 -34
  77. package/src/main/typescript/impl/util/Lang.ts +19 -22
  78. package/src/main/typescript/impl/util/XhrQueueController.ts +25 -3
  79. package/src/main/typescript/impl/xhrCore/ErrorData.ts +17 -12
  80. package/src/main/typescript/impl/xhrCore/EventData.ts +8 -7
  81. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +3 -3
  82. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +7 -6
  83. package/src/main/typescript/impl/xhrCore/Response.ts +3 -3
  84. package/src/main/typescript/impl/xhrCore/ResponseDataResolver.ts +0 -38
  85. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +17 -15
  86. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +72 -63
  87. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -134
  88. package/src/main/typescript/mona_dish_shim.ts +6 -2
  89. package/src/main/typescript/myfaces/OamSubmit.ts +10 -6
  90. package/src/main/typescript/test/api/JsfPushShimTest.spec.ts +126 -0
  91. package/src/main/typescript/test/api/MyFacesABTest.spec.ts +16 -0
  92. package/src/main/typescript/test/api/PushTypeCompatibility.ts +65 -0
  93. package/src/main/typescript/test/frameworkBase/LangTest.spec.ts +16 -0
  94. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -0
  95. package/src/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.ts +16 -0
  96. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +16 -0
  97. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +16 -0
  98. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +55 -9
  99. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +16 -0
  100. package/src/main/typescript/test/impl/AssertionsTest.spec.ts +168 -0
  101. package/src/main/typescript/test/impl/FileUtilsTest.spec.ts +126 -0
  102. package/src/main/typescript/test/impl/ImplTest.spec.ts +75 -1
  103. package/src/main/typescript/test/impl/ResponseDataResolverTest.spec.ts +62 -0
  104. package/src/main/typescript/test/impl/util/ExtDomQueryTest.spec.ts +91 -1
  105. package/src/main/typescript/test/impl/util/ExtLangTest.spec.ts +110 -0
  106. package/src/main/typescript/test/impl/util/HiddenInputBuilderTest.spec.ts +74 -0
  107. package/src/main/typescript/test/myfaces/OamSubmit.spec.ts +61 -1
  108. package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +191 -2
  109. package/src/main/typescript/test/xhrCore/ClientWindow.spec.ts +16 -0
  110. package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +14 -0
  111. package/src/main/typescript/test/xhrCore/FakeWebsocket.ts +21 -5
  112. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +363 -4
  113. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +218 -4
  114. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +1 -1
  115. package/src/main/typescript/test/xhrCore/WebsocketTest.spec.ts +764 -0
  116. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +265 -62
  117. package/src/main/typescript/test/xhrCore/XhrRequestProgress.spec.ts +16 -0
  118. package/{target/src/main/typescript/test/xhrCore/FakeWebsocket.js → src/main/typescript/tsconfig.ae.json} +16 -23
  119. package/src/main/typescript/{tsconfig.json → tsconfig.dts.json} +11 -27
  120. package/src/main/typescript/tsconfig.test.json +17 -0
  121. package/tsconfig.api-extractor.json +17 -0
  122. package/.claude/settings.local.json +0 -16
  123. package/.github/workflows/codeql-analysis.yml +0 -83
  124. package/.github/workflows/nodejs.yml +0 -26
  125. package/.mocharc.json +0 -10
  126. package/.nyc_output/384344d4-4f46-455f-84c3-010f829098cb.json +0 -1
  127. package/.nyc_output/a0f90016-f4f9-4039-bb51-57f4f7050541.json +0 -1
  128. package/.nyc_output/db388b5d-0b79-4bce-afd2-001aaf6f0245.json +0 -1
  129. package/.nyc_output/processinfo/384344d4-4f46-455f-84c3-010f829098cb.json +0 -1
  130. package/.nyc_output/processinfo/a0f90016-f4f9-4039-bb51-57f4f7050541.json +0 -1
  131. package/.nyc_output/processinfo/db388b5d-0b79-4bce-afd2-001aaf6f0245.json +0 -1
  132. package/.nyc_output/processinfo/index.json +0 -1
  133. package/.nycrc +0 -6
  134. package/build.cmd +0 -1
  135. package/build.sh +0 -3
  136. package/mvnw +0 -286
  137. package/mvnw.cmd +0 -161
  138. package/plans for 4.0.1.txt +0 -8
  139. package/remap.ts +0 -51
  140. package/src/main/typescript/test/xhrCore/WebsocketTest.ts +0 -221
  141. package/target/api/_api.js.map +0 -1
  142. package/target/api/faces.js +0 -45
  143. package/target/api/faces.js.map +0 -1
  144. package/target/api/jsf.js +0 -56
  145. package/target/api/jsf.js.map +0 -1
  146. package/target/impl/AjaxImpl.js +0 -748
  147. package/target/impl/AjaxImpl.js.map +0 -1
  148. package/target/impl/PushImpl.js +0 -265
  149. package/target/impl/PushImpl.js.map +0 -1
  150. package/target/impl/core/Const.js +0 -177
  151. package/target/impl/core/Const.js.map +0 -1
  152. package/target/impl/core/ImplTypes.js +0 -38
  153. package/target/impl/core/ImplTypes.js.map +0 -1
  154. package/target/impl/i18n/Messages.js +0 -113
  155. package/target/impl/i18n/Messages.js.map +0 -1
  156. package/target/impl/util/Assertions.js +0 -101
  157. package/target/impl/util/Assertions.js.map +0 -1
  158. package/target/impl/util/AsyncRunnable.js +0 -78
  159. package/target/impl/util/AsyncRunnable.js.map +0 -1
  160. package/target/impl/util/ExtDomQuery.js +0 -306
  161. package/target/impl/util/ExtDomQuery.js.map +0 -1
  162. package/target/impl/util/FileUtils.js +0 -98
  163. package/target/impl/util/FileUtils.js.map +0 -1
  164. package/target/impl/util/HiddenInputBuilder.js +0 -83
  165. package/target/impl/util/HiddenInputBuilder.js.map +0 -1
  166. package/target/impl/util/IListener.js +0 -3
  167. package/target/impl/util/IListener.js.map +0 -1
  168. package/target/impl/util/Lang.js +0 -263
  169. package/target/impl/util/Lang.js.map +0 -1
  170. package/target/impl/util/XhrQueueController.js +0 -92
  171. package/target/impl/util/XhrQueueController.js.map +0 -1
  172. package/target/impl/xhrCore/ErrorData.js +0 -87
  173. package/target/impl/xhrCore/ErrorData.js.map +0 -1
  174. package/target/impl/xhrCore/EventData.js +0 -52
  175. package/target/impl/xhrCore/EventData.js.map +0 -1
  176. package/target/impl/xhrCore/IResponseProcessor.js +0 -3
  177. package/target/impl/xhrCore/IResponseProcessor.js.map +0 -1
  178. package/target/impl/xhrCore/RequestDataResolver.js +0 -186
  179. package/target/impl/xhrCore/RequestDataResolver.js.map +0 -1
  180. package/target/impl/xhrCore/ResonseDataResolver.js +0 -104
  181. package/target/impl/xhrCore/ResonseDataResolver.js.map +0 -1
  182. package/target/impl/xhrCore/Response.js +0 -186
  183. package/target/impl/xhrCore/Response.js.map +0 -1
  184. package/target/impl/xhrCore/ResponseDataResolver.js +0 -104
  185. package/target/impl/xhrCore/ResponseDataResolver.js.map +0 -1
  186. package/target/impl/xhrCore/ResponseProcessor.js +0 -468
  187. package/target/impl/xhrCore/ResponseProcessor.js.map +0 -1
  188. package/target/impl/xhrCore/XhrFormData.js +0 -163
  189. package/target/impl/xhrCore/XhrFormData.js.map +0 -1
  190. package/target/impl/xhrCore/XhrRequest.js +0 -433
  191. package/target/impl/xhrCore/XhrRequest.js.map +0 -1
  192. package/target/mona_dish_shim.js +0 -70
  193. package/target/mona_dish_shim.js.map +0 -1
  194. package/target/myfaces/OamSubmit.js +0 -128
  195. package/target/myfaces/OamSubmit.js.map +0 -1
  196. package/target/src/main/typescript/api/_api.js.map +0 -1
  197. package/target/src/main/typescript/api/faces.js +0 -45
  198. package/target/src/main/typescript/api/faces.js.map +0 -1
  199. package/target/src/main/typescript/api/jsf.js +0 -56
  200. package/target/src/main/typescript/api/jsf.js.map +0 -1
  201. package/target/src/main/typescript/impl/AjaxImpl.js +0 -748
  202. package/target/src/main/typescript/impl/AjaxImpl.js.map +0 -1
  203. package/target/src/main/typescript/impl/PushImpl.js +0 -265
  204. package/target/src/main/typescript/impl/PushImpl.js.map +0 -1
  205. package/target/src/main/typescript/impl/core/Const.js +0 -177
  206. package/target/src/main/typescript/impl/core/Const.js.map +0 -1
  207. package/target/src/main/typescript/impl/core/ImplTypes.js +0 -38
  208. package/target/src/main/typescript/impl/core/ImplTypes.js.map +0 -1
  209. package/target/src/main/typescript/impl/i18n/Messages.js +0 -113
  210. package/target/src/main/typescript/impl/i18n/Messages.js.map +0 -1
  211. package/target/src/main/typescript/impl/util/Assertions.js +0 -101
  212. package/target/src/main/typescript/impl/util/Assertions.js.map +0 -1
  213. package/target/src/main/typescript/impl/util/AsyncRunnable.js +0 -78
  214. package/target/src/main/typescript/impl/util/AsyncRunnable.js.map +0 -1
  215. package/target/src/main/typescript/impl/util/ExtDomQuery.js +0 -306
  216. package/target/src/main/typescript/impl/util/ExtDomQuery.js.map +0 -1
  217. package/target/src/main/typescript/impl/util/FileUtils.js +0 -98
  218. package/target/src/main/typescript/impl/util/FileUtils.js.map +0 -1
  219. package/target/src/main/typescript/impl/util/HiddenInputBuilder.js +0 -83
  220. package/target/src/main/typescript/impl/util/HiddenInputBuilder.js.map +0 -1
  221. package/target/src/main/typescript/impl/util/IListener.js +0 -3
  222. package/target/src/main/typescript/impl/util/IListener.js.map +0 -1
  223. package/target/src/main/typescript/impl/util/Lang.js +0 -263
  224. package/target/src/main/typescript/impl/util/Lang.js.map +0 -1
  225. package/target/src/main/typescript/impl/util/XhrQueueController.js +0 -92
  226. package/target/src/main/typescript/impl/util/XhrQueueController.js.map +0 -1
  227. package/target/src/main/typescript/impl/xhrCore/ErrorData.js +0 -87
  228. package/target/src/main/typescript/impl/xhrCore/ErrorData.js.map +0 -1
  229. package/target/src/main/typescript/impl/xhrCore/EventData.js +0 -52
  230. package/target/src/main/typescript/impl/xhrCore/EventData.js.map +0 -1
  231. package/target/src/main/typescript/impl/xhrCore/IResponseProcessor.js +0 -3
  232. package/target/src/main/typescript/impl/xhrCore/IResponseProcessor.js.map +0 -1
  233. package/target/src/main/typescript/impl/xhrCore/RequestDataResolver.js +0 -186
  234. package/target/src/main/typescript/impl/xhrCore/RequestDataResolver.js.map +0 -1
  235. package/target/src/main/typescript/impl/xhrCore/Response.js +0 -186
  236. package/target/src/main/typescript/impl/xhrCore/Response.js.map +0 -1
  237. package/target/src/main/typescript/impl/xhrCore/ResponseDataResolver.js +0 -104
  238. package/target/src/main/typescript/impl/xhrCore/ResponseDataResolver.js.map +0 -1
  239. package/target/src/main/typescript/impl/xhrCore/ResponseProcessor.js +0 -468
  240. package/target/src/main/typescript/impl/xhrCore/ResponseProcessor.js.map +0 -1
  241. package/target/src/main/typescript/impl/xhrCore/XhrFormData.js +0 -163
  242. package/target/src/main/typescript/impl/xhrCore/XhrFormData.js.map +0 -1
  243. package/target/src/main/typescript/impl/xhrCore/XhrRequest.js +0 -433
  244. package/target/src/main/typescript/impl/xhrCore/XhrRequest.js.map +0 -1
  245. package/target/src/main/typescript/mona_dish_shim.js +0 -70
  246. package/target/src/main/typescript/mona_dish_shim.js.map +0 -1
  247. package/target/src/main/typescript/myfaces/OamSubmit.js +0 -128
  248. package/target/src/main/typescript/myfaces/OamSubmit.js.map +0 -1
  249. package/target/src/main/typescript/test/api/MyFacesABTest.spec.js +0 -117
  250. package/target/src/main/typescript/test/api/MyFacesABTest.spec.js.map +0 -1
  251. package/target/src/main/typescript/test/frameworkBase/LangTest.spec.js +0 -123
  252. package/target/src/main/typescript/test/frameworkBase/LangTest.spec.js.map +0 -1
  253. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +0 -657
  254. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +0 -1
  255. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/LangTest.spec.js +0 -107
  256. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +0 -1
  257. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MappingProbes.js +0 -106
  258. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MappingProbes.js.map +0 -1
  259. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MappingTest.spec.js +0 -39
  260. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +0 -1
  261. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.js +0 -153
  262. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +0 -1
  263. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.js +0 -2
  264. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.js.map +0 -1
  265. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +0 -925
  266. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +0 -1
  267. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +0 -112
  268. package/target/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +0 -1
  269. package/target/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.js +0 -728
  270. package/target/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.js.map +0 -1
  271. package/target/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.js +0 -296
  272. package/target/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.js.map +0 -1
  273. package/target/src/main/typescript/test/impl/ImplTest.spec.js +0 -225
  274. package/target/src/main/typescript/test/impl/ImplTest.spec.js.map +0 -1
  275. package/target/src/main/typescript/test/impl/ImplTest_23.spec.js +0 -143
  276. package/target/src/main/typescript/test/impl/ImplTest_23.spec.js.map +0 -1
  277. package/target/src/main/typescript/test/impl/SeparatorCharsTest.spec.js +0 -106
  278. package/target/src/main/typescript/test/impl/SeparatorCharsTest.spec.js.map +0 -1
  279. package/target/src/main/typescript/test/impl/util/ExtDomQueryTest.spec.js +0 -77
  280. package/target/src/main/typescript/test/impl/util/ExtDomQueryTest.spec.js.map +0 -1
  281. package/target/src/main/typescript/test/myfaces/OamSubmit.spec.js +0 -118
  282. package/target/src/main/typescript/test/myfaces/OamSubmit.spec.js.map +0 -1
  283. package/target/src/main/typescript/test/myfaces/OnLoad.spec.js +0 -57
  284. package/target/src/main/typescript/test/myfaces/OnLoad.spec.js.map +0 -1
  285. package/target/src/main/typescript/test/myfaces/ReserveNamespace.spec.js +0 -60
  286. package/target/src/main/typescript/test/myfaces/ReserveNamespace.spec.js.map +0 -1
  287. package/target/src/main/typescript/test/queue/AsynchronousProbe.js +0 -93
  288. package/target/src/main/typescript/test/queue/AsynchronousProbe.js.map +0 -1
  289. package/target/src/main/typescript/test/queue/AsynchronousQueueTest.spec.js +0 -133
  290. package/target/src/main/typescript/test/queue/AsynchronousQueueTest.spec.js.map +0 -1
  291. package/target/src/main/typescript/test/xhrCore/ClientWindow.spec.js +0 -101
  292. package/target/src/main/typescript/test/xhrCore/ClientWindow.spec.js.map +0 -1
  293. package/target/src/main/typescript/test/xhrCore/ErrorChainTest.spec.js +0 -175
  294. package/target/src/main/typescript/test/xhrCore/ErrorChainTest.spec.js.map +0 -1
  295. package/target/src/main/typescript/test/xhrCore/EventTests.spec.js +0 -184
  296. package/target/src/main/typescript/test/xhrCore/EventTests.spec.js.map +0 -1
  297. package/target/src/main/typescript/test/xhrCore/FakeWebsocket.js.map +0 -1
  298. package/target/src/main/typescript/test/xhrCore/FileUploadTest.spec.js +0 -181
  299. package/target/src/main/typescript/test/xhrCore/FileUploadTest.spec.js.map +0 -1
  300. package/target/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.js +0 -226
  301. package/target/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.js.map +0 -1
  302. package/target/src/main/typescript/test/xhrCore/OamSubmitTest.spec.js +0 -199
  303. package/target/src/main/typescript/test/xhrCore/OamSubmitTest.spec.js.map +0 -1
  304. package/target/src/main/typescript/test/xhrCore/RequestParamsTest.spec.js +0 -567
  305. package/target/src/main/typescript/test/xhrCore/RequestParamsTest.spec.js.map +0 -1
  306. package/target/src/main/typescript/test/xhrCore/RequestTest.spec.js +0 -845
  307. package/target/src/main/typescript/test/xhrCore/RequestTest.spec.js.map +0 -1
  308. package/target/src/main/typescript/test/xhrCore/RequestTest_23.spec.js +0 -382
  309. package/target/src/main/typescript/test/xhrCore/RequestTest_23.spec.js.map +0 -1
  310. package/target/src/main/typescript/test/xhrCore/ResponseTest.spec.js +0 -667
  311. package/target/src/main/typescript/test/xhrCore/ResponseTest.spec.js.map +0 -1
  312. package/target/src/main/typescript/test/xhrCore/ResponseTest23.spec.js +0 -367
  313. package/target/src/main/typescript/test/xhrCore/ResponseTest23.spec.js.map +0 -1
  314. package/target/src/main/typescript/test/xhrCore/ShadowDomTest.spec.js +0 -123
  315. package/target/src/main/typescript/test/xhrCore/ShadowDomTest.spec.js.map +0 -1
  316. package/target/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.js +0 -147
  317. package/target/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.js.map +0 -1
  318. package/target/src/main/typescript/test/xhrCore/WebsocketTest.js +0 -207
  319. package/target/src/main/typescript/test/xhrCore/WebsocketTest.js.map +0 -1
  320. package/target/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.js +0 -149
  321. package/target/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.js.map +0 -1
  322. package/target/src/main/typescript/test/xhrCore/XhrRequestProgress.spec.js +0 -130
  323. package/target/src/main/typescript/test/xhrCore/XhrRequestProgress.spec.js.map +0 -1
  324. package/target/test/api/MyFacesABTest.spec.js +0 -117
  325. package/target/test/api/MyFacesABTest.spec.js.map +0 -1
  326. package/target/test/frameworkBase/LangTest.spec.js +0 -123
  327. package/target/test/frameworkBase/LangTest.spec.js.map +0 -1
  328. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +0 -657
  329. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +0 -1
  330. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +0 -107
  331. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +0 -1
  332. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +0 -106
  333. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +0 -1
  334. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +0 -39
  335. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +0 -1
  336. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +0 -153
  337. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +0 -1
  338. package/target/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.js +0 -1
  339. package/target/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.js.map +0 -1
  340. package/target/test/frameworkBase/_ext/monadish/fixtures/test.js.map +0 -1
  341. package/target/test/frameworkBase/_ext/monadish/fixtures/test2.js.map +0 -1
  342. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +0 -925
  343. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +0 -1
  344. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +0 -112
  345. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +0 -1
  346. package/target/test/frameworkBase/_ext/shared/StandardInits.js +0 -728
  347. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +0 -1
  348. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +0 -296
  349. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +0 -1
  350. package/target/test/frameworkBase/_ext/shared/fixtures/js/tobago.js +0 -16
  351. package/target/test/frameworkBase/_ext/shared/fixtures/js/tobago.js.map +0 -1
  352. package/target/test/impl/ImplTest.spec.js +0 -225
  353. package/target/test/impl/ImplTest.spec.js.map +0 -1
  354. package/target/test/impl/ImplTest_23.spec.js +0 -143
  355. package/target/test/impl/ImplTest_23.spec.js.map +0 -1
  356. package/target/test/impl/SeparatorCharsTest.spec.js +0 -106
  357. package/target/test/impl/SeparatorCharsTest.spec.js.map +0 -1
  358. package/target/test/impl/util/ExtDomQueryTest.spec.js +0 -77
  359. package/target/test/impl/util/ExtDomQueryTest.spec.js.map +0 -1
  360. package/target/test/myfaces/OamSubmit.spec.js +0 -118
  361. package/target/test/myfaces/OamSubmit.spec.js.map +0 -1
  362. package/target/test/myfaces/OnLoad.spec.js +0 -57
  363. package/target/test/myfaces/OnLoad.spec.js.map +0 -1
  364. package/target/test/myfaces/ReserveNamespace.spec.js +0 -60
  365. package/target/test/myfaces/ReserveNamespace.spec.js.map +0 -1
  366. package/target/test/queue/AsynchronousProbe.js +0 -93
  367. package/target/test/queue/AsynchronousProbe.js.map +0 -1
  368. package/target/test/queue/AsynchronousQueueTest.spec.js +0 -133
  369. package/target/test/queue/AsynchronousQueueTest.spec.js.map +0 -1
  370. package/target/test/xhrCore/ClientWindow.spec.js +0 -101
  371. package/target/test/xhrCore/ClientWindow.spec.js.map +0 -1
  372. package/target/test/xhrCore/ErrorChainTest.spec.js +0 -175
  373. package/target/test/xhrCore/ErrorChainTest.spec.js.map +0 -1
  374. package/target/test/xhrCore/EventTests.spec.js +0 -184
  375. package/target/test/xhrCore/EventTests.spec.js.map +0 -1
  376. package/target/test/xhrCore/FakeWebsocket.js +0 -38
  377. package/target/test/xhrCore/FakeWebsocket.js.map +0 -1
  378. package/target/test/xhrCore/FileUploadTest.spec.js +0 -181
  379. package/target/test/xhrCore/FileUploadTest.spec.js.map +0 -1
  380. package/target/test/xhrCore/NamespacesRequestTest.spec.js +0 -226
  381. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +0 -1
  382. package/target/test/xhrCore/OamSubmitTest.spec.js +0 -199
  383. package/target/test/xhrCore/OamSubmitTest.spec.js.map +0 -1
  384. package/target/test/xhrCore/RequestParamsTest.spec.js +0 -567
  385. package/target/test/xhrCore/RequestParamsTest.spec.js.map +0 -1
  386. package/target/test/xhrCore/RequestTest.spec.js +0 -845
  387. package/target/test/xhrCore/RequestTest.spec.js.map +0 -1
  388. package/target/test/xhrCore/RequestTest_23.spec.js +0 -382
  389. package/target/test/xhrCore/RequestTest_23.spec.js.map +0 -1
  390. package/target/test/xhrCore/ResponseTest.spec.js +0 -667
  391. package/target/test/xhrCore/ResponseTest.spec.js.map +0 -1
  392. package/target/test/xhrCore/ResponseTest23.spec.js +0 -367
  393. package/target/test/xhrCore/ResponseTest23.spec.js.map +0 -1
  394. package/target/test/xhrCore/ShadowDomTest.spec.js +0 -123
  395. package/target/test/xhrCore/ShadowDomTest.spec.js.map +0 -1
  396. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +0 -147
  397. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +0 -1
  398. package/target/test/xhrCore/WebsocketTest.js +0 -207
  399. package/target/test/xhrCore/WebsocketTest.js.map +0 -1
  400. package/target/test/xhrCore/XhrFormDataTest.spec.js +0 -149
  401. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +0 -1
  402. package/target/test/xhrCore/XhrRequestProgress.spec.js +0 -130
  403. package/target/test/xhrCore/XhrRequestProgress.spec.js.map +0 -1
  404. package/target/test/xhrCore/fixtures/addedViewHead1.js +0 -17
  405. package/target/test/xhrCore/fixtures/addedViewHead1.js.map +0 -1
  406. package/target/test/xhrCore/fixtures/addedViewHead2.js +0 -17
  407. package/target/test/xhrCore/fixtures/addedViewHead2.js.map +0 -1
  408. package/target/test/xhrCore/fixtures/addedViewHead3.js +0 -17
  409. package/target/test/xhrCore/fixtures/addedViewHead3.js.map +0 -1
  410. package/target/test/xhrCore/fixtures/nonce_script.js +0 -17
  411. package/target/test/xhrCore/fixtures/nonce_script.js.map +0 -1
  412. package/tsconfig.json +0 -9
  413. package/webpack.config.ts +0 -54
@@ -17,7 +17,7 @@
17
17
  /**
18
18
  * Typescript port of the faces\.push part in the myfaces implementation
19
19
  */
20
- import {MAX_RECONNECT_ATTEMPTS, REASON_EXPIRED, RECONNECT_INTERVAL} from "./core/Const";
20
+ import {MAX_RECONNECT_ATTEMPTS, RECONNECT_INTERVAL} from "./core/Const";
21
21
  import {DQ} from "mona-dish";
22
22
 
23
23
  /**
@@ -34,18 +34,37 @@ export namespace PushImpl {
34
34
  // they are not directly touched outside of tests
35
35
 
36
36
  /* socket map by token */
37
- export let sockets = {};
37
+ export type OpenCallback = (channel: string) => void;
38
+ export type MessageCallback = (message: any, channel: string, event: MessageEvent) => void;
39
+ export type ErrorCallback = (code: number, channel: string, event: CloseEvent) => void;
40
+ export type CloseCallback = (code: number, channel: string, event?: CloseEvent) => void;
41
+
42
+ type ComponentData = {
43
+ channelToken: string;
44
+ onopen: OpenCallback;
45
+ onmessage: MessageCallback;
46
+ onerror: ErrorCallback;
47
+ onclose: CloseCallback;
48
+ behaviors: any;
49
+ autoconnect: boolean;
50
+ };
51
+
52
+ /** @internal */
53
+ export let sockets: {[key: string]: Socket} = {};
38
54
  /* component attributes by clientId */
39
- export let components = {};
55
+ /** @internal */
56
+ export let components: {[key: string]: ComponentData} = {};
40
57
  /* client ids by token (share websocket connection) */
41
- export let clientIdsByTokens = {};
42
-
58
+ /** @internal */
59
+ export let clientIdsByTokens: {[key: string]: string[]} = {};
43
60
 
44
61
  // needed for testing
62
+ /** @internal */
45
63
  export function reset() {
64
+ Object.values(sockets).forEach(s => { try { s.close(); } catch(e) { /* ignore */ } });
46
65
  sockets = {};
47
- components = {}
48
- clientIdsByTokens = {}
66
+ components = {};
67
+ clientIdsByTokens = {};
49
68
  }
50
69
 
51
70
  /*
@@ -66,13 +85,13 @@ export namespace PushImpl {
66
85
  export function init(socketClientId: string,
67
86
  url: string,
68
87
  channel: string,
69
- onopen: Function,
70
- onmessage: Function,
71
- onerror: Function,
72
- onclose: Function,
88
+ onopen: OpenCallback | string,
89
+ onmessage: MessageCallback | string,
90
+ onerror: ErrorCallback | string,
91
+ onclose: CloseCallback | string,
73
92
  behaviors: any,
74
93
  autoConnect: boolean) {
75
- onclose = resolveFunction(onclose);
94
+ onclose = resolveFunction(onclose) as CloseCallback;
76
95
 
77
96
  if (!DQ.global().WebSocket) { // IE6-9.
78
97
  onclose(-1, channel);
@@ -84,9 +103,9 @@ export namespace PushImpl {
84
103
  if (!components[socketClientId]) {
85
104
  components[socketClientId] = {
86
105
  'channelToken': channelToken,
87
- 'onopen': resolveFunction(onopen),
88
- 'onmessage' : resolveFunction(onmessage),
89
- 'onerror' : resolveFunction(onerror),
106
+ 'onopen': resolveFunction(onopen) as OpenCallback,
107
+ 'onmessage' : resolveFunction(onmessage) as MessageCallback,
108
+ 'onerror' : resolveFunction(onerror) as ErrorCallback,
90
109
  'onclose': onclose,
91
110
  'behaviors': behaviors,
92
111
  'autoconnect': autoConnect};
@@ -127,58 +146,40 @@ export namespace PushImpl {
127
146
 
128
147
  class Socket {
129
148
 
130
- socket: WebSocket;
131
- reconnectAttempts = 0;
149
+ private socket: WebSocket | null = null;
150
+ private reconnectAttempts = 0;
151
+ private hasEverConnected = false;
152
+ private hasNotifiedInitialOpenAttempt = false;
132
153
 
133
154
  constructor(private channelToken: string, private url: string, private channel: string) {
134
155
  }
135
156
 
136
157
  open() {
137
- if (this.socket && this.socket.readyState == 1) {
158
+ if (this.socket && this.socket.readyState === 1) {
138
159
  return;
139
160
  }
140
161
  this.socket = new WebSocket(this.url);
141
-
142
162
  this.bindCallbacks();
163
+ this.notifyInitialOpenAttempt();
143
164
  }
144
165
 
145
166
  // noinspection JSUnusedLocalSymbols
146
167
  onopen(event: any) {
147
- if (!this.reconnectAttempts) {
148
- let clientIds = clientIdsByTokens[this.channelToken];
149
- for (let i = clientIds.length - 1; i >= 0; i--) {
150
- let socketClientId = clientIds[i];
151
- components[socketClientId]?.['onopen']?.(this.channel);
152
- }
153
- }
168
+ this.hasEverConnected = true;
154
169
  this.reconnectAttempts = 0;
155
170
  }
156
171
 
157
172
  onerror(event: any) {
158
- let message = JSON.parse(event?.data ?? null);
159
- //TODO replace this with a more readable Stream code
160
- for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
161
- let socketClientId = clientIdsByTokens[this.channelToken][i];
162
- if (document.getElementById(socketClientId)) {
163
- try {
164
- components[socketClientId]?.['onerror']?.(message, this.channel, event);
165
- } catch (e) {
166
- //Ignore
167
- }
168
- } else {
169
- clientIdsByTokens[this.channelToken].splice(i, 1);
170
- }
171
- }
172
- if (clientIdsByTokens[this.channelToken].length == 0) {
173
- // tag disappeared
174
- this.close();
175
- }
173
+ // Native WebSocket error events do not expose the close reason code.
174
+ // Faces onerror is fired from onclose only when a reconnect is attempted.
176
175
  }
177
176
 
178
- onmmessage(event: any) {
177
+ onmessage(event: any) {
179
178
  let message = JSON.parse(event.data);
180
- for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
181
- let socketClientId = clientIdsByTokens[this.channelToken][i];
179
+ let clientIds = clientIdsByTokens[this.channelToken];
180
+ if (!clientIds) return; // socket was torn down (reset()) while message was pending
181
+ for (let i = clientIds.length - 1; i >= 0; i--) {
182
+ let socketClientId = clientIds[i];
182
183
  if (document.getElementById(socketClientId)) {
183
184
  try {
184
185
  components[socketClientId]?.['onmessage']?.(message, this.channel, event);
@@ -197,29 +198,26 @@ export namespace PushImpl {
197
198
  }
198
199
  }
199
200
  } else {
200
- clientIdsByTokens[this.channelToken].splice(i, 1);
201
+ clientIds.splice(i, 1);
201
202
  }
202
203
  }
203
- if (clientIdsByTokens[this.channelToken].length == 0) {
204
+ if (clientIds.length === 0) {
204
205
  // tag disappeared
205
206
  this.close();
206
207
  }
207
208
  }
208
209
 
209
210
  onclose(event: any) {
210
- if (!this.socket
211
- || (event.code == 1000 && event.reason == REASON_EXPIRED)
212
- || (event.code == 1008)
213
- || (!this.reconnectAttempts)
214
- || (this.reconnectAttempts >= MAX_RECONNECT_ATTEMPTS)) {
215
- let clientIds = clientIdsByTokens[this.channelToken];
216
- for (let i = clientIds.length - 1; i >= 0; i--) {
217
- let socketClientId = clientIds[i];
218
- components?.[socketClientId]?.['onclose']?.(event?.code, this?.channel, event);
219
- }
220
- } else {
221
- setTimeout(this.open, RECONNECT_INTERVAL * this.reconnectAttempts++);
211
+ if (this.isTerminalClose(event)) {
212
+ this.notifyClose(event);
213
+ this.resetConnectionState();
214
+ return;
222
215
  }
216
+
217
+ if (!this.notifyErrorAndPruneMissingComponents(event)) return;
218
+ if (this.closeIfChannelHasNoComponents()) return;
219
+
220
+ this.scheduleReconnect();
223
221
  };
224
222
 
225
223
  close() {
@@ -230,14 +228,85 @@ export namespace PushImpl {
230
228
  }
231
229
  }
232
230
 
231
+ private notifyInitialOpenAttempt() {
232
+ if (this.reconnectAttempts || this.hasNotifiedInitialOpenAttempt) return;
233
+
234
+ this.hasNotifiedInitialOpenAttempt = true;
235
+ let clientIds = clientIdsByTokens[this.channelToken];
236
+ if (!clientIds) return; // socket was torn down (reset()) while timer was pending
237
+ for (let i = clientIds.length - 1; i >= 0; i--) {
238
+ let socketClientId = clientIds[i];
239
+ components[socketClientId]?.['onopen']?.(this.channel);
240
+ }
241
+ }
242
+
243
+ private isTerminalClose(event: any): boolean {
244
+ return !this.socket
245
+ // Spec: no reconnect when the very first connection attempt fails.
246
+ // onerror must also not be invoked in this case, only onclose.
247
+ || !this.hasEverConnected
248
+ // Spec: code 1000 (normal closure) is always terminal, regardless of reason.
249
+ || event.code === 1000
250
+ // 1008 = Policy Violation. Reconnecting would hit the same rejection again.
251
+ || event.code === 1008
252
+ || this.reconnectAttempts >= MAX_RECONNECT_ATTEMPTS;
253
+ }
254
+
255
+ private notifyClose(event: any) {
256
+ let clientIds = clientIdsByTokens[this.channelToken];
257
+ if (!clientIds) return; // already torn down (reset() called while socket was open)
258
+ for (let i = clientIds.length - 1; i >= 0; i--) {
259
+ let socketClientId = clientIds[i];
260
+ components?.[socketClientId]?.['onclose']?.(event?.code, this?.channel, event);
261
+ }
262
+ }
263
+
264
+ private resetConnectionState() {
265
+ this.reconnectAttempts = 0;
266
+ this.hasEverConnected = false;
267
+ this.hasNotifiedInitialOpenAttempt = false;
268
+ }
269
+
270
+ private notifyErrorAndPruneMissingComponents(event: any): boolean {
271
+ let clientIds = clientIdsByTokens[this.channelToken];
272
+ if (!clientIds) return false; // already torn down (reset() called while socket was open)
273
+ for (let i = clientIds.length - 1; i >= 0; i--) {
274
+ let socketClientId = clientIds[i];
275
+ if (document.getElementById(socketClientId)) {
276
+ try {
277
+ components?.[socketClientId]?.['onerror']?.(event?.code, this?.channel, event);
278
+ } catch (e) {
279
+ //Ignore
280
+ }
281
+ } else {
282
+ clientIds.splice(i, 1);
283
+ }
284
+ }
285
+ return true;
286
+ }
287
+
288
+ private closeIfChannelHasNoComponents(): boolean {
289
+ if (clientIdsByTokens[this.channelToken]?.length !== 0) return false;
290
+
291
+ // tag disappeared
292
+ this.close();
293
+ return true;
294
+ }
295
+
296
+ private scheduleReconnect() {
297
+ const reconnectAttempt = ++this.reconnectAttempts;
298
+ this.socket = null;
299
+ setTimeout(() => this.open(), RECONNECT_INTERVAL * reconnectAttempt);
300
+ }
301
+
233
302
  /**
234
303
  * bind the callbacks to the socket callbacks
235
304
  */
236
305
  private bindCallbacks() {
237
- this.socket.onopen = (event: Event) => this.onopen(event);
238
- this.socket.onmessage = (event: Event) => this.onmmessage(event);
239
- this.socket.onclose = (event: Event) => this.onclose(event);
240
- this.socket.onerror = (event: Event) => this.onerror(event);
306
+ this.socket!.onopen = (event: Event) => this.onopen(event);
307
+ this.socket!.onmessage = (event: Event) => this.onmessage(event);
308
+ this.socket!.onclose = (event: Event) => this.onclose(event);
309
+ this.socket!.onerror = (event: Event) => this.onerror(event);
241
310
  }
242
311
  }
243
312
 
@@ -271,9 +340,10 @@ export namespace PushImpl {
271
340
  }
272
341
  }
273
342
 
274
- function resolveFunction(fn: Function | string = () => {
275
- }): Function {
276
- return <Function>((typeof fn !== "function") && (fn = DQ.global()[fn]), fn);
343
+ function resolveFunction<T extends Function>(fn?: T | string | null): T {
344
+ if (typeof fn === "function") return fn as T;
345
+ if (typeof fn === "string" && typeof DQ.global()[fn] === "function") return DQ.global()[fn] as T;
346
+ return (() => {}) as unknown as T;
277
347
  }
278
348
 
279
- }
349
+ }
@@ -206,8 +206,8 @@ export const UNKNOWN = "UNKNOWN";
206
206
  * changed to a simple value passthrough
207
207
  */
208
208
 
209
- export function $faces(): FacesAPI {
210
- return (window?.faces ?? window?.jsf) as FacesAPI;
209
+ export function $faces(): typeof faces {
210
+ return window?.faces ?? window?.jsf;
211
211
  }
212
212
 
213
213
  export function $nsp(inputNamespace?: any): any {
@@ -47,7 +47,7 @@ export class Messages {
47
47
  /** @constant */
48
48
  ERR_TRANSPORT = "Transport type {0} does not exist";
49
49
  /** @constant */
50
- ERR_EVT_PASS = "an event must be passed down (either a an event object null or undefined) ";
50
+ ERR_EVT_PASS = "an event must be passed down (either an event object null or undefined) ";
51
51
  /** @constant */
52
52
  ERR_CONSTRUCT = "Parts of the response couldn't be retrieved when constructing the event data= {0} ";
53
53
  /** @constant */
@@ -49,7 +49,7 @@ export namespace Assertions {
49
49
 
50
50
  export function assertUrlExists(node: XMLQuery): void | never {
51
51
  if (node.attr(ATTR_URL).isAbsent()) {
52
- throw Assertions.raiseError(new Error(), ExtLang.getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
52
+ throw Assertions.raiseError(new Error(), ExtLang.getMessage("ERR_RED_URL", undefined, "processRedirect"), "processRedirect");
53
53
  }
54
54
  }
55
55
 
@@ -113,4 +113,3 @@ export namespace Assertions {
113
113
  }
114
114
  }
115
115
 
116
-
@@ -30,12 +30,12 @@ export interface IAsyncRunnable<T> {
30
30
  /**
31
31
  * starts the runnable
32
32
  */
33
- start();
33
+ start(): void;
34
34
 
35
35
  /**
36
36
  * cancel the current ongoing op if possible
37
37
  */
38
- cancel();
38
+ cancel(): void;
39
39
 
40
40
  /**
41
41
  * callback for then functionality
@@ -127,7 +127,7 @@ export abstract class AsyncRunnable<T> implements IAsyncRunnable<T>{
127
127
 
128
128
  /**
129
129
  * registers a finally functor
130
- * @param func the functor for the finally handling chanin
130
+ * @param func the functor for the finally handling chain
131
131
  */
132
132
  finally(func: () => void): IAsyncRunnable<T> {
133
133
  // no ie11 support we probably are going to revert to shims for that one
@@ -144,4 +144,3 @@ export abstract class AsyncRunnable<T> implements IAsyncRunnable<T>{
144
144
  return this;
145
145
  }
146
146
  }
147
-
@@ -27,7 +27,7 @@ import {$faces, $nsp, P_WINDOW_ID} from "../core/Const";
27
27
  const IS_FACES_SOURCE = (source?: string): boolean => {
28
28
  //spec version smaller 4 we have to deal with the jsf namespace
29
29
 
30
- return source && !!(source?.search(/\/jakarta\.faces\.resource.*\/faces\.js.*/) != -1 ||
30
+ return !!source && !!(source.search(/\/jakarta\.faces\.resource.*\/faces\.js.*/) != -1 ||
31
31
  source?.search(/\/faces-development\.js.*/) != -1 ||
32
32
  source?.search(/\/faces-uncompressed\.js.*/) != -1 ||
33
33
  source?.search(/\/faces[^.]*\.js.*ln=jakarta.faces.*/gi) != -1 ||
@@ -56,6 +56,10 @@ const IS_INTERNAL_SOURCE = (source: string): boolean => {
56
56
 
57
57
  const ATTR_SRC = 'src';
58
58
 
59
+ function isRegExpMatchArray(value: RegExpMatchArray | null): value is RegExpMatchArray {
60
+ return value != null && value.length > 1;
61
+ }
62
+
59
63
  /**
60
64
  * Extension which adds implementation specific
61
65
  * meta-data to our dom query
@@ -123,8 +127,8 @@ export class ExtDomQuery extends DQ {
123
127
  // the last possibility
124
128
  let nonceScript: Optional<DomQuery> = Optional.fromNullable(DQ
125
129
  .querySelectorAll("script[src], link[src]").asArray
126
- .filter((item) => item.nonce.isPresent() && item.attr(ATTR_SRC) != null)
127
- .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))?.[0]);
130
+ .filter((item) => item.nonce.isPresent() && item.attr(ATTR_SRC).value != null)
131
+ .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value ?? undefined))?.[0]);
128
132
  if(!nonceScript?.value) {
129
133
  return ValueEmbedder.absent as ValueEmbedder<string>;
130
134
  }
@@ -144,18 +148,14 @@ export class ExtDomQuery extends DQ {
144
148
  searchJsfJsFor(regExp: RegExp): Optional<string> {
145
149
  //perfect application for lazy stream
146
150
  return Optional.fromNullable(DQ.querySelectorAll("script[src], link[src]").asArray
147
- .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
148
- .map(item => item.attr(ATTR_SRC).value.match(regExp))
149
- .filter(item => item != null && item.length > 1)
150
- .map((result: string[]) => {
151
+ .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value ?? undefined))
152
+ .map(item => (item.attr(ATTR_SRC).value ?? "").match(regExp))
153
+ .filter(isRegExpMatchArray)
154
+ .map((result) => {
151
155
  return decodeURIComponent(result[1]);
152
156
  })?.[0]);
153
157
  }
154
158
 
155
- globalEval(code: string, nonce ?: string): DQ {
156
- return new ExtDomQuery(super.globalEval(code, nonce ?? this.nonce.value));
157
- }
158
-
159
159
  // called from base class runScripts, do not delete
160
160
  // noinspection JSUnusedGlobalSymbols
161
161
  globalEvalSticky(code: string, nonce ?: string): DQ {
@@ -183,7 +183,7 @@ export class ExtDomQuery extends DQ {
183
183
  runHeadInserts(suppressDoubleIncludes = true): void {
184
184
  let head = ExtDomQuery.byId(document.head);
185
185
  //automated nonce handling
186
- let processedScripts = [];
186
+ let processedScripts: DomQuery[] = [];
187
187
 
188
188
  // the idea is only to run head inserts on resources
189
189
  // which do not exist already, that way
@@ -264,26 +264,26 @@ export class ExtConfig extends Config {
264
264
  super(root);
265
265
  }
266
266
 
267
- assignIf(condition: boolean, ...accessPath): IValueHolder<any> {
267
+ assignIf(condition: boolean, ...accessPath: string[]): IValueHolder<any> {
268
268
  const accessPathMapped = this.remap(accessPath);
269
269
  return super.assignIf(condition, ...accessPathMapped);
270
270
  }
271
271
 
272
- assign(...accessPath): IValueHolder<any> {
272
+ assign(...accessPath: string[]): IValueHolder<any> {
273
273
  const accessPathMapped = this.remap(accessPath);
274
274
  return super.assign(...accessPathMapped);
275
275
  }
276
276
 
277
- append(...accessPath): IValueHolder<any> {
277
+ append(...accessPath: string[]): IValueHolder<any> {
278
278
  return super.append(...accessPath);
279
279
  }
280
280
 
281
- appendIf(condition: boolean, ...accessPath): IValueHolder<any> {
281
+ appendIf(condition: boolean, ...accessPath: string[]): IValueHolder<any> {
282
282
  const accessPathMapped = this.remap(accessPath);
283
283
  return super.appendIf(condition, ...accessPathMapped);
284
284
  }
285
285
 
286
- getIf(...accessPath): Config {
286
+ getIf(...accessPath: string[]): Config {
287
287
  const accessPathMapped = this.remap(accessPath);
288
288
  return super.getIf(...accessPathMapped);
289
289
  }
@@ -333,6 +333,6 @@ export class ExtConfig extends Config {
333
333
  if(!this.$nspEnabled) {
334
334
  return accessPath;
335
335
  }
336
- return new Es2019Array(...accessPath).map(key => $nsp(key));
336
+ return new Es2019Array(...accessPath).map((key: string) => $nsp(key));
337
337
  }
338
- }
338
+ }
@@ -1,3 +1,19 @@
1
+ /*! Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
  import {Config, DomQuery, DQ, Es2019Array} from "mona-dish";
2
18
  import {ExtDomQuery} from "./ExtDomQuery";
3
19
  import {$faces, EMPTY_STR} from "../core/Const";
@@ -15,17 +31,17 @@ import {$faces, EMPTY_STR} from "../core/Const";
15
31
  * @param defaultStr a default string if nothing comes out of it
16
32
  */
17
33
  export function encodeFormData(formData: Config,
18
- paramsMapper = (inStr, inVal) => [inStr, inVal],
34
+ paramsMapper = (inStr: string, inVal: any) => [inStr, inVal],
19
35
  defaultStr = EMPTY_STR): string {
20
36
  if (formData.isAbsent()) {
21
37
  return defaultStr;
22
38
  }
23
39
  const assocValues = formData.value;
24
40
 
25
- const expandValueArrAndRename = key => assocValues[key].map(val => paramsMapper(key, val));
26
- const isPropertyKey = key => assocValues.hasOwnProperty(key);
27
- const isNotFile = ([, value]) => !(value instanceof ExtDomQuery.global().File);
28
- const mapIntoUrlParam = keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
41
+ const expandValueArrAndRename = (key: string) => assocValues[key].map((val: any) => paramsMapper(key, val));
42
+ const isPropertyKey = (key: string) => assocValues.hasOwnProperty(key);
43
+ const isNotFile = ([, value]: [string, any]) => !(value instanceof ExtDomQuery.global().File);
44
+ const mapIntoUrlParam = (keyVal: [string, any]) => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
29
45
 
30
46
  return new Es2019Array(...Object.keys(assocValues))
31
47
  .filter(isPropertyKey)
@@ -40,17 +56,17 @@ export function encodeFormData(formData: Config,
40
56
  * @param encoded encoded string
41
57
  */
42
58
  export function decodeEncodedValues(encoded: string): string[][] {
43
- const filterBlanks = item => !!(item || '').replace(/\s+/g, '');
44
- const splitKeyValuePair = _line => {
59
+ const filterBlanks = (item: string) => !!(item || '').replace(/\s+/g, '');
60
+ const splitKeyValuePair = (_line: string) => {
45
61
  let line = decodeURIComponent(_line);
46
62
  let index = line.indexOf("=");
47
- if (index == -1) {
63
+ if (index === -1) {
48
64
  return [line];
49
65
  }
50
66
  return [line.substring(0, index), line.substring(index + 1)];
51
67
  };
52
68
 
53
- let requestParamEntries = encoded.split(/&/gi);
69
+ let requestParamEntries = encoded.split("&");
54
70
  return requestParamEntries.filter(filterBlanks).map(splitKeyValuePair);
55
71
  }
56
72
 
@@ -61,10 +77,10 @@ export function decodeEncodedValues(encoded: string): string[][] {
61
77
  */
62
78
  export function resolveFiles(dataSource: DQ): [string, File][] {
63
79
 
64
- const expandFilesArr = ([key, files]) => {
65
- return [...files].map(file => [key, file]);
80
+ const expandFilesArr = ([key, files]: any[]) => {
81
+ return [...files].map((file: File) => [key, file]);
66
82
  }
67
- const remapFileInput = fileInput => {
83
+ const remapFileInput = (fileInput: DQ) => {
68
84
  return [fileInput.name.value || fileInput.id.value, fileInput.filesFromElem(0)];
69
85
  }
70
86
 
@@ -105,5 +121,5 @@ function resolveViewState(parentItem: DomQuery): string[][] | [string, File][] {
105
121
  export function getFormInputsAsArr(parentItem: DomQuery): string[][] | [string, File][] {
106
122
  const standardInputs: any = resolveViewState(parentItem);
107
123
  const fileInputs = resolveFiles(parentItem);
108
- return standardInputs.concat(fileInputs)
109
- }
124
+ return standardInputs.concat(fileInputs);
125
+ }
@@ -28,14 +28,14 @@ import {$faces, $nsp, HTML_CLIENT_WINDOW, HTML_VIEWSTATE, P_CLIENT_WINDOW, P_VIE
28
28
  export class HiddenInputBuilder {
29
29
  private namingContainerId?: string;
30
30
  private parent?: DomQuery;
31
- private namedViewRoot: boolean = false;
31
+ private namedViewRoot = false;
32
32
  private readonly name: string;
33
33
  private readonly template: string;
34
34
 
35
- constructor(private selector: string) {
36
- const isViewState = selector.indexOf($nsp(P_VIEWSTATE)) != -1;
37
- this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW
38
- this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW
35
+ constructor(selector: string) {
36
+ const isViewState = selector.includes($nsp(P_VIEWSTATE));
37
+ this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW;
38
+ this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW;
39
39
  }
40
40
 
41
41
  withNamingContainerId(namingContainer: string): HiddenInputBuilder {
@@ -55,39 +55,39 @@ export class HiddenInputBuilder {
55
55
 
56
56
 
57
57
  build(): DomQuery {
58
- const SEP = $faces().separatorchar;
59
-
60
- let existingStates = DQ$(`[name*='${$nsp(this.name)}']`);
61
- let cnt = existingStates.asArray.map(state => {
62
- let ident: string = state.id.orElse("0").value;
63
- ident = ident.substring(ident.lastIndexOf(SEP)+1);
64
- return parseInt(ident);
65
- })
66
- .filter(item => {
67
- return !isNaN(item);
68
- })
69
- .reduce((item1, item2) => {
70
- return Math.max(item1, item2);
71
- }, 0); //we start with 1 (see cnt++)
72
- //the maximum new ident is the current max + 1
73
- cnt++;
58
+ const newElement = DQ.fromMarkup($nsp(this.template));
59
+ newElement.id.value = this.buildId();
60
+ newElement.name.value = this.buildName();
61
+ this.parent?.append(newElement);
62
+ return newElement;
63
+ }
74
64
 
65
+ private buildId(): string {
66
+ const separator = $faces().separatorchar;
67
+ const parts = this.namingContainerId?.length ?
68
+ [this.namingContainerId, $nsp(this.name), this.nextIndex()] :
69
+ [$nsp(this.name), this.nextIndex()];
75
70
 
76
- const newElement = DQ.fromMarkup($nsp(this.template));
77
- newElement.id.value = ((this.namingContainerId?.length) ?
78
- [this.namingContainerId, $nsp(this.name), cnt]:
79
- [$nsp(this.name), cnt]).join(SEP);
71
+ return parts.join(separator);
72
+ }
80
73
 
81
- //name must be prefixed with the naming container id as well according to the jsdocs
82
- if(this.namedViewRoot) {
83
- newElement.name.value = (this.namingContainerId?.length) ?
84
- [this.namingContainerId, $nsp(this.name)].join(SEP): $nsp(this.name);
85
- } else {
86
- newElement.name.value = $nsp(this.name);
74
+ private buildName(): string {
75
+ if (!this.namedViewRoot) {
76
+ return $nsp(this.name);
87
77
  }
88
78
 
79
+ return this.namingContainerId?.length ?
80
+ [this.namingContainerId, $nsp(this.name)].join($faces().separatorchar) :
81
+ $nsp(this.name);
82
+ }
89
83
 
90
- this?.parent?.append(newElement);
91
- return newElement;
84
+ private nextIndex(): number {
85
+ const separator = $faces().separatorchar;
86
+ return DQ$(`[name*='${$nsp(this.name)}']`).asArray
87
+ .map(state => state.id.orElse("0").value)
88
+ .map(id => id.substring(id.lastIndexOf(separator) + 1))
89
+ .map(idSuffix => parseInt(idSuffix))
90
+ .filter(idSuffix => !isNaN(idSuffix))
91
+ .reduce((max, idSuffix) => Math.max(max, idSuffix), 0) + 1;
92
92
  }
93
- }
93
+ }