jsf.js_next_gen 4.0.2-beta.3 → 4.0.2-beta.5
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.
- package/dist/window/faces-development.js +26 -11
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +26 -11
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.map +1 -1
- package/package.json +7 -8
- package/src/main/typescript/impl/util/FileUtils.ts +3 -2
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +24 -10
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +28 -0
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +201 -2
- package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
- package/target/impl/util/FileUtils.js +3 -2
- package/target/impl/util/FileUtils.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +23 -9
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +26 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +176 -1
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test-classes/.gz +0 -0
- package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
- package/target/test-classes/fileuploadtest.html +24 -0
- package/target/test-classes/jsf-development.js +3559 -0
- package/target/test-classes/jsf-development.js.br +0 -0
- package/target/test-classes/jsf-development.js.gz +0 -0
- package/target/test-classes/jsf-development.js.map +1 -0
- package/target/test-classes/jsf.js +3 -0
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
- package/webpack.config.ts +1 -23
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/webpack.config.js +0 -71
- package/webpack.config.js.map +0 -1
|
@@ -0,0 +1,3559 @@
|
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ var __webpack_modules__ = ({
|
|
3
|
+
|
|
4
|
+
/***/ "./node_modules/mona-dish/dist/js/commonjs/index_core.js":
|
|
5
|
+
/*!***************************************************************!*\
|
|
6
|
+
!*** ./node_modules/mona-dish/dist/js/commonjs/index_core.js ***!
|
|
7
|
+
\***************************************************************/
|
|
8
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
9
|
+
|
|
10
|
+
!function(){"use strict";var t={585:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function l(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,l)}u((n=n.apply(t,e||[])).next())}))},l=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},u=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},s=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},c=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.DQ=e.DomQueryCollector=e.DomQuery=e.ElementAttribute=void 0;var f,p=r(152),h=r(551),y=r(255),d=r(805),v=d.Lang.trim,m=d.Lang.objToArray,b=d.Lang.isString,g=d.Lang.equalsIgnoreCase;function S(t,e,r){return void 0===r&&(r={attributes:!0,childList:!0,subtree:!0,timeout:500,interval:100}),new Promise((function(n,o){var a=new Error("Mutation observer timeout");if(void 0!==window.MutationObserver){var l=setTimeout((function(){return o(a)}),r.timeout),u=new window.MutationObserver((function(t,r){var o=new x(t.map((function(t){return t.target}))).first(e);o.isPresent()&&(clearTimeout(l),n(o))})),s=i({},r);delete s.timeout,t.eachElem((function(t){u.observe(t,s)}))}else var c=setInterval((function(){var o=null;(o=r.childList?e(t)?t:t.childNodes.first(e):r.subtree?e(t)?t:t.querySelectorAll(" * ").first(e):e(t)?t:x.absent).isPresent()&&f&&(clearTimeout(f),clearInterval(c),c=null,n(o))}),r.interval),f=setTimeout((function(){c&&(clearInterval(c),o(a))}),r.timeout)}))}!function(t){t.SELECT="select",t.BUTTON="button",t.SUBMIT="submit",t.RESET="reset",t.IMAGE="image",t.RADIO="radio",t.CHECKBOX="checkbox"}(f||(f={}));var A=function(t){function e(e,r,n){void 0===n&&(n=null);var o=t.call(this,e,r)||this;return o.element=e,o.name=r,o.defaultVal=n,o}return o(e,t),Object.defineProperty(e.prototype,"value",{get:function(){var t,e=(t=this.element.get(0)).orElse.apply(t,[]).values;return e.length?e[0].getAttribute(this.name):this.defaultVal},set:function(t){for(var e,r=(e=this.element.get(0)).orElse.apply(e,[]).values,n=0;n<r.length;n++)r[n].setAttribute(this.name,t);r[0].setAttribute(this.name,t)},enumerable:!1,configurable:!0}),e.prototype.getClass=function(){return e},e.fromNullable=function(t,r){return void 0===r&&(r="value"),new e(t,r)},e}(p.ValueEmbedder);e.ElementAttribute=A;var w=function(t){return-1==t.indexOf("ln=scripts")&&-1==t.indexOf("ln=javax.faces")||-1==t.indexOf("/jsf.js")&&-1==t.indexOf("/jsf-uncompressed.js")},x=function(){function t(){for(var e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(this.rootNode=[],this.pos=-1,this._limits=-1,!p.Optional.fromNullable(r).isAbsent()&&r.length)for(var o=0;o<r.length;o++)if(b(r[o])){var i=t.querySelectorAll(r[o]);i.isAbsent()||r.push.apply(r,s([],u(i.values),!1))}else r[o]instanceof t?(e=this.rootNode).push.apply(e,s([],u(r[o].values),!1)):this.rootNode.push(r[o])}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getAsElem(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"values",{get:function(){return this.allElems()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return new A(this.get(0),"id")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.rootNode.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.getAsElem(0).getIf("tagName")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nodeName",{get:function(){return this.getAsElem(0).getIf("nodeName")},enumerable:!1,configurable:!0}),t.prototype.isTag=function(t){return!this.isAbsent()&&(this.nodeName.orElse("__none___").value.toLowerCase()==t.toLowerCase()||this.tagName.orElse("__none___").value.toLowerCase()==t.toLowerCase())},Object.defineProperty(t.prototype,"type",{get:function(){return this.getAsElem(0).getIf("type")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return new p.ValueEmbedder(this.getAsElem(0).value,"name")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputValue",{get:function(){return this.getAsElem(0).getIf("value").isPresent()?new p.ValueEmbedder(this.getAsElem(0).value):p.ValueEmbedder.absent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checked",{get:function(){return h.Stream.of.apply(h.Stream,s([],u(this.values),!1)).allMatch((function(t){return!!t.checked}))},set:function(t){this.eachElem((function(e){return e.checked=t}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"elements",{get:function(){return this.querySelectorAll("input, checkbox, select, textarea, fieldset")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deepElements",{get:function(){return this.querySelectorAllDeep("input, select, textarea, checkbox, fieldset")},enumerable:!1,configurable:!0}),t.prototype.querySelectorAllDeep=function(e){var r=[],n=this.querySelectorAll(e);n.length&&r.push(n);var o=this.querySelectorAll("*").shadowRoot;if(o.length){var i=o.querySelectorAllDeep(e);i.length&&r.push(i)}return new(t.bind.apply(t,s([void 0],u(r),!1)))},Object.defineProperty(t.prototype,"disabled",{get:function(){return this.attr("disabled").isPresent()},set:function(t){t?this.attr("disabled").value="disabled":this.removeAttribute("disabled")},enumerable:!1,configurable:!0}),t.prototype.removeAttribute=function(t){this.eachElem((function(e){return e.removeAttribute(t)}))},Object.defineProperty(t.prototype,"childNodes",{get:function(){var e=[];return this.eachElem((function(t){e=e.concat(m(t.childNodes))})),new(t.bind.apply(t,s([void 0],u(e),!1)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stream",{get:function(){return new(h.Stream.bind.apply(h.Stream,s([void 0],u(this.asArray),!1)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lazyStream",{get:function(){return h.LazyStream.of.apply(h.LazyStream,s([],u(this.asArray),!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"asArray",{get:function(){return[].concat(h.LazyStream.of.apply(h.LazyStream,s([],u(this.rootNode),!1)).filter((function(t){return null!=t})).map((function(e){return t.byId(e)})).collect(new y.ArrayCollector))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"asNodeArray",{get:function(){return[].concat(h.Stream.of(this.rootNode).filter((function(t){return null!=t})).collect(new y.ArrayCollector))},enumerable:!1,configurable:!0}),t.querySelectorAllDeep=function(e){return new t(document).querySelectorAllDeep(e)},t.querySelectorAll=function(e){return-1!=e.indexOf("/shadow/")?new t(document)._querySelectorAllDeep(e):new t(document)._querySelectorAll(e)},t.byId=function(e,r){return void 0===r&&(r=!1),b(e)?r?new t(document).byIdDeep(e):new t(document).byId(e):new t(e)},t.byTagName=function(e){return b(e)?new t(document).byTagName(e):new t(e)},t.globalEval=function(e,r){return new t(document).globalEval(e,r)},t.fromMarkup=function(e){var r=document.implementation.createHTMLDocument(""),n=(e=v(e)).toLowerCase();if(-1!=n.indexOf("<!doctype")||-1!=n.indexOf("<html")||-1!=n.indexOf("<head")||-1!=n.indexOf("<body"))return r.documentElement.innerHTML=e,new t(r.documentElement);var o=function(t,e){var r=["<",e,">"].join(""),n=["<",e," "].join("");return 0==t.indexOf(r)||0==t.indexOf(n)},i=new t(document.createElement("div"));return o(n,"thead")||o(n,"tbody")?(i.html("<table>".concat(e,"</table>")),i.querySelectorAll("table").get(0).childNodes.detach()):o(n,"tfoot")?(i.html("<table><thead></thead><tbody><tbody".concat(e,"</table>")),i.querySelectorAll("table").get(2).childNodes.detach()):o(n,"tr")?(i.html("<table><tbody>".concat(e,"</tbody></table>")),i.querySelectorAll("tbody").get(0).childNodes.detach()):o(n,"td")?(i.html("<table><tbody><tr>".concat(e,"</tr></tbody></table>")),i.querySelectorAll("tr").get(0).childNodes.detach()):(i.html(e),i.childNodes.detach())},t.prototype.get=function(e){return e<this.rootNode.length?new t(this.rootNode[e]):t.absent},t.prototype.getAsElem=function(t,e){return void 0===e&&(e=p.Optional.absent),t<this.rootNode.length?p.Optional.fromNullable(this.rootNode[t]):e},t.prototype.filesFromElem=function(t){var e;return t<this.rootNode.length&&(null===(e=this.rootNode[t])||void 0===e?void 0:e.files)?this.rootNode[t].files:[]},t.prototype.allElems=function(){return this.rootNode},t.prototype.isAbsent=function(){return 0==this.length},t.prototype.isPresent=function(t){var e=this.isAbsent();return!e&&t&&t.call(this,this),!e},t.prototype.ifPresentLazy=function(t){return void 0===t&&(t=function(){}),this.isPresent.call(this,t),this},t.prototype.delete=function(){this.eachElem((function(t){t.parentNode&&t.parentNode.removeChild(t)}))},t.prototype.querySelectorAll=function(t){return-1!=t.indexOf("/shadow/")?this._querySelectorAllDeep(t):this._querySelectorAll(t)},t.prototype._querySelectorAll=function(e){var r,n;if(!(null===(r=null==this?void 0:this.rootNode)||void 0===r?void 0:r.length))return this;for(var o=[],i=0;i<this.rootNode.length;i++)if(null===(n=this.rootNode[i])||void 0===n?void 0:n.querySelectorAll){var a=this.rootNode[i].querySelectorAll(e);o=o.concat(m(a))}return new(t.bind.apply(t,s([void 0],u(o),!1)))},t.prototype._querySelectorAllDeep=function(e){var r;if(!(null===(r=null==this?void 0:this.rootNode)||void 0===r?void 0:r.length))return this;for(var n=new(t.bind.apply(t,s([void 0],u(this.rootNode),!1))),o=e.split(/\/shadow\//),i=0;i<o.length;i++)if(""!=o[i]){var a=o[i];n=n.querySelectorAll(a),i<o.length-1&&(n=n.shadowRoot)}return n},t.prototype.byId=function(e,r){var n=[];return r&&(n=n.concat(h.LazyStream.of.apply(h.LazyStream,s([],u((null==this?void 0:this.rootNode)||[]),!1)).filter((function(t){return e==t.id})).map((function(e){return new t(e)})).collect(new y.ArrayCollector))),n=n.concat(this.querySelectorAll('[id="'.concat(e,'"]'))),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.byIdDeep=function(e,r){var n=[];r&&(n=n.concat(h.LazyStream.of.apply(h.LazyStream,s([],u((null==this?void 0:this.rootNode)||[]),!1)).filter((function(t){return e==t.id})).map((function(e){return new t(e)})).collect(new y.ArrayCollector)));var o=this.querySelectorAllDeep('[id="'.concat(e,'"]'));return o.length&&n.push(o),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.byTagName=function(e,r,n){var o,i=[];return r&&(i=h.LazyStream.of.apply(h.LazyStream,s([],u(null!==(o=null==this?void 0:this.rootNode)&&void 0!==o?o:[]),!1)).filter((function(t){return(null==t?void 0:t.tagName)==e})).reduce((function(t,e){return t.concat([e])}),i).orElse(i).value),n?i.push(this.querySelectorAllDeep(e)):i.push(this.querySelectorAll(e)),new(t.bind.apply(t,s([void 0],u(i),!1)))},t.prototype.attr=function(t,e){return void 0===e&&(e=null),new A(this,t,e)},t.prototype.hasClass=function(t){var e=!1;return this.eachElem((function(r){if(e=r.classList.contains(t))return!1})),e},t.prototype.addClass=function(t){return this.eachElem((function(e){return e.classList.add(t)})),this},t.prototype.removeClass=function(t){return this.eachElem((function(e){return e.classList.remove(t)})),this},t.prototype.isMultipartCandidate=function(t){var e=this;void 0===t&&(t=!1);return this.stream.filter((function(r){return function(r){var n;return 0!=r.length&&(1==r.length?"input"==r.tagName.get("booga").value.toLowerCase()&&"file"==((null===(n=r.attr("type"))||void 0===n?void 0:n.value)||"").toLowerCase()||(t?e.querySelectorAllDeep("input[type='file']").firstElem().isPresent():e.querySelectorAll("input[type='file']").firstElem().isPresent()):r.isMultipartCandidate(t))}(r)})).first().isPresent()},t.prototype.html=function(t){return p.Optional.fromNullable(t).isAbsent()?this.isPresent()?p.Optional.fromNullable(this.innerHtml):p.Optional.absent:(this.innerHtml=t,this)},t.prototype.dispatchEvent=function(t){return this.eachElem((function(e){return e.dispatchEvent(t)})),this},Object.defineProperty(t.prototype,"innerHtml",{get:function(){var t=[];return this.eachElem((function(e){return t.push(e.innerHTML)})),t.join("")},set:function(t){this.eachElem((function(e){return e.innerHTML=t}))},enumerable:!1,configurable:!0}),t.prototype._mozMatchesSelector=function(t,e){var r=t,n=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector||function(e){for(var r=(document||window.ownerDocument).querySelectorAll(e),n=r.length;--n>=0&&r.item(n)!==t;);return n>-1};return n.call(t,e)},t.prototype.filterSelector=function(e){var r=this,n=[];return this.eachElem((function(t){r._mozMatchesSelector(t,e)&&n.push(t)})),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.matchesSelector=function(t){var e=this;return this.eachElem((function(r){if(!e._mozMatchesSelector(r,t))return!1})),!0},t.prototype.getIf=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=this.childNodes,n=0;n<t.length;n++)if((r=r.filterSelector(t[n])).isAbsent())return r;return r},t.prototype.eachElem=function(t){for(var e=0,r=this.rootNode.length;e<r&&!1!==t(this.rootNode[e],e);e++);return this},t.prototype.firstElem=function(t){return void 0===t&&(t=function(t){return t}),this.rootNode.length>1&&t(this.rootNode[0],0),this},t.prototype.each=function(e){return h.Stream.of.apply(h.Stream,s([],u(this.rootNode),!1)).each((function(r,n){if(null!=r)return e(t.byId(r),n)})),this},t.prototype.first=function(t){return void 0===t&&(t=function(t){return t}),this.rootNode.length>=1?(t(this.get(0),0),this.get(0)):this},t.prototype.filter=function(e){var r=[];return this.each((function(t){e(t)&&r.push(t)})),new(t.bind.apply(t,s([void 0],u(r),!1)))},t.prototype.globalEval=function(t,e){var r=document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("script");e&&n.setAttribute("nonce",e),n.type="text/javascript",n.innerHTML=t;var o=r.appendChild(n);return r.removeChild(o),this},t.prototype.detach=function(){return this.eachElem((function(t){t.parentNode.removeChild(t)})),this},t.prototype.appendTo=function(t){this.eachElem((function(e){t.getAsElem(0).orElseLazy((function(){return{appendChild:function(t){}}})).value.appendChild(e)}))},t.prototype.loadScriptEval=function(t,e,r){var n=this;void 0===e&&(e=0),void 0===r&&(r="utf-8");var o=new XMLHttpRequest;return o.open("GET",t,!1),r&&o.setRequestHeader("Content-Type","application/x-javascript; charset:"+r),o.send(null),o.onload=function(r){e?setTimeout((function(){n.globalEval(o.responseText+"\r\n//@ sourceURL="+t)}),e):n.globalEval(o.responseText.replace(/\n/g,"\r\n")+"\r\n//@ sourceURL="+t)},o.onerror=function(t){throw Error(t)},this},t.prototype.insertAfter=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.each((function(t){for(var r=t.getAsElem(0).value,n=r.parentNode,o=function(t){var o=r.nextSibling;e[t].eachElem((function(t){o?(n.insertBefore(t,o),r=o):n.appendChild(t)}))},i=0;i<e.length;i++)o(i)}));var n=[];return n.push(this),n=n.concat(e),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.insertBefore=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.each((function(t){for(var r=t.getAsElem(0).value,n=r.parentNode,o=0;o<e.length;o++)e[o].eachElem((function(t){n.insertBefore(t,r)}))}));var n=[];return n.push(this),n=n.concat(e),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.orElse=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this.isPresent()?this:new(t.bind.apply(t,s([void 0],u(e),!1)))},t.prototype.orElseLazy=function(e){return this.isPresent()?this:new t(e())},t.prototype.parents=function(e){var r=new Set,n=[],o=e.toLowerCase(),i=function(t){(t.tagName||"").toLowerCase()!=o||r.has(t)||(r.add(t),n.push(t))};return this.eachElem((function(t){for(var r;t.parentNode||t.host;)if(t=null!==(r=null==t?void 0:t.parentNode)&&void 0!==r?r:null==t?void 0:t.host,i(t),"form"==e&&n.length)return!1})),new(t.bind.apply(t,s([void 0],u(n),!1)))},t.prototype.copyAttrs=function(t){var e=this;return t.eachElem((function(t){var r,n,o=m(t.attributes);try{for(var i=c(o),a=i.next();!a.done;a=i.next()){var l=a.value,u=l.value,s=l.name;switch(s){case"id":e.id.value=u;break;case"disabled":e.resolveAttributeHolder("disabled").disabled=u;break;case"checked":e.resolveAttributeHolder("checked").checked=u;break;default:e.attr(s).value=u}}}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}})),this},t.prototype.resolveAttributeHolder=function(t){void 0===t&&(t="value");var e=[];return e[t]=null,t in this.getAsElem(0).value?this.getAsElem(0).value:e},t.prototype.outerHTML=function(e,r,n,o){var i;if(void 0===o&&(o=!1),!this.isAbsent()){var a=null===(i=null===document||void 0===document?void 0:document.activeElement)||void 0===i?void 0:i.id,l=a?t.getCaretPosition(document.activeElement):null,c=t.fromMarkup(e),f=[],p=this.getAsElem(0).value,h=c.get(0),y=p.parentNode,d=h.getAsElem(0).value;if(y.replaceChild(d,p),f.push(new t(d)),this.isAbsent())return this;var v=[];c.length>1&&(v=v.concat.apply(v,s([],u(c.values.slice(1)),!1)),f.push(t.byId(d).insertAfter(new(t.bind.apply(t,s([void 0],u(v),!1)))))),r&&this.runScripts(),n&&this.runCss();var m=t.byId(a);return a&&m.isPresent()&&null!=l&&void 0!==l&&m.eachElem((function(e){return t.setCaretPosition(e,l)})),c}},t.prototype.runScripts=function(e){var r=this;void 0===e&&(e=w);var n=[],o=g,i=function(t){var i=t.tagName,a=t.type||"";if(i&&o(i,"script")&&(""===a||o(a,"text/javascript")||o(a,"javascript")||o(a,"text/ecmascript")||o(a,"ecmascript"))){var l=t.getAttribute("src");if(void 0!==l&&null!=l&&l.length>0)e(l)&&(n.length&&(r.globalEval(n.join("\n")),n=[]),r.loadScriptEval(l,0,"UTF-8"));else{for(var u=v(t.text||t.innerText||t.innerHTML),s=!0;s;)s=!1,"\x3c!--"==u.substring(0,4)&&(u=u.substring(4),s=!0),"//\x3c!--"==u.substring(0,4)&&(u=u.substring(6),s=!0),"//<![CDATA["==u.substring(0,11)&&(u=u.substring(11),s=!0);n.push(u)}}};try{new t(this.filterSelector("script"),this.querySelectorAll("script")).stream.flatMap((function(t){return h.Stream.of(t.values)})).sort((function(t,e){return t.compareDocumentPosition(e)-3})).each((function(t){return i(t)})),n.length&&this.globalEval(n.join("\n"))}catch(t){window.console&&window.console.error&&console.error(t.message||t.description)}finally{i=null}return this},t.prototype.runCss=function(){var e=function(t,e){var r,n,o,i,a=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(a);var l=null!==(r=a.sheet)&&void 0!==r?r:a.styleSheet;a.setAttribute("rel",null!==(n=t.getAttribute("rel"))&&void 0!==n?n:"stylesheet"),a.setAttribute("type",null!==(o=t.getAttribute("type"))&&void 0!==o?o:"text/css"),null!==(i=null==l?void 0:l.cssText)&&void 0!==i&&i?l.cssText=e:a.appendChild(document.createTextNode(e))};return new t(this.filterSelector("link, style"),this.querySelectorAll("link, style")).stream.flatMap((function(t){return h.Stream.of(t.values)})).sort((function(t,e){return t.compareDocumentPosition(e)-3})).each((function(t){return function(t){var r=t.tagName;if(r&&g(r,"link")&&g(t.getAttribute("type"),"text/css"))e(t,"@import url('"+t.getAttribute("href")+"');");else if(r&&g(r,"style")&&g(t.getAttribute("type"),"text/css")){var n=[],o=Array.prototype.slice.call(t.childNodes);o?o.forEach((function(t){return n.push(t.innerHTML||t.data)})):t.innerHTML&&n.push(t.innerHTML),e(t,n.join(""))}}(t)})),this},t.prototype.click=function(){return this.fireEvent("click"),this},t.prototype.addEventListener=function(t,e,r){return this.eachElem((function(n){return n.addEventListener(t,e,r)})),this},t.prototype.removeEventListener=function(t,e,r){return this.eachElem((function(n){return n.removeEventListener(t,e,r)})),this},t.prototype.fireEvent=function(t){this.eachElem((function(e){var r;if(e.ownerDocument)r=e.ownerDocument;else{if(9!=e.nodeType)throw new Error("Invalid node passed to fireEvent: "+e.id);r=e}if(e.dispatchEvent){var n="";switch(t){case"click":case"mousedown":case"mouseup":n="MouseEvents";break;case"focus":case"change":case"blur":case"select":n="HTMLEvents";break;default:throw"fireEvent: Couldn't find an event class for event '"+t+"'."}var o=r.createEvent(n);o.initEvent(t,!0,!0),o.synthetic=!0,e.dispatchEvent(o)}else if(e.fireEvent){var i=r.createEventObject();i.synthetic=!0,e.fireEvent("on"+t,i)}}))},t.prototype.textContent=function(t){return void 0===t&&(t=""),this.stream.map((function(t){return t.getAsElem(0).orElseLazy((function(){return{textContent:""}})).value.textContent||""})).reduce((function(e,r){return e+t+r}),"").value},t.prototype.innerText=function(t){return void 0===t&&(t=""),this.stream.map((function(t){return t.getAsElem(0).orElseLazy((function(){return{innerText:""}})).value.innerText||""})).reduce((function(e,r){return[e,r].join(t)}),"").value},t.prototype.encodeFormElement=function(t){if(void 0===t&&(t=new p.Config({})),!this.name.isAbsent()){var e=t.shallowCopy;return this.each((function(t){var r,n;if(!t.name.isAbsent()){var o=t.name.value,i=t.tagName.orElse("__none__").value.toLowerCase(),a=t.type.orElse("__none__").value.toLowerCase();if(a=a.toLowerCase(),("input"==i||"textarea"==i||"select"==i)&&null!=o&&""!=o&&!t.disabled){if("select"==i){var l=t.getAsElem(0).value;if(l.selectedIndex>=0)for(var u=l.options.length,s=0;s<u;s++)if(l.options[s].selected){var c=l.options[s];e.append(o).value=null!=c.getAttribute("value")?c.value:c.text}}if(i!=f.SELECT&&a!=f.BUTTON&&a!=f.RESET&&a!=f.SUBMIT&&a!=f.IMAGE&&(a!=f.CHECKBOX&&a!=f.RADIO||t.checked)){var p=null!==(n=null===(r=t.value.value)||void 0===r?void 0:r.files)&&void 0!==n?n:[];(null==p?void 0:p.length)?e.append(o).value=p[0]:e.append(o).value=t.inputValue.value}}}})),e}},Object.defineProperty(t.prototype,"cDATAAsString",{get:function(){return this.lazyStream.flatMap((function(t){return t.childNodes.stream})).filter((function(t){var e,r;return 4==(null===(r=null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.value)||void 0===r?void 0:r.nodeType)})).reduce((function(t,e){var r,n,o;return t.push(null!==(o=null===(n=null===(r=null==e?void 0:e.value)||void 0===r?void 0:r.value)||void 0===n?void 0:n.data)&&void 0!==o?o:""),t}),[]).value.join("")},enumerable:!1,configurable:!0}),t.prototype.subNodes=function(e,r){return p.Optional.fromNullable(r).isAbsent()&&(r=this.length),new(t.bind.apply(t,s([void 0],u(this.rootNode.slice(e,Math.min(r,this.length))),!1)))},t.prototype.limits=function(t){return this._limits=t,this},t.prototype.hasNext=function(){var t=-1!=this._limits&&this.pos>=this._limits-1,e=this.pos>=this.values.length-1;return!(t||e)},t.prototype.next=function(){return this.hasNext()?(this.pos++,new t(this.values[this.pos])):null},t.prototype.reset=function(){this.pos=-1},t.prototype.attachShadow=function(e){void 0===e&&(e={mode:"open"});var r=[];return this.eachElem((function(n){var o;if(!(null==n?void 0:n.attachShadow))throw new Error("Shadow dom creation not supported by the browser, please use a shim, to gain this functionality");o=t.byId(n.attachShadow(e)),r.push(o)})),new(t.bind.apply(t,s([void 0],u(r),!1)))},t.prototype.waitUntilDom=function(t,e){return void 0===e&&(e={attributes:!0,childList:!0,subtree:!0,timeout:500,interval:100}),a(this,void 0,void 0,(function(){return l(this,(function(r){return[2,S(this,t,e)]}))}))},Object.defineProperty(t.prototype,"shadowElements",{get:function(){var e=(this.querySelectorAll("*").filter((function(t){return t.hasShadow})).allElems()||[]).map((function(t){return t.shadowRoot}));return new(t.bind.apply(t,s([void 0],u(e),!1)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowRoot",{get:function(){for(var e=[],r=0;r<this.rootNode.length;r++)this.rootNode[r].shadowRoot&&e.push(this.rootNode[r].shadowRoot);return new(t.bind.apply(t,s([void 0],u(e),!1)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasShadow",{get:function(){for(var t=0;t<this.rootNode.length;t++)if(this.rootNode[t].shadowRoot)return!0;return!1},enumerable:!1,configurable:!0}),t.getCaretPosition=function(t){var e=0;try{if(null===document||void 0===document?void 0:document.selection){t.focus();var r=document.selection.createRange();r.moveStart("character",-t.value.length),e=r.text.length}}catch(t){}return e},t.setCaretPosition=function(t,e){(null==t?void 0:t.focus)&&(null==t||t.focus()),(null==t?void 0:t.setSelectiongRange)&&(null==t||t.setSelectiongRange(e,e))},t.prototype[Symbol.iterator]=function(){var t=this;return{next:function(){return{done:!t.hasNext(),value:t.next()}}}},t.absent=new t,t}();e.DomQuery=x;var E=function(){function t(){this.data=[]}return t.prototype.collect=function(t){this.data.push(t)},Object.defineProperty(t.prototype,"finalValue",{get:function(){return new(x.bind.apply(x,s([void 0],u(this.data),!1)))},enumerable:!1,configurable:!0}),t}();e.DomQueryCollector=E,e.DQ=x},805:function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Lang=void 0;var n=r(152);!function(t){function e(t){for(var e=/\s/,r=(t=t.replace(/^\s\s*/,"")).length;e.test(t.charAt(--r)););return t.slice(0,r+1)}function r(t){return!!arguments.length&&null!=t&&("string"==typeof t||t instanceof String)}t.saveResolve=function(t,e){void 0===e&&(e=null);try{var r=t();return n.Optional.fromNullable(null!=r?r:e)}catch(t){return n.Optional.absent}},t.saveResolveLazy=function(t,e){void 0===e&&(e=null);try{var r=t();return n.Optional.fromNullable(null!=r?r:e())}catch(t){return n.Optional.absent}},t.strToArray=function(t,r){void 0===r&&(r=/\./gi);var n=[];return t.split(r).forEach((function(t){n.push(e(t))})),n},t.trim=e,t.objToArray=function(t,e,r){return void 0===e&&(e=0),void 0===r&&(r=[]),"__undefined__"==(null!=t?t:"__undefined__")?null!=r?r:null:t instanceof Array&&!e&&!r?t:r.concat(Array.prototype.slice.call(t,e))},t.equalsIgnoreCase=function(t,e){var r=null!=e?e:"___no_value__";return(null!=t?t:"___no_value__").toLowerCase()===r.toLowerCase()},t.assertType=function(t,e){return r(e)?typeof t==e:t instanceof e},t.isString=r,t.isFunc=function(t){return t instanceof Function||"function"==typeof t},t.objAssign=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(null==t)throw new TypeError("Cannot convert undefined or null to object");var n=Object(t);return Object.assign?(e.forEach((function(t){return Object.assign(n,t)})),n):(e.filter((function(t){return null!=t})).forEach((function(t){var e=t;Object.keys(e).filter((function(t){return Object.prototype.hasOwnProperty.call(e,t)})).forEach((function(t){return n[t]=e[t]}))})),n)}}(e.Lang||(e.Lang={}))},152:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.Config=e.ValueEmbedder=e.Optional=e.Monad=void 0;var l=r(805),u=r(255),s=r(551),c=l.Lang.objAssign,f=function(){function t(t){this._value=t}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),t.prototype.map=function(e){return e||(e=function(t){return t}),new t(e(this.value))},t.prototype.flatMap=function(e){for(var r=this.map(e);(null==r?void 0:r.value)instanceof t;)r=r.value;return r},t}();e.Monad=f;var p=function(t){function e(e){return t.call(this,e)||this}return o(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this._value instanceof f?this._value.flatMap().value:this._value},enumerable:!1,configurable:!0}),e.fromNullable=function(t){return new e(t)},e.prototype.isAbsent=function(){return void 0===this.value||null==this.value},e.prototype.isPresent=function(t){var e=this.isAbsent();return!e&&t&&t.call(this,this),!e},e.prototype.ifPresentLazy=function(t){return void 0===t&&(t=function(){}),this.isPresent.call(this,t),this},e.prototype.orElse=function(t){return this.isPresent()?this:null==t?e.absent:this.flatMap((function(){return t}))},e.prototype.orElseLazy=function(t){return this.isPresent()?this:this.flatMap(t)},e.prototype.flatMap=function(r){var n=t.prototype.flatMap.call(this,r);return n instanceof e?n.flatMap():e.fromNullable(n.value)},e.prototype.getIf=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=this,n=0;n<t.length;n++){var o=this.keyVal(t[n]),i=this.arrayIndex(t[n]);if(""===o&&i>=0){if((r=this.getClass().fromNullable(r.value instanceof Array?r.value.length<i?null:r.value[i]:null)).isAbsent())return r}else if(o&&i>=0){if(r.getIfPresent(o).isAbsent())return r;if((r=r.getIfPresent(o).value instanceof Array?this.getClass().fromNullable(r.getIfPresent(o).value[i]):this.getClass().absent).isAbsent())return r}else{if((r=r.getIfPresent(o)).isAbsent())return r;i>-1&&(r=this.getClass().fromNullable(r.value[i]))}}return r},e.prototype.match=function(t){return!this.isAbsent()&&t(this.value)},e.prototype.get=function(t){return void 0===t&&(t=e.absent),this.isAbsent()?this.getClass().fromNullable(t).flatMap():this.getClass().fromNullable(this.value).flatMap()},e.prototype.toJson=function(){return JSON.stringify(this.value)},e.prototype.getClass=function(){return e},e.prototype.arrayIndex=function(t){var e=t.indexOf("["),r=t.indexOf("]");return e>=0&&r>0&&e<r?parseInt(t.substring(e+1,r)):-1},e.prototype.keyVal=function(t){var e=t.indexOf("[");return e>=0?t.substring(0,e):t},e.prototype.getIfPresent=function(t){return this.isAbsent()?this.getClass().absent:this.getClass().fromNullable(this.value[t]).flatMap()},e.prototype.resolve=function(t){if(this.isAbsent())return e.absent;try{return e.fromNullable(t(this.value))}catch(t){return e.absent}},e.absent=e.fromNullable(null),e}(f);e.Optional=p;var h=function(t){function e(e,r){void 0===r&&(r="value");var n=t.call(this,e)||this;return n.key=r,n}return o(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this._value?this._value[this.key]:null},set:function(t){this._value&&(this._value[this.key]=t)},enumerable:!1,configurable:!0}),e.prototype.orElse=function(t){var r={};return r[this.key]=t,this.isPresent()?this:new e(r,this.key)},e.prototype.orElseLazy=function(t){if(this.isPresent())return this;var r={};return r[this.key]=t(),new e(r,this.key)},e.prototype.getClass=function(){return e},e.fromNullable=function(t,r){return void 0===r&&(r="value"),new e(t,r)},e.absent=e.fromNullable(null),e}(p);e.ValueEmbedder=h;var y=function(t){function e(e,r,n){var o=t.call(this,e,r)||this;return o.arrPos=null!=n?n:-1,o}return o(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return""==this.key&&this.arrPos>=0?this._value[this.arrPos]:this.key&&this.arrPos>=0?this._value[this.key][this.arrPos]:this._value[this.key]},set:function(t){""==this.key&&this.arrPos>=0?this._value[this.arrPos]=t:this.key&&this.arrPos>=0?this._value[this.key][this.arrPos]=t:this._value[this.key]=t},enumerable:!1,configurable:!0}),e.absent=e.fromNullable(null),e}(h),d=function(t){function e(e){return t.call(this,e)||this}return o(e,t),Object.defineProperty(e.prototype,"shallowCopy",{get:function(){return new e(s.Stream.ofAssoc(this.value).collect(new u.AssocArrayCollector))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deepCopy",{get:function(){return new e(c({},this.value))},enumerable:!1,configurable:!0}),e.fromNullable=function(t){return new e(t)},e.prototype.shallowMerge=function(t,e,r){var n=this;void 0===e&&(e=!0),void 0===r&&(r=!1);var o=function(o){!e&&o in l.value||(r?Array.isArray(t.getIf(o).value)?s.Stream.of.apply(s.Stream,a([],i(t.getIf(o).value),!1)).each((function(t){return n.append(o).value=t})):l.append(o).value=t.getIf(o).value:l.assign(o).value=t.getIf(o).value)},l=this;for(var u in t.value)o(u)},e.prototype.append=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.length<1;if(!r){var n=t[t.length-1],o=(this.keyVal(n),this.getIf.apply(this,a([],i(t),!1)).isPresent());this.buildPath(t);var l=this.arrayIndex(n);if(l>-1)throw Error("Append only possible on non array properties, use assign on indexed data");var u=this.getIf.apply(this,a([],i(t),!1)).value;Array.isArray(u)||(u=this.assign.apply(this,a([],i(t),!1)).value=[u]),o&&u.push({}),l=u.length-1;var s=new y(1==t.length?this.value:this.getIf.apply(this,t.slice(0,t.length-1)).value,n,l);return s}},e.prototype.appendIf=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return t?this.append.apply(this,a([],i(e),!1)):{value:null}},e.prototype.assign=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!(t.length<1)){this.buildPath(t);var r=this.keyVal(t[t.length-1]),n=this.arrayIndex(t[t.length-1]),o=new y(1==t.length?this.value:this.getIf.apply(this,t.slice(0,t.length-1)).value,r,n);return o}},e.prototype.assignIf=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return t?this.assign.apply(this,a([],i(e),!1)):{value:null}},e.prototype.getIf=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this.getClass().fromNullable(t.prototype.getIf.apply(this,e).value)},e.prototype.get=function(e){return this.getClass().fromNullable(t.prototype.get.call(this,e).value)},e.prototype.delete=function(t){return t in this.value&&delete this.value[t],this},e.prototype.toJson=function(){return JSON.stringify(this.value)},e.prototype.getClass=function(){return e},e.prototype.setVal=function(t){this._value=t},e.prototype.buildPath=function(t){for(var e=this,r=this.getClass().fromNullable(null),n=-1,o=function(t,e){for(var r=t.length,n=r+e,o=r;o<n;o++)t.push({})},i=0;i<t.length;i++){var a=this.keyVal(t[i]),l=this.arrayIndex(t[i]);if(""===a&&l>=0)e.setVal(e.value instanceof Array?e.value:[]),o(e.value,l+1),n>=0&&(r.value[n]=e.value),r=e,n=l,e=this.getClass().fromNullable(e.value[l]);else{var u=e.getIf(a);if(-1==l)u.isAbsent()?u=this.getClass().fromNullable(e.value[a]={}):e=u;else{var s=u.value instanceof Array?u.value:[];o(s,l+1),e.value[a]=s,u=this.getClass().fromNullable(s[l])}r=e,n=l,e=u}}return this},e}(p);e.Config=d},255:function(t,e,r){var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.QueryFormStringCollector=e.QueryFormDataCollector=e.FormDataCollector=e.AssocArrayCollector=e.Run=e.ArrayAssocArrayCollector=e.ArrayCollector=e.FlatMapStreamDataSource=e.MappedStreamDataSource=e.FilteredStreamDatasource=e.ArrayStreamDataSource=e.SequenceDataSource=void 0;var i=r(551),a=function(){function t(t,e){this.total=e,this.start=t,this.value=t}return t.prototype.hasNext=function(){return this.value<this.total},t.prototype.next=function(){return Math.min(this.value++,this.total-1)},t.prototype.reset=function(){this.value=0},t}();e.SequenceDataSource=a;var l=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.dataPos=-1,this.value=t}return t.prototype.hasNext=function(){return this.value.length-1>this.dataPos},t.prototype.next=function(){return this.dataPos++,this.value[this.dataPos]},t.prototype.reset=function(){this.dataPos=-1},t}();e.ArrayStreamDataSource=l;var u=function(){function t(t,e){this.filteredNext=null,this.filterFunc=t,this.inputDataSource=e}return t.prototype.hasNext=function(){for(;null==this.filteredNext&&this.inputDataSource.hasNext();){var t=this.inputDataSource.next();if(this.filterFunc(t))return this.filteredNext=t,!0;this.filteredNext=null}return null!=this.filteredNext},t.prototype.next=function(){var t=this.filteredNext;return this.filteredNext=null,this.hasNext(),t},t.prototype.reset=function(){this.filteredNext=null,this.inputDataSource.reset()},t}();e.FilteredStreamDatasource=u;var s=function(){function t(t,e){this.mapFunc=t,this.inputDataSource=e}return t.prototype.hasNext=function(){return this.inputDataSource.hasNext()},t.prototype.next=function(){return this.mapFunc(this.inputDataSource.next())},t.prototype.reset=function(){this.inputDataSource.reset()},t}();e.MappedStreamDataSource=s;var c=function(){function t(t,e){this.mapFunc=t,this.inputDataSource=e}return t.prototype.hasNext=function(){return this.resolveCurrentNext()||this.resolveNextNext()},t.prototype.resolveCurrentNext=function(){var t=!1;return this.activeDataSource&&(t=this.activeDataSource.hasNext()),t},t.prototype.resolveNextNext=function(){for(var t=!1;!t&&this.inputDataSource.hasNext();){var e=this.mapFunc(this.inputDataSource.next());Array.isArray(e)?this.activeDataSource=new(l.bind.apply(l,o([void 0],n(e),!1))):this.activeDataSource=e,t=this.activeDataSource.hasNext()}return t},t.prototype.next=function(){return this.activeDataSource.next()},t.prototype.reset=function(){this.inputDataSource.reset()},t}();e.FlatMapStreamDataSource=c;var f=function(){function t(){this.data=[]}return t.prototype.collect=function(t){this.data.push(t)},Object.defineProperty(t.prototype,"finalValue",{get:function(){return this.data},enumerable:!1,configurable:!0}),t}();e.ArrayCollector=f;var p=function(){function t(){this.finalValue={}}return t.prototype.collect=function(t){var e,r,n,o,i=null!==(e=null==t?void 0:t[0])&&void 0!==e?e:t;this.finalValue[i]=null!==(n=null===(r=this.finalValue)||void 0===r?void 0:r[i])&&void 0!==n?n:[],this.finalValue[i].push(null===(o=null==t?void 0:t[1])||void 0===o||o)},t}();e.ArrayAssocArrayCollector=p;var h=function(){function t(){}return t.prototype.collect=function(t){},Object.defineProperty(t.prototype,"finalValue",{get:function(){return null},enumerable:!1,configurable:!0}),t}();e.Run=h;var y=function(){function t(){this.finalValue={}}return t.prototype.collect=function(t){var e,r;this.finalValue[null!==(e=t[0])&&void 0!==e?e:t]=null===(r=t[1])||void 0===r||r},t}();e.AssocArrayCollector=y;var d=function(){function t(){this.finalValue=new FormData}return t.prototype.collect=function(t){this.finalValue.append(t.key,t.value)},t}();e.FormDataCollector=d;var v=function(){function t(){this.finalValue=new FormData}return t.prototype.collect=function(t){var e=t.encodeFormElement();e.isPresent()&&this.finalValue.append(t.name.value,e.get(t.name).value)},t}();e.QueryFormDataCollector=v;var m=function(){function t(){this.formData=[]}return t.prototype.collect=function(t){var e=t.encodeFormElement();e.isPresent()&&this.formData.push([t.name.value,e.get(t.name).value])},Object.defineProperty(t.prototype,"finalValue",{get:function(){return i.Stream.of.apply(i.Stream,o([],n(this.formData),!1)).map((function(t){return t.join("=")})).reduce((function(t,e){return[t,e].join("&")})).orElse("").value},enumerable:!1,configurable:!0}),t}();e.QueryFormStringCollector=m},551:function(t,e,r){var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.LazyStream=e.Stream=void 0;var i=r(152),a=r(255),l=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._limits=-1,this.pos=-1,this.value=t}return t.of=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new(t.bind.apply(t,o([void 0],n(e),!1)))},t.ofAssoc=function(t){return this.of.apply(this,o([],n(Object.keys(t)),!1)).map((function(e){return[e,t[e]]}))},t.ofDataSource=function(e){for(var r=[];e.hasNext();)r.push(e.next());return new(t.bind.apply(t,o([void 0],n(r),!1)))},t.prototype.limits=function(t){return this._limits=t,this},t.prototype.concat=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.of.apply(t,o([this],n(e),!1)).flatMap((function(t){return t}))},t.prototype.onElem=function(t){for(var e=0;e<this.value.length&&(-1==this._limits||e<this._limits)&&!1!==t(this.value[e],e);e++);return this},t.prototype.each=function(t){this.onElem(t)},t.prototype.map=function(e){e||(e=function(t){return t});var r=[];return this.each((function(t,n){r.push(e(t))})),new(t.bind.apply(t,o([void 0],n(r),!1)))},t.prototype.flatMap=function(e){var r=[];return this.each((function(t){var i=e(t);r=Array.isArray(i)?r.concat(i):r.concat.apply(r,o([],n(i.value),!1))})),t.of.apply(t,o([],n(r),!1))},t.prototype.filter=function(e){var r=[];return this.each((function(t){e(t)&&r.push(t)})),new(t.bind.apply(t,o([void 0],n(r),!1)))},t.prototype.reduce=function(t,e){void 0===e&&(e=null);for(var r=null!=e?0:1,n=null!=e?e:this.value.length?this.value[0]:null,o=r;o<this.value.length&&(-1==this._limits||o<this._limits);o++)n=t(n,this.value[o]);return i.Optional.fromNullable(n)},t.prototype.first=function(){return this.value&&this.value.length?i.Optional.fromNullable(this.value[0]):i.Optional.absent},t.prototype.last=function(){var t=this._limits>0?Math.min(this._limits,this.value.length):this.value.length;return i.Optional.fromNullable(t?this.value[t-1]:null)},t.prototype.anyMatch=function(t){for(var e=0;e<this.value.length&&(-1==this._limits||e<this._limits);e++)if(t(this.value[e]))return!0;return!1},t.prototype.allMatch=function(t){if(!this.value.length)return!1;for(var e=0,r=0;r<this.value.length;r++)t(this.value[r])&&e++;return e==this.value.length},t.prototype.noneMatch=function(t){for(var e=0,r=0;r<this.value.length;r++)t(this.value[r])||e++;return e==this.value.length},t.prototype.sort=function(e){var r=this.value.slice().sort(e);return t.of.apply(t,o([],n(r),!1))},t.prototype.collect=function(t){return this.each((function(e){return t.collect(e)})),t.finalValue},t.prototype.hasNext=function(){var t=-1!=this._limits&&this.pos>=this._limits-1,e=this.pos>=this.value.length-1;return!(t||e)},t.prototype.next=function(){return this.hasNext()?(this.pos++,this.value[this.pos]):null},t.prototype[Symbol.iterator]=function(){var t=this;return{next:function(){return{done:!t.hasNext(),value:t.next()}}}},t.prototype.reset=function(){this.pos=-1},t}();e.Stream=l;var u=function(){function t(t){this._limits=-1,this.pos=-1,this.dataSource=t}return t.of=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new t(new(a.ArrayStreamDataSource.bind.apply(a.ArrayStreamDataSource,o([void 0],n(e),!1))))},t.ofAssoc=function(t){return this.of.apply(this,o([],n(Object.keys(t)),!1)).map((function(e){return[e,t[e]]}))},t.ofStreamDataSource=function(e){return new t(e)},t.prototype.hasNext=function(){return!this.isOverLimits()&&this.dataSource.hasNext()},t.prototype.next=function(){var t=this.dataSource.next();return this.pos++,t},t.prototype.reset=function(){this.dataSource.reset(),this.pos=0,this._limits=-1},t.prototype.concat=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.of.apply(t,o([this],n(e),!1)).flatMap((function(t){return t}))},t.prototype.nextFilter=function(t){if(this.hasNext()){var e=this.next();return t(e)?e:this.nextFilter(t)}return null},t.prototype.limits=function(t){return this._limits=t,this},t.prototype.collect=function(t){for(;this.hasNext();){var e=this.next();t.collect(e)}return t.finalValue},t.prototype.onElem=function(e){var r=this;return new t(new a.MappedStreamDataSource((function(t){return!1===e(t,r.pos)&&r.stop(),t}),this))},t.prototype.filter=function(e){return new t(new a.FilteredStreamDatasource(e,this))},t.prototype.map=function(e){return new t(new a.MappedStreamDataSource(e,this))},t.prototype.flatMap=function(e){return new t(new a.FlatMapStreamDataSource(e,this))},t.prototype.each=function(t){for(;this.hasNext();)!1===t(this.next())&&this.stop()},t.prototype.reduce=function(t,e){if(void 0===e&&(e=null),!this.hasNext())return i.Optional.absent;var r=null,n=null;if(null!=e)r=e,n=this.next();else{if(r=this.next(),!this.hasNext())return i.Optional.fromNullable(r);n=this.next()}for(r=t(r,n);this.hasNext();)r=t(r,n=this.next());return i.Optional.fromNullable(r)},t.prototype.last=function(){return this.hasNext()?this.reduce((function(t,e){return e})):i.Optional.absent},t.prototype.first=function(){return this.reset(),this.hasNext()?i.Optional.fromNullable(this.next()):i.Optional.absent},t.prototype.anyMatch=function(t){for(;this.hasNext();)if(t(this.next()))return!0;return!1},t.prototype.allMatch=function(t){for(;this.hasNext();)if(!t(this.next()))return!1;return!0},t.prototype.noneMatch=function(t){for(;this.hasNext();)if(t(this.next()))return!1;return!0},t.prototype.sort=function(e){var r=this.collect(new a.ArrayCollector);return r=r.sort(e),t.of.apply(t,o([],n(r),!1))},Object.defineProperty(t.prototype,"value",{get:function(){return this.collect(new a.ArrayCollector)},enumerable:!1,configurable:!0}),t.prototype[Symbol.iterator]=function(){var t=this;return{next:function(){return{done:!t.hasNext(),value:t.next()}}}},t.prototype.stop=function(){this.pos=this._limits+1e9},t.prototype.isOverLimits=function(){return-1!=this._limits&&this.pos>=this._limits-1},t}();e.LazyStream=u},121:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.XQ=e.XMLQuery=void 0;var i=r(805),a=r(585),l=i.Lang.isString,u=function(t){function e(e,r){void 0===r&&(r="text/xml");var n;return l(e)?t.call(this,null==(n=e)?null:i.Lang.saveResolveLazy((function(){return new window.DOMParser}),(function(){return(t=new ActiveXObject("Microsoft.XMLDOM")).async=!1,{parseFromString:function(e,r){return t.loadXML(e)}};var t})).value.parseFromString(n,r))||this:t.call(this,e)||this}return o(e,t),e.prototype.isXMLParserError=function(){return this.querySelectorAll("parsererror").isPresent()},e.prototype.toString=function(){var t=[];return this.eachElem((function(e){var r,n,o,i=null!==(o=null===(n=null===(r=null===window||void 0===window?void 0:window.XMLSerializer)||void 0===r?void 0:r.constructor())||void 0===n?void 0:n.serializeToString(e))&&void 0!==o?o:null==e?void 0:e.xml;i&&t.push(i)})),t.join("")},e.prototype.parserErrorText=function(t){return this.querySelectorAll("parsererror").textContent(t)},e.parseXML=function(t){return new e(t)},e.parseHTML=function(t){return new e(t,"text/html")},e.fromString=function(t,r){return void 0===r&&(r="text/xml"),new e(t,r)},e}(a.DomQuery);e.XMLQuery=u,e.XQ=u}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}var n={};!function(){var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.QueryFormDataCollector=t.FormDataCollector=t.AssocArrayCollector=t.ArrayCollector=t.QueryFormStringCollector=t.SequenceDataSource=t.FlatMapStreamDataSource=t.FilteredStreamDatasource=t.MappedStreamDataSource=t.ArrayStreamDataSource=t.LazyStream=t.Stream=t.XQ=t.XMLQuery=t.ValueEmbedder=t.Optional=t.Monad=t.Config=t.Lang=t.DQ=t.DomQueryCollector=t.ElementAttribute=t.DomQuery=void 0;var e=r(585);Object.defineProperty(t,"DomQuery",{enumerable:!0,get:function(){return e.DomQuery}}),Object.defineProperty(t,"ElementAttribute",{enumerable:!0,get:function(){return e.ElementAttribute}}),Object.defineProperty(t,"DomQueryCollector",{enumerable:!0,get:function(){return e.DomQueryCollector}}),Object.defineProperty(t,"DQ",{enumerable:!0,get:function(){return e.DQ}});var o=r(805);Object.defineProperty(t,"Lang",{enumerable:!0,get:function(){return o.Lang}});var i=r(152);Object.defineProperty(t,"Config",{enumerable:!0,get:function(){return i.Config}}),Object.defineProperty(t,"Monad",{enumerable:!0,get:function(){return i.Monad}}),Object.defineProperty(t,"Optional",{enumerable:!0,get:function(){return i.Optional}}),Object.defineProperty(t,"ValueEmbedder",{enumerable:!0,get:function(){return i.ValueEmbedder}});var a=r(121);Object.defineProperty(t,"XMLQuery",{enumerable:!0,get:function(){return a.XMLQuery}}),Object.defineProperty(t,"XQ",{enumerable:!0,get:function(){return a.XQ}});var l=r(551);Object.defineProperty(t,"Stream",{enumerable:!0,get:function(){return l.Stream}}),Object.defineProperty(t,"LazyStream",{enumerable:!0,get:function(){return l.LazyStream}});var u=r(255);Object.defineProperty(t,"ArrayStreamDataSource",{enumerable:!0,get:function(){return u.ArrayStreamDataSource}}),Object.defineProperty(t,"MappedStreamDataSource",{enumerable:!0,get:function(){return u.MappedStreamDataSource}}),Object.defineProperty(t,"FilteredStreamDatasource",{enumerable:!0,get:function(){return u.FilteredStreamDatasource}}),Object.defineProperty(t,"FlatMapStreamDataSource",{enumerable:!0,get:function(){return u.FlatMapStreamDataSource}}),Object.defineProperty(t,"SequenceDataSource",{enumerable:!0,get:function(){return u.SequenceDataSource}}),Object.defineProperty(t,"QueryFormStringCollector",{enumerable:!0,get:function(){return u.QueryFormStringCollector}}),Object.defineProperty(t,"ArrayCollector",{enumerable:!0,get:function(){return u.ArrayCollector}}),Object.defineProperty(t,"AssocArrayCollector",{enumerable:!0,get:function(){return u.AssocArrayCollector}}),Object.defineProperty(t,"FormDataCollector",{enumerable:!0,get:function(){return u.FormDataCollector}}),Object.defineProperty(t,"QueryFormDataCollector",{enumerable:!0,get:function(){return u.QueryFormDataCollector}})}();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})}();
|
|
11
|
+
//# sourceMappingURL=index_core.js.map
|
|
12
|
+
|
|
13
|
+
/***/ }),
|
|
14
|
+
|
|
15
|
+
/***/ "./src/main/typescript/api/Jsf.ts":
|
|
16
|
+
/*!****************************************!*\
|
|
17
|
+
!*** ./src/main/typescript/api/_api.ts ***!
|
|
18
|
+
\****************************************/
|
|
19
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
20
|
+
|
|
21
|
+
"use strict";
|
|
22
|
+
|
|
23
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
24
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
25
|
+
* this work for additional information regarding copyright ownership.
|
|
26
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
27
|
+
* (the "License"); you may not use this file except in compliance with
|
|
28
|
+
* the License. You may obtain a copy of the License at
|
|
29
|
+
*
|
|
30
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
* See the License for the specific language governing permissions and
|
|
36
|
+
* limitations under the License.
|
|
37
|
+
*/
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
48
|
+
exports.myfaces = exports.jsf = void 0;
|
|
49
|
+
///<reference types='../../types/typedefs'/>
|
|
50
|
+
var AjaxImpl_1 = __webpack_require__(/*! ../impl/AjaxImpl */ "./src/main/typescript/impl/AjaxImpl.ts");
|
|
51
|
+
var PushImpl_1 = __webpack_require__(/*! ../impl/PushImpl */ "./src/main/typescript/impl/PushImpl.ts");
|
|
52
|
+
var jsf;
|
|
53
|
+
(function (jsf) {
|
|
54
|
+
"use strict";
|
|
55
|
+
/*
|
|
56
|
+
* Version of the implementation for the jsf.js.
|
|
57
|
+
* <p />
|
|
58
|
+
* as specified within the jsf specifications jsf.html:
|
|
59
|
+
* <ul>
|
|
60
|
+
* <li>left two digits major release number</li>
|
|
61
|
+
* <li>middle two digits minor spec release number</li>
|
|
62
|
+
* <li>right two digits bug release number</li>
|
|
63
|
+
* </ul>
|
|
64
|
+
* @constant
|
|
65
|
+
*/
|
|
66
|
+
jsf.specversion = 220000;
|
|
67
|
+
/**
|
|
68
|
+
* Implementation version as specified within the jsf specification.
|
|
69
|
+
* <p />
|
|
70
|
+
* A number increased with every implementation version
|
|
71
|
+
* and reset by moving to a new spec release number
|
|
72
|
+
*
|
|
73
|
+
* @constant
|
|
74
|
+
*/
|
|
75
|
+
jsf.implversion = 0;
|
|
76
|
+
/**
|
|
77
|
+
* SeparatorChar as defined by UINamingContainer.getNamingContainerSeparatorChar()
|
|
78
|
+
* @type {Char}
|
|
79
|
+
*/
|
|
80
|
+
jsf.separatorchar = getSeparatorChar();
|
|
81
|
+
/**
|
|
82
|
+
* This method is responsible for the return of a given project stage as defined
|
|
83
|
+
* by the jsf specification.
|
|
84
|
+
* <p/>
|
|
85
|
+
* Valid return values are:
|
|
86
|
+
* <ul>
|
|
87
|
+
* <li>"Production"</li>
|
|
88
|
+
* <li>"Development"</li>
|
|
89
|
+
* <li>"SystemTest"</li>
|
|
90
|
+
* <li>"UnitTest"</li>
|
|
91
|
+
* </li>
|
|
92
|
+
*
|
|
93
|
+
* @return {String} the current project state emitted by the server side method:
|
|
94
|
+
* <i>javax.faces.application.Application.getProjectStage()</i>
|
|
95
|
+
*/
|
|
96
|
+
function getProjectStage() {
|
|
97
|
+
return AjaxImpl_1.Implementation.getProjectStage();
|
|
98
|
+
}
|
|
99
|
+
jsf.getProjectStage = getProjectStage;
|
|
100
|
+
/**
|
|
101
|
+
* collect and encode data for a given form element (must be of type form)
|
|
102
|
+
* find the javax.faces.ViewState element and encode its value as well!
|
|
103
|
+
* return a concatenated string of the encoded values!
|
|
104
|
+
*
|
|
105
|
+
* @throws an exception in case of the given element not being of type form!
|
|
106
|
+
* https://issues.apache.org/jira/browse/MYFACES-2110
|
|
107
|
+
*/
|
|
108
|
+
function getViewState(formElement) {
|
|
109
|
+
return AjaxImpl_1.Implementation.getViewState(formElement);
|
|
110
|
+
}
|
|
111
|
+
jsf.getViewState = getViewState;
|
|
112
|
+
/**
|
|
113
|
+
* returns the window identifier for the given node / window
|
|
114
|
+
* @return the window identifier or null if none is found
|
|
115
|
+
* @param rootNode
|
|
116
|
+
*/
|
|
117
|
+
function getClientWindow(rootNode) {
|
|
118
|
+
return AjaxImpl_1.Implementation.getClientWindow(rootNode);
|
|
119
|
+
}
|
|
120
|
+
jsf.getClientWindow = getClientWindow;
|
|
121
|
+
//private helper functions
|
|
122
|
+
function getSeparatorChar() {
|
|
123
|
+
return AjaxImpl_1.Implementation.getSeparatorChar();
|
|
124
|
+
}
|
|
125
|
+
var ajax;
|
|
126
|
+
(function (ajax) {
|
|
127
|
+
"use strict";
|
|
128
|
+
/**
|
|
129
|
+
* this function has to send the ajax requests
|
|
130
|
+
*
|
|
131
|
+
* following requestInternal conditions must be met:
|
|
132
|
+
* <ul>
|
|
133
|
+
* <li> the requestInternal must be sent asynchronously! </li>
|
|
134
|
+
* <li> the requestInternal must be a POST!!! requestInternal </li>
|
|
135
|
+
* <li> the requestInternal url must be the form action attribute </li>
|
|
136
|
+
* <li> all requests must be queued with a client side requestInternal queue to ensure the requestInternal ordering!</li>
|
|
137
|
+
* </ul>
|
|
138
|
+
*
|
|
139
|
+
* @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted
|
|
140
|
+
* @param {EVENT} event: any javascript event supported by that object
|
|
141
|
+
* @param {Map} options : map of options being pushed into the ajax cycle
|
|
142
|
+
*/
|
|
143
|
+
function request(element, event, options) {
|
|
144
|
+
AjaxImpl_1.Implementation.request(element, event, options);
|
|
145
|
+
//Implementation.getInstance().requestInternal(element, event, options);
|
|
146
|
+
}
|
|
147
|
+
ajax.request = request;
|
|
148
|
+
/**
|
|
149
|
+
* response handler
|
|
150
|
+
* @param request the request object having triggered this response
|
|
151
|
+
* @param context the request context
|
|
152
|
+
*
|
|
153
|
+
* TODO add info on what can be in the context
|
|
154
|
+
*/
|
|
155
|
+
function response(request, context) {
|
|
156
|
+
AjaxImpl_1.Implementation.response(request, context);
|
|
157
|
+
}
|
|
158
|
+
ajax.response = response;
|
|
159
|
+
/**
|
|
160
|
+
* Adds an error handler to our global error queue.
|
|
161
|
+
* the error handler must be of the format <i>function errorListener(<errorData>)</i>
|
|
162
|
+
* with errorData being of following format:
|
|
163
|
+
* <ul>
|
|
164
|
+
* <li> errorData.type : "error"</li>
|
|
165
|
+
* <li> errorData.status : the error status message</li>
|
|
166
|
+
* <li> errorData.serverErrorName : the server error name in case of a server error</li>
|
|
167
|
+
* <li> errorData.serverErrorMessage : the server error message in case of a server error</li>
|
|
168
|
+
* <li> errorData.source : the issuing source element which triggered the requestInternal </li>
|
|
169
|
+
* <li> eventData.responseCode: the response code (aka http requestInternal response code, 401 etc...) </li>
|
|
170
|
+
* <li> eventData.responseText: the requestInternal response text </li>
|
|
171
|
+
* <li> eventData.responseXML: the requestInternal response xml </li>
|
|
172
|
+
* </ul>
|
|
173
|
+
*
|
|
174
|
+
* @param {function} errorListener error handler must be of the format <i>function errorListener(<errorData>)</i>
|
|
175
|
+
*/
|
|
176
|
+
function addOnError(errorFunc) {
|
|
177
|
+
AjaxImpl_1.Implementation.addOnError(errorFunc);
|
|
178
|
+
}
|
|
179
|
+
ajax.addOnError = addOnError;
|
|
180
|
+
/**
|
|
181
|
+
* Adds a global event listener to the ajax event queue. The event listener must be a function
|
|
182
|
+
* of following format: <i>function eventListener(<eventData>)</i>
|
|
183
|
+
*
|
|
184
|
+
* @param {function} eventListener event must be of the format <i>function eventListener(<eventData>)</i>
|
|
185
|
+
*/
|
|
186
|
+
function addOnEvent(eventFunc) {
|
|
187
|
+
AjaxImpl_1.Implementation.addOnEvent(eventFunc);
|
|
188
|
+
}
|
|
189
|
+
ajax.addOnEvent = addOnEvent;
|
|
190
|
+
})(ajax = jsf.ajax || (jsf.ajax = {}));
|
|
191
|
+
var util;
|
|
192
|
+
(function (util) {
|
|
193
|
+
/**
|
|
194
|
+
* varargs function which executes a chain of code (functions or any other code)
|
|
195
|
+
*
|
|
196
|
+
* if any of the code returns false, the execution
|
|
197
|
+
* is terminated prematurely skipping the rest of the code!
|
|
198
|
+
*
|
|
199
|
+
* @param {DomNode} source, the callee object
|
|
200
|
+
* @param {Event} event, the event object of the callee event triggering this function
|
|
201
|
+
* @param funcs ... arbitrary array of functions or strings
|
|
202
|
+
* @returns true if the chain has succeeded false otherwise
|
|
203
|
+
*/
|
|
204
|
+
function chain(source, event) {
|
|
205
|
+
var funcs = [];
|
|
206
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
207
|
+
funcs[_i - 2] = arguments[_i];
|
|
208
|
+
}
|
|
209
|
+
return AjaxImpl_1.Implementation.chain.apply(AjaxImpl_1.Implementation, __spreadArray([source, event], funcs, false));
|
|
210
|
+
}
|
|
211
|
+
util.chain = chain;
|
|
212
|
+
})(util = jsf.util || (jsf.util = {}));
|
|
213
|
+
var push;
|
|
214
|
+
(function (push) {
|
|
215
|
+
/**
|
|
216
|
+
* @param {function} onopen The function to be invoked when the web socket is opened.
|
|
217
|
+
* @param {function} onmessage The function to be invoked when a message is received.
|
|
218
|
+
* @param {function} onclose The function to be invoked when the web socket is closed.
|
|
219
|
+
* @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.
|
|
220
|
+
*/
|
|
221
|
+
function init(socketClientId, uri, channel, onopen, onmessage, onclose, behaviorScripts, autoconnect) {
|
|
222
|
+
PushImpl_1.PushImpl.init(socketClientId, uri, channel, onopen, onmessage, onclose, behaviorScripts, autoconnect);
|
|
223
|
+
}
|
|
224
|
+
push.init = init;
|
|
225
|
+
/**
|
|
226
|
+
* Open the web socket on the given channel.
|
|
227
|
+
* @param {string} channel The name of the web socket channel.
|
|
228
|
+
* @throws {Error} When channel is unknown.
|
|
229
|
+
*/
|
|
230
|
+
function open(socketClientId) {
|
|
231
|
+
PushImpl_1.PushImpl.open(socketClientId);
|
|
232
|
+
}
|
|
233
|
+
push.open = open;
|
|
234
|
+
/**
|
|
235
|
+
* Close the web socket on the given channel.
|
|
236
|
+
* @param {string} channel The name of the web socket channel.
|
|
237
|
+
* @throws {Error} When channel is unknown.
|
|
238
|
+
*/
|
|
239
|
+
function close(socketClientId) {
|
|
240
|
+
PushImpl_1.PushImpl.close(socketClientId);
|
|
241
|
+
}
|
|
242
|
+
push.close = close;
|
|
243
|
+
})(push = jsf.push || (jsf.push = {}));
|
|
244
|
+
//We hook the old namespace system into our npm system
|
|
245
|
+
//if ("undefined" == window.jsf) {
|
|
246
|
+
// window.jsf = jsf;
|
|
247
|
+
//}
|
|
248
|
+
})(jsf = exports.jsf || (exports.jsf = {}));
|
|
249
|
+
//fullfill the window contract
|
|
250
|
+
var myfaces;
|
|
251
|
+
(function (myfaces) {
|
|
252
|
+
/**
|
|
253
|
+
* AB function similar to mojarra and Primefaces
|
|
254
|
+
* not part of the spec but a convenience accessor method
|
|
255
|
+
* Code provided by Thomas Andraschko
|
|
256
|
+
*
|
|
257
|
+
* @param source the event source
|
|
258
|
+
* @param event the event
|
|
259
|
+
* @param eventName event name for java.javax.faces.behavior.evemnt
|
|
260
|
+
* @param execute execute list as passed down in jsf.ajax.request
|
|
261
|
+
* @param render
|
|
262
|
+
* @param options
|
|
263
|
+
*/
|
|
264
|
+
function ab(source, event, eventName, execute, render, options) {
|
|
265
|
+
if (options === void 0) { options = {}; }
|
|
266
|
+
if (eventName) {
|
|
267
|
+
options["javax.faces.behavior.event"] = eventName;
|
|
268
|
+
}
|
|
269
|
+
if (execute) {
|
|
270
|
+
options["execute"] = execute;
|
|
271
|
+
}
|
|
272
|
+
if (render) {
|
|
273
|
+
options["render"] = render;
|
|
274
|
+
}
|
|
275
|
+
jsf.ajax.request(source, event, options);
|
|
276
|
+
}
|
|
277
|
+
myfaces.ab = ab;
|
|
278
|
+
})(myfaces = exports.myfaces || (exports.myfaces = {}));
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
/***/ }),
|
|
282
|
+
|
|
283
|
+
/***/ "./src/main/typescript/impl/AjaxImpl.ts":
|
|
284
|
+
/*!**********************************************!*\
|
|
285
|
+
!*** ./src/main/typescript/impl/AjaxImpl.ts ***!
|
|
286
|
+
\**********************************************/
|
|
287
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
288
|
+
|
|
289
|
+
"use strict";
|
|
290
|
+
|
|
291
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
292
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
293
|
+
* this work for additional information regarding copyright ownership.
|
|
294
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
295
|
+
* (the "License"); you may not use this file except in compliance with
|
|
296
|
+
* the License. You may obtain a copy of the License at
|
|
297
|
+
*
|
|
298
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
299
|
+
*
|
|
300
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
301
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
302
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
303
|
+
* See the License for the specific language governing permissions and
|
|
304
|
+
* limitations under the License.
|
|
305
|
+
*/
|
|
306
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
307
|
+
exports.Implementation = void 0;
|
|
308
|
+
var Response_1 = __webpack_require__(/*! ./xhrCore/Response */ "./src/main/typescript/impl/xhrCore/Response.ts");
|
|
309
|
+
var XhrRequest_1 = __webpack_require__(/*! ./xhrCore/XhrRequest */ "./src/main/typescript/impl/xhrCore/XhrRequest.ts");
|
|
310
|
+
var AsyncQueue_1 = __webpack_require__(/*! ./util/AsyncQueue */ "./src/main/typescript/impl/util/AsyncQueue.ts");
|
|
311
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
312
|
+
var Assertions_1 = __webpack_require__(/*! ./util/Assertions */ "./src/main/typescript/impl/util/Assertions.ts");
|
|
313
|
+
var XhrFormData_1 = __webpack_require__(/*! ./xhrCore/XhrFormData */ "./src/main/typescript/impl/xhrCore/XhrFormData.ts");
|
|
314
|
+
var ExtDomQuery_1 = __webpack_require__(/*! ./util/ExtDomQuery */ "./src/main/typescript/impl/util/ExtDomQuery.ts");
|
|
315
|
+
var ErrorData_1 = __webpack_require__(/*! ./xhrCore/ErrorData */ "./src/main/typescript/impl/xhrCore/ErrorData.ts");
|
|
316
|
+
var Lang_1 = __webpack_require__(/*! ./util/Lang */ "./src/main/typescript/impl/util/Lang.ts");
|
|
317
|
+
var Const_1 = __webpack_require__(/*! ./core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
318
|
+
var RequestDataResolver_1 = __webpack_require__(/*! ./xhrCore/RequestDataResolver */ "./src/main/typescript/impl/xhrCore/RequestDataResolver.ts");
|
|
319
|
+
/*
|
|
320
|
+
* allowed project stages
|
|
321
|
+
*/
|
|
322
|
+
var ProjectStages;
|
|
323
|
+
(function (ProjectStages) {
|
|
324
|
+
ProjectStages["Production"] = "Production";
|
|
325
|
+
ProjectStages["Development"] = "Development";
|
|
326
|
+
ProjectStages["SystemTest"] = "SystemTest";
|
|
327
|
+
ProjectStages["UnitTest"] = "UnitTest";
|
|
328
|
+
})(ProjectStages || (ProjectStages = {}));
|
|
329
|
+
/*
|
|
330
|
+
* blockfilter for the passthrough filtering; the attributes given here
|
|
331
|
+
* will not be transmitted from the options into the passthrough
|
|
332
|
+
*/
|
|
333
|
+
var BlockFilter;
|
|
334
|
+
(function (BlockFilter) {
|
|
335
|
+
BlockFilter["onerror"] = "onerror";
|
|
336
|
+
BlockFilter["onevent"] = "onevent";
|
|
337
|
+
BlockFilter["render"] = "render";
|
|
338
|
+
BlockFilter["execute"] = "execute";
|
|
339
|
+
BlockFilter["myfaces"] = "myfaces";
|
|
340
|
+
BlockFilter["delay"] = "delay";
|
|
341
|
+
BlockFilter["timeout"] = "timeout";
|
|
342
|
+
BlockFilter["windowId"] = "windowId";
|
|
343
|
+
})(BlockFilter || (BlockFilter = {}));
|
|
344
|
+
/**
|
|
345
|
+
* Core Implementation
|
|
346
|
+
* to distinct between api and impl
|
|
347
|
+
*
|
|
348
|
+
* The original idea was to make the implementation pluggable
|
|
349
|
+
* but this is pointless, you always can overwrite the thin api layer
|
|
350
|
+
* however a dedicated api makes sense for readability reasons
|
|
351
|
+
*/
|
|
352
|
+
var Implementation;
|
|
353
|
+
(function (Implementation) {
|
|
354
|
+
var trim = mona_dish_1.Lang.trim;
|
|
355
|
+
var getMessage = Lang_1.ExtLang.getMessage;
|
|
356
|
+
var getGlobalConfig = Lang_1.ExtLang.getGlobalConfig;
|
|
357
|
+
var assert = Assertions_1.Assertions.assert;
|
|
358
|
+
var projectStage = null;
|
|
359
|
+
var separator = null;
|
|
360
|
+
var eventQueue = [];
|
|
361
|
+
var errorQueue = [];
|
|
362
|
+
Implementation.requestQueue = null;
|
|
363
|
+
/*error reporting threshold*/
|
|
364
|
+
var threshold = "ERROR";
|
|
365
|
+
/**
|
|
366
|
+
* fetches the separator char from the given script tags
|
|
367
|
+
*
|
|
368
|
+
* @return {char} the separator char for the given script tags
|
|
369
|
+
*/
|
|
370
|
+
function getSeparatorChar() {
|
|
371
|
+
var _a, _b, _c;
|
|
372
|
+
return (_c = (_b = (_a = resolveGlobalConfig()) === null || _a === void 0 ? void 0 : _a.separator) !== null && _b !== void 0 ? _b : this === null || this === void 0 ? void 0 : this.separator) !== null && _c !== void 0 ? _c : (separator = ExtDomQuery_1.ExtDomquery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
|
|
373
|
+
}
|
|
374
|
+
Implementation.getSeparatorChar = getSeparatorChar;
|
|
375
|
+
/**
|
|
376
|
+
* this is for testing purposes only, since AjaxImpl is a module
|
|
377
|
+
* we need to reset for every unit test its internal states
|
|
378
|
+
*/
|
|
379
|
+
function reset() {
|
|
380
|
+
projectStage = null;
|
|
381
|
+
separator = null;
|
|
382
|
+
eventQueue = [];
|
|
383
|
+
errorQueue = [];
|
|
384
|
+
Implementation.requestQueue = null;
|
|
385
|
+
}
|
|
386
|
+
Implementation.reset = reset;
|
|
387
|
+
/**
|
|
388
|
+
* @return the project stage also emitted by the server:
|
|
389
|
+
* it cannot be cached and must be delivered over the server
|
|
390
|
+
* The value for it comes from the requestInternal parameter of the jsf.js script called "stage".
|
|
391
|
+
*/
|
|
392
|
+
function getProjectStage() {
|
|
393
|
+
var _a, _b, _c;
|
|
394
|
+
return (_c = (_b = (_a = resolveGlobalConfig()) === null || _a === void 0 ? void 0 : _a.projectStage) !== null && _b !== void 0 ? _b : this === null || this === void 0 ? void 0 : this.projectStage) !== null && _c !== void 0 ? _c : (projectStage = resolveProjectStateFromURL());
|
|
395
|
+
}
|
|
396
|
+
Implementation.getProjectStage = getProjectStage;
|
|
397
|
+
/**
|
|
398
|
+
* resolves the project stage as url parameter
|
|
399
|
+
* @return the project stage or null
|
|
400
|
+
*/
|
|
401
|
+
function resolveProjectStateFromURL() {
|
|
402
|
+
/* run through all script tags and try to find the one that includes jsf.js */
|
|
403
|
+
var foundStage = ExtDomQuery_1.ExtDomquery.searchJsfJsFor(/stage=([^&;]*)/).value;
|
|
404
|
+
return (foundStage in ProjectStages) ? foundStage : null;
|
|
405
|
+
}
|
|
406
|
+
Implementation.resolveProjectStateFromURL = resolveProjectStateFromURL;
|
|
407
|
+
/**
|
|
408
|
+
* implementation of the jsf.util.chain functionality
|
|
409
|
+
*
|
|
410
|
+
* @param source
|
|
411
|
+
* @param event
|
|
412
|
+
* @param funcs
|
|
413
|
+
*/
|
|
414
|
+
function chain(source, event) {
|
|
415
|
+
var funcs = [];
|
|
416
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
417
|
+
funcs[_i - 2] = arguments[_i];
|
|
418
|
+
}
|
|
419
|
+
var ret = true;
|
|
420
|
+
var resolveAndExecute = function (func) {
|
|
421
|
+
if ("string" != typeof func) {
|
|
422
|
+
//function is passed down as chain parameter, can be executed as is
|
|
423
|
+
return (ret = ret && (func.call(source, event) !== false));
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
//either a function or a string can be passed in case of a string we have to wrap it into another function
|
|
427
|
+
//it it is not a plain executable code but a definition
|
|
428
|
+
var sourceCode = trim(func);
|
|
429
|
+
if (sourceCode.indexOf("function ") == 0) {
|
|
430
|
+
sourceCode = "return ".concat(sourceCode, " (event)");
|
|
431
|
+
}
|
|
432
|
+
return (ret = ret && (new Function("event", sourceCode).call(source, event) !== false));
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
//we can use our stream each functionality to run our chain here..
|
|
436
|
+
//the no return value == false stop stream functionality is handled by our resolveAndExecute
|
|
437
|
+
mona_dish_1.Stream.of.apply(mona_dish_1.Stream, funcs).each(function (func) { return resolveAndExecute(func); });
|
|
438
|
+
return ret;
|
|
439
|
+
}
|
|
440
|
+
Implementation.chain = chain;
|
|
441
|
+
/**
|
|
442
|
+
* this function has to send the ajax requests
|
|
443
|
+
*
|
|
444
|
+
* following request conditions must be met:
|
|
445
|
+
* <ul>
|
|
446
|
+
* <li> the request must be sent asynchronously! </li>
|
|
447
|
+
* <li> the request must be a POST!!! request </li>
|
|
448
|
+
* <li> the request url must be the form action attribute </li>
|
|
449
|
+
* <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
|
|
450
|
+
* </ul>
|
|
451
|
+
*
|
|
452
|
+
* @param el any dom element no matter being it html or jsf, from which the event is emitted
|
|
453
|
+
* @param event any javascript event supported by that object
|
|
454
|
+
* @param opts map of options being pushed into the ajax cycle
|
|
455
|
+
*
|
|
456
|
+
* a) transformArguments out of the function
|
|
457
|
+
* b) passThrough handling with a map copy with a filter map block map
|
|
458
|
+
*/
|
|
459
|
+
function request(el, event, opts) {
|
|
460
|
+
var _a, _b, _c;
|
|
461
|
+
var _d = (0, RequestDataResolver_1.resolveDefaults)(event, opts, el), resolvedEvent = _d.resolvedEvent, options = _d.options, elem = _d.elem, elementId = _d.elementId, requestCtx = _d.requestCtx, internalCtx = _d.internalCtx, windowId = _d.windowId, isResetValues = _d.isResetValues;
|
|
462
|
+
Assertions_1.Assertions.assertRequestIntegrity(options, elem);
|
|
463
|
+
requestCtx.assignIf(!!windowId, Const_1.P_WINDOW_ID).value = windowId;
|
|
464
|
+
requestCtx.assign(Const_1.CTX_PARAM_PASS_THR).value = filterPassthroughValues(options.value);
|
|
465
|
+
requestCtx.assignIf(!!resolvedEvent, Const_1.CTX_PARAM_PASS_THR, Const_1.P_EVT).value = resolvedEvent === null || resolvedEvent === void 0 ? void 0 : resolvedEvent.type;
|
|
466
|
+
/**
|
|
467
|
+
* ajax pass through context with the source
|
|
468
|
+
* onresolvedEvent and onerror
|
|
469
|
+
*/
|
|
470
|
+
requestCtx.assign(Const_1.SOURCE).value = elementId.value;
|
|
471
|
+
/**
|
|
472
|
+
* on resolvedEvent and onError...
|
|
473
|
+
* those values will be traversed later on
|
|
474
|
+
* also into the response context
|
|
475
|
+
*/
|
|
476
|
+
requestCtx.assign(Const_1.ON_EVENT).value = (_a = options.value) === null || _a === void 0 ? void 0 : _a.onevent;
|
|
477
|
+
requestCtx.assign(Const_1.ON_ERROR).value = (_b = options.value) === null || _b === void 0 ? void 0 : _b.onerror;
|
|
478
|
+
/**
|
|
479
|
+
* lets drag the myfaces config params also in
|
|
480
|
+
*/
|
|
481
|
+
requestCtx.assign(Const_1.MYFACES).value = (_c = options.value) === null || _c === void 0 ? void 0 : _c.myfaces;
|
|
482
|
+
/**
|
|
483
|
+
* fetch the parent form
|
|
484
|
+
*
|
|
485
|
+
* note we also add an override possibility here
|
|
486
|
+
* so that people can use dummy forms and work
|
|
487
|
+
* with detached objects
|
|
488
|
+
*/
|
|
489
|
+
var form = (0, RequestDataResolver_1.resolveForm)(requestCtx, elem, resolvedEvent);
|
|
490
|
+
/**
|
|
491
|
+
* binding contract the javax.faces.source must be set
|
|
492
|
+
*/
|
|
493
|
+
requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value = elementId.value;
|
|
494
|
+
/**
|
|
495
|
+
* javax.faces.partial.ajax must be set to true
|
|
496
|
+
*/
|
|
497
|
+
requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_AJAX).value = true;
|
|
498
|
+
/**
|
|
499
|
+
* binding contract the javax.faces.source must be set
|
|
500
|
+
*/
|
|
501
|
+
requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value = elementId.value;
|
|
502
|
+
/**
|
|
503
|
+
* if resetValues is set to true
|
|
504
|
+
* then we have to set javax.faces.resetValues as well
|
|
505
|
+
* as pass through parameter
|
|
506
|
+
* the value has to be explicitly true, according to
|
|
507
|
+
* the specs jsdoc
|
|
508
|
+
*/
|
|
509
|
+
requestCtx.assignIf(isResetValues, Const_1.CTX_PARAM_PASS_THR, Const_1.P_RESET_VALUES).value = true;
|
|
510
|
+
//additional meta information to speed things up, note internal non jsf
|
|
511
|
+
//pass through options are stored under _mfInternal in the context
|
|
512
|
+
internalCtx.assign(Const_1.CTX_PARAM_SRC_FRM_ID).value = form.id.value;
|
|
513
|
+
internalCtx.assign(Const_1.CTX_PARAM_SRC_CTL_ID).value = elementId.value;
|
|
514
|
+
internalCtx.assign(Const_1.CTX_PARAM_TR_TYPE).value = Const_1.REQ_TYPE_POST;
|
|
515
|
+
//mojarra compatibility, mojarra is sending the form id as well
|
|
516
|
+
//this is not documented behavior but can be determined by running
|
|
517
|
+
//mojarra under blackbox conditions
|
|
518
|
+
//i assume it does the same as our formId_submit=1 so leaving it out
|
|
519
|
+
//wont hurt but for the sake of compatibility we are going to add it
|
|
520
|
+
requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, form.id.value).value = form.id.value;
|
|
521
|
+
assignClientWindowId(form, requestCtx);
|
|
522
|
+
assignExecute(options, requestCtx, form, elementId.value);
|
|
523
|
+
assignRender(options, requestCtx, form, elementId.value);
|
|
524
|
+
var delay = (0, RequestDataResolver_1.resolveDelay)(options);
|
|
525
|
+
var timeout = (0, RequestDataResolver_1.resolveTimeout)(options);
|
|
526
|
+
//now we enqueue the request as asynchronous runnable into our request
|
|
527
|
+
//queue and let the queue take over the rest
|
|
528
|
+
Implementation.queueHandler.addRequestToQueue(elem, form, requestCtx, internalCtx, delay, timeout);
|
|
529
|
+
}
|
|
530
|
+
Implementation.request = request;
|
|
531
|
+
/**
|
|
532
|
+
* Spec. 13.3.3
|
|
533
|
+
* Examining the response markup and updating the DOM tree
|
|
534
|
+
* @param {XMLHttpRequest} request - the ajax request
|
|
535
|
+
* @param {Object} context - the ajax context
|
|
536
|
+
*/
|
|
537
|
+
function response(request, context) {
|
|
538
|
+
Response_1.Response.processResponse(request, context);
|
|
539
|
+
}
|
|
540
|
+
Implementation.response = response;
|
|
541
|
+
/**
|
|
542
|
+
* adds an error handler to the error queue
|
|
543
|
+
*
|
|
544
|
+
* @param errorListener the error listener handler
|
|
545
|
+
*/
|
|
546
|
+
function addOnError(errorListener) {
|
|
547
|
+
/*error handling already done in the assert of the queue*/
|
|
548
|
+
errorQueue.push(errorListener);
|
|
549
|
+
}
|
|
550
|
+
Implementation.addOnError = addOnError;
|
|
551
|
+
/**
|
|
552
|
+
* adds an event handler to the event queue
|
|
553
|
+
*
|
|
554
|
+
* @param eventListener the event listener handler
|
|
555
|
+
*/
|
|
556
|
+
function addOnEvent(eventListener) {
|
|
557
|
+
/*error handling already done in the assert of the queue*/
|
|
558
|
+
eventQueue.push(eventListener);
|
|
559
|
+
}
|
|
560
|
+
Implementation.addOnEvent = addOnEvent;
|
|
561
|
+
// noinspection JSUnusedLocalSymbols
|
|
562
|
+
/**
|
|
563
|
+
* sends an event to the event handlers
|
|
564
|
+
*
|
|
565
|
+
* @param data the event data object hosting the event data according to the spec @see EventData for what is reachable
|
|
566
|
+
* @param localHandler an optional event handler, which is processed before the event handler chain
|
|
567
|
+
*/
|
|
568
|
+
function sendEvent(data, localHandler) {
|
|
569
|
+
if (localHandler === void 0) { localHandler = function (data) {
|
|
570
|
+
}; }
|
|
571
|
+
/*now we serve the queue as well*/
|
|
572
|
+
localHandler(data);
|
|
573
|
+
eventQueue.forEach(function (fn) { return fn(data); });
|
|
574
|
+
}
|
|
575
|
+
Implementation.sendEvent = sendEvent;
|
|
576
|
+
/**
|
|
577
|
+
* error handler behavior called internally
|
|
578
|
+
* and only into the impl it takes care of the
|
|
579
|
+
* internal message transformation to a myfaces internal error
|
|
580
|
+
* and then uses the standard send error mechanisms
|
|
581
|
+
* also a double error logging prevention is done as well
|
|
582
|
+
*
|
|
583
|
+
* @param request the request currently being processed
|
|
584
|
+
* @param context the context affected by this error
|
|
585
|
+
* @param exception the exception being thrown
|
|
586
|
+
* @param clearRequestQueue if set to true, clears the request queue of all pending requests
|
|
587
|
+
*/
|
|
588
|
+
function stdErrorHandler(request, context, exception, clearRequestQueue) {
|
|
589
|
+
if (clearRequestQueue === void 0) { clearRequestQueue = false; }
|
|
590
|
+
//newer browsers do not allow to hold additional values on native objects like exceptions
|
|
591
|
+
//we hence capsule it into the request, which is gced automatically
|
|
592
|
+
//on ie as well, since the stdErrorHandler usually is called between requests
|
|
593
|
+
//this is a valid approach
|
|
594
|
+
try {
|
|
595
|
+
if (threshold == "ERROR") {
|
|
596
|
+
var errorData = ErrorData_1.ErrorData.fromClient(exception);
|
|
597
|
+
sendError(errorData);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
finally {
|
|
601
|
+
if (clearRequestQueue) {
|
|
602
|
+
Implementation.requestQueue.cleanup();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
Implementation.stdErrorHandler = stdErrorHandler;
|
|
607
|
+
// noinspection JSUnusedLocalSymbols
|
|
608
|
+
/**
|
|
609
|
+
* implementation triggering the error chain
|
|
610
|
+
*
|
|
611
|
+
*
|
|
612
|
+
*
|
|
613
|
+
* handles the errors, in case of an onError exists within the context the onError is called as local error handler
|
|
614
|
+
* the registered error handlers in the queue receiv an error message to be dealt with
|
|
615
|
+
* and if the projectStage is at development an alert box is displayed
|
|
616
|
+
*
|
|
617
|
+
* note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided
|
|
618
|
+
* which changes the default output behavior from alert to something else
|
|
619
|
+
*
|
|
620
|
+
* @param errorData the error data to be displayed
|
|
621
|
+
* @param localHandler an optional local error handler which has to be processed before the error handler queue
|
|
622
|
+
*/
|
|
623
|
+
function sendError(errorData, localHandler) {
|
|
624
|
+
if (localHandler === void 0) { localHandler = function (data) {
|
|
625
|
+
}; }
|
|
626
|
+
localHandler(errorData);
|
|
627
|
+
errorQueue.forEach(function (errorCallback) {
|
|
628
|
+
errorCallback(errorData);
|
|
629
|
+
});
|
|
630
|
+
var displayError = getGlobalConfig("defaultErrorOutput", (console ? console.error : alert));
|
|
631
|
+
displayError(errorData);
|
|
632
|
+
}
|
|
633
|
+
Implementation.sendError = sendError;
|
|
634
|
+
/**
|
|
635
|
+
* @node optional element or id defining a rootnode where an element with the id "javax.faces.windowId" is hosted
|
|
636
|
+
* @return the client window id of the current window, if one is given if none is found, null is returned
|
|
637
|
+
*/
|
|
638
|
+
function getClientWindow(node) {
|
|
639
|
+
var ALTERED = "___mf_id_altered__";
|
|
640
|
+
var INIT = "___init____";
|
|
641
|
+
/**
|
|
642
|
+
* the search root for the dom element search
|
|
643
|
+
*/
|
|
644
|
+
var searchRoot = new mona_dish_1.DQ(node || document.body).querySelectorAll("form input [name='".concat(Const_1.P_CLIENT_WINDOW, "']"));
|
|
645
|
+
/**
|
|
646
|
+
* lazy helper to fetch the window id from the window url
|
|
647
|
+
*/
|
|
648
|
+
var fetchWindowIdFromUrl = function () { return ExtDomQuery_1.ExtDomquery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value; };
|
|
649
|
+
/**
|
|
650
|
+
* functional double check based on stream reduction
|
|
651
|
+
* the values should be identical or on INIT value which is a premise to
|
|
652
|
+
* skip the first check
|
|
653
|
+
*
|
|
654
|
+
* @param value1
|
|
655
|
+
* @param value2
|
|
656
|
+
*/
|
|
657
|
+
var differenceCheck = function (value1, value2) {
|
|
658
|
+
if (value1 == INIT) {
|
|
659
|
+
return value2;
|
|
660
|
+
}
|
|
661
|
+
else if (value1 == ALTERED || value1 != value2) {
|
|
662
|
+
return ALTERED;
|
|
663
|
+
}
|
|
664
|
+
return value2;
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* helper for cleaner code, maps the value from an item
|
|
668
|
+
*
|
|
669
|
+
* @param item
|
|
670
|
+
*/
|
|
671
|
+
var getValue = function (item) { return item.attr("value").value; };
|
|
672
|
+
/**
|
|
673
|
+
* fetch the window id from the forms
|
|
674
|
+
* window ids must be present in all forms
|
|
675
|
+
* or non existent. If they exist all of them must be the same
|
|
676
|
+
*/
|
|
677
|
+
var formWindowId = searchRoot.stream.map(getValue).reduce(differenceCheck, INIT);
|
|
678
|
+
//if the resulting window id is set on altered then we have an unresolvable problem
|
|
679
|
+
assert(ALTERED != formWindowId.value, "Multiple different windowIds found in document");
|
|
680
|
+
/**
|
|
681
|
+
* return the window id or null
|
|
682
|
+
* prio, forms under node/document and if not given then from the url
|
|
683
|
+
*/
|
|
684
|
+
return formWindowId.value != INIT ? formWindowId.value : fetchWindowIdFromUrl();
|
|
685
|
+
}
|
|
686
|
+
Implementation.getClientWindow = getClientWindow;
|
|
687
|
+
/**
|
|
688
|
+
* collect and encode data for a given form element (must be of type form)
|
|
689
|
+
* find the javax.faces.ViewState element and encode its value as well!
|
|
690
|
+
* @return a concatenated string of the encoded values!
|
|
691
|
+
*
|
|
692
|
+
* @throws Error in case of the given element not being of type form!
|
|
693
|
+
* https://issues.apache.org/jira/browse/MYFACES-2110
|
|
694
|
+
*/
|
|
695
|
+
function getViewState(form) {
|
|
696
|
+
/**
|
|
697
|
+
* typecheck assert!, we opt for strong typing here
|
|
698
|
+
* because it makes it easier to detect bugs
|
|
699
|
+
*/
|
|
700
|
+
var element = mona_dish_1.DQ.byId(form, true);
|
|
701
|
+
if (!element.isTag(Const_1.TAG_FORM)) {
|
|
702
|
+
throw new Error(getMessage("ERR_VIEWSTATE"));
|
|
703
|
+
}
|
|
704
|
+
var formData = new XhrFormData_1.XhrFormData(element);
|
|
705
|
+
return formData.toString();
|
|
706
|
+
}
|
|
707
|
+
Implementation.getViewState = getViewState;
|
|
708
|
+
/**
|
|
709
|
+
* this at the first sight looks like a weird construct, but we need to do it this way
|
|
710
|
+
* for testing, we cannot proxy addRequestToQueue from the testing frameworks directly
|
|
711
|
+
* but we need to keep it under unit tests.
|
|
712
|
+
*/
|
|
713
|
+
Implementation.queueHandler = {
|
|
714
|
+
/**
|
|
715
|
+
* public to make it shimmable for tests
|
|
716
|
+
*
|
|
717
|
+
* adds a new request to our queue for further processing
|
|
718
|
+
*/
|
|
719
|
+
addRequestToQueue: function (elem, form, reqCtx, respPassThr, delay, timeout) {
|
|
720
|
+
if (delay === void 0) { delay = 0; }
|
|
721
|
+
if (timeout === void 0) { timeout = 0; }
|
|
722
|
+
Implementation.requestQueue = Implementation.requestQueue !== null && Implementation.requestQueue !== void 0 ? Implementation.requestQueue : new AsyncQueue_1.AsynchronouseQueue();
|
|
723
|
+
Implementation.requestQueue.enqueue(new XhrRequest_1.XhrRequest(elem, form, reqCtx, respPassThr, [], timeout), delay);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
//----------------------------------------------- Methods ---------------------------------------------------------------------
|
|
727
|
+
/**
|
|
728
|
+
* the idea is to replace some placeholder parameters with their respective values
|
|
729
|
+
* placeholder params like @all, @none, @form, @this need to be replaced by
|
|
730
|
+
* the values defined by the specification
|
|
731
|
+
*
|
|
732
|
+
* This function does it for the render parameters
|
|
733
|
+
*
|
|
734
|
+
* @param requestOptions the source options coming in as options object from jsf.ajax.request (options parameter)
|
|
735
|
+
* @param targetContext the receiving target context
|
|
736
|
+
* @param issuingForm the issuing form
|
|
737
|
+
* @param sourceElementId the executing element triggering the jsf.ajax.request (id of it)
|
|
738
|
+
*/
|
|
739
|
+
function assignRender(requestOptions, targetContext, issuingForm, sourceElementId) {
|
|
740
|
+
if (requestOptions.getIf(Const_1.RENDER).isPresent()) {
|
|
741
|
+
remapDefaultConstants(targetContext.getIf(Const_1.CTX_PARAM_PASS_THR).get({}), Const_1.P_RENDER, requestOptions.getIf(Const_1.RENDER).value, issuingForm, sourceElementId);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* the idea is to replace some placeholder parameters with their respective values
|
|
746
|
+
* placeholder params like @all, @none, @form, @this need to be replaced by
|
|
747
|
+
* the values defined by the specification
|
|
748
|
+
*
|
|
749
|
+
* This function does it for the execute parameters
|
|
750
|
+
*
|
|
751
|
+
* @param requestOptions the source options coming in as options object from jsf.ajax.request (options parameter)
|
|
752
|
+
* @param targetContext the receiving target context
|
|
753
|
+
* @param issuingForm the issuing form
|
|
754
|
+
* @param sourceElementId the executing element triggering the jsf.ajax.request (id of it)
|
|
755
|
+
*/
|
|
756
|
+
function assignExecute(requestOptions, targetContext, issuingForm, sourceElementId) {
|
|
757
|
+
if (requestOptions.getIf(Const_1.CTX_PARAM_EXECUTE).isPresent()) {
|
|
758
|
+
/*the options must be a blank delimited list of strings*/
|
|
759
|
+
/*compliance with Mojarra which automatically adds @this to an execute
|
|
760
|
+
* the spec rev 2.0a however states, if none is issued nothing at all should be sent down
|
|
761
|
+
*/
|
|
762
|
+
requestOptions.assign(Const_1.CTX_PARAM_EXECUTE).value = [requestOptions.getIf(Const_1.CTX_PARAM_EXECUTE).value, Const_1.IDENT_THIS].join(" ");
|
|
763
|
+
remapDefaultConstants(targetContext.getIf(Const_1.CTX_PARAM_PASS_THR).get({}), Const_1.P_EXECUTE, requestOptions.getIf(Const_1.CTX_PARAM_EXECUTE).value, issuingForm, sourceElementId);
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
targetContext.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_EXECUTE).value = sourceElementId;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* apply the browser tab where the request was originating from
|
|
771
|
+
*
|
|
772
|
+
* @param form the form hosting the client window id
|
|
773
|
+
* @param targetContext the target context receiving the value
|
|
774
|
+
*/
|
|
775
|
+
function assignClientWindowId(form, targetContext) {
|
|
776
|
+
var clientWindow = jsf.getClientWindow(form.getAsElem(0).value);
|
|
777
|
+
if (clientWindow) {
|
|
778
|
+
targetContext.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_CLIENT_WINDOW).value = clientWindow;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* transforms the user values to the expected one
|
|
783
|
+
* with the proper none all form and this handling
|
|
784
|
+
* (note we also could use a simple string replace but then
|
|
785
|
+
* we would have had double entries under some circumstances)
|
|
786
|
+
*
|
|
787
|
+
* there are several standardized constants which need a special treatment
|
|
788
|
+
* like @all, @none, @form, @this
|
|
789
|
+
*
|
|
790
|
+
* @param targetConfig the target configuration receiving the final values
|
|
791
|
+
* @param targetKey the target key
|
|
792
|
+
* @param userValues the passed user values (aka input string which needs to be transformed)
|
|
793
|
+
* @param issuingForm the form where the issuing element originates
|
|
794
|
+
* @param issuingElementId the issuing element
|
|
795
|
+
*/
|
|
796
|
+
function remapDefaultConstants(targetConfig, targetKey, userValues, issuingForm, issuingElementId) {
|
|
797
|
+
//a cleaner implementation of the transform list method
|
|
798
|
+
var iterValues = (userValues) ? trim(userValues).split(/\s+/gi) : [];
|
|
799
|
+
var ret = [];
|
|
800
|
+
var processed = {};
|
|
801
|
+
//the idea is simply to loop over all values and then replace
|
|
802
|
+
//their generic values and filter out doubles
|
|
803
|
+
//this is more readable than the old indexed based solution
|
|
804
|
+
//and not really slower because we had to build up the index in our old solution
|
|
805
|
+
//anyway
|
|
806
|
+
for (var cnt = 0; cnt < iterValues.length; cnt++) {
|
|
807
|
+
//avoid doubles
|
|
808
|
+
if (iterValues[cnt] in processed) {
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
switch (iterValues[cnt]) {
|
|
812
|
+
//@none no values should be sent
|
|
813
|
+
case Const_1.IDENT_NONE:
|
|
814
|
+
return targetConfig.delete(targetKey);
|
|
815
|
+
//@all is a pass through case according to the spec
|
|
816
|
+
case Const_1.IDENT_ALL:
|
|
817
|
+
targetConfig.assign(targetKey).value = Const_1.IDENT_ALL;
|
|
818
|
+
return targetConfig;
|
|
819
|
+
//@form pushes the issuing form id into our list
|
|
820
|
+
case Const_1.IDENT_FORM:
|
|
821
|
+
ret.push(issuingForm.id.value);
|
|
822
|
+
processed[issuingForm.id.value] = true;
|
|
823
|
+
break;
|
|
824
|
+
//@this is replaced with the current issuing element id
|
|
825
|
+
case Const_1.IDENT_THIS:
|
|
826
|
+
if (!(issuingElementId in processed)) {
|
|
827
|
+
ret.push(issuingElementId);
|
|
828
|
+
processed[issuingElementId] = true;
|
|
829
|
+
}
|
|
830
|
+
break;
|
|
831
|
+
default:
|
|
832
|
+
ret.push(iterValues[cnt]);
|
|
833
|
+
processed[iterValues[cnt]] = true;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
//We now add the target as joined list
|
|
837
|
+
targetConfig.assign(targetKey).value = ret.join(" ");
|
|
838
|
+
return targetConfig;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* filter the options given with a blacklist so that only
|
|
842
|
+
* the values required for passthough land in the ajax request
|
|
843
|
+
*
|
|
844
|
+
* @param {Context} mappedOpts the options to be filtered
|
|
845
|
+
*/
|
|
846
|
+
function filterPassthroughValues(mappedOpts) {
|
|
847
|
+
//we now can use the full code reduction given by our stream api
|
|
848
|
+
//to filter
|
|
849
|
+
return mona_dish_1.Stream.ofAssoc(mappedOpts)
|
|
850
|
+
.filter(function (item) { return !(item[0] in BlockFilter); })
|
|
851
|
+
.collect(new mona_dish_1.AssocArrayCollector());
|
|
852
|
+
}
|
|
853
|
+
function resolveGlobalConfig() {
|
|
854
|
+
var _a, _b;
|
|
855
|
+
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 : {};
|
|
856
|
+
}
|
|
857
|
+
})(Implementation = exports.Implementation || (exports.Implementation = {}));
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
/***/ }),
|
|
861
|
+
|
|
862
|
+
/***/ "./src/main/typescript/impl/PushImpl.ts":
|
|
863
|
+
/*!**********************************************!*\
|
|
864
|
+
!*** ./src/main/typescript/impl/PushImpl.ts ***!
|
|
865
|
+
\**********************************************/
|
|
866
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
867
|
+
|
|
868
|
+
"use strict";
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Typescript port of the jsf.push part in the myfaces implementation
|
|
872
|
+
*/
|
|
873
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
874
|
+
exports.PushImpl = void 0;
|
|
875
|
+
//TODO still work in progress
|
|
876
|
+
//this is a 1:1 port for the time being
|
|
877
|
+
var Jsf_1 = __webpack_require__(/*! ../api/Jsf */ "./src/main/typescript/api/Jsf.ts");
|
|
878
|
+
var Const_1 = __webpack_require__(/*! ./core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
879
|
+
/**
|
|
880
|
+
* Implementation class for the push functionality
|
|
881
|
+
*/
|
|
882
|
+
var PushImpl;
|
|
883
|
+
(function (PushImpl) {
|
|
884
|
+
var URL_PROTOCOL = window.location.protocol.replace("http", "ws") + "//";
|
|
885
|
+
//we expose the member variables for testing purposes
|
|
886
|
+
//they are not directly touched outside of tests
|
|
887
|
+
/* socket map by token */
|
|
888
|
+
PushImpl.sockets = {};
|
|
889
|
+
/* component attributes by clientId */
|
|
890
|
+
PushImpl.components = {};
|
|
891
|
+
/* client ids by token (share websocket connection) */
|
|
892
|
+
PushImpl.clientIdsByTokens = {};
|
|
893
|
+
//needed for testing
|
|
894
|
+
function reset() {
|
|
895
|
+
PushImpl.sockets = {};
|
|
896
|
+
PushImpl.components = {};
|
|
897
|
+
PushImpl.clientIdsByTokens = {};
|
|
898
|
+
}
|
|
899
|
+
PushImpl.reset = reset;
|
|
900
|
+
/*
|
|
901
|
+
* Api implementations, exposed functions
|
|
902
|
+
*/
|
|
903
|
+
/**
|
|
904
|
+
*
|
|
905
|
+
* @param {function} onopen The function to be invoked when the web socket is opened.
|
|
906
|
+
* @param {function} onmessage The function to be invoked when a message is received.
|
|
907
|
+
* @param {function} onclose The function to be invoked when the web socket is closed.
|
|
908
|
+
* @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.
|
|
909
|
+
*/
|
|
910
|
+
function init(socketClientId, uri, channel, onopen, onmessage, onclose, behaviorScripts, autoconnect) {
|
|
911
|
+
onclose = resolveFunction(onclose);
|
|
912
|
+
if (!window.WebSocket) { // IE6-9.
|
|
913
|
+
onclose(-1, channel);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
var channelToken = uri.substr(uri.indexOf('?') + 1);
|
|
917
|
+
if (!PushImpl.components[socketClientId]) {
|
|
918
|
+
PushImpl.components[socketClientId] = {
|
|
919
|
+
'channelToken': channelToken,
|
|
920
|
+
'onopen': resolveFunction(onopen),
|
|
921
|
+
'onmessage': resolveFunction(onmessage),
|
|
922
|
+
'onclose': onclose,
|
|
923
|
+
'behaviors': behaviorScripts,
|
|
924
|
+
'autoconnect': autoconnect
|
|
925
|
+
};
|
|
926
|
+
if (!PushImpl.clientIdsByTokens[channelToken]) {
|
|
927
|
+
PushImpl.clientIdsByTokens[channelToken] = [];
|
|
928
|
+
}
|
|
929
|
+
PushImpl.clientIdsByTokens[channelToken].push(socketClientId);
|
|
930
|
+
if (!PushImpl.sockets[channelToken]) {
|
|
931
|
+
PushImpl.sockets[channelToken] = new Socket(channelToken, getBaseURL(uri), channel);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (autoconnect) {
|
|
935
|
+
Jsf_1.jsf.push.open(socketClientId);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
PushImpl.init = init;
|
|
939
|
+
function open(socketClientId) {
|
|
940
|
+
var _a;
|
|
941
|
+
getSocket((_a = PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a.channelToken).open();
|
|
942
|
+
}
|
|
943
|
+
PushImpl.open = open;
|
|
944
|
+
function close(socketClientId) {
|
|
945
|
+
getSocket(PushImpl.components === null || PushImpl.components === void 0 ? void 0 : PushImpl.components[socketClientId].channelToken).close();
|
|
946
|
+
}
|
|
947
|
+
PushImpl.close = close;
|
|
948
|
+
// Private helper classes
|
|
949
|
+
// Private classes functions ----------------------------------------------------------------------------------
|
|
950
|
+
/**
|
|
951
|
+
* Creates a reconnecting web socket. When the web socket successfully connects on first attempt, then it will
|
|
952
|
+
* automatically reconnect on timeout with cumulative intervals of 500ms with a maximum of 25 attempts (~3 minutes).
|
|
953
|
+
* The <code>onclose</code> function will be called with the error code of the last attempt.
|
|
954
|
+
* @constructor
|
|
955
|
+
* @param {string} channelToken the channel token associated with this websocket connection
|
|
956
|
+
* @param {string} url The URL of the web socket
|
|
957
|
+
* @param {string} channel The name of the web socket channel.
|
|
958
|
+
*/
|
|
959
|
+
var Socket = /** @class */ (function () {
|
|
960
|
+
function Socket(channelToken, url, channel) {
|
|
961
|
+
this.channelToken = channelToken;
|
|
962
|
+
this.url = url;
|
|
963
|
+
this.channel = channel;
|
|
964
|
+
this.reconnectAttempts = 0;
|
|
965
|
+
}
|
|
966
|
+
Socket.prototype.open = function () {
|
|
967
|
+
if (this.socket && this.socket.readyState == 1) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
this.socket = new WebSocket(this.url);
|
|
971
|
+
this.bindCallbacks();
|
|
972
|
+
};
|
|
973
|
+
Socket.prototype.onopen = function (event) {
|
|
974
|
+
if (!this.reconnectAttempts) {
|
|
975
|
+
var clientIds = PushImpl.clientIdsByTokens[this.channelToken];
|
|
976
|
+
for (var i = clientIds.length - 1; i >= 0; i--) {
|
|
977
|
+
var socketClientId = clientIds[i];
|
|
978
|
+
PushImpl.components[socketClientId]['onopen'](this.channel);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
this.reconnectAttempts = 0;
|
|
982
|
+
};
|
|
983
|
+
Socket.prototype.onmmessage = function (event) {
|
|
984
|
+
var message = JSON.parse(event.data);
|
|
985
|
+
for (var i = PushImpl.clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
|
|
986
|
+
var socketClientId = PushImpl.clientIdsByTokens[this.channelToken][i];
|
|
987
|
+
if (document.getElementById(socketClientId)) {
|
|
988
|
+
try {
|
|
989
|
+
PushImpl.components[socketClientId]['onmessage'](message, this.channel, event);
|
|
990
|
+
}
|
|
991
|
+
catch (e) {
|
|
992
|
+
//Ignore
|
|
993
|
+
}
|
|
994
|
+
var behaviors = PushImpl.components[socketClientId]['behaviors'];
|
|
995
|
+
var functions = behaviors[message];
|
|
996
|
+
if (functions && functions.length) {
|
|
997
|
+
for (var j = 0; j < functions.length; j++) {
|
|
998
|
+
try {
|
|
999
|
+
functions[j](null);
|
|
1000
|
+
}
|
|
1001
|
+
catch (e) {
|
|
1002
|
+
//Ignore
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
PushImpl.clientIdsByTokens[this.channelToken].splice(i, 1);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
if (PushImpl.clientIdsByTokens[this.channelToken].length == 0) {
|
|
1012
|
+
//tag dissapeared
|
|
1013
|
+
this.close();
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
Socket.prototype.onclose = function (event) {
|
|
1017
|
+
if (!this.socket
|
|
1018
|
+
|| (event.code == 1000 && event.reason == Const_1.REASON_EXPIRED)
|
|
1019
|
+
|| (event.code == 1008)
|
|
1020
|
+
|| (!this.reconnectAttempts)
|
|
1021
|
+
|| (this.reconnectAttempts >= Const_1.MAX_RECONNECT_ATTEMPTS)) {
|
|
1022
|
+
var clientIds = PushImpl.clientIdsByTokens[this.channelToken];
|
|
1023
|
+
for (var i = clientIds.length - 1; i >= 0; i--) {
|
|
1024
|
+
var socketClientId = clientIds[i];
|
|
1025
|
+
PushImpl.components[socketClientId]['onclose'](event === null || event === void 0 ? void 0 : event.code, this === null || this === void 0 ? void 0 : this.channel, event);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
setTimeout(this.open, Const_1.RECONNECT_INTERVAL * this.reconnectAttempts++);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
;
|
|
1033
|
+
Socket.prototype.close = function () {
|
|
1034
|
+
if (this.socket) {
|
|
1035
|
+
var s = this.socket;
|
|
1036
|
+
this.socket = null;
|
|
1037
|
+
s.close();
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* bind the callbacks to the socket callbacks
|
|
1042
|
+
*/
|
|
1043
|
+
Socket.prototype.bindCallbacks = function () {
|
|
1044
|
+
var _this = this;
|
|
1045
|
+
this.socket.onopen = function (event) { return _this.onopen(event); };
|
|
1046
|
+
this.socket.onmessage = function (event) { return _this.onmmessage(event); };
|
|
1047
|
+
this.socket.onclose = function (event) { return _this.onclose(event); };
|
|
1048
|
+
};
|
|
1049
|
+
return Socket;
|
|
1050
|
+
}());
|
|
1051
|
+
// Private static functions ---------------------------------------------------------------------------------------
|
|
1052
|
+
function getBaseURL(url) {
|
|
1053
|
+
if (url.indexOf("://") < 0) {
|
|
1054
|
+
var base = window.location.hostname + ":" + window.location.port;
|
|
1055
|
+
return URL_PROTOCOL + base + url;
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
return url;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Get socket associated with given channelToken.
|
|
1063
|
+
* @param {string} channelToken The name of the web socket channelToken.
|
|
1064
|
+
* @return {Socket} Socket associated with given channelToken.
|
|
1065
|
+
* @throws {Error} When channelToken is unknown, you may need to initialize
|
|
1066
|
+
* it first via <code>init()</code> function.
|
|
1067
|
+
*/
|
|
1068
|
+
function getSocket(channelToken) {
|
|
1069
|
+
var socket = PushImpl.sockets[channelToken];
|
|
1070
|
+
if (socket) {
|
|
1071
|
+
return socket;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
throw new Error("Unknown channelToken: " + channelToken);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function resolveFunction(fn) {
|
|
1078
|
+
if (fn === void 0) { fn = function () {
|
|
1079
|
+
}; }
|
|
1080
|
+
return ((typeof fn !== "function") && (fn = window[fn]), fn);
|
|
1081
|
+
}
|
|
1082
|
+
})(PushImpl = exports.PushImpl || (exports.PushImpl = {}));
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
/***/ }),
|
|
1086
|
+
|
|
1087
|
+
/***/ "./src/main/typescript/impl/core/Const.ts":
|
|
1088
|
+
/*!************************************************!*\
|
|
1089
|
+
!*** ./src/main/typescript/impl/core/Const.ts ***!
|
|
1090
|
+
\************************************************/
|
|
1091
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1092
|
+
|
|
1093
|
+
"use strict";
|
|
1094
|
+
|
|
1095
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
1096
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
1097
|
+
* this work for additional information regarding copyright ownership.
|
|
1098
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
1099
|
+
* (the "License"); you may not use this file except in compliance with
|
|
1100
|
+
* the License. You may obtain a copy of the License at
|
|
1101
|
+
*
|
|
1102
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1103
|
+
*
|
|
1104
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1105
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1106
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1107
|
+
* See the License for the specific language governing permissions and
|
|
1108
|
+
* limitations under the License.
|
|
1109
|
+
*/
|
|
1110
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1111
|
+
exports.CTX_PARAM_RST = exports.CTX_PARAM_TIMEOUT = 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.RENDER = 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_VIEWBODY = exports.P_VIEWHEAD = exports.P_VIEWROOT = exports.P_VIEWSTATE = exports.PARTIAL_ID = exports.P_PARTIAL_SOURCE = void 0;
|
|
1112
|
+
exports.RECONNECT_INTERVAL = exports.APPLIED_CLIENT_WINDOW = exports.APPLIED_VST = exports.REASON_EXPIRED = exports.MF_NONE = exports.SEL_SCRIPTS_STYLES = exports.MYFACES = 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 = void 0;
|
|
1113
|
+
exports.UNKNOWN = exports.MAX_RECONNECT_ATTEMPTS = void 0;
|
|
1114
|
+
/*
|
|
1115
|
+
* [export const] constants
|
|
1116
|
+
*/
|
|
1117
|
+
exports.P_PARTIAL_SOURCE = "javax.faces.source";
|
|
1118
|
+
exports.PARTIAL_ID = "partialId";
|
|
1119
|
+
exports.P_VIEWSTATE = "javax.faces.ViewState";
|
|
1120
|
+
exports.P_VIEWROOT = "javax.faces.ViewRoot";
|
|
1121
|
+
exports.P_VIEWHEAD = "javax.faces.ViewHead";
|
|
1122
|
+
exports.P_VIEWBODY = "javax.faces.ViewBody";
|
|
1123
|
+
/*some useful definitions*/
|
|
1124
|
+
exports.EMPTY_FUNC = Object.freeze(function () {
|
|
1125
|
+
});
|
|
1126
|
+
exports.EMPTY_STR = "";
|
|
1127
|
+
exports.EMPTY_MAP = Object.freeze({});
|
|
1128
|
+
exports.HTML_VIEWSTATE = ["<input type='hidden'", "id='", exports.P_VIEWSTATE, "' name='", exports.P_VIEWSTATE, "' value='' />"].join(exports.EMPTY_STR);
|
|
1129
|
+
/*internal identifiers for options*/
|
|
1130
|
+
exports.IDENT_ALL = "@all";
|
|
1131
|
+
exports.IDENT_NONE = "@none";
|
|
1132
|
+
exports.IDENT_THIS = "@this";
|
|
1133
|
+
exports.IDENT_FORM = "@form";
|
|
1134
|
+
exports.P_AJAX = "javax.faces.partial.ajax";
|
|
1135
|
+
exports.P_EXECUTE = "javax.faces.partial.execute";
|
|
1136
|
+
exports.P_RENDER = "javax.faces.partial.render";
|
|
1137
|
+
exports.P_EVT = "javax.faces.partial.event";
|
|
1138
|
+
exports.P_CLIENT_WINDOW = "javax.faces.ClientWindow";
|
|
1139
|
+
exports.P_RESET_VALUES = "javax.faces.partial.resetValues";
|
|
1140
|
+
exports.P_WINDOW_ID = "javax.faces.windowId";
|
|
1141
|
+
exports.RENDER = "render";
|
|
1142
|
+
exports.WINDOW_ID = "windowId";
|
|
1143
|
+
/* message types */
|
|
1144
|
+
exports.ERROR = "error";
|
|
1145
|
+
exports.EVENT = "event";
|
|
1146
|
+
exports.ON_ERROR = "onerror";
|
|
1147
|
+
exports.ON_EVENT = "onevent";
|
|
1148
|
+
/* event emitting stages */
|
|
1149
|
+
exports.BEGIN = "begin";
|
|
1150
|
+
exports.COMPLETE = "complete";
|
|
1151
|
+
exports.SUCCESS = "success";
|
|
1152
|
+
exports.SOURCE = "source";
|
|
1153
|
+
exports.STATUS = "status";
|
|
1154
|
+
exports.ERROR_NAME = "error-name";
|
|
1155
|
+
exports.ERROR_MESSAGE = "error-message";
|
|
1156
|
+
exports.RESPONSE_TEXT = "responseText";
|
|
1157
|
+
exports.RESPONSE_XML = "responseXML";
|
|
1158
|
+
/*ajax errors spec 14.4.2*/
|
|
1159
|
+
exports.HTTPERROR = "httpError";
|
|
1160
|
+
exports.EMPTY_RESPONSE = "emptyResponse";
|
|
1161
|
+
exports.MALFORMEDXML = "malformedXML";
|
|
1162
|
+
exports.SERVER_ERROR = "serverError";
|
|
1163
|
+
exports.CLIENT_ERROR = "clientError";
|
|
1164
|
+
exports.TIMEOUT_EVENT = "timeout";
|
|
1165
|
+
exports.CTX_PARAM_MF_INTERNAL = "_mfInternal";
|
|
1166
|
+
exports.CTX_PARAM_SRC_FRM_ID = "_mfSourceFormId";
|
|
1167
|
+
exports.CTX_PARAM_SRC_CTL_ID = "_mfSourceControlId";
|
|
1168
|
+
exports.CTX_PARAM_TR_TYPE = "_mfTransportType";
|
|
1169
|
+
exports.CTX_PARAM_PASS_THR = "passThrgh";
|
|
1170
|
+
exports.CTX_PARAM_DELAY = "delay";
|
|
1171
|
+
exports.CTX_PARAM_TIMEOUT = "timeout";
|
|
1172
|
+
exports.CTX_PARAM_RST = "resetValues";
|
|
1173
|
+
exports.CTX_PARAM_EXECUTE = "execute";
|
|
1174
|
+
exports.STAGE_DEVELOPMENT = "Development";
|
|
1175
|
+
exports.CONTENT_TYPE = "Content-Type";
|
|
1176
|
+
exports.HEAD_FACES_REQ = "Faces-Request";
|
|
1177
|
+
exports.REQ_ACCEPT = "Accept";
|
|
1178
|
+
exports.VAL_AJAX = "partial/ajax";
|
|
1179
|
+
exports.ENCODED_URL = "javax.faces.encodedURL";
|
|
1180
|
+
exports.REQ_TYPE_GET = "GET";
|
|
1181
|
+
exports.REQ_TYPE_POST = "POST";
|
|
1182
|
+
exports.STATE_EVT_BEGIN = "begin"; //TODO remove this
|
|
1183
|
+
exports.STATE_EVT_TIMEOUT = "TIMEOUT_EVENT";
|
|
1184
|
+
exports.STATE_EVT_COMPLETE = "complete"; //TODO remove this
|
|
1185
|
+
exports.URL_ENCODED = "application/x-www-form-urlencoded";
|
|
1186
|
+
exports.MULTIPART = "multipart/form-data";
|
|
1187
|
+
exports.NO_TIMEOUT = 0;
|
|
1188
|
+
exports.STD_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
1189
|
+
exports.TAG_HEAD = "head";
|
|
1190
|
+
exports.TAG_FORM = "form";
|
|
1191
|
+
exports.TAG_BODY = "body";
|
|
1192
|
+
exports.TAG_BEFORE = "before";
|
|
1193
|
+
exports.TAG_AFTER = "after";
|
|
1194
|
+
exports.TAG_ATTR = "attribute";
|
|
1195
|
+
exports.SEL_VIEWSTATE_ELEM = "[name='" + exports.P_VIEWSTATE + "']";
|
|
1196
|
+
exports.SEL_CLIENT_WINDOW_ELEM = "[name='" + exports.P_CLIENT_WINDOW + "']";
|
|
1197
|
+
exports.SEL_RESPONSE_XML = "responseXML";
|
|
1198
|
+
exports.PHASE_PROCESS_RESPONSE = "processResponse";
|
|
1199
|
+
exports.ERR_NO_PARTIAL_RESPONSE = "Partial response not set";
|
|
1200
|
+
exports.ATTR_URL = "url";
|
|
1201
|
+
exports.ATTR_NAME = "name";
|
|
1202
|
+
exports.ATTR_VALUE = "value";
|
|
1203
|
+
exports.ATTR_ID = "id";
|
|
1204
|
+
/*partial response types*/
|
|
1205
|
+
exports.RESP_PARTIAL = "partial-response";
|
|
1206
|
+
/*partial commands*/
|
|
1207
|
+
exports.CMD_CHANGES = "changes";
|
|
1208
|
+
exports.CMD_UPDATE = "update";
|
|
1209
|
+
exports.CMD_DELETE = "delete";
|
|
1210
|
+
exports.CMD_INSERT = "insert";
|
|
1211
|
+
exports.CMD_EVAL = "eval";
|
|
1212
|
+
exports.CMD_ERROR = "error";
|
|
1213
|
+
exports.CMD_ATTRIBUTES = "attributes";
|
|
1214
|
+
exports.CMD_EXTENSION = "extension";
|
|
1215
|
+
exports.CMD_REDIRECT = "redirect";
|
|
1216
|
+
/*other constants*/
|
|
1217
|
+
exports.UPDATE_FORMS = "_updateForms";
|
|
1218
|
+
exports.UPDATE_ELEMS = "_updateElems";
|
|
1219
|
+
exports.MYFACES = "myfaces";
|
|
1220
|
+
exports.SEL_SCRIPTS_STYLES = "script, style, link";
|
|
1221
|
+
exports.MF_NONE = "__mf_none__";
|
|
1222
|
+
exports.REASON_EXPIRED = "Expired";
|
|
1223
|
+
exports.APPLIED_VST = "appliedViewState";
|
|
1224
|
+
exports.APPLIED_CLIENT_WINDOW = "appliedClientWindow";
|
|
1225
|
+
exports.RECONNECT_INTERVAL = 500;
|
|
1226
|
+
exports.MAX_RECONNECT_ATTEMPTS = 25;
|
|
1227
|
+
exports.UNKNOWN = "UNKNOWN";
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
/***/ }),
|
|
1231
|
+
|
|
1232
|
+
/***/ "./src/main/typescript/impl/core/ImplTypes.ts":
|
|
1233
|
+
/*!****************************************************!*\
|
|
1234
|
+
!*** ./src/main/typescript/impl/core/ImplTypes.ts ***!
|
|
1235
|
+
\****************************************************/
|
|
1236
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1237
|
+
|
|
1238
|
+
"use strict";
|
|
1239
|
+
|
|
1240
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1241
|
+
exports.StateHolder = void 0;
|
|
1242
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
1243
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
1244
|
+
* this work for additional information regarding copyright ownership.
|
|
1245
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
1246
|
+
* (the "License"); you may not use this file except in compliance with
|
|
1247
|
+
* the License. You may obtain a copy of the License at
|
|
1248
|
+
*
|
|
1249
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1250
|
+
*
|
|
1251
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1252
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1253
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1254
|
+
* See the License for the specific language governing permissions and
|
|
1255
|
+
* limitations under the License.
|
|
1256
|
+
*/
|
|
1257
|
+
var Const_1 = __webpack_require__(/*! ./Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
1258
|
+
/**
|
|
1259
|
+
* a helper class to isolate the
|
|
1260
|
+
* view state and client window and other
|
|
1261
|
+
* future states which follow a similar pattern
|
|
1262
|
+
*/
|
|
1263
|
+
var StateHolder = /** @class */ (function () {
|
|
1264
|
+
function StateHolder(id, value) {
|
|
1265
|
+
this.id = id;
|
|
1266
|
+
this.value = value;
|
|
1267
|
+
var viewStatePos = id.indexOf(Const_1.P_VIEWSTATE);
|
|
1268
|
+
this.nameSpace = viewStatePos > 0 ? id.substr(0, viewStatePos - 1) : Const_1.EMPTY_STR;
|
|
1269
|
+
}
|
|
1270
|
+
Object.defineProperty(StateHolder.prototype, "hasNameSpace", {
|
|
1271
|
+
get: function () {
|
|
1272
|
+
var _a;
|
|
1273
|
+
return !!((_a = this === null || this === void 0 ? void 0 : this.nameSpace) !== null && _a !== void 0 ? _a : Const_1.EMPTY_STR).length;
|
|
1274
|
+
},
|
|
1275
|
+
enumerable: false,
|
|
1276
|
+
configurable: true
|
|
1277
|
+
});
|
|
1278
|
+
return StateHolder;
|
|
1279
|
+
}());
|
|
1280
|
+
exports.StateHolder = StateHolder;
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
/***/ }),
|
|
1284
|
+
|
|
1285
|
+
/***/ "./src/main/typescript/impl/i18n/Messages.ts":
|
|
1286
|
+
/*!***************************************************!*\
|
|
1287
|
+
!*** ./src/main/typescript/impl/i18n/Messages.ts ***!
|
|
1288
|
+
\***************************************************/
|
|
1289
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1290
|
+
|
|
1291
|
+
"use strict";
|
|
1292
|
+
|
|
1293
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
1294
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
1295
|
+
* this work for additional information regarding copyright ownership.
|
|
1296
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
1297
|
+
* (the "License"); you may not use this file except in compliance with
|
|
1298
|
+
* the License. You may obtain a copy of the License at
|
|
1299
|
+
*
|
|
1300
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1301
|
+
*
|
|
1302
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1303
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1304
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1305
|
+
* See the License for the specific language governing permissions and
|
|
1306
|
+
* limitations under the License.
|
|
1307
|
+
*/
|
|
1308
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1309
|
+
exports.Messages = void 0;
|
|
1310
|
+
var Messages = /** @class */ (function () {
|
|
1311
|
+
function Messages() {
|
|
1312
|
+
this.MSG_TEST = "Testmessage";
|
|
1313
|
+
/*Messages*/
|
|
1314
|
+
/** @constant */
|
|
1315
|
+
this.MSG_DEV_MODE = "Note, this message is only sent, because project stage is development and no " +
|
|
1316
|
+
"other error listeners are registered.";
|
|
1317
|
+
/** @constant */
|
|
1318
|
+
this.MSG_AFFECTED_CLASS = "Affected Class=";
|
|
1319
|
+
/** @constant */
|
|
1320
|
+
this.MSG_AFFECTED_METHOD = "Affected Method=";
|
|
1321
|
+
/** @constant */
|
|
1322
|
+
this.MSG_ERROR_NAME = "Error Name=";
|
|
1323
|
+
/** @constant */
|
|
1324
|
+
this.MSG_ERROR_MESSAGE = "Error Message=";
|
|
1325
|
+
/** @constant */
|
|
1326
|
+
this.MSG_SERVER_ERROR_NAME = "Server Error Name=";
|
|
1327
|
+
/** @constant */
|
|
1328
|
+
this.MSG_ERROR_DESC = "Error Description=";
|
|
1329
|
+
/** @constant */
|
|
1330
|
+
this.MSG_ERROR_NO = "Error Number=";
|
|
1331
|
+
/** @constant */
|
|
1332
|
+
this.MSG_ERROR_LINENO = "Error Line Number=";
|
|
1333
|
+
/*Errors and messages*/
|
|
1334
|
+
/** @constant */
|
|
1335
|
+
this.ERR_FORM = "Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing";
|
|
1336
|
+
/** @constant */
|
|
1337
|
+
this.ERR_VIEWSTATE = "jsf.viewState= param value not of type form!";
|
|
1338
|
+
/** @constant */
|
|
1339
|
+
this.ERR_TRANSPORT = "Transport type {0} does not exist";
|
|
1340
|
+
/** @constant */
|
|
1341
|
+
this.ERR_EVT_PASS = "an event must be passed down (either a an event object null or undefined) ";
|
|
1342
|
+
/** @constant */
|
|
1343
|
+
this.ERR_CONSTRUCT = "Parts of the response couldn't be retrieved when constructing the event data= {0} ";
|
|
1344
|
+
/** @constant */
|
|
1345
|
+
this.ERR_MALFORMEDXML = "The server response could not be parsed, the server has returned with a response which is not xml !";
|
|
1346
|
+
/** @constant */
|
|
1347
|
+
this.ERR_SOURCE_FUNC = "source cannot be a function (probably source and event were not defined or set to null";
|
|
1348
|
+
/** @constant */
|
|
1349
|
+
this.ERR_EV_OR_UNKNOWN = "An event object or unknown must be passed as second parameter";
|
|
1350
|
+
/** @constant */
|
|
1351
|
+
this.ERR_SOURCE_NOSTR = "source cannot be a string";
|
|
1352
|
+
/** @constant */
|
|
1353
|
+
this.ERR_SOURCE_DEF_NULL = "source must be defined or null";
|
|
1354
|
+
//_Lang.js
|
|
1355
|
+
/** @constant */
|
|
1356
|
+
this.ERR_MUST_STRING = "{0}: {1} namespace must be of type String";
|
|
1357
|
+
/** @constant */
|
|
1358
|
+
this.ERR_REF_OR_ID = "{0}: {1} a reference node or identifier must be provided";
|
|
1359
|
+
/** @constant */
|
|
1360
|
+
this.ERR_PARAM_GENERIC = "{0}: parameter {1} must be of type {2}";
|
|
1361
|
+
/** @constant */
|
|
1362
|
+
this.ERR_PARAM_STR = "{0}: {1} param must be of type string";
|
|
1363
|
+
/** @constant */
|
|
1364
|
+
this.ERR_PARAM_STR_RE = "{0}: {1} param must be of type string or a regular expression";
|
|
1365
|
+
/** @constant */
|
|
1366
|
+
this.ERR_PARAM_MIXMAPS = "{0}: both a source as well as a destination map must be provided";
|
|
1367
|
+
/** @constant */
|
|
1368
|
+
this.ERR_MUST_BE_PROVIDED = "{0}: an {1} and a {2} must be provided";
|
|
1369
|
+
/** @constant */
|
|
1370
|
+
this.ERR_MUST_BE_PROVIDED1 = "{0}: {1} must be set";
|
|
1371
|
+
/** @constant */
|
|
1372
|
+
this.ERR_REPLACE_EL = "replaceElements called while evalNodes is not an array";
|
|
1373
|
+
/** @constant */
|
|
1374
|
+
this.ERR_EMPTY_RESPONSE = "{0}: The response cannot be null or empty!";
|
|
1375
|
+
/** @constant */
|
|
1376
|
+
this.ERR_ITEM_ID_NOTFOUND = "{0}: item with identifier {1} could not be found";
|
|
1377
|
+
/** @constant */
|
|
1378
|
+
this.ERR_PPR_IDREQ = "{0}: Error in PPR Insert, id must be present";
|
|
1379
|
+
/** @constant */
|
|
1380
|
+
this.ERR_PPR_INSERTBEFID = "{0}: Error in PPR Insert, before id or after id must be present";
|
|
1381
|
+
/** @constant */
|
|
1382
|
+
this.ERR_PPR_INSERTBEFID_1 = "{0}: Error in PPR Insert, before node of id {1} does not exist in document";
|
|
1383
|
+
/** @constant */
|
|
1384
|
+
this.ERR_PPR_INSERTBEFID_2 = "{0}: Error in PPR Insert, after node of id {1} does not exist in document";
|
|
1385
|
+
/** @constant */
|
|
1386
|
+
this.ERR_PPR_DELID = "{0}: Error in delete, id not in xml markup";
|
|
1387
|
+
/** @constant */
|
|
1388
|
+
this.ERR_PPR_UNKNOWNCID = "{0}: Unknown Html-Component-ID= {1}";
|
|
1389
|
+
/** @constant */
|
|
1390
|
+
this.ERR_NO_VIEWROOTATTR = "{0}: Changing of ViewRoot attributes is not supported";
|
|
1391
|
+
/** @constant */
|
|
1392
|
+
this.ERR_NO_HEADATTR = "{0}: Changing of Head attributes is not supported";
|
|
1393
|
+
/** @constant */
|
|
1394
|
+
this.ERR_RED_URL = "{0}: Redirect without url";
|
|
1395
|
+
/** @constant */
|
|
1396
|
+
this.ERR_REQ_FAILED_UNKNOWN = "Request failed with unknown status";
|
|
1397
|
+
/** @constant */
|
|
1398
|
+
this.ERR_REQU_FAILED = "Request failed with status {0} and reason {1}";
|
|
1399
|
+
/** @constant */
|
|
1400
|
+
this.UNKNOWN = "UNKNOWN";
|
|
1401
|
+
}
|
|
1402
|
+
return Messages;
|
|
1403
|
+
}());
|
|
1404
|
+
exports.Messages = Messages;
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
/***/ }),
|
|
1408
|
+
|
|
1409
|
+
/***/ "./src/main/typescript/impl/util/Assertions.ts":
|
|
1410
|
+
/*!*****************************************************!*\
|
|
1411
|
+
!*** ./src/main/typescript/impl/util/Assertions.ts ***!
|
|
1412
|
+
\*****************************************************/
|
|
1413
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1414
|
+
|
|
1415
|
+
"use strict";
|
|
1416
|
+
|
|
1417
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1418
|
+
exports.Assertions = void 0;
|
|
1419
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
1420
|
+
var Lang_1 = __webpack_require__(/*! ./Lang */ "./src/main/typescript/impl/util/Lang.ts");
|
|
1421
|
+
var getMessage = Lang_1.ExtLang.getMessage;
|
|
1422
|
+
var makeException = Lang_1.ExtLang.makeException;
|
|
1423
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
1424
|
+
/**
|
|
1425
|
+
* a set of internal code assertions
|
|
1426
|
+
* which raise an error
|
|
1427
|
+
*
|
|
1428
|
+
*/
|
|
1429
|
+
var Assertions;
|
|
1430
|
+
(function (Assertions) {
|
|
1431
|
+
function assertRequestIntegrity(options, elem) {
|
|
1432
|
+
/*assert if the onerror is set and once if it is set it must be of type function*/
|
|
1433
|
+
assertFunction(options.getIf(Const_1.ON_ERROR).value);
|
|
1434
|
+
/*assert if the onevent is set and once if it is set it must be of type function*/
|
|
1435
|
+
assertFunction(options.getIf(Const_1.ON_EVENT).value);
|
|
1436
|
+
//improve the error messages if an empty elem is passed
|
|
1437
|
+
//Assertions.assertElementExists(elem);
|
|
1438
|
+
assert(elem.isPresent(), getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "jsf.ajax.request", "ArgNotSet");
|
|
1439
|
+
}
|
|
1440
|
+
Assertions.assertRequestIntegrity = assertRequestIntegrity;
|
|
1441
|
+
function assertUrlExists(node) {
|
|
1442
|
+
if (node.attr(Const_1.ATTR_URL).isAbsent()) {
|
|
1443
|
+
throw Assertions.raiseError(new Error(), getMessage("ERR_RED_URL", null, "_Ajaxthis.processRedirect"), "processRedirect");
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
Assertions.assertUrlExists = assertUrlExists;
|
|
1447
|
+
/**
|
|
1448
|
+
* checks the xml for various issues which can occur
|
|
1449
|
+
* and prevent a proper processing
|
|
1450
|
+
*/
|
|
1451
|
+
function assertValidXMLResponse(responseXML) {
|
|
1452
|
+
assert(!responseXML.isAbsent(), Const_1.EMPTY_RESPONSE, Const_1.PHASE_PROCESS_RESPONSE);
|
|
1453
|
+
assert(!responseXML.isXMLParserError(), responseXML.parserErrorText(Const_1.EMPTY_STR), Const_1.PHASE_PROCESS_RESPONSE);
|
|
1454
|
+
assert(responseXML.querySelectorAll(Const_1.RESP_PARTIAL).isPresent(), Const_1.ERR_NO_PARTIAL_RESPONSE, Const_1.PHASE_PROCESS_RESPONSE);
|
|
1455
|
+
}
|
|
1456
|
+
Assertions.assertValidXMLResponse = assertValidXMLResponse;
|
|
1457
|
+
/**
|
|
1458
|
+
* internal helper which raises an error in the
|
|
1459
|
+
* format we need for further processing
|
|
1460
|
+
*
|
|
1461
|
+
* @param error
|
|
1462
|
+
* @param message the message
|
|
1463
|
+
* @param caller
|
|
1464
|
+
* @param title the title of the error (optional)
|
|
1465
|
+
* @param name the name of the error (optional)
|
|
1466
|
+
*/
|
|
1467
|
+
function raiseError(error, message, caller, title, name) {
|
|
1468
|
+
var finalTitle = title !== null && title !== void 0 ? title : Const_1.MALFORMEDXML;
|
|
1469
|
+
var finalName = name !== null && name !== void 0 ? name : Const_1.MALFORMEDXML;
|
|
1470
|
+
var finalMessage = message !== null && message !== void 0 ? message : Const_1.EMPTY_STR;
|
|
1471
|
+
//TODO clean up the messy makeException, this is a perfect case for encapsulation and sane defaults
|
|
1472
|
+
return makeException(error, finalTitle, finalName, "Response", caller || ((arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
|
|
1473
|
+
}
|
|
1474
|
+
Assertions.raiseError = raiseError;
|
|
1475
|
+
/*
|
|
1476
|
+
* using the new typescript 3.7 compiler assertion functionality to improve compiler hinting
|
|
1477
|
+
* we are not fully there yet, but soon
|
|
1478
|
+
*/
|
|
1479
|
+
function assert(value, msg, caller, title) {
|
|
1480
|
+
if (msg === void 0) { msg = Const_1.EMPTY_STR; }
|
|
1481
|
+
if (caller === void 0) { caller = Const_1.EMPTY_STR; }
|
|
1482
|
+
if (title === void 0) { title = "Assertion Error"; }
|
|
1483
|
+
if (!value) {
|
|
1484
|
+
throw Assertions.raiseError(new Error(), msg, caller, title);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
Assertions.assert = assert;
|
|
1488
|
+
function assertType(value, theType, msg, caller, title) {
|
|
1489
|
+
if (msg === void 0) { msg = Const_1.EMPTY_STR; }
|
|
1490
|
+
if (caller === void 0) { caller = Const_1.EMPTY_STR; }
|
|
1491
|
+
if (title === void 0) { title = "Type Assertion Error"; }
|
|
1492
|
+
if ((!!value) && !mona_dish_1.Lang.assertType(value, theType)) {
|
|
1493
|
+
throw Assertions.raiseError(new Error(), msg, caller, title);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
Assertions.assertType = assertType;
|
|
1497
|
+
function assertFunction(value, msg, caller, title) {
|
|
1498
|
+
if (msg === void 0) { msg = Const_1.EMPTY_STR; }
|
|
1499
|
+
if (caller === void 0) { caller = Const_1.EMPTY_STR; }
|
|
1500
|
+
if (title === void 0) { title = "Assertion Error"; }
|
|
1501
|
+
assertType(value, "function", msg, caller, title);
|
|
1502
|
+
}
|
|
1503
|
+
Assertions.assertFunction = assertFunction;
|
|
1504
|
+
})(Assertions = exports.Assertions || (exports.Assertions = {}));
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
/***/ }),
|
|
1508
|
+
|
|
1509
|
+
/***/ "./src/main/typescript/impl/util/AsyncQueue.ts":
|
|
1510
|
+
/*!*****************************************************!*\
|
|
1511
|
+
!*** ./src/main/typescript/impl/util/AsyncQueue.ts ***!
|
|
1512
|
+
\*****************************************************/
|
|
1513
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1514
|
+
|
|
1515
|
+
"use strict";
|
|
1516
|
+
|
|
1517
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1518
|
+
exports.AsynchronousQueue = void 0;
|
|
1519
|
+
/**
|
|
1520
|
+
* Asynchronous queue which starts to work
|
|
1521
|
+
* through the callbacks until the queue is empty
|
|
1522
|
+
*
|
|
1523
|
+
* Every callback must be of async runnable
|
|
1524
|
+
* which is sort of an extended promise which has
|
|
1525
|
+
* added a decicated cancel and start point
|
|
1526
|
+
*
|
|
1527
|
+
* This interface can be used as wrapper contract
|
|
1528
|
+
* for normal promises if needed.
|
|
1529
|
+
*/
|
|
1530
|
+
var AsynchronouseQueue = /** @class */ (function () {
|
|
1531
|
+
function AsynchronouseQueue() {
|
|
1532
|
+
this.runnableQueue = [];
|
|
1533
|
+
}
|
|
1534
|
+
Object.defineProperty(AsynchronouseQueue.prototype, "isEmpty", {
|
|
1535
|
+
get: function () {
|
|
1536
|
+
return !this.runnableQueue.length;
|
|
1537
|
+
},
|
|
1538
|
+
enumerable: false,
|
|
1539
|
+
configurable: true
|
|
1540
|
+
});
|
|
1541
|
+
/**
|
|
1542
|
+
* enequeues an element and starts the
|
|
1543
|
+
* asynchronous work loop if not already running
|
|
1544
|
+
*
|
|
1545
|
+
* @param element the element to be queued and processed
|
|
1546
|
+
* @param delay possible delay after our usual process or drop if something newer is incoming algorithm
|
|
1547
|
+
*/
|
|
1548
|
+
AsynchronouseQueue.prototype.enqueue = function (element, delay) {
|
|
1549
|
+
var _this = this;
|
|
1550
|
+
if (delay === void 0) { delay = 0; }
|
|
1551
|
+
if (this.delayTimeout) {
|
|
1552
|
+
clearTimeout(this.delayTimeout);
|
|
1553
|
+
this.delayTimeout = null;
|
|
1554
|
+
}
|
|
1555
|
+
if (delay) {
|
|
1556
|
+
this.delayTimeout = setTimeout(function () {
|
|
1557
|
+
_this.appendElement(element);
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
else {
|
|
1561
|
+
this.appendElement(element);
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
AsynchronouseQueue.prototype.dequeue = function () {
|
|
1565
|
+
return this.runnableQueue.shift();
|
|
1566
|
+
};
|
|
1567
|
+
AsynchronouseQueue.prototype.cleanup = function () {
|
|
1568
|
+
this.currentlyRunning = null;
|
|
1569
|
+
this.runnableQueue.length = 0;
|
|
1570
|
+
};
|
|
1571
|
+
AsynchronouseQueue.prototype.appendElement = function (element) {
|
|
1572
|
+
//only if the first element is added we start with a trigger
|
|
1573
|
+
//otherwise a process already is running and not finished yet at that
|
|
1574
|
+
//time
|
|
1575
|
+
this.runnableQueue.push(element);
|
|
1576
|
+
if (!this.currentlyRunning) {
|
|
1577
|
+
this.runEntry();
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
AsynchronouseQueue.prototype.runEntry = function () {
|
|
1581
|
+
var _this = this;
|
|
1582
|
+
if (this.isEmpty) {
|
|
1583
|
+
this.currentlyRunning = null;
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
this.currentlyRunning = this.dequeue();
|
|
1587
|
+
this.currentlyRunning
|
|
1588
|
+
.catch(function (e) {
|
|
1589
|
+
//in case of an error we always clean up the remaining calls
|
|
1590
|
+
//to allow a clean recovery of the application
|
|
1591
|
+
_this.cleanup();
|
|
1592
|
+
throw e;
|
|
1593
|
+
})
|
|
1594
|
+
.then(
|
|
1595
|
+
//the idea is to trigger the next over an event to reduce
|
|
1596
|
+
//the number of recursive calls (stacks might be limited
|
|
1597
|
+
//compared to ram)
|
|
1598
|
+
//naturally give we have a DOM, the DOM is the natural event dispatch system
|
|
1599
|
+
//which we can use, to decouple the calls from a recursive stack call
|
|
1600
|
+
//(the browser engine will take care of that)
|
|
1601
|
+
function () { return _this.callForNextElementToProcess(); }).start();
|
|
1602
|
+
};
|
|
1603
|
+
AsynchronouseQueue.prototype.cancel = function () {
|
|
1604
|
+
try {
|
|
1605
|
+
if (this.currentlyRunning) {
|
|
1606
|
+
this.currentlyRunning.cancel();
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
finally {
|
|
1610
|
+
this.cleanup();
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
AsynchronouseQueue.prototype.callForNextElementToProcess = function () {
|
|
1614
|
+
this.runEntry();
|
|
1615
|
+
};
|
|
1616
|
+
return AsynchronouseQueue;
|
|
1617
|
+
}());
|
|
1618
|
+
exports.AsynchronousQueue = AsynchronouseQueue;
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
/***/ }),
|
|
1622
|
+
|
|
1623
|
+
/***/ "./src/main/typescript/impl/util/ExtDomQuery.ts":
|
|
1624
|
+
/*!******************************************************!*\
|
|
1625
|
+
!*** ./src/main/typescript/impl/util/ExtDomQuery.ts ***!
|
|
1626
|
+
\******************************************************/
|
|
1627
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1628
|
+
|
|
1629
|
+
"use strict";
|
|
1630
|
+
|
|
1631
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1632
|
+
var extendStatics = function (d, b) {
|
|
1633
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1634
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1635
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1636
|
+
return extendStatics(d, b);
|
|
1637
|
+
};
|
|
1638
|
+
return function (d, b) {
|
|
1639
|
+
if (typeof b !== "function" && b !== null)
|
|
1640
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1641
|
+
extendStatics(d, b);
|
|
1642
|
+
function __() { this.constructor = d; }
|
|
1643
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1644
|
+
};
|
|
1645
|
+
})();
|
|
1646
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1647
|
+
exports.ExtDQ = exports.ExtDomquery = void 0;
|
|
1648
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
1649
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
1650
|
+
/**
|
|
1651
|
+
* Extension which adds implementation specific
|
|
1652
|
+
* meta data to our dom qury
|
|
1653
|
+
*
|
|
1654
|
+
* Usage
|
|
1655
|
+
* el = new ExtDQ(oldReference)
|
|
1656
|
+
* nonce = el.nonce
|
|
1657
|
+
* windowId = el.getWindowId
|
|
1658
|
+
*/
|
|
1659
|
+
var ExtDomquery = /** @class */ (function (_super) {
|
|
1660
|
+
__extends(ExtDomquery, _super);
|
|
1661
|
+
function ExtDomquery() {
|
|
1662
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1663
|
+
}
|
|
1664
|
+
Object.defineProperty(ExtDomquery, "windowId", {
|
|
1665
|
+
get: function () {
|
|
1666
|
+
return new ExtDomquery(document.body).windowId;
|
|
1667
|
+
},
|
|
1668
|
+
enumerable: false,
|
|
1669
|
+
configurable: true
|
|
1670
|
+
});
|
|
1671
|
+
Object.defineProperty(ExtDomquery, "nonce", {
|
|
1672
|
+
get: function () {
|
|
1673
|
+
return new ExtDomquery(document.body).nonce;
|
|
1674
|
+
},
|
|
1675
|
+
enumerable: false,
|
|
1676
|
+
configurable: true
|
|
1677
|
+
});
|
|
1678
|
+
Object.defineProperty(ExtDomquery.prototype, "windowId", {
|
|
1679
|
+
get: function () {
|
|
1680
|
+
var fetchWindowIdFromURL = function () {
|
|
1681
|
+
var href = window.location.href;
|
|
1682
|
+
var windowId = "windowId";
|
|
1683
|
+
var regex = new RegExp("[\\?&]" + windowId + "=([^&#\\;]*)");
|
|
1684
|
+
var results = regex.exec(href);
|
|
1685
|
+
//initial trial over the url and a regexp
|
|
1686
|
+
if (results != null)
|
|
1687
|
+
return results[1];
|
|
1688
|
+
return null;
|
|
1689
|
+
};
|
|
1690
|
+
//byId ($)
|
|
1691
|
+
if (this.value.isPresent()) {
|
|
1692
|
+
var result = this.querySelectorAll("form input[name='" + Const_1.P_WINDOW_ID + "']");
|
|
1693
|
+
if (result.length > 0) {
|
|
1694
|
+
throw Error("Multiple different windowIds found in document");
|
|
1695
|
+
}
|
|
1696
|
+
return (result.isPresent()) ? result.getAsElem(0).value.value : fetchWindowIdFromURL();
|
|
1697
|
+
}
|
|
1698
|
+
else {
|
|
1699
|
+
return fetchWindowIdFromURL();
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1702
|
+
enumerable: false,
|
|
1703
|
+
configurable: true
|
|
1704
|
+
});
|
|
1705
|
+
Object.defineProperty(ExtDomquery.prototype, "nonce", {
|
|
1706
|
+
/*
|
|
1707
|
+
determines the jsfjs nonce and adds them to the namespace
|
|
1708
|
+
* this is done once and only lazily
|
|
1709
|
+
*/
|
|
1710
|
+
get: function () {
|
|
1711
|
+
//already processed
|
|
1712
|
+
var myfacesConfig = new mona_dish_1.Config(window.myfaces);
|
|
1713
|
+
var nonce = myfacesConfig.assign("config", "cspMeta", "nonce");
|
|
1714
|
+
if (nonce.value) {
|
|
1715
|
+
return nonce.value;
|
|
1716
|
+
}
|
|
1717
|
+
var curScript = new mona_dish_1.DQ(document.currentScript);
|
|
1718
|
+
//since our baseline atm is ie11 we cannot use document.currentScript globally
|
|
1719
|
+
if (curScript.attr("nonce").value != null) {
|
|
1720
|
+
//fastpath for modern browsers
|
|
1721
|
+
return curScript.attr("nonce").value;
|
|
1722
|
+
}
|
|
1723
|
+
var nonceScript = mona_dish_1.DQ
|
|
1724
|
+
.querySelectorAll("script[src], link[src]")
|
|
1725
|
+
.lazyStream
|
|
1726
|
+
.filter(function (item) { return item.attr("nonce").value != null && item.attr("src") != null; })
|
|
1727
|
+
.map((function (item) { return !item.attr("src").value.match(/jsf\.js\?ln=javax\.faces/gi); }))
|
|
1728
|
+
.first();
|
|
1729
|
+
if (nonceScript.isPresent()) {
|
|
1730
|
+
nonce.value = mona_dish_1.DomQuery.byId(nonceScript.value, true).attr("nonce").value;
|
|
1731
|
+
}
|
|
1732
|
+
return nonce.value;
|
|
1733
|
+
},
|
|
1734
|
+
enumerable: false,
|
|
1735
|
+
configurable: true
|
|
1736
|
+
});
|
|
1737
|
+
ExtDomquery.searchJsfJsFor = function (item) {
|
|
1738
|
+
return new ExtDomquery(document).searchJsfJsFor(item);
|
|
1739
|
+
};
|
|
1740
|
+
ExtDomquery.prototype.searchJsfJsFor = function (rexp) {
|
|
1741
|
+
//perfect application for lazy stream
|
|
1742
|
+
return mona_dish_1.DQ.querySelectorAll("script").lazyStream
|
|
1743
|
+
.filter(function (item) {
|
|
1744
|
+
var _a;
|
|
1745
|
+
return ((_a = item.attr("src").value) !== null && _a !== void 0 ? _a : Const_1.EMPTY_STR).search(/\/javax\.faces\.resource.*\/jsf\.js.*separator/) != -1;
|
|
1746
|
+
}).map(function (item) {
|
|
1747
|
+
var result = item.attr("src").value.match(rexp);
|
|
1748
|
+
return decodeURIComponent(result[1]);
|
|
1749
|
+
}).first();
|
|
1750
|
+
};
|
|
1751
|
+
ExtDomquery.prototype.globalEval = function (code, nonce) {
|
|
1752
|
+
return _super.prototype.globalEval.call(this, code, nonce !== null && nonce !== void 0 ? nonce : this.nonce);
|
|
1753
|
+
};
|
|
1754
|
+
return ExtDomquery;
|
|
1755
|
+
}(mona_dish_1.DQ));
|
|
1756
|
+
exports.ExtDomquery = ExtDomquery;
|
|
1757
|
+
exports.ExtDQ = mona_dish_1.DQ;
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
/***/ }),
|
|
1761
|
+
|
|
1762
|
+
/***/ "./src/main/typescript/impl/util/Lang.ts":
|
|
1763
|
+
/*!***********************************************!*\
|
|
1764
|
+
!*** ./src/main/typescript/impl/util/Lang.ts ***!
|
|
1765
|
+
\***********************************************/
|
|
1766
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1767
|
+
|
|
1768
|
+
"use strict";
|
|
1769
|
+
|
|
1770
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
1771
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
1772
|
+
* this work for additional information regarding copyright ownership.
|
|
1773
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
1774
|
+
* (the "License"); you may not use this file except in compliance with
|
|
1775
|
+
* the License. You may obtain a copy of the License at
|
|
1776
|
+
*
|
|
1777
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1778
|
+
*
|
|
1779
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1780
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1781
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1782
|
+
* See the License for the specific language governing permissions and
|
|
1783
|
+
* limitations under the License.
|
|
1784
|
+
*
|
|
1785
|
+
* todo replace singleton with module definition
|
|
1786
|
+
*
|
|
1787
|
+
*/
|
|
1788
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1789
|
+
exports.ExtLang = void 0;
|
|
1790
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
1791
|
+
var Messages_1 = __webpack_require__(/*! ../i18n/Messages */ "./src/main/typescript/impl/i18n/Messages.ts");
|
|
1792
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
1793
|
+
var RequestDataResolver_1 = __webpack_require__(/*! ../xhrCore/RequestDataResolver */ "./src/main/typescript/impl/xhrCore/RequestDataResolver.ts");
|
|
1794
|
+
var ExtLang;
|
|
1795
|
+
(function (ExtLang) {
|
|
1796
|
+
var installedLocale;
|
|
1797
|
+
var nameSpace = "impl/util/Lang/";
|
|
1798
|
+
function getLanguage() {
|
|
1799
|
+
//TODO global config override
|
|
1800
|
+
var _a, _b;
|
|
1801
|
+
var language = (_b = (_a = navigator.languages) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : navigator === null || navigator === void 0 ? void 0 : navigator.language;
|
|
1802
|
+
language = language.split("-")[0];
|
|
1803
|
+
return language;
|
|
1804
|
+
}
|
|
1805
|
+
ExtLang.getLanguage = getLanguage;
|
|
1806
|
+
//should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those
|
|
1807
|
+
/**
|
|
1808
|
+
* helper function to savely resolve anything
|
|
1809
|
+
* this is not an elvis operator, it resolves
|
|
1810
|
+
* a value without exception in a tree and if
|
|
1811
|
+
* it is not resolvable then an optional of
|
|
1812
|
+
* a default value is restored or Optional.empty
|
|
1813
|
+
* if none is given
|
|
1814
|
+
*
|
|
1815
|
+
* usage
|
|
1816
|
+
* <code>
|
|
1817
|
+
* let var: Optional<string> = saveResolve(() => a.b.c.d.e, "foobaz")
|
|
1818
|
+
* </code>
|
|
1819
|
+
*
|
|
1820
|
+
* @param resolverProducer a lambda which can produce the value
|
|
1821
|
+
* @param defaultValue an optional default value if the producer failes to produce anything
|
|
1822
|
+
* @returns an Optional of the produced value
|
|
1823
|
+
*/
|
|
1824
|
+
function failSaveResolve(resolverProducer, defaultValue) {
|
|
1825
|
+
if (defaultValue === void 0) { defaultValue = null; }
|
|
1826
|
+
return mona_dish_1.Lang.saveResolve(resolverProducer, defaultValue);
|
|
1827
|
+
}
|
|
1828
|
+
ExtLang.failSaveResolve = failSaveResolve;
|
|
1829
|
+
/**
|
|
1830
|
+
* under some conditions it makes sense to swallow errors and return a default value in the error case
|
|
1831
|
+
* classical example the optional resolution of values in a chain (thankfully now covered by Typescript itself)
|
|
1832
|
+
* another example which we have in our system is that some operations fail only under test due to test framework
|
|
1833
|
+
* limitations while they cannot fail in the real world.
|
|
1834
|
+
*
|
|
1835
|
+
* @param resolverProducer a producer function which produces a value in the non error case
|
|
1836
|
+
* @param defaultValue the default value in case of a fail of the function
|
|
1837
|
+
*/
|
|
1838
|
+
function failSaveExecute(resolverProducer, defaultValue) {
|
|
1839
|
+
if (defaultValue === void 0) { defaultValue = null; }
|
|
1840
|
+
mona_dish_1.Lang.saveResolve(resolverProducer, defaultValue);
|
|
1841
|
+
}
|
|
1842
|
+
ExtLang.failSaveExecute = failSaveExecute;
|
|
1843
|
+
/**
|
|
1844
|
+
* returns a given localized message upon a given key
|
|
1845
|
+
* basic java log like templating functionality is included
|
|
1846
|
+
*
|
|
1847
|
+
* @param {String} key the key for the message
|
|
1848
|
+
* @param {String} defaultMessage optional default message if none was found
|
|
1849
|
+
*
|
|
1850
|
+
* Additionally you can pass additional arguments, which are used
|
|
1851
|
+
* in the same way java log templates use the params
|
|
1852
|
+
*
|
|
1853
|
+
* @param templateParams the param list to be filled in
|
|
1854
|
+
*/
|
|
1855
|
+
function getMessage(key, defaultMessage) {
|
|
1856
|
+
var _a, _b;
|
|
1857
|
+
var templateParams = [];
|
|
1858
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1859
|
+
templateParams[_i - 2] = arguments[_i];
|
|
1860
|
+
}
|
|
1861
|
+
installedLocale = installedLocale !== null && installedLocale !== void 0 ? installedLocale : new Messages_1.Messages();
|
|
1862
|
+
var msg = (_b = (_a = installedLocale[key]) !== null && _a !== void 0 ? _a : defaultMessage) !== null && _b !== void 0 ? _b : key + " - undefined message";
|
|
1863
|
+
mona_dish_1.Stream.of.apply(mona_dish_1.Stream, templateParams).each(function (param, cnt) {
|
|
1864
|
+
msg = msg.replace(new RegExp(["\\{", cnt, "\\}"].join(Const_1.EMPTY_STR), "g"), param);
|
|
1865
|
+
});
|
|
1866
|
+
return msg;
|
|
1867
|
+
}
|
|
1868
|
+
ExtLang.getMessage = getMessage;
|
|
1869
|
+
/**
|
|
1870
|
+
* transforms a key value pair into a string
|
|
1871
|
+
* @param key the key
|
|
1872
|
+
* @param val the value
|
|
1873
|
+
* @param delimiter the delimiter
|
|
1874
|
+
*/
|
|
1875
|
+
function keyValToStr(key, val, delimiter) {
|
|
1876
|
+
if (delimiter === void 0) { delimiter = "\n"; }
|
|
1877
|
+
return [key, val].join(delimiter);
|
|
1878
|
+
}
|
|
1879
|
+
ExtLang.keyValToStr = keyValToStr;
|
|
1880
|
+
/**
|
|
1881
|
+
* creates an exeption with additional internal parameters
|
|
1882
|
+
* for extra information
|
|
1883
|
+
*
|
|
1884
|
+
* @param error
|
|
1885
|
+
* @param {String} title the exception title
|
|
1886
|
+
* @param {String} name the exception name
|
|
1887
|
+
* @param {String} callerCls the caller class
|
|
1888
|
+
* @param {String} callFunc the caller function
|
|
1889
|
+
* @param {String} message the message for the exception
|
|
1890
|
+
*/
|
|
1891
|
+
function makeException(error, title, name, callerCls, callFunc, message) {
|
|
1892
|
+
var _a;
|
|
1893
|
+
return new Error((_a = message + (callerCls !== null && callerCls !== void 0 ? callerCls : nameSpace) + callFunc) !== null && _a !== void 0 ? _a : (Const_1.EMPTY_STR + arguments.caller.toString()));
|
|
1894
|
+
}
|
|
1895
|
+
ExtLang.makeException = makeException;
|
|
1896
|
+
/**
|
|
1897
|
+
* fetches a global config entry
|
|
1898
|
+
* @param {String} configName the name of the configuration entry
|
|
1899
|
+
* @param {Object} defaultValue
|
|
1900
|
+
*
|
|
1901
|
+
* @return either the config entry or if none is given the default value
|
|
1902
|
+
*/
|
|
1903
|
+
function getGlobalConfig(configName, defaultValue) {
|
|
1904
|
+
var _a, _b, _c;
|
|
1905
|
+
/**
|
|
1906
|
+
* note we could use exists but this is an heavy operation, since the config name usually
|
|
1907
|
+
* given this function here is called very often
|
|
1908
|
+
* is a single entry without . in between we can do the lighter shortcut
|
|
1909
|
+
*/
|
|
1910
|
+
return (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.myfaces) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b[configName]) !== null && _c !== void 0 ? _c : defaultValue;
|
|
1911
|
+
}
|
|
1912
|
+
ExtLang.getGlobalConfig = getGlobalConfig;
|
|
1913
|
+
/**
|
|
1914
|
+
* fetches the form in an fuzzy manner depending
|
|
1915
|
+
* on an element or event target.
|
|
1916
|
+
*
|
|
1917
|
+
* The idea is that according to the jsf spec
|
|
1918
|
+
* the enclosing form of the issuing element needs to be fetched.
|
|
1919
|
+
*
|
|
1920
|
+
* This is fine, but since then html5 came into the picture with the form attribute the element
|
|
1921
|
+
* can be anywhere referencing its parent form.
|
|
1922
|
+
*
|
|
1923
|
+
* Also theoretically you can have the case of an issuing element enclosing a set of forms
|
|
1924
|
+
* (not really often used, but theoretically it could be input button allows to embed html for instance)
|
|
1925
|
+
*
|
|
1926
|
+
* So the idea is not to limit the issuing form determination to the spec case
|
|
1927
|
+
* but also cover the theoretical and html5 corner case.
|
|
1928
|
+
*
|
|
1929
|
+
* @param elem
|
|
1930
|
+
* @param event
|
|
1931
|
+
*/
|
|
1932
|
+
function getForm(elem, event) {
|
|
1933
|
+
var queryElem = new mona_dish_1.DQ(elem);
|
|
1934
|
+
var eventTarget = new mona_dish_1.DQ((0, RequestDataResolver_1.getEventTarget)(event));
|
|
1935
|
+
if (queryElem.isTag(Const_1.TAG_FORM)) {
|
|
1936
|
+
return queryElem;
|
|
1937
|
+
}
|
|
1938
|
+
//html 5 for handling
|
|
1939
|
+
if (queryElem.attr(Const_1.TAG_FORM).isPresent()) {
|
|
1940
|
+
var formId = queryElem.attr(Const_1.TAG_FORM).value;
|
|
1941
|
+
var foundForm = mona_dish_1.DQ.byId(formId, true);
|
|
1942
|
+
if (foundForm.isPresent()) {
|
|
1943
|
+
return foundForm;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
var form = queryElem.parents(Const_1.TAG_FORM)
|
|
1947
|
+
.orElseLazy(function () { return queryElem.byTagName(Const_1.TAG_FORM, true); })
|
|
1948
|
+
.orElseLazy(function () { return eventTarget.parents(Const_1.TAG_FORM); })
|
|
1949
|
+
.orElseLazy(function () { return eventTarget.byTagName(Const_1.TAG_FORM); })
|
|
1950
|
+
.first();
|
|
1951
|
+
assertFormExists(form);
|
|
1952
|
+
return form;
|
|
1953
|
+
}
|
|
1954
|
+
ExtLang.getForm = getForm;
|
|
1955
|
+
/**
|
|
1956
|
+
* gets the local or global options with local ones having higher priority
|
|
1957
|
+
* if no local or global one was found then the default value is given back
|
|
1958
|
+
*
|
|
1959
|
+
* @param {String} configName the name of the configuration entry
|
|
1960
|
+
* @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
|
|
1961
|
+
*
|
|
1962
|
+
* @param {Object} defaultValue
|
|
1963
|
+
*
|
|
1964
|
+
* @return either the config entry or if none is given the default value
|
|
1965
|
+
*/
|
|
1966
|
+
function getLocalOrGlobalConfig(localOptions, configName, defaultValue) {
|
|
1967
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1968
|
+
return (_g = (_d = (_c = (_b = (_a = localOptions.value) === null || _a === void 0 ? void 0 : _a.myfaces) === null || _b === void 0 ? void 0 : _b.config) === null || _c === void 0 ? void 0 : _c[configName]) !== null && _d !== void 0 ? _d : (_f = (_e = window === null || window === void 0 ? void 0 : window.myfaces) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f[configName]) !== null && _g !== void 0 ? _g : defaultValue;
|
|
1969
|
+
}
|
|
1970
|
+
ExtLang.getLocalOrGlobalConfig = getLocalOrGlobalConfig;
|
|
1971
|
+
/**
|
|
1972
|
+
* assert that the form exists and throw an exception in the case it does not
|
|
1973
|
+
* (TODO move this into the assertions)
|
|
1974
|
+
*
|
|
1975
|
+
* @param form the form to check for
|
|
1976
|
+
*/
|
|
1977
|
+
function assertFormExists(form) {
|
|
1978
|
+
if (form.isAbsent()) {
|
|
1979
|
+
throw makeException(new Error(), null, null, "Impl", "getForm", getMessage("ERR_FORM"));
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
})(ExtLang = exports.ExtLang || (exports.ExtLang = {}));
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
/***/ }),
|
|
1986
|
+
|
|
1987
|
+
/***/ "./src/main/typescript/impl/xhrCore/ErrorData.ts":
|
|
1988
|
+
/*!*******************************************************!*\
|
|
1989
|
+
!*** ./src/main/typescript/impl/xhrCore/ErrorData.ts ***!
|
|
1990
|
+
\*******************************************************/
|
|
1991
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1992
|
+
|
|
1993
|
+
"use strict";
|
|
1994
|
+
|
|
1995
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1996
|
+
var extendStatics = function (d, b) {
|
|
1997
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1998
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1999
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2000
|
+
return extendStatics(d, b);
|
|
2001
|
+
};
|
|
2002
|
+
return function (d, b) {
|
|
2003
|
+
if (typeof b !== "function" && b !== null)
|
|
2004
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2005
|
+
extendStatics(d, b);
|
|
2006
|
+
function __() { this.constructor = d; }
|
|
2007
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2008
|
+
};
|
|
2009
|
+
})();
|
|
2010
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2011
|
+
exports.ErrorData = exports.ErrorType = void 0;
|
|
2012
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2013
|
+
var EventData_1 = __webpack_require__(/*! ./EventData */ "./src/main/typescript/impl/xhrCore/EventData.ts");
|
|
2014
|
+
var Lang_1 = __webpack_require__(/*! ../util/Lang */ "./src/main/typescript/impl/util/Lang.ts");
|
|
2015
|
+
var getMessage = Lang_1.ExtLang.getMessage;
|
|
2016
|
+
var ErrorType;
|
|
2017
|
+
(function (ErrorType) {
|
|
2018
|
+
ErrorType["SERVER_ERROR"] = "serverError";
|
|
2019
|
+
ErrorType["HTTP_ERROR"] = "httpError";
|
|
2020
|
+
ErrorType["CLIENT_ERROR"] = "clientErrror";
|
|
2021
|
+
ErrorType["TIMEOUT"] = "timeout";
|
|
2022
|
+
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
2023
|
+
/**
|
|
2024
|
+
* the spec has a problem of having the error
|
|
2025
|
+
* object somewhat underspecified, there is no clear
|
|
2026
|
+
* description of the required contents.
|
|
2027
|
+
* I want to streamline it with mojarra here
|
|
2028
|
+
* hence we are going to move
|
|
2029
|
+
* everything into the same attributes,
|
|
2030
|
+
* I will add deprecated myfaces backwards compatibility attributes as well
|
|
2031
|
+
*/
|
|
2032
|
+
var ErrorData = /** @class */ (function (_super) {
|
|
2033
|
+
__extends(ErrorData, _super);
|
|
2034
|
+
function ErrorData(source, errorName, errorMessage, responseText, responseXML, responseCode, status, type) {
|
|
2035
|
+
if (responseText === void 0) { responseText = null; }
|
|
2036
|
+
if (responseXML === void 0) { responseXML = null; }
|
|
2037
|
+
if (responseCode === void 0) { responseCode = "200"; }
|
|
2038
|
+
if (status === void 0) { status = "UNKNOWN"; }
|
|
2039
|
+
if (type === void 0) { type = ErrorType.CLIENT_ERROR; }
|
|
2040
|
+
var _this = _super.call(this) || this;
|
|
2041
|
+
_this.type = "error";
|
|
2042
|
+
_this.source = source;
|
|
2043
|
+
_this.type = "error";
|
|
2044
|
+
_this.errorName = errorName;
|
|
2045
|
+
_this.message = _this.errorMessage = errorMessage;
|
|
2046
|
+
_this.responseCode = responseCode;
|
|
2047
|
+
_this.responseText = responseText;
|
|
2048
|
+
_this.status = status;
|
|
2049
|
+
_this.typeDetails = type;
|
|
2050
|
+
if (type == ErrorType.SERVER_ERROR) {
|
|
2051
|
+
_this.serverErrorName = _this.errorName;
|
|
2052
|
+
_this.serverErrorMessage = _this.errorMessage;
|
|
2053
|
+
}
|
|
2054
|
+
return _this;
|
|
2055
|
+
}
|
|
2056
|
+
ErrorData.fromClient = function (e) {
|
|
2057
|
+
return new ErrorData("client", e.name, e.message, e.stack);
|
|
2058
|
+
};
|
|
2059
|
+
ErrorData.fromHttpConnection = function (source, name, message, responseText, responseCode) {
|
|
2060
|
+
return new ErrorData(source, name, message, responseText, responseCode, null, "UNKNOWN", ErrorType.HTTP_ERROR);
|
|
2061
|
+
};
|
|
2062
|
+
ErrorData.fromGeneric = function (context, errorCode, errorType) {
|
|
2063
|
+
if (errorType === void 0) { errorType = ErrorType.SERVER_ERROR; }
|
|
2064
|
+
var getMsg = this.getMsg;
|
|
2065
|
+
var source = getMsg(context, Const_1.SOURCE);
|
|
2066
|
+
var errorName = getMsg(context, Const_1.ERROR_NAME);
|
|
2067
|
+
var errorMessage = getMsg(context, Const_1.ERROR_MESSAGE);
|
|
2068
|
+
var status = getMsg(context, Const_1.STATUS);
|
|
2069
|
+
var responseText = getMsg(context, Const_1.RESPONSE_TEXT);
|
|
2070
|
+
var responseXML = getMsg(context, Const_1.RESPONSE_XML);
|
|
2071
|
+
return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode + Const_1.EMPTY_STR, status, errorType);
|
|
2072
|
+
};
|
|
2073
|
+
ErrorData.getMsg = function (context, param) {
|
|
2074
|
+
return getMessage(context.getIf(param).orElse(Const_1.UNKNOWN).value);
|
|
2075
|
+
};
|
|
2076
|
+
ErrorData.fromServerError = function (context) {
|
|
2077
|
+
return this.fromGeneric(context, -1);
|
|
2078
|
+
};
|
|
2079
|
+
return ErrorData;
|
|
2080
|
+
}(EventData_1.EventData));
|
|
2081
|
+
exports.ErrorData = ErrorData;
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
/***/ }),
|
|
2085
|
+
|
|
2086
|
+
/***/ "./src/main/typescript/impl/xhrCore/EventData.ts":
|
|
2087
|
+
/*!*******************************************************!*\
|
|
2088
|
+
!*** ./src/main/typescript/impl/xhrCore/EventData.ts ***!
|
|
2089
|
+
\*******************************************************/
|
|
2090
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2091
|
+
|
|
2092
|
+
"use strict";
|
|
2093
|
+
|
|
2094
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2095
|
+
exports.EventData = void 0;
|
|
2096
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2097
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2098
|
+
var EventData = /** @class */ (function () {
|
|
2099
|
+
function EventData() {
|
|
2100
|
+
}
|
|
2101
|
+
EventData.createFromRequest = function (request, context, /*event name*/ name) {
|
|
2102
|
+
var _a;
|
|
2103
|
+
var eventData = new EventData();
|
|
2104
|
+
eventData.type = Const_1.EVENT;
|
|
2105
|
+
eventData.status = name;
|
|
2106
|
+
var sourceId = context.getIf(Const_1.SOURCE)
|
|
2107
|
+
.orElse(context.getIf(Const_1.P_PARTIAL_SOURCE).value)
|
|
2108
|
+
.orElse(context.getIf(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value).value;
|
|
2109
|
+
if (sourceId) {
|
|
2110
|
+
eventData.source = mona_dish_1.DQ.byId(sourceId, true).first().value.value;
|
|
2111
|
+
}
|
|
2112
|
+
if (name !== Const_1.BEGIN) {
|
|
2113
|
+
eventData.responseCode = (_a = request === null || request === void 0 ? void 0 : request.status) === null || _a === void 0 ? void 0 : _a.toString();
|
|
2114
|
+
eventData.responseText = request === null || request === void 0 ? void 0 : request.responseText;
|
|
2115
|
+
eventData.responseXML = request === null || request === void 0 ? void 0 : request.responseXML;
|
|
2116
|
+
}
|
|
2117
|
+
return eventData;
|
|
2118
|
+
};
|
|
2119
|
+
return EventData;
|
|
2120
|
+
}());
|
|
2121
|
+
exports.EventData = EventData;
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
/***/ }),
|
|
2125
|
+
|
|
2126
|
+
/***/ "./src/main/typescript/impl/xhrCore/RequestDataResolver.ts":
|
|
2127
|
+
/*!*****************************************************************!*\
|
|
2128
|
+
!*** ./src/main/typescript/impl/xhrCore/RequestDataResolver.ts ***!
|
|
2129
|
+
\*****************************************************************/
|
|
2130
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2131
|
+
|
|
2132
|
+
"use strict";
|
|
2133
|
+
|
|
2134
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2135
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
2136
|
+
* this work for additional information regarding copyright ownership.
|
|
2137
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
2138
|
+
* (the "License"); you may not use this file except in compliance with
|
|
2139
|
+
* the License. You may obtain a copy of the License at
|
|
2140
|
+
*
|
|
2141
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2142
|
+
*
|
|
2143
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2144
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2145
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2146
|
+
* See the License for the specific language governing permissions and
|
|
2147
|
+
* limitations under the License.
|
|
2148
|
+
*/
|
|
2149
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2150
|
+
exports.resolveDefaults = exports.getEventTarget = exports.resolveWindowId = exports.resolveDelay = exports.resolveTimeout = exports.resolveForm = exports.resolveFinalUrl = exports.resolveTargetUrl = exports.resolveHandlerFunc = void 0;
|
|
2151
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2152
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2153
|
+
var Lang_1 = __webpack_require__(/*! ../util/Lang */ "./src/main/typescript/impl/util/Lang.ts");
|
|
2154
|
+
var ExtDomQuery_1 = __webpack_require__(/*! ../util/ExtDomQuery */ "./src/main/typescript/impl/util/ExtDomQuery.ts");
|
|
2155
|
+
/**
|
|
2156
|
+
* Resolver functions for various aspects of the request data
|
|
2157
|
+
*
|
|
2158
|
+
* stateless because it might be called from various
|
|
2159
|
+
* parts of the response classes
|
|
2160
|
+
*/
|
|
2161
|
+
/**
|
|
2162
|
+
* resolves the event handlers lazly
|
|
2163
|
+
* so that if some decoration happens in between we can deal with it
|
|
2164
|
+
*
|
|
2165
|
+
* @param requestContext
|
|
2166
|
+
* @param responseContext
|
|
2167
|
+
* @param funcName
|
|
2168
|
+
*/
|
|
2169
|
+
function resolveHandlerFunc(requestContext, responseContext, funcName) {
|
|
2170
|
+
return responseContext.getIf(funcName)
|
|
2171
|
+
.orElse(requestContext.getIf(funcName).value)
|
|
2172
|
+
.orElse(Const_1.EMPTY_FUNC).value;
|
|
2173
|
+
}
|
|
2174
|
+
exports.resolveHandlerFunc = resolveHandlerFunc;
|
|
2175
|
+
function resolveTargetUrl(srcFormElement) {
|
|
2176
|
+
return (typeof srcFormElement.elements[Const_1.ENCODED_URL] == 'undefined') ?
|
|
2177
|
+
srcFormElement.action :
|
|
2178
|
+
srcFormElement.elements[Const_1.ENCODED_URL].value;
|
|
2179
|
+
}
|
|
2180
|
+
exports.resolveTargetUrl = resolveTargetUrl;
|
|
2181
|
+
function resolveFinalUrl(sourceForm, formData, ajaxType) {
|
|
2182
|
+
if (ajaxType === void 0) { ajaxType = Const_1.REQ_TYPE_POST; }
|
|
2183
|
+
var targetUrl = resolveTargetUrl(sourceForm.getAsElem(0).value);
|
|
2184
|
+
return targetUrl + (ajaxType == Const_1.REQ_TYPE_GET ? "?" + formData.toString() : Const_1.EMPTY_STR);
|
|
2185
|
+
}
|
|
2186
|
+
exports.resolveFinalUrl = resolveFinalUrl;
|
|
2187
|
+
/**
|
|
2188
|
+
* form resolution the same way our old implementation did
|
|
2189
|
+
* it is either the id or the parent form of the element or an embedded form
|
|
2190
|
+
* of the element
|
|
2191
|
+
*
|
|
2192
|
+
* @param requestCtx
|
|
2193
|
+
* @param elem
|
|
2194
|
+
* @param event
|
|
2195
|
+
*/
|
|
2196
|
+
function resolveForm(requestCtx, elem, event) {
|
|
2197
|
+
var _a, _b, _c;
|
|
2198
|
+
var configId = (_c = (_b = (_a = requestCtx.value) === null || _a === void 0 ? void 0 : _a.myfaces) === null || _b === void 0 ? void 0 : _b.form) !== null && _c !== void 0 ? _c : Const_1.MF_NONE; //requestCtx.getIf(MYFACES, "form").orElse(MF_NONE).value;
|
|
2199
|
+
return mona_dish_1.DQ
|
|
2200
|
+
.byId(configId, true)
|
|
2201
|
+
.orElseLazy(function () { return Lang_1.ExtLang.getForm(elem.getAsElem(0).value, event); });
|
|
2202
|
+
}
|
|
2203
|
+
exports.resolveForm = resolveForm;
|
|
2204
|
+
function resolveTimeout(options) {
|
|
2205
|
+
var _a;
|
|
2206
|
+
var getCfg = Lang_1.ExtLang.getLocalOrGlobalConfig;
|
|
2207
|
+
return (_a = options.getIf(Const_1.CTX_PARAM_TIMEOUT).value) !== null && _a !== void 0 ? _a : getCfg(options.value, Const_1.CTX_PARAM_TIMEOUT, 0);
|
|
2208
|
+
}
|
|
2209
|
+
exports.resolveTimeout = resolveTimeout;
|
|
2210
|
+
/**
|
|
2211
|
+
* resolve the delay from the options and/or the request context and or the configuration
|
|
2212
|
+
*
|
|
2213
|
+
* @param options ... the options object, in most cases it will host the delay value
|
|
2214
|
+
*/
|
|
2215
|
+
function resolveDelay(options) {
|
|
2216
|
+
var _a;
|
|
2217
|
+
var getCfg = Lang_1.ExtLang.getLocalOrGlobalConfig;
|
|
2218
|
+
return (_a = options.getIf(Const_1.CTX_PARAM_DELAY).value) !== null && _a !== void 0 ? _a : getCfg(options.value, Const_1.CTX_PARAM_DELAY, 0);
|
|
2219
|
+
}
|
|
2220
|
+
exports.resolveDelay = resolveDelay;
|
|
2221
|
+
/**
|
|
2222
|
+
* resolves the window Id from various sources
|
|
2223
|
+
*
|
|
2224
|
+
* @param options
|
|
2225
|
+
*/
|
|
2226
|
+
function resolveWindowId(options) {
|
|
2227
|
+
var _a, _b;
|
|
2228
|
+
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;
|
|
2229
|
+
}
|
|
2230
|
+
exports.resolveWindowId = resolveWindowId;
|
|
2231
|
+
/**
|
|
2232
|
+
* cross port from the dojo lib
|
|
2233
|
+
* browser save event resolution
|
|
2234
|
+
* @param evt the event object
|
|
2235
|
+
* (with a fallback for ie events if none is present)
|
|
2236
|
+
*/
|
|
2237
|
+
function getEventTarget(evt) {
|
|
2238
|
+
var _a, _b;
|
|
2239
|
+
//ie6 and 7 fallback
|
|
2240
|
+
var finalEvent = evt;
|
|
2241
|
+
/**
|
|
2242
|
+
* evt source is defined in the jsf events
|
|
2243
|
+
* seems like some component authors use our code
|
|
2244
|
+
* so we add it here see also
|
|
2245
|
+
* https://issues.apache.org/jira/browse/MYFACES-2458
|
|
2246
|
+
* not entirely a bug but makes sense to add this
|
|
2247
|
+
* behavior. I dont use it that way but nevertheless it
|
|
2248
|
+
* does not break anything so why not
|
|
2249
|
+
* */
|
|
2250
|
+
var t = (_b = (_a = finalEvent === null || finalEvent === void 0 ? void 0 : finalEvent.srcElement) !== null && _a !== void 0 ? _a : finalEvent === null || finalEvent === void 0 ? void 0 : finalEvent.target) !== null && _b !== void 0 ? _b : finalEvent === null || finalEvent === void 0 ? void 0 : finalEvent.source;
|
|
2251
|
+
while ((t) && (t.nodeType != 1)) {
|
|
2252
|
+
t = t.parentNode;
|
|
2253
|
+
}
|
|
2254
|
+
return t;
|
|
2255
|
+
}
|
|
2256
|
+
exports.getEventTarget = getEventTarget;
|
|
2257
|
+
/**
|
|
2258
|
+
* resolves a bunch of default values
|
|
2259
|
+
* which can be further processed from the given
|
|
2260
|
+
* call parameters of jsf.ajax.request
|
|
2261
|
+
*
|
|
2262
|
+
* @param event
|
|
2263
|
+
* @param opts
|
|
2264
|
+
* @param el
|
|
2265
|
+
*/
|
|
2266
|
+
function resolveDefaults(event, opts, el) {
|
|
2267
|
+
var _a;
|
|
2268
|
+
if (opts === void 0) { opts = {}; }
|
|
2269
|
+
if (el === void 0) { el = null; }
|
|
2270
|
+
//deep copy the options, so that further transformations to not backfire into the callers
|
|
2271
|
+
var resolvedEvent = event, options = new mona_dish_1.Config(opts).deepCopy, elem = mona_dish_1.DQ.byId(el || resolvedEvent.target, true), elementId = elem.id, requestCtx = new mona_dish_1.Config({}), internalCtx = new mona_dish_1.Config({}), windowId = resolveWindowId(options), isResetValues = true === ((_a = options.value) === null || _a === void 0 ? void 0 : _a.resetValues);
|
|
2272
|
+
return { resolvedEvent: resolvedEvent, options: options, elem: elem, elementId: elementId, requestCtx: requestCtx, internalCtx: internalCtx, windowId: windowId, isResetValues: isResetValues };
|
|
2273
|
+
}
|
|
2274
|
+
exports.resolveDefaults = resolveDefaults;
|
|
2275
|
+
|
|
2276
|
+
|
|
2277
|
+
/***/ }),
|
|
2278
|
+
|
|
2279
|
+
/***/ "./src/main/typescript/impl/xhrCore/ResonseDataResolver.ts":
|
|
2280
|
+
/*!*****************************************************************!*\
|
|
2281
|
+
!*** ./src/main/typescript/impl/xhrCore/ResonseDataResolver.ts ***!
|
|
2282
|
+
\*****************************************************************/
|
|
2283
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2284
|
+
|
|
2285
|
+
"use strict";
|
|
2286
|
+
|
|
2287
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2288
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
2289
|
+
* this work for additional information regarding copyright ownership.
|
|
2290
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
2291
|
+
* (the "License"); you may not use this file except in compliance with
|
|
2292
|
+
* the License. You may obtain a copy of the License at
|
|
2293
|
+
*
|
|
2294
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2295
|
+
*
|
|
2296
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2297
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2298
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2299
|
+
* See the License for the specific language governing permissions and
|
|
2300
|
+
* limitations under the License.
|
|
2301
|
+
*/
|
|
2302
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2303
|
+
exports.resolveSourceForm = exports.resolveSourceElement = exports.resolveContexts = exports.resolveResponseXML = void 0;
|
|
2304
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2305
|
+
var Assertions_1 = __webpack_require__(/*! ../util/Assertions */ "./src/main/typescript/impl/util/Assertions.ts");
|
|
2306
|
+
var mona_dish_2 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2307
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2308
|
+
/**
|
|
2309
|
+
* Resolver functions for various aspects of the response data
|
|
2310
|
+
*
|
|
2311
|
+
* stateless because it might be called from various
|
|
2312
|
+
* parts of the response classes
|
|
2313
|
+
*/
|
|
2314
|
+
/**
|
|
2315
|
+
* fetches the response XML
|
|
2316
|
+
* as XML Query object
|
|
2317
|
+
*
|
|
2318
|
+
* @param request the request hosting the responseXML
|
|
2319
|
+
*
|
|
2320
|
+
* Throws an error in case of non existent or wrong xml data
|
|
2321
|
+
*
|
|
2322
|
+
*/
|
|
2323
|
+
function resolveResponseXML(request) {
|
|
2324
|
+
var ret = new mona_dish_1.XMLQuery(request.getIf(Const_1.SEL_RESPONSE_XML).value);
|
|
2325
|
+
Assertions_1.Assertions.assertValidXMLResponse(ret);
|
|
2326
|
+
return ret;
|
|
2327
|
+
}
|
|
2328
|
+
exports.resolveResponseXML = resolveResponseXML;
|
|
2329
|
+
/**
|
|
2330
|
+
* Splits the incoming passthrough context apart
|
|
2331
|
+
* in an internal and an external nomalized context
|
|
2332
|
+
* the internal one is just for our internal processing
|
|
2333
|
+
*
|
|
2334
|
+
* @param context the root context as associative array
|
|
2335
|
+
*/
|
|
2336
|
+
function resolveContexts(context) {
|
|
2337
|
+
/**
|
|
2338
|
+
* we split the context apart into the external one and
|
|
2339
|
+
* some internal values
|
|
2340
|
+
*/
|
|
2341
|
+
var externalContext = mona_dish_1.Config.fromNullable(context);
|
|
2342
|
+
var internalContext = externalContext.getIf(Const_1.CTX_PARAM_MF_INTERNAL);
|
|
2343
|
+
if (!internalContext.isPresent()) {
|
|
2344
|
+
internalContext = mona_dish_1.Config.fromNullable({});
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* prepare storage for some deferred operations
|
|
2348
|
+
*/
|
|
2349
|
+
internalContext.assign(Const_1.UPDATE_FORMS).value = [];
|
|
2350
|
+
internalContext.assign(Const_1.UPDATE_ELEMS).value = [];
|
|
2351
|
+
return { externalContext: externalContext, internalContext: internalContext };
|
|
2352
|
+
}
|
|
2353
|
+
exports.resolveContexts = resolveContexts;
|
|
2354
|
+
/**
|
|
2355
|
+
* fetches the source element out of our conexts
|
|
2356
|
+
*
|
|
2357
|
+
* @param context the external context which shpuld host the source id
|
|
2358
|
+
* @param internalContext internal passthrough fall back
|
|
2359
|
+
*
|
|
2360
|
+
*/
|
|
2361
|
+
function resolveSourceElement(context, internalContext) {
|
|
2362
|
+
var elemId = resolveSourceElementId(context, internalContext);
|
|
2363
|
+
return mona_dish_2.DQ.byId(elemId.value, true);
|
|
2364
|
+
}
|
|
2365
|
+
exports.resolveSourceElement = resolveSourceElement;
|
|
2366
|
+
/**
|
|
2367
|
+
* fetches the source form if it still exists
|
|
2368
|
+
* also embedded forms and parent forms are taken into consideration
|
|
2369
|
+
* as fallbacks
|
|
2370
|
+
*
|
|
2371
|
+
* @param internalContext
|
|
2372
|
+
* @param elem
|
|
2373
|
+
*/
|
|
2374
|
+
function resolveSourceForm(internalContext, elem) {
|
|
2375
|
+
var sourceFormId = internalContext.getIf(Const_1.CTX_PARAM_SRC_FRM_ID);
|
|
2376
|
+
var sourceForm = new mona_dish_2.DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);
|
|
2377
|
+
sourceForm = sourceForm.orElse(elem.parents(Const_1.TAG_FORM))
|
|
2378
|
+
.orElse(elem.querySelectorAll(Const_1.TAG_FORM))
|
|
2379
|
+
.orElse(mona_dish_2.DQ.querySelectorAll(Const_1.TAG_FORM));
|
|
2380
|
+
return sourceForm;
|
|
2381
|
+
}
|
|
2382
|
+
exports.resolveSourceForm = resolveSourceForm;
|
|
2383
|
+
function resolveSourceElementId(context, internalContext) {
|
|
2384
|
+
//?internal context?? used to be external one
|
|
2385
|
+
return internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID)
|
|
2386
|
+
.orElseLazy(function () { return context.getIf(Const_1.SOURCE, "id").value; });
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
/***/ }),
|
|
2391
|
+
|
|
2392
|
+
/***/ "./src/main/typescript/impl/xhrCore/Response.ts":
|
|
2393
|
+
/*!******************************************************!*\
|
|
2394
|
+
!*** ./src/main/typescript/impl/xhrCore/Response.ts ***!
|
|
2395
|
+
\******************************************************/
|
|
2396
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2397
|
+
|
|
2398
|
+
"use strict";
|
|
2399
|
+
|
|
2400
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2401
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
2402
|
+
* this work for additional information regarding copyright ownership.
|
|
2403
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
2404
|
+
* (the "License"); you may not use this file except in compliance with
|
|
2405
|
+
* the License. You may obtain a copy of the License at
|
|
2406
|
+
*
|
|
2407
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2408
|
+
*
|
|
2409
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2410
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2411
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2412
|
+
* See the License for the specific language governing permissions and
|
|
2413
|
+
* limitations under the License.
|
|
2414
|
+
*/
|
|
2415
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2416
|
+
exports.Response = void 0;
|
|
2417
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2418
|
+
var ResponseProcessor_1 = __webpack_require__(/*! ./ResponseProcessor */ "./src/main/typescript/impl/xhrCore/ResponseProcessor.ts");
|
|
2419
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2420
|
+
var ResonseDataResolver_1 = __webpack_require__(/*! ./ResonseDataResolver */ "./src/main/typescript/impl/xhrCore/ResonseDataResolver.ts");
|
|
2421
|
+
var Response;
|
|
2422
|
+
(function (Response) {
|
|
2423
|
+
/**
|
|
2424
|
+
* Standardized jsf.js response
|
|
2425
|
+
* this one is called straight from jsf.js.response
|
|
2426
|
+
*
|
|
2427
|
+
* The processing follows the spec by going for the responseXML
|
|
2428
|
+
* and processing its tags
|
|
2429
|
+
*
|
|
2430
|
+
* @param {XMLHttpRequest} request (xhrRequest) - xhr request object
|
|
2431
|
+
* @param ASSOC_ARR<any> context (Map) - AJAX context
|
|
2432
|
+
*
|
|
2433
|
+
*/
|
|
2434
|
+
function processResponse(request, context) {
|
|
2435
|
+
var req = mona_dish_1.Config.fromNullable(request);
|
|
2436
|
+
var _a = (0, ResonseDataResolver_1.resolveContexts)(context), externalContext = _a.externalContext, internalContext = _a.internalContext;
|
|
2437
|
+
var responseXML = (0, ResonseDataResolver_1.resolveResponseXML)(req);
|
|
2438
|
+
var responseProcessor = new ResponseProcessor_1.ResponseProcessor(req, externalContext, internalContext);
|
|
2439
|
+
internalContext.assign(Const_1.RESPONSE_XML).value = responseXML;
|
|
2440
|
+
//we now process the partial tags, or in none given raise an error
|
|
2441
|
+
responseXML.querySelectorAll(Const_1.RESP_PARTIAL)
|
|
2442
|
+
.each(function (item) { return processPartialTag(item, responseProcessor, internalContext); });
|
|
2443
|
+
//we now process the viewstates, client windows and the evals deferred
|
|
2444
|
+
//the reason for this is that often it is better
|
|
2445
|
+
//to wait until the document has caught up before
|
|
2446
|
+
//doing any evals even on embedded scripts
|
|
2447
|
+
//usually this does not matter, the client window comes in almost last always anyway
|
|
2448
|
+
//we maybe drop this deferred assignment in the future, but myfaces did it until now
|
|
2449
|
+
responseProcessor.fixViewStates();
|
|
2450
|
+
responseProcessor.fixClientWindow();
|
|
2451
|
+
responseProcessor.globalEval();
|
|
2452
|
+
responseProcessor.done();
|
|
2453
|
+
}
|
|
2454
|
+
Response.processResponse = processResponse;
|
|
2455
|
+
/**
|
|
2456
|
+
* highest node partial-response from there the main operations are triggered
|
|
2457
|
+
*/
|
|
2458
|
+
function processPartialTag(node, responseProcessor, internalContext) {
|
|
2459
|
+
internalContext.assign(Const_1.PARTIAL_ID).value = node.id;
|
|
2460
|
+
var SEL_SUB_TAGS = [Const_1.CMD_ERROR, Const_1.CMD_REDIRECT, Const_1.CMD_CHANGES].join(",");
|
|
2461
|
+
//now we can process the main operations
|
|
2462
|
+
node.getIf(SEL_SUB_TAGS).each(function (node) {
|
|
2463
|
+
switch (node.tagName.value) {
|
|
2464
|
+
case Const_1.CMD_ERROR:
|
|
2465
|
+
responseProcessor.error(node);
|
|
2466
|
+
break;
|
|
2467
|
+
case Const_1.CMD_REDIRECT:
|
|
2468
|
+
responseProcessor.redirect(node);
|
|
2469
|
+
break;
|
|
2470
|
+
case Const_1.CMD_CHANGES:
|
|
2471
|
+
processChangesTag(node, responseProcessor);
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2475
|
+
}
|
|
2476
|
+
var processInsert = function (responseProcessor, node) {
|
|
2477
|
+
//path1 insert after as child tags
|
|
2478
|
+
if (node.querySelectorAll([Const_1.TAG_BEFORE, Const_1.TAG_AFTER].join(",")).length) {
|
|
2479
|
+
responseProcessor.insertWithSubtags(node);
|
|
2480
|
+
}
|
|
2481
|
+
else { //insert before after with id
|
|
2482
|
+
responseProcessor.insert(node);
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
/**
|
|
2486
|
+
* next level changes tag
|
|
2487
|
+
*
|
|
2488
|
+
* @param node
|
|
2489
|
+
* @param responseProcessor
|
|
2490
|
+
*/
|
|
2491
|
+
function processChangesTag(node, responseProcessor) {
|
|
2492
|
+
var ALLOWED_TAGS = [Const_1.CMD_UPDATE, Const_1.CMD_EVAL, Const_1.CMD_INSERT, Const_1.CMD_DELETE, Const_1.CMD_ATTRIBUTES, Const_1.CMD_EXTENSION].join(",");
|
|
2493
|
+
node.getIf(ALLOWED_TAGS).each(function (node) {
|
|
2494
|
+
switch (node.tagName.value) {
|
|
2495
|
+
case Const_1.CMD_UPDATE:
|
|
2496
|
+
processUpdateTag(node, responseProcessor);
|
|
2497
|
+
break;
|
|
2498
|
+
case Const_1.CMD_EVAL:
|
|
2499
|
+
responseProcessor.eval(node);
|
|
2500
|
+
break;
|
|
2501
|
+
case Const_1.CMD_INSERT:
|
|
2502
|
+
processInsert(responseProcessor, node);
|
|
2503
|
+
break;
|
|
2504
|
+
case Const_1.CMD_DELETE:
|
|
2505
|
+
responseProcessor.delete(node);
|
|
2506
|
+
break;
|
|
2507
|
+
case Const_1.CMD_ATTRIBUTES:
|
|
2508
|
+
responseProcessor.attributes(node);
|
|
2509
|
+
break;
|
|
2510
|
+
case Const_1.CMD_EXTENSION:
|
|
2511
|
+
break;
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
return true;
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* checks and stores a state update for delayed processing
|
|
2518
|
+
*
|
|
2519
|
+
* @param responseProcessor the response processor to perform the store operation
|
|
2520
|
+
* @param node the xml node to check for the state
|
|
2521
|
+
*
|
|
2522
|
+
* @private
|
|
2523
|
+
*/
|
|
2524
|
+
function storeState(responseProcessor, node) {
|
|
2525
|
+
return responseProcessor.processViewState(node) || responseProcessor.processClientWindow(node);
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* branch tag update.. drill further down into the updates
|
|
2529
|
+
* special case viewstate in that case it is a leaf
|
|
2530
|
+
* and the viewstate must be processed
|
|
2531
|
+
*
|
|
2532
|
+
* @param node
|
|
2533
|
+
* @param responseProcessor
|
|
2534
|
+
*/
|
|
2535
|
+
function processUpdateTag(node, responseProcessor) {
|
|
2536
|
+
//early state storing, if no state we perform a normal update cycle
|
|
2537
|
+
if (!storeState(responseProcessor, node)) {
|
|
2538
|
+
handleElementUpdate(node, responseProcessor);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* element update
|
|
2543
|
+
*
|
|
2544
|
+
* @param node
|
|
2545
|
+
* @param responseProcessor
|
|
2546
|
+
*/
|
|
2547
|
+
function handleElementUpdate(node, responseProcessor) {
|
|
2548
|
+
var cdataBlock = node.cDATAAsString;
|
|
2549
|
+
switch (node.id.value) {
|
|
2550
|
+
case Const_1.P_VIEWROOT:
|
|
2551
|
+
responseProcessor.replaceViewRoot(mona_dish_1.DQ.fromMarkup(cdataBlock.substring(cdataBlock.indexOf("<html"))));
|
|
2552
|
+
break;
|
|
2553
|
+
case Const_1.P_VIEWHEAD:
|
|
2554
|
+
responseProcessor.replaceHead(mona_dish_1.DQ.fromMarkup(cdataBlock));
|
|
2555
|
+
break;
|
|
2556
|
+
case Const_1.P_VIEWBODY:
|
|
2557
|
+
responseProcessor.replaceBody(mona_dish_1.DQ.fromMarkup(cdataBlock));
|
|
2558
|
+
break;
|
|
2559
|
+
default: //htmlItem replacement
|
|
2560
|
+
responseProcessor.update(node, cdataBlock);
|
|
2561
|
+
break;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
})(Response = exports.Response || (exports.Response = {}));
|
|
2565
|
+
|
|
2566
|
+
|
|
2567
|
+
/***/ }),
|
|
2568
|
+
|
|
2569
|
+
/***/ "./src/main/typescript/impl/xhrCore/ResponseProcessor.ts":
|
|
2570
|
+
/*!***************************************************************!*\
|
|
2571
|
+
!*** ./src/main/typescript/impl/xhrCore/ResponseProcessor.ts ***!
|
|
2572
|
+
\***************************************************************/
|
|
2573
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2574
|
+
|
|
2575
|
+
"use strict";
|
|
2576
|
+
|
|
2577
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2578
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
2579
|
+
* this work for additional information regarding copyright ownership.
|
|
2580
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
2581
|
+
* (the "License"); you may not use this file except in compliance with
|
|
2582
|
+
* the License. You may obtain a copy of the License at
|
|
2583
|
+
*
|
|
2584
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2585
|
+
*
|
|
2586
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2587
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2588
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2589
|
+
* See the License for the specific language governing permissions and
|
|
2590
|
+
* limitations under the License.
|
|
2591
|
+
*/
|
|
2592
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2593
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2594
|
+
if (ar || !(i in from)) {
|
|
2595
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2596
|
+
ar[i] = from[i];
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2600
|
+
};
|
|
2601
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2602
|
+
exports.ResponseProcessor = void 0;
|
|
2603
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2604
|
+
var AjaxImpl_1 = __webpack_require__(/*! ../AjaxImpl */ "./src/main/typescript/impl/AjaxImpl.ts");
|
|
2605
|
+
var Assertions_1 = __webpack_require__(/*! ../util/Assertions */ "./src/main/typescript/impl/util/Assertions.ts");
|
|
2606
|
+
var ErrorData_1 = __webpack_require__(/*! ./ErrorData */ "./src/main/typescript/impl/xhrCore/ErrorData.ts");
|
|
2607
|
+
var ImplTypes_1 = __webpack_require__(/*! ../core/ImplTypes */ "./src/main/typescript/impl/core/ImplTypes.ts");
|
|
2608
|
+
var EventData_1 = __webpack_require__(/*! ./EventData */ "./src/main/typescript/impl/xhrCore/EventData.ts");
|
|
2609
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
2610
|
+
var trim = mona_dish_1.Lang.trim;
|
|
2611
|
+
/**
|
|
2612
|
+
* Response processor
|
|
2613
|
+
*
|
|
2614
|
+
* Each XML tag is either a node or a leaf
|
|
2615
|
+
* or both
|
|
2616
|
+
*
|
|
2617
|
+
* the processor provides a set of operations
|
|
2618
|
+
* which are executed on a single leaf node per operation
|
|
2619
|
+
* and present the core functionality of our response
|
|
2620
|
+
*
|
|
2621
|
+
* Note the response processor is stateful hence we bundle it in a class
|
|
2622
|
+
* to reduce code we keep references tot contexts in place
|
|
2623
|
+
*/
|
|
2624
|
+
var ResponseProcessor = /** @class */ (function () {
|
|
2625
|
+
function ResponseProcessor(request, externalContext, internalContext) {
|
|
2626
|
+
this.request = request;
|
|
2627
|
+
this.externalContext = externalContext;
|
|
2628
|
+
this.internalContext = internalContext;
|
|
2629
|
+
}
|
|
2630
|
+
ResponseProcessor.prototype.replaceHead = function (shadowDocument) {
|
|
2631
|
+
var shadowHead = shadowDocument.querySelectorAll(Const_1.TAG_HEAD);
|
|
2632
|
+
if (!shadowHead.isPresent()) {
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
var oldHead = mona_dish_1.DQ.querySelectorAll(Const_1.TAG_HEAD);
|
|
2636
|
+
//delete all to avoid script and style overlays
|
|
2637
|
+
oldHead.querySelectorAll(Const_1.SEL_SCRIPTS_STYLES).delete();
|
|
2638
|
+
this.storeForEval(shadowHead);
|
|
2639
|
+
};
|
|
2640
|
+
/**
|
|
2641
|
+
* replaces the body in the expected manner
|
|
2642
|
+
* which means the entire body content is refreshed
|
|
2643
|
+
* however also the body attributes must be transferred
|
|
2644
|
+
* keeping event handlers etc... in place
|
|
2645
|
+
*
|
|
2646
|
+
* @param shadowDocument .. an incoming shadow document hosting the new nodes
|
|
2647
|
+
*/
|
|
2648
|
+
ResponseProcessor.prototype.replaceBody = function (shadowDocument) {
|
|
2649
|
+
var shadowBody = shadowDocument.querySelectorAll(Const_1.TAG_BODY);
|
|
2650
|
+
if (!shadowBody.isPresent()) {
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
var shadowInnerHTML = shadowBody.html().value;
|
|
2654
|
+
var resultingBody = mona_dish_1.DQ.querySelectorAll(Const_1.TAG_BODY).html(shadowInnerHTML);
|
|
2655
|
+
var updateForms = resultingBody.querySelectorAll(Const_1.TAG_FORM);
|
|
2656
|
+
resultingBody.copyAttrs(shadowBody);
|
|
2657
|
+
this.storeForPostProcessing(updateForms, resultingBody);
|
|
2658
|
+
};
|
|
2659
|
+
/**
|
|
2660
|
+
* Leaf Tag eval... process whatever is in the evals cdata block
|
|
2661
|
+
*
|
|
2662
|
+
* @param node the node to eval
|
|
2663
|
+
*/
|
|
2664
|
+
ResponseProcessor.prototype.eval = function (node) {
|
|
2665
|
+
mona_dish_1.DQ.globalEval(node.cDATAAsString);
|
|
2666
|
+
};
|
|
2667
|
+
/**
|
|
2668
|
+
* processes an incoming error from the response
|
|
2669
|
+
* which is hosted under the <error> tag
|
|
2670
|
+
* @param node the node hosting the error in our response xml
|
|
2671
|
+
* @param node the node in the xml hosting the error message
|
|
2672
|
+
*/
|
|
2673
|
+
ResponseProcessor.prototype.error = function (node) {
|
|
2674
|
+
/**
|
|
2675
|
+
* <error>
|
|
2676
|
+
* <error-name>String</error-name>
|
|
2677
|
+
* <error-message><![CDATA[message]]></error-message>
|
|
2678
|
+
* <error>
|
|
2679
|
+
*/
|
|
2680
|
+
var mergedErrorData = new mona_dish_1.Config({});
|
|
2681
|
+
mergedErrorData.assign(Const_1.SOURCE).value = this.externalContext.getIf(Const_1.P_PARTIAL_SOURCE).get(0).value;
|
|
2682
|
+
mergedErrorData.assign(Const_1.ERROR_NAME).value = node.getIf(Const_1.ERROR_NAME).textContent(Const_1.EMPTY_STR);
|
|
2683
|
+
mergedErrorData.assign(Const_1.ERROR_MESSAGE).value = node.getIf(Const_1.ERROR_MESSAGE).cDATAAsString;
|
|
2684
|
+
var hasResponseXML = this.internalContext.get(Const_1.RESPONSE_XML).isPresent();
|
|
2685
|
+
mergedErrorData.assignIf(hasResponseXML, Const_1.RESPONSE_XML).value = this.internalContext.getIf(Const_1.RESPONSE_XML).value.get(0).value;
|
|
2686
|
+
var errorData = ErrorData_1.ErrorData.fromServerError(mergedErrorData);
|
|
2687
|
+
this.externalContext.getIf(Const_1.ON_ERROR).orElse(this.internalContext.getIf(Const_1.ON_ERROR).value).orElse(Const_1.EMPTY_FUNC).value(errorData);
|
|
2688
|
+
AjaxImpl_1.Implementation.sendError(errorData);
|
|
2689
|
+
};
|
|
2690
|
+
/**
|
|
2691
|
+
* process the redirect operation
|
|
2692
|
+
*
|
|
2693
|
+
* @param node
|
|
2694
|
+
*/
|
|
2695
|
+
ResponseProcessor.prototype.redirect = function (node) {
|
|
2696
|
+
Assertions_1.Assertions.assertUrlExists(node);
|
|
2697
|
+
var redirectUrl = trim(node.attr(Const_1.ATTR_URL).value);
|
|
2698
|
+
if (redirectUrl != Const_1.EMPTY_STR) {
|
|
2699
|
+
window.location.href = redirectUrl;
|
|
2700
|
+
}
|
|
2701
|
+
};
|
|
2702
|
+
/**
|
|
2703
|
+
* processes the update operation and updates the node with the cdata block
|
|
2704
|
+
* @param node the xml response node hosting the update info
|
|
2705
|
+
* @param cdataBlock the cdata block with the new html code
|
|
2706
|
+
*/
|
|
2707
|
+
ResponseProcessor.prototype.update = function (node, cdataBlock) {
|
|
2708
|
+
var result = mona_dish_1.DQ.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
|
|
2709
|
+
var sourceForm = result === null || result === void 0 ? void 0 : result.parents(Const_1.TAG_FORM).orElse(result.byTagName(Const_1.TAG_FORM, true));
|
|
2710
|
+
if (sourceForm) {
|
|
2711
|
+
this.storeForPostProcessing(sourceForm, result);
|
|
2712
|
+
}
|
|
2713
|
+
};
|
|
2714
|
+
ResponseProcessor.prototype.delete = function (node) {
|
|
2715
|
+
mona_dish_1.DQ.byId(node.id.value, true).delete();
|
|
2716
|
+
};
|
|
2717
|
+
/**
|
|
2718
|
+
* attributes leaf tag... process the attributes
|
|
2719
|
+
*
|
|
2720
|
+
* @param node
|
|
2721
|
+
*/
|
|
2722
|
+
ResponseProcessor.prototype.attributes = function (node) {
|
|
2723
|
+
var elem = mona_dish_1.DQ.byId(node.id.value, true);
|
|
2724
|
+
node.byTagName(Const_1.TAG_ATTR).each(function (item) {
|
|
2725
|
+
elem.attr(item.attr(Const_1.ATTR_NAME).value).value = item.attr(Const_1.ATTR_VALUE).value;
|
|
2726
|
+
});
|
|
2727
|
+
};
|
|
2728
|
+
/**
|
|
2729
|
+
* @param shadowDocument a shadow document which is needed for further processing
|
|
2730
|
+
*/
|
|
2731
|
+
ResponseProcessor.prototype.replaceViewRoot = function (shadowDocument) {
|
|
2732
|
+
this.replaceHead(shadowDocument);
|
|
2733
|
+
this.replaceBody(shadowDocument);
|
|
2734
|
+
};
|
|
2735
|
+
/**
|
|
2736
|
+
* insert handling, either before or after
|
|
2737
|
+
*
|
|
2738
|
+
* @param node
|
|
2739
|
+
*/
|
|
2740
|
+
ResponseProcessor.prototype.insert = function (node) {
|
|
2741
|
+
//let insertId = node.id; //not used atm
|
|
2742
|
+
var before = node.attr(Const_1.TAG_BEFORE);
|
|
2743
|
+
var after = node.attr(Const_1.TAG_AFTER);
|
|
2744
|
+
var insertNodes = mona_dish_1.DQ.fromMarkup(node.cDATAAsString);
|
|
2745
|
+
if (before.isPresent()) {
|
|
2746
|
+
mona_dish_1.DQ.byId(before.value, true).insertBefore(insertNodes);
|
|
2747
|
+
this.internalContext.assign(Const_1.UPDATE_ELEMS).value.push(insertNodes);
|
|
2748
|
+
}
|
|
2749
|
+
if (after.isPresent()) {
|
|
2750
|
+
var domQuery = mona_dish_1.DQ.byId(after.value, true);
|
|
2751
|
+
domQuery.insertAfter(insertNodes);
|
|
2752
|
+
this.internalContext.assign(Const_1.UPDATE_ELEMS).value.push(insertNodes);
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
/**
|
|
2756
|
+
* handler for the case <insert << before id="...
|
|
2757
|
+
*
|
|
2758
|
+
* @param node the node hosting the insert data
|
|
2759
|
+
*/
|
|
2760
|
+
ResponseProcessor.prototype.insertWithSubtags = function (node) {
|
|
2761
|
+
var _this = this;
|
|
2762
|
+
var before = node.querySelectorAll(Const_1.TAG_BEFORE);
|
|
2763
|
+
var after = node.querySelectorAll(Const_1.TAG_AFTER);
|
|
2764
|
+
before.each(function (item) {
|
|
2765
|
+
var insertId = item.attr(Const_1.ATTR_ID);
|
|
2766
|
+
var insertNodes = mona_dish_1.DQ.fromMarkup(item.cDATAAsString);
|
|
2767
|
+
if (insertId.isPresent()) {
|
|
2768
|
+
mona_dish_1.DQ.byId(insertId.value, true).insertBefore(insertNodes);
|
|
2769
|
+
_this.internalContext.assign(Const_1.UPDATE_ELEMS).value.push(insertNodes);
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
after.each(function (item) {
|
|
2773
|
+
var insertId = item.attr(Const_1.ATTR_ID);
|
|
2774
|
+
var insertNodes = mona_dish_1.DQ.fromMarkup(item.cDATAAsString);
|
|
2775
|
+
if (insertId.isPresent()) {
|
|
2776
|
+
mona_dish_1.DQ.byId(insertId.value, true).insertAfter(insertNodes);
|
|
2777
|
+
_this.internalContext.assign(Const_1.UPDATE_ELEMS).value.push(insertNodes);
|
|
2778
|
+
}
|
|
2779
|
+
});
|
|
2780
|
+
};
|
|
2781
|
+
/**
|
|
2782
|
+
* process the viewState update, update the affected
|
|
2783
|
+
* forms with their respective new viewstate values
|
|
2784
|
+
*
|
|
2785
|
+
*/
|
|
2786
|
+
ResponseProcessor.prototype.processViewState = function (node) {
|
|
2787
|
+
if (ResponseProcessor.isViewStateNode(node)) {
|
|
2788
|
+
var state = node.cDATAAsString;
|
|
2789
|
+
this.internalContext.assign(Const_1.APPLIED_VST, node.id.value).value = new ImplTypes_1.StateHolder(node.id.value, state);
|
|
2790
|
+
return true;
|
|
2791
|
+
}
|
|
2792
|
+
return false;
|
|
2793
|
+
};
|
|
2794
|
+
ResponseProcessor.prototype.processClientWindow = function (node) {
|
|
2795
|
+
if (ResponseProcessor.isClientWindowNode(node)) {
|
|
2796
|
+
var state = node.cDATAAsString;
|
|
2797
|
+
this.internalContext.assign(Const_1.APPLIED_CLIENT_WINDOW, node.id.value).value = new ImplTypes_1.StateHolder(node.id.value, state);
|
|
2798
|
+
return true;
|
|
2799
|
+
}
|
|
2800
|
+
};
|
|
2801
|
+
/**
|
|
2802
|
+
* generic global eval which runs the embedded css and scripts
|
|
2803
|
+
*/
|
|
2804
|
+
ResponseProcessor.prototype.globalEval = function () {
|
|
2805
|
+
var updateElems = new (mona_dish_1.DQ.bind.apply(mona_dish_1.DQ, __spreadArray([void 0], this.internalContext.getIf(Const_1.UPDATE_ELEMS).value, false)))();
|
|
2806
|
+
updateElems.runCss();
|
|
2807
|
+
updateElems.runScripts();
|
|
2808
|
+
};
|
|
2809
|
+
/**
|
|
2810
|
+
* post processing viewstate fixing
|
|
2811
|
+
*/
|
|
2812
|
+
ResponseProcessor.prototype.fixViewStates = function () {
|
|
2813
|
+
var _this = this;
|
|
2814
|
+
mona_dish_1.Stream.ofAssoc(this.internalContext.getIf(Const_1.APPLIED_VST).orElse({}).value)
|
|
2815
|
+
.each(function (item) {
|
|
2816
|
+
var value = item[1];
|
|
2817
|
+
var nameSpace = mona_dish_1.DQ.byId(value.nameSpace, true).orElse(document.body);
|
|
2818
|
+
var affectedForms = nameSpace.byTagName(Const_1.TAG_FORM);
|
|
2819
|
+
var affectedForms2 = nameSpace.filter(function (item) { return item.tagName.orElse(Const_1.EMPTY_STR).value.toLowerCase() == Const_1.TAG_FORM; });
|
|
2820
|
+
_this.appendViewStateToForms(new mona_dish_1.DomQuery(affectedForms, affectedForms2), value.value);
|
|
2821
|
+
});
|
|
2822
|
+
};
|
|
2823
|
+
ResponseProcessor.prototype.fixClientWindow = function () {
|
|
2824
|
+
var _this = this;
|
|
2825
|
+
mona_dish_1.Stream.ofAssoc(this.internalContext.getIf(Const_1.APPLIED_CLIENT_WINDOW).orElse({}).value)
|
|
2826
|
+
.each(function (item) {
|
|
2827
|
+
var value = item[1];
|
|
2828
|
+
var nameSpace = mona_dish_1.DQ.byId(value.nameSpace, true).orElse(document.body);
|
|
2829
|
+
var affectedForms = nameSpace.byTagName(Const_1.TAG_FORM);
|
|
2830
|
+
var affectedForms2 = nameSpace.filter(function (item) { return item.tagName.orElse(Const_1.EMPTY_STR).value.toLowerCase() == Const_1.TAG_FORM; });
|
|
2831
|
+
_this.appendClientWindowToForms(new mona_dish_1.DomQuery(affectedForms, affectedForms2), value.value);
|
|
2832
|
+
});
|
|
2833
|
+
};
|
|
2834
|
+
/**
|
|
2835
|
+
* all processing done we can close the request and send the appropriate events
|
|
2836
|
+
*/
|
|
2837
|
+
ResponseProcessor.prototype.done = function () {
|
|
2838
|
+
var eventData = EventData_1.EventData.createFromRequest(this.request.value, this.externalContext, Const_1.SUCCESS);
|
|
2839
|
+
//because some frameworks might decorate them over the context in the response
|
|
2840
|
+
var eventHandler = this.externalContext.getIf(Const_1.ON_EVENT).orElse(this.internalContext.getIf(Const_1.ON_EVENT).value).orElse(Const_1.EMPTY_FUNC).value;
|
|
2841
|
+
AjaxImpl_1.Implementation.sendEvent(eventData, eventHandler);
|
|
2842
|
+
};
|
|
2843
|
+
/**
|
|
2844
|
+
* proper viewstate -> form assignment
|
|
2845
|
+
*
|
|
2846
|
+
* @param forms the forms to append the viewstate to
|
|
2847
|
+
* @param viewState the final viewstate
|
|
2848
|
+
*/
|
|
2849
|
+
ResponseProcessor.prototype.appendViewStateToForms = function (forms, viewState) {
|
|
2850
|
+
this.assignState(forms, Const_1.SEL_VIEWSTATE_ELEM, viewState);
|
|
2851
|
+
};
|
|
2852
|
+
/**
|
|
2853
|
+
* proper clientwindow -> form assignment
|
|
2854
|
+
*
|
|
2855
|
+
* @param forms the forms to append the viewstate to
|
|
2856
|
+
* @param clientWindow the final viewstate
|
|
2857
|
+
*/
|
|
2858
|
+
ResponseProcessor.prototype.appendClientWindowToForms = function (forms, clientWindow) {
|
|
2859
|
+
this.assignState(forms, Const_1.SEL_CLIENT_WINDOW_ELEM, clientWindow);
|
|
2860
|
+
};
|
|
2861
|
+
/**
|
|
2862
|
+
* generic append state which appends a certain state as hidden element to an existing set of forms
|
|
2863
|
+
*
|
|
2864
|
+
* @param forms the forms to append or change to
|
|
2865
|
+
* @param selector the selector for the state
|
|
2866
|
+
* @param state the state itself which needs to be assigned
|
|
2867
|
+
*
|
|
2868
|
+
* @private
|
|
2869
|
+
*/
|
|
2870
|
+
ResponseProcessor.prototype.assignState = function (forms, selector, state) {
|
|
2871
|
+
forms.each(function (form) {
|
|
2872
|
+
var stateHolders = form.querySelectorAll(selector)
|
|
2873
|
+
.orElseLazy(function () { return ResponseProcessor.newViewStateElement(form); });
|
|
2874
|
+
stateHolders.attr("value").value = state;
|
|
2875
|
+
});
|
|
2876
|
+
};
|
|
2877
|
+
/**
|
|
2878
|
+
* Helper to Create a new JSF ViewState Element
|
|
2879
|
+
*
|
|
2880
|
+
* @param parent, the parent node to attach the viewstate element to
|
|
2881
|
+
* (usually a form node)
|
|
2882
|
+
*/
|
|
2883
|
+
ResponseProcessor.newViewStateElement = function (parent) {
|
|
2884
|
+
var newViewState = mona_dish_1.DQ.fromMarkup(Const_1.HTML_VIEWSTATE);
|
|
2885
|
+
newViewState.appendTo(parent);
|
|
2886
|
+
return newViewState;
|
|
2887
|
+
};
|
|
2888
|
+
/**
|
|
2889
|
+
* Stores certain aspects of the dom for later post processing
|
|
2890
|
+
*
|
|
2891
|
+
* @param updateForms the update forms which should receive standardized internal jsf data
|
|
2892
|
+
* @param toBeEvaled the resulting elements which should be evaled
|
|
2893
|
+
*/
|
|
2894
|
+
ResponseProcessor.prototype.storeForPostProcessing = function (updateForms, toBeEvaled) {
|
|
2895
|
+
this.storeForUpdate(updateForms);
|
|
2896
|
+
this.storeForEval(toBeEvaled);
|
|
2897
|
+
};
|
|
2898
|
+
/**
|
|
2899
|
+
* helper to store a given form for the update post processing (viewstate)
|
|
2900
|
+
*
|
|
2901
|
+
* @param updateForms the dom query object pointing to the forms which need to be updated
|
|
2902
|
+
*/
|
|
2903
|
+
ResponseProcessor.prototype.storeForUpdate = function (updateForms) {
|
|
2904
|
+
this.internalContext.assign(Const_1.UPDATE_FORMS).value.push(updateForms);
|
|
2905
|
+
};
|
|
2906
|
+
/**
|
|
2907
|
+
* same for eval (js and css)
|
|
2908
|
+
*
|
|
2909
|
+
* @param toBeEvaled
|
|
2910
|
+
*/
|
|
2911
|
+
ResponseProcessor.prototype.storeForEval = function (toBeEvaled) {
|
|
2912
|
+
this.internalContext.assign(Const_1.UPDATE_ELEMS).value.push(toBeEvaled);
|
|
2913
|
+
};
|
|
2914
|
+
/**
|
|
2915
|
+
* check whether a given XMLQuery node is an explicit viewstate node
|
|
2916
|
+
*
|
|
2917
|
+
* @param node the node to check
|
|
2918
|
+
* @returns true of it ii
|
|
2919
|
+
*/
|
|
2920
|
+
ResponseProcessor.isViewStateNode = function (node) {
|
|
2921
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2922
|
+
var separatorChar = window.jsf.separatorchar;
|
|
2923
|
+
return "undefined" != typeof ((_a = node === null || node === void 0 ? void 0 : node.id) === null || _a === void 0 ? void 0 : _a.value) && (((_b = node === null || node === void 0 ? void 0 : node.id) === null || _b === void 0 ? void 0 : _b.value) == Const_1.P_VIEWSTATE ||
|
|
2924
|
+
((_d = (_c = node === null || node === void 0 ? void 0 : node.id) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.indexOf([separatorChar, Const_1.P_VIEWSTATE].join(Const_1.EMPTY_STR))) != -1 ||
|
|
2925
|
+
((_f = (_e = node === null || node === void 0 ? void 0 : node.id) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.indexOf([Const_1.P_VIEWSTATE, separatorChar].join(Const_1.EMPTY_STR))) != -1);
|
|
2926
|
+
};
|
|
2927
|
+
/**
|
|
2928
|
+
* incoming client window node also needs special processing
|
|
2929
|
+
*
|
|
2930
|
+
* @param node the node to check
|
|
2931
|
+
* @returns true of it ii
|
|
2932
|
+
*/
|
|
2933
|
+
ResponseProcessor.isClientWindowNode = function (node) {
|
|
2934
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2935
|
+
var separatorChar = window.jsf.separatorchar;
|
|
2936
|
+
return "undefined" != typeof ((_a = node === null || node === void 0 ? void 0 : node.id) === null || _a === void 0 ? void 0 : _a.value) && (((_b = node === null || node === void 0 ? void 0 : node.id) === null || _b === void 0 ? void 0 : _b.value) == Const_1.P_CLIENT_WINDOW ||
|
|
2937
|
+
((_d = (_c = node === null || node === void 0 ? void 0 : node.id) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.indexOf([separatorChar, Const_1.P_CLIENT_WINDOW].join(Const_1.EMPTY_STR))) != -1 ||
|
|
2938
|
+
((_f = (_e = node === null || node === void 0 ? void 0 : node.id) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.indexOf([Const_1.P_CLIENT_WINDOW, separatorChar].join(Const_1.EMPTY_STR))) != -1);
|
|
2939
|
+
};
|
|
2940
|
+
return ResponseProcessor;
|
|
2941
|
+
}());
|
|
2942
|
+
exports.ResponseProcessor = ResponseProcessor;
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
/***/ }),
|
|
2946
|
+
|
|
2947
|
+
/***/ "./src/main/typescript/impl/xhrCore/XhrFormData.ts":
|
|
2948
|
+
/*!*********************************************************!*\
|
|
2949
|
+
!*** ./src/main/typescript/impl/xhrCore/XhrFormData.ts ***!
|
|
2950
|
+
\*********************************************************/
|
|
2951
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2952
|
+
|
|
2953
|
+
"use strict";
|
|
2954
|
+
|
|
2955
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2956
|
+
var extendStatics = function (d, b) {
|
|
2957
|
+
extendStatics = Object.setPrototypeOf ||
|
|
2958
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2959
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2960
|
+
return extendStatics(d, b);
|
|
2961
|
+
};
|
|
2962
|
+
return function (d, b) {
|
|
2963
|
+
if (typeof b !== "function" && b !== null)
|
|
2964
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2965
|
+
extendStatics(d, b);
|
|
2966
|
+
function __() { this.constructor = d; }
|
|
2967
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2968
|
+
};
|
|
2969
|
+
})();
|
|
2970
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2971
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2972
|
+
if (ar || !(i in from)) {
|
|
2973
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2974
|
+
ar[i] = from[i];
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2978
|
+
};
|
|
2979
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2980
|
+
exports.XhrFormData = void 0;
|
|
2981
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2982
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
2983
|
+
* this work for additional information regarding copyright ownership.
|
|
2984
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
2985
|
+
* (the "License"); you may not use this file except in compliance with
|
|
2986
|
+
* the License. You may obtain a copy of the License at
|
|
2987
|
+
*
|
|
2988
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2989
|
+
*
|
|
2990
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2991
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2992
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2993
|
+
* See the License for the specific language governing permissions and
|
|
2994
|
+
* limitations under the License.
|
|
2995
|
+
*/
|
|
2996
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2997
|
+
var mona_dish_2 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
2998
|
+
var isString = mona_dish_1.Lang.isString;
|
|
2999
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
3000
|
+
/**
|
|
3001
|
+
* A unified form data class
|
|
3002
|
+
* which builds upon our configuration.
|
|
3003
|
+
*
|
|
3004
|
+
* We cannot use standard html5 forms everywhere
|
|
3005
|
+
* due to api constraints on the HTML Form object in IE11
|
|
3006
|
+
* and due to the url encoding constraint given by the jsf.js spec
|
|
3007
|
+
*
|
|
3008
|
+
* TODO not ideal. too many encoding calls
|
|
3009
|
+
* probably only one needed and one overlay!
|
|
3010
|
+
* the entire fileinput storing probably is redundant now
|
|
3011
|
+
* that domquery has been fixed
|
|
3012
|
+
*/
|
|
3013
|
+
var XhrFormData = /** @class */ (function (_super) {
|
|
3014
|
+
__extends(XhrFormData, _super);
|
|
3015
|
+
/**
|
|
3016
|
+
* data collector from a given form
|
|
3017
|
+
*
|
|
3018
|
+
* @param dataSource either a form as DomQuery object or an encoded url string
|
|
3019
|
+
* @param partialIdsArray partial ids to collect, to reduce the data sent down
|
|
3020
|
+
*/
|
|
3021
|
+
function XhrFormData(dataSource, partialIdsArray, encode) {
|
|
3022
|
+
if (encode === void 0) { encode = true; }
|
|
3023
|
+
var _this = _super.call(this, {}) || this;
|
|
3024
|
+
_this.dataSource = dataSource;
|
|
3025
|
+
_this.partialIdsArray = partialIdsArray;
|
|
3026
|
+
_this.encode = encode;
|
|
3027
|
+
_this.fileInputs = {};
|
|
3028
|
+
//a call to getViewState before must pass the encoded line
|
|
3029
|
+
//a call from getViewState passes the form element as datasource
|
|
3030
|
+
//so we have two call points
|
|
3031
|
+
if (isString(dataSource)) {
|
|
3032
|
+
_this.assignEncodedString(_this.dataSource);
|
|
3033
|
+
}
|
|
3034
|
+
else {
|
|
3035
|
+
_this.handleFormSource();
|
|
3036
|
+
}
|
|
3037
|
+
return _this;
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* generic application of ids
|
|
3041
|
+
* @param executes
|
|
3042
|
+
*/
|
|
3043
|
+
XhrFormData.prototype.applyFileInputs = function () {
|
|
3044
|
+
var _this = this;
|
|
3045
|
+
var executes = [];
|
|
3046
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3047
|
+
executes[_i] = arguments[_i];
|
|
3048
|
+
}
|
|
3049
|
+
var fetchInput = function (id) {
|
|
3050
|
+
if (id == "@all") {
|
|
3051
|
+
return mona_dish_2.DQ.querySelectorAllDeep("input[type='file']");
|
|
3052
|
+
}
|
|
3053
|
+
else if (id == "@form") {
|
|
3054
|
+
return _this.dataSource.querySelectorAllDeep("input[type='file']");
|
|
3055
|
+
}
|
|
3056
|
+
else {
|
|
3057
|
+
var element = mona_dish_2.DQ.byId(id, true);
|
|
3058
|
+
return _this.getFileInputs(element);
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
var inputExists = function (item) {
|
|
3062
|
+
return !!item.length;
|
|
3063
|
+
};
|
|
3064
|
+
var applyInput = function (item) {
|
|
3065
|
+
_this.fileInputs[_this.resolveSubmitIdentifier(item.getAsElem(0).value)] = true;
|
|
3066
|
+
};
|
|
3067
|
+
mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, executes).map(fetchInput)
|
|
3068
|
+
.filter(inputExists)
|
|
3069
|
+
.each(applyInput);
|
|
3070
|
+
};
|
|
3071
|
+
XhrFormData.prototype.getFileInputs = function (rootElment) {
|
|
3072
|
+
var _this = this;
|
|
3073
|
+
var resolveFileInputs = function (item) {
|
|
3074
|
+
var _a;
|
|
3075
|
+
if (item.length == 1) {
|
|
3076
|
+
if (item.tagName.get("booga").value.toLowerCase() == "input" &&
|
|
3077
|
+
(((_a = item.attr("type")) === null || _a === void 0 ? void 0 : _a.value) || '').toLowerCase() == "file") {
|
|
3078
|
+
return item;
|
|
3079
|
+
}
|
|
3080
|
+
return rootElment.querySelectorAllDeep("input[type='file']");
|
|
3081
|
+
}
|
|
3082
|
+
return _this.getFileInputs(item);
|
|
3083
|
+
};
|
|
3084
|
+
var itemExists = function (item) {
|
|
3085
|
+
return !!(item === null || item === void 0 ? void 0 : item.length);
|
|
3086
|
+
};
|
|
3087
|
+
var ret = rootElment.lazyStream
|
|
3088
|
+
.map(resolveFileInputs)
|
|
3089
|
+
.filter(itemExists)
|
|
3090
|
+
.collect(new mona_dish_1.DomQueryCollector());
|
|
3091
|
+
return ret;
|
|
3092
|
+
};
|
|
3093
|
+
XhrFormData.prototype.handleFormSource = function () {
|
|
3094
|
+
//encode and append the issuing item if not a partial ids array of ids is passed
|
|
3095
|
+
/*
|
|
3096
|
+
* Spec. 13.3.1
|
|
3097
|
+
* Collect and encode input elements.
|
|
3098
|
+
* Additionally the hidden element javax.faces.ViewState
|
|
3099
|
+
* Enhancement partial page submit
|
|
3100
|
+
*
|
|
3101
|
+
*/
|
|
3102
|
+
this.encodeSubmittableFields(this, this.dataSource, this.partialIdsArray);
|
|
3103
|
+
if (this.getIf(Const_1.P_VIEWSTATE).isPresent()) {
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
this.applyViewState(this.dataSource);
|
|
3107
|
+
};
|
|
3108
|
+
/**
|
|
3109
|
+
* special case viewstate handling
|
|
3110
|
+
*
|
|
3111
|
+
* @param form the form holding the viewstate value
|
|
3112
|
+
*/
|
|
3113
|
+
XhrFormData.prototype.applyViewState = function (form) {
|
|
3114
|
+
var viewState = form.byId(Const_1.P_VIEWSTATE, true).inputValue;
|
|
3115
|
+
this.appendIf(viewState.isPresent(), Const_1.P_VIEWSTATE).value = viewState.value;
|
|
3116
|
+
};
|
|
3117
|
+
/**
|
|
3118
|
+
* assignes a url encoded string to this xhrFormData object
|
|
3119
|
+
* as key value entry
|
|
3120
|
+
* @param encoded
|
|
3121
|
+
*/
|
|
3122
|
+
XhrFormData.prototype.assignEncodedString = function (encoded) {
|
|
3123
|
+
var keyValueEntries = decodeURIComponent(encoded).split(/&/gi);
|
|
3124
|
+
this.assignKeyValueEntries(keyValueEntries);
|
|
3125
|
+
};
|
|
3126
|
+
XhrFormData.prototype.assignString = function (keyValueEntries) {
|
|
3127
|
+
var toMerge = new mona_dish_1.Config({});
|
|
3128
|
+
mona_dish_2.Stream.of.apply(mona_dish_2.Stream, keyValueEntries).map(function (line) { return line.split(/=(.*)/gi); })
|
|
3129
|
+
//special case of having keys without values
|
|
3130
|
+
.map(function (keyVal) { var _a, _b; 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; })
|
|
3131
|
+
.each(function (keyVal) {
|
|
3132
|
+
var _a, _b;
|
|
3133
|
+
toMerge.append(keyVal[0]).value = (_b = (_a = keyVal === null || keyVal === void 0 ? void 0 : keyVal.splice(1)) === null || _a === void 0 ? void 0 : _a.join("")) !== null && _b !== void 0 ? _b : "";
|
|
3134
|
+
});
|
|
3135
|
+
//merge with overwrite but no append! (aka no double entries are allowed)
|
|
3136
|
+
this.shallowMerge(toMerge);
|
|
3137
|
+
};
|
|
3138
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3139
|
+
/**
|
|
3140
|
+
* @returns a Form data representation
|
|
3141
|
+
*/
|
|
3142
|
+
XhrFormData.prototype.toFormData = function () {
|
|
3143
|
+
var _this = this;
|
|
3144
|
+
var ret = new FormData();
|
|
3145
|
+
mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, Object.keys(this.value)).filter(function (key) { return !(key in _this.fileInputs); })
|
|
3146
|
+
.each(function (key) {
|
|
3147
|
+
mona_dish_2.Stream.of.apply(mona_dish_2.Stream, _this.value[key]).each(function (item) { return ret.append(key, item); });
|
|
3148
|
+
});
|
|
3149
|
+
mona_dish_2.Stream.of.apply(mona_dish_2.Stream, Object.keys(this.fileInputs)).each(function (key) {
|
|
3150
|
+
mona_dish_2.DQ.querySelectorAllDeep("[name='".concat(key, "'], [id=\"").concat(key, "\"]")).eachElem(function (elem) {
|
|
3151
|
+
var _a;
|
|
3152
|
+
var identifier = _this.resolveSubmitIdentifier(elem);
|
|
3153
|
+
if (!((_a = elem === null || elem === void 0 ? void 0 : elem.files) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3154
|
+
ret.append(identifier, elem.value);
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
ret.append(identifier, elem.files[0]);
|
|
3158
|
+
});
|
|
3159
|
+
});
|
|
3160
|
+
return ret;
|
|
3161
|
+
};
|
|
3162
|
+
XhrFormData.prototype.resolveSubmitIdentifier = function (elem) {
|
|
3163
|
+
var _a;
|
|
3164
|
+
var identifier = elem.name;
|
|
3165
|
+
identifier = (((_a = elem === null || elem === void 0 ? void 0 : elem.name) !== null && _a !== void 0 ? _a : "").replace(/s+/gi, "") == "") ? elem.id : identifier;
|
|
3166
|
+
return identifier;
|
|
3167
|
+
};
|
|
3168
|
+
/**
|
|
3169
|
+
* returns an encoded string representation of our xhr form data
|
|
3170
|
+
*
|
|
3171
|
+
* @param defaultStr optional default value if nothing is there to encode
|
|
3172
|
+
*/
|
|
3173
|
+
XhrFormData.prototype.toString = function (defaultStr) {
|
|
3174
|
+
var _this = this;
|
|
3175
|
+
if (defaultStr === void 0) { defaultStr = Const_1.EMPTY_STR; }
|
|
3176
|
+
if (this.isAbsent()) {
|
|
3177
|
+
return defaultStr;
|
|
3178
|
+
}
|
|
3179
|
+
var entries = mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, Object.keys(this.value)).filter(function (key) { return _this.value.hasOwnProperty(key); })
|
|
3180
|
+
.flatMap(function (key) { return mona_dish_2.Stream.of.apply(mona_dish_2.Stream, _this.value[key]).map(function (val) { return [key, val]; }).collect(new mona_dish_1.ArrayCollector()); })
|
|
3181
|
+
.map(function (keyVal) {
|
|
3182
|
+
return "".concat(encodeURIComponent(keyVal[0]), "=").concat(encodeURIComponent(keyVal[1]));
|
|
3183
|
+
})
|
|
3184
|
+
.collect(new mona_dish_1.ArrayCollector());
|
|
3185
|
+
return entries.join("&");
|
|
3186
|
+
};
|
|
3187
|
+
/**
|
|
3188
|
+
* determines fields to submit
|
|
3189
|
+
* @param {Object} targetBuf - the target form buffer receiving the data
|
|
3190
|
+
* @param {Node} parentItem - form element item is nested in
|
|
3191
|
+
* @param {Array} partialIds - ids fo PPS
|
|
3192
|
+
*/
|
|
3193
|
+
XhrFormData.prototype.encodeSubmittableFields = function (targetBuf, parentItem, partialIds) {
|
|
3194
|
+
var toEncode = null;
|
|
3195
|
+
if (this.partialIdsArray && this.partialIdsArray.length) {
|
|
3196
|
+
//in case of our myfaces reduced ppr we only
|
|
3197
|
+
//only submit the partials
|
|
3198
|
+
this._value = {};
|
|
3199
|
+
toEncode = new (mona_dish_2.DQ.bind.apply(mona_dish_2.DQ, __spreadArray([void 0], this.partialIdsArray, false)))();
|
|
3200
|
+
}
|
|
3201
|
+
else {
|
|
3202
|
+
if (parentItem.isAbsent())
|
|
3203
|
+
throw "NO_PARITEM";
|
|
3204
|
+
toEncode = parentItem;
|
|
3205
|
+
}
|
|
3206
|
+
//lets encode the form elements
|
|
3207
|
+
this.shallowMerge(toEncode.deepElements.encodeFormElement());
|
|
3208
|
+
};
|
|
3209
|
+
Object.defineProperty(XhrFormData.prototype, "isMultipartRequest", {
|
|
3210
|
+
/**
|
|
3211
|
+
* checks if the given datasource is a multipart request source
|
|
3212
|
+
* multipart is only needed if one of the executes is a file input
|
|
3213
|
+
* since file inputs are stateless, they fall out of the viewstate
|
|
3214
|
+
* and need special handling
|
|
3215
|
+
*/
|
|
3216
|
+
get: function () {
|
|
3217
|
+
return !!Object.keys(this.fileInputs).length;
|
|
3218
|
+
},
|
|
3219
|
+
enumerable: false,
|
|
3220
|
+
configurable: true
|
|
3221
|
+
});
|
|
3222
|
+
return XhrFormData;
|
|
3223
|
+
}(mona_dish_1.Config));
|
|
3224
|
+
exports.XhrFormData = XhrFormData;
|
|
3225
|
+
|
|
3226
|
+
|
|
3227
|
+
/***/ }),
|
|
3228
|
+
|
|
3229
|
+
/***/ "./src/main/typescript/impl/xhrCore/XhrRequest.ts":
|
|
3230
|
+
/*!********************************************************!*\
|
|
3231
|
+
!*** ./src/main/typescript/impl/xhrCore/XhrRequest.ts ***!
|
|
3232
|
+
\********************************************************/
|
|
3233
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3234
|
+
|
|
3235
|
+
"use strict";
|
|
3236
|
+
|
|
3237
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3238
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
3239
|
+
* this work for additional information regarding copyright ownership.
|
|
3240
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
3241
|
+
* (the "License"); you may not use this file except in compliance with
|
|
3242
|
+
* the License. You may obtain a copy of the License at
|
|
3243
|
+
*
|
|
3244
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3245
|
+
*
|
|
3246
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3247
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3248
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3249
|
+
* See the License for the specific language governing permissions and
|
|
3250
|
+
* limitations under the License.
|
|
3251
|
+
*/
|
|
3252
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3253
|
+
exports.XhrRequest = void 0;
|
|
3254
|
+
var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/dist/js/commonjs/index_core.js");
|
|
3255
|
+
var AjaxImpl_1 = __webpack_require__(/*! ../AjaxImpl */ "./src/main/typescript/impl/AjaxImpl.ts");
|
|
3256
|
+
var XhrFormData_1 = __webpack_require__(/*! ./XhrFormData */ "./src/main/typescript/impl/xhrCore/XhrFormData.ts");
|
|
3257
|
+
var ErrorData_1 = __webpack_require__(/*! ./ErrorData */ "./src/main/typescript/impl/xhrCore/ErrorData.ts");
|
|
3258
|
+
var EventData_1 = __webpack_require__(/*! ./EventData */ "./src/main/typescript/impl/xhrCore/EventData.ts");
|
|
3259
|
+
var Lang_1 = __webpack_require__(/*! ../util/Lang */ "./src/main/typescript/impl/util/Lang.ts");
|
|
3260
|
+
var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
|
|
3261
|
+
var RequestDataResolver_1 = __webpack_require__(/*! ./RequestDataResolver */ "./src/main/typescript/impl/xhrCore/RequestDataResolver.ts");
|
|
3262
|
+
var failSaveExecute = Lang_1.ExtLang.failSaveExecute;
|
|
3263
|
+
var XhrRequest = /** @class */ (function () {
|
|
3264
|
+
/**
|
|
3265
|
+
* Reqired Parameters
|
|
3266
|
+
*
|
|
3267
|
+
* @param source the issuing element
|
|
3268
|
+
* @param sourceForm the form which is related to the issuing element
|
|
3269
|
+
* @param requestContext the request context with allö pass through values
|
|
3270
|
+
*
|
|
3271
|
+
* Optional Parameters
|
|
3272
|
+
*
|
|
3273
|
+
* @param partialIdsArray an optional restricting partial ids array for encoding
|
|
3274
|
+
* @param timeout optional xhr timeout
|
|
3275
|
+
* @param ajaxType optional request type, default "POST"
|
|
3276
|
+
* @param contentType optional content type, default "application/x-www-form-urlencoded"
|
|
3277
|
+
* @param xhrObject optional xhr object which must fullfill the XMLHTTPRequest api, default XMLHttpRequest
|
|
3278
|
+
*/
|
|
3279
|
+
function XhrRequest(source, sourceForm, requestContext, internalContext, partialIdsArray, timeout, ajaxType, contentType, xhrObject) {
|
|
3280
|
+
if (partialIdsArray === void 0) { partialIdsArray = []; }
|
|
3281
|
+
if (timeout === void 0) { timeout = Const_1.NO_TIMEOUT; }
|
|
3282
|
+
if (ajaxType === void 0) { ajaxType = Const_1.REQ_TYPE_POST; }
|
|
3283
|
+
if (contentType === void 0) { contentType = Const_1.URL_ENCODED; }
|
|
3284
|
+
if (xhrObject === void 0) { xhrObject = new XMLHttpRequest(); }
|
|
3285
|
+
var _this = this;
|
|
3286
|
+
this.source = source;
|
|
3287
|
+
this.sourceForm = sourceForm;
|
|
3288
|
+
this.requestContext = requestContext;
|
|
3289
|
+
this.internalContext = internalContext;
|
|
3290
|
+
this.partialIdsArray = partialIdsArray;
|
|
3291
|
+
this.timeout = timeout;
|
|
3292
|
+
this.ajaxType = ajaxType;
|
|
3293
|
+
this.contentType = contentType;
|
|
3294
|
+
this.xhrObject = xhrObject;
|
|
3295
|
+
this.stopProgress = false;
|
|
3296
|
+
/**
|
|
3297
|
+
* helper support so that we do not have to drag in Promise shims
|
|
3298
|
+
*/
|
|
3299
|
+
this.catchFuncs = [];
|
|
3300
|
+
this.thenFunc = [];
|
|
3301
|
+
/*
|
|
3302
|
+
* we omit promises here
|
|
3303
|
+
* some browsers do not support it and we do not need shim code
|
|
3304
|
+
*/
|
|
3305
|
+
this.registerXhrCallbacks(function (data) {
|
|
3306
|
+
_this.resolve(data);
|
|
3307
|
+
}, function (data) {
|
|
3308
|
+
_this.reject(data);
|
|
3309
|
+
});
|
|
3310
|
+
}
|
|
3311
|
+
XhrRequest.prototype.start = function () {
|
|
3312
|
+
var _this = this;
|
|
3313
|
+
var ignoreErr = failSaveExecute;
|
|
3314
|
+
var xhrObject = this.xhrObject;
|
|
3315
|
+
var executesArr = function () {
|
|
3316
|
+
return _this.requestContext.getIf(Const_1.CTX_PARAM_PASS_THR, Const_1.P_EXECUTE).get("none").value.split(/\s+/gi);
|
|
3317
|
+
};
|
|
3318
|
+
try {
|
|
3319
|
+
var formElement = this.sourceForm.getAsElem(0).value;
|
|
3320
|
+
var viewState = jsf.getViewState(formElement);
|
|
3321
|
+
//encoded we need to decode
|
|
3322
|
+
//We generated a base representation of the current form
|
|
3323
|
+
var formData = new XhrFormData_1.XhrFormData(this.sourceForm);
|
|
3324
|
+
//in case someone has overloaded the viewstate with addtional decorators we merge
|
|
3325
|
+
//that in, there is no way around it, the spec allows it and getViewState
|
|
3326
|
+
//must be called, so whatever getViewState delivers has higher priority then
|
|
3327
|
+
//whatever the formData object delivers
|
|
3328
|
+
formData.assignEncodedString(viewState);
|
|
3329
|
+
formData.applyFileInputs.apply(formData, executesArr());
|
|
3330
|
+
this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
|
|
3331
|
+
//next step the pass through parameters are merged in for post params
|
|
3332
|
+
var requestContext = this.requestContext;
|
|
3333
|
+
var passThroughParams = requestContext.getIf(Const_1.CTX_PARAM_PASS_THR);
|
|
3334
|
+
formData.shallowMerge(passThroughParams, true, true);
|
|
3335
|
+
this.responseContext = passThroughParams.deepCopy;
|
|
3336
|
+
//we have to shift the internal passthroughs around to build up our response context
|
|
3337
|
+
var responseContext = this.responseContext;
|
|
3338
|
+
responseContext.assign(Const_1.CTX_PARAM_MF_INTERNAL).value = this.internalContext.value;
|
|
3339
|
+
//per spec the onevent and onerrors must be passed through to the response
|
|
3340
|
+
responseContext.assign(Const_1.ON_EVENT).value = requestContext.getIf(Const_1.ON_EVENT).value;
|
|
3341
|
+
responseContext.assign(Const_1.ON_ERROR).value = requestContext.getIf(Const_1.ON_ERROR).value;
|
|
3342
|
+
xhrObject.open(this.ajaxType, (0, RequestDataResolver_1.resolveFinalUrl)(this.sourceForm, formData, this.ajaxType), true);
|
|
3343
|
+
//adding timeout
|
|
3344
|
+
this.timeout ? xhrObject.timeout = this.timeout : null;
|
|
3345
|
+
//a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
|
|
3346
|
+
//normal browsers should resolve this
|
|
3347
|
+
//tests can quietly fail on this one
|
|
3348
|
+
if (this.contentType != "undefined") {
|
|
3349
|
+
ignoreErr(function () { return xhrObject.setRequestHeader(Const_1.CONTENT_TYPE, "".concat(_this.contentType, "; charset=utf-8")); });
|
|
3350
|
+
}
|
|
3351
|
+
ignoreErr(function () { return xhrObject.setRequestHeader(Const_1.HEAD_FACES_REQ, Const_1.VAL_AJAX); });
|
|
3352
|
+
//probably not needed anymore, will test this
|
|
3353
|
+
//some webkit based mobile browsers do not follow the w3c spec of
|
|
3354
|
+
// setting the accept headers automatically
|
|
3355
|
+
ignoreErr(function () { return xhrObject.setRequestHeader(Const_1.REQ_ACCEPT, Const_1.STD_ACCEPT); });
|
|
3356
|
+
this.sendEvent(Const_1.BEGIN);
|
|
3357
|
+
this.sendRequest(formData);
|
|
3358
|
+
}
|
|
3359
|
+
catch (e) {
|
|
3360
|
+
//_onError//_onError
|
|
3361
|
+
this.handleError(e);
|
|
3362
|
+
}
|
|
3363
|
+
return this;
|
|
3364
|
+
};
|
|
3365
|
+
XhrRequest.prototype.cancel = function () {
|
|
3366
|
+
try {
|
|
3367
|
+
this.xhrObject.abort();
|
|
3368
|
+
}
|
|
3369
|
+
catch (e) {
|
|
3370
|
+
this.handleError(e);
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
XhrRequest.prototype.resolve = function (data) {
|
|
3374
|
+
mona_dish_1.Stream.of.apply(mona_dish_1.Stream, this.thenFunc).reduce(function (inputVal, thenFunc) {
|
|
3375
|
+
return thenFunc(inputVal);
|
|
3376
|
+
}, data);
|
|
3377
|
+
};
|
|
3378
|
+
XhrRequest.prototype.reject = function (data) {
|
|
3379
|
+
mona_dish_1.Stream.of.apply(mona_dish_1.Stream, this.catchFuncs).reduce(function (inputVal, catchFunc) {
|
|
3380
|
+
return catchFunc(inputVal);
|
|
3381
|
+
}, data);
|
|
3382
|
+
};
|
|
3383
|
+
XhrRequest.prototype.catch = function (func) {
|
|
3384
|
+
//this.$promise.catch(func);
|
|
3385
|
+
this.catchFuncs.push(func);
|
|
3386
|
+
return this;
|
|
3387
|
+
};
|
|
3388
|
+
XhrRequest.prototype.finally = function (func) {
|
|
3389
|
+
//no ie11 support we probably are going to revert to shims for that one
|
|
3390
|
+
//(<any>this.$promise).then(func).catch(func);
|
|
3391
|
+
this.catchFuncs.push(func);
|
|
3392
|
+
this.thenFunc.push(func);
|
|
3393
|
+
return this;
|
|
3394
|
+
};
|
|
3395
|
+
XhrRequest.prototype.then = function (func) {
|
|
3396
|
+
//this.$promise.then(func);
|
|
3397
|
+
this.thenFunc.push(func);
|
|
3398
|
+
return this;
|
|
3399
|
+
};
|
|
3400
|
+
/**
|
|
3401
|
+
* attaches the internal event and processing
|
|
3402
|
+
* callback within the promise to our xhr object
|
|
3403
|
+
*
|
|
3404
|
+
* @param resolve
|
|
3405
|
+
* @param reject
|
|
3406
|
+
*/
|
|
3407
|
+
XhrRequest.prototype.registerXhrCallbacks = function (resolve, reject) {
|
|
3408
|
+
var _this = this;
|
|
3409
|
+
var xhrObject = this.xhrObject;
|
|
3410
|
+
xhrObject.onabort = function () {
|
|
3411
|
+
_this.onAbort(resolve, reject);
|
|
3412
|
+
};
|
|
3413
|
+
xhrObject.ontimeout = function () {
|
|
3414
|
+
_this.onTimeout(resolve, reject);
|
|
3415
|
+
};
|
|
3416
|
+
xhrObject.onload = function () {
|
|
3417
|
+
_this.onSuccess(_this.xhrObject, resolve, reject);
|
|
3418
|
+
};
|
|
3419
|
+
xhrObject.onloadend = function () {
|
|
3420
|
+
_this.onDone(_this.xhrObject, resolve, reject);
|
|
3421
|
+
};
|
|
3422
|
+
xhrObject.onerror = function (errorData) {
|
|
3423
|
+
_this.onError(errorData, resolve, reject);
|
|
3424
|
+
};
|
|
3425
|
+
};
|
|
3426
|
+
/*
|
|
3427
|
+
* xhr processing callbacks
|
|
3428
|
+
*
|
|
3429
|
+
* Those methods are the callbacks called by
|
|
3430
|
+
* the xhr object depending on its own state
|
|
3431
|
+
*/
|
|
3432
|
+
XhrRequest.prototype.onAbort = function (resolve, reject) {
|
|
3433
|
+
reject();
|
|
3434
|
+
};
|
|
3435
|
+
XhrRequest.prototype.onTimeout = function (resolve, reject) {
|
|
3436
|
+
this.sendEvent(Const_1.STATE_EVT_TIMEOUT);
|
|
3437
|
+
reject();
|
|
3438
|
+
};
|
|
3439
|
+
XhrRequest.prototype.onSuccess = function (data, resolve, reject) {
|
|
3440
|
+
var _a, _b;
|
|
3441
|
+
this.sendEvent(Const_1.COMPLETE);
|
|
3442
|
+
//malforms always result in empty response xml
|
|
3443
|
+
if (!((_a = this === null || this === void 0 ? void 0 : this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseXML)) {
|
|
3444
|
+
this.handleMalFormedXML(resolve);
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3447
|
+
jsf.ajax.response(this.xhrObject, (_b = this.responseContext.value) !== null && _b !== void 0 ? _b : {});
|
|
3448
|
+
};
|
|
3449
|
+
XhrRequest.prototype.handleMalFormedXML = function (resolve) {
|
|
3450
|
+
var _a;
|
|
3451
|
+
this.stopProgress = true;
|
|
3452
|
+
var errorData = {
|
|
3453
|
+
type: Const_1.ERROR,
|
|
3454
|
+
status: Const_1.MALFORMEDXML,
|
|
3455
|
+
responseCode: 200,
|
|
3456
|
+
responseText: (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseText,
|
|
3457
|
+
source: {
|
|
3458
|
+
id: this.source.id.value
|
|
3459
|
+
}
|
|
3460
|
+
};
|
|
3461
|
+
try {
|
|
3462
|
+
AjaxImpl_1.Implementation.sendError(errorData);
|
|
3463
|
+
}
|
|
3464
|
+
finally {
|
|
3465
|
+
resolve(errorData);
|
|
3466
|
+
}
|
|
3467
|
+
//non blocking non clearing
|
|
3468
|
+
};
|
|
3469
|
+
XhrRequest.prototype.onDone = function (data, resolve, reject) {
|
|
3470
|
+
if (this.stopProgress) {
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
resolve(data);
|
|
3474
|
+
};
|
|
3475
|
+
XhrRequest.prototype.onError = function (errorData, resolve, reject) {
|
|
3476
|
+
this.handleError(errorData);
|
|
3477
|
+
reject();
|
|
3478
|
+
};
|
|
3479
|
+
/*
|
|
3480
|
+
* other helpers
|
|
3481
|
+
*/
|
|
3482
|
+
XhrRequest.prototype.sendEvent = function (evtType) {
|
|
3483
|
+
var eventData = EventData_1.EventData.createFromRequest(this.xhrObject, this.requestContext, evtType);
|
|
3484
|
+
try {
|
|
3485
|
+
//user code error, we might cover
|
|
3486
|
+
//this in onError but also we cannot swallow it
|
|
3487
|
+
//we need to resolve the local handlers lazyly,
|
|
3488
|
+
//because some frameworks might decorate them over the context in the response
|
|
3489
|
+
var eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_EVENT);
|
|
3490
|
+
AjaxImpl_1.Implementation.sendEvent(eventData, eventHandler);
|
|
3491
|
+
}
|
|
3492
|
+
catch (e) {
|
|
3493
|
+
this.handleError(e);
|
|
3494
|
+
throw e;
|
|
3495
|
+
}
|
|
3496
|
+
};
|
|
3497
|
+
XhrRequest.prototype.handleError = function (exception) {
|
|
3498
|
+
var errorData = ErrorData_1.ErrorData.fromClient(exception);
|
|
3499
|
+
var eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_ERROR);
|
|
3500
|
+
AjaxImpl_1.Implementation.sendError(errorData, eventHandler);
|
|
3501
|
+
};
|
|
3502
|
+
XhrRequest.prototype.sendRequest = function (formData) {
|
|
3503
|
+
var isPost = this.ajaxType != Const_1.REQ_TYPE_GET;
|
|
3504
|
+
if (formData.isMultipartRequest) {
|
|
3505
|
+
//in case of a multipart request we send in a formData object as body
|
|
3506
|
+
this.xhrObject.send((isPost) ? formData.toFormData() : null);
|
|
3507
|
+
}
|
|
3508
|
+
else {
|
|
3509
|
+
//in case of a normal request we send it normally
|
|
3510
|
+
this.xhrObject.send((isPost) ? formData.toString() : null);
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
return XhrRequest;
|
|
3514
|
+
}());
|
|
3515
|
+
exports.XhrRequest = XhrRequest;
|
|
3516
|
+
|
|
3517
|
+
|
|
3518
|
+
/***/ })
|
|
3519
|
+
|
|
3520
|
+
/******/ });
|
|
3521
|
+
/************************************************************************/
|
|
3522
|
+
/******/ // The module cache
|
|
3523
|
+
/******/ var __webpack_module_cache__ = {};
|
|
3524
|
+
/******/
|
|
3525
|
+
/******/ // The require function
|
|
3526
|
+
/******/ function __webpack_require__(moduleId) {
|
|
3527
|
+
/******/ // Check if module is in cache
|
|
3528
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
3529
|
+
/******/ if (cachedModule !== undefined) {
|
|
3530
|
+
/******/ return cachedModule.exports;
|
|
3531
|
+
/******/ }
|
|
3532
|
+
/******/ // Create a new module (and put it into the cache)
|
|
3533
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
3534
|
+
/******/ // no module.id needed
|
|
3535
|
+
/******/ // no module.loaded needed
|
|
3536
|
+
/******/ exports: {}
|
|
3537
|
+
/******/ };
|
|
3538
|
+
/******/
|
|
3539
|
+
/******/ // Execute the module function
|
|
3540
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
3541
|
+
/******/
|
|
3542
|
+
/******/ // Return the exports of the module
|
|
3543
|
+
/******/ return module.exports;
|
|
3544
|
+
/******/ }
|
|
3545
|
+
/******/
|
|
3546
|
+
/************************************************************************/
|
|
3547
|
+
/******/
|
|
3548
|
+
/******/ // startup
|
|
3549
|
+
/******/ // Load entry module and return exports
|
|
3550
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
3551
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/main/typescript/api/Jsf.ts");
|
|
3552
|
+
/******/ var __webpack_export_target__ = window;
|
|
3553
|
+
/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
|
|
3554
|
+
/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
3555
|
+
/******/
|
|
3556
|
+
/******/ })()
|
|
3557
|
+
;
|
|
3558
|
+
//# sourceMappingURL=jsf-development.js.map
|
|
3559
|
+
//# sourceMappingURL=jsf-development.js.map.jsf?ln=scripts
|