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

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.
@@ -982,6 +982,10 @@ class DomQuery {
982
982
  get asNodeArray() {
983
983
  return new Es2019Array_1.Es2019Array(...this.rootNode.filter(item => item != null));
984
984
  }
985
+ get nonce() {
986
+ var _a, _b, _c, _d, _e;
987
+ return Monad_1.Optional.fromNullable((_c = (_b = (_a = this === null || this === void 0 ? void 0 : this.rootNode) === 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.rootNode) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.getAttribute("nonce"));
988
+ }
985
989
  static querySelectorAllDeep(selector) {
986
990
  return new DomQuery(document).querySelectorAllDeep(selector);
987
991
  }
@@ -1866,8 +1870,8 @@ class DomQuery {
1866
1870
  // for a full head replace
1867
1871
  _toReplace.replace(newElement);
1868
1872
  };
1869
- const scriptElements = new DomQuery(this.filterSelector("link, style"), this.querySelectorAll("link, style"));
1870
- scriptElements.asArray
1873
+ const cssElems = new DomQuery(this.filterSelector("link, style"), this.querySelectorAll("link, style"));
1874
+ cssElems.asArray
1871
1875
  .flatMap(item => [...item.values])
1872
1876
  // sort to make sure the execution order is correct
1873
1877
  // this is needed because we mix 2 queries together
@@ -4561,7 +4565,7 @@ var Implementation;
4561
4565
  /*
4562
4566
  * lazy helper to fetch the window id from the included faces.js
4563
4567
  */
4564
- let fetchWindowIdFromJSFJS = () => ExtDomQuery_1.ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;
4568
+ let fetchWindowIdFromJSFJS = () => ExtDomQuery_1.ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null);
4565
4569
  /*
4566
4570
  * fetch window id from the url
4567
4571
  */
@@ -4571,8 +4575,8 @@ var Implementation;
4571
4575
  const results = regex.exec(href);
4572
4576
  //initial trial over the url and a regexp
4573
4577
  if (results != null)
4574
- return results[1];
4575
- return null;
4578
+ return mona_dish_1.Optional.fromNullable(results[1]);
4579
+ return mona_dish_1.Optional.fromNullable(null);
4576
4580
  };
4577
4581
  /*
4578
4582
  * functional double check based on stream reduction
@@ -4608,7 +4612,7 @@ var Implementation;
4608
4612
  /*
4609
4613
  * return the window id or null
4610
4614
  */
4611
- return formWindowId != INIT ? formWindowId : (fetchWindowIdFromURL() || fetchWindowIdFromJSFJS());
4615
+ return formWindowId != INIT ? formWindowId : (fetchWindowIdFromURL() || fetchWindowIdFromJSFJS()).value;
4612
4616
  }
4613
4617
  Implementation.getClientWindow = getClientWindow;
4614
4618
  /**
@@ -5800,10 +5804,10 @@ class ExtDomQuery extends mona_dish_1.DQ {
5800
5804
  if (result.length > 1) {
5801
5805
  throw Error("Multiple different windowIds found in document");
5802
5806
  }
5803
- return (result.isPresent()) ? result.getAsElem(0).value.value : fetchWindowIdFromURL();
5807
+ return mona_dish_1.Optional.fromNullable((result.isPresent()) ? result.getAsElem(0).value.value : fetchWindowIdFromURL());
5804
5808
  }
5805
5809
  else {
5806
- return fetchWindowIdFromURL();
5810
+ return mona_dish_1.Optional.fromNullable(fetchWindowIdFromURL());
5807
5811
  }
5808
5812
  }
5809
5813
  /*
@@ -5811,29 +5815,27 @@ class ExtDomQuery extends mona_dish_1.DQ {
5811
5815
  * this is done once and only lazily
5812
5816
  */
5813
5817
  get nonce() {
5814
- var _a;
5818
+ var _a, _b, _c;
5815
5819
  //already processed
5816
5820
  let myfacesConfig = new ExtConfig(window.myfaces);
5817
- let nonce = myfacesConfig.getIf("config", "cspMeta", "nonce");
5818
- if (nonce.value) {
5819
- return nonce.value;
5821
+ let globalNonce = myfacesConfig.getIf("config", "cspMeta", "nonce");
5822
+ if (!!globalNonce.value) {
5823
+ return mona_dish_1.Optional.fromNullable(globalNonce.value);
5820
5824
  }
5821
5825
  let curScript = new mona_dish_1.DQ(document.currentScript);
5822
5826
  //since our baseline atm is ie11 we cannot use document.currentScript globally
5823
- if (!!this.extractNonce(curScript)) {
5827
+ let nonce = curScript.nonce;
5828
+ if (nonce.isPresent()) {
5824
5829
  // fast-path for modern browsers
5825
- return this.extractNonce(curScript);
5830
+ return nonce;
5826
5831
  }
5827
5832
  // fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
5828
5833
  // the last possibility
5829
5834
  let nonceScript = mona_dish_1.Optional.fromNullable((_a = mona_dish_1.DQ
5830
5835
  .querySelectorAll("script[src], link[src]").asArray
5831
- .filter((item) => this.extractNonce(item) && item.attr(ATTR_SRC) != null)
5836
+ .filter((item) => item.nonce.isPresent() && item.attr(ATTR_SRC) != null)
5832
5837
  .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);
5835
- }
5836
- return null;
5838
+ return mona_dish_1.Optional.fromNullable((_c = (_b = nonceScript.value) === null || _b === void 0 ? void 0 : _b.nonce) === null || _c === void 0 ? void 0 : _c.value);
5837
5839
  }
5838
5840
  static searchJsfJsFor(item) {
5839
5841
  return new ExtDomQuery(document).searchJsfJsFor(item);
@@ -5855,12 +5857,12 @@ class ExtDomQuery extends mona_dish_1.DQ {
5855
5857
  })) === null || _a === void 0 ? void 0 : _a[0]);
5856
5858
  }
5857
5859
  globalEval(code, nonce) {
5858
- return new ExtDomQuery(super.globalEval(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce));
5860
+ return new ExtDomQuery(super.globalEval(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce.value));
5859
5861
  }
5860
5862
  // called from base class runScripts, do not delete
5861
5863
  // noinspection JSUnusedGlobalSymbols
5862
5864
  globalEvalSticky(code, nonce) {
5863
- return new ExtDomQuery(super.globalEvalSticky(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce));
5865
+ return new ExtDomQuery(super.globalEvalSticky(code, nonce !== null && nonce !== void 0 ? nonce : this.nonce.value));
5864
5866
  }
5865
5867
  /**
5866
5868
  * decorated run scripts which takes our jsf extensions into consideration
@@ -5934,10 +5936,6 @@ class ExtDomQuery extends mona_dish_1.DQ {
5934
5936
  const ret = mona_dish_1.DomQuery.byId(selector, deep);
5935
5937
  return new ExtDomQuery(ret);
5936
5938
  }
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
5939
  filter(func) {
5942
5940
  return new ExtDomQuery(super.filter(func));
5943
5941
  }
@@ -6869,7 +6867,7 @@ exports.resolveDelay = resolveDelay;
6869
6867
  */
6870
6868
  function resolveWindowId(options) {
6871
6869
  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;
6870
+ 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
6871
  }
6874
6872
  exports.resolveWindowId = resolveWindowId;
6875
6873
  /**
Binary file
Binary file