jsf.js_next_gen 4.0.1-alpha.0 → 4.0.1-beta.2

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 (115) hide show
  1. package/README.md +0 -12
  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 +0 -1
  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.onDomReady.html → myfaces.onOnDomReady.html} +5 -5
  9. package/dist/docs/index.html +0 -14
  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 +1323 -1300
  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 +1323 -1300
  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/pom.xml +1 -1
  30. package/src/main/typescript/@types/definitions/index.d.ts +5 -5
  31. package/src/main/typescript/api/_api.ts +12 -13
  32. package/src/main/typescript/impl/AjaxImpl.ts +68 -65
  33. package/src/main/typescript/impl/core/Const.ts +2 -5
  34. package/src/main/typescript/impl/util/AsyncQueue.ts +133 -0
  35. package/src/main/typescript/impl/util/AsyncRunnable.ts +6 -81
  36. package/src/main/typescript/impl/util/ExtDomQuery.ts +9 -7
  37. package/src/main/typescript/impl/util/FileUtils.ts +22 -26
  38. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +3 -7
  39. package/src/main/typescript/impl/util/Lang.ts +4 -61
  40. package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
  41. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +10 -12
  42. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +19 -32
  43. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +72 -51
  44. package/src/main/typescript/myfaces/OamSubmit.ts +6 -6
  45. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +40 -179
  46. package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
  47. package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +231 -0
  48. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +4 -5
  49. package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
  50. package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +3 -4
  51. package/src/main/typescript/test/xhrCore/ClientWindow.spec.ts +78 -0
  52. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +22 -28
  53. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +4 -4
  54. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +2 -2
  55. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +6 -80
  56. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +1 -6
  57. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +22 -23
  58. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +5 -5
  59. package/target/api/_api.js +11 -12
  60. package/target/api/_api.js.map +1 -1
  61. package/target/impl/AjaxImpl.js +59 -55
  62. package/target/impl/AjaxImpl.js.map +1 -1
  63. package/target/impl/core/Const.js +5 -7
  64. package/target/impl/core/Const.js.map +1 -1
  65. package/target/impl/util/AsyncRunnable.js +0 -60
  66. package/target/impl/util/AsyncRunnable.js.map +1 -1
  67. package/target/impl/util/ExtDomQuery.js +8 -8
  68. package/target/impl/util/ExtDomQuery.js.map +1 -1
  69. package/target/impl/util/FileUtils.js +20 -21
  70. package/target/impl/util/FileUtils.js.map +1 -1
  71. package/target/impl/util/HiddenInputBuilder.js +3 -7
  72. package/target/impl/util/HiddenInputBuilder.js.map +1 -1
  73. package/target/impl/util/Lang.js +1 -52
  74. package/target/impl/util/Lang.js.map +1 -1
  75. package/target/impl/xhrCore/EventData.js +2 -2
  76. package/target/impl/xhrCore/EventData.js.map +1 -1
  77. package/target/impl/xhrCore/ResponseProcessor.js +7 -9
  78. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  79. package/target/impl/xhrCore/XhrFormData.js +15 -29
  80. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  81. package/target/impl/xhrCore/XhrRequest.js +64 -43
  82. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  83. package/target/myfaces/OamSubmit.js +3 -5
  84. package/target/myfaces/OamSubmit.js.map +1 -1
  85. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +37 -138
  86. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  87. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
  88. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  89. package/target/test/frameworkBase/_ext/shared/StandardInits.js +4 -5
  90. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  91. package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
  92. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  93. package/target/test/xhrCore/ClientWindow.spec.js +90 -0
  94. package/target/test/xhrCore/ClientWindow.spec.js.map +1 -0
  95. package/target/test/xhrCore/EventTests.spec.js +19 -26
  96. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  97. package/target/test/xhrCore/NamespacesRequestTest.spec.js +3 -3
  98. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
  99. package/target/test/xhrCore/RequestParamsTest.spec.js +1 -1
  100. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  101. package/target/test/xhrCore/RequestTest.spec.js +4 -73
  102. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  103. package/target/test/xhrCore/RequestTest_23.spec.js +0 -6
  104. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  105. package/target/test/xhrCore/ResponseTest.spec.js +15 -22
  106. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  107. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +5 -5
  108. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -1
  109. package/plans for 4.0.1.txt +0 -8
  110. package/src/main/typescript/impl/util/XhrQueueController.ts +0 -112
  111. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
  112. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +0 -921
  113. package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +0 -108
  114. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
  115. package/src/main/typescript/test/myfaces/OnLoadSpec.ts +0 -52
