jsf.js_next_gen 4.0.1-beta.7 → 4.0.1-beta.9

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.
@@ -580,6 +580,34 @@ var isString = Lang_1.Lang.isString;
580
580
  var eqi = Lang_1.Lang.equalsIgnoreCase;
581
581
  var objToArray = Lang_1.Lang.objToArray;
582
582
  const AssocArray_1 = __webpack_require__(/*! ./AssocArray */ "./node_modules/mona-dish/src/main/typescript/AssocArray.ts");
583
+ class NonceValueEmbedder extends Monad_1.ValueEmbedder {
584
+ constructor(rootElems) {
585
+ super(rootElems === null || rootElems === void 0 ? void 0 : rootElems[0], "nonce");
586
+ this.rootElems = rootElems;
587
+ }
588
+ isAbsent() {
589
+ const value = this.value;
590
+ return 'undefined' == typeof value || '' == value;
591
+ }
592
+ get value() {
593
+ var _a, _b, _c, _d, _e;
594
+ return (_c = (_b = (_a = this === null || this === void 0 ? void 0 : this.rootElems) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.nonce) !== null && _c !== void 0 ? _c : (_e = (_d = this === null || this === void 0 ? void 0 : this.rootElems) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.getAttribute("nonce");
595
+ }
596
+ set value(newVal) {
597
+ var _a;
598
+ if (!((_a = this === null || this === void 0 ? void 0 : this.rootElems) === null || _a === void 0 ? void 0 : _a.length)) {
599
+ return;
600
+ }
601
+ this.rootElems.forEach((rootElem) => {
602
+ if ("undefined" != typeof (rootElem === null || rootElem === void 0 ? void 0 : rootElem.nonce)) {
603
+ rootElem.nonce = newVal;
604
+ }
605
+ else {
606
+ rootElem.setAttribute("nonce", newVal);
607
+ }
608
+ });
609
+ }
610
+ }
583
611
  /**
584
612
  *
585
613
  * // - submit checkboxes and radio inputs only if checked
@@ -982,6 +1010,9 @@ class DomQuery {
982
1010
  get asNodeArray() {
983
1011
  return new Es2019Array_1.Es2019Array(...this.rootNode.filter(item => item != null));
984
1012
  }
1013
+ get nonce() {
1014
+ return new NonceValueEmbedder(this.rootNode);
1015
+ }
985
1016
  static querySelectorAllDeep(selector) {
986
1017
  return new DomQuery(document).querySelectorAllDeep(selector);
987
1018
  }
@@ -1674,11 +1705,18 @@ class DomQuery {
1674
1705
  case "checked":
1675
1706
  this.resolveAttributeHolder("checked").checked = value;
1676
1707
  break;
1708
+ case "nonce":
1709
+ // nonce will be handled below!
1710
+ break;
1677
1711
  default:
1678
1712
  this.attr(name).value = value;
1679
1713
  }
1680
1714
  }
1681
1715
  });
1716
+ //special nonce handling
1717
+ sourceItem.nonce.isPresent(() => {
1718
+ this.nonce.value = sourceItem.nonce.value;
1719
+ });
1682
1720
  return this;
1683
1721
  }
1684
1722
  /**
@@ -1866,8 +1904,8 @@ class DomQuery {
1866
1904
  // for a full head replace
1867
1905
  _toReplace.replace(newElement);
1868
1906
  };
1869
- const scriptElements = new DomQuery(this.filterSelector("link, style"), this.querySelectorAll("link, style"));
1870
- scriptElements.asArray
1907
+ const cssElems = new DomQuery(this.filterSelector("link, style"), this.querySelectorAll("link, style"));
1908
+ cssElems.asArray
1871
1909
  .flatMap(item => [...item.values])
1872
1910
  // sort to make sure the execution order is correct
1873
1911
  // this is needed because we mix 2 queries together
@@ -4561,7 +4599,7 @@ var Implementation;
4561
4599
  /*
4562
4600
  * lazy helper to fetch the window id from the included faces.js
4563
4601
  */
4564
- let fetchWindowIdFromJSFJS = () => ExtDomQuery_1.ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;
4602
+ let fetchWindowIdFromJSFJS = () => ExtDomQuery_1.ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null);
4565
4603
  /*
4566
4604
  * fetch window id from the url
4567
4605
  */
@@ -4571,8 +4609,8 @@ var Implementation;
4571
4609
  const results = regex.exec(href);
4572
4610
  //initial trial over the url and a regexp
4573
4611
  if (results != null)
4574
- return results[1];
4575
- return null;
4612
+ return mona_dish_1.Optional.fromNullable(results[1]);
4613
+ return mona_dish_1.Optional.fromNullable(null);
4576
4614
  };
4577
4615
  /*
4578
4616
  * functional double check based on stream reduction
@@ -4608,7 +4646,7 @@ var Implementation;
4608
4646
  /*
4609
4647
  * return the window id or null
4610
4648
  */
4611
- return formWindowId != INIT ? formWindowId : (fetchWindowIdFromURL() || fetchWindowIdFromJSFJS());
4649
+ return formWindowId != INIT ? formWindowId : (fetchWindowIdFromURL() || fetchWindowIdFromJSFJS()).value;
4612
4650
  }
4613
4651
  Implementation.getClientWindow = getClientWindow;
