jsf.js_next_gen 4.0.0-beta-20 → 4.0.0-beta-21

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 (41) hide show
  1. package/dist/window/faces-development.js +124 -78
  2. package/dist/window/faces-development.js.br +0 -0
  3. package/dist/window/faces-development.js.gz +0 -0
  4. package/dist/window/faces-development.js.map +1 -1
  5. package/dist/window/faces.js +1 -1
  6. package/dist/window/faces.js.br +0 -0
  7. package/dist/window/faces.js.gz +0 -0
  8. package/dist/window/faces.js.map +1 -1
  9. package/dist/window/jsf-development.js +124 -78
  10. package/dist/window/jsf-development.js.br +0 -0
  11. package/dist/window/jsf-development.js.gz +0 -0
  12. package/dist/window/jsf-development.js.map +1 -1
  13. package/dist/window/jsf.js +1 -1
  14. package/dist/window/jsf.js.br +0 -0
  15. package/dist/window/jsf.js.gz +0 -0
  16. package/dist/window/jsf.js.map +1 -1
  17. package/package.json +3 -3
  18. package/src/main/typescript/impl/util/ExtDomQuery.ts +51 -2
  19. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +1 -23
  20. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +283 -68
  21. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +1 -0
  22. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +1 -0
  23. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +9 -2
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +8 -6
  25. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +34 -10
  26. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +1 -0
  27. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +3 -0
  28. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +1 -0
  29. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +3 -0
  30. package/target/impl/util/ExtDomQuery.js +45 -1
  31. package/target/impl/util/ExtDomQuery.js.map +1 -1
  32. package/target/impl/xhrCore/ResponseProcessor.js +1 -23
  33. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  34. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +243 -83
  35. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  36. package/target/test/frameworkBase/_ext/shared/StandardInits.js +9 -2
  37. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  38. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +8 -6
  39. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  40. package/target/test/xhrCore/ResponseTest.spec.js +27 -10
  41. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
@@ -69,7 +69,13 @@ var Submittables;
69
69
  * @param condition the condition lambda to be fulfilled
70
70
  * @param options options for the search
71
71
  */