@@ -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 IAsyncRunnable<T> {
29
+ export interface AsyncRunnable<T> {
30
30
  /**
31
31
  * starts the runnable
32
32
  */
@@ -45,9 +45,9 @@ export interface IAsyncRunnable<T> {
45
45
  * and then triggers all the registered then functions
46
46
  * when it is complete
47
47
  *
48
- * @param func the then functor
48
+ * @param func
49
49
  */
50
- then(func: (data: any) => any): IAsyncRunnable<T>;
50
+ then(func: (data: any) => any): AsyncRunnable<T>;
51
51
 
52
52
  /**
53
53
  * callback for catch functionality
@@ -59,7 +59,7 @@ export interface IAsyncRunnable<T> {
59
59
  *
60
60
  * @param func
61
61
  */
62
- catch(func: (data: any) => any): IAsyncRunnable<T>;
62
+ catch(func: (data: any) => any): AsyncRunnable<T>;
63
63
 
64
64
 
65
65
  /**
@@ -68,80 +68,5 @@ export interface IAsyncRunnable<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): 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
-
71
+ finally(func: () => void): AsyncRunnable<T>;
72
+ }
@@ -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} from "mona-dish";
16
+ import {Config, IValueHolder, Optional, DomQuery, DQ, Stream, ArrayCollector} from "mona-dish";
17
17
  import {$nsp, P_WINDOW_ID} from "../core/Const";
18
18
 
19
19
 
@@ -120,10 +120,12 @@ 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 = Optional.fromNullable(DQ
124
- .querySelectorAll("script[src], link[src]").asArray
123
+ let nonceScript = DQ
124
+ .querySelectorAll("script[src], link[src]")
125
+ .lazyStream
125
126
  .filter((item) => this.extractNonce(item) && item.attr(ATTR_SRC) != null)
126
- .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))?.[0]);
127
+ .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
128
+ .first();
127
129
 
128
130
  if (nonceScript.isPresent()) {
129
131
  return this.extractNonce(nonceScript.value);
@@ -142,13 +144,13 @@ export class ExtDomQuery extends DQ {
142
144
  */
143
145
  searchJsfJsFor(regExp: RegExp): Optional<string> {
144
146
  //perfect application for lazy stream
145
- return Optional.fromNullable(DQ.querySelectorAll("script[src], link[src]").asArray
147
+ return DQ.querySelectorAll("script[src], link[src]").lazyStream
146
148
  .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
147
149
  .map(item => item.attr(ATTR_SRC).value.match(regExp))
148
150
  .filter(item => item != null && item.length > 1)
149
151
  .map((result: string[]) => {
150
152
  return decodeURIComponent(result[1]);
151
- })?.[0]);
153
+ }).first();
152
154
  }
153
155
 
154
156
  globalEval(code: string, nonce ?: string): DQ {
@@ -330,6 +332,6 @@ export class ExtConfig extends Config {
330
332
  if(!this.$nspEnabled) {
331
333
  return accessPath;
332
334
  }
333
- return [...accessPath].map(key => $nsp(key));
335
+ return Stream.of(...accessPath).map(key => $nsp(key)).collect(new ArrayCollector());
334
336
  }
335
337
  }
@@ -1,4 +1,4 @@
1
- import {Config, DomQuery, DQ} from "mona-dish";
1
+ import {ArrayCollector, Config, DomQuery, DQ, LazyStream, Stream} from "mona-dish";
2
2
  import {ExtDomQuery} from "./ExtDomQuery";
3
3
  import {$faces, EMPTY_STR} from "../core/Const";
4
4
 
@@ -22,24 +22,27 @@ export function encodeFormData(formData: Config,
22
22
  }
23
23
  const assocValues = formData.value;
24
24
 
25
- const expandValueArrAndRename = key => assocValues[key].map(val => paramsMapper(key, val));
25
+ const expandValueArrAndRename = key => Stream.of(...assocValues[key]).map(val => paramsMapper(key, val));
26
26
  const isPropertyKey = key => assocValues.hasOwnProperty(key);
27
27
  const isNotFile = ([, value]) => !(value instanceof ExtDomQuery.global().File);
28
28
  const mapIntoUrlParam = keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
29
29
 
30
- return Object.keys(assocValues)
30
+ const entries = LazyStream.of(...Object.keys(assocValues))
31
31
  .filter(isPropertyKey)
32
32
  .flatMap(expandValueArrAndRename)
33
+ //we cannot encode file elements that is handled by multipart requests anyway
33
34
  .filter(isNotFile)
34
35
  .map(mapIntoUrlParam)
35
- .join("&");
36
+ .collect(new ArrayCollector());
37
+
38
+ return entries.join("&")
36
39
  }
