jsf.js_next_gen 4.0.0-RC.1 → 4.0.0-RC.10

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 (93) hide show
  1. package/dist/docs/assets/main.js +1 -1
  2. package/dist/docs/functions/faces.push.init.html +5 -1
  3. package/dist/docs/functions/myfaces.ab.html +2 -2
  4. package/dist/window/faces-development.js +365 -136
  5. package/dist/window/faces-development.js.br +0 -0
  6. package/dist/window/faces-development.js.gz +0 -0
  7. package/dist/window/faces-development.js.map +1 -1
  8. package/dist/window/faces.js +1 -1
  9. package/dist/window/faces.js.br +0 -0
  10. package/dist/window/faces.js.gz +0 -0
  11. package/dist/window/faces.js.map +1 -1
  12. package/dist/window/jsf-development.js +376 -136
  13. package/dist/window/jsf-development.js.br +0 -0
  14. package/dist/window/jsf-development.js.gz +0 -0
  15. package/dist/window/jsf-development.js.map +1 -1
  16. package/dist/window/jsf.js +1 -1
  17. package/dist/window/jsf.js.br +0 -0
  18. package/dist/window/jsf.js.gz +0 -0
  19. package/dist/window/jsf.js.map +1 -1
  20. package/package.json +11 -11
  21. package/src/main/typescript/@types/definitions/index.d.ts +17 -2
  22. package/src/main/typescript/api/_api.ts +4 -2
  23. package/src/main/typescript/api/jsf.ts +18 -0
  24. package/src/main/typescript/impl/AjaxImpl.ts +22 -2
  25. package/src/main/typescript/impl/PushImpl.ts +38 -12
  26. package/src/main/typescript/impl/core/Const.ts +9 -5
  27. package/src/main/typescript/impl/util/Assertions.ts +14 -6
  28. package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
  29. package/src/main/typescript/impl/util/ExtDomQuery.ts +4 -1
  30. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -1
  31. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +13 -3
  32. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +91 -29
  33. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +24 -12
  34. package/src/main/typescript/myfaces/OamSubmit.ts +15 -10
  35. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  36. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  37. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +237 -8
  38. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +174 -10
  39. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +8 -6
  40. package/src/main/typescript/test.xml +6 -0
  41. package/target/api/_api.js +3 -2
  42. package/target/api/_api.js.map +1 -1
  43. package/target/api/jsf.js +11 -0
  44. package/target/api/jsf.js.map +1 -1
  45. package/target/impl/AjaxImpl.js +18 -0
  46. package/target/impl/AjaxImpl.js.map +1 -1
  47. package/target/impl/PushImpl.js +44 -14
  48. package/target/impl/PushImpl.js.map +1 -1
  49. package/target/impl/core/Const.js +10 -8
  50. package/target/impl/core/Const.js.map +1 -1
  51. package/target/impl/util/Assertions.js +11 -6
  52. package/target/impl/util/Assertions.js.map +1 -1
  53. package/target/impl/util/AsyncQueue.js.map +1 -1
  54. package/target/impl/util/ExtDomQuery.js +3 -0
  55. package/target/impl/util/ExtDomQuery.js.map +1 -1
  56. package/target/impl/xhrCore/RequestDataResolver.js +11 -2
  57. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  58. package/target/impl/xhrCore/ResponseProcessor.js +84 -23
  59. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  60. package/target/impl/xhrCore/XhrFormData.js +18 -7
  61. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  62. package/target/myfaces/OamSubmit.js +13 -11
  63. package/target/myfaces/OamSubmit.js.map +1 -1
  64. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  65. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  66. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  67. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  68. package/target/test/xhrCore/RequestTest.spec.js +214 -7
  69. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  70. package/target/test/xhrCore/ResponseTest.spec.js +139 -8
  71. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  72. package/target/test/xhrCore/ResponseTest23.spec.js +5 -5
  73. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  74. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  75. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  76. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  77. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  78. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
  79. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
  80. package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
  81. package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
  82. package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
  83. package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
  84. package/target/test-classes/.gz +0 -0
  85. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  86. package/target/test-classes/fileuploadtest.html +0 -24
  87. package/target/test-classes/jsf-development.js +0 -3559
  88. package/target/test-classes/jsf-development.js.br +0 -0
  89. package/target/test-classes/jsf-development.js.gz +0 -0
  90. package/target/test-classes/jsf-development.js.map +0 -1
  91. package/target/test-classes/jsf.js +0 -3
  92. package/target/test-classes/jsf.js.br +0 -0
  93. package/target/test-classes/jsf.js.gz +0 -0