72
- function waitUntilDom(root, condition, options = { attributes: true, childList: true, subtree: true, timeout: 500, interval: 100 }) {
72
+ function waitUntilDom(root, condition, options = {
73
+ attributes: true,
74
+ childList: true,
75
+ subtree: true,
76
+ timeout: 500,
77
+ interval: 100
78
+ }) {
73
79
  return new Promise((success, error) => {
74
80
  let observer = null;
75
81
  const MUT_ERROR = new Error("Mutation observer timeout");
@@ -1030,32 +1036,18 @@ class DomQuery {
1030
1036
  * @param charSet
1031
1037
  */
1032
1038
  loadScriptEval(src, defer = 0, charSet = "utf-8", nonce) {
1033
- let xhr = new XMLHttpRequest();
1034
- xhr.open("GET", src, false);
1035
- if (charSet) {
1036
- xhr.setRequestHeader("Content-Type", "application/x-javascript; charset:" + charSet);
1037
- }
1038
- xhr.onload = () => {
1039
- //defer also means we have to process after the ajax response
1040
- //has been processed
1041
- //we can achieve that with a small timeout, the timeout
1042
- //triggers after the processing is done!
1043
- if (!defer) {
1044
- this.globalEval(xhr.responseText.replace(/\n/g, "\r\n") + "\r\n//@ sourceURL=" + src, nonce);
1045
- }
1046
- else {
1047
- //TODO not ideal we maybe ought to move to something else here
1048
- //but since it is not in use yet, it is ok
1049
- setTimeout(() => {
1050
- this.globalEval(xhr.responseText + "\r\n//@ sourceURL=" + src, nonce);
1051
- }, defer);
1052
- }
1053
- };
1054
- xhr.onerror = (data) => {
1055
- throw Error(data);
1056
- };
1057
- //since we are synchronous we do it after not with onReadyStateChange
1058
- xhr.send(null);
1039
+ let srcNode = this.createSourceNode(src, nonce);
1040
+ let head = document.head;
1041
+ if (!defer) {
1042
+ head.appendChild(srcNode);
1043
+ head.removeChild(srcNode);
1044
+ }
1045
+ else {
1046
+ setTimeout(() => {
1047
+ head.appendChild(srcNode);
1048
+ head.removeChild(srcNode);
1049
+ }, defer);
1050
+ }
1059
1051
  return this;
1060
1052
  }
1061
1053
  /**
@@ -1066,32 +1058,15 @@ class DomQuery {
1066
1058
  * @param charSet
1067
1059
  */
1068
1060
  loadScriptEvalSticky(src, defer = 0, charSet = "utf-8", nonce) {
1069
- let xhr = new XMLHttpRequest();
1070
- xhr.open("GET", src, false);
1071
- if (charSet) {
1072
- xhr.setRequestHeader("Content-Type", "application/x-javascript; charset:" + charSet);
1073
- }
1074
- xhr.onload = () => {
1075
- //defer also means we have to process after the ajax response
1076
- //has been processed
1077
- //we can achieve that with a small timeout, the timeout
1078
- //triggers after the processing is done!
1079
- if (!defer) {
1080
- this.globalEvalSticky(xhr.responseText.replace(/\n/g, "\r\n") + "\r\n//@ sourceURL=" + src, nonce);
1081
- }
1082
- else {
1083
- //TODO not ideal we maybe ought to move to something else here
1084
- //but since it is not in use yet, it is ok
1085
- setTimeout(() => {
1086
- this.globalEvalSticky(xhr.responseText + "\r\n//@ sourceURL=" + src, nonce);
1087
- }, defer);
1088
- }
1089
- };
1090
- xhr.onerror = (data) => {
1091
- throw Error(data);
1092
- };
1093
- //since we are synchronous we do it after not with onReadyStateChange
1094
- xhr.send(null);
1061
+ let srcNode = this.createSourceNode(src, nonce);
1062
+ if (!defer) {
1063
+ document.head.appendChild(srcNode);
1064
+ }
1065
+ else {
1066
+ setTimeout(() => {
1067
+ document.head.appendChild(srcNode);
1068
+ }, defer);
1069
+ }
1095
1070
  return this;
1096
1071
  }
1097
1072
  insertAfter(...toInsertParams) {
@@ -1665,7 +1640,13 @@ class DomQuery {
1665
1640
  * @param condition
1666
1641
  * @param options
1667
1642
  */
1668
- waitUntilDom(condition, options = { attributes: true, childList: true, subtree: true, timeout: 500, interval: 100 }) {
1643
+ waitUntilDom(condition, options = {
1644
+ attributes: true,
1645
+ childList: true,
1646
+ subtree: true,
1647
+ timeout: 500,
1648
+ interval: 100
1649
+ }) {
1669
1650
  return __awaiter(this, void 0, void 0, function* () {
1670
1651
  return waitUntilDom(this, condition, options);
1671
1652
  });
@@ -1781,6 +1762,49 @@ class DomQuery {
1781
1762
  });
1782
1763
  return this;
1783
1764
  }
1765
+ /*[observable](): Observable<DomQuery> {
1766
+ return this.observable;
1767
+ }
1768
+
1769
+ get observable(): Observable<DomQuery> {
1770
+ let observerFunc = (observer:Subscriber<DomQuery>) => {
1771
+ try {
1772
+ this.each(dqNode => {
1773
+ observer.next(dqNode);
1774
+ });
1775
+ } catch (e) {
1776
+ observer.error(e);
1777
+ }
1778
+ };
1779
+ return new Observable(observerFunc);
1780
+ }
1781
+
1782
+ get observableElem(): Observable<Element> {
1783
+ let observerFunc = (observer:Subscriber<Element>) => {
1784
+ try {
1785
+ this.eachElem(node => {
1786
+ observer.next(node);
1787
+ });
1788
+ } catch (e) {
1789
+ observer.error(e);
1790
+ }
1791
+ };
1792
+ return new Observable(observerFunc);
1793
+ }*/
1794
+ createSourceNode(src, nonce) {
1795
+ let srcNode = document.createElement("script");
1796
+ srcNode.type = "text/javascript";
1797
+ if (!!nonce) {
1798
+ if ('undefined' != typeof (srcNode === null || srcNode === void 0 ? void 0 : srcNode.nonce)) {
1799
+ srcNode.nonce = nonce;
1800
+ }
1801
+ else {
1802
+ srcNode.setAttribute("nonce", nonce);
1803
+ }
1804
+ }
1805
+ srcNode.src = src;
1806
+ return srcNode;
1807
+ }
1784
1808
  }
1785
1809
  exports.DomQuery = DomQuery;
1786
1810
  DomQuery.absent = new DomQuery();
@@ -5497,7 +5521,51 @@ class ExtDomquery extends mona_dish_1.DQ {
5497
5521
  var _a;
5498
5522
  return ((_a = whilteListed === null || whilteListed === void 0 ? void 0 : whilteListed(src)) !== null && _a !== void 0 ? _a : true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
5499
5523
  };
5500
- return super.runScripts(false, whitelistFunc);
5524
+ return super.runScripts(sticky, whitelistFunc);
5525
+ }
5526
+ /**
5527
+ * adds the elements in this ExtDomQuery to the head
5528
+ *
5529
+ * @param newElements the elements which need addition
5530
+ */
5531
+ runHeadInserts(suppressDoubleIncludes = true) {
5532
+ let head = ExtDomquery.byId(document.head);
5533
+ //automated nonce handling
5534
+ let processedScripts = [];
5535
+ // the idea is only to run head inserts on resources
5536
+ // which do not exist already, that way
5537
+ // we can avoid double includes on subsequent resource
5538
+ // requests.
5539
+ function resourceIsNew(element) {
5540
+ if (!suppressDoubleIncludes) {
5541
+ return true;
5542
+ }
5543
+ const tagName = element.tagName.value;
5544
+ if (!tagName) {
5545
+ // textnode
5546
+ return true;
5547
+ }
5548
+ let href = element.attr("href").orElse(element.attr("src").value);
5549
+ if (!href.isPresent()) {
5550
+ return true;
5551
+ }
5552
+ return !head.querySelectorAll(`${tagName}[href='${href.value}']`).length &&
5553
+ !head.querySelectorAll(`${tagName}[src='${href.value}']`).length;
5554
+ }
5555
+ this
5556
+ .filter(resourceIsNew)
5557
+ .each(element => {
5558
+ if (element.tagName.value != "SCRIPT") {
5559
+ //we need to run runScripts properly to deal with the rest
5560
+ new ExtDomquery(...processedScripts).runScripts(true);
5561
+ processedScripts = [];
5562
+ head.append(element);
5563
+ }
5564
+ else {
5565
+ processedScripts.push(element);
5566
+ }
5567
+ });
5568
+ new ExtDomquery(...processedScripts).runScripts(true);
5501
5569
  }
5502
5570
  /**
5503
5571
  * byId producer
@@ -6633,7 +6701,7 @@ class ResponseProcessor {
6633
6701
  globalEval() {
6634
6702
  // phase one, if we have head inserts, we build up those before going into the script eval phase
6635
6703
  let insertHeadElems = new ExtDomQuery_1.ExtDomquery(...this.internalContext.getIf(Const_1.DEFERRED_HEAD_INSERTS).value);
6636
- this.runHeadInserts(insertHeadElems);
6704
+ insertHeadElems.runHeadInserts(true);
6637
6705
  // phase 2 we run a script eval on all updated elements in the body
6638
6706
  let updateElems = new ExtDomQuery_1.ExtDomquery(...this.internalContext.getIf(Const_1.UPDATE_ELEMS).value);
6639
6707
  updateElems.runCss();
@@ -6783,28 +6851,6 @@ class ResponseProcessor {
6783
6851
  triggerOnError(errorData) {
6784
6852
  this.externalContext.getIf(Const_1.ON_ERROR).orElse(this.internalContext.getIf(Const_1.ON_ERROR).value).orElse(Const_1.EMPTY_FUNC).value(errorData);
6785
6853
  }
6786
- /**
6787
- * adds new elements to the head as per spec, we use it in a deferred way
6788
- * to have the html buildup first then the head inserts which run the head evals
6789
- * and then the body and css evals from the markup
6790
- *
6791
- * This is only performed upon a head replacement or resource insert
6792
- *
6793
- * @param newElements the elements which need addition
6794
- */
6795
- runHeadInserts(newElements) {
6796
- let head = ExtDomQuery_1.ExtDomquery.byId(document.head);
6797
- //automated nonce handling
6798
- newElements.each(element => {
6799
- if (element.tagName.value != "SCRIPT" || element.attr("src").isPresent()) {
6800
- head.append(element);
6801
- return;
6802
- }
6803
- // special corner case
6804
- // embedded script code,
6805
- element.globalEvalSticky(element.innerHTML);
6806
- });
6807
- }
6808
6854
  }
6809
6855
  exports.ResponseProcessor = ResponseProcessor;
6810
6856
 
Binary file
Binary file