jsf.js_next_gen 4.0.0 → 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 (113) hide show
  1. package/README.md +7 -0
  2. package/dist/docs/assets/search.js +1 -1
  3. package/dist/docs/functions/faces.ajax.addOnError.html +4 -4
  4. package/dist/docs/functions/faces.ajax.request.html +7 -7
  5. package/dist/docs/functions/faces.ajax.response.html +1 -0
  6. package/dist/docs/functions/faces.util.chain.html +3 -3
  7. package/dist/docs/functions/myfaces.ab.html +1 -1
  8. package/dist/docs/functions/{myfaces.onOnDomReady.html → myfaces.onDomReady.html} +5 -5
  9. package/dist/docs/index.html +9 -0
  10. package/dist/docs/modules/myfaces.html +2 -2
  11. package/dist/docs/variables/myfaces.oam.html +1 -1
  12. package/dist/window/faces-development.js +1021 -628
  13. package/dist/window/faces-development.js.br +0 -0
  14. package/dist/window/faces-development.js.gz +0 -0
  15. package/dist/window/faces-development.js.map +1 -1
  16. package/dist/window/faces.js +1 -1
  17. package/dist/window/faces.js.br +0 -0
  18. package/dist/window/faces.js.gz +0 -0
  19. package/dist/window/faces.js.map +1 -1
  20. package/dist/window/jsf-development.js +1021 -628
  21. package/dist/window/jsf-development.js.br +0 -0
  22. package/dist/window/jsf-development.js.gz +0 -0
  23. package/dist/window/jsf-development.js.map +1 -1
  24. package/dist/window/jsf.js +1 -1
  25. package/dist/window/jsf.js.br +0 -0
  26. package/dist/window/jsf.js.gz +0 -0
  27. package/dist/window/jsf.js.map +1 -1
  28. package/package.json +3 -3
  29. package/plans for 4.0.1.txt +8 -0
  30. package/pom.xml +1 -1
  31. package/src/main/typescript/@types/definitions/index.d.ts +5 -5
  32. package/src/main/typescript/api/_api.ts +13 -12
  33. package/src/main/typescript/impl/AjaxImpl.ts +59 -45
  34. package/src/main/typescript/impl/core/Const.ts +5 -2
  35. package/src/main/typescript/impl/util/AsyncRunnable.ts +81 -6
  36. package/src/main/typescript/impl/util/ExtDomQuery.ts +7 -9
  37. package/src/main/typescript/impl/util/FileUtils.ts +26 -22
  38. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +7 -3
  39. package/src/main/typescript/impl/util/Lang.ts +61 -4
  40. package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
  41. package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
  42. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +12 -10
  43. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +32 -19
  44. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +51 -72
  45. package/src/main/typescript/myfaces/OamSubmit.ts +6 -6
  46. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +179 -40
  47. package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
  48. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
  49. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +921 -0
  50. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
  51. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +3 -2
  52. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
  53. package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
  54. package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
  55. package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
  56. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
  57. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +4 -4
  58. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +2 -2
  59. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +80 -6
  60. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +6 -1
  61. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +23 -22
  62. package/target/api/_api.js +12 -11
  63. package/target/api/_api.js.map +1 -1
  64. package/target/impl/AjaxImpl.js +50 -39
  65. package/target/impl/AjaxImpl.js.map +1 -1
  66. package/target/impl/core/Const.js +7 -5
  67. package/target/impl/core/Const.js.map +1 -1
  68. package/target/impl/util/AsyncRunnable.js +60 -0
  69. package/target/impl/util/AsyncRunnable.js.map +1 -1
  70. package/target/impl/util/ExtDomQuery.js +8 -8
  71. package/target/impl/util/ExtDomQuery.js.map +1 -1
  72. package/target/impl/util/FileUtils.js +21 -20
  73. package/target/impl/util/FileUtils.js.map +1 -1
  74. package/target/impl/util/HiddenInputBuilder.js +7 -3
  75. package/target/impl/util/HiddenInputBuilder.js.map +1 -1
  76. package/target/impl/util/IAsyncRunnable.js +27 -0
  77. package/target/impl/util/IAsyncRunnable.js.map +1 -0
  78. package/target/impl/util/Lang.js +52 -1
  79. package/target/impl/util/Lang.js.map +1 -1
  80. package/target/impl/util/XhrQueueController.js +33 -8
  81. package/target/impl/util/XhrQueueController.js.map +1 -1
  82. package/target/impl/xhrCore/EventData.js +2 -2
  83. package/target/impl/xhrCore/EventData.js.map +1 -1
  84. package/target/impl/xhrCore/ResponseProcessor.js +9 -7
  85. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  86. package/target/impl/xhrCore/XhrFormData.js +29 -15
  87. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  88. package/target/impl/xhrCore/XhrRequest.js +43 -64
  89. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  90. package/target/myfaces/OamSubmit.js +5 -3
  91. package/target/myfaces/OamSubmit.js.map +1 -1
  92. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +138 -37
  93. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  94. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
  95. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  96. package/target/test/frameworkBase/_ext/shared/StandardInits.js +3 -2
  97. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  98. package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
  99. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  100. package/target/test/xhrCore/EventTests.spec.js +26 -19
  101. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  102. package/target/test/xhrCore/NamespacesRequestTest.spec.js +3 -3
  103. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
  104. package/target/test/xhrCore/RequestParamsTest.spec.js +1 -1
  105. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  106. package/target/test/xhrCore/RequestTest.spec.js +73 -4
  107. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  108. package/target/test/xhrCore/RequestTest_23.spec.js +6 -0
  109. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  110. package/target/test/xhrCore/ResponseTest.spec.js +22 -15
  111. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  112. package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
  113. package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "4.0.0",