@@ -42,7 +42,7 @@ const SourcesCollectors_1 = __webpack_require__(/*! ./SourcesCollectors */ "./no
42
42
  const Lang_1 = __webpack_require__(/*! ./Lang */ "./node_modules/mona-dish/src/main/typescript/Lang.ts");
43
43
  var trim = Lang_1.Lang.trim;
44
44
  var isString = Lang_1.Lang.isString;
45
- var eIgnoreC = Lang_1.Lang.equalsIgnoreCase;
45
+ var eqi = Lang_1.Lang.equalsIgnoreCase;
46
46
  const Global_1 = __webpack_require__(/*! ./Global */ "./node_modules/mona-dish/src/main/typescript/Global.ts");
47
47
  var objToArray = Lang_1.Lang.objToArray;
48
48
  /**
@@ -632,6 +632,15 @@ class DomQuery {
632
632
  return this._querySelectorAll(selector);
633
633
  }
634
634
  }
635
+ closest(selector) {
636
+ // We could merge both methods, but for now this is more readable
637
+ if (selector.indexOf("/shadow/") != -1) {
638
+ return this._closestDeep(selector);
639
+ }
640
+ else {
641
+ return this._closest(selector);
642
+ }
643
+ }
635
644
  /**
636
645
  * core byId method
637
646
  * @param id the id to search for
@@ -866,6 +875,30 @@ class DomQuery {
866
875
  });
867
876
  return this;
868
877
  }
878
+ /**
879
+ * replace convenience function, replaces one or more elements with
880
+ * a set of elements passed as DomQuery
881
+ * @param toReplace the replaced nodes as reference (original node has been replaced)
882
+ */
883
+ replace(toReplace) {
884
+ this.each(item => {
885
+ let asElem = item.getAsElem(0).value;
886
+ let parent = asElem.parentElement;
887
+ let nextElement = asElem.nextElementSibling;
888
+ let previousElement = asElem.previousElementSibling;
889
+ if (nextElement != null) {
890
+ new DomQuery(nextElement).insertBefore(toReplace);
891
+ }
892
+ else if (previousElement) {
893
+ new DomQuery(previousElement).insertAfter(toReplace);
894
+ }
895
+ else {
896
+ new DomQuery(parent).append(toReplace);
897
+ }
898
+ item.delete();
899
+ });
900
+ return toReplace;
901
+ }
869
902
  /**
870
903
  * returns a new dom query containing only the first element max
871
904
  *
@@ -1049,28 +1082,24 @@ class DomQuery {
1049
1082
  return new DomQuery(func());
1050
1083
  }
1051
1084
  }
1052
- parents(tagName) {
1053
- const retSet = new Set();
1085
+ parents(selector) {
1054
1086
  const retArr = [];
1055
- const lowerTagName = tagName.toLowerCase();
1056
- let resolveItem = (item) => {
1057
- if ((item.tagName || "").toLowerCase() == lowerTagName && !retSet.has(item)) {
1058
- retSet.add(item);
1059
- retArr.push(item);
1060
- }
1061
- };
1087
+ let parent = this.parent().filter(item => item.matchesSelector(selector));
1088
+ while (parent.isPresent()) {
1089
+ retArr.push(parent);
1090
+ parent = parent.parent().filter(item => item.matchesSelector(selector));
1091
+ }
1092
+ return new DomQuery(...retArr);
1093
+ }
1094
+ parent() {
1095
+ let ret = [];
1062
1096
  this.eachElem((item) => {
1063
- var _a;
1064
- while (item.parentNode || item.host) {
1065
- item = (_a = item === null || item === void 0 ? void 0 : item.parentNode) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.host;
1066
- resolveItem(item);
1067
- // nested forms not possible, performance shortcut
1068
- if (tagName == "form" && retArr.length) {
1069
- return false;
1070
- }
1097
+ let parent = item.parentNode || item.host;
1098
+ if (parent && ret.indexOf(parent) == -1) {
1099
+ ret.push(parent);
1071
1100
  }
1072
1101
  });
1073
- return new DomQuery(...retArr);
1102
+ return new DomQuery(...ret);
1074
1103
  }
1075
1104
  copyAttrs(sourceItem) {
1076
1105
  sourceItem.eachElem((sourceNode) => {
@@ -1184,7 +1213,7 @@ class DomQuery {
1184
1213
  let tagName = item.tagName;
1185
1214
  let itemType = ((_a = item === null || item === void 0 ? void 0 : item.type) !== null && _a !== void 0 ? _a : '').toLowerCase();
1186
1215
  if (tagName &&
1187
- eIgnoreC(tagName, "script") &&
1216
+ eqi(tagName, "script") &&
1188
1217
  allowedItemTypes.indexOf(itemType) != -1) {
1189
1218
  let src = item.getAttribute('src');
1190
1219
  if ('undefined' != typeof src
@@ -1270,36 +1299,30 @@ class DomQuery {
1270
1299
  return this;
1271
1300
  }
1272
1301
  runCss() {
1273
- const applyStyle = (item, style) => {
1274
- var _a, _b, _c, _d;
1275
- let newSS = document.createElement("style");
1276
- document.getElementsByTagName("head")[0].appendChild(newSS);
1277
- let styleSheet = (_a = newSS.sheet) !== null && _a !== void 0 ? _a : newSS.styleSheet;
1278
- newSS.setAttribute("rel", (_b = item.getAttribute("rel")) !== null && _b !== void 0 ? _b : "stylesheet");
1279
- newSS.setAttribute("type", (_c = item.getAttribute("type")) !== null && _c !== void 0 ? _c : "text/css");
1280
- if ((_d = styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssText) !== null && _d !== void 0 ? _d : false) {
1281
- styleSheet.cssText = style;
1282
- }
1283
- else {
1284
- newSS.appendChild(document.createTextNode(style));
1285
- }
1286
- }, execCss = (item) => {
1287
- const tagName = item.tagName;
1288
- if (tagName && eIgnoreC(tagName, "link") && eIgnoreC(item.getAttribute("type"), "text/css")) {
1289
- applyStyle(item, "@import url('" + item.getAttribute("href") + "');");
1290
- }
1291
- else if (tagName && eIgnoreC(tagName, "style") && eIgnoreC(item.getAttribute("type"), "text/css")) {
1292
- let innerText = [];
1293
- // compliant browsers know child nodes
1294
- let childNodes = Array.prototype.slice.call(item.childNodes);
1295
- if (childNodes) {
1296
- childNodes.forEach(child => innerText.push(child.innerHTML || child.data));
1297
- // non-compliant elements innerHTML
1302
+ const execCss = (toReplace) => {
1303
+ const _toReplace = DomQuery.byId(toReplace);
1304
+ const tagName = _toReplace.tagName.orElse("").value;
1305
+ const head = DomQuery.byTagName("head");
1306
+ if (tagName && eqi(tagName, "link") && eqi(toReplace.getAttribute("rel"), "stylesheet")) {
1307
+ const rel = toReplace.getAttribute("rel");
1308
+ //if possible we are now replacing the existing elements where we reference this stylesheet
1309
+ const matches = head.querySelectorAll(`link[rel='stylesheet'][href='${rel}']`);
1310
+ if (matches.length) {
1311
+ matches.replace(_toReplace);
1298
1312
  }
1299
- else if (item.innerHTML) {
1300
- innerText.push(item.innerHTML);
1313
+ else {
1314
+ head.append(_toReplace);
1315
+ }
1316
+ }
1317
+ else if (tagName && eqi(tagName, "style")) {
1318
+ let innerText = _toReplace.innerHTML.replace(/\s+/gi, "");
1319
+ let styles = head.querySelectorAll("style");
1320
+ styles = styles.stream.filter(style => {
1321
+ return style.innerHTML.replace(/\s+/gi, "") == innerText;
1322
+ }).collect(new DomQueryCollector());
1323
+ if (!styles.length) { //already present
1324
+ head.append(_toReplace);
1301
1325
  }
1302
- applyStyle(item, innerText.join(""));
1303
1326
  }
1304
1327
  };
1305
1328
  const scriptElements = new DomQuery(this.filterSelector("link, style"), this.querySelectorAll("link, style"));
@@ -1480,12 +1503,17 @@ class DomQuery {
1480
1503
  elemType != ALLOWED_SUBMITTABLE_ELEMENTS.SUBMIT &&
1481
1504
  elemType != ALLOWED_SUBMITTABLE_ELEMENTS.IMAGE) && ((elemType != ALLOWED_SUBMITTABLE_ELEMENTS.CHECKBOX && elemType != ALLOWED_SUBMITTABLE_ELEMENTS.RADIO) ||
1482
1505
  element.checked)) {
1483
- let files = (_b = (_a = element.value.value) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : [];
1484
- if (files === null || files === void 0 ? void 0 : files.length) {
1485
- // xhr level2
1486
- target.append(name).value = files[0];
1506
+ let uploadedFiles = (_b = (_a = element.value) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.files;
1507
+ let filesArr = uploadedFiles !== null && uploadedFiles !== void 0 ? uploadedFiles : [];
1508
+ if (filesArr === null || filesArr === void 0 ? void 0 : filesArr.length) { //files can be empty but set
1509
+ // xhr level2, single multiple must be passes as they are
1510
+ target.assign(name).value = Array.from(filesArr);
1487
1511
  }
1488
1512
  else {
1513
+ if (!!uploadedFiles) { //we skip empty file elements i
1514
+ return;
1515
+ }
1516
+ //checkboxes etc.. need to be appended
1489
1517
  target.append(name).value = element.inputValue.value;
1490
1518
  }
1491
1519
  }
@@ -1730,6 +1758,47 @@ class DomQuery {
1730
1758
  }
1731
1759
  return foundNodes;
1732
1760
  }
1761
+ /**
1762
+ * query selector all on the existing dom queryX object
1763
+ *
1764
+ * @param selector the standard selector
1765
+ * @return a DomQuery with the results
1766
+ */
1767
+ _closest(selector) {
1768
+ var _a, _b;
1769
+ if (!((_a = this === null || this === void 0 ? void 0 : this.rootNode) === null || _a === void 0 ? void 0 : _a.length)) {
1770
+ return this;
1771
+ }
1772
+ let nodes = [];
1773
+ for (let cnt = 0; cnt < this.rootNode.length; cnt++) {
1774
+ if (!((_b = this.rootNode[cnt]) === null || _b === void 0 ? void 0 : _b.closest)) {
1775
+ continue;
1776
+ }
1777
+ let res = [this.rootNode[cnt].closest(selector)];
1778
+ nodes = nodes.concat(...res);
1779
+ }
1780
+ return new DomQuery(...nodes);
1781
+ }
1782
+ /*deep with a selector and a pseudo /shadow/ marker to break into the next level*/
1783
+ _closestDeep(selector) {
1784
+ var _a;
1785
+ if (!((_a = this === null || this === void 0 ? void 0 : this.rootNode) === null || _a === void 0 ? void 0 : _a.length)) {
1786
+ return this;
1787
+ }
1788
+ let foundNodes = new DomQuery(...this.rootNode);
1789
+ let selectors = selector.split(/\/shadow\//);
1790
+ for (let cnt2 = 0; cnt2 < selectors.length; cnt2++) {
1791
+ if (selectors[cnt2] == "") {
1792
+ continue;
1793
+ }
1794
+ let levelSelector = selectors[cnt2];
1795
+ foundNodes = foundNodes.closest(levelSelector);
1796
+ if (cnt2 < selectors.length - 1) {
1797
+ foundNodes = foundNodes.shadowRoot;
1798
+ }
1799
+ }
1800
+ return foundNodes;
1801
+ }
1733
1802
  // source: https:// developer.mozilla.org/en-US/docs/Web/API/Element/matches
1734
1803
  // code snippet license: https:// creativecommons.org/licenses/by-sa/2.5/
1735
1804
  /**
@@ -2510,6 +2579,9 @@ class Config extends Optional {
2510
2579
  */
2511
2580
  shallowMerge(other, overwrite = true, withAppend = false) {
2512
2581
  for (let key in other.value) {
2582
+ if ('undefined' == typeof key || null == key) {
2583
+ continue;
2584
+ }
2513
2585
  if (overwrite || !(key in this.value)) {
2514
2586
  if (!withAppend) {
2515
2587
  this.assign(key).value = other.getIf(key).value;
@@ -2711,7 +2783,7 @@ exports.Config = Config;
2711
2783
  * limitations under the License.
2712
2784
  */
2713
2785
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2714
- exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.ITERATION_STATUS = void 0;
2786
+ exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.InverseArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.ITERATION_STATUS = void 0;
2715
2787
  const Stream_1 = __webpack_require__(/*! ./Stream */ "./node_modules/mona-dish/src/main/typescript/Stream.ts");
2716
2788
  /**
2717
2789
  * special status of the datasource location pointer
@@ -3018,6 +3090,21 @@ class ArrayCollector {
3018
3090
  }
3019
3091
  }
3020
3092
  exports.ArrayCollector = ArrayCollector;
3093
+ /**
3094
+ * collects the values as inverse array
3095
+ */
3096
+ class InverseArrayCollector {
3097
+ constructor() {
3098
+ this.data = [];
3099
+ }
3100
+ collect(element) {
3101
+ this.data.unshift(element);
3102
+ }
3103
+ get finalValue() {
3104
+ return this.data;
3105
+ }
3106
+ }
3107
+ exports.InverseArrayCollector = InverseArrayCollector;
3021
3108
  /**
3022
3109
  * collects an tuple array stream into an assoc array with elements being collected into arrays
3023
3110
  *
@@ -3353,6 +3440,15 @@ exports.Stream = Stream;
3353
3440
  *
3354
3441
  */
3355
3442
  class LazyStream {
3443
+ static of(...values) {
3444
+ return new LazyStream(new SourcesCollectors_1.ArrayStreamDataSource(...values));
3445
+ }
3446
+ static ofAssoc(data) {
3447
+ return this.of(...Object.keys(data)).map(key => [key, data[key]]);
3448
+ }
3449
+ static ofStreamDataSource(value) {
3450
+ return new LazyStream(value);
3451
+ }
3356
3452
  constructor(parent) {
3357
3453
  this._limits = -1;
3358
3454
  /*
@@ -3363,15 +3459,6 @@ class LazyStream {
3363
3459
  this.pos = -1;
3364
3460
  this.dataSource = parent;
3365
3461
  }
3366
- static of(...values) {
3367
- return new LazyStream(new SourcesCollectors_1.ArrayStreamDataSource(...values));
3368
- }
3369
- static ofAssoc(data) {
3370
- return this.of(...Object.keys(data)).map(key => [key, data[key]]);
3371
- }
3372
- static ofStreamDataSource(value) {
3373
- return new LazyStream(value);
3374
- }
3375
3462
  hasNext() {
3376
3463
  if (this.isOverLimits()) {
3377
3464
  return false;
@@ -3907,12 +3994,13 @@ var faces;
3907
3994
  * @param channel the channel name/id
3908
3995
  * @param onopen The function to be invoked when the web socket is opened.
3909
3996
  * @param onmessage The function to be invoked when a message is received.
3997
+ * @param onerror The function to be invoked when an error occurs.
3910
3998
  * @param onclose The function to be invoked when the web socket is closed.
3911
3999
  * @param behaviors functions which are invoked whenever a message is received
3912
4000
  * @param autoConnect Whether or not to automatically open the socket. Defaults to <code>false</code>.
3913
4001
  */
3914
- function init(socketClientId, url, channel, onopen, onmessage, onclose, behaviors, autoConnect) {
3915
- PushImpl_1.PushImpl.init(socketClientId, url, channel, onopen, onmessage, onclose, behaviors, autoConnect);
4002
+ function init(socketClientId, url, channel, onopen, onmessage, onerror, onclose, behaviors, autoConnect) {
4003
+ PushImpl_1.PushImpl.init(socketClientId, url, channel, onopen, onmessage, onerror, onclose, behaviors, autoConnect);
3916
4004
  }
3917
4005
  push.init = init;
3918
4006
  /**
@@ -4030,7 +4118,9 @@ var BlockFilter;
4030
4118
  BlockFilter["myfaces"] = "myfaces";
4031
4119
  BlockFilter["delay"] = "delay";
4032
4120
  BlockFilter["timeout"] = "timeout";
4121
+ BlockFilter["resetValues"] = "resetValues";
4033
4122
  BlockFilter["windowId"] = "windowId";
4123
+ BlockFilter["params"] = "params";
4034
4124
  })(BlockFilter || (BlockFilter = {}));
4035
4125
  /**
4036
4126
  * Core Implementation
@@ -4196,7 +4286,11 @@ var Implementation;
4196
4286
  const delay = (0, RequestDataResolver_1.resolveDelay)(options);
4197
4287
  const timeout = (0, RequestDataResolver_1.resolveTimeout)(options);
4198
4288
  requestCtx.assignIf(!!windowId, Const_1.P_WINDOW_ID).value = windowId;
4289
+ // old non spec behavior will be removed after it is clear whether the removal breaks any code
4199
4290
  requestCtx.assign(Const_1.CTX_PARAM_PASS_THR).value = filterPassThroughValues(options.value);
4291
+ // spec conform behavior, all passthrough params must be under "passthrough
4292
+ const params = remapArrayToAssocArr(options.getIf(Const_1.CTX_PARAM_SPEC_PARAMS).orElse({}).value);
4293
+ requestCtx.getIf(Const_1.CTX_PARAM_PASS_THR).shallowMerge(new mona_dish_1.Config(params), true);
4200
4294
  requestCtx.assignIf(!!resolvedEvent, Const_1.CTX_PARAM_PASS_THR, Const_1.P_EVT).value = resolvedEvent === null || resolvedEvent === void 0 ? void 0 : resolvedEvent.type;
4201
4295
  /**
4202
4296
  * ajax pass through context with the source
@@ -4552,7 +4646,13 @@ var Implementation;
4552
4646
  * Filter the options given with a blacklist, so that only
4553
4647
  * the values required for pass-through are processed in the ajax request
4554
4648
  *
4649
+ * Note this is a bug carried over from the old implementation
4650
+ * the spec conform behavior is to use params for passthrough values
4651
+ * this will be removed soon, after it is cleared up wheter removing
4652
+ * it breaks any legacy code
4653
+ *
4555
4654
  * @param {Context} mappedOpts the options to be filtered
4655
+ * @deprecated
4556
4656
  */
4557
4657
  function filterPassThroughValues(mappedOpts) {
4558
4658
  //we now can use the full code reduction given by our stream api
@@ -4561,6 +4661,12 @@ var Implementation;
4561
4661
  .filter(item => !(item[0] in BlockFilter))
4562
4662
  .collect(new mona_dish_1.AssocArrayCollector());
4563
4663
  }
4664
+ function remapArrayToAssocArr(arrayedParams) {
4665
+ if (Array.isArray(arrayedParams)) {
4666
+ return mona_dish_1.Stream.of(...arrayedParams).collect(new mona_dish_1.AssocArrayCollector());
4667
+ }
4668
+ return arrayedParams;
4669
+ }
4564
4670
  function resolveGlobalConfig() {
4565
4671
  var _a, _b;
4566
4672
  return (_b = (_a = window === null || window === void 0 ? void 0 : window[Const_1.MYFACES]) === null || _a === void 0 ? void 0 : _a.config) !== null && _b !== void 0 ? _b : {};
@@ -4622,12 +4728,13 @@ exports.PushImpl = void 0;
4622
4728
  * Typescript port of the faces\.push part in the myfaces implementation
4623
4729
  */
4624
4730
  const Const_1 = __webpack_require__(/*! ./core/Const */ "./src/main/typescript/impl/core/Const.ts");
4731
+ const mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
4625
4732
  /**
4626
4733
  * Implementation class for the push functionality
4627
4734
  */
4628
4735
  var PushImpl;
4629
4736
  (function (PushImpl) {
4630
- const URL_PROTOCOL = window.location.protocol.replace("http", "ws") + "//";
4737
+ const URL_PROTOCOL = mona_dish_1.DQ.global().location.protocol.replace("http", "ws") + "//";
4631
4738
  // we expose the member variables for testing purposes
4632
4739
  // they are not directly touched outside of tests
4633
4740
  /* socket map by token */
@@ -4652,14 +4759,15 @@ var PushImpl;
4652
4759
  * @param channel the channel name/id
4653
4760
  * @param onopen The function to be invoked when the web socket is opened.
4654
4761
  * @param onmessage The function to be invoked when a message is received.
4762
+ * @param onerror The function to be invoked when an error occurs.
4655
4763
  * @param onclose The function to be invoked when the web socket is closed.
4656
4764
  * @param behaviors functions which are invoked whenever a message is received
4657
4765
  * @param autoConnect Whether or not to automatically open the socket. Defaults to <code>false</code>.
4658
4766
  */
4659
- function init(socketClientId, url, channel, onopen, onmessage, onclose, behaviors, autoConnect) {
4660
- var _a;
4767
+ function init(socketClientId, url, channel, onopen, onmessage, onerror, onclose, behaviors, autoConnect) {
4768
+ var _a, _b, _c;
4661
4769
  onclose = resolveFunction(onclose);
4662
- if (!window.WebSocket) { // IE6-9.
4770
+ if (!mona_dish_1.DQ.global().WebSocket) { // IE6-9.
4663
4771
  onclose(-1, channel);
4664
4772
  return;
4665
4773
  }
@@ -4669,6 +4777,7 @@ var PushImpl;
4669
4777
  'channelToken': channelToken,
4670
4778
  'onopen': resolveFunction(onopen),
4671
4779
  'onmessage': resolveFunction(onmessage),
4780
+ 'onerror': resolveFunction(onerror),
4672
4781
  'onclose': onclose,
4673
4782
  'behaviors': behaviors,
4674
4783
  'autoconnect': autoConnect
@@ -4682,17 +4791,17 @@ var PushImpl;
4682
4791
  }
4683
4792
  }
4684
4793
  if (autoConnect) {
4685
- ((_a = window === null || window === void 0 ? void 0 : window.faces) !== null && _a !== void 0 ? _a : window === null || window === void 0 ? void 0 : window.jsf).push.open(socketClientId);
4794
+ ((_b = (_a = mona_dish_1.DQ.global()) === null || _a === void 0 ? void 0 : _a.faces) !== null && _b !== void 0 ? _b : (_c = mona_dish_1.DQ.global()) === null || _c === void 0 ? void 0 : _c.jsf).push.open(socketClientId);
4686
4795
  }
4687
4796
  }
4688
4797
  PushImpl.init = init;
4689
4798
  function open(socketClientId) {
4690
4799
  var _a;
4691
- getSocket((_a = PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a.channelToken).open();
4800
+ getSocket((_a = PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a.channelToken).open();
4692
4801
  }
4693
4802
  PushImpl.open = open;
4694
4803
  function close(socketClientId) {
4695
- getSocket(PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId].channelToken).close();
4804
+ getSocket(PushImpl.components[socketClientId].channelToken).close();
4696
4805
  }
4697
4806
  PushImpl.close = close;
4698
4807
  // Private helper classes
@@ -4722,28 +4831,53 @@ var PushImpl;
4722
4831
  }
4723
4832
  // noinspection JSUnusedLocalSymbols
4724
4833
  onopen(event) {
4834
+ var _a, _b;
4725
4835
  if (!this.reconnectAttempts) {
4726
4836
  let clientIds = PushImpl.clientIdsByTokens[this.channelToken];
4727
4837
  for (let i = clientIds.length - 1; i >= 0; i--) {
4728
4838
  let socketClientId = clientIds[i];
4729
- PushImpl.components[socketClientId]['onopen'](this.channel);
4839
+ (_b = (_a = PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a['onopen']) === null || _b === void 0 ? void 0 : _b.call(_a, this.channel);
4730
4840
  }
4731
4841
  }
4732
4842
  this.reconnectAttempts = 0;
4733
4843
  }
4844
+ onerror(event) {
4845
+ var _a, _b;
4846
+ let message = JSON.parse(event.data);
4847
+ //TODO replace this with a more readable Stream code
4848
+ for (let i = PushImpl.clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
4849
+ let socketClientId = PushImpl.clientIdsByTokens[this.channelToken][i];
4850
+ if (document.getElementById(socketClientId)) {
4851
+ try {
4852
+ (_b = (_a = PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a['onerror']) === null || _b === void 0 ? void 0 : _b.call(_a, message, this.channel, event);
4853
+ }
4854
+ catch (e) {
4855
+ //Ignore
4856
+ }
4857
+ }
4858
+ else {
4859
+ PushImpl.clientIdsByTokens[this.channelToken].splice(i, 1);
4860
+ }
4861
+ }
4862
+ if (PushImpl.clientIdsByTokens[this.channelToken].length == 0) {
4863
+ // tag disappeared
4864
+ this.close();
4865
+ }
4866
+ }
4734
4867
  onmmessage(event) {
4868
+ var _a, _b, _c;
4735
4869
  let message = JSON.parse(event.data);
4736
4870
  for (let i = PushImpl.clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
4737
4871
  let socketClientId = PushImpl.clientIdsByTokens[this.channelToken][i];
4738
4872
  if (document.getElementById(socketClientId)) {
4739
4873
  try {
4740
- PushImpl.components[socketClientId]['onmessage'](message, this.channel, event);
4874
+ (_b = (_a = PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a['onmessage']) === null || _b === void 0 ? void 0 : _b.call(_a, message, this.channel, event);
4741
4875
  }
4742
4876
  catch (e) {
4743
4877
  //Ignore
4744
4878
  }
4745
- let behaviors = PushImpl.components[socketClientId]['behaviors'];
4746
- let functions = behaviors[message];
4879
+ let behaviors = (_c = PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId]) === null || _c === void 0 ? void 0 : _c['behaviors'];
4880
+ let functions = behaviors === null || behaviors === void 0 ? void 0 : behaviors[message];
4747
4881
  if (functions && functions.length) {
4748
4882
  for (let j = 0; j < functions.length; j++) {
4749
4883
  try {
@@ -4765,6 +4899,7 @@ var PushImpl;
4765
4899
  }
4766
4900
  }
4767
4901
  onclose(event) {
4902
+ var _a, _b;
4768
4903
  if (!this.socket
4769
4904
  || (event.code == 1000 && event.reason == Const_1.REASON_EXPIRED)
4770
4905
  || (event.code == 1008)
@@ -4773,7 +4908,7 @@ var PushImpl;
4773
4908
  let clientIds = PushImpl.clientIdsByTokens[this.channelToken];
4774
4909
  for (let i = clientIds.length - 1; i >= 0; i--) {
4775
4910
  let socketClientId = clientIds[i];
4776
- PushImpl.components[socketClientId]['onclose'](event === null || event === void 0 ? void 0 : event.code, this === null || this === void 0 ? void 0 : this.channel, event);
4911
+ (_b = (_a = PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a['onclose']) === null || _b === void 0 ? void 0 : _b.call(_a, event === null || event === void 0 ? void 0 : event.code, this === null || this === void 0 ? void 0 : this.channel, event);
4777
4912
  }
4778
4913
  }
4779
4914
  else {
@@ -4795,12 +4930,13 @@ var PushImpl;
4795
4930
  this.socket.onopen = (event) => this.onopen(event);
4796
4931
  this.socket.onmessage = (event) => this.onmmessage(event);
4797
4932
  this.socket.onclose = (event) => this.onclose(event);
4933
+ this.socket.onerror = (event) => this.onerror(event);
4798
4934
  }
4799
4935
  }
4800
4936
  // Private static functions ---------------------------------------------------------------------------------------
4801
4937
  function getBaseURL(url) {
4802
4938
  if (url.indexOf("://") < 0) {
4803
- let base = window.location.hostname + ":" + window.location.port;
4939
+ let base = mona_dish_1.DQ.global().location.hostname + ":" + mona_dish_1.DQ.global().location.port;
4804
4940
  return URL_PROTOCOL + base + url;
4805
4941
  }
4806
4942
  else {
@@ -4825,7 +4961,7 @@ var PushImpl;
4825
4961
  }
4826
4962
  function resolveFunction(fn = () => {
4827
4963
  }) {
4828
- return ((typeof fn !== "function") && (fn = window[fn]), fn);
4964
+ return ((typeof fn !== "function") && (fn = mona_dish_1.DQ.global()[fn]), fn);
4829
4965
  }
4830
4966
  })(PushImpl = exports.PushImpl || (exports.PushImpl = {}));
4831
4967
 
@@ -4855,15 +4991,16 @@ var PushImpl;
4855
4991
  * limitations under the License.
4856
4992
  */
4857
4993
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4858
- exports.CTX_PARAM_DELAY = exports.CTX_PARAM_PASS_THR = exports.CTX_PARAM_TR_TYPE = exports.CTX_PARAM_SRC_CTL_ID = exports.CTX_PARAM_SRC_FRM_ID = exports.CTX_PARAM_MF_INTERNAL = exports.TIMEOUT_EVENT = exports.CLIENT_ERROR = exports.SERVER_ERROR = exports.MALFORMEDXML = exports.EMPTY_RESPONSE = exports.HTTPERROR = exports.RESPONSE_XML = exports.RESPONSE_TEXT = exports.ERROR_MESSAGE = exports.ERROR_NAME = exports.STATUS = exports.SOURCE = exports.SUCCESS = exports.COMPLETE = exports.BEGIN = exports.ON_EVENT = exports.ON_ERROR = exports.EVENT = exports.ERROR = exports.WINDOW_ID = exports.CTX_PARAM_RENDER = exports.P_BEHAVIOR_EVENT = exports.P_WINDOW_ID = exports.P_RESET_VALUES = exports.P_CLIENT_WINDOW = exports.P_EVT = exports.P_RENDER = exports.P_EXECUTE = exports.P_AJAX = exports.IDENT_FORM = exports.IDENT_THIS = exports.IDENT_NONE = exports.IDENT_ALL = exports.HTML_VIEWSTATE = exports.EMPTY_MAP = exports.EMPTY_STR = exports.EMPTY_FUNC = exports.P_RESOURCE = exports.P_VIEWBODY = exports.P_VIEWHEAD = exports.P_VIEWROOT = exports.P_VIEWSTATE = exports.PARTIAL_ID = exports.P_PARTIAL_SOURCE = void 0;
4859
- exports.REASON_EXPIRED = exports.MF_NONE = exports.SEL_SCRIPTS_STYLES = exports.MYFACES = exports.DEFERRED_HEAD_INSERTS = exports.UPDATE_ELEMS = exports.UPDATE_FORMS = exports.CMD_REDIRECT = exports.CMD_EXTENSION = exports.CMD_ATTRIBUTES = exports.CMD_ERROR = exports.CMD_EVAL = exports.CMD_INSERT = exports.CMD_DELETE = exports.CMD_UPDATE = exports.CMD_CHANGES = exports.RESP_PARTIAL = exports.ATTR_ID = exports.ATTR_VALUE = exports.ATTR_NAME = exports.ATTR_URL = exports.ERR_NO_PARTIAL_RESPONSE = exports.PHASE_PROCESS_RESPONSE = exports.SEL_RESPONSE_XML = exports.SEL_CLIENT_WINDOW_ELEM = exports.SEL_VIEWSTATE_ELEM = exports.TAG_ATTR = exports.TAG_AFTER = exports.TAG_BEFORE = exports.TAG_BODY = exports.TAG_FORM = exports.TAG_HEAD = exports.STD_ACCEPT = exports.NO_TIMEOUT = exports.MULTIPART = exports.URL_ENCODED = exports.STATE_EVT_COMPLETE = exports.STATE_EVT_TIMEOUT = exports.STATE_EVT_BEGIN = exports.REQ_TYPE_POST = exports.REQ_TYPE_GET = exports.ENCODED_URL = exports.VAL_AJAX = exports.REQ_ACCEPT = exports.HEAD_FACES_REQ = exports.CONTENT_TYPE = exports.STAGE_DEVELOPMENT = exports.CTX_PARAM_EXECUTE = exports.CTX_PARAM_RST = exports.CTX_PARAM_TIMEOUT = void 0;
4860
- exports.$nsp = exports.UNKNOWN = exports.MAX_RECONNECT_ATTEMPTS = exports.RECONNECT_INTERVAL = exports.APPLIED_CLIENT_WINDOW = exports.APPLIED_VST = void 0;
4994
+ exports.CTX_PARAM_PASS_THR = exports.CTX_PARAM_TR_TYPE = exports.CTX_PARAM_SRC_CTL_ID = exports.CTX_PARAM_SRC_FRM_ID = exports.CTX_PARAM_MF_INTERNAL = exports.TIMEOUT_EVENT = exports.CLIENT_ERROR = exports.SERVER_ERROR = exports.MALFORMEDXML = exports.EMPTY_RESPONSE = exports.HTTPERROR = exports.RESPONSE_XML = exports.RESPONSE_TEXT = exports.ERROR_MESSAGE = exports.ERROR_NAME = exports.STATUS = exports.SOURCE = exports.SUCCESS = exports.COMPLETE = exports.BEGIN = exports.ON_EVENT = exports.ON_ERROR = exports.EVENT = exports.ERROR = exports.WINDOW_ID = exports.CTX_PARAM_RENDER = exports.P_BEHAVIOR_EVENT = exports.P_WINDOW_ID = exports.P_RESET_VALUES = exports.P_EVT = exports.P_RENDER = exports.P_EXECUTE = exports.P_AJAX = exports.IDENT_FORM = exports.IDENT_THIS = exports.IDENT_NONE = exports.IDENT_ALL = exports.HTML_CLIENT_WINDOW = exports.HTML_VIEWSTATE = exports.EMPTY_MAP = exports.EMPTY_STR = exports.EMPTY_FUNC = exports.P_RESOURCE = exports.P_VIEWBODY = exports.P_VIEWHEAD = exports.P_VIEWROOT = exports.P_CLIENT_WINDOW = exports.P_VIEWSTATE = exports.PARTIAL_ID = exports.P_PARTIAL_SOURCE = void 0;
4995
+ exports.SEL_SCRIPTS_STYLES = exports.MYFACES = exports.DEFERRED_HEAD_INSERTS = exports.UPDATE_ELEMS = exports.UPDATE_FORMS = exports.CMD_REDIRECT = exports.CMD_EXTENSION = exports.CMD_ATTRIBUTES = exports.CMD_ERROR = exports.CMD_EVAL = exports.CMD_INSERT = exports.CMD_DELETE = exports.CMD_UPDATE = exports.CMD_CHANGES = exports.RESP_PARTIAL = exports.ATTR_ID = exports.ATTR_VALUE = exports.ATTR_NAME = exports.ATTR_URL = exports.ERR_NO_PARTIAL_RESPONSE = exports.PHASE_PROCESS_RESPONSE = exports.SEL_RESPONSE_XML = exports.SEL_CLIENT_WINDOW_ELEM = exports.SEL_VIEWSTATE_ELEM = exports.TAG_ATTR = exports.TAG_AFTER = exports.TAG_BEFORE = exports.TAG_BODY = exports.TAG_FORM = exports.TAG_HEAD = exports.STD_ACCEPT = exports.NO_TIMEOUT = exports.MULTIPART = exports.URL_ENCODED = exports.STATE_EVT_COMPLETE = exports.STATE_EVT_TIMEOUT = exports.STATE_EVT_BEGIN = exports.REQ_TYPE_POST = exports.REQ_TYPE_GET = exports.ENCODED_URL = exports.VAL_AJAX = exports.REQ_ACCEPT = exports.HEAD_FACES_REQ = exports.CONTENT_TYPE = exports.STAGE_DEVELOPMENT = exports.CTX_PARAM_EXECUTE = exports.CTX_PARAM_RST = exports.CTX_PARAM_TIMEOUT = exports.CTX_PARAM_DELAY = exports.CTX_PARAM_SPEC_PARAMS = void 0;
4996
+ exports.$nsp = exports.UNKNOWN = exports.MAX_RECONNECT_ATTEMPTS = exports.RECONNECT_INTERVAL = exports.APPLIED_CLIENT_WINDOW = exports.APPLIED_VST = exports.REASON_EXPIRED = exports.MF_NONE = void 0;
4861
4997
  /*
4862
4998
  * [export const] constants
4863
4999
  */
4864
5000
  exports.P_PARTIAL_SOURCE = "jakarta.faces.source";
4865
5001
  exports.PARTIAL_ID = "partialId";
4866
5002
  exports.P_VIEWSTATE = "jakarta.faces.ViewState";
5003
+ exports.P_CLIENT_WINDOW = "jakarta.faces.ClientWindow";
4867
5004
  exports.P_VIEWROOT = "jakarta.faces.ViewRoot";
4868
5005
  exports.P_VIEWHEAD = "jakarta.faces.ViewHead";
4869
5006
  exports.P_VIEWBODY = "jakarta.faces.ViewBody";
@@ -4873,7 +5010,8 @@ exports.EMPTY_FUNC = Object.freeze(() => {
4873
5010
  });
4874
5011
  exports.EMPTY_STR = "";
4875
5012
  exports.EMPTY_MAP = Object.freeze({});
4876
- exports.HTML_VIEWSTATE = ["<input type='hidden'", "id='", exports.P_VIEWSTATE, "' name='", exports.P_VIEWSTATE, "' value='' />"].join(exports.EMPTY_STR);
5013
+ exports.HTML_VIEWSTATE = ["<input type='hidden'", "name='", exports.P_VIEWSTATE, "' value='' />"].join(exports.EMPTY_STR);
5014
+ exports.HTML_CLIENT_WINDOW = ["<input type='hidden'", "' name='", exports.P_CLIENT_WINDOW, "' value='' />"].join(exports.EMPTY_STR);
4877
5015
  /*internal identifiers for options*/
4878
5016
  exports.IDENT_ALL = "@all";
4879
5017
  exports.IDENT_NONE = "@none";
@@ -4883,7 +5021,6 @@ exports.P_AJAX = "jakarta.faces.partial.ajax";
4883
5021
  exports.P_EXECUTE = "jakarta.faces.partial.execute";
4884
5022
  exports.P_RENDER = "jakarta.faces.partial.render";
4885
5023
  exports.P_EVT = "jakarta.faces.partial.event";
4886
- exports.P_CLIENT_WINDOW = "jakarta.faces.ClientWindow";
4887
5024
  exports.P_RESET_VALUES = "jakarta.faces.partial.resetValues";
4888
5025
  exports.P_WINDOW_ID = "jakarta.faces.windowId";
4889
5026
  exports.P_BEHAVIOR_EVENT = "jakarta.faces.behavior.event";
@@ -4916,6 +5053,7 @@ exports.CTX_PARAM_SRC_FRM_ID = "_mfSourceFormId";
4916
5053
  exports.CTX_PARAM_SRC_CTL_ID = "_mfSourceControlId";
4917
5054
  exports.CTX_PARAM_TR_TYPE = "_mfTransportType";
4918
5055
  exports.CTX_PARAM_PASS_THR = "passThrgh";
5056
+ exports.CTX_PARAM_SPEC_PARAMS = "params";
4919
5057
  exports.CTX_PARAM_DELAY = "delay";
4920
5058
  exports.CTX_PARAM_TIMEOUT = "timeout";
4921
5059
  exports.CTX_PARAM_RST = "resetValues";
@@ -4935,9 +5073,9 @@ exports.URL_ENCODED = "application/x-www-form-urlencoded";
4935
5073
  exports.MULTIPART = "multipart/form-data";
4936
5074
  exports.NO_TIMEOUT = 0;
4937
5075
  exports.STD_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
4938
- exports.TAG_HEAD = "head";
4939
- exports.TAG_FORM = "form";
4940
- exports.TAG_BODY = "body";
5076
+ exports.TAG_HEAD = "HEAD";
5077
+ exports.TAG_FORM = "FORM";
5078
+ exports.TAG_BODY = "BODY";
4941
5079
  exports.TAG_BEFORE = "before";
4942
5080
  exports.TAG_AFTER = "after";
4943
5081
  exports.TAG_ATTR = "attribute";
@@ -5189,10 +5327,8 @@ exports.Assertions = void 0;
5189
5327
  * limitations under the License.
5190
5328
  */
5191
5329
  const mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
5192
- const Lang_1 = __webpack_require__(/*! ./Lang */ "./src/main/typescript/impl/util/Lang.ts");
5193
- var getMessage = Lang_1.ExtLang.getMessage;
5194
- var makeException = Lang_1.ExtLang.makeException;
5195
5330
  const Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
5331
+ const Lang_1 = __webpack_require__(/*! ./Lang */ "./src/main/typescript/impl/util/Lang.ts");
5196
5332
  /**
5197
5333
  * a set of internal code assertions
5198
5334
  * which raise an error
@@ -5207,12 +5343,12 @@ var Assertions;
5207
5343
  assertFunction(options.getIf(Const_1.ON_EVENT).value);
5208
5344
  //improve the error messages if an empty elem is passed
5209
5345
  //Assertions.assertElementExists(elem);
5210
- assert(elem.isPresent(), getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet");
5346
+ assert(elem.isPresent(), Lang_1.ExtLang.getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet");
5211
5347
  }
5212
5348
  Assertions.assertRequestIntegrity = assertRequestIntegrity;
5213
5349
  function assertUrlExists(node) {
5214
5350
  if (node.attr(Const_1.ATTR_URL).isAbsent()) {
5215
- throw Assertions.raiseError(new Error(), getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
5351
+ throw Assertions.raiseError(new Error(), Lang_1.ExtLang.getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
5216
5352
  }
5217
5353
  }
5218
5354
  Assertions.assertUrlExists = assertUrlExists;
@@ -5241,7 +5377,7 @@ var Assertions;
5241
5377
  let finalName = name !== null && name !== void 0 ? name : Const_1.MALFORMEDXML;
5242
5378
  let finalMessage = message !== null && message !== void 0 ? message : Const_1.EMPTY_STR;
5243
5379
  //TODO clean up the messy makeException, this is a perfect case for encapsulation and sane defaults
5244
- return makeException(error, finalTitle, finalName, "Response", caller || ((arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
5380
+ return Lang_1.ExtLang.makeException(error, finalTitle, finalName, "Response", caller || ((arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
5245
5381
  }
5246
5382
  Assertions.raiseError = raiseError;
5247
5383
  /*
@@ -5264,6 +5400,13 @@ var Assertions;
5264
5400
  assertType(value, "function", msg, caller, title);
5265
5401
  }
5266
5402
  Assertions.assertFunction = assertFunction;
5403
+ function assertDelay(value) {
5404
+ if (!(value >= 0)) { // >= 0 abbreviation which covers all cases of non positive values,
5405
+ // including NaN and non numeric strings, no type equality is deliberate here,
5406
+ throw new Error("Invalid delay value: " + value);
5407
+ }
5408
+ }
5409
+ Assertions.assertDelay = assertDelay;
5267
5410
  })(Assertions = exports.Assertions || (exports.Assertions = {}));
5268
5411
 
5269
5412
 
@@ -5618,6 +5761,9 @@ class ExtDomQuery extends mona_dish_1.DQ {
5618
5761
  var _a, _b;
5619
5762
  return (_b = (_a = curScript.getAsElem(0).value) === null || _a === void 0 ? void 0 : _a.nonce) !== null && _b !== void 0 ? _b : curScript.attr("nonce").value;
5620
5763
  }
5764
+ filter(func) {
5765
+ return new ExtDomQuery(super.filter(func));
5766
+ }
5621
5767
  }
5622
5768
  exports.ExtDomQuery = ExtDomQuery;
5623
5769
  exports.ExtDQ = ExtDomQuery;
@@ -6079,6 +6225,7 @@ const mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-di
6079
6225
  const Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
6080
6226
  const Lang_1 = __webpack_require__(/*! ../util/Lang */ "./src/main/typescript/impl/util/Lang.ts");
6081
6227
  const ExtDomQuery_1 = __webpack_require__(/*! ../util/ExtDomQuery */ "./src/main/typescript/impl/util/ExtDomQuery.ts");
6228
+ const Assertions_1 = __webpack_require__(/*! ../util/Assertions */ "./src/main/typescript/impl/util/Assertions.ts");
6082
6229
  /**
6083
6230
  * Resolver functions for various aspects of the request data
6084
6231
  *
@@ -6141,7 +6288,15 @@ exports.resolveTimeout = resolveTimeout;
6141
6288
  function resolveDelay(options) {
6142
6289
  var _a;
6143
6290
  let getCfg = Lang_1.ExtLang.getLocalOrGlobalConfig;
6144
- return (_a = options.getIf(Const_1.CTX_PARAM_DELAY).value) !== null && _a !== void 0 ? _a : getCfg(options.value, Const_1.CTX_PARAM_DELAY, 0);
6291
+ // null or non undefined will automatically be mapped to 0 aka no delay
6292
+ let ret = (_a = options.getIf(Const_1.CTX_PARAM_DELAY).value) !== null && _a !== void 0 ? _a : getCfg(options.value, Const_1.CTX_PARAM_DELAY, 0);
6293
+ // if delay === none, no delay must be used, aka delay 0
6294
+ if ('none' === ret) {
6295
+ ret = 0;
6296
+ }
6297
+ // negative, or invalid values will automatically get a js exception
6298
+ Assertions_1.Assertions.assertDelay(ret);
6299
+ return ret;
6145
6300
  }
6146
6301
  exports.resolveDelay = resolveDelay;
6147
6302
  /**
@@ -6190,7 +6345,7 @@ exports.getEventTarget = getEventTarget;
6190
6345
  * @param opts
6191
6346
  * @param el
6192
6347
  */
6193
- function resolveDefaults(event, opts = {}, el = null) {
6348
+ function resolveDefaults(event, opts, el = null) {
6194
6349
  var _a;
6195
6350
  //deep copy the options, so that further transformations to not backfire into the callers
6196
6351
  const resolvedEvent = event, options = new ExtDomQuery_1.ExtConfig(opts).deepCopy, elem = mona_dish_1.DQ.byId(el || resolvedEvent.target, true), elementId = elem.id.value, requestCtx = new ExtDomQuery_1.ExtConfig({}), internalCtx = new ExtDomQuery_1.ExtConfig({}), windowId = resolveWindowId(options), isResetValues = true === ((_a = options.value) === null || _a === void 0 ? void 0 : _a.resetValues);
@@ -6557,18 +6712,25 @@ class ResponseProcessor {
6557
6712
  if (!shadowHead.isPresent()) {
6558
6713
  return;
6559
6714
  }
6560
- let oldHead = ExtDomQuery_1.ExtDomQuery.querySelectorAll(Const_1.TAG_HEAD);
6561
- //delete all to avoid script and style overlays
6562
- oldHead.querySelectorAll(Const_1.SEL_SCRIPTS_STYLES).delete();
6563
- // we cannot replace new elements in the head, but we can eval the elements
6564
- // eval means the scripts will get attached (eval script attach method)
6565
- // but this is done by DomQuery not in this code
6566
- this.storeForEval(shadowHead);
6567
- //incoming either the outer head tag or its children
6568
- //shadowHead = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
6569
- //this.addToHead(shadowHead);
6715
+ let head = ExtDomQuery_1.ExtDomQuery.querySelectorAll(Const_1.TAG_HEAD);
6716
+ // full replace we delete everything
6717
+ head.childNodes.delete();
6718
+ this.addToHead(shadowHead);
6570
6719
  }
6571
- addToHead(newElements) {
6720
+ addToHead(shadowHead) {
6721
+ const mappedHeadData = new ExtDomQuery_1.ExtDomQuery(shadowHead);
6722
+ const postProcessTags = ["STYLE", "LINK", "SCRIPT"];
6723
+ const nonExecutables = mappedHeadData.filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) == -1);
6724
+ nonExecutables.runHeadInserts(true);
6725
+ //incoming either the outer head tag or its children
6726
+ const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
6727
+ // this is stored for post processing
6728
+ // after the rest of the "pyhsical build up", head before body
6729
+ const evalElements = nodesToAdd.stream
6730
+ .filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) != -1).collect(new mona_dish_1.DomQueryCollector());
6731
+ this.addToHeadDeferred(evalElements);
6732
+ }
6733
+ addToHeadDeferred(newElements) {
6572
6734
  this.internalContext.assign(Const_1.DEFERRED_HEAD_INSERTS).value.push(newElements);
6573
6735
  }
6574
6736
  /**
@@ -6766,10 +6928,11 @@ class ResponseProcessor {
6766
6928
  mona_dish_1.Stream.ofAssoc(this.internalContext.getIf(Const_1.APPLIED_VST).orElse({}).value)
6767
6929
  .each((item) => {
6768
6930
  let value = item[1];
6769
- let nameSpace = mona_dish_1.DQ.byId(value.nameSpace, true).orElse(document.body);
6770
- let affectedForms = nameSpace.byTagName(Const_1.TAG_FORM);
6771
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(Const_1.EMPTY_STR).value.toLowerCase() == Const_1.TAG_FORM);
6772
- this.appendViewStateToForms(new mona_dish_1.DomQuery(affectedForms, affectedForms2), value.value);
6931
+ let namingContainerId = this.internalContext.getIf(Const_1.PARTIAL_ID);
6932
+ let affectedForms;
6933
+ affectedForms = this.getContainerForms(namingContainerId)
6934
+ .filter(affectedForm => this.executeOrRenderFilter(affectedForm));
6935
+ this.appendViewStateToForms(affectedForms, value.value);
6773
6936
  });
6774
6937
  }
6775
6938
  /**
@@ -6779,11 +6942,12 @@ class ResponseProcessor {
6779
6942
  fixClientWindow() {
6780
6943
  mona_dish_1.Stream.ofAssoc(this.internalContext.getIf(Const_1.APPLIED_CLIENT_WINDOW).orElse({}).value)
6781
6944
  .each((item) => {
6782
- let value = item[1];
6783
- let nameSpace = mona_dish_1.DQ.byId(value.nameSpace, true).orElse(document.body);
6784
- let affectedForms = nameSpace.byTagName(Const_1.TAG_FORM);
6785
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(Const_1.EMPTY_STR).value.toLowerCase() == Const_1.TAG_FORM);
6786
- this.appendClientWindowToForms(new mona_dish_1.DomQuery(affectedForms, affectedForms2), value.value);
6945
+ const value = item[1];
6946
+ const namingContainerId = this.internalContext.getIf(Const_1.PARTIAL_ID);
6947
+ let affectedForms;
6948
+ affectedForms = this.getContainerForms(namingContainerId)
6949
+ .filter(affectedForm => this.executeOrRenderFilter(affectedForm));
6950
+ this.appendClientWindowToForms(affectedForms, value.value);
6787
6951
  });
6788
6952
  }
6789
6953
  /**
@@ -6825,7 +6989,11 @@ class ResponseProcessor {
6825
6989
  assignState(forms, selector, state) {
6826
6990
  forms.each((form) => {
6827
6991
  let stateHolders = form.querySelectorAll(selector)
6828
- .orElseLazy(() => ResponseProcessor.newViewStateElement(form));
6992
+ .orElseLazy(() => {
6993
+ return selector.indexOf("ViewState") != -1 ?
6994
+ ResponseProcessor.newViewStateElement(form) :
6995
+ ResponseProcessor.newClientWindowElement(form);
6996
+ });
6829
6997
  stateHolders.attr("value").value = state;
6830
6998
  });
6831
6999
  }
@@ -6836,9 +7004,20 @@ class ResponseProcessor {
6836
7004
  * (usually a form node)
6837
7005
  */
6838
7006
  static newViewStateElement(parent) {
6839
- let newViewState = mona_dish_1.DQ.fromMarkup((0, Const_1.$nsp)(Const_1.HTML_VIEWSTATE));
6840
- newViewState.appendTo(parent);
6841
- return newViewState;
7007
+ let newElement = mona_dish_1.DQ.fromMarkup((0, Const_1.$nsp)(Const_1.HTML_VIEWSTATE));
7008
+ newElement.appendTo(parent);
7009
+ return newElement;
7010
+ }
7011
+ /**
7012
+ * Helper to Create a new JSF ViewState Element
7013
+ *
7014
+ * @param parent, the parent node to attach the viewState element to
7015
+ * (usually a form node)
7016
+ */
7017
+ static newClientWindowElement(parent) {
7018
+ let newElement = mona_dish_1.DQ.fromMarkup((0, Const_1.$nsp)(Const_1.HTML_CLIENT_WINDOW));
7019
+ newElement.appendTo(parent);
7020
+ return newElement;
6842
7021
  }
6843
7022
  /**
6844
7023
  * Stores certain aspects of the dom for later post-processing
@@ -6895,6 +7074,43 @@ class ResponseProcessor {
6895
7074
  triggerOnError(errorData) {
6896
7075
  this.externalContext.getIf(Const_1.ON_ERROR).orElse(this.internalContext.getIf(Const_1.ON_ERROR).value).orElse(Const_1.EMPTY_FUNC).value(errorData);
6897
7076
  }
7077
+ /**
7078
+ * filters the forms according to being in the execute or render cycle
7079
+ * @param affectedForm
7080
+ * @private
7081
+ */
7082
+ executeOrRenderFilter(affectedForm) {
7083
+ let executes = this.externalContext.getIf((0, Const_1.$nsp)(Const_1.P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
7084
+ let renders = this.externalContext.getIf((0, Const_1.$nsp)(Const_1.P_RENDER)).orElse("@none").value.split(/\s+/gi);
7085
+ let executeAndRenders = executes.concat(...renders);
7086
+ return mona_dish_1.LazyStream.of(...executeAndRenders).filter(nameOrId => {
7087
+ if (nameOrId == "@all") {
7088
+ return true;
7089
+ }
7090
+ if (nameOrId == "@none") {
7091
+ return true;
7092
+ }
7093
+ const nameOrIdSelector = `[id='${nameOrId}'], [name='#${nameOrId}']`;
7094
+ //either the form directly is in execute or render or one of its children or one of its parents
7095
+ return affectedForm.matchesSelector(nameOrIdSelector) ||
7096
+ affectedForm.querySelectorAll(nameOrIdSelector).isPresent() ||
7097
+ affectedForm.parents(nameOrIdSelector).isPresent();
7098
+ }).first().isPresent();
7099
+ }
7100
+ /**
7101
+ * gets all forms under a single naming container id
7102
+ * @param namingContainerId
7103
+ * @private
7104
+ */
7105
+ getContainerForms(namingContainerId) {
7106
+ if (namingContainerId.isPresent()) {
7107
+ //naming container mode, all forms under naming container id must be processed
7108
+ return mona_dish_1.DQ.byId(namingContainerId.value).orElse((0, mona_dish_1.DQ$)(`form[name='${namingContainerId.value}']`)).byTagName(Const_1.TAG_FORM, true);
7109
+ }
7110
+ else {
7111
+ return mona_dish_1.DQ.byTagName(Const_1.TAG_FORM);
7112
+ }
7113
+ }
6898
7114
  }
6899
7115
  exports.ResponseProcessor = ResponseProcessor;
6900
7116
 
@@ -6965,12 +7181,17 @@ class XhrFormData extends mona_dish_1.Config {
6965
7181
  //a call to getViewState before must pass the encoded line
6966
7182
  //a call from getViewState passes the form element as datasource,
6967
7183
  //so we have two call points
7184
+ // atm we basically encode twice, to keep the code leaner
7185
+ // this will be later optmized, practically elements
7186
+ // which are already covered by an external viewstate do not need
7187
+ // the encoding a second time, because they are overwritten by the viewstate again
6968
7188
  if (isString(dataSource)) {
6969
7189
  this.assignEncodedString(this.dataSource);
6970
7190
  }
6971
7191
  else {
6972
7192
  this.applyFormDataToConfig();
6973
7193
  }
7194
+ //now assign the external viewstate overrides
6974
7195
  if ('undefined' != typeof viewState) {
6975
7196
  this.assignEncodedString(viewState);
6976
7197
  }
@@ -6984,23 +7205,26 @@ class XhrFormData extends mona_dish_1.Config {
6984
7205
  * in our ajax request
6985
7206
  */
6986
7207
  postInit(...executes) {
6987
- let fetchInput = (id) => {
7208
+ let fetchFileInputs = (id) => {
7209
+ const INPUT_FILE = "input[type='file']";
6988
7210
  if (id == Const_1.IDENT_ALL) {
6989
- return mona_dish_1.DQ.querySelectorAllDeep("input[type='file']");
7211
+ return mona_dish_1.DQ.querySelectorAllDeep(INPUT_FILE);
6990
7212
  }
6991
7213
  else if (id == Const_1.IDENT_FORM) {
6992
- return this.dataSource.querySelectorAllDeep("input[type='file']");
7214
+ return this.dataSource.matchesSelector(INPUT_FILE) ?
7215
+ this.dataSource :
7216
+ this.dataSource.querySelectorAllDeep(INPUT_FILE);
6993
7217
  }
6994
7218
  else {
6995
7219
  let element = mona_dish_1.DQ.byId(id, true);
6996
- return this.getFileInputs(element);
7220
+ return element.matchesSelector(INPUT_FILE) ? element : this.getFileInputs(element);
6997
7221
  }
6998
7222
  };
6999
7223
  let inputExists = (item) => {
7000
7224
  return item.isPresent();
7001
7225
  };
7002
7226
  this.isMultipartRequest = mona_dish_1.LazyStream.of(...executes)
7003
- .map(fetchInput)
7227
+ .map(fetchFileInputs)
7004
7228
  .filter(inputExists)
7005
7229
  .first().isPresent();
7006
7230
  }
@@ -7038,8 +7262,8 @@ class XhrFormData extends mona_dish_1.Config {
7038
7262
  var _a, _b;
7039
7263
  return keyVal.length < 3 ? [(_a = keyVal === null || keyVal === void 0 ? void 0 : keyVal[0]) !== null && _a !== void 0 ? _a : [], (_b = keyVal === null || keyVal === void 0 ? void 0 : keyVal[1]) !== null && _b !== void 0 ? _b : []] : keyVal;
7040
7264
  }
7265
+ //TODO fix files...
7041
7266
  mona_dish_1.Stream.of(...keyValueEntries)
7042
- //split only the first =
7043
7267
  .map(line => splitToKeyVal(line))
7044
7268
  //special case of having keys without values
7045
7269
  .map(keyVal => fixKeyWithoutVal(keyVal))
@@ -7075,7 +7299,10 @@ class XhrFormData extends mona_dish_1.Config {
7075
7299
  }
7076
7300
  let entries = mona_dish_1.LazyStream.of(...Object.keys(this.value))
7077
7301
  .filter(key => this.value.hasOwnProperty(key))
7078
- .flatMap(key => mona_dish_1.Stream.of(...this.value[key]).map(val => [key, val]).collect(new mona_dish_1.ArrayCollector()))
7302
+ .flatMap(key => mona_dish_1.Stream.of(...this.value[key]).map(val => [key, val])
7303
+ //we cannot encode file elements that is handled by multipart requests anyway
7304
+ .filter(([, value]) => !(value instanceof ExtDomQuery_1.ExtDomQuery.global().File))
7305
+ .collect(new mona_dish_1.ArrayCollector()))
7079
7306
  .map(keyVal => {
7080
7307
  return `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
7081
7308
  })
@@ -7532,31 +7759,32 @@ var oam;
7532
7759
  }
7533
7760
  mona_dish_1.DQ.byId(element).delete();
7534
7761
  };
7535
- // noinspection JSUnusedGlobalSymbols
7762
+ // noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
7536
7763
  /**
7537
7764
  * does special form submit remapping
7538
7765
  * re-maps the issuing command link into something,
7539
- * a decode of the command link on the server can understand
7766
+ * the "decode" of the command link on the server can understand
7540
7767
  *
7541
7768
  * @param formName
7542
7769
  * @param linkId
7543
7770
  * @param target
7544
7771
  * @param params
7545
7772
  */
7546
- oam.submitForm = function (formName, linkId, target, params) {
7547
- var _a, _b, _c, _d;
7773
+ oam.submitForm = function (formName, linkId = null, target = null, params = {}) {
7774
+ var _a, _b, _c, _d, _e, _f;
7775
+ //handle a possible incoming null, not sure if this is used that way anywhere, but we allow it
7776
+ params = (!params) ? {} : params;
7548
7777
  let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
7549
7778
  (_a = window === null || window === void 0 ? void 0 : window[clearFn]) === null || _a === void 0 ? void 0 : _a.call(window, formName);
7550
7779
  //autoscroll code
7551
7780
  if (((_d = (_c = (_b = window === null || window === void 0 ? void 0 : window.myfaces) === null || _b === void 0 ? void 0 : _b.core) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.autoScroll) && (window === null || window === void 0 ? void 0 : window.getScrolling)) {
7552
7781
  myfaces.oam.setHiddenInput(formName, 'autoScroll', window === null || window === void 0 ? void 0 : window.getScrolling());
7553
7782
  }
7554
- mona_dish_1.Stream.ofAssoc(params).each((param) => {
7555
- myfaces.oam.setHiddenInput(formName, param[0], param[1]);
7556
- });
7783
+ let paramsStream = Array.isArray(params) ? mona_dish_1.Stream.of(...params) : mona_dish_1.Stream.ofAssoc(params);
7784
+ paramsStream.each(([key, data]) => myfaces.oam.setHiddenInput(formName, key, data));
7557
7785
  //we call the namespaced function, to allow decoration, via a direct call we would
7558
- myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
7559
- mona_dish_1.DQ.byId(document.forms[formName]).each(form => {
7786
+ myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId !== null && linkId !== void 0 ? linkId : '');
7787
+ mona_dish_1.DQ.byId((_f = (_e = document.forms) === null || _e === void 0 ? void 0 : _e[formName]) !== null && _f !== void 0 ? _f : document.getElementById(formName)).each(form => {
7560
7788
  var _a;
7561
7789
  const ATTR_TARGET = "target";
7562
7790
  const formElement = form.getAsElem(0).value;
@@ -7573,8 +7801,9 @@ var oam;
7573
7801
  }
7574
7802
  finally {
7575
7803
  form.attr(ATTR_TARGET).value = oldTarget;
7576
- mona_dish_1.Stream.ofAssoc(params).each((param) => {
7577
- myfaces.oam.clearHiddenInput(formName, param[0]);
7804
+ // noinspection JSUnusedLocalSymbols
7805
+ paramsStream.each(([key, data]) => {
7806
+ myfaces.oam.clearHiddenInput(formName, key);
7578
7807
  });
7579
7808
  myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
7580
7809
  }