4614
4652
  /**
@@ -5800,10 +5838,10 @@ class ExtDomQuery extends mona_dish_1.DQ {
5800
5838
  if (result.length > 1) {
5801
5839
  throw Error("Multiple different windowIds found in document");
5802
5840
  }
5803
- return (result.isPresent()) ? result.getAsElem(0).value.value : fetchWindowIdFromURL();
5841
+ return mona_dish_1.Optional.fromNullable((result.isPresent()) ? result.getAsElem(0).value.value : fetchWindowIdFromURL());
5804
5842
  }
5805
5843
  else {
5806
- return fetchWindowIdFromURL();
5844
+ return mona_dish_1.Optional.fromNullable(fetchWindowIdFromURL());
5807
5845
  }
5808
5846
  }
5809
5847
  /*
@@ -5814,26 +5852,27 @@ class ExtDomQuery extends mona_dish_1.DQ {
5814
5852
  var _a;
5815
5853
  //already processed
5816
5854
  let myfacesConfig = new ExtConfig(window.myfaces);
5817
- let nonce = myfacesConfig.getIf("config", "cspMeta", "nonce");
5818
- if (nonce.value) {
5819
- return nonce.value;
5855
+ let globalNonce = myfacesConfig.getIf("config", "cspMeta", "nonce");
5856
+ if (!!globalNonce.value) {
5857
+ return mona_dish_1.ValueEmbedder.fromNullable(globalNonce);
5820
5858
  }
5821
5859
  let curScript = new mona_dish_1.DQ(document.currentScript);
5822
5860
  //since our baseline atm is ie11 we cannot use document.currentScript globally
5823
- if (!!this.extractNonce(curScript)) {
5861
+ let nonce = curScript.nonce;
5862
+ if (nonce.isPresent()) {
5824
5863
  // fast-path for modern browsers
5825
- return this.extractNonce(curScript);
5864
+ return mona_dish_1.ValueEmbedder.fromNullable(nonce);
5826
5865
  }
5827
5866
  // fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
5828
5867
  // the last possibility
5829
5868
  let nonceScript = mona_dish_1.Optional.fromNullable((_a = mona_dish_1.DQ
5830
5869
  .querySelectorAll("script[src], link[src]").asArray
5831
- .filter((item) => this.extractNonce(item) && item.attr(ATTR_SRC) != null)
5870
+ .filter((item) => item.nonce.isPresent() && item.attr(ATTR_SRC) != null)
5832
5871
  .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))) === null || _a === void 0 ? void 0 : _a[0]);
5833
- if (nonceScript.isPresent()) {
5834
- return this.extractNonce(nonceScript.value);
5872
+ if (!(nonceScript === null || nonceScript === void 0 ? void 0 : nonceScript.value)) {
5873
+ return mona_dish_1.ValueEmbedder.absent;
5835
5874
  }
5836
- return null;
5875
+ return new mona_dish_1.DomQuery(nonceScript.value).nonce;
5837
5876
  }
5838
5877
  static searchJsfJsFor(item) {
5839
5878
  return new ExtDomQuery(document).searchJsfJsFor(item);
@@ -5855,12 +5894,12 @@ class ExtDomQuery extends mona_dish_1.DQ {
5855
5894
  })) === null || _a === void 0 ? void 0 : _a[0]);
5856
5895
  }
5857
5896
  globalEval(code, nonce) {
5858
- return new ExtDomQuery(super.globalEval(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce));
5897
+ return new ExtDomQuery(super.globalEval(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce.value));
5859
5898
  }
5860
5899
  // called from base class runScripts, do not delete
5861
5900
  // noinspection JSUnusedGlobalSymbols
5862
5901
  globalEvalSticky(code, nonce) {
5863
- return new ExtDomQuery(super.globalEvalSticky(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce));
5902
+ return new ExtDomQuery(super.globalEvalSticky(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce.value));
5864
5903
  }
5865
5904
  /**
5866
5905
  * decorated run scripts which takes our jsf extensions into consideration
@@ -5934,10 +5973,6 @@ class ExtDomQuery extends mona_dish_1.DQ {
5934
5973
  const ret = mona_dish_1.DomQuery.byId(selector, deep);
5935
5974
  return new ExtDomQuery(ret);
5936
5975
  }
5937
- extractNonce(curScript) {
5938
- var _a, _b;
5939
- return (_b = (_a = curScript.getAsElem(0).value) === null || _a === void 0 ? void 0 : _a.nonce) !== null && _b !== void 0 ? _b : curScript.attr("nonce").value;
5940
- }
5941
5976
  filter(func) {
5942
5977
  return new ExtDomQuery(super.filter(func));
5943
5978
  }
@@ -6869,7 +6904,7 @@ exports.resolveDelay = resolveDelay;
6869
6904
  */
6870
6905
  function resolveWindowId(options) {
6871
6906
  var _a, _b;
6872
- return (_b = (_a = options === null || options === void 0 ? void 0 : options.value) === null || _a === void 0 ? void 0 : _a.windowId) !== null && _b !== void 0 ? _b : ExtDomQuery_1.ExtDomQuery.windowId;
6907
+ return (_b = (_a = options === null || options === void 0 ? void 0 : options.value) === null || _a === void 0 ? void 0 : _a.windowId) !== null && _b !== void 0 ? _b : ExtDomQuery_1.ExtDomQuery.windowId.value;
6873
6908
  }
6874
6909
  exports.resolveWindowId = resolveWindowId;
6875
6910
  /**
Binary file
Binary file