3
+ "version": "4.0.1-alpha.0",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/faces.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
24
24
  "@types/chai": "^4.3.4",
25
25
  "@types/mocha": "^10.0.1",
26
- "@types/node": "^18.14.2",
26
+ "@types/node": "^18.14.6",
27
27
  "@types/sinon": "^10.0.13",
28
28
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
29
29
  "chai": "^4.3.7",
@@ -49,6 +49,6 @@
49
49
  "webpack-dev-server": "^4.11.1"
50
50
  },
51
51
  "dependencies": {
52
- "mona-dish": "^0.26.0"
52
+ "mona-dish": "0.25.28"
53
53
  }
54
54
  }
@@ -0,0 +1,8 @@
1
+ # Brainstorming for 4.0.1
2
+
3
+ * Eliminate Streams - done, this was the biggest one
4
+ * Reintroduce partial page submit (myfaces.pps?), while never really used - done, pps=true is reintroduced
5
+ reducing the commit load onto execute!
6
+
7
+ queue size reduction... not really needed, there never was a usecase for it
8
+
package/pom.xml CHANGED
@@ -10,7 +10,7 @@
10
10
  </parent>
11
11
  <groupId>com.example</groupId>
12
12
  <artifactId>jsfs_js_ts</artifactId>
13
- <version>4.0</version>
13
+ <version>0.0.1-SNAPSHOT</version>
14
14
  <name>jsfs_js_ts</name>
15
15
  <description>Demo project for Spring Boot</description>
16
16
 