37
40
 
38
41
  /**
39
42
  * splits and decodes encoded values into strings containing of key=value
40
43
  * @param encoded encoded string
41
44
  */
42
- export function decodeEncodedValues(encoded: string): string[][] {
45
+ export function decodeEncodedValues(encoded: string): Stream<string[]> {
43
46
  const filterBlanks = item => !!(item || '').replace(/\s+/g, '');
44
47
  const splitKeyValuePair = line => {
45
48
  let index = line.indexOf("=");
@@ -50,7 +53,9 @@ export function decodeEncodedValues(encoded: string): string[][] {
50
53
  };
51
54
 
52
55
  let requestParamEntries = decodeURIComponent(encoded).split(/&/gi);
53
- return requestParamEntries.filter(filterBlanks).map(splitKeyValuePair);
56
+ return Stream.of(...requestParamEntries)
57
+ .filter(filterBlanks)
58
+ .map(splitKeyValuePair)
54
59
  }
55
60
 
56
61
 
@@ -58,28 +63,19 @@ export function decodeEncodedValues(encoded: string): string[][] {
58
63
  * gets all the input files and their corresponding file objects
59
64
  * @param dataSource
60
65
  */
61
- export function resolveFiles(dataSource: DQ): [string, File][] {
62
-
63
- const expandFilesArr = ([key, files]) => {
64
- return [...files].map(file => [key, file]);
65
- }
66
- const remapFileInput = fileInput => {
67
- return [fileInput.name.value || fileInput.id.value, fileInput.filesFromElem(0)];
68
- }
66
+ export function resolveFiles(dataSource: DQ): Stream<[string, File]> {
69
67
 
70
- const files = dataSource
68
+ const expandFilesArr = ([key, files]) => Stream.of(...files).map(file => [key, file]);
69
+ const remapFileInput = fileInput => [fileInput.name.value || fileInput.id.value, fileInput.filesFromElem(0)];
70
+ return dataSource
71
71
  .querySelectorAllDeep("input[type='file']")
72
- .asArray;
73
-
74
- const ret = files
72
+ .stream
75
73
  .map(remapFileInput)
76
74
  .flatMap(expandFilesArr);
77
-
78
- return ret as any;
79
75
  }
80
76
 
81
77
 
82
- export function fixEmptyParameters(keyVal: any[]): [string, any] {
78
+ export function fixEmmptyParameters(keyVal: any[]): [string, any] {
83
79
  return (keyVal.length < 3 ? [keyVal?.[0] ?? [], keyVal?.[1] ?? []] : keyVal) as [string, any];
84
80
  }
85
81
 
@@ -87,7 +83,7 @@ export function fixEmptyParameters(keyVal: any[]): [string, any] {
87
83
  * returns the decoded viewState from parentItem
88
84
  * @param parentItem
89
85
  */
90
- function resolveViewState(parentItem: DomQuery): string[][] | [string, File][] {
86
+ function resolveViewState(parentItem: DomQuery): Stream<string[] | [string, File]> {
91
87
  const viewStateStr = $faces().getViewState(parentItem.getAsElem(0).value);
92
88
 
93
89
  // we now need to decode it and then merge it into the target buf
@@ -98,11 +94,11 @@ function resolveViewState(parentItem: DomQuery): string[][] | [string, File][] {
98
94
 
99
95
  /**
100
96
  * gets all the inputs under the form parentItem
101
- * as array
97
+ * as stream
102
98
  * @param parentItem
103
99
  */
104
- export function getFormInputsAsArr(parentItem: DomQuery): string[][] | [string, File][] {
105
- const standardInputs: any = resolveViewState(parentItem);
100
+ export function getFormInputsAsStream(parentItem: DomQuery): Stream<string[] | [string, File]> {
101
+ const standardInputs = resolveViewState(parentItem);
106
102
  const fileInputs = resolveFiles(parentItem);
107
- return standardInputs.concat(...fileInputs)
103
+ return standardInputs.concat(fileInputs as any)
108
104
  }
@@ -58,17 +58,13 @@ export class HiddenInputBuilder {
58
58
  const SEP = $faces().separatorchar;
59
59
 
60
60
  let existingStates = DQ$(`[name*='${$nsp(this.name)}']`);
61
- let cnt = existingStates.asArray.map(state => {
61
+ let cnt = existingStates.stream.map(state => {
62
62
  let ident: string = state.id.orElse("-1").value;
63
63
  ident = ident.substring(ident.lastIndexOf(SEP)+1);
64
64
  return parseInt(ident);
65
65
  })
66
- .filter(item => {
67
- return !isNaN(item);
68
- })
69
- .reduce((item1, item2) => {
70
- return Math.max(item1, item2);
71
- }, -1);
66
+ .filter(item => !isNaN(item))
67
+ .reduce((item1, item2) => Math.max(item1, item2), -1).value;
72
68
  //the maximum new ident is the current max + 1
73
69
  cnt++;
74
70
 
@@ -15,7 +15,7 @@
15
15
  *
16
16
  */
17
17
 
18
- import {Lang as LangBase, Config, Optional, DomQuery, DQ} from "mona-dish";
18
+ import {Lang as LangBase, Config, Optional, DomQuery, DQ, Stream} from "mona-dish";
19
19
  import {Messages} from "../i18n/Messages";
20
20
  import {EMPTY_STR, HTML_TAG_FORM} from "../core/Const";
21
21
  import {getEventTarget} from "../xhrCore/RequestDataResolver";
@@ -85,10 +85,10 @@ export module ExtLang {
85
85
  installedLocale = installedLocale ?? new Messages();
86
86
 
87
87
  let msg = installedLocale[key] ?? defaultMessage ?? key;
88
- templateParams.forEach((param, cnt) => {
89
- msg = msg.replace(new RegExp(["\\{", cnt, "\\}"].join(EMPTY_STR), "g"), param);
90
- })
91
88
 
89
+ Stream.of(...templateParams).each((param, cnt) => {
90
+ msg = msg.replace(new RegExp(["\\{", cnt, "\\}"].join(EMPTY_STR), "g"), param);
91
+ });
92
92
 
93
93
  return msg;
94
94
  }
@@ -202,61 +202,6 @@ export module ExtLang {
202
202
  defaultValue;
203
203
  }
204
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
-
260
205
  /**
261
206
  * assert that the form exists and throw an exception in the case it does not
262
207
  *
@@ -267,6 +212,4 @@ export module ExtLang {
267
212
  throw makeException(new Error(), null, null, "Impl", "getForm", getMessage("ERR_FORM"));
268
213
  }
269
214
  }
270
-
271
-
272
215
  }
@@ -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_REQ_PASS_THR, EVENT, P_AJAX_SOURCE, SOURCE} from "../core/Const";
17
+ import {BEGIN, CTX_PARAM_REQ_PASS_THR, EVENT, P_PARTIAL_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_AJAX_SOURCE).value)
36
- .orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_AJAX_SOURCE).value)
35
+ .orElseLazy(() => context.getIf(P_PARTIAL_SOURCE).value)
36
+ .orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value)
37
37
  .value;
38
38
  if (sourceId) {
39
39
  eventData.source = DQ.byId(sourceId, true).first().value.value;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config, DomQuery, DomQueryCollector, DQ, DQ$, Lang, XMLQuery} from "mona-dish";
17
+ import {Config, DomQuery, DomQueryCollector, DQ, DQ$, Lang, LazyStream, Stream, XMLQuery} from "mona-dish";
18
18
  import {Implementation} from "../AjaxImpl";
19
19
  import {Assertions} from "../util/Assertions";
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
@@ -46,7 +46,7 @@ import {
46
46
  ON_EVENT,
47
47
  P_CLIENT_WINDOW,
48
48
  P_EXECUTE,
49
- P_AJAX_SOURCE,
49
+ P_PARTIAL_SOURCE,
50
50
  P_RENDER,
51
51
  P_RENDER_OVERRIDE,
52
52
  P_VIEWSTATE,
@@ -65,8 +65,6 @@ import {
65
65
  import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
66
66
  import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
67
67
  import trim = Lang.trim;
68
- import {ExtLang} from "../util/Lang";
69
- import ofAssoc = ExtLang.ofAssoc;
70
68
 
71
69
 
72
70
  /**
@@ -176,7 +174,7 @@ export class ResponseProcessor implements IResponseProcessor {
176
174
  */
177
175
 
178
176
  const mergedErrorData = new ExtConfig({});
179
- mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_AJAX_SOURCE).get(0).value;
177
+ mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
180
178
  mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
181
179
  mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
182
180
 
@@ -348,15 +346,15 @@ export class ResponseProcessor implements IResponseProcessor {
348
346
  * as last lifecycle step, before going into the next request.
349
347
  */
350
348
  fixViewStates() {
351
- ofAssoc(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
352
- .forEach(([, value]) => {
349
+ Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
350
+ .each(([, value]) => {
353
351
  const namingContainerId = this.internalContext.getIf(NAMING_CONTAINER_ID);
354
352
  const namedViewRoot = !!this.internalContext.getIf(NAMED_VIEWROOT).value
355
353
  const affectedForms = this.getContainerForms(namingContainerId)
356
354
  .filter(affectedForm => this.isInExecuteOrRender(affectedForm));
357
355
 
358
356
  this.appendViewStateToForms(affectedForms, namedViewRoot, value.value, namingContainerId.orElse("").value);
359
- })
357
+ });
360
358
  }
361
359
 
362
360
 
@@ -366,8 +364,8 @@ export class ResponseProcessor implements IResponseProcessor {
366
364
  * is done.
367
365
  */
368
366
  fixClientWindow() {
369
- ofAssoc(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
370
- .forEach(([, value]) => {
367
+ Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
368
+ .each(([, value]) => {
371
369
  const namingContainerId = this.internalContext.getIf(NAMING_CONTAINER_ID);
372
370
  const namedViewRoot = !!this.internalContext.getIf(NAMED_VIEWROOT).value;
373
371
  const affectedForms = this.getContainerForms(namingContainerId)
@@ -524,7 +522,7 @@ export class ResponseProcessor implements IResponseProcessor {
524
522
  .orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
525
523
  .orElse(IDENT_NONE).value.split(/\s+/gi);
526
524
  const executeAndRenders = executes.concat(...renders);
527
- return [...executeAndRenders].filter(nameOrId => {
525
+ return LazyStream.of(...executeAndRenders).filter(nameOrId => {
528
526
  if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
529
527
  return true;
530
528
  }
@@ -534,7 +532,7 @@ export class ResponseProcessor implements IResponseProcessor {
534
532
  return affectedForm.matchesSelector(NAME_OR_ID) ||
535
533
  affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
536
534
  affectedForm.firstParent(NAME_OR_ID).isPresent();
537
- }).length > 0;
535
+ }).first().isPresent();
538
536
  }
539
537
 
540
538
  /**
@@ -13,20 +13,19 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import {Config, DQ} from "mona-dish";
16
+ import {Config, DQ, FormDataCollector, Stream} from "mona-dish";
17
17
  import {$nsp, EMPTY_STR, IDENT_NONE, P_VIEWSTATE} from "../core/Const";
18
18
 
19
19
  import {
20
20
  encodeFormData,
21
- fixEmptyParameters, getFormInputsAsArr
21
+ fixEmmptyParameters, getFormInputsAsStream
22
22
  } from "../util/FileUtils";
23
- import {ExtLang} from "../util/Lang";
24
- import ofAssoc = ExtLang.ofAssoc;
25
23
 
26
24
 
27
25
  type ParamsMapper<V, K> = (key: V, item: K) => [V, K];
28
26
  const defaultParamsMapper: ParamsMapper<string, any> = (key, item) => [key, item];
29
27
 
28
+
30
29
  /**
31
30
  * A unified form data class
32
31
  * which builds upon our configuration.
@@ -77,17 +76,13 @@ export class XhrFormData extends Config {
77
76
  */
78
77
  toFormData(): FormData {
79
78
  /*
80
- * expands key: [item1, item2]
81
- * to: [{key: key, value: item1}, {key: key, value: item2}]
82
- */
83
- let expandValueArrays = ([key, item]) => {
84
- if (Array.isArray(item)) {
85
- return item.map(value => {
86
- return {key, value}
87
- })
88
- }
89
- return [{key, value: item}]
90
- }
79
+ * expands key: [item1, item2]
80
+ * to: [{key: key, value: item1}, {key: key, value: item2}]
81
+ */
82
+ let expandAssocArray = ([key, item]) =>
83
+ Stream.of(...(item as Array<any>)).map(value => {
84
+ return {key, value};
85
+ });
91
86
 
92
87
  /*
93
88
  * remaps the incoming {key, value} tuples
@@ -101,13 +96,10 @@ export class XhrFormData extends Config {
101
96
  /*
102
97
  * collects everything into a FormData object
103
98
  */
104
- return ofAssoc(this.value)
105
- .flatMap(expandValueArrays)
99
+ return Stream.ofAssoc(this.value)
100
+ .flatMap(expandAssocArray)
106
101
  .map(remapForNamingContainer)
107
- .reduce((formData: FormData, {key, value}: any) => {
108
- formData.append(key, value);
109
- return formData;
110
- }, new FormData()) as FormData;
102
+ .collect(new FormDataCollector() as any);
111
103
  }
112
104
 
113
105
  /**
@@ -121,7 +113,6 @@ export class XhrFormData extends Config {
121
113
 
122
114
  /**
123
115
  * generic post init code, for now, this performs some post assign data post-processing
124
- * @param rootElement the root element which knows the request type (usually a form)
125
116
  * @param executes the executable dom nodes which need to be processed into the form data, which we can send
126
117
  * in our ajax request
127
118
  */
@@ -148,24 +139,20 @@ export class XhrFormData extends Config {
148
139
 
149
140
  /**
150
141
  * determines fields to submit
142
+ * @param {Object} targetBuf - the target form buffer receiving the data
151
143
  * @param {Node} parentItem - form element item is nested in
152
144
  * @param {Array} partialIds - ids fo PPS
153
145
  */
154
- private encodeSubmittableFields(parentItem: DQ, partialIds: string[] = []) {
146
+ private encodeSubmittableFields(parentItem: DQ, partialIds ?: string[]) {
155
147
 
148
+ const formInputs = getFormInputsAsStream(parentItem);
156
149
  const mergeIntoThis = ([key, value]) => this.append(key).value = value;
157
150
  const namingContainerRemap = ([key, value]) => this.paramsMapper(key as string, value);
158
151
 
159
- const remappedPartialIds = partialIds.map(partialId => this.remapKeyForNamingContainer(partialId));
160
- const partialIdsFilter = ([key, value]) => (!remappedPartialIds.length || key.indexOf("@") == 0) ? true :
161
- remappedPartialIds.indexOf(key) != -1;
162
-
163
- let inputs = getFormInputsAsArr(parentItem);
164
- inputs
165
- .map(fixEmptyParameters)
152
+ formInputs
153
+ .map(fixEmmptyParameters)
166
154
  .map(namingContainerRemap)
167
- .filter(partialIdsFilter)
168
- .forEach(mergeIntoThis);
155
+ .each(mergeIntoThis);
169
156
  }
170
157
 
171
158
  private remapKeyForNamingContainer(key: string): string {