@@ -50,10 +50,10 @@ declare global {
50
50
  * <li> errorData.status : the error status message</li>
51
51
  * <li> errorData.serverErrorName : the server error name in case of a server error</li>
52
52
  * <li> errorData.serverErrorMessage : the server error message in case of a server error</li>
53
- * <li> errorData.source : the issuing source element which triggered the request </li>
54
- * <li> eventData.responseCode: the response code (aka http request response code, 401 etc...) </li>
55
- * <li> eventData.responseText: the response text </li>
56
- * <li> eventData.responseXML: the response xml </li>
53
+ * <li> errorData.source : the issuing source element which triggered the requestInternal </li>
54
+ * <li> eventData.responseCode: the response code (aka http requestInternal response code, 401 etc...) </li>
55
+ * <li> eventData.responseText: the requestInternal response text </li>
56
+ * <li> eventData.responseXML: the requestInternal response xml </li>
57
57
  * </ul>
58
58
  */
59
59
  interface IErrorData {
@@ -78,7 +78,7 @@ declare global {
78
78
  }
79
79
 
80
80
  interface Ajax {
81
- request(element: Element, event?: Event, options?: Options): void;
81
+ request(element: Element, event?: Event, options?: Context): void;
82
82
  response(request: XMLHttpRequest, context?: Context): void;
83
83
  }
84
84
 
@@ -117,19 +117,19 @@ export module faces {
117
117
  /**
118
118
  * this function has to send the ajax requests
119
119
  *
120
- * following request conditions must be met:
120
+ * following requestInternal conditions must be met:
121
121
  * <ul>
122
- * <li> the request must be sent asynchronously! </li>
123
- * <li> the request must be a POST!!! request </li>
124
- * <li> the request url must be the form action attribute </li>
125
- * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
122
+ * <li> the requestInternal must be sent asynchronously! </li>
123
+ * <li> the requestInternal must be a POST!!! requestInternal </li>
124
+ * <li> the requestInternal url must be the form action attribute </li>
125
+ * <li> all requests must be queued with a client side requestInternal queue to ensure the requestInternal ordering!</li>
126
126
  * </ul>
127
127
  *
128
128
  * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted
129
129
  * @param {EVENT} event: any javascript event supported by that object
130
130
  * @param {Map} options : map of options being pushed into the ajax cycle
131
131
  */
132
- export function request(element: Element, event?: Event, options?: Options): void {
132
+ export function request(element: Element, event?: Event, options?: Context): void {
133
133
  Implementation.request(element, event, options)
134
134
  }
135
135
 
@@ -138,6 +138,7 @@ export module faces {
138
138
  * @param request the request object having triggered this response
139
139
  * @param context the request context
140
140
  *
141
+ * TODO add info on what can be in the context
141
142
  */
142
143
  export function response(request: XMLHttpRequest, context?: Context): void {
143
144
  Implementation.response(request, context);
@@ -152,10 +153,10 @@ export module faces {
152
153
  * <li> errorData.status : the error status message</li>
153
154
  * <li> errorData.serverErrorName : the server error name in case of a server error</li>
154
155
  * <li> errorData.serverErrorMessage : the server error message in case of a server error</li>
155
- * <li> errorData.source : the issuing source element which triggered the request </li>
156
- * <li> eventData.responseCode: the response code (aka http request response code, 401 etc...) </li>
157
- * <li> eventData.responseText: the request response text </li>
158
- * <li> eventData.responseXML: the request response xml </li>
156
+ * <li> errorData.source : the issuing source element which triggered the requestInternal </li>
157
+ * <li> eventData.responseCode: the response code (aka http requestInternal response code, 401 etc...) </li>
158
+ * <li> eventData.responseText: the requestInternal response text </li>
159
+ * <li> eventData.responseXML: the requestInternal response xml </li>
159
160
  * </ul>
160
161
  *
161
162
  * @param errorFunc error handler must be of the format <i>function errorListener(&lt;errorData&gt;)</i>
@@ -188,7 +189,7 @@ export module faces {
188
189
  * @param funcs ... arbitrary array of functions or strings
189
190
  * @returns true if the chain has succeeded false otherwise
190
191
  */
191
- export function chain(source: HTMLElement | string, event: Event | null, ...funcs: Array<Function | string>): boolean {
192
+ export function chain(source, event, ...funcs: Array<Function | string>): boolean {
192
193
  return Implementation.chain(source, event, ...(funcs as EvalFuncs));
193
194
  }
194
195
  }
@@ -277,7 +278,7 @@ export module myfaces {
277
278
  *
278
279
  * @param executionFunc the function to be executed upon ready
279
280
  */
280
- export function onOnDomReady(executionFunc: () => void) {
281
+ export function onDomReady(executionFunc: () => void) {
281
282
  if(document.readyState !== "complete") {
282
283
  onReadyChain.push(executionFunc);
283
284
  if(!readyStateListener) {
@@ -17,8 +17,7 @@
17
17
  import {IListener} from "./util/IListener";
18
18
  import {Response} from "./xhrCore/Response";
19
19
  import {XhrRequest} from "./xhrCore/XhrRequest";
20
- import {AsynchronousQueue} from "./util/AsyncQueue";
21
- import {AssocArrayCollector, Config, DQ, Lang, LazyStream, Optional, Stream} from "mona-dish";
20
+ import {Config, DQ, Lang, Optional} from "mona-dish";
22
21
  import {Assertions} from "./util/Assertions";
23
22
  import {ExtConfig, ExtDomQuery} from "./util/ExtDomQuery";
24
23
  import {ErrorData} from "./xhrCore/ErrorData";
@@ -41,7 +40,7 @@ import {
41
40
  P_CLIENT_WINDOW,
42
41
  P_EVT,
43
42
  P_EXECUTE,
44
- P_PARTIAL_SOURCE,
43
+ P_AJAX_SOURCE,
45
44
  P_RENDER,
46
45
  P_RESET_VALUES,
47
46
  P_WINDOW_ID,
@@ -52,9 +51,8 @@ import {
52
51
  VIEW_ID,
53
52
  $faces,
54
53
  EMPTY_STR,
55
- CTX_PARAM_MF_INTERNAL,
56
54
  NAMED_VIEWROOT,
57
- NAMING_CONTAINER_ID
55
+ NAMING_CONTAINER_ID, CTX_PARAM_PPS, MYFACES_OPTION_PPS
58
56
  } from "./core/Const";
59
57
  import {
60
58
  resolveDefaults,
@@ -63,6 +61,7 @@ import {
63
61
  resolveTimeout, resolveViewId, resolveViewRootId, resoveNamingContainerMapper
64
62
  } from "./xhrCore/RequestDataResolver";
65
63
  import {encodeFormData} from "./util/FileUtils";
64
+ import {XhrQueueController} from "./util/XhrQueueController";
66
65
 
67
66
  /*
68
67
  * allowed project stages
@@ -91,6 +90,8 @@ enum BlockFilter {
91
90
  params = "params"
92
91
  }
93
92
 
93
+
94
+
94
95
  /**
95
96
  * Core Implementation
96
97
  * to distinct between api and impl
@@ -110,17 +111,7 @@ export module Implementation {
110
111
  it provides following
111
112
 
112
113
  a) Monad like structures for querying because this keeps the code denser and adds abstractions
113
- that always was the strong point of jquery and it still is better in this regard than what ecmascript provides
114
-
115
- b) Streams and lazy streams like java has, a pull stream construct, ecmascript does not have anything like it.
116
- (it has array filters and maps, but ES2015 does not support flatMap)
117
- Another option would have been rxjs but that would have introduced a code dependency and probably more code. We might
118
- move to RXJS if the need arises, however. But for now I would rather stick with my small self grown library which works
119
- quite well and where I can patch quickly (I have used it in several industrial projects, so it works well
120
- and is heavily fortified by unit tests (140 testcases as time of writing this))
121
- The long term plan is to eliminate the Stream usage as soon as we can move up to ES2019 (adding the missing
122
- functions as shims, is a no go, because we are a library, and absolutey do not Shim anything which can leak
123
- into the global namespace!)
114
+ that always was the strong point of jQuery, and it still is better in this regard than what ecmascript provides
124
115
 
125
116
  c) A neutral json like configuration which allows assignments of arbitrary values with reduce code which then can be
126
117
  transformed into different data representations
@@ -157,12 +148,14 @@ export module Implementation {
157
148
  import getMessage = ExtLang.getMessage;
158
149
  import getGlobalConfig = ExtLang.getGlobalConfig;
159
150
  import assert = Assertions.assert;
151
+ import ofAssoc = ExtLang.ofAssoc;
152
+ import collectAssoc = ExtLang.collectAssoc;
160
153
 
161
154
  let projectStage: string = null;
162
155
  let separator: string = null;
163
156
  let eventQueue = [];
164
157
  let errorQueue = [];
165
- export let requestQueue: AsynchronousQueue<XhrRequest> = null;
158
+ export let requestQueue: XhrQueueController<XhrRequest> = null;
166
159
  /*error reporting threshold*/
167
160
  let threshold = "ERROR";
168
161
 
@@ -192,7 +185,7 @@ export module Implementation {
192
185
  /**
193
186
  * @return the project stage also emitted by the server:
194
187
  * it cannot be cached and must be delivered over the server
195
- * The value for it comes from the request parameter of the faces.js script called "stage".
188
+ * The value for it comes from the requestInternal parameter of the faces.js script called "stage".
196
189
  */
197
190
  export function getProjectStage(): string | null {
198
191
  return resolveGlobalConfig()?.projectStage ??
@@ -218,17 +211,21 @@ export module Implementation {
218
211
  * @param event
219
212
  * @param funcs
220
213
  */
221
- export function chain(source: HTMLElement | string, event: Event | null, ...funcs: EvalFuncs): boolean {
222
- // we can use our lazy stream each functionality to run our chain here..
214
+ export function chain(source: any, event: Event, ...funcs: EvalFuncs): boolean {
215
+ // we can use our lazy stream each functionality to run our chain here.
223
216
  // by passing a boolean as return value into the onElem call
224
217
  // we can stop early at the first false, just like the spec requests
225
218
 
226
- return LazyStream.of(...funcs)
227
- .map(func => resolveAndExecute(source, event, func))
228
- // we use the return false == stop as an early stop, onElem stops at the first false
229
- .onElem((opResult: boolean) => opResult)
230
- //last ensures we run until the first false is returned
231
- .last().value;
219
+ let ret;
220
+ funcs.every(func => {
221
+ let returnVal = resolveAndExecute(source, event, func);
222
+ if(returnVal !== false) {
223
+ ret = returnVal;
224
+ }
225
+ return returnVal !== false;
226
+ });
227
+ return ret;
228
+
232
229
  }
233
230
 
234
231
  /**
@@ -278,7 +275,7 @@ export module Implementation {
278
275
 
279
276
  requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;
280
277
 
281
- // old non spec behavior will be removed after it is clear whether the removal breaks any code
278
+ // old non - spec behavior will be removed after it is clear whether the removal breaks any code
282
279
  requestCtx.assign(CTX_PARAM_REQ_PASS_THR).value = extractLegacyParams(options.value);
283
280
 
284
281
  // spec conform behavior, all passthrough params must be under "passthrough
@@ -310,14 +307,14 @@ export module Implementation {
310
307
  requestCtx.assign(ON_ERROR).value = options.value?.onerror;
311
308
 
312
309
  /**
313
- * lets drag the myfaces config params also in
310
+ * Fetch the myfaces config params
314
311
  */
315
312
  requestCtx.assign(MYFACES).value = options.value?.myfaces;
316
313
 
317
314
  /**
318
315
  * binding contract the jakarta.faces.source must be set
319
316
  */
320
- requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
317
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_AJAX_SOURCE).value = elementId;
321
318
 
322
319
  /**
323
320
  * jakarta.faces.partial.ajax must be set to true
@@ -344,6 +341,9 @@ export module Implementation {
344
341
  // won't hurt but for the sake of compatibility we are going to add it
345
342
  requestCtx.assign(CTX_PARAM_REQ_PASS_THR, formId).value = formId;
346
343
  internalCtx.assign(CTX_PARAM_SRC_CTL_ID).value = elementId;
344
+ // reintroduction of PPS as per myfaces 2.3 (myfaces.pps = true, only the executes are submitted)
345
+ internalCtx.assign(CTX_PARAM_PPS).value = extractMyFacesParams(options.value)?.[MYFACES_OPTION_PPS] ?? false;
346
+
347
347
 
348
348
  assignClientWindowId(form, requestCtx);
349
349
  assignExecute(options, requestCtx, form, elementId);
@@ -424,7 +424,7 @@ export module Implementation {
424
424
  }
425
425
  } finally {
426
426
  if (clearRequestQueue) {
427
- requestQueue.cleanup();
427
+ requestQueue.clear();
428
428
  }
429
429
  }
430
430
  }
@@ -503,7 +503,8 @@ export module Implementation {
503
503
  * or non-existent. If they exist all of them must be the same
504
504
  */
505
505
 
506
- let formWindowId: Optional<string> = searchRoot.stream.map(getValue).reduce(differenceCheck, INIT);
506
+ let formWindowId: Optional<string> = Optional.fromNullable(searchRoot.asArray
507
+ .map<string>(getValue).reduce(differenceCheck, INIT));
507
508
 
508
509
 
509
510
  //if the resulting window id is set on altered then we have an unresolvable problem
@@ -541,7 +542,7 @@ export module Implementation {
541
542
  let formElements = element.deepElements.encodeFormElement()
542
543
 
543
544
  // encode them! (file inputs are handled differently and are not part of the viewstate)
544
- return encodeFormData(formElements, resoveNamingContainerMapper(dummyContext));
545
+ return encodeFormData(new ExtConfig(formElements), resoveNamingContainerMapper(dummyContext));
545
546
  }
546
547
 
547
548
  /**
@@ -556,8 +557,8 @@ export module Implementation {
556
557
  * adds a new request to our queue for further processing
557
558
  */
558
559
  addRequestToQueue: function (elem: DQ, form: DQ, reqCtx: ExtConfig, respPassThr: Config, delay = 0, timeout = 0) {
559
- requestQueue = requestQueue ?? new AsynchronousQueue<XhrRequest>();
560
- requestQueue.enqueue(new XhrRequest(elem, form, reqCtx, respPassThr, [], timeout), delay);
560
+ requestQueue = requestQueue ?? new XhrQueueController<XhrRequest>();
561
+ requestQueue.enqueue(new XhrRequest(reqCtx, respPassThr, timeout), delay);
561
562
  }
562
563
  };
563
564
 
@@ -666,7 +667,7 @@ export module Implementation {
666
667
  * can deal with them either prefixed ir not
667
668
  * also resolves the absolute id case (it was assumed the server does this, but
668
669
  * apparently the RI does not, so we have to follow the RI behavior here)
669
- * @param componentIdToTransform the componentId which needs post processing
670
+ * @param componentIdToTransform the componentId which needs post-processing
670
671
  */
671
672
  const remapNamingContainer = componentIdToTransform => {
672
673
  // pattern :<anything> must be prepended by viewRoot if there is one,
@@ -680,7 +681,7 @@ export module Implementation {
680
681
  const hasLeadingSep = componentIdToTransform.indexOf(SEP) === 0;
681
682
  const isAbsolutSearchExpr = hasLeadingSep || (rootNamingContainerId.length
682
683
  && componentIdToTransform.indexOf(rootNamingContainerPrefix) == 0);
683
- let finalIdentifier = "";
684
+ let finalIdentifier: string;
684
685
  if (isAbsolutSearchExpr) {
685
686
  //we cut off the leading sep if there is one
686
687
  componentIdToTransform = hasLeadingSep ? componentIdToTransform.substring(1) : componentIdToTransform;
@@ -699,14 +700,14 @@ export module Implementation {
699
700
  [rootNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR) :
700
701
  [nearestNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR);
701
702
  }
702
- // We need to double check because we have scenarios where we have a naming container
703
+ // We need to double-check because we have scenarios where we have a naming container
703
704
  // and no prepend (aka tobago testcase "must handle ':' in IDs properly", scenario 3,
704
705
  // in this case we return the component id, and be happy
705
706
  // we can roll a dom check here
706
707
  return (!!document.getElementById(finalIdentifier)) ? finalIdentifier : componentIdToTransform;
707
708
  };
708
709
 
709
- // in this case we do not use lazy stream because it wont bring any code reduction
710
+ // in this case we do not use lazy stream because it won´t bring any code reduction
710
711
  // or speedup
711
712
  for (let cnt = 0; cnt < iterValues.length; cnt++) {
712
713
  //avoid doubles
@@ -748,24 +749,37 @@ export module Implementation {
748
749
  * the values required for params-through are processed in the ajax request
749
750
  *
750
751
  * Note this is a bug carried over from the old implementation
751
- * the spec conform behavior is to use params for passthrough values
752
+ * the spec conform behavior is to use params for pass - through values
752
753
  * this will be removed soon, after it is cleared up whether removing
753
754
  * it breaks any legacy code
754
755
  *
755
756
  * @param {Context} mappedOpts the options to be filtered
756
- * @deprecated
757
757
  */
758
- function extractLegacyParams(mappedOpts: Options): Context {
758
+ function extractLegacyParams(mappedOpts: Options): {[key: string]: any} {
759
+ //we now can use the full code reduction given by our stream api
760
+ //to filter
761
+ return ofAssoc(mappedOpts)
762
+ .filter((item => !(item[0] in BlockFilter)))
763
+ .reduce(collectAssoc, {});
764
+ }
765
+
766
+ /**
767
+ * extracts the myfaces config parameters which provide extra functionality
768
+ * on top of JSF
769
+ * @param mappedOpts
770
+ * @private
771
+ */
772
+ function extractMyFacesParams(mappedOpts: Options): {[key: string]: any} {
759
773
  //we now can use the full code reduction given by our stream api
760
774
  //to filter
761
- return Stream.ofAssoc(mappedOpts)
762
- .filter(item => !(item[0] in BlockFilter))
763
- .collect(new AssocArrayCollector());
775
+ return ofAssoc(mappedOpts)
776
+ .filter((item => (item[0] == "myfaces")))
777
+ .reduce(collectAssoc, {})?.[MYFACES];
764
778
  }
765
779
 
766
780
  function remapArrayToAssocArr(arrayedParams: [[string, any]] | {[key: string]: any}): {[key: string]: any} {
767
781
  if(Array.isArray(arrayedParams)) {
768
- return Stream.of(... arrayedParams).collect(new AssocArrayCollector());
782
+ return arrayedParams.reduce(collectAssoc, {} as any);
769
783
  }
770
784
  return arrayedParams;
771
785
  }
@@ -21,8 +21,8 @@
21
21
  export const XML_ATTR_NAMED_VIEWROOT = "namedViewRoot";
22
22
  export const NAMED_VIEWROOT = "namedViewRoot";
23
23
 
24
- export const P_PARTIAL_SOURCE = "jakarta.faces.source";
25
- export const NAMING_CONTAINER_ID = "myfaces.partialId";
24
+ export const P_AJAX_SOURCE = "jakarta.faces.source";
25
+ export const NAMING_CONTAINER_ID = "myfaces.NamingContainerId";
26
26
 
27
27
  export const VIEW_ID = "myfaces.viewId";
28
28
  export const P_VIEWSTATE = "jakarta.faces.ViewState";
@@ -108,6 +108,7 @@ export const CTX_PARAM_MF_INTERNAL = "myfaces.internal";
108
108
  export const CTX_PARAM_SRC_FRM_ID = "myfaces.source.formId";
109
109
  export const CTX_PARAM_SRC_CTL_ID = "myfaces.source.controlId";
110
110
  export const CTX_PARAM_REQ_PASS_THR = "myfaces.request.passThrough";
111
+ export const CTX_PARAM_PPS = "myfaces.request.pps";
111
112
 
112
113
  export const CONTENT_TYPE = "Content-Type";
113
114
  export const HEAD_FACES_REQ = "Faces-Request";
@@ -141,6 +142,8 @@ export const PHASE_PROCESS_RESPONSE = "processResponse";
141
142
 
142
143
  export const ERR_NO_PARTIAL_RESPONSE = "Partial response not set";
143
144
 
145
+ export const MYFACES_OPTION_PPS = "pps";
146
+
144
147
  export const ATTR_URL = "url";
145
148
  export const ATTR_NAME = "name";
146
149
  export const ATTR_VALUE = "value";
@@ -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
  */
@@ -45,9 +45,9 @@ export interface AsyncRunnable<T> {
45
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
@@ -59,7 +59,7 @@ export interface AsyncRunnable<T> {
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
+
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import {Config, IValueHolder, Optional, DomQuery, DQ, Stream, ArrayCollector} from "mona-dish";
16
+ import {Config, IValueHolder, Optional, DomQuery, DQ} from "mona-dish";
17
17
  import {$nsp, P_WINDOW_ID} from "../core/Const";
18
18
 
19
19
 
@@ -120,12 +120,10 @@ export class ExtDomQuery extends DQ {
120
120
  }
121
121
  // fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
122
122
  // the last possibility
123
- let nonceScript = DQ
124
- .querySelectorAll("script[src], link[src]")
125
- .lazyStream
123
+ let nonceScript = Optional.fromNullable(DQ
124
+ .querySelectorAll("script[src], link[src]").asArray
126
125
  .filter((item) => this.extractNonce(item) && item.attr(ATTR_SRC) != null)
127
- .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
128
- .first();
126
+ .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))?.[0]);
129
127
 
130
128
  if (nonceScript.isPresent()) {
131
129
  return this.extractNonce(nonceScript.value);
@@ -144,13 +142,13 @@ export class ExtDomQuery extends DQ {
144
142
  */
145
143
  searchJsfJsFor(regExp: RegExp): Optional<string> {
146
144
  //perfect application for lazy stream
147
- return DQ.querySelectorAll("script[src], link[src]").lazyStream
145
+ return Optional.fromNullable(DQ.querySelectorAll("script[src], link[src]").asArray
148
146
  .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
149
147
  .map(item => item.attr(ATTR_SRC).value.match(regExp))
150
148
  .filter(item => item != null && item.length > 1)
151
149
  .map((result: string[]) => {
152
150
  return decodeURIComponent(result[1]);
153
- }).first();
151
+ })?.[0]);
154
152
  }
155
153
 
156
154
  globalEval(code: string, nonce ?: string): DQ {
@@ -332,6 +330,6 @@ export class ExtConfig extends Config {
332
330
  if(!this.$nspEnabled) {
333
331
  return accessPath;
334
332
  }
335
- return Stream.of(...accessPath).map(key => $nsp(key)).collect(new ArrayCollector());
333
+ return [...accessPath].map(key => $nsp(key));
336
334
  }
337
335
  }