blob: ce5148e155c9bcf3690fb5145f51fd3a0bdbedc5 [file] [log] [blame]
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/main/typescript/impl/core/Const.ts","webpack:///./src/main/typescript/ext/monadish/index.ts","webpack:///./src/main/typescript/ext/monadish/Monad.ts","webpack:///./src/main/typescript/ext/monadish/Lang.ts","webpack:///./src/main/typescript/impl/util/Lang.ts","webpack:///./src/main/typescript/ext/monadish/DomQuery.ts","webpack:///./src/main/typescript/ext/monadish/SourcesCollectors.ts","webpack:///./src/main/typescript/ext/monadish/Stream.ts","webpack:///./src/main/typescript/impl/AjaxImpl.ts","webpack:///./src/main/typescript/impl/util/Assertions.ts","webpack:///./src/main/typescript/impl/xhrCore/RequestDataResolver.ts","webpack:///./src/main/typescript/impl/xhrCore/ErrorData.ts","webpack:///./src/main/typescript/impl/xhrCore/EventData.ts","webpack:///./src/main/typescript/api/Jsf.ts","webpack:///./src/main/typescript/impl/util/ExtDomQuery.ts","webpack:///./src/main/typescript/impl/xhrCore/XhrFormData.ts","webpack:///./src/main/typescript/impl/xhrCore/Response.ts","webpack:///./src/main/typescript/ext/monadish/XmlQuery.ts","webpack:///./src/main/typescript/impl/xhrCore/ResponseProcessor.ts","webpack:///./src/main/typescript/impl/i18n/Messages.ts","webpack:///./src/main/typescript/impl/core/ImplTypes.ts","webpack:///./src/main/typescript/impl/xhrCore/ResonseDataResolver.ts","webpack:///./src/main/typescript/impl/xhrCore/XhrRequest.ts","webpack:///./src/main/typescript/impl/util/AsyncQueue.ts","webpack:///./src/main/typescript/impl/PushImpl.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","P_PARTIAL_SOURCE","PARTIAL_ID","P_VIEWSTATE","P_VIEWROOT","P_VIEWHEAD","P_VIEWBODY","EMPTY_FUNC","freeze","EMPTY_STR","EMPTY_MAP","HTML_VIEWSTATE","join","IDENT_ALL","IDENT_NONE","IDENT_THIS","IDENT_FORM","P_AJAX","P_EXECUTE","P_RENDER","P_EVT","P_CLIENT_WINDOW","P_RESET_VALUES","P_WINDOW_ID","RENDER","WINDOW_ID","ERROR","EVENT","ON_ERROR","ON_EVENT","BEGIN","COMPLETE","SUCCESS","SOURCE","STATUS","ERROR_NAME","ERROR_MESSAGE","RESPONSE_TEXT","RESPONSE_XML","HTTPERROR","EMPTY_RESPONSE","MALFORMEDXML","SERVER_ERROR","CLIENT_ERROR","TIMEOUT_EVENT","CTX_PARAM_MF_INTERNAL","CTX_PARAM_SRC_FRM_ID","CTX_PARAM_SRC_CTL_ID","CTX_PARAM_TR_TYPE","CTX_PARAM_PASS_THR","CTX_PARAM_DELAY","CTX_PARAM_TIMEOUT","CTX_PARAM_RST","CTX_PARAM_EXECUTE","STAGE_DEVELOPMENT","CONTENT_TYPE","HEAD_FACES_REQ","REQ_ACCEPT","VAL_AJAX","ENCODED_URL","REQ_TYPE_GET","REQ_TYPE_POST","STATE_EVT_BEGIN","STATE_EVT_TIMEOUT","STATE_EVT_COMPLETE","URL_ENCODED","MULTIPART","NO_TIMEOUT","STD_ACCEPT","TAG_HEAD","TAG_FORM","TAG_BODY","TAG_BEFORE","TAG_AFTER","TAG_ATTR","SEL_VIEWSTATE_ELEM","SEL_RESPONSE_XML","PHASE_PROCESS_RESPONSE","ERR_NO_PARTIAL_RESPONSE","ATTR_URL","ATTR_NAME","ATTR_VALUE","ATTR_ID","RESP_PARTIAL","CMD_CHANGES","CMD_UPDATE","CMD_DELETE","CMD_INSERT","CMD_EVAL","CMD_ERROR","CMD_ATTRIBUTES","CMD_EXTENSION","CMD_REDIRECT","UPDATE_FORMS","UPDATE_ELEMS","MYFACES","SEL_SCRIPTS_STYLES","MF_NONE","REASON_EXPIRED","APPLIED_VST","RECONNECT_INTERVAL","MAX_RECONNECT_ATTEMPTS","UNKNOWN","DomQuery","ElementAttribute","DomQueryCollector","DQ","Lang","Config","Monad","Optional","ValueEmbedder","XMLQuery","XQ","Stream","LazyStream","ArrayStreamDataSource","MappedStreamDataSource","FilteredStreamDatasource","FlatMapStreamDataSource","QueryFormStringCollector","ArrayCollector","AssocArrayCollector","FormDataCollector","QueryFormDataCollector","objAssign","this","_value","map","fn","inval","flatMap","mapped","fromNullable","isAbsent","isPresent","presentRunnable","absent","ifPresentLazy","orElse","elseValue","orElseLazy","func","val","getIf","currentPos","cnt","length","currKey","keyVal","arrPos","arrayIndex","getClass","Array","getIfPresent","match","defaultVal","toJson","JSON","stringify","start","indexOf","end","parseInt","substring","resolve","resolver","e","rootElem","valueKey","newVal","alternative","ConfigEntry","root","ofAssoc","collect","shallowMerge","other","overwrite","withAppend","isArray","of","each","item","append","assign","noKeys","keys","lastKey","pathExists","buildPath","finalKeyArrPos","Error","push","retVal","apply","slice","appendIf","condition","assignIf","delete","setVal","parentVal","parentPos","alloc","arr","length1","length2","tempVal","trim","str","ws","replace","test","charAt","isString","it","arguments","String","saveResolve","resolverProducer","defaultValue","result","saveResolveLazy","strToArray","splitter","ret","split","forEach","element","objToArray","obj","offset","pack","concat","equalsIgnoreCase","source","destination","finalDest","toLowerCase","assertType","probe","theType","isFunc","Function","target","TypeError","to","theArgs","nextSource","nextKey","ExtLang","installedLocale","getMessage","defaultMessage","msg","Messages","templateParams","param","RegExp","makeException","error","title","callerCls","callFunc","message","caller","toString","getLanguage","language","navigator","languages","failSaveResolve","failSaveExecute","keyValToStr","delimiter","getGlobalConfig","configName","window","myfaces","config","getForm","elem","event","queryElem","eventTarget","getEventTarget","isTag","attr","formId","foundForm","byId","form","parents","byTagName","first","assertFormExists","getLocalOrGlobalConfig","localOptions","Submittables","values","getAttribute","setAttribute","DEFAULT_JSF_WHITELIST","src","rootNode","pos","_limits","foundElement","querySelectorAll","getAsElem","allElems","tagName","nodeName","allMatch","el","checked","newChecked","eachElem","querySelectorAllDeep","queryStr","found","queryRes","shadowRoots","shadowRoot","shadowRes","disabled","removeAttribute","childNodeArr","childNodes","asArray","ofStreamDataSource","filter","selector","document","_querySelectorAllDeep","_querySelectorAll","deep","byIdDeep","globalEval","code","nonce","fromMarkup","markup","doc","implementation","createHTMLDocument","lowerMarkup","documentElement","innerHTML","startsWithTag","tag1","tag2","dummyPlaceHolder","createElement","html","detach","index","defaults","filesFromElem","files","node","parentNode","removeChild","nodes","res","foundNodes","selectors","cnt2","levelSelector","id","includeRoot","subItems","reduce","reduction","hasClass","clazz","hasIt","classList","contains","addClass","add","removeClass","remove","isMultipartCandidate","stream","firstElem","isCandidate","innerHtml","dispatchEvent","evt","retArr","inVal","_mozMatchesSelector","toMatch","prot","matchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","matches","ownerDocument","filterSelector","matched","selectorStage","nodeSelector","len","reArr","head","getElementsByTagName","script","type","newScriptElement","appendChild","appendTo","theItem","loadScriptEval","defer","charSet","xhr","XMLHttpRequest","open","setRequestHeader","send","onload","responseData","setTimeout","responseText","onerror","data","insertAfter","existingItem","existingElement","nextSibling","toInsertParams","insertElem","insertBefore","retSet","Set","lowerTagName","resolveItem","has","copyAttrs","sourceItem","sourceNode","attributes","resolveAttributeHolder","attrName","outerHTML","runEmbeddedScripts","runEmbeddedCss","focusElementId","activeElement","caretPosition","getCaretPosition","toReplace","firstInsert","replaced","replaceChild","insertAdditionalItems","runScripts","runCss","focusElement","setCaretPosition","whilteListed","finalScripts","equi","execScrpt","itemType","evalText","text","innerText","go","sort","node1","node2","compareDocumentPosition","console","description","applyStyle","style","newSS","styleSheet","sheet","cssText","createTextNode","child","execCss","click","fireEvent","addEventListener","listener","options","removeEventListener","eventName","nodeType","eventClass","createEvent","initEvent","synthetic","createEventObject","textContent","joinstr","text1","text2","encodeFormElement","toMerge","shallowCopy","elemType","selectElem","selectedIndex","uLen","u","selected","elementOption","SELECT","BUTTON","RESET","SUBMIT","IMAGE","CHECKBOX","RADIO","inputValue","lazyStream","reduced","subNodes","from","Math","min","limits","hasNext","isLimitsReached","isEndOfArray","next","reset","attachShadow","params","shadowElement","hasShadow","ctrl","caretPos","selection","focus","createRange","moveStart","setSelectiongRange","dataPos","filterFunc","parent","filteredNext","inputDataSource","mapFunc","resolveCurrentNext","resolveNextNext","activeDataSource","finalValue","FormData","formData","item1","item2","ofDataSource","dataSource","onElem","strmR","startVal","val1","last","anyMatch","noneMatch","comparator","newArr","collector","isOverLimits","nextFilter","max","stop","value1","value2","el1","el2","ProjectStages","BlockFilter","Implementation","assert","Assertions","eventQueue","errorQueue","requestQueue","resolveProjectStateFromURL","foundStage","ExtDomquery","searchJsfJsFor","sendError","errorData","localHandler","errorCallback","alert","displayError","remapDefaultConstants","targetConfig","targetKey","userValues","issuingForm","issuingElementId","iterValues","processed","resolveGlobalConfig","getSeparatorChar","separator","getProjectStage","projectStage","chain","resolveAndExecute","sourceCode","funcs","request","opts","mappedOpts","resolvedEvent","elementId","requestCtx","internalCtx","windowId","isResetValues","assertRequestIntegrity","onevent","requestOptions","targetContext","sourceElementId","resolveForm","clientWindow","jsf","getClientWindow","assignClientWindowId","assignRender","delay","resolveDelay","timeout","resolveTimeout","queueHandler","addRequestToQueue","response","context","Response","processResponse","addOnError","errorListener","addOnEvent","eventListener","sendEvent","stdErrorHandler","exception","clearRequestQueue","ErrorData","fromClient","cleanup","ALTERED","formWindowId","body","getViewState","XhrFormData","reqCtx","respPassThr","AsynchronouseQueue","enqueue","XhrRequest","raiseError","assertFunction","assertUrlExists","assertValidXMLResponse","responseXML","isXMLParserError","parserErrorText","finalTitle","finalName","finalMessage","resolveWindowId","requestContext","responseContext","funcName","srcFormElement","elements","action","sourceForm","ajaxType","resolveTargetUrl","configId","getCfg","finalEvent","srcElement","deepCopy","resetValues","ErrorType","errorName","errorMessage","responseCode","status","typeDetails","serverErrorName","serverErrorMessage","stack","fromHttpConnection","HTTP_ERROR","fromGeneric","errorCode","errorType","getMsg","fromServerError","EventData","createFromRequest","eventData","sourceId","specversion","implversion","separatorchar","formElement","ajax","errorFunc","eventFunc","util","init","socketClientId","uri","channel","onopen","onmessage","onclose","behaviorScripts","autoconnect","PushImpl","close","ab","execute","render","fetchWindowIdFromURL","href","location","results","exec","curScript","currentScript","nonceScript","rexp","search","decodeURIComponent","ExtDQ","partialIdsArray","encode","fileInputs","assignEncodedString","handleFormSource","applyFileInputs","executes","getFileInputs","rootElment","encodeSubmittableFields","applyViewState","viewState","encoded","keyValueEntries","assignString","line","splice","toFormData","identifier","resolveSubmitIdentifier","defaultStr","encodeURIComponent","targetBuf","parentItem","partialIds","toEncode","deepElements","req","externalContext","internalContext","resolveResponseXML","responseProcessor","ResponseProcessor","SEL_SUB_TAGS","redirect","ALLOWED_TAGS","processViewState","cdataBlock","cDATAAsString","replaceViewRoot","replaceHead","replaceBody","update","handleElementUpdate","processUpdateTag","eval","insertWithSubtags","insert","processInsert","processChangesTag","processPartialTag","fixViewStates","done","docType","xml","DOMParser","parser","ActiveXObject","async","parseFromString","contentType","loadXML","serialized","XMLSerializer","constructor","serializeToString","parseXML","txt","parseHTML","fromString","parseType","shadowDocument","shadowHead","storeForEval","shadowBody","shadowInnerHTML","resultingBody","updateForms","storeForPostProcessing","mergedErrorData","hasResponseXML","redirectUrl","before","after","insertNodes","insertId","isViewStateNode","viewStateValue","ViewState","updateElems","nameSpace","affectedForms","affectedForms2","appendViewStateToForms","eventHandler","forms","newViewStateElement","newViewState","toBeEvaled","storeForUpdate","separatorChar","MSG_TEST","MSG_DEV_MODE","MSG_AFFECTED_CLASS","MSG_AFFECTED_METHOD","MSG_ERROR_NAME","MSG_ERROR_MESSAGE","MSG_SERVER_ERROR_NAME","MSG_ERROR_DESC","MSG_ERROR_NO","MSG_ERROR_LINENO","ERR_FORM","ERR_VIEWSTATE","ERR_TRANSPORT","ERR_EVT_PASS","ERR_CONSTRUCT","ERR_MALFORMEDXML","ERR_SOURCE_FUNC","ERR_EV_OR_UNKNOWN","ERR_SOURCE_NOSTR","ERR_SOURCE_DEF_NULL","ERR_MUST_STRING","ERR_REF_OR_ID","ERR_PARAM_GENERIC","ERR_PARAM_STR","ERR_PARAM_STR_RE","ERR_PARAM_MIXMAPS","ERR_MUST_BE_PROVIDED","ERR_MUST_BE_PROVIDED1","ERR_REPLACE_EL","ERR_EMPTY_RESPONSE","ERR_ITEM_ID_NOTFOUND","ERR_PPR_IDREQ","ERR_PPR_INSERTBEFID","ERR_PPR_INSERTBEFID_1","ERR_PPR_INSERTBEFID_2","ERR_PPR_DELID","ERR_PPR_UNKNOWNCID","ERR_NO_VIEWROOTATTR","ERR_NO_HEADATTR","ERR_RED_URL","ERR_REQ_FAILED_UNKNOWN","ERR_REQU_FAILED","viewStatePos","substr","elemId","resolveSourceElementId","sourceFormId","xhrObject","stopProgress","catchFuncs","thenFunc","registerXhrCallbacks","reject","ignoreErr","isMultipartRequest","passThroughParams","resolveFinalUrl","sendRequest","handleError","cancel","abort","inputVal","catchFunc","catch","finally","then","onabort","onAbort","ontimeout","onTimeout","onSuccess","onloadend","onDone","onError","handleMalFormedXML","evtType","resolveHandlerFunc","isPost","runnableQueue","delayTimeout","clearTimeout","appendElement","dequeue","shift","currentlyRunning","runEntry","isEmpty","callForNextElementToProcess","URL_PROTOCOL","protocol","sockets","components","clientIdsByTokens","resolveFunction","WebSocket","channelToken","Socket","url","base","hostname","port","getBaseURL","getSocket","reconnectAttempts","socket","readyState","bindCallbacks","clientIds","onmmessage","parse","getElementById","functions","j","reason"],"mappings":"4DACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAG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EAEP,MAAM,IAAIxvB,MAAM,yBAA2B+uB,GAInD,SAASF,EAAgB5yB,GAErB,YAFqB,IAAAA,MAAA,cAEY,mBAAPA,IAAuBA,EAAKqJ,OAAOrJ,IAAMA,GA1N3E,CAAc,EAAAylB,WAAA,EAAAA,SAAQ","file":"jsf.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 13);\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * [export const] constants\n */\n\nexport const P_PARTIAL_SOURCE = \"javax.faces.source\";\nexport const PARTIAL_ID = \"partialId\";\nexport const P_VIEWSTATE = \"javax.faces.ViewState\";\nexport const P_VIEWROOT = \"javax.faces.ViewRoot\";\nexport const P_VIEWHEAD = \"javax.faces.ViewHead\";\nexport const P_VIEWBODY = \"javax.faces.ViewBody\";\n\n/*some useful definitions*/\n\nexport const EMPTY_FUNC = Object.freeze(() => {\n});\nexport const EMPTY_STR = \"\";\nexport const EMPTY_MAP = Object.freeze({});\n\nexport const HTML_VIEWSTATE = [\"<input type='hidden'\", \"id='\", P_VIEWSTATE, \"' name='\", P_VIEWSTATE, \"' value='' />\"].join(EMPTY_STR);\n\n\n/*internal identifiers for options*/\nexport const IDENT_ALL = \"@all\";\nexport const IDENT_NONE = \"@none\";\nexport const IDENT_THIS = \"@this\";\nexport const IDENT_FORM = \"@form\";\n\n\nexport const P_AJAX = \"javax.faces.partial.ajax\";\nexport const P_EXECUTE = \"javax.faces.partial.execute\";\nexport const P_RENDER = \"javax.faces.partial.render\";\nexport const P_EVT = \"javax.faces.partial.event\";\nexport const P_CLIENT_WINDOW = \"javax.faces.ClientWindow\";\nexport const P_RESET_VALUES = \"javax.faces.partial.resetValues\";\n\nexport const P_WINDOW_ID = \"javax.faces.windowId\";\n\nexport const RENDER = \"render\";\nexport const WINDOW_ID = \"windowId\";\n\n/* message types */\nexport const ERROR = \"error\";\nexport const EVENT = \"event\";\n\nexport const ON_ERROR = \"onerror\";\nexport const ON_EVENT = \"onevent\";\n\n/* event emitting stages */\nexport const BEGIN = \"begin\";\nexport const COMPLETE = \"complete\";\nexport const SUCCESS = \"success\";\n\nexport const SOURCE = \"source\";\nexport const STATUS = \"status\";\n\n\nexport const ERROR_NAME = \"error-name\";\nexport const ERROR_MESSAGE = \"error-message\";\n\n\nexport const RESPONSE_TEXT = \"responseText\";\nexport const RESPONSE_XML = \"responseXML\";\n\n/*ajax errors spec 14.4.2*/\nexport const HTTPERROR = \"httpError\";\nexport const EMPTY_RESPONSE = \"emptyResponse\";\nexport const MALFORMEDXML = \"malformedXML\";\nexport const SERVER_ERROR = \"serverError\";\nexport const CLIENT_ERROR = \"clientError\";\nexport const TIMEOUT_EVENT = \"timeout\";\n\nexport const CTX_PARAM_MF_INTERNAL = \"_mfInternal\";\n\nexport const CTX_PARAM_SRC_FRM_ID = \"_mfSourceFormId\";\nexport const CTX_PARAM_SRC_CTL_ID = \"_mfSourceControlId\";\nexport const CTX_PARAM_TR_TYPE = \"_mfTransportType\";\nexport const CTX_PARAM_PASS_THR = \"passThrgh\";\nexport const CTX_PARAM_DELAY = \"delay\";\nexport const CTX_PARAM_TIMEOUT = \"timeout\";\nexport const CTX_PARAM_RST = \"resetValues\";\nexport const CTX_PARAM_EXECUTE = \"execute\";\n\nexport const STAGE_DEVELOPMENT = \"Development\";\n\n\nexport const CONTENT_TYPE = \"Content-Type\";\nexport const HEAD_FACES_REQ = \"Faces-Request\";\nexport const REQ_ACCEPT = \"Accept\";\nexport const VAL_AJAX = \"partial/ajax\";\nexport const ENCODED_URL = \"javax.faces.encodedURL\";\nexport const REQ_TYPE_GET = \"GET\";\nexport const REQ_TYPE_POST = \"POST\";\nexport const STATE_EVT_BEGIN = \"begin\"; //TODO remove this\nexport const STATE_EVT_TIMEOUT = \"TIMEOUT_EVENT\";\nexport const STATE_EVT_COMPLETE = \"complete\"; //TODO remove this\nexport const URL_ENCODED = \"application/x-www-form-urlencoded\";\nexport const MULTIPART = \"multipart/form-data\";\nexport const NO_TIMEOUT = 0;\nexport const STD_ACCEPT = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\";\n\nexport const TAG_HEAD = \"head\";\nexport const TAG_FORM = \"form\";\nexport const TAG_BODY = \"body\";\nexport const TAG_BEFORE = \"before\";\nexport const TAG_AFTER = \"after\";\n\nexport const TAG_ATTR = \"attribute\";\n\n\nexport const SEL_VIEWSTATE_ELEM = \"[name='\" + P_VIEWSTATE + \"']\";\nexport const SEL_RESPONSE_XML = \"responseXML\";\n\nexport const PHASE_PROCESS_RESPONSE = \"processResponse\";\n\n\nexport const ERR_NO_PARTIAL_RESPONSE = \"Partial response not set\";\n\nexport const ATTR_URL = \"url\";\nexport const ATTR_NAME = \"name\";\nexport const ATTR_VALUE = \"value\";\nexport const ATTR_ID = \"id\";\n\n/*partial response types*/\nexport const RESP_PARTIAL = \"partial-response\";\n\n/*partial commands*/\nexport const CMD_CHANGES = \"changes\";\nexport const CMD_UPDATE = \"update\";\nexport const CMD_DELETE = \"delete\";\nexport const CMD_INSERT = \"insert\";\nexport const CMD_EVAL = \"eval\";\nexport const CMD_ERROR = \"error\";\nexport const CMD_ATTRIBUTES = \"attributes\";\nexport const CMD_EXTENSION = \"extension\";\nexport const CMD_REDIRECT = \"redirect\";\n\n/*other constants*/\n\nexport const UPDATE_FORMS = \"_updateForms\";\nexport const UPDATE_ELEMS = \"_updateElems\";\n\nexport const MYFACES = \"myfaces\";\n\nexport const SEL_SCRIPTS_STYLES = \"script, style, link\";\n\nexport const MF_NONE = \"__mf_none__\";\n\nexport const REASON_EXPIRED = \"Expired\";\n\nexport const APPLIED_VST = \"appliedViewState\";\n\nexport const RECONNECT_INTERVAL = 500;\nexport const MAX_RECONNECT_ATTEMPTS = 25;\n\nexport const UNKNOWN = \"UNKNOWN\";\n","export {DomQuery, ElementAttribute, DomQueryCollector, DQ} from \"./DomQuery\";\nexport {Lang} from \"./Lang\";\nexport {Config, Monad, IValueHolder, IFunctor, IMonad, IIdentity, Optional, ValueEmbedder} from \"./Monad\";\nexport {XMLQuery, XQ} from \"./XmlQuery\";\nexport {Stream, LazyStream, IteratableConsumer, IStream} from \"./Stream\";\nexport {\n ArrayStreamDataSource,\n MappedStreamDataSource,\n FilteredStreamDatasource,\n FlatMapStreamDataSource,\n QueryFormStringCollector,\n IStreamDataSource,\n ICollector,\n ArrayCollector,\n AssocArrayCollector,\n FormDataCollector,\n QueryFormDataCollector\n} from \"./SourcesCollectors\";\n\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A module which keeps basic monadish like definitions in place without any sidedependencies to other modules.\n * Useful if you need the functions in another library to keep its dependencies down\n */\n\n/*IMonad definitions*/\n\nimport {Lang} from \"./Lang\";\nimport {AssocArrayCollector} from \"./SourcesCollectors\";\nimport {Stream} from \"./Stream\";\nimport objAssign = Lang.objAssign;\n\n/**\n * IFunctor interface,\n * defines an interface which allows to map a functor\n * via a first order function to another functor\n */\nexport interface IFunctor<T> {\n map<R>(fn: (data: T) => R): IFunctor<R>;\n}\n\n/**\n * IMonad definition, basically a functor with a flaptmap implementation (flatmap reduces all nested monads after a\n * function call f into a monad with the nesting level of 1\n *\n * flatmap flats nested Monads into a IMonad of the deepest nested implementation\n */\nexport interface IMonad<T, M extends IMonad<any, any>> extends IFunctor<T> {\n flatMap<T, M>(f: (T) => M): IMonad<any, any>;\n}\n\n/**\n * a stateful functor which holds a value upn which a\n * function can be applied\n *\n * as value holder of type T\n */\nexport interface IIdentity<T> extends IFunctor<T> {\n readonly value: T;\n}\n\n/**\n * custom value holder definition, since we are not pure functional\n * but iterative we have structures which allow the assignment of a value\n * also not all structures are sideffect free\n */\nexport interface IValueHolder<T> {\n value: T | Array<T>;\n}\n\n/**\n * Implementation of a monad\n * (Sideffect free), no write allowed directly on the monads\n * value state\n */\nexport class Monad<T> implements IMonad<T, Monad<any>>, IValueHolder<T> {\n constructor(value: T) {\n this._value = value;\n }\n\n protected _value: T;\n\n get value(): T {\n return this._value;\n }\n\n map<R>(fn?: (data: T) => R): Monad<R> {\n if (!fn) {\n fn = (inval: any) => <R>inval;\n }\n let result: R = fn(this.value);\n return new Monad(result);\n }\n\n flatMap<R>(fn?: (data: T) => R): Monad<any> {\n let mapped: Monad<any> = this.map(fn);\n while (mapped?.value instanceof Monad) {\n mapped = mapped.value\n }\n return mapped;\n }\n\n}\n\n/**\n * optional implementation, an optional is basically an implementation of a Monad with additional syntactic\n * sugar on top\n * (Sideeffect free, since value assignment is not allowed)\n * */\nexport class Optional<T> extends Monad<T> {\n\n /*default value for absent*/\n static absent = Optional.fromNullable(null);\n\n constructor(value: T) {\n super(value);\n }\n\n get value(): T {\n if (this._value instanceof Monad) {\n return this._value.flatMap().value\n }\n return this._value;\n }\n\n static fromNullable<T>(value?: T): Optional<T> {\n return new Optional(value);\n }\n\n /*syntactic sugar for absent and present checks*/\n isAbsent(): boolean {\n return \"undefined\" == typeof this.value || null == this.value;\n }\n\n /**\n * any value present\n */\n isPresent(presentRunnable ?: (val ?: Monad<T>) => void): boolean {\n let absent = this.isAbsent();\n if (!absent && presentRunnable) {\n presentRunnable.call(this, this)\n }\n return !absent;\n }\n\n ifPresentLazy(presentRunnable: (val ?: Monad<T>) => void = () => {\n }): Monad<T> {\n this.isPresent.call(this, presentRunnable);\n return this;\n }\n\n orElse(elseValue: any): Optional<any> {\n if (this.isPresent()) {\n return this;\n } else {\n //shortcut\n if (elseValue == null) {\n return Optional.absent;\n }\n return this.flatMap(() => elseValue);\n }\n }\n\n /**\n * lazy, passes a function which then is lazily evaluated\n * instead of a direct value\n * @param func\n */\n orElseLazy(func: () => any): Optional<any> {\n if (this.isPresent()) {\n return this;\n } else {\n return this.flatMap(func);\n }\n }\n\n /*\n * we need to implement it to fullfill the contract, although it is used only internally\n * all values are flattened when accessed anyway, so there is no need to call this methiod\n */\n flatMap<R>(fn?: (data: T) => R): Optional<any> {\n let val = super.flatMap(fn);\n if (!(val instanceof Optional)) {\n return Optional.fromNullable(val.value);\n }\n\n return <Optional<any>>val.flatMap();\n }\n\n /*\n * elvis operation, take care, if you use this you lose typesafety and refactoring\n * capabilites, unfortunately typesceript does not allow to have its own elvis operator\n * this is some syntactic sugar however which is quite useful*/\n getIf<R>(...key: string[]): Optional<R> {\n\n let currentPos: Optional<any> = this;\n for (let cnt = 0; cnt < key.length; cnt++) {\n let currKey = this.keyVal(key[cnt]);\n let arrPos = this.arrayIndex(key[cnt]);\n\n if (currKey === \"\" && arrPos >= 0) {\n currentPos = this.getClass().fromNullable(!(currentPos.value instanceof Array) ? null : (currentPos.value.length < arrPos ? null : currentPos.value[arrPos]));\n if (currentPos.isAbsent()) {\n return currentPos;\n }\n continue;\n } else if (currKey && arrPos >= 0) {\n if (currentPos.getIfPresent(currKey).isAbsent()) {\n return currentPos;\n }\n currentPos = (currentPos.getIfPresent(currKey).value instanceof Array) ? this.getClass().fromNullable(currentPos.getIfPresent(currKey).value[arrPos]) : this.getClass().absent;\n if (currentPos.isAbsent()) {\n return currentPos;\n }\n continue;\n\n } else {\n currentPos = currentPos.getIfPresent(currKey);\n }\n if (currentPos.isAbsent()) {\n return currentPos;\n } else if (arrPos > -1) {\n currentPos = this.getClass().fromNullable(currentPos.value[arrPos]);\n }\n }\n let retVal = currentPos;\n\n return retVal;\n }\n\n /**\n * simple match, if the first order function call returns\n * true then there is a match, if the value is not present\n * it never matches\n *\n * @param fn the first order function performing the match\n */\n match(fn: (item: T) => boolean): boolean {\n if (this.isAbsent()) {\n return false\n }\n return fn(this.value);\n }\n\n /**\n * convenience function to flatmap the internal value\n * and replace it with a default in case of being absent\n *\n * @param defaultVal\n * @returns {Optional<any>}\n */\n get<R>(defaultVal: any = Optional.absent): Optional<R> {\n if (this.isAbsent()) {\n return this.getClass().fromNullable(defaultVal).flatMap();\n }\n\n return this.getClass().fromNullable(this.value).flatMap();\n }\n\n toJson(): string {\n return JSON.stringify(this.value);\n }\n\n /**\n * helper to override several implementations in a more fluent way\n * by having a getClass operation we can avoid direct calls into the constructor or\n * static methods and do not have to implement several methods which rely on the type\n * of \"this\"\n * @returns {Monadish.Optional}\n */\n protected getClass(): any {\n return Optional;\n }\n\n /*helper method for getIf with array access aka <name>[<indexPos>]*/\n protected arrayIndex(key: string): number {\n let start = key.indexOf(\"[\");\n let end = key.indexOf(\"]\");\n if (start >= 0 && end > 0 && start < end) {\n return parseInt(key.substring(start + 1, end));\n } else {\n return -1;\n }\n }\n\n /*helper method for getIf with array access aka <name>[<indexPos>]*/\n protected keyVal(key: string): string {\n let start = key.indexOf(\"[\");\n\n if (start >= 0) {\n return key.substring(0, start);\n } else {\n return key;\n }\n }\n\n /**\n * additional syntactic sugar which is not part of the usual optional implementation\n * but makes life easier, if you want to sacrifice typesafety and refactoring\n * capabilities in typescript\n */\n getIfPresent<R>(key: string): Optional<R> {\n if (this.isAbsent()) {\n return this.getClass().absent;\n }\n return this.getClass().fromNullable(this.value[key]).flatMap();\n }\n\n /**\n * elvis like typesafe functional save resolver\n * a typesafe option for getIfPresent\n *\n * usage myOptional.resolve(value => value.subAttr.subAttr2).orElseLazy(....)\n * if this is resolvable without any errors an Optional with the value is returned\n * if not, then an Optional absent is returned, also if you return Optional absent\n * it is flatmapped into absent\n *\n * @param resolver the resolver function, can throw any arbitrary errors, int the error case\n * the resolution goes towards absent\n */\n resolve<V>(resolver: (item: T) => V): Optional<V> {\n if (this.isAbsent()) {\n return Optional.absent;\n }\n try {\n return Optional.fromNullable(resolver(this.value))\n } catch (e) {\n return Optional.absent;\n }\n }\n\n}\n\n// --------------------- From here onwards we break out the sideffects free limits ------------\n\n/**\n * ValueEmbedder is the writeable version\n * of optional, it basically is a wrappber\n * around a construct which has a state\n * and can be written to.\n *\n * For the readonly version see Optional\n */\nexport class ValueEmbedder<T> extends Optional<T> implements IValueHolder<T> {\n\n /*default value for absent*/\n static absent = ValueEmbedder.fromNullable(null);\n\n protected key: string;\n\n constructor(rootElem: any, valueKey: string = \"value\") {\n super(rootElem);\n\n this.key = valueKey;\n }\n\n get value(): T {\n return this._value ? <T>this._value[this.key] : null;\n }\n\n set value(newVal: T) {\n if (!this._value) {\n return;\n }\n this._value[this.key] = newVal\n }\n\n orElse(elseValue: any): Optional<any> {\n let alternative = {};\n alternative[this.key] = elseValue;\n return this.isPresent() ? this : new ValueEmbedder(alternative, this.key);\n }\n\n orElseLazy(func: () => any): Optional<any> {\n if (this.isPresent()) {\n return this;\n } else {\n let alternative = {};\n alternative[this.key] = func();\n return new ValueEmbedder(alternative, this.key);\n }\n }\n\n /**\n * helper to override several implementations in a more fluent way\n * by having a getClass operation we can avoid direct calls into the constructor or\n * static methods and do not have to implement several methods which rely on the type\n * of \"this\"\n * @returns {Monadish.Optional}\n */\n protected getClass(): any {\n return ValueEmbedder;\n }\n\n static fromNullable<T>(value?: any, valueKey: string = \"value\"): ValueEmbedder<T> {\n return new ValueEmbedder(value, valueKey);\n }\n\n}\n\n/**\n * specialized value embedder\n * for our Configuration\n */\nclass ConfigEntry<T> extends ValueEmbedder<T> {\n\n /*default value for absent*/\n static absent = ConfigEntry.fromNullable(null);\n\n /**\n * arrayed value positions\n */\n arrPos: number;\n\n constructor(rootElem: any, key: any, arrPos?: number) {\n super(rootElem, key);\n\n this.arrPos = arrPos ?? -1;\n }\n\n get value() {\n if (this.key == \"\" && this.arrPos >= 0) {\n return this._value[this.arrPos];\n } else if (this.key && this.arrPos >= 0) {\n return this._value[this.key][this.arrPos];\n }\n return this._value[this.key];\n }\n\n set value(val: T) {\n if (this.key == \"\" && this.arrPos >= 0) {\n this._value[this.arrPos] = val;\n return;\n } else if (this.key && this.arrPos >= 0) {\n this._value[this.key][this.arrPos] = val;\n return;\n }\n this._value[this.key] = val;\n }\n}\n\n/**\n * Config, basically an optional wrapper for a json structure\n * (not sideeffect free, since we can alter the internal config state\n * without generating a new config), not sure if we should make it sideffect free\n * since this would swallow a lot of performane and ram\n */\nexport class Config extends Optional<any> {\n constructor(root: any) {\n super(root);\n }\n\n get shallowCopy(): Config {\n return new Config(Stream.ofAssoc(this.value).collect(new AssocArrayCollector()));\n }\n\n get deepCopy(): Config {\n return new Config(objAssign({}, this.value));\n }\n\n static fromNullable<T>(value?: any): Config {\n return new Config(value);\n }\n\n /**\n * simple merge for the root configs\n */\n shallowMerge(other: Config, overwrite = true, withAppend = false) {\n for (let key in other.value) {\n if (overwrite || !(key in this.value)) {\n if (!withAppend) {\n this.assign(key).value = other.getIf(key).value;\n } else {\n if (Array.isArray(other.getIf(key).value)) {\n Stream.of(...other.getIf(key).value).each(item => this.append(key).value = item);\n } else {\n this.append(key).value = other.getIf(key).value;\n }\n }\n }\n }\n }\n\n /**\n * assigns a single value as array, or appends it\n * to an existing value mapping a single value to array\n *\n *\n * usage myConfig.append(\"foobaz\").value = \"newValue\"\n * myConfig.append(\"foobaz\").value = \"newValue2\"\n *\n * resulting in myConfig.foobaz == [\"newValue, newValue2\"]\n *\n * @param keys\n */\n append(...keys): IValueHolder<any> {\n let noKeys = keys.length < 1;\n if (noKeys) {\n return;\n }\n\n let lastKey = keys[keys.length - 1];\n let currKey, finalKey = this.keyVal(lastKey);\n\n let pathExists = this.getIf(...keys).isPresent();\n this.buildPath(keys);\n\n let finalKeyArrPos = this.arrayIndex(lastKey);\n if (finalKeyArrPos > -1) {\n throw Error(\"Append only possible on non array properties, use assign on indexed data\");\n }\n let value = <any>this.getIf(...keys).value;\n if (!Array.isArray(value)) {\n value = this.assign(...keys).value = [value];\n }\n if (pathExists) {\n value.push({});\n }\n finalKeyArrPos = value.length - 1;\n\n let retVal = new ConfigEntry(keys.length == 1 ? this.value : this.getIf.apply(this, keys.slice(0, keys.length - 1)).value,\n lastKey, finalKeyArrPos\n );\n\n return retVal;\n }\n\n appendIf(condition: boolean, ...keys): IValueHolder<any> {\n if (!condition) {\n return {value: null};\n }\n return this.append(...keys);\n }\n\n assign(...keys): IValueHolder<any> {\n if (keys.length < 1) {\n return;\n }\n\n this.buildPath(keys);\n\n let currKey = this.keyVal(keys[keys.length - 1]);\n let arrPos = this.arrayIndex(keys[keys.length - 1]);\n let retVal = new ConfigEntry(keys.length == 1 ? this.value : this.getIf.apply(this, keys.slice(0, keys.length - 1)).value,\n currKey, arrPos\n );\n\n return retVal;\n }\n\n assignIf(condition: boolean, ...keys: Array<any>): IValueHolder<any> {\n return condition ? this.assign(...keys) : {value: null};\n }\n\n getIf(...keys: Array<string>): Config {\n return this.getClass().fromNullable(super.getIf.apply(this, keys).value);\n }\n\n get(defaultVal: any): Config {\n return this.getClass().fromNullable(super.get(defaultVal).value);\n }\n\n //empties the current config entry\n delete(key: string): Config {\n if (key in this.value) {\n delete this.value[key];\n }\n return this;\n }\n\n toJson(): any {\n return JSON.stringify(this.value);\n }\n\n protected getClass(): any {\n return Config;\n }\n\n private setVal(val: any) {\n this._value = val;\n }\n\n /**\n * builds the config path\n *\n * @param keys a sequential array of keys containing either a key name or an array reference name[<index>]\n */\n private buildPath(keys: Array<any>): Config {\n let val = this;\n let parentVal = this.getClass().fromNullable(null);\n let parentPos = -1;\n let alloc = function (arr: Array<any>, length: number) {\n let length1 = arr.length;\n let length2 = length1 + length;\n for (let cnt = length1; cnt < length2; cnt++) {\n arr.push({});\n }\n };\n\n for (let cnt = 0; cnt < keys.length; cnt++) {\n let currKey = this.keyVal(keys[cnt]);\n let arrPos = this.arrayIndex(keys[cnt]);\n\n if (currKey === \"\" && arrPos >= 0) {\n\n val.setVal((val.value instanceof Array) ? val.value : []);\n alloc(val.value, arrPos + 1);\n if (parentPos >= 0) {\n parentVal.value[parentPos] = val.value;\n }\n parentVal = val;\n parentPos = arrPos;\n val = this.getClass().fromNullable(val.value[arrPos]);\n continue;\n }\n\n let tempVal = <Config>val.getIf(currKey);\n if (arrPos == -1) {\n if (tempVal.isAbsent()) {\n tempVal = <Config>this.getClass().fromNullable(val.value[currKey] = {});\n } else {\n val = <any>tempVal;\n }\n } else {\n let arr = (tempVal.value instanceof Array) ? tempVal.value : [];\n alloc(arr, arrPos + 1);\n val.value[currKey] = arr;\n tempVal = this.getClass().fromNullable(arr[arrPos]);\n }\n parentVal = val;\n parentPos = arrPos;\n val = <any>tempVal;\n }\n\n return this;\n }\n}\n\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Optional} from \"./Monad\";\n\n/**\n * Lang helpers crossported from the apache myfaces project\n */\nexport module Lang {\n \n\n //should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those\n /**\n * helper function to savely resolve anything\n * this is not an elvis operator, it resolves\n * a value without exception in a tree and if\n * it is not resolvable then an optional of\n * a default value is restored or Optional.empty\n * if none is given\n *\n * usage\n * <code>\n * let var: Optiona<string> = saveResolve(() => a.b.c.d.e, \"foobaz\")\n * </code>\n *\n * @param resolverProducer a lambda which can produce the value\n * @param defaultValue an optional default value if the producer failes to produce anything\n * @returns an Optional of the produced value\n */\n export function saveResolve<T>(resolverProducer: () => T, defaultValue: T = null): Optional<T> {\n try {\n let result = resolverProducer();\n return Optional.fromNullable(result ?? defaultValue);\n } catch (e) {\n return Optional.absent;\n }\n }\n\n export function saveResolveLazy<T>(resolverProducer: () => T, defaultValue: () => T = null): Optional<T> {\n try {\n let result = resolverProducer();\n return Optional.fromNullable(result ?? defaultValue());\n } catch (e) {\n return Optional.absent;\n }\n }\n\n /**\n * String to array function performs a string to array transformation\n * @param {String} it the string which has to be changed into an array\n * @param {RegExp} splitter our splitter reglar expression\n * @return a trimmed array of the splitted string\n */\n export function strToArray(it: string, splitter: string | RegExp = /\\./gi): Array<string> {\n\n let ret = [];\n it.split(splitter).forEach((element => {\n ret.push(trim(element));\n }));\n return ret;\n }\n\n /**\n * hyperfast trim\n * http://blog.stevenlevithan.com/archives/faster-trim-javascript\n * crossported from dojo\n */\n export function trim(str: string): string {\n str = str.replace(/^\\s\\s*/, '');\n let ws = /\\s/, i = str.length;\n\n while (ws.test(str.charAt(--i))) {\n //do nothing\n }\n return str.slice(0, i + 1);\n }\n\n /**\n * generic object arrays like dom definitions to array conversion method which\n * transforms any object to something array like\n * @param obj\n * @param offset\n * @param pack\n * @returns an array converted from the object\n */\n export function objToArray<T>(obj: any, offset: number = 0, pack: Array<T> = []): Array<T> {\n if ((obj ?? \"__undefined__\") == \"__undefined__\") {\n return pack ?? null;\n }\n //since offset is numeric we cannot use the shortcut due to 0 being false\n //special condition array delivered no offset no pack\n if ((<any>obj) instanceof Array && !offset && !pack) return obj;\n\n return pack.concat(Array.prototype.slice.call(obj, offset));\n }\n\n /**\n * equalsIgnoreCase, case insensitive comparison of two strings\n *\n * @param source\n * @param destination\n */\n export function equalsIgnoreCase(source?: string, destination?: string): boolean {\n let finalSource = source ?? \"___no_value__\";\n let finalDest = destination ?? \"___no_value__\";\n\n //in any other case we do a strong string comparison\n return finalSource.toLowerCase() === finalDest.toLowerCase();\n }\n\n /**\n * runtime type assertion\n *\n * @param probe the probe to be tested for a type\n * @param theType the type to be tested for\n */\n export function assertType(probe: any, theType: any): boolean {\n return isString(theType) ? typeof probe == theType : probe instanceof theType;\n }\n\n /**\n * Backported from dojo\n * a failsafe string determination method\n * (since in javascript String != \"\" typeof alone fails!)\n * @param it {|Object|} the object to be checked for being a string\n * @return true in case of being a string false otherwise\n */\n export function isString(it?: any): boolean {\n //\tsummary:\n //\t\tReturn true if it is a String\n return !!arguments.length && it != null && (typeof it == \"string\" || it instanceof String); // Boolean\n }\n\n export function isFunc(it: any): boolean {\n return it instanceof Function || typeof it === \"function\";\n }\n\n // code from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n // license https://creativecommons.org/licenses/by-sa/2.5/\n export function objAssign(target: any, ...theArgs: any) { // .length of function is 2\n if (target == null) { // TypeError if undefined or null\n throw new TypeError('Cannot convert undefined or null to object');\n }\n\n let to = Object(target);\n if((<any>Object).assign) {\n theArgs.forEach(item => (<any>Object).assign(to, item));\n return to;\n }\n\n theArgs.forEach(item => {\n let nextSource = item;\n if (nextSource != null) { // Skip over if undefined or null\n for (let nextKey in nextSource) {\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n to[nextKey] = nextSource[nextKey];\n }\n }\n }\n });\n return to;\n }\n}\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * todo replace singleton with module definition\n *\n */\n\nimport {Lang as LangBase} from \"../../ext/monadish/Lang\";\nimport {Messages} from \"../i18n/Messages\";\n// noinspection TypeScriptPreferShortImport\nimport {Config, Optional} from \"../../ext/monadish/Monad\";\n// noinspection TypeScriptPreferShortImport\nimport {DomQuery, DQ} from \"../../ext/monadish/DomQuery\";\nimport {Stream} from \"../../ext/monadish\";\nimport {EMPTY_STR, TAG_FORM} from \"../core/Const\";\nimport {getEventTarget} from \"../xhrCore/RequestDataResolver\";\n\nexport module ExtLang {\n\n let installedLocale: Messages;\n let nameSpace = \"impl/util/Lang/\";\n\n export function getLanguage(): string {\n //TODO global config override\n\n let language: string = (<any>navigator).languages?.[0] ?? navigator?.language;\n language = language.split(\"-\")[0];\n return language;\n }\n\n //should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those\n /**\n * helper function to savely resolve anything\n * this is not an elvis operator, it resolves\n * a value without exception in a tree and if\n * it is not resolvable then an optional of\n * a default value is restored or Optional.empty\n * if none is given\n *\n * usage\n * <code>\n * let var: Optional<string> = saveResolve(() => a.b.c.d.e, \"foobaz\")\n * </code>\n *\n * @param resolverProducer a lambda which can produce the value\n * @param defaultValue an optional default value if the producer failes to produce anything\n * @returns an Optional of the produced value\n */\n export function failSaveResolve<T>(resolverProducer: () => T, defaultValue: T = null): Optional<T> {\n return LangBase.saveResolve(resolverProducer, defaultValue);\n }\n\n /**\n * under some conditions it makes sense to swallow errors and return a default value in the error case\n * classical example the optional resolution of values in a chain (thankfully now covered by Typescript itself)\n * another example which we have in our system is that some operations fail only under test due to test framework\n * limitations while they cannot fail in the real world.\n *\n * @param resolverProducer a producer function which produces a value in the non error case\n * @param defaultValue the default value in case of a fail of the function\n */\n export function failSaveExecute<T>(resolverProducer: () => any, defaultValue: T = null): void {\n LangBase.saveResolve(resolverProducer, defaultValue);\n }\n\n /**\n * returns a given localized message upon a given key\n * basic java log like templating functionality is included\n *\n * @param {String} key the key for the message\n * @param {String} defaultMessage optional default message if none was found\n *\n * Additionally you can pass additional arguments, which are used\n * in the same way java log templates use the params\n *\n * @param templateParams the param list to be filled in\n */\n export function getMessage(key: string, defaultMessage?: string, ...templateParams: Array<string>): string {\n installedLocale = installedLocale ?? new Messages();\n\n let msg = installedLocale[key] ?? defaultMessage ?? key + \" - undefined message\";\n\n Stream.of(...templateParams).each((param, cnt) => {\n msg = msg.replace(new RegExp([\"\\\\{\", cnt, \"\\\\}\"].join(EMPTY_STR), \"g\"), param);\n });\n\n return msg;\n }\n\n /**\n * transforms a key value pair into a string\n * @param key the key\n * @param val the value\n * @param delimiter the delimiter\n */\n export function keyValToStr(key: string, val: string, delimiter: string = \"\\n\") {\n return [key, val].join(delimiter);\n }\n\n /**\n * creates an exeption with additional internal parameters\n * for extra information\n *\n * @param error\n * @param {String} title the exception title\n * @param {String} name the exception name\n * @param {String} callerCls the caller class\n * @param {String} callFunc the caller function\n * @param {String} message the message for the exception\n */\n export function makeException(error: Error, title: string, name: string, callerCls: string, callFunc: string, message: string): Error {\n\n return new Error(message + (callerCls ?? nameSpace) + callFunc ?? (EMPTY_STR + (<any>arguments).caller.toString()));\n\n }\n\n /**\n * fetches a global config entry\n * @param {String} configName the name of the configuration entry\n * @param {Object} defaultValue\n *\n * @return either the config entry or if none is given the default value\n */\n export function getGlobalConfig(configName: string, defaultValue: any): any {\n /**\n * note we could use exists but this is an heavy operation, since the config name usually\n * given this function here is called very often\n * is a single entry without . in between we can do the lighter shortcut\n */\n return (<any>window)?.myfaces?.config?.[configName] ?? defaultValue;\n }\n\n /**\n * fetches the form in an fuzzy manner depending\n * on an element or event target.\n *\n * The idea is that according to the jsf spec\n * the enclosing form of the issuing element needs to be fetched.\n *\n * This is fine, but since then html5 came into the picture with the form attribute the element\n * can be anywhere referencing its parent form.\n *\n * Also theoretically you can have the case of an issuing element enclosing a set of forms\n * (not really often used, but theoretically it could be input button allows to embed html for instance)\n *\n * So the idea is not to limit the issuing form determination to the spec case\n * but also cover the theoretical and html5 corner case.\n *\n * @param elem\n * @param event\n */\n export function getForm(elem: Element, event ?: Event): DQ | never {\n\n let queryElem = new DQ(elem);\n let eventTarget = new DQ(getEventTarget(event));\n\n if (queryElem.isTag(TAG_FORM)) {\n return queryElem;\n }\n\n //html 5 for handling\n if (queryElem.attr(TAG_FORM).isPresent()) {\n let formId = queryElem.attr(TAG_FORM).value;\n let foundForm = DQ.byId(formId, true);\n if (foundForm.isPresent()) {\n return foundForm;\n }\n }\n\n let form = queryElem.parents(TAG_FORM)\n .orElseLazy(() => queryElem.byTagName(TAG_FORM, true))\n .orElseLazy(() => eventTarget.parents(TAG_FORM))\n .orElseLazy(() => eventTarget.byTagName(TAG_FORM))\n .first();\n\n assertFormExists(form);\n\n return form;\n }\n\n /**\n * gets the local or global options with local ones having higher priority\n * if no local or global one was found then the default value is given back\n *\n * @param {String} configName the name of the configuration entry\n * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely\n *\n * @param {Object} defaultValue\n *\n * @return either the config entry or if none is given the default value\n */\n export function getLocalOrGlobalConfig(localOptions: Config, configName: string, defaultValue: any): any {\n return localOptions.value?.myfaces?.config?.[configName] ??\n (<any>window)?.myfaces?.config?.[configName] ??\n defaultValue;\n }\n\n /**\n * assert that the form exists and throw an exception in the case it does not\n * (TODO move this into the assertions)\n *\n * @param form the form to check for\n */\n function assertFormExists(form: DomQuery): void | never {\n if (form.isAbsent()) {\n throw makeException(new Error(), null, null, \"Impl\", \"getForm\", getMessage(\"ERR_FORM\"));\n }\n }\n\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Config, Optional, ValueEmbedder} from \"./Monad\";\nimport {XMLQuery} from \"./XmlQuery\";\nimport {IStream, LazyStream, Stream} from \"./Stream\";\nimport {ArrayCollector, ICollector, IStreamDataSource} from \"./SourcesCollectors\";\nimport {Lang} from \"./Lang\";\nimport trim = Lang.trim;\nimport objToArray = Lang.objToArray;\nimport isString = Lang.isString;\nimport equalsIgnoreCase = Lang.equalsIgnoreCase;\n\n\n/**\n *\n * // - submit checkboxes and radio inputs only if checked\n if ((tagName != \"select\" && elemType != \"button\"\n && elemType != \"reset\" && elemType != \"submit\" && elemType != \"image\")\n && ((elemType != \"checkbox\" && elemType != \"radio\"\n */\n\nenum Submittables {\n SELECT = \"select\",\n BUTTON = \"button\",\n SUBMIT = \"submit\",\n RESET = \"reset\",\n IMAGE = \"image\",\n RADIO = \"radio\",\n CHECKBOX = \"checkbox\"\n\n}\n\n// @ts-ignore supression needed here due to fromnullable\nexport class ElementAttribute extends ValueEmbedder<string> {\n\n constructor(private element: DomQuery, private name: string, private defaultVal: string = null) {\n super(element, name);\n }\n\n get value(): string {\n let val: Element[] = this.element.get(0).orElse(...[]).values;\n if (!val.length) {\n return this.defaultVal;\n }\n return val[0].getAttribute(this.name);\n }\n\n set value(value: string) {\n let val: Element[] = this.element.get(0).orElse(...[]).values;\n for (let cnt = 0; cnt < val.length; cnt++) {\n val[cnt].setAttribute(this.name, value);\n }\n val[0].setAttribute(this.name, value);\n }\n\n protected getClass(): any {\n return ElementAttribute;\n }\n\n static fromNullable(value?: any, valueKey: string = \"value\"): ElementAttribute {\n return new ElementAttribute(value, valueKey);\n }\n\n}\n\n/**\n * small helper for the specialized jsf case\n * @param src\n * @constructor\n */\nconst DEFAULT_JSF_WHITELIST = (src: string) => {\n return (src.indexOf(\"ln=scripts\") == -1 &&\n src.indexOf(\"ln=javax.faces\") == -1) ||\n (src.indexOf(\"/jsf.js\") == -1 &&\n src.indexOf(\"/jsf-uncompressed.js\") == -1);\n};\n\ninterface IDomQuery {\n /**\n * reads the first element if it exists and returns an optional\n */\n readonly value: Optional<Element>;\n /**\n * All elements as array\n */\n readonly values: Element[];\n /**\n * returns the id as settable value (See also ValueEmbedder)\n */\n readonly id: ValueEmbedder<string>;\n /**\n * returns the length of embedded nodes (top level)\n */\n readonly length: number;\n /**\n * the tag name of the first element\n */\n readonly tagName: Optional<string>;\n /**\n * the node name of the first element\n */\n readonly nodeName: Optional<string>;\n /**\n * the type of the first element\n */\n readonly type: Optional<string>;\n /**\n * The name as changeable value\n */\n readonly name: ValueEmbedder<string>;\n /**\n * The the value in case of inputs as changeable value\n */\n readonly inputValue: ValueEmbedder<string | boolean>;\n /**\n * the underlying form elements as domquery object\n */\n readonly elements: DomQuery;\n /**\n * settable flag for disabled\n */\n disabled: boolean;\n /**\n * The child nodes of this node collection as readonly attribute\n */\n readonly childNodes: DomQuery;\n /**\n * an early stream representation for this DomQuery\n */\n readonly stream: Stream<DomQuery>;\n /**\n * lazy stream representation for this DomQuery\n */\n readonly lazyStream: LazyStream<DomQuery>;\n /**\n * transform this node collection to an array\n */\n readonly asArray: Array<DomQuery>;\n\n /**\n * returns true if the elements have the tag *tagName* as tag embedded (highest level)\n * @param tagName\n */\n isTag(tagName: string): boolean;\n\n /**\n * returns the nth element as domquery\n * from the internal elements\n * note if you try to reach a non existing element position\n * you will get back an absent entry\n *\n * @param index the nth index\n */\n get(index: number): DomQuery;\n\n /**\n * returns the nth element as optional of an Element object\n * @param index the number from the index\n * @param defaults the default value if the index is overrun default Optional.absent\n */\n getAsElem(index: number, defaults: Optional<any>): Optional<Element>;\n\n /**\n * returns the value array< of all elements\n */\n allElems(): Array<Element>;\n\n /**\n * absent no values reached?\n */\n isAbsent(): boolean;\n\n /**\n * should make the code clearer\n * note if you pass a function\n * this refers to the active dopmquery object\n */\n isPresent(presentRunnable ?: (elem ?: DomQuery) => void): boolean;\n\n /**\n * should make the code clearer\n * note if you pass a function\n * this refers to the active dopmquery object\n *\n *\n * @param presentRunnable\n */\n ifPresentLazy(presentRunnable: (elem ?: DomQuery) => void): DomQuery;\n\n /**\n * remove all affected nodes from this query object from the dom tree\n */\n delete(): void;\n\n /**\n * query selector all on the existing dom query object\n *\n * @param selector the standard selector\n * @return a DomQuery with the results\n */\n querySelectorAll(selector): DomQuery;\n\n /**\n * core byId method\n * @param id the id to search for\n * @param includeRoot also match the root element?\n */\n byId(id: string, includeRoot?: boolean): DomQuery;\n\n /**\n * same as byId just for the tag name\n * @param tagName\n * @param includeRoot\n */\n byTagName(tagName: string, includeRoot ?: boolean): DomQuery;\n\n /**\n * attr accessor, usage myQuery.attr(\"class\").value = \"bla\"\n * or let value myQuery.attr(\"class\").value\n * @param attr the attribute to set\n * @param defaultValue the default value in case nothing is presented (defaults to null)\n */\n attr(attr: string, defaultValue: string): ElementAttribute;\n\n /**\n * hasclass, checks for an existing class in the class attributes\n *\n * @param clazz the class to search for\n */\n hasClass(clazz: string): boolean;\n\n /**\n * appends a class string if not already in the element(s)\n *\n * @param clazz the style class to append\n */\n addClass(clazz: string): DomQuery;\n\n /**\n * remove the style class if in the class definitions\n *\n * @param clazz\n */\n removeClass(clazz: string): DomQuery;\n\n /**\n * checks whether we have a multipart element in our children\n */\n isMultipartCandidate(): boolean;\n\n /**\n * innerHtml equivalkent\n * equivalent to jqueries html\n * as setter the html is set and the\n * DomQuery is given back\n * as getter the html string is returned\n *\n * @param inval\n */\n html(inval?: string): DomQuery | Optional<string>;\n\n /**\n * dispatch event on all children\n * just a delegated dispatchevent from the standard\n * dom working on all queried elements in the monad level\n *\n * @param evt the event to be dispatched\n */\n dispatchEvent(evt: Event): DomQuery;\n\n /**\n * easy node traversal, you can pass\n * a set of node selectors which are joined as direct childs\n *\n * not the rootnodes are not in the getIf, those are always the child nodes\n *\n * @param nodeSelector\n */\n getIf(...nodeSelector: Array<string>): DomQuery;\n\n /**\n * iterate over each element and perform something on the element\n * (Dom element is passed instead of DomQuery)\n * @param func\n */\n eachElem(func: (item: Element, cnt?: number) => any): DomQuery;\n\n /**\n * perform an operation on the first element\n * returns a DomQuery on the first element only\n * @param func\n */\n firstElem(func: (item: Element, cnt?: number) => any): DomQuery;\n\n /**\n * same as eachElem, but a DomQuery object is passed down\n *\n * @param func\n */\n each(func: (item: DomQuery, cnt?: number) => any): DomQuery;\n\n /**\n * returns a new dom query containing only the first element max\n *\n * @param func a an optional callback function to perform an operation on the first element\n */\n first(func: (item: DomQuery, cnt?: number) => any): DomQuery;\n\n /**\n * filter function which filters a subset\n *\n * @param func\n */\n filter(func: (item: DomQuery) => boolean): DomQuery;\n\n /**\n * global eval head appendix method\n * no other methods are supported anymore\n * @param code the code to be evaled\n * @param nonce optional nonce key for higher security\n */\n globalEval(code: string, nonce ?: string): DomQuery;\n\n /**\n * detaches a set of nodes from their parent elements\n * in a browser independend manner\n * @param {Object} items the items which need to be detached\n * @return {Array} an array of nodes with the detached dom nodes\n */\n detach(): DomQuery;\n\n /**\n * appends the current set of elements\n * to the element or first element passed via elem\n * @param elem\n */\n appendTo(elem: DomQuery): void;\n\n /**\n * loads and evals a script from a source uri\n *\n * @param src the source to be loaded and evaled\n * @param defer in miliseconds execution default (0 == no defer)\n * @param charSet\n */\n loadScriptEval(src: string, defer: number, charSet: string): void;\n\n /**\n * insert toInsert after the current element\n *\n * @param toInsert an array of DomQuery objects\n */\n insertAfter(...toInsert: Array<DomQuery>): DomQuery;\n\n /**\n * inserts the elements before the current element\n *\n * @param toInsert\n */\n insertBefore(...toInsert: Array<DomQuery>): DomQuery;\n\n /**\n * in case the domquery is pointing to nothing the else value is taken into consideration\n * als alternative\n *\n * @param elseValue the else value\n */\n orElse(...elseValue: any): DomQuery;\n\n /**\n * the same with lazy evaluation for cases where getting the else value\n * is a heavy operation\n *\n * @param func the else provider function\n */\n orElseLazy(func: () => any): DomQuery;\n\n /**\n * all parents with TagName\n * @param tagName\n */\n parents(tagName: string): DomQuery;\n\n /**\n * copy all attributes of sourceItem to this DomQuery items\n *\n * @param sourceItem the source item to copy over (can be another domquery or a parsed XML Query item)\n */\n copyAttrs(sourceItem: DomQuery | XMLQuery): DomQuery;\n\n /**\n * outerhtml convenience method\n * browsers only support innerHTML but\n * for instance for your jsf.js we have a full\n * replace pattern which needs outerHTML processing\n *\n * @param markup\n * @param runEmbeddedScripts\n * @param runEmbeddedCss\n */\n outerHTML(markup: string, runEmbeddedScripts ?: boolean, runEmbeddedCss ?: boolean): DomQuery;\n\n /**\n * Run through the given nodes in the DomQuery execute the inline scripts\n * @param whilteListed: optional whitelist function which can filter out script tags which are not processed\n * defaults to the standard jsf.js exclusion (we use this code for myfaces)\n */\n runScripts(whilteListed: (val: string) => boolean): DomQuery;\n\n /**\n * runs the embedded css\n */\n runCss(): DomQuery;\n\n /**\n * fires a click event on the underlying dom elements\n */\n click(): DomQuery;\n\n /**\n * adds an event listener\n *\n * @param type\n * @param listener\n * @param options\n */\n addEventListener(type: string, listener: (evt: Event) => void, options?: boolean | EventListenerOptions): DomQuery;\n\n /**\n * removes an event listener\n *\n * @param type\n * @param listener\n * @param options\n */\n removeEventListener(type: string, listener: (evt: Event) => void, options?: boolean | EventListenerOptions): DomQuery;\n\n /**\n * fires an event\n */\n fireEvent(eventName: string): void;\n\n /*\n * pushes in optionally a new textContent, and/or returns the current text content\n */\n textContent(joinstr?: string): string;\n\n /*\n * pushes in optionally a new innerText, and/or returns the current innerText\n */\n innerText(joinstr?: string): string;\n\n /**\n * encodes all input elements properly into respective\n * config entries, this can be used\n * for legacy systems, for newer usecases, use the\n * HTML5 Form class which all newer browsers provide\n *\n * @param toMerge optional config which can be merged in\n * @return a copy pf\n */\n encodeFormElement(toMerge): Config;\n\n /**\n * fetches the subnodes from ... to..\n * @param from\n * @param to\n */\n subNodes(from: number, to?: number): DomQuery;\n\n\n /**\n * attach shadow elements\n * 1:1 mapping from attach shadow\n *\n * @param modeParams\n */\n attachShadow(modeParams: { [key: string]: string }): DomQuery\n}\n\n/**\n * Monadic DomNode representation, ala jquery\n * This is a thin wrapper over querySelectorAll\n * to get slim monadic support\n * to reduce implementation code on the users side.\n * This is vital for frameworks which want to rely on\n * plain dom but still do not want to lose\n * the reduced code footprint of querying dom trees and traversing\n * by using functional patterns.\n *\n * Also a few convenience methods are added to reduce\n * the code footprint of standard dom processing\n * operations like eval\n *\n * TODO add jquery fallback support, since it is supported\n * in most older systems\n * Note parts of this code still stem from the Dom.js I have written 10 years\n * ago, those parts look a little bit ancient and will be replaced over time.\n *\n */\nexport class DomQuery implements IDomQuery, IStreamDataSource<DomQuery> {\n\n static absent = new DomQuery();\n\n private rootNode: Array<Element> = [];\n\n pos = -1;\n\n constructor(...rootNode: Array<Element | ShadowRoot | DomQuery | Document | Array<any> | string>) {\n\n if (Optional.fromNullable(rootNode).isAbsent() || !rootNode.length) {\n return;\n } else {\n //we need to flatten out the arrays\n\n for (let cnt = 0; cnt < rootNode.length; cnt++) {\n if (isString(rootNode[cnt])) {\n let foundElement = DomQuery.querySelectorAll(<string>rootNode[cnt]);\n if (!foundElement.isAbsent()) {\n rootNode.push(...foundElement.values)\n }\n } else if (rootNode[cnt] instanceof DomQuery) {\n this.rootNode.push(...(<any>rootNode[cnt]).values);\n } else {\n this.rootNode.push(<any>rootNode[cnt]);\n }\n }\n }\n }\n\n /**\n * returns the first element\n */\n get value(): Optional<Element> {\n return this.getAsElem(0);\n }\n\n get values(): Element[] {\n return this.allElems();\n }\n\n /**\n * returns the id of the first element\n */\n get id(): ValueEmbedder<string> {\n return new ElementAttribute(this.get(0), \"id\");\n }\n\n /**\n * length of the entire query set\n */\n get length(): number {\n return this.rootNode.length\n }\n\n /**\n * convenience method for tagName\n */\n get tagName(): Optional<string> {\n return <Optional<string>>this.getAsElem(0).getIf(\"tagName\");\n }\n\n /**\n * convenience method for nodeName\n */\n get nodeName(): Optional<string> {\n return <Optional<string>>this.getAsElem(0).getIf(\"nodeName\");\n }\n\n isTag(tagName: string): boolean {\n return !this.isAbsent()\n && (this.nodeName.orElse(\"__none___\")\n .value.toLowerCase() == tagName.toLowerCase()\n || this.tagName.orElse(\"__none___\")\n .value.toLowerCase() == tagName.toLowerCase()\n )\n }\n\n /**\n * convenience property for type\n *\n * returns null in case of no type existing otherwise\n * the type of the first element\n */\n get type(): Optional<string> {\n return this.getAsElem(0).getIf(\"type\");\n }\n\n /**\n * convenience property for name\n *\n * returns null in case of no type existing otherwise\n * the name of the first element\n */\n get name(): ValueEmbedder<string> {\n return new ValueEmbedder(this.getAsElem(0).value, \"name\");\n }\n\n /**\n * convenience property for value\n *\n * returns null in case of no type existing otherwise\n * the value of the first element\n */\n get inputValue(): ValueEmbedder<string | boolean> {\n if (this.getAsElem(0).getIf(\"value\").isPresent()) {\n return new ValueEmbedder<string>(this.getAsElem(0).value);\n } else {\n return <any>ValueEmbedder.absent;\n }\n }\n\n get checked(): boolean {\n return Stream.of(...this.values).allMatch(el => !!(<any>el).checked);\n }\n\n set checked(newChecked: boolean) {\n this.eachElem(el => (<any>el).checked = newChecked);\n }\n\n get elements(): DomQuery {\n //a simple querySelectorAll should suffice\n return this.querySelectorAll(\"input, checkbox, select, textarea, fieldset\");\n }\n\n get deepElements(): DomQuery {\n let elemStr = \"input, select, textarea, checkbox, fieldset\";\n return this.querySelectorAllDeep(elemStr);\n }\n\n /**\n * a deep search which treats the single isolated shadow doms\n * separately and runs the query on earch shadow dom\n * @param queryStr\n */\n querySelectorAllDeep(queryStr: string): DomQuery {\n let found: Array<DomQuery> = [];\n let queryRes = this.querySelectorAll(queryStr);\n if(queryRes.length) {\n found.push(queryRes);\n }\n let shadowRoots = this.querySelectorAll(\"*\").shadowRoot;\n if(shadowRoots.length) {\n let shadowRes = shadowRoots.querySelectorAllDeep(queryStr);\n if(shadowRes.length) {\n found.push(shadowRes);\n }\n }\n return new DomQuery(...found);\n }\n\n\n\n /**\n * todo align this api with the rest of the apis\n */\n get disabled(): boolean {\n return this.attr(\"disabled\").isPresent();\n }\n\n set disabled(disabled: boolean) {\n // this.attr(\"disabled\").value = disabled + \"\";\n if (!disabled) {\n this.removeAttribute(\"disabled\");\n } else {\n this.attr(\"disabled\").value = \"disabled\";\n }\n\n }\n\n removeAttribute(name: string) {\n this.eachElem(item => item.removeAttribute(name));\n }\n\n get childNodes(): DomQuery {\n let childNodeArr: Array<Element> = [];\n this.eachElem((item: Element) => {\n childNodeArr = childNodeArr.concat(objToArray(item.childNodes));\n });\n return new DomQuery(...childNodeArr);\n }\n\n /**\n * binding into stream\n */\n get stream(): Stream<DomQuery> {\n return new Stream<DomQuery>(...this.asArray);\n }\n\n /**\n * fetches a lazy stream representation\n * lazy should be applied if you have some filters etc\n * in between, this can reduce the number of post filter operations\n * and ram usage\n * significantly because the operations are done lazily and stop\n * once they hit a dead end.\n */\n get lazyStream(): LazyStream<DomQuery> {\n return LazyStream.ofStreamDataSource(this);\n }\n\n get asArray(): Array<DomQuery> {\n //filter not supported by IE11\n return [].concat(LazyStream.of(...this.rootNode).filter(item => item != null)\n .map(item => DomQuery.byId(item)).collect(new ArrayCollector()));\n }\n\n get asNodeArray(): Array<DomQuery> {\n return [].concat(Stream.of(this.rootNode).filter(item => item != null).collect(new ArrayCollector()));\n }\n\n /**\n * easy query selector all producer\n *\n * @param selector the selector\n * @returns a results dom query object\n */\n static querySelectorAll(selector: string): DomQuery {\n if (selector.indexOf(\"/shadow/\") != -1) {\n return new DomQuery(document)._querySelectorAllDeep(selector);\n } else {\n return new DomQuery(document)._querySelectorAll(selector);\n }\n\n }\n\n /**\n * byId producer\n *\n * @param selector id\n * @return a DomQuery containing the found elements\n */\n static byId(selector: string | DomQuery | Element, deep = false): DomQuery {\n if (isString(selector)) {\n return (!deep) ? new DomQuery(document).byId(<string>selector) : new DomQuery(document).byIdDeep(<string>selector);\n } else {\n return new DomQuery(<any>selector);\n }\n }\n\n /**\n * byTagName producer\n *\n * @param selector name\n * @return a DomQuery containing the found elements\n */\n static byTagName(selector: string | DomQuery | Element): DomQuery {\n if (isString(selector)) {\n return new DomQuery(document).byTagName(<string>selector);\n } else {\n return new DomQuery(<any>selector);\n }\n }\n\n static globalEval(code: string, nonce?: string): DomQuery {\n return new DomQuery(document).globalEval(code, nonce);\n }\n\n /**\n * builds the ie nodes properly in a placeholder\n * and bypasses a non script insert bug that way\n * @param markup the marku code\n */\n static fromMarkup(markup: string): DomQuery {\n\n //https://developer.mozilla.org/de/docs/Web/API/DOMParser license creative commons\n const doc = document.implementation.createHTMLDocument(\"\");\n markup = trim(markup);\n let lowerMarkup = markup.toLowerCase();\n if (lowerMarkup.indexOf('<!doctype') != -1 ||\n lowerMarkup.indexOf('<html') != -1 ||\n lowerMarkup.indexOf('<head') != -1 || //TODO proper regexps here to avoid embedded tags with same element names to be triggered\n lowerMarkup.indexOf('<body') != -1) {\n doc.documentElement.innerHTML = markup;\n return new DomQuery(doc.documentElement);\n } else {\n let startsWithTag = function (str: string, tagName: string) {\n let tag1 = [\"<\", tagName, \">\"].join(\"\");\n let tag2 = [\"<\", tagName, \" \"].join(\"\");\n return (str.indexOf(tag1) == 0) || (str.indexOf(tag2) == 0);\n };\n\n let dummyPlaceHolder = new DomQuery(document.createElement(\"div\"));\n\n //table needs special treatment due to the browsers auto creation\n if (startsWithTag(lowerMarkup, \"thead\") || startsWithTag(lowerMarkup, \"tbody\")) {\n dummyPlaceHolder.html(`<table>${markup}</table>`);\n return dummyPlaceHolder.querySelectorAll(\"table\").get(0).childNodes.detach();\n } else if (startsWithTag(lowerMarkup, \"tfoot\")) {\n dummyPlaceHolder.html(`<table><thead></thead><tbody><tbody${markup}</table>`);\n return dummyPlaceHolder.querySelectorAll(\"table\").get(2).childNodes.detach();\n } else if (startsWithTag(lowerMarkup, \"tr\")) {\n dummyPlaceHolder.html(`<table><tbody>${markup}</tbody></table>`);\n return dummyPlaceHolder.querySelectorAll(\"tbody\").get(0).childNodes.detach();\n } else if (startsWithTag(lowerMarkup, \"td\")) {\n dummyPlaceHolder.html(`<table><tbody><tr>${markup}</tr></tbody></table>`);\n return dummyPlaceHolder.querySelectorAll(\"tr\").get(0).childNodes.detach();\n }\n\n dummyPlaceHolder.html(markup);\n return dummyPlaceHolder.childNodes.detach();\n }\n\n }\n\n /**\n * returns the nth element as domquery\n * from the internal elements\n * note if you try to reach a non existing element position\n * you will get back an absent entry\n *\n * @param index the nth index\n */\n get(index: number): DomQuery {\n return (index < this.rootNode.length) ? new DomQuery(this.rootNode[index]) : DomQuery.absent;\n }\n\n /**\n * returns the nth element as optional of an Element object\n * @param index the number from the index\n * @param defaults the default value if the index is overrun default Optional.absent\n */\n getAsElem(index: number, defaults: Optional<any> = Optional.absent): Optional<Element> {\n return (index < this.rootNode.length) ? Optional.fromNullable(this.rootNode[index]) : defaults;\n }\n\n /**\n * returns the files from a given elmement\n * @param index\n */\n filesFromElem(index: number): Array<any> {\n return (index < this.rootNode.length) ? (<any>this.rootNode[index])?.files ? (<any>this.rootNode[index]).files : [] : [];\n }\n\n /**\n * returns the value array< of all elements\n */\n allElems(): Array<Element> {\n return this.rootNode;\n }\n\n /**\n * absent no values reached?\n */\n isAbsent(): boolean {\n return this.length == 0;\n }\n\n /**\n * should make the code clearer\n * note if you pass a function\n * this refers to the active dopmquery object\n */\n isPresent(presentRunnable ?: (elem ?: DomQuery) => void): boolean {\n let absent = this.isAbsent();\n if (!absent && presentRunnable) {\n presentRunnable.call(this, this)\n }\n return !absent;\n }\n\n /**\n * should make the code clearer\n * note if you pass a function\n * this refers to the active dopmquery object\n *\n *\n * @param presentRunnable\n */\n ifPresentLazy(presentRunnable: (elem ?: DomQuery) => void = function () {\n }): DomQuery {\n this.isPresent.call(this, presentRunnable);\n return this;\n }\n\n /**\n * remove all affected nodes from this query object from the dom tree\n */\n delete() {\n this.eachElem((node: Element) => {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n });\n }\n\n querySelectorAll(selector): DomQuery {\n //We could merge both methods, but for now this is more readable\n if (selector.indexOf(\"/shadow/\") != -1) {\n return this._querySelectorAllDeep(selector);\n } else {\n return this._querySelectorAll(selector);\n }\n }\n\n /**\n * query selector all on the existing dom queryX object\n *\n * @param selector the standard selector\n * @return a DomQuery with the results\n */\n private _querySelectorAll(selector): DomQuery {\n if (!this?.rootNode?.length) {\n return this;\n }\n let nodes = [];\n for (let cnt = 0; cnt < this.rootNode.length; cnt++) {\n if (!this.rootNode[cnt]?.querySelectorAll) {\n continue;\n }\n let res = this.rootNode[cnt].querySelectorAll(selector);\n nodes = nodes.concat(objToArray(res));\n }\n\n return new DomQuery(...nodes);\n }\n\n\n /*deep with a selector and a peudo /shadow/ marker to break into the next level*/\n private _querySelectorAllDeep(selector): DomQuery {\n if (!this?.rootNode?.length) {\n return this;\n }\n\n let nodes = [];\n let foundNodes: DomQuery = new DomQuery(...this.rootNode);\n let selectors = selector.split(/\\/shadow\\//);\n\n for (let cnt2 = 0; cnt2 < selectors.length; cnt2++) {\n if (selectors[cnt2] == \"\") {\n continue;\n }\n let levelSelector = selectors[cnt2];\n foundNodes = foundNodes.querySelectorAll(levelSelector);\n if (cnt2 < selectors.length - 1) {\n foundNodes = foundNodes.shadowRoot;\n }\n }\n\n return foundNodes;\n }\n\n /**\n * core byId method\n * @param id the id to search for\n * @param includeRoot also match the root element?\n */\n byId(id: string, includeRoot?: boolean): DomQuery {\n let res: Array<DomQuery> = [];\n if (includeRoot) {\n res = res.concat(\n LazyStream.of(...(this?.rootNode || []))\n .filter(item => id == item.id)\n .map(item => new DomQuery(item))\n .collect(new ArrayCollector())\n );\n }\n\n //for some strange kind of reason the # selector fails\n //on hidden elements we use the attributes match selector\n //that works\n res = res.concat(this.querySelectorAll(`[id=\"${id}\"]`));\n return new DomQuery(...res);\n }\n\n\n byIdDeep(id: string, includeRoot?: boolean): DomQuery {\n let res: Array<DomQuery> = [];\n if (includeRoot) {\n res = res.concat(\n LazyStream.of(...(this?.rootNode || []))\n .filter(item => id == item.id)\n .map(item => new DomQuery(item))\n .collect(new ArrayCollector())\n );\n }\n\n let subItems = this.querySelectorAllDeep(`[id=\"${id}\"]`);\n if(subItems.length) {\n res.push(subItems);\n }\n\n return new DomQuery(...res);\n }\n\n /**\n * same as byId just for the tag name\n * @param tagName\n * @param includeRoot\n */\n byTagName(tagName: string, includeRoot ?: boolean, deep ?: boolean): DomQuery {\n let res: Array<Element | DomQuery> = [];\n if (includeRoot) {\n res = <any> LazyStream.of(...(this?.rootNode ?? []))\n .filter(element => element?.tagName == tagName)\n .reduce<Array<Element | DomQuery>>((reduction: any, item: Element) => reduction.concat([item]), res)\n .orElse(res).value;\n }\n\n (deep) ? res.push(this.querySelectorAllDeep(tagName)) : res.push(this.querySelectorAll(tagName));\n return new DomQuery(...res);\n }\n\n /**\n * attr accessor, usage myQuery.attr(\"class\").value = \"bla\"\n * or let value myQuery.attr(\"class\").value\n * @param attr the attribute to set\n * @param defaultValue the default value in case nothing is presented (defaults to null)\n */\n attr(attr: string, defaultValue: string = null): ElementAttribute {\n return new ElementAttribute(this, attr, defaultValue);\n }\n\n /**\n * hasclass, checks for an existing class in the class attributes\n *\n * @param clazz the class to search for\n */\n hasClass(clazz: string) {\n let hasIt = false;\n this.eachElem(node => {\n hasIt = node.classList.contains(clazz);\n if (hasIt) {\n return false;\n }\n });\n return hasIt;\n }\n\n /**\n * appends a class string if not already in the element(s)\n *\n * @param clazz the style class to append\n */\n addClass(clazz: string): DomQuery {\n this.eachElem(item => item.classList.add(clazz))\n return this;\n }\n\n /**\n * remove the style class if in the class definitions\n *\n * @param clazz\n */\n removeClass(clazz: string): DomQuery {\n this.eachElem(item => item.classList.remove(clazz));\n return this;\n }\n\n /**\n * checks whether we have a multipart element in our children\n * or are one\n */\n isMultipartCandidate(deep = false): boolean {\n let isCandidate = (item: DomQuery): boolean => {\n if(item.length == 0) {\n return false;\n }\n if(item.length == 1) {\n if ((<string>item.tagName.get(\"booga\").value).toLowerCase() == \"input\" &&\n (<string>item.attr(\"type\")?.value || \"\").toLowerCase() == \"file\") {\n return true;\n }\n if (deep) {\n return this.querySelectorAllDeep(\"input[type='file']\").firstElem().isPresent();\n } else {\n return this.querySelectorAll(\"input[type='file']\").firstElem().isPresent();\n }\n }\n return item.isMultipartCandidate(deep);\n };\n let ret = this.stream.filter(item => isCandidate(item)).first().isPresent();\n\n return ret;\n }\n\n\n\n /**\n * innerHtml equivalkent\n * equivalent to jqueries html\n * as setter the html is set and the\n * DomQuery is given back\n * as getter the html string is returned\n *\n * @param inval\n */\n html(inval?: string): DomQuery | Optional<string> {\n if (Optional.fromNullable(inval).isAbsent()) {\n return this.isPresent() ? Optional.fromNullable(this.innerHtml) : Optional.absent;\n }\n this.innerHtml = inval;\n\n return this;\n }\n\n /**\n * Standard dispatch event method, delegated from node\n */\n dispatchEvent(evt: Event): DomQuery {\n this.eachElem(elem => elem.dispatchEvent(evt));\n return this;\n }\n\n set innerHtml(inVal: string) {\n this.eachElem(elem => elem.innerHTML = inVal);\n }\n\n get innerHtml(): string {\n let retArr = [];\n this.eachElem(elem => retArr.push(elem.innerHTML));\n return retArr.join(\"\");\n }\n\n //source: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches\n //code snippet license: https://creativecommons.org/licenses/by-sa/2.5/\n private _mozMatchesSelector(toMatch: Element, selector: string): boolean {\n let prot: { [key: string]: Function } = (<any>toMatch);\n let matchesSelector: Function = prot.matchesSelector ||\n prot.mozMatchesSelector ||\n prot.msMatchesSelector ||\n prot.oMatchesSelector ||\n prot.webkitMatchesSelector ||\n function (s: string) {\n let matches: NodeListOf<HTMLElement> = (document || (<any>window).ownerDocument).querySelectorAll(s),\n i = matches.length;\n while (--i >= 0 && matches.item(i) !== toMatch) {\n }\n return i > -1;\n };\n return matchesSelector.call(toMatch, selector);\n }\n\n /**\n * filters the current dom query elements\n * upon a given selector\n *\n * @param selector\n */\n filterSelector(selector: string): DomQuery {\n let matched = [];\n\n this.eachElem(item => {\n if (this._mozMatchesSelector(item, selector)) {\n matched.push(item)\n }\n });\n return new DomQuery(...matched);\n }\n\n matchesSelector(selector: string): boolean {\n this.eachElem(item => {\n if (!this._mozMatchesSelector(item, selector)) {\n return false;\n }\n });\n return true;\n }\n\n /**\n * easy node traversal, you can pass\n * a set of node selectors which are joined as direct childs\n *\n * not the rootnodes are not in the getIf, those are always the child nodes\n *\n * @param nodeSelector\n */\n getIf(...nodeSelector: Array<string>): DomQuery {\n\n let selectorStage: DomQuery = this.childNodes;\n for (let cnt = 0; cnt < nodeSelector.length; cnt++) {\n selectorStage = selectorStage.filterSelector(nodeSelector[cnt]);\n if (selectorStage.isAbsent()) {\n return selectorStage;\n }\n }\n return selectorStage;\n }\n\n eachElem(func: (item: Element, cnt?: number) => any): DomQuery {\n\n for (let cnt = 0, len = this.rootNode.length; cnt < len; cnt++) {\n if (func(this.rootNode[cnt], cnt) === false) {\n break;\n }\n }\n return this;\n }\n\n firstElem(func: (item: Element, cnt?: number) => any = item => item): DomQuery {\n if (this.rootNode.length > 1) {\n func(this.rootNode[0], 0);\n }\n return this;\n }\n\n each(func: (item: DomQuery, cnt?: number) => any): DomQuery {\n Stream.of(...this.rootNode)\n .each((item, cnt) => {\n //we could use a filter, but for the best performance we dont\n if (item == null) {\n return;\n }\n return func(DomQuery.byId(item), cnt);\n });\n\n return this;\n }\n\n /**\n * returns a new dom query containing only the first element max\n *\n * @param func a an optional callback function to perform an operation on the first element\n */\n first(func: (item: DomQuery, cnt?: number) => any = (item) => item): DomQuery {\n if (this.rootNode.length >= 1) {\n func(this.get(0), 0);\n return this.get(0);\n }\n return this;\n }\n\n /**\n * filter function which filters a subset\n *\n * @param func\n */\n filter(func: (item: DomQuery) => boolean): DomQuery {\n let reArr: Array<DomQuery> = [];\n this.each((item: DomQuery) => {\n func(item) ? reArr.push(item) : null;\n });\n return new DomQuery(...<any>reArr);\n }\n\n //TODO append prepend\n\n /**\n * global eval head appendix method\n * no other methods are supported anymore\n * @param code the code to be evaled\n * @param nonce optional nonce key for higher security\n */\n globalEval(code: string, nonce ?: string): DomQuery {\n let head = document.getElementsByTagName(\"head\")[0] || document.documentElement;\n let script = document.createElement(\"script\");\n if (nonce) {\n script.setAttribute(\"nonce\", nonce);\n }\n script.type = \"text/javascript\";\n script.innerHTML = code;\n let newScriptElement = head.appendChild(script);\n head.removeChild(newScriptElement);\n return this;\n }\n\n /**\n * detaches a set of nodes from their parent elements\n * in a browser independend manner\n * @param {Object} items the items which need to be detached\n * @return {Array} an array of nodes with the detached dom nodes\n */\n detach(): DomQuery {\n this.eachElem((item: Element) => {\n item.parentNode.removeChild(item);\n });\n return this;\n }\n\n /**\n * appends the current set of elements\n * to the element or first element passed via elem\n * @param elem\n */\n appendTo(elem: DomQuery) {\n this.eachElem((item) => {\n let value1: Element = <Element>elem.getAsElem(0).orElseLazy(() => {\n return {\n appendChild: (theItem: any) => {\n }\n }\n }).value;\n value1.appendChild(item);\n });\n }\n\n /**\n * loads and evals a script from a source uri\n *\n * @param src the source to be loaded and evaled\n * @param defer in miliseconds execution default (0 == no defer)\n * @param charSet\n */\n loadScriptEval(src: string, defer: number = 0, charSet: string = \"utf-8\") {\n let xhr = new XMLHttpRequest();\n xhr.open(\"GET\", src, false);\n\n if (charSet) {\n xhr.setRequestHeader(\"Content-Type\", \"application/x-javascript; charset:\" + charSet);\n }\n\n xhr.send(null);\n\n xhr.onload = (responseData: any) => {\n //defer also means we have to process after the ajax response\n //has been processed\n //we can achieve that with a small timeout, the timeout\n //triggers after the processing is done!\n if (!defer) {\n this.globalEval(xhr.responseText.replace(\"\\n\", \"\\r\\n\") + \"\\r\\n//@ sourceURL=\" + src);\n } else {\n //TODO not ideal we maybe ought to move to something else here\n //but since it is not in use yet, it is ok\n setTimeout(() => {\n this.globalEval(xhr.responseText + \"\\r\\n//@ sourceURL=\" + src);\n }, defer);\n }\n };\n\n xhr.onerror = (data: any) => {\n throw Error(data);\n };\n //since we are synchronous we do it after not with onReadyStateChange\n\n return this;\n }\n\n insertAfter(...toInsertParams: Array<DomQuery>): DomQuery {\n\n this.each(existingItem => {\n let existingElement = existingItem.getAsElem(0).value;\n let rootNode = existingElement.parentNode;\n for (let cnt = 0; cnt < toInsertParams.length; cnt++) {\n let nextSibling: Element = <any>existingElement.nextSibling;\n toInsertParams[cnt].eachElem(insertElem => {\n if (nextSibling) {\n rootNode.insertBefore(insertElem, nextSibling);\n existingElement = nextSibling;\n } else {\n rootNode.appendChild(insertElem);\n }\n });\n\n }\n });\n\n let res = [];\n res.push(this);\n res = res.concat(toInsertParams);\n return new DomQuery(...res);\n }\n\n insertBefore(...toInsertParams: Array<DomQuery>): DomQuery {\n this.each(existingItem => {\n let existingElement = existingItem.getAsElem(0).value;\n let rootNode = existingElement.parentNode;\n for (let cnt = 0; cnt < toInsertParams.length; cnt++) {\n toInsertParams[cnt].eachElem(insertElem => {\n rootNode.insertBefore(insertElem, existingElement);\n });\n }\n });\n let res = [];\n res.push(this);\n res = res.concat(toInsertParams);\n return new DomQuery(...res);\n }\n\n orElse(...elseValue: any): DomQuery {\n if (this.isPresent()) {\n return this;\n } else {\n return new DomQuery(...elseValue);\n }\n }\n\n orElseLazy(func: () => any): DomQuery {\n if (this.isPresent()) {\n return this;\n } else {\n return new DomQuery(func());\n }\n }\n\n parents(tagName: string): DomQuery {\n const retSet: Set<Element> = new Set();\n const retArr: Array<Element> = [];\n const lowerTagName = tagName.toLowerCase();\n\n let resolveItem = (item: Element) => {\n if ((item.tagName || \"\").toLowerCase() == lowerTagName && !retSet.has(item)) {\n retSet.add(item);\n retArr.push(item);\n }\n };\n\n this.eachElem((item: Element) => {\n while (item.parentNode) {\n item = <Element>item.parentNode;\n resolveItem(item);\n //nested forms not possible, performance shortcut\n if (tagName == \"form\" && retArr.length) {\n return false;\n }\n }\n });\n\n return new DomQuery(...retArr);\n }\n\n copyAttrs(sourceItem: DomQuery | XMLQuery): DomQuery {\n sourceItem.eachElem((sourceNode: Element) => {\n let attrs: Array<Attr> = objToArray(sourceNode.attributes);\n for (let item of attrs) {\n let value: string = item.value;\n let name: string = item.name;\n\n switch (name) {\n case \"id\":\n this.id.value = value;\n break;\n case \"disabled\":\n this.resolveAttributeHolder(\"disabled\").disabled = value;\n break;\n case \"checked\":\n this.resolveAttributeHolder(\"checked\").checked = value;\n break;\n default:\n this.attr(name).value = value;\n }\n }\n });\n return this;\n }\n\n /**\n * resolves an attribute holder compared\n * @param attrName the attribute name\n */\n private resolveAttributeHolder(attrName: string = \"value\"): HTMLFormElement | any {\n let ret = [];\n ret[attrName] = null;\n return (attrName in this.getAsElem(0).value) ?\n this.getAsElem(0).value :\n ret;\n }\n\n /**\n * outerhtml convenience method\n * browsers only support innerHTML but\n * for instance for your jsf.js we have a full\n * replace pattern which needs outerHTML processing\n *\n * @param markup\n * @param runEmbeddedScripts\n * @param runEmbeddedCss\n */\n outerHTML(markup: string, runEmbeddedScripts ?: boolean, runEmbeddedCss ?: boolean, deep = false): DomQuery {\n if (this.isAbsent()) {\n return;\n }\n\n let focusElementId = document?.activeElement?.id;\n let caretPosition = (focusElementId) ? DomQuery.getCaretPosition(document.activeElement) : null;\n let nodes = DomQuery.fromMarkup(markup);\n let res = [];\n let toReplace = this.getAsElem(0).value;\n let firstInsert = nodes.get(0);\n let parentNode = toReplace.parentNode;\n let replaced = firstInsert.getAsElem(0).value;\n parentNode.replaceChild(replaced, toReplace);\n res.push(new DomQuery(replaced));\n //no replacement possible\n if (this.isAbsent()) {\n return this;\n }\n\n let insertAdditionalItems = [];\n\n if (nodes.length > 1) {\n insertAdditionalItems = insertAdditionalItems.concat(...nodes.values.slice(1));\n res.push(DomQuery.byId(replaced).insertAfter(new DomQuery(...insertAdditionalItems)));\n }\n\n if (runEmbeddedScripts) {\n this.runScripts();\n }\n if (runEmbeddedCss) {\n this.runCss();\n }\n\n let focusElement = DomQuery.byId(focusElementId);\n if (focusElementId && focusElement.isPresent() &&\n caretPosition != null && \"undefined\" != typeof caretPosition) {\n focusElement.eachElem(item => DomQuery.setCaretPosition(item, caretPosition));\n }\n\n return nodes;\n }\n\n /**\n * Run through the given nodes in the DomQuery execute the inline scripts\n * @param whilteListed: optional whitelist function which can filter out script tags which are not processed\n * defaults to the standard jsf.js exclusion (we use this code for myfaces)\n */\n runScripts(whilteListed: (val: string) => boolean = DEFAULT_JSF_WHITELIST): DomQuery {\n let finalScripts = [],\n equi = equalsIgnoreCase,\n execScrpt = (item) => {\n let tagName = item.tagName;\n let itemType = item.type || \"\";\n if (tagName && equi(tagName, \"script\") &&\n (itemType === \"\" || equi(itemType, \"text/javascript\") ||\n equi(itemType, \"javascript\") ||\n equi(itemType, \"text/ecmascript\") ||\n equi(itemType, \"ecmascript\"))) {\n let src = item.getAttribute('src');\n if ('undefined' != typeof src\n && null != src\n && src.length > 0\n ) {\n //we have to move this into an inner if because chrome otherwise chokes\n //due to changing the and order instead of relying on left to right\n //if jsf.js is already registered we do not replace it anymore\n if (whilteListed(src)) {\n if (finalScripts.length) {\n //script source means we have to eval the existing\n //scripts before running the include\n this.globalEval(finalScripts.join(\"\\n\"));\n\n finalScripts = [];\n }\n this.loadScriptEval(src, 0, \"UTF-8\");\n }\n\n } else {\n // embedded script auto eval\n //TODO this probably needs to be changed due to our new parsing structures\n //probably not needed anymore\n let evalText = trim(item.text || item.innerText || item.innerHTML);\n let go = true;\n\n while (go) {\n go = false;\n if (evalText.substring(0, 4) == \"<!--\") {\n evalText = evalText.substring(4);\n go = true;\n }\n if (evalText.substring(0, 4) == \"//<!--\") {\n evalText = evalText.substring(6);\n go = true;\n }\n if (evalText.substring(0, 11) == \"//<![CDATA[\") {\n evalText = evalText.substring(11);\n go = true;\n }\n }\n // we have to run the script under a global context\n //we store the script for less calls to eval\n finalScripts.push(evalText);\n\n }\n }\n };\n try {\n let scriptElements = new DomQuery(this.filterSelector(\"script\"), this.querySelectorAll(\"script\"));\n //script execution order by relative pos in their dom tree\n scriptElements.stream\n .flatMap(item => Stream.of(item.values))\n .sort((node1, node2) => node1.compareDocumentPosition(node2) - 3) //preceding 2, following == 4)\n .each(item => execScrpt(item));\n\n if (finalScripts.length) {\n this.globalEval(finalScripts.join(\"\\n\"));\n }\n } catch (e) {\n if (window.console && window.console.error) {\n //not sure if we\n //should use our standard\n //error mechanisms here\n //because in the head appendix\n //method only a console\n //error would be raised as well\n console.error(e.message || e.description);\n }\n } finally {\n //the usual ie6 fix code\n //the IE6 garbage collector is broken\n //nulling closures helps somewhat to reduce\n //mem leaks, which are impossible to avoid\n //at this browser\n execScrpt = null;\n }\n return this;\n }\n\n runCss(): DomQuery {\n\n const applyStyle = (item: Element, style: string) => {\n let newSS: HTMLStyleElement = document.createElement(\"style\");\n document.getElementsByTagName(\"head\")[0].appendChild(newSS);\n\n let styleSheet = newSS.sheet ?? (<any>newSS).styleSheet;\n\n newSS.setAttribute(\"rel\", item.getAttribute(\"rel\") ?? \"stylesheet\");\n newSS.setAttribute(\"type\", item.getAttribute(\"type\") ?? \"text/css\");\n\n if (styleSheet?.cssText ?? false) {\n styleSheet.cssText = style;\n } else {\n newSS.appendChild(document.createTextNode(style));\n }\n },\n\n execCss = (item: Element) => {\n const tagName = item.tagName;\n if (tagName && equalsIgnoreCase(tagName, \"link\") && equalsIgnoreCase(item.getAttribute(\"type\"), \"text/css\")) {\n applyStyle(item, \"@import url('\" + item.getAttribute(\"href\") + \"');\");\n } else if (tagName && equalsIgnoreCase(tagName, \"style\") && equalsIgnoreCase(item.getAttribute(\"type\"), \"text/css\")) {\n let innerText = [];\n //compliant browsers know child nodes\n let childNodes: NodeList = item.childNodes;\n if (childNodes) {\n childNodes.forEach(child => innerText.push((<Element>child).innerHTML || (<CharacterData>child).data));\n //non compliant ones innerHTML\n } else if (item.innerHTML) {\n innerText.push(item.innerHTML);\n }\n\n applyStyle(item, innerText.join(\"\"));\n }\n };\n\n const scriptElements: DomQuery = new DomQuery(this.filterSelector(\"link, style\"), this.querySelectorAll(\"link, style\"));\n\n scriptElements.stream\n .flatMap(item => Stream.of(item.values))\n .sort((node1, node2) => node1.compareDocumentPosition(node2) - 3)\n .each(item => execCss(item));\n\n return this;\n }\n\n /**\n * fires a click event on the underlying dom elements\n */\n click(): DomQuery {\n this.fireEvent(\"click\");\n return this;\n }\n\n addEventListener(type: string, listener: (evt: Event) => void, options?: boolean | EventListenerOptions): DomQuery {\n this.eachElem((node: Element) => node.addEventListener(type, listener, options));\n return this;\n }\n\n removeEventListener(type: string, listener: (evt: Event) => void, options?: boolean | EventListenerOptions): DomQuery {\n this.eachElem((node: Element) => node.removeEventListener(type, listener, options));\n return this;\n }\n\n /**\n * fires an event\n */\n fireEvent(eventName: string) {\n this.eachElem((node: Element) => {\n let doc;\n if (node.ownerDocument) {\n doc = node.ownerDocument;\n } else if (node.nodeType == 9) {\n // the node may be the document itself, nodeType 9 = DOCUMENT_NODE\n doc = node;\n } else {\n throw new Error(\"Invalid node passed to fireEvent: \" + node.id);\n }\n\n if (node.dispatchEvent) {\n // Gecko-style approach (now the standard) takes more work\n let eventClass = \"\";\n\n // Different events have different event classes.\n // If this switch statement can't map an eventName to an eventClass,\n // the event firing is going to fail.\n switch (eventName) {\n case \"click\": // Dispatching of 'click' appears to not work correctly in Safari. Use 'mousedown' or 'mouseup' instead.\n case \"mousedown\":\n case \"mouseup\":\n eventClass = \"MouseEvents\";\n break;\n\n case \"focus\":\n case \"change\":\n case \"blur\":\n case \"select\":\n eventClass = \"HTMLEvents\";\n break;\n\n default:\n throw \"fireEvent: Couldn't find an event class for event '\" + eventName + \"'.\";\n break;\n }\n let event = doc.createEvent(eventClass);\n event.initEvent(eventName, true, true); // All events created as bubbling and cancelable.\n\n event.synthetic = true; // allow detection of synthetic events\n // The second parameter says go ahead with the default action\n node.dispatchEvent(event);\n } else if ((<any>node).fireEvent) {\n // IE-old school style, you can drop this if you don't need to support IE8 and lower\n let event = doc.createEventObject();\n event.synthetic = true; // allow detection of synthetic events\n (<any>node).fireEvent(\"on\" + eventName, event);\n }\n })\n }\n\n textContent(joinstr: string = \"\"): string {\n return this.stream\n .map((value: DomQuery) => {\n let item = value.getAsElem(0).orElseLazy(() => {\n return <any>{\n textContent: \"\"\n };\n }).value;\n return (<any>item).textContent || \"\";\n })\n .reduce((text1, text2) => text1 + joinstr + text2, \"\").value;\n }\n\n innerText(joinstr: string = \"\"): string {\n return this.stream\n .map((value: DomQuery) => {\n let item = value.getAsElem(0).orElseLazy(() => {\n return <any>{\n innerText: \"\"\n };\n }).value;\n return (<any>item).innerText || \"\";\n })\n .reduce((text1, text2) => [text1, text2].join(joinstr), \"\").value;\n\n }\n\n /**\n * encodes all input elements properly into respective\n * config entries, this can be used\n * for legacy systems, for newer usecases, use the\n * HTML5 Form class which all newer browsers provide\n *\n * @param toMerge optional config which can be merged in\n * @return a copy pf\n */\n encodeFormElement(toMerge = new Config({})): Config {\n\n //browser behavior no element name no encoding (normal submit fails in that case)\n //https://issues.apache.org/jira/browse/MYFACES-2847\n if (this.name.isAbsent()) {\n return;\n }\n\n //lets keep it sideffects free\n let target = toMerge.shallowCopy;\n\n this.each((element: DomQuery) => {\n if (element.name.isAbsent()) {//no name, no encoding\n return;\n }\n let name = element.name.value;\n let tagName = element.tagName.orElse(\"__none__\").value.toLowerCase();\n let elemType = element.type.orElse(\"__none__\").value.toLowerCase();\n\n elemType = elemType.toLowerCase();\n\n // routine for all elements\n // rules:\n // - process only inputs, textareas and selects\n // - elements muest have attribute \"name\"\n // - elements must not be disabled\n if (((tagName == \"input\" || tagName == \"textarea\" || tagName == \"select\") &&\n (name != null && name != \"\")) && !element.disabled) {\n\n // routine for select elements\n // rules:\n // - if select-one and value-Attribute exist => \"name=value\"\n // (also if value empty => \"name=\")\n // - if select-one and value-Attribute don't exist =>\n // \"name=DisplayValue\"\n // - if select multi and multple selected => \"name=value1&name=value2\"\n // - if select and selectedIndex=-1 don't submit\n if (tagName == \"select\") {\n // selectedIndex must be >= 0 sein to be submittet\n let selectElem: HTMLSelectElement = <HTMLSelectElement>element.getAsElem(0).value;\n if (selectElem.selectedIndex >= 0) {\n let uLen = selectElem.options.length;\n for (let u = 0; u < uLen; u++) {\n // find all selected options\n //let subBuf = [];\n if (selectElem.options[u].selected) {\n let elementOption = selectElem.options[u];\n target.append(name).value = (elementOption.getAttribute(\"value\") != null) ?\n elementOption.value : elementOption.text;\n }\n }\n }\n }\n\n // routine for remaining elements\n // rules:\n // - don't submit no selects (processed above), buttons, reset buttons, submit buttons,\n // - submit checkboxes and radio inputs only if checked\n if (\n (\n tagName != Submittables.SELECT &&\n elemType != Submittables.BUTTON &&\n elemType != Submittables.RESET &&\n elemType != Submittables.SUBMIT &&\n elemType != Submittables.IMAGE\n ) && (\n (\n elemType != Submittables.CHECKBOX && elemType != Submittables.RADIO) ||\n element.checked\n )\n ) {\n let files: any = (<any>element.value).files;\n if (files?.length) {\n //xhr level2\n target.append(name).value = files[0];\n } else {\n target.append(name).value = element.inputValue.value;\n }\n }\n\n }\n });\n\n return target;\n }\n\n get cDATAAsString(): string {\n let cDataBlock = [];\n let TYPE_CDATA_BLOCK = 4;\n\n let res: any = this.lazyStream.flatMap(item => {\n return item.childNodes.stream\n }).filter(item => {\n return item?.value?.value?.nodeType == TYPE_CDATA_BLOCK;\n }).reduce((reduced: Array<any>, item: DomQuery) => {\n reduced.push((<any>item?.value?.value)?.data ?? \"\");\n return reduced;\n }, []).value;\n\n // response may contain several blocks\n return res.join(\"\");\n }\n\n subNodes(from: number, to?: number): DomQuery {\n if (Optional.fromNullable(to).isAbsent()) {\n to = this.length;\n }\n return new DomQuery(...this.rootNode.slice(from, Math.min(to, this.length)));\n }\n\n _limits = -1;\n\n limits(end: number): IStream<DomQuery> {\n this._limits = end;\n return <any>this;\n }\n\n //-- internally exposed methods needed for the interconnectivity\n hasNext() {\n let isLimitsReached = this._limits != -1 && this.pos >= this._limits - 1;\n let isEndOfArray = this.pos >= this.values.length - 1;\n return !(isLimitsReached ||\n isEndOfArray);\n }\n\n next(): DomQuery {\n if (!this.hasNext()) {\n return null;\n }\n this.pos++;\n return new DomQuery(this.values[this.pos]);\n }\n\n reset() {\n this.pos = -1;\n }\n\n attachShadow(params: { [key: string]: string } = {mode: \"open\"}): DomQuery {\n let shadowRoots: DomQuery[] = [];\n this.eachElem((item: Element) => {\n let shadowElement: DomQuery;\n if ((<any>item)?.attachShadow) {\n shadowElement = DomQuery.byId((<any>item).attachShadow(params));\n shadowRoots.push(shadowElement);\n } else {\n throw new Error(\"Shadow dom creation not supported by the browser, please use a shim, to gain this functionality\");\n }\n });\n return new DomQuery(...shadowRoots);\n }\n\n /**\n * returns the embedded shadow elements\n */\n get shadowElements(): DomQuery {\n let shadowElements = this.querySelectorAll(\"*\")\n .filter(item => item.hasShadow);\n\n\n let mapped: Array<ShadowRoot> = (shadowElements.allElems() || []).map(element => element.shadowRoot);\n return new DomQuery(...mapped);\n }\n\n get shadowRoot(): DomQuery {\n let shadowRoots = [];\n for (let cnt = 0; cnt < this.rootNode.length; cnt++) {\n if (this.rootNode[cnt].shadowRoot) {\n shadowRoots.push(this.rootNode[cnt].shadowRoot);\n }\n }\n return new DomQuery(...shadowRoots);\n }\n\n get hasShadow(): boolean {\n for (let cnt = 0; cnt < this.rootNode.length; cnt++) {\n if (this.rootNode[cnt].shadowRoot) {\n return true;\n }\n }\n return false;\n }\n\n //from\n // http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/\n static getCaretPosition(ctrl: any) {\n let caretPos = 0;\n\n try {\n if ((<any>document)?.selection) {\n ctrl.focus();\n let selection = (<any>document).selection.createRange();\n //the selection now is start zero\n selection.moveStart('character', -ctrl.value.length);\n //the caretposition is the selection start\n caretPos = selection.text.length;\n }\n } catch (e) {\n //now this is ugly, but not supported input types throw errors for selectionStart\n //just in case someone dumps this code onto unsupported browsers\n }\n return caretPos;\n }\n\n /**\n * sets the caret position\n *\n * @param ctrl the control to set the caret position to\n * @param pos the position to set\n *\n * note if the control does not have any selectable and focusable behavior\n * calling this method does nothing (silent fail)\n *\n */\n static setCaretPosition(ctrl: any, pos: number) {\n ctrl?.focus ? ctrl?.focus() : null;\n //the selection range is our caret position\n\n ctrl?.setSelectiongRange ? ctrl?.setSelectiongRange(pos, pos) : null;\n }\n\n\n}\n\n/**\n * Various collectors\n * which can be used in conjunction with Streams\n */\n\n/**\n * A collector which bundles a full dom query stream into a single dom query element\n *\n * This connects basically our stream back into DomQuery\n */\nexport class DomQueryCollector implements ICollector<DomQuery, DomQuery> {\n\n data: DomQuery[] = [];\n\n collect(element: DomQuery) {\n this.data.push(element);\n }\n\n get finalValue(): DomQuery {\n return new DomQuery(...this.data);\n }\n}\n\n/**\n * abbreviation for DomQuery\n */\nexport const DQ = DomQuery;\nexport type DQ = DomQuery;\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Stream, StreamMapper} from \"./Stream\";\nimport {DomQuery} from \"./DomQuery\";\n\n/**\n * Every data source wich feeds data into the lazy stream\n * or stream generally must implement this interface\n *\n * It is basically an iteratable to the core\n */\nexport interface IStreamDataSource<T> {\n\n /**\n * @returns true if additional data is present\n */\n hasNext(): boolean;\n\n /**\n * false if not\n */\n next(): T;\n\n /**\n * resets the position to the beginning\n */\n reset(): void;\n}\n\n/**\n * A collector, needs to be implemented\n */\nexport interface ICollector<T, S> {\n /**\n * this method basically takes a single stream element\n * and does something with it (collecting it one way or the other\n * in most cases)\n *\n * @param element\n */\n collect(element: T);\n\n /**\n * the final result after all the collecting is done\n */\n finalValue: S;\n}\n\n/**\n * implementation of iteratable on top of array\n */\nexport class ArrayStreamDataSource<T> implements IStreamDataSource<T> {\n value: Array<T>;\n dataPos = -1;\n\n constructor(...value: Array<T>) {\n this.value = value;\n }\n\n hasNext(): boolean {\n return this.value.length - 1 > this.dataPos;\n }\n\n next(): T {\n this.dataPos++;\n return this.value[this.dataPos];\n }\n\n reset() {\n this.dataPos = -1;\n }\n}\n\n/**\n * an intermediate data source wich prefilters\n * incoming stream data\n * and lets only the data out which\n * passes the filter function check\n */\nexport class FilteredStreamDatasource<T> implements IStreamDataSource<T> {\n\n filterFunc: (T) => boolean;\n inputDataSource: IStreamDataSource<T>;\n\n filteredNext: T = null;\n\n constructor(filterFunc: (T) => boolean, parent: IStreamDataSource<T>) {\n this.filterFunc = filterFunc;\n this.inputDataSource = parent;\n }\n\n /**\n * in order to filter we have to make a look ahead until the\n * first next allowed element\n * hence we prefetch the element and then\n * serve it via next\n */\n hasNext(): boolean {\n while (this.filteredNext == null && this.inputDataSource.hasNext()) {\n let next: T = <T>this.inputDataSource.next();\n if (this.filterFunc(next)) {\n this.filteredNext = next;\n return true;\n } else {\n this.filteredNext = null;\n }\n }\n return this.filteredNext != null;\n\n }\n\n /**\n * serve the next element\n */\n next(): T {\n let ret = this.filteredNext;\n this.filteredNext = null;\n //We have to call hasNext, to roll another\n //prefetch in case someone runs next\n //sequentially without calling hasNext\n this.hasNext();\n return ret;\n }\n\n reset(): void {\n this.filteredNext = null;\n this.inputDataSource.reset();\n }\n}\n\n/**\n * an intermediate datasource which maps the items from\n * one into another\n */\nexport class MappedStreamDataSource<T, S> implements IStreamDataSource<S> {\n\n mapFunc: (T) => S;\n inputDataSource: IStreamDataSource<T>;\n\n constructor(mapFunc: (T) => S, parent: IStreamDataSource<T>) {\n this.mapFunc = mapFunc;\n this.inputDataSource = parent;\n }\n\n hasNext(): boolean {\n return this.inputDataSource.hasNext();\n }\n\n next(): S {\n return this.mapFunc(this.inputDataSource.next());\n }\n\n reset(): void {\n this.inputDataSource.reset();\n }\n}\n\n/**\n * Same for flatmap to deal with element -> stream mappings\n */\nexport class FlatMapStreamDataSource<T, S> implements IStreamDataSource<S> {\n\n mapFunc: StreamMapper<T>;\n\n inputDataSource: IStreamDataSource<T>;\n\n /**\n * the currently active stream\n * coming from an incoming element\n * once the end of this one is reached\n * it is swapped out by another one\n * from the next element\n */\n activeDataSource: IStreamDataSource<S>;\n\n constructor(func: StreamMapper<T>, parent: IStreamDataSource<T>) {\n this.mapFunc = func;\n this.inputDataSource = parent;\n }\n\n hasNext(): boolean {\n return this.resolveCurrentNext() || this.resolveNextNext();\n }\n\n private resolveCurrentNext() {\n let next = false;\n if (this.activeDataSource) {\n next = this.activeDataSource.hasNext();\n }\n return next;\n }\n\n private resolveNextNext() {\n let next = false;\n while (!next && this.inputDataSource.hasNext()) {\n let mapped = this.mapFunc(this.inputDataSource.next());\n if(Array.isArray(mapped)) {\n this.activeDataSource = new ArrayStreamDataSource(...mapped);\n } else {\n this.activeDataSource = mapped;\n }\n next = this.activeDataSource.hasNext();\n }\n return next;\n }\n\n next(): S {\n return this.activeDataSource.next();\n }\n\n reset(): void {\n this.inputDataSource.reset();\n }\n}\n\n/**\n * For the time being we only need one collector\n * a collector which collects a stream back into arrays\n */\nexport class ArrayCollector<S> implements ICollector<S, Array<S>> {\n private data: Array<S> = [];\n\n collect(element: S) {\n this.data.push(element);\n }\n\n get finalValue(): Array<S> {\n return this.data;\n }\n}\n\n/**\n * collects an assoc stream back to an assoc array\n */\nexport class AssocArrayCollector<S> implements ICollector<[string, S] | string, {[key:string]:S}> {\n\n finalValue: {[key:string]:any} = {};\n\n collect(element: [string, S] | string) {\n this.finalValue[element[0] ?? <string>element] = element[1] ?? true;\n }\n}\n\n/**\n * Form data collector for key value pair streams\n */\nexport class FormDataCollector implements ICollector<{ key: string, value: any }, FormData> {\n finalValue: FormData = new FormData();\n\n collect(element: { key: string; value: any }) {\n this.finalValue.append(element.key, element.value);\n }\n}\n\n/**\n * Form data collector for DomQuery streams\n */\nexport class QueryFormDataCollector implements ICollector<DomQuery, FormData> {\n finalValue: FormData = new FormData();\n\n collect(element: DomQuery) {\n let toMerge = element.encodeFormElement();\n if (toMerge.isPresent()) {\n this.finalValue.append(element.name.value, toMerge.get(element.name).value);\n }\n }\n}\n\n/**\n * Encoded String collector from dom query streams\n */\nexport class QueryFormStringCollector implements ICollector<DomQuery, string> {\n\n formData: [[string, string]] = <any>[];\n\n collect(element: DomQuery) {\n let toMerge = element.encodeFormElement();\n if (toMerge.isPresent()) {\n Stream.of(...toMerge.value).each(item => {\n this.formData.push([element.name.value, item]);\n });\n }\n }\n\n get finalValue(): string {\n return Stream.of(...this.formData)\n .map<string>(keyVal => keyVal.join(\"=\"))\n .reduce((item1, item2) => [item1, item2].join(\"&\"))\n .orElse(\"\").value;\n }\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * A small stream implementation\n */\nimport {IMonad, IValueHolder, Optional} from \"./Monad\";\nimport {\n ArrayCollector,\n ArrayStreamDataSource,\n FilteredStreamDatasource, FlatMapStreamDataSource,\n ICollector,\n IStreamDataSource,\n MappedStreamDataSource\n} from \"./SourcesCollectors\";\n\n/*\n * some typedefs to make the code more reabable\n */\nexport type StreamMapper<T> = (data: T) => IStreamDataSource<any>;\nexport type ArrayMapper<T> = (data: T) => Array<any>;\nexport type IteratableConsumer<T> = (data: T, pos ?: number) => void | boolean;\nexport type Reducable<T, V> = (val1: T | V, val2: T) => V;\nexport type Matchable<T> = (data: T) => boolean;\nexport type Mappable<T, R> = (data: T) => R;\nexport type Comparator<T> = (el1: T, el2: T) => number;\n\n/**\n * Generic interface defining a stream\n */\nexport interface IStream<T> {\n /**\n * Perform the operation fn on a single element in the stream at a time\n * then pass the stream over for further processing\n * This is basically an intermediate point in the stream\n * with further processing happening later, do not use\n * this method to gather data or iterate over all date for processing\n * (for the second case each has to be used)\n *\n * @param fn the processing function, if it returns false, further processing is stopped\n */\n onElem(fn: IteratableConsumer<T>): IStream<T>;\n\n /**\n * Iterate over all elements in the stream and do some processing via fn\n *\n * @param fn takes a single element and if it returns false\n * then further processing is stopped\n */\n each(fn: IteratableConsumer<T>): void;\n\n /**\n * maps a single element into another via fn\n * @param fn function which takes one element in and returns another\n */\n map<R>(fn?: Mappable<T, R>): IStream<R>;\n\n /**\n * Takes an element in and returns a set of something\n * the set then is flatted into a single stream to be further processed\n *\n * @param fn\n */\n flatMap<R>(fn?: StreamMapper<T> | ArrayMapper<T>): IStream<R>;\n\n /**\n * filtering, takes an element in and is processed by fn.\n * If it returns false then further processing on this element is skipped\n * if it returns true it is passed down the chain.\n *\n * @param fn\n */\n filter(fn?: Matchable<T>): IStream<T>;\n\n /**\n * functional reduce... takes two elements in the stream and reduces to\n * one from left to right\n *\n * @param fn the reduction function for instance (val1,val2) => val1l+val2\n * @param startVal an optional starting value, if provided the the processing starts with this element\n * and further goes down into the stream, if not, then the first two elements are taken as reduction starting point\n */\n reduce<V>(fn: Reducable<T, V>, startVal: T | V): Optional<T | V>;\n\n /**\n * returns the first element in the stream is given as Optional\n */\n first(): Optional<T>;\n\n /**\n * Returns the last stream element (note in endless streams without filtering and limiting you will never reach that\n * point hence producing an endless loop)\n */\n last(): Optional<T>;\n\n /**\n * returns true if there is at least one element where a call fn(element) produces true\n *\n * @param fn\n */\n anyMatch(fn: Matchable<T>): boolean;\n\n /**\n * returns true if all elmements produce true on a call to fn(element)\n *\n * @param fn\n */\n allMatch(fn: Matchable<T>): boolean;\n\n /**\n * returns true if no elmements produce true on a call to fn(element)\n *\n * @param fn\n */\n noneMatch(fn: Matchable<T>): boolean;\n\n /**\n * Collect the elements with a collector given\n * There are a number of collectors provided\n *\n * @param collector\n */\n collect(collector: ICollector<T, any>): any;\n\n /**\n * sort on the stream, this is a special case\n * of an endpoint, so your data which is fed in needs\n * to be limited otherwise it will fail\n * it still returns a stream for further processing\n *\n * @param comparator\n */\n sort(comparator: Comparator<T>): IStream<T>;\n\n /**\n * Limits the stream to a certain number of elements\n *\n * @param end the limit of the stream\n */\n limits(end: number): IStream<T>;\n\n /**\n * returns the stream collected into an array (90% use-case abbreviation\n */\n value: Array<T>;\n}\n\n/**\n * A simple typescript based reimplementation of streams\n *\n * This is the early eval version\n * for a lazy eval version check, LazyStream, which is api compatible\n * to this implementation, however with the benefit of being able\n * to provide infinite data sources and generic data providers, the downside\n * is, it might be a tad slower in some situations\n */\nexport class Stream<T> implements IMonad<T, Stream<any>>, IValueHolder<Array<T>>, IStream<T> {\n\n value: Array<T>;\n _limits = -1;\n\n private pos = -1;\n\n constructor(...value: T[]) {\n this.value = value;\n }\n\n static of<T>(...data: Array<T>): Stream<T> {\n return new Stream<T>(...data);\n }\n\n static ofAssoc<T>(data: { [key: string]: T }): Stream<[string, T]> {\n return this.of(...Object.keys(data)).map(key => [key, data[key]]);\n }\n\n static ofDataSource<T>(dataSource: IStreamDataSource<T>) {\n let value: T[] = [];\n while (dataSource.hasNext()) {\n value.push(dataSource.next());\n }\n\n return new Stream(...value);\n }\n\n limits(end: number): Stream<T> {\n this._limits = end;\n return this;\n }\n\n onElem(fn: (data: T, pos ?: number) => void | boolean): Stream<T> {\n for (let cnt = 0; cnt < this.value.length && (this._limits == -1 || cnt < this._limits); cnt++) {\n if (fn(this.value[cnt], cnt) === false) {\n break;\n }\n }\n return this;\n }\n\n each(fn: (data: T, pos ?: number) => void | boolean) {\n this.onElem(fn);\n }\n\n map<R>(fn?: (data: T) => R): Stream<R> {\n if (!fn) {\n fn = (inval: any) => <R>inval;\n }\n let res: R[] = [];\n this.each((item, cnt) => {\n res.push(fn(item))\n });\n\n return new Stream<R>(...res);\n }\n\n /*\n * we need to implement it to fullfill the contract, although it is used only internally\n * all values are flattened when accessed anyway, so there is no need to call this methiod\n */\n\n flatMap<IStreamDataSource>(fn: (data: T) => IStreamDataSource | Array<any>): Stream<any> {\n let ret = [];\n this.each(item => {\n let strmR: any = fn(item);\n ret = Array.isArray(strmR) ? ret.concat(strmR) : ret.concat(...strmR.value);\n });\n return <Stream<any>>Stream.of(...ret);\n }\n\n filter(fn?: (data: T) => boolean): Stream<T> {\n let res: Array<T> = [];\n this.each((data) => {\n if (fn(data)) {\n res.push(data);\n }\n });\n return new Stream<T>(...res);\n }\n\n reduce<V>(fn: Reducable<T, V | T>, startVal: V = null): Optional<V | T> {\n let offset = startVal != null ? 0 : 1;\n let val1: V | T = startVal != null ? startVal : this.value.length ? this.value[0] : null;\n\n for (let cnt = offset; cnt < this.value.length && (this._limits == -1 || cnt < this._limits); cnt++) {\n val1 = fn(val1, this.value[cnt]);\n }\n return Optional.fromNullable<V | T>(val1);\n }\n\n first(): Optional<T> {\n return this.value && this.value.length ? Optional.fromNullable(this.value[0]) : Optional.absent;\n }\n\n last(): Optional<T> {\n //could be done via reduce, but is faster this way\n let length = this._limits > 0 ? Math.min(this._limits, this.value.length) : this.value.length;\n\n return Optional.fromNullable(length ? this.value[length - 1] : null);\n }\n\n anyMatch(fn: Matchable<T>): boolean {\n for (let cnt = 0; cnt < this.value.length && (this._limits == -1 || cnt < this._limits); cnt++) {\n if (fn(this.value[cnt])) {\n return true;\n }\n }\n return false;\n }\n\n allMatch(fn: Matchable<T>): boolean {\n if (!this.value.length) {\n return false;\n }\n let matches = 0;\n for (let cnt = 0; cnt < this.value.length; cnt++) {\n if (fn(this.value[cnt])) {\n matches++;\n }\n }\n return matches == this.value.length;\n }\n\n noneMatch(fn: Matchable<T>): boolean {\n let matches = 0;\n for (let cnt = 0; cnt < this.value.length; cnt++) {\n if (!fn(this.value[cnt])) {\n matches++;\n }\n }\n return matches == this.value.length;\n }\n\n sort(comparator: Comparator<T>): IStream<T> {\n let newArr = this.value.slice().sort(comparator);\n return Stream.of(...newArr);\n }\n\n collect(collector: ICollector<T, any>): any {\n this.each(data => collector.collect(data));\n return collector.finalValue;\n }\n\n //-- internally exposed methods needed for the interconnectivity\n hasNext() {\n let isLimitsReached = this._limits != -1 && this.pos >= this._limits - 1;\n let isEndOfArray = this.pos >= this.value.length - 1;\n return !(isLimitsReached || isEndOfArray);\n }\n\n next(): T {\n if (!this.hasNext()) {\n return null;\n }\n this.pos++;\n return this.value[this.pos];\n }\n\n reset() {\n this.pos = -1;\n }\n\n}\n\n/**\n * Lazy implementation of a Stream\n * The idea is to connect the intermediate\n * streams as datasources like a linked list\n * with reverse referencing and for special\n * operations like filtering flatmapping\n * have intermediate datasources in the list\n * with specialized functions.\n *\n * Sort of a modified pipe valve pattern\n * the streams are the pipes the intermediate\n * data sources are the valves\n *\n * We then can use passed in functions to control\n * the flow in the valves\n *\n * That way we can have a lazy evaluating stream\n *\n * So if an endpoint requests data\n * a callback trace goes back the stream list\n * which triggers an operation upwards\n * which sends data down the drain which then is processed\n * and filtered until one element hits the endpoint.\n *\n * That is repeated, until all elements are processed\n * or an internal limit is hit.\n *\n */\nexport class LazyStream<T> implements IStreamDataSource<T>, IStream<T>, IMonad<T, LazyStream<any>> {\n\n protected dataSource: IStreamDataSource<T>;\n _limits = -1;\n\n /*\n * needed to have the limits check working\n * we need to keep track of the current position\n * in the stream\n */\n pos = -1;\n\n static of<T>(...values: Array<T>): LazyStream<T> {\n return new LazyStream<T>(new ArrayStreamDataSource(...values));\n }\n\n static ofAssoc<T>(data: { [key: string]: T }): LazyStream<[string, T]> {\n return this.of(...Object.keys(data)).map(key => [key, data[key]]);\n }\n\n static ofStreamDataSource<T>(value: IStreamDataSource<T>): LazyStream<T> {\n return new LazyStream(value);\n }\n\n constructor(parent: IStreamDataSource<T>) {\n this.dataSource = parent;\n\n }\n\n hasNext(): boolean {\n if (this.isOverLimits()) {\n return false;\n }\n\n return this.dataSource.hasNext();\n }\n\n next(): T {\n let next = this.dataSource.next();\n // @ts-ignore\n this.pos++;\n return next;\n }\n\n reset(): void {\n this.dataSource.reset();\n this.pos = 0;\n this._limits = -1;\n }\n\n nextFilter(fn: Matchable<T>): T {\n if (this.hasNext()) {\n let newVal: T = this.next();\n if (!fn(newVal)) {\n return this.nextFilter(fn);\n }\n return <T>newVal;\n }\n return null;\n }\n\n limits(max: number): LazyStream<T> {\n this._limits = max;\n return this;\n }\n\n //main stream methods\n collect(collector: ICollector<T, any>): any {\n while (this.hasNext()) {\n let t = this.next();\n collector.collect(<T>t);\n }\n return collector.finalValue;\n }\n\n onElem(fn: IteratableConsumer<T>): LazyStream<T> {\n return new LazyStream(new MappedStreamDataSource((el) => {\n if (fn(el, this.pos) === false) {\n this.stop();\n }\n return el;\n }, this));\n }\n\n filter(fn: Matchable<T>): LazyStream<T> {\n return <LazyStream<T>>new LazyStream<T>(new FilteredStreamDatasource<any>(fn, this));\n }\n\n map<R>(fn: Mappable<T, R>): LazyStream<any> {\n return new LazyStream(new MappedStreamDataSource(fn, this));\n }\n\n flatMap<StreamMapper>(fn: StreamMapper | ArrayMapper<any>): LazyStream<any> {\n\n return new LazyStream<any>(new FlatMapStreamDataSource(<any>fn, this));\n }\n\n //endpoint\n each(fn: IteratableConsumer<T>) {\n while (this.hasNext()) {\n if (fn(this.next()) === false) {\n this.stop();\n }\n }\n }\n\n reduce<V>(fn: Reducable<T, V>, startVal: T | V = null): Optional<T | V> {\n if (!this.hasNext()) {\n return Optional.absent;\n }\n let value1 = null;\n let value2 = null;\n if (startVal != null) {\n value1 = startVal;\n value2 = this.next();\n } else {\n value1 = this.next();\n if (!this.hasNext()) {\n return Optional.fromNullable(value1);\n }\n value2 = this.next();\n }\n value1 = fn(value1, value2);\n while (this.hasNext()) {\n value2 = this.next();\n value1 = fn(value1, value2);\n }\n\n return Optional.fromNullable(value1);\n }\n\n last(): Optional<T> {\n if (!this.hasNext()) {\n return Optional.absent;\n }\n return this.reduce((el1, el2) => el2);\n }\n\n first(): Optional<T> {\n this.reset();\n if (!this.hasNext()) {\n return Optional.absent;\n }\n return Optional.fromNullable(this.next());\n }\n\n anyMatch(fn: Matchable<T>): boolean {\n while (this.hasNext()) {\n if (fn(this.next())) {\n return true;\n }\n }\n return false;\n }\n\n allMatch(fn: Matchable<T>): boolean {\n while (this.hasNext()) {\n if (!fn(this.next())) {\n return false;\n }\n }\n return true;\n }\n\n noneMatch(fn: Matchable<T>): boolean {\n while (this.hasNext()) {\n if (fn(this.next())) {\n return false;\n }\n }\n return true;\n }\n\n sort(comparator: Comparator<T>): IStream<T> {\n let arr = this.collect(new ArrayCollector());\n arr = arr.sort(comparator);\n return LazyStream.of(...arr);\n }\n\n get value(): Array<T> {\n return this.collect(new ArrayCollector<T>());\n }\n\n private stop() {\n this.pos = this._limits + 1000000000;\n }\n\n private isOverLimits() {\n return this._limits != -1 && this.pos >= this._limits - 1;\n }\n\n}\n\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {IListener} from \"./util/ListenerQueue\";\nimport {Response} from \"./xhrCore/Response\";\nimport {XhrRequest} from \"./xhrCore/XhrRequest\";\nimport {AsynchronouseQueue} from \"./util/AsyncQueue\";\nimport {AssocArrayCollector, Config, DQ, Lang, Optional, Stream} from \"../ext/monadish\";\nimport {Assertions} from \"./util/Assertions\";\nimport {XhrFormData} from \"./xhrCore/XhrFormData\";\nimport {ExtDomquery} from \"./util/ExtDomQuery\";\nimport {ErrorData} from \"./xhrCore/ErrorData\";\nimport {EventData} from \"./xhrCore/EventData\";\nimport {ExtLang} from \"./util/Lang\";\nimport {\n CTX_PARAM_EXECUTE,\n CTX_PARAM_PASS_THR,\n CTX_PARAM_SRC_CTL_ID,\n CTX_PARAM_SRC_FRM_ID,\n CTX_PARAM_TR_TYPE,\n IDENT_ALL,\n IDENT_FORM,\n IDENT_NONE,\n IDENT_THIS,\n MYFACES,\n ON_ERROR,\n ON_EVENT,\n P_AJAX,\n P_CLIENT_WINDOW,\n P_EVT,\n P_EXECUTE,\n P_PARTIAL_SOURCE,\n P_RENDER,\n P_RESET_VALUES,\n P_WINDOW_ID,\n RENDER,\n REQ_TYPE_POST,\n SOURCE,\n TAG_FORM\n} from \"./core/Const\";\nimport {\n resolveDefaults,\n resolveDelay,\n resolveForm,\n resolveTimeout\n} from \"./xhrCore/RequestDataResolver\";\n\ndeclare var jsf: any;\n\n/*\n * allowed project stages\n */\nenum ProjectStages {\n Production = \"Production\",\n Development = \"Development\",\n SystemTest = \"SystemTest\",\n UnitTest = \"UnitTest\"\n}\n\n/*\n * blockfilter for the passthrough filtering; the attributes given here\n * will not be transmitted from the options into the passthrough\n */\nenum BlockFilter {\n onerror = \"onerror\",\n onevent = \"onevent\",\n render = \"render\",\n execute = \"execute\",\n myfaces = \"myfaces\",\n delay = \"delay\",\n timeout = \"timeout\",\n windowId = \"windowId\"\n}\n\n/**\n * Core Implementation\n * to distinct between api and impl\n *\n * The original idea was to make the implementation pluggable\n * but this is pointless, you always can overwrite the thin api layer\n * however a dedicated api makes sense for readability reasons\n */\nexport module Implementation {\n\n import trim = Lang.trim;\n import getMessage = ExtLang.getMessage;\n import getGlobalConfig = ExtLang.getGlobalConfig;\n import assert = Assertions.assert;\n\n\n\n let projectStage: string = null;\n let separator: string = null;\n let eventQueue = [];\n let errorQueue = [];\n export let requestQueue: AsynchronouseQueue<XhrRequest> = null;\n /*error reporting threshold*/\n let threshold = \"ERROR\";\n\n /**\n * fetches the separator char from the given script tags\n *\n * @return {char} the separator char for the given script tags\n */\n export function getSeparatorChar(): string {\n return resolveGlobalConfig()?.separator ??\n this?.separator ??\n (separator = ExtDomquery.searchJsfJsFor(/separator=([^&;]*)/).orElse(\":\").value);\n }\n\n /**\n * this is for testing purposes only, since AjaxImpl is a module\n * we need to reset for every unit test its internal states\n */\n export function reset() {\n projectStage = null;\n separator = null;\n eventQueue = [];\n errorQueue = [];\n requestQueue = null;\n }\n\n /**\n * @return the project stage also emitted by the server:\n * it cannot be cached and must be delivered over the server\n * The value for it comes from the requestInternal parameter of the jsf.js script called \"stage\".\n */\n export function getProjectStage(): string | null {\n return resolveGlobalConfig()?.projectStage ??\n this?.projectStage ??\n (projectStage = resolveProjectStateFromURL());\n }\n\n /**\n * resolves the project stage as url parameter\n * @return the project stage or null\n */\n export function resolveProjectStateFromURL(): string | null {\n\n /* run through all script tags and try to find the one that includes jsf.js */\n let foundStage = <string>ExtDomquery.searchJsfJsFor(/stage=([^&;]*)/).value;\n return (foundStage in ProjectStages) ? foundStage : null;\n }\n\n /**\n * implementation of the jsf.util.chain functionality\n *\n * @param source\n * @param event\n * @param funcs\n */\n export function chain(source: any, event: Event, ...funcs: EvalFuncs): boolean {\n\n let ret = true;\n let resolveAndExecute = function (func: Function | string) {\n if (\"string\" != typeof func) {\n //function is passed down as chain parameter, can be executed as is\n return (ret = ret && ((<Function>func).call(source, event) !== false));\n } else {\n //either a function or a string can be passed in case of a string we have to wrap it into another function\n //it it is not a plain executable code but a definition\n let sourceCode = trim(<string>func);\n if (sourceCode.indexOf(\"function \") == 0) {\n sourceCode = `return ${sourceCode} (event)`;\n }\n return (ret = ret && (new Function(\"event\", sourceCode).call(source, event) !== false));\n }\n };\n\n //we can use our stream each functionality to run our chain here..\n //the no return value == false stop stream functionality is handled by our resolveAndExecute\n <any>Stream.of(...funcs).each(func => resolveAndExecute(func));\n return ret;\n }\n\n /**\n * this function has to send the ajax requests\n *\n * following request conditions must be met:\n * <ul>\n * <li> the request must be sent asynchronously! </li>\n * <li> the request must be a POST!!! request </li>\n * <li> the request url must be the form action attribute </li>\n * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>\n * </ul>\n *\n * @param el any dom element no matter being it html or jsf, from which the event is emitted\n * @param event any javascript event supported by that object\n * @param opts map of options being pushed into the ajax cycle\n *\n * a) transformArguments out of the function\n * b) passThrough handling with a map copy with a filter map block map\n */\n export function request(el: ElemDef, event?: Event, opts ?: Options) {\n\n const {\n resolvedEvent,\n options,\n elem,\n elementId,\n requestCtx,\n internalCtx,\n windowId,\n isResetValues\n } = resolveDefaults(event, opts, el);\n\n Assertions.assertRequestIntegrity(options, elem);\n\n requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;\n\n requestCtx.assign(CTX_PARAM_PASS_THR).value = filterPassthroughValues(options.value);\n\n requestCtx.assignIf(!!resolvedEvent, CTX_PARAM_PASS_THR, P_EVT).value = resolvedEvent?.type;\n\n /**\n * ajax pass through context with the source\n * onresolvedEvent and onerror\n */\n requestCtx.assign(SOURCE).value = elementId.value;\n\n /**\n * on resolvedEvent and onError...\n * those values will be traversed later on\n * also into the response context\n */\n requestCtx.assign(ON_EVENT).value = options.value?.onevent;\n requestCtx.assign(ON_ERROR).value = options.value?.onerror;\n\n /**\n * lets drag the myfaces config params also in\n */\n requestCtx.assign(MYFACES).value = options.value?.myfaces;\n /**\n * fetch the parent form\n *\n * note we also add an override possibility here\n * so that people can use dummy forms and work\n * with detached objects\n */\n let form: DQ = resolveForm(requestCtx, elem, resolvedEvent);\n\n /**\n * binding contract the javax.faces.source must be set\n */\n requestCtx.assign(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value = elementId.value;\n\n /**\n * javax.faces.partial.ajax must be set to true\n */\n requestCtx.assign(CTX_PARAM_PASS_THR, P_AJAX).value = true;\n\n /**\n * binding contract the javax.faces.source must be set\n */\n requestCtx.assign(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value = elementId.value;\n\n /**\n * if resetValues is set to true\n * then we have to set javax.faces.resetValues as well\n * as pass through parameter\n * the value has to be explicitly true, according to\n * the specs jsdoc\n */\n requestCtx.assignIf(isResetValues, CTX_PARAM_PASS_THR, P_RESET_VALUES).value = true;\n\n //additional meta information to speed things up, note internal non jsf\n //pass through options are stored under _mfInternal in the context\n internalCtx.assign(CTX_PARAM_SRC_FRM_ID).value = form.id.value;\n internalCtx.assign(CTX_PARAM_SRC_CTL_ID).value = elementId.value;\n internalCtx.assign(CTX_PARAM_TR_TYPE).value = REQ_TYPE_POST;\n\n //mojarra compatibility, mojarra is sending the form id as well\n //this is not documented behavior but can be determined by running\n //mojarra under blackbox conditions\n //i assume it does the same as our formId_submit=1 so leaving it out\n //wont hurt but for the sake of compatibility we are going to add it\n\n requestCtx.assign(CTX_PARAM_PASS_THR, form.id.value).value = form.id.value;\n\n assignClientWindowId(form, requestCtx);\n\n assignExecute(options, requestCtx, form, elementId.value);\n assignRender(options, requestCtx, form, elementId.value);\n\n let delay: number = resolveDelay(options);\n let timeout: number = resolveTimeout(options);\n\n //now we enqueue the request as asynchronous runnable into our request\n //queue and let the queue take over the rest\n queueHandler.addRequestToQueue(elem, form, requestCtx, internalCtx, delay, timeout);\n }\n\n /**\n * Spec. 13.3.3\n * Examining the response markup and updating the DOM tree\n * @param {XMLHttpRequest} request - the ajax request\n * @param {Object} context - the ajax context\n */\n export function response(request: XMLHttpRequest, context: Context) {\n Response.processResponse(request, context);\n }\n\n /**\n * adds an error handler to the error queue\n *\n * @param errorListener the error listener handler\n */\n export function addOnError(errorListener: IListener<ErrorData>) {\n /*error handling already done in the assert of the queue*/\n errorQueue.push(errorListener);\n }\n\n /**\n * adds an event handler to the event queue\n *\n * @param eventListener the event listener handler\n */\n export function addOnEvent(eventListener: IListener<EventData>) {\n /*error handling already done in the assert of the queue*/\n eventQueue.push(eventListener);\n }\n\n // noinspection JSUnusedLocalSymbols\n /**\n * sends an event to the event handlers\n *\n * @param data the event data object hosting the event data according to the spec @see EventData for what is reachable\n * @param localHandler an optional event handler, which is processed before the event handler chain\n */\n export function sendEvent(data: EventData, localHandler = function (data: EventData) {\n }) {\n /*now we serve the queue as well*/\n localHandler(data);\n eventQueue.forEach(fn => fn(data));\n }\n\n /**\n * error handler behavior called internally\n * and only into the impl it takes care of the\n * internal message transformation to a myfaces internal error\n * and then uses the standard send error mechanisms\n * also a double error logging prevention is done as well\n *\n * @param request the request currently being processed\n * @param context the context affected by this error\n * @param exception the exception being thrown\n * @param clearRequestQueue if set to true, clears the request queue of all pending requests\n */\n export function stdErrorHandler(request: XMLHttpRequest,\n context: Config,\n exception: any,\n clearRequestQueue = false) {\n //newer browsers do not allow to hold additional values on native objects like exceptions\n //we hence capsule it into the request, which is gced automatically\n //on ie as well, since the stdErrorHandler usually is called between requests\n //this is a valid approach\n try {\n if (threshold == \"ERROR\") {\n let errorData = ErrorData.fromClient(exception);\n sendError(errorData);\n }\n } finally {\n if (clearRequestQueue) {\n requestQueue.cleanup();\n }\n }\n }\n\n // noinspection JSUnusedLocalSymbols\n /**\n * implementation triggering the error chain\n *\n *\n *\n * handles the errors, in case of an onError exists within the context the onError is called as local error handler\n * the registered error handlers in the queue receiv an error message to be dealt with\n * and if the projectStage is at development an alert box is displayed\n *\n * note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided\n * which changes the default output behavior from alert to something else\n *\n * @param errorData the error data to be displayed\n * @param localHandler an optional local error handler which has to be processed before the error handler queue\n */\n export function sendError(errorData: ErrorData, localHandler = function (data: any) {\n }) {\n\n localHandler(errorData);\n errorQueue.forEach((errorCallback: Function) => {\n errorCallback(errorData);\n });\n let displayError: (string) => void = getGlobalConfig(\"defaultErrorOutput\", (console ? console.error : alert));\n displayError(errorData);\n }\n\n /**\n * @node optional element or id defining a rootnode where an element with the id \"javax.faces.windowId\" is hosted\n * @return the client window id of the current window, if one is given if none is found, null is returned\n */\n export function getClientWindow(node ?: Element | string): string | null {\n const ALTERED = \"___mf_id_altered__\";\n const INIT = \"___init____\";\n\n /**\n * the search root for the dom element search\n */\n let searchRoot = new DQ(node || document.body);\n\n /**\n * lazy helper to fetch the window id from the window url\n */\n let fetchWindowIdFromUrl = () => ExtDomquery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;\n\n /**\n * functional double check based on stream reduction\n * the values should be identical or on INIT value which is a premise to\n * skip the first check\n *\n * @param value1\n * @param value2\n */\n let doubleCheck = (value1: string, value2: string) => {\n if (value1 == ALTERED) {\n return value1;\n } else if (value1 == INIT) {\n return value2;\n } else if (value1 != value2) {\n return ALTERED;\n }\n return value2;\n };\n\n /**\n * helper for cleaner code, maps the value from an item\n *\n * @param item\n */\n let getValue = (item: DQ) => item.attr(\"value\").value;\n /**\n * fetch the window id from the forms\n * window ids must be present in all forms\n * or non existent. If they exist all of them must be the same\n */\n let formWindowId: Optional<string> = searchRoot.stream.map<string>(getValue).reduce(doubleCheck, INIT);\n\n //if the resulting window id is set on altered then we have an unresolvable problem\n assert(formWindowId.value != ALTERED, \"Multiple different windowIds found in document\");\n\n /**\n * return the window id or null\n * prio, forms under node/document and if not given then from the url\n */\n return formWindowId.value ?? fetchWindowIdFromUrl();\n }\n\n /**\n * collect and encode data for a given form element (must be of type form)\n * find the javax.faces.ViewState element and encode its value as well!\n * @return a concatenated string of the encoded values!\n *\n * @throws Error in case of the given element not being of type form!\n * https://issues.apache.org/jira/browse/MYFACES-2110\n */\n export function getViewState(form: Element | string): string {\n /**\n * typecheck assert!, we opt for strong typing here\n * because it makes it easier to detect bugs\n */\n\n let element: DQ = DQ.byId(form, true);\n if (!element.isTag(TAG_FORM)) {\n throw new Error(getMessage(\"ERR_VIEWSTATE\"));\n }\n\n let formData = new XhrFormData(element);\n return formData.toString();\n }\n\n /**\n * this at the first sight looks like a weird construct, but we need to do it this way\n * for testing, we cannot proxy addRequestToQueue from the testing frameworks directly\n * but we need to keep it under unit tests.\n */\n export let queueHandler = {\n /**\n * public to make it shimmable for tests\n *\n * adds a new request to our queue for further processing\n */\n addRequestToQueue: function (elem: DQ, form: DQ, reqCtx: Config, respPassThr: Config, delay = 0, timeout = 0) {\n requestQueue = requestQueue ?? new AsynchronouseQueue<XhrRequest>();\n requestQueue.enqueue(new XhrRequest(elem, form, reqCtx, respPassThr, [], timeout), delay);\n }\n };\n\n //----------------------------------------------- Methods ---------------------------------------------------------------------\n\n /**\n * the idea is to replace some placeholder parameters with their respective values\n * placeholder params like @all, @none, @form, @this need to be replaced by\n * the values defined by the specification\n *\n * This function does it for the render parameters\n *\n * @param requestOptions the source options coming in as options object from jsf.ajax.request (options parameter)\n * @param targetContext the receiving target context\n * @param issuingForm the issuing form\n * @param sourceElementId the executing element triggering the jsf.ajax.request (id of it)\n */\n function assignRender(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {\n if (requestOptions.getIf(RENDER).isPresent()) {\n remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_RENDER, <string>requestOptions.getIf(RENDER).value, issuingForm, <any>sourceElementId);\n }\n }\n\n /**\n * the idea is to replace some placeholder parameters with their respective values\n * placeholder params like @all, @none, @form, @this need to be replaced by\n * the values defined by the specification\n *\n * This function does it for the execute parameters\n *\n * @param requestOptions the source options coming in as options object from jsf.ajax.request (options parameter)\n * @param targetContext the receiving target context\n * @param issuingForm the issuing form\n * @param sourceElementId the executing element triggering the jsf.ajax.request (id of it)\n */\n function assignExecute(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {\n\n if (requestOptions.getIf(CTX_PARAM_EXECUTE).isPresent()) {\n /*the options must be a blank delimited list of strings*/\n /*compliance with Mojarra which automatically adds @this to an execute\n * the spec rev 2.0a however states, if none is issued nothing at all should be sent down\n */\n requestOptions.assign(CTX_PARAM_EXECUTE).value = [requestOptions.getIf(CTX_PARAM_EXECUTE).value, IDENT_THIS].join(\" \");\n remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_EXECUTE, <string>requestOptions.getIf(CTX_PARAM_EXECUTE).value, issuingForm, <any>sourceElementId);\n } else {\n targetContext.assign(CTX_PARAM_PASS_THR, P_EXECUTE).value = sourceElementId;\n }\n }\n\n /**\n * apply the browser tab where the request was originating from\n *\n * @param form the form hosting the client window id\n * @param targetContext the target context receiving the value\n */\n function assignClientWindowId(form: DQ, targetContext: Config) {\n let clientWindow = jsf.getClientWindow(form.getAsElem(0).value);\n if (clientWindow) {\n targetContext.assign(CTX_PARAM_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;\n }\n }\n\n /**\n * transforms the user values to the expected one\n * with the proper none all form and this handling\n * (note we also could use a simple string replace but then\n * we would have had double entries under some circumstances)\n *\n * there are several standardized constants which need a special treatment\n * like @all, @none, @form, @this\n *\n * @param targetConfig the target configuration receiving the final values\n * @param targetKey the target key\n * @param userValues the passed user values (aka input string which needs to be transformed)\n * @param issuingForm the form where the issuing element originates\n * @param issuingElementId the issuing element\n */\n function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string): Config {\n //a cleaner implementation of the transform list method\n\n let iterValues = (userValues) ? trim(userValues).split(/\\s+/gi) : [];\n let ret = [];\n let processed = {};\n\n //the idea is simply to loop over all values and then replace\n //their generic values and filter out doubles\n //this is more readable than the old indexed based solution\n //and not really slower because we had to build up the index in our old solution\n //anyway\n for (let cnt = 0; cnt < iterValues.length; cnt++) {\n //avoid doubles\n if (iterValues[cnt] in processed) {\n continue;\n }\n switch (iterValues[cnt]) {\n //@none no values should be sent\n case IDENT_NONE:\n return targetConfig.delete(targetKey);\n //@all is a pass through case according to the spec\n case IDENT_ALL:\n targetConfig.assign(targetKey).value = IDENT_ALL;\n return targetConfig;\n //@form pushes the issuing form id into our list\n case IDENT_FORM:\n ret.push(issuingForm.id.value);\n processed[issuingForm.id.value] = true;\n break;\n //@this is replaced with the current issuing element id\n case IDENT_THIS:\n if (!(issuingElementId in processed)) {\n ret.push(issuingElementId);\n processed[issuingElementId] = true;\n }\n break;\n default:\n ret.push(iterValues[cnt]);\n processed[iterValues[cnt]] = true;\n }\n }\n //We now add the target as joined list\n targetConfig.assign(targetKey).value = ret.join(\" \");\n return targetConfig;\n }\n\n /**\n * filter the options given with a blacklist so that only\n * the values required for passthough land in the ajax request\n *\n * @param mappedOpts the options to be filtered\n */\n function filterPassthroughValues(mappedOpts: { [key: string]: any }) {\n //we now can use the full code reduction given by our stream api\n //to filter\n return Stream.ofAssoc(mappedOpts)\n .filter(item => !(item[0] in BlockFilter))\n .collect(new AssocArrayCollector());\n }\n\n function resolveGlobalConfig(): any {\n return window?.[MYFACES]?.config ?? {};\n }\n\n}\n","import {Config, Lang, XMLQuery} from \"../../ext/monadish\";\n\nimport {DQ} from \"../../ext/monadish\";\nimport {ExtLang} from \"./Lang\";\nimport getMessage = ExtLang.getMessage;\nimport makeException = ExtLang.makeException;\nimport {\n ATTR_URL,\n EMPTY_RESPONSE,\n EMPTY_STR, ERR_NO_PARTIAL_RESPONSE, MALFORMEDXML,\n ON_ERROR,\n ON_EVENT,\n PHASE_PROCESS_RESPONSE,\n RESP_PARTIAL\n} from \"../core/Const\";\n\n/**\n * a set of internal code assertions\n * which raise an error\n *\n */\nexport module Assertions {\n\n export function assertRequestIntegrity(options: Config, elem: DQ): void | never {\n /*assert if the onerror is set and once if it is set it must be of type function*/\n assertFunction(options.getIf(ON_ERROR).value);\n /*assert if the onevent is set and once if it is set it must be of type function*/\n assertFunction(options.getIf(ON_EVENT).value);\n //improve the error messages if an empty elem is passed\n //Assertions.assertElementExists(elem);\n assert(elem.isPresent(), getMessage(\"ERR_MUST_BE_PROVIDED1\", \"{0}: source must be provided or exist\", \"source element id\"), \"jsf.ajax.request\", \"ArgNotSet\", )\n }\n\n export function assertUrlExists(node: XMLQuery): void | never {\n if (node.attr(ATTR_URL).isAbsent()) {\n throw Assertions.raiseError(new Error(), getMessage(\"ERR_RED_URL\", null, \"_Ajaxthis.processRedirect\"), \"processRedirect\");\n }\n }\n\n /**\n * checks the xml for various issues which can occur\n * and prevent a proper processing\n */\n export function assertValidXMLResponse(responseXML: XMLQuery) : void | never {\n assert(!responseXML.isAbsent(), EMPTY_RESPONSE, PHASE_PROCESS_RESPONSE);\n assert(!responseXML.isXMLParserError(), responseXML.parserErrorText(EMPTY_STR), PHASE_PROCESS_RESPONSE);\n assert(responseXML.querySelectorAll(RESP_PARTIAL).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);\n }\n\n /**\n * internal helper which raises an error in the\n * format we need for further processing\n *\n * @param error\n * @param message the message\n * @param caller\n * @param title the title of the error (optional)\n * @param name the name of the error (optional)\n */\n export function raiseError(error: any, message: string, caller ?: string, title ?: string, name ?: string): Error {\n\n let finalTitle = title ?? MALFORMEDXML;\n let finalName = name ?? MALFORMEDXML;\n let finalMessage = message ?? EMPTY_STR;\n\n //TODO clean up the messy makeException, this is a perfect case for encapsulation and sane defaults\n return makeException(error, finalTitle, finalName, \"Response\", caller || (((<any>arguments).caller) ? (<any>arguments).caller.toString() : \"_raiseError\"), finalMessage);\n }\n\n /*\n * using the new typescript 3.7 compiler assertion functionality to improve compiler hinting\n * we are not fully there yet, but soon\n */\n\n export function assert(value: any, msg = EMPTY_STR, caller=EMPTY_STR, title=\"Assertion Error\"): asserts value {\n if(!value) {\n throw Assertions.raiseError(new Error(), msg ,caller, title);\n }\n }\n\n\n export function assertType(value: any, theType: any, msg = EMPTY_STR, caller=EMPTY_STR, title=\"Type Assertion Error\"): asserts value {\n if((!!value) && !Lang.assertType(value,theType)) {\n throw Assertions.raiseError(new Error(), msg ,caller, title);\n }\n }\n\n export function assertFunction(value: any, msg = EMPTY_STR, caller=EMPTY_STR, title=\"Assertion Error\"): asserts value is Function {\n assertType(value, \"function\", msg, caller, title);\n }\n}\n\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Config, DomQuery, DQ} from \"../../ext/monadish\";\nimport {\n CTX_PARAM_DELAY,\n CTX_PARAM_TIMEOUT,\n EMPTY_FUNC,\n EMPTY_STR,\n ENCODED_URL,\n MF_NONE,\n REQ_TYPE_GET,\n REQ_TYPE_POST\n} from \"../core/Const\";\nimport {XhrFormData} from \"./XhrFormData\";\nimport {ExtLang} from \"../util/Lang\";\nimport {ExtDomquery} from \"../util/ExtDomQuery\";\n\n/**\n * Resolver functions for various aspects of the request data\n *\n * stateless because it might be called from various\n * parts of the response classes\n */\n\n/**\n * resolves the event handlers lazly\n * so that if some decoration happens in between we can deal with it\n *\n * @param requestContext\n * @param responseContext\n * @param funcName\n */\nexport function resolveHandlerFunc(requestContext: Config, responseContext: Config, funcName: string) {\n return responseContext.getIf(funcName)\n .orElse(requestContext.getIf(funcName).value)\n .orElse(EMPTY_FUNC).value;\n}\n\nexport function resolveTargetUrl(srcFormElement: HTMLFormElement) {\n return (typeof srcFormElement.elements[ENCODED_URL] == 'undefined') ?\n srcFormElement.action :\n srcFormElement.elements[ENCODED_URL].value;\n}\n\nexport function resolveFinalUrl(sourceForm: DomQuery, formData: XhrFormData, ajaxType = REQ_TYPE_POST) {\n let targetUrl = this.resolveTargetUrl(<HTMLFormElement>sourceForm.getAsElem(0).value);\n\n return targetUrl + (ajaxType == REQ_TYPE_GET ? \"?\" + formData.toString() : EMPTY_STR);\n}\n\n/**\n * form resolution the same way our old implementation did\n * it is either the id or the parent form of the element or an embedded form\n * of the element\n *\n * @param requestCtx\n * @param elem\n * @param event\n */\nexport function resolveForm(requestCtx: Config, elem: DQ, event: Event): DQ {\n const configId = requestCtx.value?.myfaces?.form ?? MF_NONE; //requestCtx.getIf(MYFACES, \"form\").orElse(MF_NONE).value;\n return DQ\n .byId(configId, true)\n .orElseLazy(() => ExtLang.getForm(elem.getAsElem(0).value, event));\n}\n\nexport function resolveTimeout(options: Config): number {\n let getCfg = ExtLang.getLocalOrGlobalConfig;\n return options.getIf(CTX_PARAM_TIMEOUT).value ?? getCfg(options.value, CTX_PARAM_TIMEOUT, 0);\n}\n\n/**\n * resolve the delay from the options and/or the request context and or the configuration\n *\n * @param options ... the options object, in most cases it will host the delay value\n */\nexport function resolveDelay(options: Config): number {\n let getCfg = ExtLang.getLocalOrGlobalConfig;\n\n return options.getIf(CTX_PARAM_DELAY).value ?? getCfg(options.value, CTX_PARAM_DELAY, 0);\n}\n\n/**\n * resolves the window Id from various sources\n *\n * @param options\n */\nexport function resolveWindowId(options: Config) {\n return options?.value?.windowId ?? ExtDomquery.windowId;\n}\n\n/**\n * cross port from the dojo lib\n * browser save event resolution\n * @param evt the event object\n * (with a fallback for ie events if none is present)\n */\nexport function getEventTarget(evt: Event): Element {\n //ie6 and 7 fallback\n let finalEvent = evt;\n /**\n * evt source is defined in the jsf events\n * seems like some component authors use our code\n * so we add it here see also\n * https://issues.apache.org/jira/browse/MYFACES-2458\n * not entirely a bug but makes sense to add this\n * behavior. I dont use it that way but nevertheless it\n * does not break anything so why not\n * */\n let t = finalEvent?.srcElement ?? finalEvent?.target ?? (<any>finalEvent)?.source;\n while ((t) && (t.nodeType != 1)) {\n t = t.parentNode;\n }\n return t;\n}\n\n/**\n * resolves a bunch of default values\n * which can be further processed from the given\n * call parameters of jsf.ajax.request\n *\n * @param event\n * @param opts\n * @param el\n */\nexport function resolveDefaults(event: Event, opts: any = {}, el: Element | string = null) {\n //deep copy the options, so that further transformations to not backfire into the callers\n const resolvedEvent = event,\n options = new Config(opts).deepCopy,\n elem = DQ.byId(el || <Element>resolvedEvent.target, true),\n elementId = elem.id, requestCtx = new Config({}),\n internalCtx = new Config({}), windowId = resolveWindowId(options),\n isResetValues = true === options.value?.resetValues;\n\n return {resolvedEvent, options, elem, elementId, requestCtx, internalCtx, windowId, isResetValues};\n}","import {\n EMPTY_STR,\n ERROR_MESSAGE,\n ERROR_NAME,\n RESPONSE_TEXT,\n RESPONSE_XML,\n SOURCE,\n STATUS,\n UNKNOWN\n} from \"../core/Const\";\nimport {Config} from \"../../ext/monadish\";\n\nimport {EventData} from \"./EventData\";\nimport {ExtLang} from \"../util/Lang\";\nimport getMessage = ExtLang.getMessage;\n\n\nexport enum ErrorType {\n SERVER_ERROR = \"serverError\",\n HTTP_ERROR = \"httpError\",\n CLIENT_ERROR = \"clientErrror\",\n TIMEOUT = \"timeout\"\n}\n\n/**\n * the spec has a problem of having the error\n * object somewhat underspecified, there is no clear\n * description of the required contents.\n * I want to streamline it with mojarra here\n * hence we are going to move\n * everything into the same attributes,\n * I will add deprecated myfaces backwards compatibility attributes as well\n */\nexport class ErrorData extends EventData {\n\n type: string = \"error\";\n source: string;\n errorName: string;\n errorMessage: string;\n\n responseText: string;\n responseXML: any;\n\n status: string;\n typeDetails: ErrorType;\n\n //TODO backwards compatible attributes\n serverErrorName: string;\n serverErrorMessage: string;\n message: string;\n\n constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = \"200\", status: string = \"UNKNOWN\", type = ErrorType.CLIENT_ERROR) {\n super();\n this.source = source;\n this.type = \"error\";\n this.errorName = errorName;\n this.message = this.errorMessage = errorMessage;\n this.responseCode = responseCode;\n this.responseText = responseText;\n this.status = status;\n this.typeDetails = type;\n\n if (type == ErrorType.SERVER_ERROR) {\n this.serverErrorName = this.errorName;\n this.serverErrorMessage = this.errorMessage;\n }\n }\n\n static fromClient(e: Error): ErrorData {\n return new ErrorData(\"client\", e.name, e.message, e.stack);\n }\n\n static fromHttpConnection(source: string, name: string, message: string, responseText, responseCode: number): ErrorData {\n return new ErrorData(source, name, message, responseText, responseCode, null, \"UNKNOWN\", ErrorType.HTTP_ERROR);\n }\n\n static fromGeneric(context: Config, errorCode: number, errorType: ErrorType = ErrorType.SERVER_ERROR): ErrorData {\n\n let getMsg = this.getMsg;\n\n let source = getMsg(context, SOURCE);\n let errorName = getMsg(context, ERROR_NAME);\n let errorMessage = getMsg(context, ERROR_MESSAGE);\n let status = getMsg(context, STATUS);\n let responseText = getMsg(context, RESPONSE_TEXT);\n let responseXML = getMsg(context, RESPONSE_XML);\n return new ErrorData(source, name, errorMessage, responseText, responseXML, errorCode + EMPTY_STR, status, errorType);\n }\n\n private static getMsg(context, param) {\n return getMessage(context.getIf(param).orElse(UNKNOWN).value);\n }\n\n static fromServerError(context: Config): ErrorData {\n return this.fromGeneric(context, -1);\n }\n\n}","import {Config, DQ} from \"../../ext/monadish\";\nimport {BEGIN, CTX_PARAM_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from \"../core/Const\";\n\nexport class EventData {\n type: string;\n status: string;\n source: any;\n responseCode: string;\n responseText: string;\n responseXML: Document;\n\n static createFromRequest(request: XMLHttpRequest, context: Config, /*event name*/ name: string): EventData {\n\n let eventData = new EventData();\n\n eventData.type = EVENT;\n eventData.status = name;\n\n let sourceId: string = context.getIf(SOURCE)\n .orElse(context.getIf(P_PARTIAL_SOURCE).value)\n .orElse(context.getIf(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value).value;\n if (sourceId) {\n eventData.source = DQ.byId(sourceId, true).first().value.value;\n }\n\n if (name !== BEGIN) {\n eventData.responseCode = request?.status?.toString();\n eventData.responseText = request?.responseText;\n eventData.responseXML = request?.responseXML;\n }\n return eventData;\n }\n}\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n///<reference types='../../types/typedefs'/>\n\nimport {Implementation} from \"../impl/AjaxImpl\";\nimport {PushImpl} from \"../impl/PushImpl\";\n\ndeclare type Context = { [key: string]: any };\n\nexport module jsf {\n \"use strict\";\n\n /*\n * Version of the implementation for the jsf.js.\n * <p />\n * as specified within the jsf specifications jsf.html:\n * <ul>\n * <li>left two digits major release number</li>\n * <li>middle two digits minor spec release number</li>\n * <li>right two digits bug release number</li>\n * </ul>\n * @constant\n */\n export var specversion = 220000;\n /**\n * Implementation version as specified within the jsf specification.\n * <p />\n * A number increased with every implementation version\n * and reset by moving to a new spec release number\n *\n * @constant\n */\n export var implversion = 0;\n\n /**\n * SeparatorChar as defined by UINamingContainer.getNamingContainerSeparatorChar()\n * @type {Char}\n */\n export var separatorchar = getSeparatorChar();\n\n /**\n * This method is responsible for the return of a given project stage as defined\n * by the jsf specification.\n * <p/>\n * Valid return values are:\n * <ul>\n * <li>&quot;Production&quot;</li>\n * <li>&quot;Development&quot;</li>\n * <li>&quot;SystemTest&quot;</li>\n * <li>&quot;UnitTest&quot;</li>\n * </li>\n *\n * @return {String} the current project state emitted by the server side method:\n * <i>javax.faces.application.Application.getProjectStage()</i>\n */\n export function getProjectStage(): string {\n return Implementation.getProjectStage();\n }\n\n /**\n * collect and encode data for a given form element (must be of type form)\n * find the javax.faces.ViewState element and encode its value as well!\n * return a concatenated string of the encoded values!\n *\n * @throws an exception in case of the given element not being of type form!\n * https://issues.apache.org/jira/browse/MYFACES-2110\n */\n export function getViewState(formElement: Element | string): string {\n return Implementation.getViewState(formElement);\n }\n\n /**\n * returns the window identifier for the given node / window\n * @return the window identifier or null if none is found\n * @param rootNode\n */\n export function getClientWindow(rootNode?: Element | string): string {\n return Implementation.getClientWindow(rootNode);\n }\n\n //private helper functions\n function getSeparatorChar() {\n return Implementation.getSeparatorChar();\n }\n\n\n export module ajax {\n \"use strict\";\n\n /**\n * this function has to send the ajax requests\n *\n * following requestInternal conditions must be met:\n * <ul>\n * <li> the requestInternal must be sent asynchronously! </li>\n * <li> the requestInternal must be a POST!!! requestInternal </li>\n * <li> the requestInternal url must be the form action attribute </li>\n * <li> all requests must be queued with a client side requestInternal queue to ensure the requestInternal ordering!</li>\n * </ul>\n *\n * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted\n * @param {EVENT} event: any javascript event supported by that object\n * @param {Map} options : map of options being pushed into the ajax cycle\n */\n export function request(element: Element, event?: Event, options?: Context) {\n Implementation.request(element, event, options)\n //Implementation.getInstance().requestInternal(element, event, options);\n }\n\n /**\n * response handler\n * @param request the request object having triggered this response\n * @param context the request context\n *\n * TODO add info on what can be in the context\n */\n export function response(request: XMLHttpRequest, context?: Context) {\n Implementation.response(request, context);\n }\n\n /**\n * Adds an error handler to our global error queue.\n * the error handler must be of the format <i>function errorListener(&lt;errorData&gt;)</i>\n * with errorData being of following format:\n * <ul>\n * <li> errorData.type : &quot;error&quot;</li>\n * <li> errorData.status : the error status message</li>\n * <li> errorData.serverErrorName : the server error name in case of a server error</li>\n * <li> errorData.serverErrorMessage : the server error message in case of a server error</li>\n * <li> errorData.source : the issuing source element which triggered the requestInternal </li>\n * <li> eventData.responseCode: the response code (aka http requestInternal response code, 401 etc...) </li>\n * <li> eventData.responseText: the requestInternal response text </li>\n * <li> eventData.responseXML: the requestInternal response xml </li>\n * </ul>\n *\n * @param {function} errorListener error handler must be of the format <i>function errorListener(&lt;errorData&gt;)</i>\n */\n export function addOnError(errorFunc: (data: ErrorData) => void) {\n Implementation.addOnError(<any>errorFunc);\n }\n\n /**\n * Adds a global event listener to the ajax event queue. The event listener must be a function\n * of following format: <i>function eventListener(&lt;eventData&gt;)</i>\n *\n * @param {function} eventListener event must be of the format <i>function eventListener(&lt;eventData&gt;)</i>\n */\n export function addOnEvent(eventFunc: (data: EventData) => void) {\n Implementation.addOnEvent(<any>eventFunc);\n }\n }\n\n export module util {\n\n /**\n * varargs function which executes a chain of code (functions or any other code)\n *\n * if any of the code returns false, the execution\n * is terminated prematurely skipping the rest of the code!\n *\n * @param {DomNode} source, the callee object\n * @param {Event} event, the event object of the callee event triggering this function\n * @param funcs ... arbitrary array of functions or strings\n * @returns true if the chain has succeeded false otherwise\n */\n export function chain(source, event, ...funcs: Array<Function | string>): boolean {\n return Implementation.chain(source, event, ...funcs);\n }\n }\n\n export module push {\n /**\n * @param {function} onopen The function to be invoked when the web socket is opened.\n * @param {function} onmessage The function to be invoked when a message is received.\n * @param {function} onclose The function to be invoked when the web socket is closed.\n * @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.\n */\n export function init(socketClientId: string,\n uri: string,\n channel: string,\n onopen: Function,\n onmessage: Function,\n onclose: Function,\n behaviorScripts: any,\n autoconnect: boolean) {\n PushImpl.init(socketClientId, uri, channel, onopen, onmessage, onclose, behaviorScripts, autoconnect);\n }\n\n /**\n * Open the web socket on the given channel.\n * @param {string} channel The name of the web socket channel.\n * @throws {Error} When channel is unknown.\n */\n export function open(socketClientId: string) {\n PushImpl.open(socketClientId);\n }\n\n /**\n * Close the web socket on the given channel.\n * @param {string} channel The name of the web socket channel.\n * @throws {Error} When channel is unknown.\n */\n export function close(socketClientId: string) {\n PushImpl.close(socketClientId);\n }\n\n }\n\n //We hook the old namespace system into our npm system\n //if (\"undefined\" == window.jsf) {\n // window.jsf = jsf;\n //}\n\n\n}\n\n\n\n//fullfill the window contract\nexport module myfaces {\n\n /**\n * AB function similar to mojarra and Primefaces\n * not part of the spec but a convenience accessor method\n * Code provided by Thomas Andraschko\n *\n * @param source the event source\n * @param event the event\n * @param eventName event name for java.javax.faces.behavior.evemnt\n * @param execute execute list as passed down in jsf.ajax.request\n * @param render\n * @param options\n */\n export function ab(source: Element, event: Event, eventName: string, execute: string, render: string, options: Context = {}) {\n if (eventName) {\n options[\"javax.faces.behavior.event\"] = eventName;\n }\n if (execute) {\n options[\"execute\"] = execute;\n }\n if (render) {\n options[\"render\"] = render;\n }\n\n jsf.ajax.request(source, event, options);\n }\n}\n\n\n","import {Config, IValueHolder, Optional} from \"../../ext/monadish/Monad\";\nimport {DomQuery, DQ} from \"../../ext/monadish/DomQuery\";\nimport {EMPTY_STR, P_WINDOW_ID} from \"../core/Const\";\n\ndeclare let window: any;\n\n/**\n * Extension which adds implementation specific\n * meta data to our dom qury\n *\n * Usage\n * el = new ExtDQ(oldReference)\n * nonce = el.nonce\n * windowId = el.getWindowId\n */\nexport class ExtDomquery extends DQ {\n\n static get windowId() {\n return new ExtDomquery(document.body).windowId;\n }\n\n static get nonce(): string {\n return new ExtDomquery(document.body).nonce;\n }\n\n get windowId(): string | null {\n\n const fetchWindowIdFromURL = function (): string | null {\n let href = window.location.href;\n let windowId = \"windowId\";\n let regex = new RegExp(\"[\\\\?&]\" + windowId + \"=([^&#\\\\;]*)\");\n let results = regex.exec(href);\n //initial trial over the url and a regexp\n if (results != null) return results[1];\n return null;\n };\n\n //byId ($)\n if (this.value.isPresent()) {\n let result = this.querySelectorAll(\"form input[name='\" + P_WINDOW_ID + \"']\");\n if (result.length > 0) {\n throw Error(\"Multiple different windowIds found in document\");\n }\n\n return (result.isPresent()) ? (<HTMLInputElement>result.getAsElem(0).value).value : fetchWindowIdFromURL();\n } else {\n return fetchWindowIdFromURL();\n }\n }\n\n /*\n determines the jsfjs nonce and adds them to the namespace\n * this is done once and only lazily\n */\n get nonce(): string {\n //already processed\n let myfacesConfig = new Config(window.myfaces);\n let nonce: IValueHolder<string> = myfacesConfig.assign(\"config\", \"cspMeta\", \"nonce\");\n if (nonce.value) {\n return <string>nonce.value;\n }\n\n let curScript = new DQ(document.currentScript);\n //since our baseline atm is ie11 we cannot use document.currentScript globally\n if (curScript.attr(\"nonce\").value != null) {\n //fastpath for modern browsers\n return curScript.attr(\"nonce\").value;\n }\n\n let nonceScript = DQ\n .querySelectorAll(\"script[src], link[src]\")\n .lazyStream\n .filter((item) => item.attr(\"nonce\").value != null && item.attr(\"src\") != null)\n .map((item => !item.attr(\"src\").value.match(/jsf\\.js\\?ln=javax\\.faces/gi)))\n .first();\n\n if (nonceScript.isPresent()) {\n nonce.value = DomQuery.byId(nonceScript.value, true).attr(\"nonce\").value;\n }\n return <string>nonce.value;\n }\n\n static searchJsfJsFor(item: RegExp): Optional<String> {\n return new ExtDomquery(document).searchJsfJsFor(item);\n }\n\n searchJsfJsFor(rexp: RegExp): Optional<string> {\n //perfect application for lazy stream\n return DQ.querySelectorAll(\"script\").lazyStream\n .filter(item => {\n return (item.attr(\"src\").value ?? EMPTY_STR).search(/\\/javax\\.faces\\.resource.*\\/jsf\\.js.*separator/) != -1;\n }).map((item: DQ) => {\n let result = item.attr(\"src\").value.match(rexp);\n return decodeURIComponent(result[1]);\n }).first();\n }\n\n globalEval(code: string, nonce ?: string): DQ {\n return super.globalEval(code, nonce ?? this.nonce);\n }\n}\n\nexport const ExtDQ = DQ;","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {ArrayCollector, Config, DomQuery, Lang, LazyStream} from \"../../ext/monadish\";\n\nimport {Stream} from \"../../ext/monadish\";\nimport {DQ} from \"../../ext/monadish\";\nimport isString = Lang.isString;\nimport {EMPTY_STR, P_VIEWSTATE} from \"../core/Const\";\n\n\n/**\n * A unified form data class\n * which builds upon our configuration.\n *\n * We cannot use standard html5 forms everywhere\n * due to api constraints on the HTML Form object in IE11\n * and due to the url encoding constraint given by the jsf.js spec\n */\nexport class XhrFormData extends Config {\n\n private fileInputs = {};\n\n /**\n * data collector from a given form\n *\n * @param dataSource either a form as DomQuery object or an encoded url string\n * @param partialIdsArray partial ids to collect, to reduce the data sent down\n */\n constructor(private dataSource: DQ | string, private partialIdsArray?: string[], private encode = true) {\n super({});\n //a call to getViewState before must pass the encoded line\n //a call from getViewState passes the form element as datasource\n //so we have two call points\n if (isString(dataSource)) {\n this.assignEncodedString(<string>this.dataSource);\n } else {\n this.handleFormSource();\n }\n }\n\n /**\n * generic application of ids\n * @param executes\n */\n applyFileInputs(...executes: Array<string>) {\n LazyStream.of(...executes).map(id => {\n if (id == \"@all\") {\n return DomQuery.querySelectorAll(\"input[type='file']\");\n } else if (id == \"@form\") {\n return (<DQ>this.dataSource).querySelectorAllDeep(\"input[type='file']\");\n } else {\n let element = DomQuery.byId(id, true);\n return this.getFileInputs(element);\n }\n })\n .filter(item => {\n return !!item.length;\n })\n .each(item => {\n this.fileInputs[item.id.value] = true;\n });\n }\n\n private getFileInputs(rootElment: DomQuery): DomQuery {\n let ret = rootElment.lazyStream.map(item => {\n if (item.length == 0) {\n return null;\n }\n if (item.length == 1) {\n if ((<string>item.tagName.get(\"booga\").value).toLowerCase() == \"input\" &&\n (<string>item.attr(\"type\")?.value || '').toLowerCase() == \"file\") {\n return item;\n }\n\n return rootElment.querySelectorAllDeep(\"input[type='file']\").firstElem().getAsElem(0).value;\n }\n return this.getFileInputs(item);\n }).filter(item => {\n return item != null;\n }).collect(new ArrayCollector());\n\n return new DomQuery(...ret);\n }\n\n\n private handleFormSource() {\n //encode and append the issuing item if not a partial ids array of ids is passed\n /*\n * Spec. 13.3.1\n * Collect and encode input elements.\n * Additionally the hidden element javax.faces.ViewState\n * Enhancement partial page submit\n *\n */\n this.encodeSubmittableFields(this, <DQ>this.dataSource, this.partialIdsArray);\n\n if (this.getIf(P_VIEWSTATE).isPresent()) {\n return;\n }\n\n this.applyViewState(<DQ>this.dataSource);\n }\n\n /**\n * special case viewstate handling\n *\n * @param form the form holding the viewstate value\n */\n private applyViewState(form: DQ) {\n let viewState = form.byId(P_VIEWSTATE, true).inputValue;\n this.appendIf(viewState.isPresent(), P_VIEWSTATE).value = viewState.value;\n }\n\n /**\n * assignes a url encoded string to this xhrFormData object\n * as key value entry\n * @param encoded\n */\n assignEncodedString(encoded: string) {\n let keyValueEntries = decodeURIComponent(encoded).split(/&/gi);\n this.assignString(keyValueEntries);\n }\n\n assignString(keyValueEntries: string[]) {\n let toMerge = new Config({});\n\n Stream.of(...keyValueEntries)\n //split only the first =\n .map(line => line.split(/=(.*)/gi))\n //special case of having keys without values\n .map(keyVal => keyVal.length < 3 ? [keyVal?.[0] ?? [], keyVal?.[1] ?? []] : keyVal)\n .each(keyVal => {\n toMerge.append(keyVal[0]).value = keyVal?.splice(1)?.join(\"\") ?? \"\";\n });\n //merge with overwrite but no append! (aka no double entries are allowed)\n this.shallowMerge(toMerge);\n }\n\n// noinspection JSUnusedGlobalSymbols\n /**\n * @returns a Form data representation\n */\n toFormData(): FormData {\n let ret: any = new FormData();\n\n Stream.of(...Object.keys(this.value))\n .filter(key => !(key in this.fileInputs))\n .each(key => {\n Stream.of(...this.value[key]).each(item => ret.append(key, item));\n });\n Stream.of<string>(...Object.keys(this.fileInputs)).each((key: string) => {\n DomQuery.byId(key, true).eachElem((elem: HTMLInputElement) => {\n let identifier = this.resolveSubmitIdentifier(elem);\n if (!elem?.files?.length) {\n ret.append(identifier, elem.value);\n return;\n }\n\n ret.append(identifier, elem.files[0]);\n })\n });\n return ret;\n }\n\n resolveSubmitIdentifier(elem: HTMLInputElement) {\n let identifier = elem.name;\n identifier = ((elem?.name ?? \"\").replace(/s+/gi,\"\") == \"\") ? elem.id : identifier;\n return identifier;\n }\n\n /**\n * returns an encoded string representation of our xhr form data\n *\n * @param defaultStr optional default value if nothing is there to encode\n */\n toString(defaultStr = EMPTY_STR): string {\n if (this.isAbsent()) {\n return defaultStr;\n }\n let entries = Stream.of(...Object.keys(this.value))\n .filter(key => this.value.hasOwnProperty(key))\n .flatMap(key => Stream.of(...this.value[key]).map(val => [key, val]).collect(new ArrayCollector()))\n .map(keyVal => {\n return `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;\n })\n .collect(new ArrayCollector());\n\n return entries.join(\"&\")\n }\n\n /**\n * determines fields to submit\n * @param {Object} targetBuf - the target form buffer receiving the data\n * @param {Node} parentItem - form element item is nested in\n * @param {Array} partialIds - ids fo PPS\n */\n private encodeSubmittableFields(targetBuf: Config,\n parentItem: DQ, partialIds ?: string[]) {\n let toEncode = null;\n if (this.partialIdsArray && this.partialIdsArray.length) {\n //in case of our myfaces reduced ppr we only\n //only submit the partials\n this._value = {};\n toEncode = new DQ(...this.partialIdsArray);\n\n } else {\n if (parentItem.isAbsent()) throw \"NO_PARITEM\";\n toEncode = parentItem;\n }\n\n //lets encode the form elements\n\n this.shallowMerge(toEncode.deepElements.encodeFormElement());\n }\n\n /**\n * checks if the given datasource is a multipart request source\n * multipart is only needed if one of the executes is a file input\n * since file inputs are stateless, they fall out of the viewstate\n * and need special handling\n */\n get isMultipartRequest(): boolean {\n return !!Object.keys(this.fileInputs).length;\n }\n\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Config, DQ, XMLQuery} from \"../../ext/monadish\";\nimport {ResponseProcessor} from \"./ResponseProcessor\";\n\nimport {IResponseProcessor} from \"./IResponseProcessor\";\nimport {\n CMD_ATTRIBUTES,\n CMD_CHANGES,\n CMD_DELETE,\n CMD_ERROR,\n CMD_EVAL,\n CMD_EXTENSION,\n CMD_INSERT,\n CMD_REDIRECT,\n CMD_UPDATE,\n P_VIEWBODY,\n P_VIEWHEAD,\n P_VIEWROOT,\n PARTIAL_ID,\n RESP_PARTIAL,\n RESPONSE_XML,\n TAG_AFTER,\n TAG_BEFORE\n} from \"../core/Const\";\nimport {resolveContexts, resolveResponseXML} from \"./ResonseDataResolver\";\n\n\nexport module Response {\n\n\n /**\n * Standardized jsf.js response\n * this one is called straight from jsf.js.response\n *\n * The processing follows the spec by going for the responseXML\n * and processing its tags\n *\n * @param {XMLHttpRequest} request (xhrRequest) - xhr request object\n * @param {[key: string]: any} context (Map) - AJAX context\n *\n */\n export function processResponse(request: XMLHttpRequest, context: { [key: string]: any }) {\n\n let req = Config.fromNullable(request);\n let {externalContext, internalContext} = resolveContexts(context);\n let responseXML: XMLQuery = resolveResponseXML(req);\n let responseProcessor = new ResponseProcessor(req, externalContext, internalContext);\n\n internalContext.assign(RESPONSE_XML).value = responseXML;\n\n //we now process the partial tags, or in none given raise an error\n responseXML.querySelectorAll(RESP_PARTIAL)\n .each(item => processPartialTag(<XMLQuery>item, responseProcessor, internalContext));\n\n //we now process the viewstates and the evals deferred\n //the reason for this is that often it is better\n //to wait until the document has caught up before\n //doing any evals even on embedded scripts\n responseProcessor.fixViewStates();\n responseProcessor.globalEval();\n\n responseProcessor.done();\n }\n\n /**\n * highest node partial-response from there the main operations are triggered\n */\n function processPartialTag(node: XMLQuery, responseProcessor: IResponseProcessor, internalContext) {\n\n internalContext.assign(PARTIAL_ID).value = node.id;\n const SEL_SUB_TAGS = [CMD_ERROR, CMD_REDIRECT, CMD_CHANGES].join(\",\");\n\n //now we can process the main operations\n node.getIf(SEL_SUB_TAGS).each((node: XMLQuery) => {\n switch (node.tagName.value) {\n case CMD_ERROR:\n responseProcessor.error(node);\n break;\n case CMD_REDIRECT:\n responseProcessor.redirect(node);\n break;\n case CMD_CHANGES:\n processChangesTag(node, responseProcessor);\n break;\n }\n });\n\n }\n\n let processInsert = function (responseProcessor: IResponseProcessor, node: XMLQuery) {\n //path1 insert after as child tags\n if(node.querySelectorAll([TAG_BEFORE, TAG_AFTER].join(\",\")).length) {\n responseProcessor.insertWithSubtags(node);\n } else { //insert before after with id\n responseProcessor.insert(node);\n }\n\n };\n\n /**\n * next level changes tag\n *\n * @param node\n * @param responseProcessor\n */\n function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {\n const ALLOWED_TAGS = [CMD_UPDATE, CMD_EVAL, CMD_INSERT, CMD_DELETE, CMD_ATTRIBUTES, CMD_EXTENSION].join(\",\");\n node.getIf(ALLOWED_TAGS).each(\n (node: XMLQuery) => {\n switch (node.tagName.value) {\n case CMD_UPDATE:\n processUpdateTag(node, responseProcessor);\n break;\n\n case CMD_EVAL:\n responseProcessor.eval(node);\n break;\n\n case CMD_INSERT:\n processInsert(responseProcessor, node);\n break;\n\n case CMD_DELETE:\n responseProcessor.delete(node);\n break;\n\n case CMD_ATTRIBUTES:\n responseProcessor.attributes(node);\n break;\n\n case CMD_EXTENSION:\n break;\n }\n }\n );\n return true;\n }\n\n /**\n * branch tag update.. drill further down into the updates\n * special case viewstate in that case it is a leaf\n * and the viewstate must be processed\n *\n * @param node\n * @param responseProcessor\n */\n function processUpdateTag(node: XMLQuery, responseProcessor: IResponseProcessor) {\n if (!responseProcessor.processViewState(node)) {\n handleElementUpdate(node, responseProcessor);\n }\n }\n\n /**\n * element update\n *\n * @param node\n * @param responseProcessor\n */\n function handleElementUpdate(node: XMLQuery, responseProcessor: IResponseProcessor) {\n let cdataBlock = node.cDATAAsString;\n switch (node.id.value) {\n case P_VIEWROOT :\n responseProcessor.replaceViewRoot(DQ.fromMarkup(cdataBlock.substring(cdataBlock.indexOf(\"<html\"))));\n break;\n\n case P_VIEWHEAD:\n responseProcessor.replaceHead(DQ.fromMarkup(cdataBlock));\n break;\n\n case P_VIEWBODY:\n responseProcessor.replaceBody(DQ.fromMarkup(cdataBlock));\n break;\n\n default://htmlItem replacement\n responseProcessor.update(node, cdataBlock);\n break;\n\n }\n }\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Lang} from \"./Lang\";\nimport {DomQuery} from \"./DomQuery\";\nimport isString = Lang.isString;\n\ndeclare let ActiveXObject: any;\n\n/**\n * xml query as specialized case for DomQuery\n */\nexport class XMLQuery extends DomQuery {\n\n constructor(rootNode: Document | string | DomQuery, docType: SupportedType = \"text/xml\") {\n\n\n let createIe11DomQueryShim = (): DOMParser => {\n //at the time if wroting ie11 is the only relevant browser\n //left withut any DomQuery support\n let parser = new ActiveXObject(\"Microsoft.XMLDOM\");\n parser.async = false;\n //we shim th dom parser from ie in\n return <any> {\n parseFromString: (text: string, contentType: string): Document => {\n return parser.loadXML(text);\n }\n }\n };\n\n let parseXML = (xml: string): Document => {\n if(xml == null) {\n return null;\n }\n let domParser: DOMParser = Lang.saveResolveLazy<DOMParser>(\n () => new window.DOMParser(),\n (): DOMParser => createIe11DomQueryShim()\n ).value;\n return domParser.parseFromString(xml, docType);\n };\n\n if(isString(rootNode)) {\n super(parseXML(<string>rootNode))\n } else {\n super(rootNode);\n }\n }\n\n\n isXMLParserError(): boolean {\n return this.querySelectorAll(\"parsererror\").isPresent();\n }\n\n\n\n toString(): string {\n let ret = [];\n this.eachElem((node: any) => {\n let serialized = (<any>window)?.XMLSerializer?.constructor()?.serializeToString(node) ?? node?.xml;\n if(!!serialized) {\n ret.push(serialized);\n }\n });\n return ret.join(\"\");\n }\n\n\n parserErrorText(joinstr: string): string {\n return this.querySelectorAll(\"parsererror\").textContent(joinstr);\n }\n\n static parseXML(txt: string): XMLQuery {\n return new XMLQuery(txt);\n }\n static parseHTML(txt: string): XMLQuery {\n return new XMLQuery(txt, \"text/html\");\n }\n\n static fromString(txt: string, parseType: SupportedType = \"text/xml\"): XMLQuery {\n return new XMLQuery(txt,parseType);\n }\n}\n\nexport const XQ = XMLQuery;\nexport type XQ = XMLQuery;","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Config, DomQuery, DQ, Lang, Stream, XMLQuery} from \"../../ext/monadish\";\nimport {Implementation} from \"../AjaxImpl\";\nimport {Assertions} from \"../util/Assertions\";\nimport {IResponseProcessor} from \"./IResponseProcessor\";\nimport {ErrorData} from \"./ErrorData\";\nimport {ExtLang} from \"../util/Lang\";\n\nimport {ViewState} from \"../core/ImplTypes\";\nimport {EventData} from \"./EventData\";\nimport {\n APPLIED_VST,\n ATTR_ID,\n ATTR_NAME,\n ATTR_URL,\n ATTR_VALUE,\n EMPTY_FUNC,\n EMPTY_STR,\n ERROR_MESSAGE,\n ERROR_NAME,\n HTML_VIEWSTATE,\n ON_ERROR,\n ON_EVENT,\n P_PARTIAL_SOURCE,\n P_VIEWSTATE,\n RESPONSE_XML,\n SEL_SCRIPTS_STYLES,\n SEL_VIEWSTATE_ELEM,\n SOURCE,\n SUCCESS,\n TAG_AFTER,\n TAG_ATTR,\n TAG_BEFORE,\n TAG_BODY,\n TAG_FORM,\n TAG_HEAD,\n UPDATE_ELEMS,\n UPDATE_FORMS\n} from \"../core/Const\";\nimport trim = Lang.trim;\n\n/**\n * Response processor\n *\n * Each XML tag is either a node or a leaf\n * or both\n *\n * the processor provides a set of operations\n * which are executed on a single leaf node per operation\n * and present the core functionality of our response\n *\n * Note the response processor is stateful hence we bundle it in a class\n * to reduce code we keep references tot contexts in place\n */\nexport class ResponseProcessor implements IResponseProcessor {\n\n constructor(private request: Config, private externalContext: Config, private internalContext: Config) {\n\n }\n\n replaceHead(shadowDocument: XMLQuery | DQ) {\n let shadowHead = shadowDocument.querySelectorAll(TAG_HEAD);\n if (!shadowHead.isPresent()) {\n return;\n }\n\n let oldHead = DQ.querySelectorAll(TAG_HEAD);\n\n //delete all to avoid script and style overlays\n oldHead.querySelectorAll(SEL_SCRIPTS_STYLES).delete();\n\n this.storeForEval(shadowHead);\n }\n\n /**\n * replaces the body in the expected manner\n * which means the entire body content is refreshed\n * however also the body attributes must be transferred\n * keeping event handlers etc... in place\n *\n * @param shadowDocument .. an incoming shadow document hosting the new nodes\n */\n replaceBody(shadowDocument: XMLQuery | DQ) {\n\n let shadowBody = shadowDocument.querySelectorAll(TAG_BODY);\n if (!shadowBody.isPresent()) {\n return;\n }\n\n let shadowInnerHTML: string = <string>shadowBody.html().value;\n\n let resultingBody = <DQ>DQ.querySelectorAll(TAG_BODY).html(shadowInnerHTML);\n let updateForms = resultingBody.querySelectorAll(TAG_FORM);\n\n resultingBody.copyAttrs(shadowBody);\n\n this.storeForPostProcessing(updateForms, resultingBody);\n }\n\n /**\n * Leaf Tag eval... process whatever is in the evals cdata block\n *\n * @param node the node to eval\n */\n eval(node: XMLQuery) {\n DQ.globalEval(node.cDATAAsString);\n }\n\n /**\n * processes an incoming error from the response\n * which is hosted under the &lt;error&gt; tag\n * @param node the node hosting the error in our response xml\n * @param node the node in the xml hosting the error message\n */\n error(node: XMLQuery) {\n /**\n * <error>\n * <error-name>String</error-name>\n * <error-message><![CDATA[message]]></error-message>\n * <error>\n */\n\n let mergedErrorData = new Config({});\n mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;\n mergedErrorData.assign(ERROR_NAME).value = node.getIf(ERROR_NAME).textContent(EMPTY_STR);\n mergedErrorData.assign(ERROR_MESSAGE).value = node.getIf(ERROR_MESSAGE).cDATAAsString;\n\n let hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();\n mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;\n\n let errorData = ErrorData.fromServerError(mergedErrorData);\n\n this.externalContext.getIf(ON_ERROR).orElse(this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);\n Implementation.sendError(errorData);\n }\n\n /**\n * process the redirect operation\n *\n * @param node\n */\n redirect(node: XMLQuery) {\n Assertions.assertUrlExists(node);\n\n let redirectUrl = trim(node.attr(ATTR_URL).value);\n if (redirectUrl != EMPTY_STR) {\n (<any>window).location.href = redirectUrl;\n }\n }\n\n /**\n * processes the update operation and updates the node with the cdata block\n * @param node the xml response node hosting the update info\n * @param cdataBlock the cdata block with the new html code\n */\n update(node: XMLQuery, cdataBlock: string) {\n let result = DQ.byId(node.id.value, true).outerHTML(cdataBlock, false, false);\n let sourceForm = result?.parents(TAG_FORM).orElse(result.byTagName(TAG_FORM, true));\n if (sourceForm) {\n this.storeForPostProcessing(sourceForm, result);\n }\n }\n\n delete(node: XMLQuery) {\n DQ.byId(node.id.value, true).delete();\n }\n\n /**\n * attributes leaf tag... process the attributes\n *\n * @param node\n */\n attributes(node: XMLQuery) {\n let elem = DQ.byId(node.id.value, true);\n\n node.byTagName(TAG_ATTR).each((item: XMLQuery) => {\n elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;\n });\n }\n\n /**\n * @param shadowDocument a shadow document which is needed for further processing\n */\n replaceViewRoot(shadowDocument: XMLQuery) {\n this.replaceHead(shadowDocument);\n this.replaceBody(shadowDocument);\n }\n\n /**\n * insert handling, either before or after\n *\n * @param node\n */\n insert(node: XMLQuery) {\n //let insertId = node.id; //not used atm\n\n let before = node.attr(TAG_BEFORE);\n let after = node.attr(TAG_AFTER);\n\n let insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);\n\n if (before.isPresent()) {\n DQ.byId(before.value, true).insertBefore(insertNodes);\n this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);\n }\n if (after.isPresent()) {\n let domQuery = DQ.byId(after.value, true);\n domQuery.insertAfter(insertNodes);\n\n this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);\n }\n }\n\n /**\n * handler for the case &lt;insert <&lt; before id=\"...\n *\n * @param node the node hosting the insert data\n */\n insertWithSubtags(node: XMLQuery) {\n let before = node.querySelectorAll(TAG_BEFORE);\n let after = node.querySelectorAll(TAG_AFTER);\n\n before.each(item => {\n let insertId = item.attr(ATTR_ID);\n let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);\n if (insertId.isPresent()) {\n DQ.byId(insertId.value, true).insertBefore(insertNodes);\n this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);\n }\n });\n\n after.each(item => {\n let insertId = item.attr(ATTR_ID);\n let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);\n if (insertId.isPresent()) {\n DQ.byId(insertId.value, true).insertAfter(insertNodes);\n this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);\n }\n });\n }\n\n /**\n * process the viewState update, update the affected\n * forms with their respective new viewstate values\n *\n */\n processViewState(node: XMLQuery): boolean {\n if (ResponseProcessor.isViewStateNode(node)) {\n let viewStateValue = node.cDATAAsString;\n this.internalContext.assign(APPLIED_VST, node.id.value).value = new ViewState(node.id.value, viewStateValue);\n return true;\n }\n return false;\n }\n\n /**\n * generic global eval which runs the embedded css and scripts\n */\n globalEval() {\n let updateElems = new DQ(...this.internalContext.getIf(UPDATE_ELEMS).value);\n updateElems.runCss();\n updateElems.runScripts();\n }\n\n /**\n * post processing viewstate fixing\n */\n fixViewStates() {\n Stream.ofAssoc<ViewState>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)\n .each((item: Array<any>) => {\n let value: ViewState = item[1];\n let nameSpace = DQ.byId(value.nameSpace, true).orElse(document.body);\n let affectedForms = nameSpace.byTagName(TAG_FORM);\n let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);\n\n this.appendViewStateToForms(new DomQuery(affectedForms, affectedForms2), value.value);\n });\n }\n\n /**\n * all processing done we can close the request and send the appropriate events\n */\n done() {\n let eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);\n\n //because some frameworks might decorate them over the context in the response\n let eventHandler = this.externalContext.getIf(ON_EVENT).orElse(this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;\n Implementation.sendEvent(eventData, eventHandler);\n }\n\n /**\n * proper viewstate -> form assignment\n *\n * @param forms the forms to append the viewstate to\n * @param viewState the final viewstate\n */\n private appendViewStateToForms(forms: DQ, viewState: string) {\n forms.each((form: DQ) => {\n let viewStateElems = form.querySelectorAll(SEL_VIEWSTATE_ELEM)\n .orElseLazy(() => ResponseProcessor.newViewStateElement(form));\n\n viewStateElems.attr(\"value\").value = viewState;\n });\n }\n\n /**\n * Helper to Create a new JSF ViewState Element\n *\n * @param parent, the parent node to attach the viewstate element to\n * (usually a form node)\n */\n private static newViewStateElement(parent: DQ): DQ {\n let newViewState = DQ.fromMarkup(HTML_VIEWSTATE);\n newViewState.appendTo(parent);\n return newViewState;\n }\n\n /**\n * Stores certain aspects of the dom for later post processing\n *\n * @param updateForms the update forms which should receive standardized internal jsf data\n * @param toBeEvaled the resulting elements which should be evaled\n */\n private storeForPostProcessing(updateForms: DQ, toBeEvaled: DQ) {\n this.storeForUpdate(updateForms);\n this.storeForEval(toBeEvaled);\n }\n\n /**\n * helper to store a given form for the update post processing (viewstate)\n *\n * @param updateForms the dom query object pointing to the forms which need to be updated\n */\n private storeForUpdate(updateForms: DQ) {\n this.internalContext.assign(UPDATE_FORMS).value.push(updateForms);\n }\n\n /**\n * same for eval (js and css)\n *\n * @param toBeEvaled\n */\n private storeForEval(toBeEvaled: DQ) {\n this.internalContext.assign(UPDATE_ELEMS).value.push(toBeEvaled);\n }\n\n /**\n * check whether a given XMLQuery node is an explicit viewstate node\n *\n * @param node the node to check\n * @returns true of it ii\n */\n private static isViewStateNode(node: XMLQuery): boolean {\n let separatorChar = (<any>window).jsf.separatorchar;\n return \"undefined\" != typeof node?.id?.value && (node?.id?.value == P_VIEWSTATE ||\n node?.id?.value?.indexOf([separatorChar, P_VIEWSTATE].join(EMPTY_STR)) != -1 ||\n node?.id?.value?.indexOf([P_VIEWSTATE, separatorChar].join(EMPTY_STR)) != -1);\n }\n\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class Messages {\n MSG_TEST = \"Testmessage\";\n\n /*Messages*/\n /** @constant */\n MSG_DEV_MODE = \"Note, this message is only sent, because project stage is development and no \" +\n \"other error listeners are registered.\";\n /** @constant */\n MSG_AFFECTED_CLASS = \"Affected Class=\";\n /** @constant */\n MSG_AFFECTED_METHOD = \"Affected Method=\";\n /** @constant */\n MSG_ERROR_NAME = \"Error Name=\";\n /** @constant */\n MSG_ERROR_MESSAGE = \"Error Message=\";\n /** @constant */\n MSG_SERVER_ERROR_NAME = \"Server Error Name=\";\n\n /** @constant */\n MSG_ERROR_DESC = \"Error Description=\";\n /** @constant */\n MSG_ERROR_NO = \"Error Number=\";\n /** @constant */\n MSG_ERROR_LINENO = \"Error Line Number=\";\n\n /*Errors and messages*/\n /** @constant */\n 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\";\n /** @constant */\n ERR_VIEWSTATE = \"jsf.viewState= param value not of type form!\";\n /** @constant */\n ERR_TRANSPORT = \"Transport type {0} does not exist\";\n /** @constant */\n ERR_EVT_PASS = \"an event must be passed down (either a an event object null or undefined) \";\n /** @constant */\n ERR_CONSTRUCT = \"Parts of the response couldn't be retrieved when constructing the event data= {0} \";\n /** @constant */\n ERR_MALFORMEDXML = \"The server response could not be parsed, the server has returned with a response which is not xml !\";\n /** @constant */\n ERR_SOURCE_FUNC = \"source cannot be a function (probably source and event were not defined or set to null\";\n /** @constant */\n ERR_EV_OR_UNKNOWN = \"An event object or unknown must be passed as second parameter\";\n /** @constant */\n ERR_SOURCE_NOSTR = \"source cannot be a string\";\n /** @constant */\n ERR_SOURCE_DEF_NULL = \"source must be defined or null\";\n\n //_Lang.js\n /** @constant */\n ERR_MUST_STRING = \"{0}: {1} namespace must be of type String\";\n /** @constant */\n ERR_REF_OR_ID = \"{0}: {1} a reference node or identifier must be provided\";\n /** @constant */\n ERR_PARAM_GENERIC = \"{0}: parameter {1} must be of type {2}\";\n /** @constant */\n ERR_PARAM_STR = \"{0}: {1} param must be of type string\";\n /** @constant */\n ERR_PARAM_STR_RE = \"{0}: {1} param must be of type string or a regular expression\";\n /** @constant */\n ERR_PARAM_MIXMAPS = \"{0}: both a source as well as a destination map must be provided\";\n /** @constant */\n ERR_MUST_BE_PROVIDED = \"{0}: an {1} and a {2} must be provided\";\n /** @constant */\n ERR_MUST_BE_PROVIDED1 = \"{0}: {1} must be set\";\n\n /** @constant */\n ERR_REPLACE_EL = \"replaceElements called while evalNodes is not an array\";\n\n /** @constant */\n ERR_EMPTY_RESPONSE = \"{0}: The response cannot be null or empty!\";\n /** @constant */\n ERR_ITEM_ID_NOTFOUND = \"{0}: item with identifier {1} could not be found\";\n /** @constant */\n ERR_PPR_IDREQ = \"{0}: Error in PPR Insert, id must be present\";\n /** @constant */\n ERR_PPR_INSERTBEFID = \"{0}: Error in PPR Insert, before id or after id must be present\";\n /** @constant */\n ERR_PPR_INSERTBEFID_1 = \"{0}: Error in PPR Insert, before node of id {1} does not exist in document\";\n /** @constant */\n ERR_PPR_INSERTBEFID_2 = \"{0}: Error in PPR Insert, after node of id {1} does not exist in document\";\n\n /** @constant */\n ERR_PPR_DELID = \"{0}: Error in delete, id not in xml markup\";\n /** @constant */\n ERR_PPR_UNKNOWNCID = \"{0}: Unknown Html-Component-ID= {1}\";\n\n /** @constant */\n ERR_NO_VIEWROOTATTR = \"{0}: Changing of ViewRoot attributes is not supported\";\n /** @constant */\n ERR_NO_HEADATTR = \"{0}: Changing of Head attributes is not supported\";\n /** @constant */\n ERR_RED_URL = \"{0}: Redirect without url\";\n\n /** @constant */\n ERR_REQ_FAILED_UNKNOWN = \"Request failed with unknown status\";\n\n /** @constant */\n ERR_REQU_FAILED = \"Request failed with status {0} and reason {1}\";\n\n /** @constant */\n UNKNOWN = \"UNKNOWN\";\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {EMPTY_STR, P_VIEWSTATE} from \"./Const\";\n\nexport interface IdValueHolder {\n\n readonly id: string;\n readonly value: string;\n\n}\n\n/**\n * a helper class to isolate the\n * view state data processing\n */\nexport class ViewState implements IdValueHolder {\n\n nameSpace: string;\n\n constructor(public id: string, public value: string) {\n let viewStatePos = id.indexOf(P_VIEWSTATE);\n this.nameSpace = viewStatePos > 0 ? id.substr(0, viewStatePos - 1) : EMPTY_STR;\n }\n\n get hasNameSpace(): boolean {\n return !!(this?.nameSpace ?? EMPTY_STR).length;\n }\n}","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Config, Optional, XMLQuery} from \"../../ext/monadish\";\n\nimport {Assertions} from \"../util/Assertions\";\nimport {DQ} from \"../../ext/monadish\";\nimport {\n CTX_PARAM_MF_INTERNAL,\n CTX_PARAM_SRC_CTL_ID,\n CTX_PARAM_SRC_FRM_ID,\n SEL_RESPONSE_XML,\n SOURCE,\n TAG_FORM,\n UPDATE_ELEMS,\n UPDATE_FORMS\n} from \"../core/Const\";\n\n/**\n * Resolver functions for various aspects of the response data\n *\n * stateless because it might be called from various\n * parts of the response classes\n */\n\n/**\n * fetches the response XML\n * as XML Query object\n *\n * @param request the request hosting the responseXML\n *\n * Throws an error in case of non existent or wrong xml data\n *\n */\nexport function resolveResponseXML(request: Config): XMLQuery {\n let ret = new XMLQuery(request.getIf(SEL_RESPONSE_XML).value);\n Assertions.assertValidXMLResponse(ret);\n\n return ret;\n}\n\n/**\n * Splits the incoming passthrough context apart\n * in an internal and an external nomalized context\n * the internal one is just for our internal processing\n *\n * @param context the root context as associative array\n */\nexport function resolveContexts(context: { [p: string]: any }): any {\n /**\n * we split the context apart into the external one and\n * some internal values\n */\n let externalContext = Config.fromNullable(context);\n let internalContext = externalContext.getIf(CTX_PARAM_MF_INTERNAL);\n if (!internalContext.isPresent()) {\n internalContext = Config.fromNullable({});\n }\n\n /**\n * prepare storage for some deferred operations\n */\n internalContext.assign(UPDATE_FORMS).value = [];\n internalContext.assign(UPDATE_ELEMS).value = [];\n return {externalContext, internalContext};\n}\n\n/**\n * fetches the source element out of our conexts\n *\n * @param context the external context which shpuld host the source id\n * @param internalContext internal passthrough fall back\n *\n */\nexport function resolveSourceElement(context: Config, internalContext: Config): DQ {\n let elemId = resolveSourceElementId(context, internalContext);\n return DQ.byId(elemId.value, true);\n}\n\n/**\n * fetches the source form if it still exists\n * also embedded forms and parent forms are taken into consideration\n * as fallbacks\n *\n * @param internalContext\n * @param elem\n */\nexport function resolveSourceForm(internalContext: Config, elem: DQ): DQ {\n let sourceFormId = internalContext.getIf(CTX_PARAM_SRC_FRM_ID);\n let sourceForm = new DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);\n\n sourceForm = sourceForm.orElse(elem.parents(TAG_FORM))\n .orElse(elem.querySelectorAll(TAG_FORM))\n .orElse(DQ.querySelectorAll(TAG_FORM));\n\n return sourceForm;\n}\n\nfunction resolveSourceElementId(context: Config, internalContext: Config): Optional<string> {\n //?internal context?? used to be external one\n return internalContext.getIf(CTX_PARAM_SRC_CTL_ID)\n .orElseLazy(() => context.getIf(SOURCE, \"id\").value);\n}\n\n","/* Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {AsyncRunnable} from \"../util/AsyncRunnable\";\nimport {Config, DQ, Stream} from \"../../ext/monadish\";\nimport {Implementation} from \"../AjaxImpl\";\n\nimport {XhrFormData} from \"./XhrFormData\";\nimport {ErrorData} from \"./ErrorData\";\nimport {EventData} from \"./EventData\";\nimport {ExtLang} from \"../util/Lang\";\nimport {\n BEGIN,\n COMPLETE,\n CONTENT_TYPE,\n CTX_PARAM_MF_INTERNAL,\n CTX_PARAM_PASS_THR,\n ERROR,\n HEAD_FACES_REQ,\n MALFORMEDXML,\n MULTIPART,\n NO_TIMEOUT,\n ON_ERROR,\n ON_EVENT, P_EXECUTE,\n REQ_ACCEPT,\n REQ_TYPE_GET,\n REQ_TYPE_POST,\n STATE_EVT_TIMEOUT,\n STD_ACCEPT,\n URL_ENCODED,\n VAL_AJAX\n} from \"../core/Const\";\nimport {resolveFinalUrl, resolveHandlerFunc} from \"./RequestDataResolver\";\nimport failSaveExecute = ExtLang.failSaveExecute;\n\n/**\n * JSFed XHR Request Wrapper\n * as Asyncrunnable for our Asynchronous queue\n *\n * The idea is that we basically just enqueue\n * a single ajax request into our queue\n * and let the queue do the processing.\n *\n */\n\ndeclare let jsf: any;\n\nexport class XhrRequest implements AsyncRunnable<XMLHttpRequest> {\n\n private responseContext: Config;\n\n private stopProgress = false;\n\n /**\n * helper support so that we do not have to drag in Promise shims\n */\n private catchFuncs: Array<Function> = [];\n private thenFunc: Array<Function> = [];\n\n /**\n * Reqired Parameters\n *\n * @param source the issuing element\n * @param sourceForm the form which is related to the issuing element\n * @param requestContext the request context with allö pass through values\n *\n * Optional Parameters\n *\n * @param partialIdsArray an optional restricting partial ids array for encoding\n * @param timeout optional xhr timeout\n * @param ajaxType optional request type, default \"POST\"\n * @param contentType optional content type, default \"application/x-www-form-urlencoded\"\n * @param xhrObject optional xhr object which must fullfill the XMLHTTPRequest api, default XMLHttpRequest\n */\n constructor(\n private source: DQ,\n private sourceForm: DQ,\n private requestContext: Config,\n private internalContext: Config,\n private partialIdsArray = [],\n private timeout = NO_TIMEOUT,\n private ajaxType = REQ_TYPE_POST,\n private contentType = URL_ENCODED,\n private xhrObject = new XMLHttpRequest()\n ) {\n /*\n * we omit promises here\n * some browsers do not support it and we do not need shim code\n */\n this.registerXhrCallbacks((data: any) => {\n this.resolve(data)\n }, (data: any) => {\n this.reject(data)\n });\n }\n\n start(): AsyncRunnable<XMLHttpRequest> {\n\n let ignoreErr = failSaveExecute;\n let xhrObject = this.xhrObject;\n\n let executesArr = () => {\n return this.requestContext.getIf(CTX_PARAM_PASS_THR, P_EXECUTE).get(\"none\").value.split(/\\s+/gi);\n };\n try {\n\n let formElement = this.sourceForm.getAsElem(0).value;\n let viewState = jsf.getViewState(formElement);\n //encoded we need to decode\n //We generated a base representation of the current form\n let formData: XhrFormData = new XhrFormData(this.sourceForm);\n //in case someone has overloaded the viewstate with addtional decorators we merge\n //that in, there is no way around it, the spec allows it and getViewState\n //must be called, so whatever getViewState delivers has higher priority then\n //whatever the formData object delivers\n formData.assignEncodedString(viewState);\n formData.applyFileInputs(...executesArr());\n\n this.contentType = formData.isMultipartRequest ? \"undefined\" : this.contentType;\n\n //next step the pass through parameters are merged in for post params\n let requestContext = this.requestContext;\n let passThroughParams = requestContext.getIf(CTX_PARAM_PASS_THR);\n formData.shallowMerge(passThroughParams, true, true);\n\n this.responseContext = passThroughParams.deepCopy;\n\n //we have to shift the internal passthroughs around to build up our response context\n let responseContext = this.responseContext;\n\n responseContext.assign(CTX_PARAM_MF_INTERNAL).value = this.internalContext.value;\n\n //per spec the onevent and onerrors must be passed through to the response\n responseContext.assign(ON_EVENT).value = requestContext.getIf(ON_EVENT).value;\n responseContext.assign(ON_ERROR).value = requestContext.getIf(ON_ERROR).value;\n\n xhrObject.open(this.ajaxType, resolveFinalUrl(this.sourceForm, formData, this.ajaxType), true);\n\n //adding timeout\n this.timeout ? xhrObject.timeout = this.timeout : null;\n\n //a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects\n //normal browsers should resolve this\n //tests can quietly fail on this one\n if(this.contentType != \"undefined\") {\n ignoreErr(() => xhrObject.setRequestHeader(CONTENT_TYPE, `${this.contentType}; charset=utf-8`));\n }\n\n ignoreErr(() => xhrObject.setRequestHeader(HEAD_FACES_REQ, VAL_AJAX));\n\n //probably not needed anymore, will test this\n //some webkit based mobile browsers do not follow the w3c spec of\n // setting the accept headers automatically\n ignoreErr(() => xhrObject.setRequestHeader(REQ_ACCEPT, STD_ACCEPT));\n\n this.sendEvent(BEGIN);\n\n this.sendRequest(formData);\n\n } catch (e) {\n //_onError//_onError\n this.handleError(e);\n }\n return this;\n }\n\n cancel() {\n try {\n this.xhrObject.abort();\n } catch (e) {\n this.handleError(e);\n }\n }\n\n resolve(data: any) {\n Stream.of(...this.thenFunc).reduce((inputVal: any, thenFunc: any) => {\n return thenFunc(inputVal);\n }, data);\n }\n\n reject(data: any) {\n Stream.of(...this.catchFuncs).reduce((inputVal: any, catchFunc: any) => {\n return catchFunc(inputVal);\n }, data);\n }\n\n catch(func: (data: any) => any): AsyncRunnable<XMLHttpRequest> {\n //this.$promise.catch(func);\n this.catchFuncs.push(func);\n return this;\n }\n\n finally(func: () => void): AsyncRunnable<XMLHttpRequest> {\n //no ie11 support we probably are going to revert to shims for that one\n //(<any>this.$promise).then(func).catch(func);\n this.catchFuncs.push(func);\n this.thenFunc.push(func);\n return this;\n }\n\n then(func: (data: any) => any): AsyncRunnable<XMLHttpRequest> {\n //this.$promise.then(func);\n this.thenFunc.push(func);\n return this;\n }\n\n /**\n * attaches the internal event and processing\n * callback within the promise to our xhr object\n *\n * @param resolve\n * @param reject\n */\n protected registerXhrCallbacks(resolve: Consumer<any>, reject: Consumer<any>) {\n let xhrObject = this.xhrObject;\n\n xhrObject.onabort = () => {\n this.onAbort(resolve, reject);\n };\n xhrObject.ontimeout = () => {\n this.onTimeout(resolve, reject);\n };\n xhrObject.onload = () => {\n this.onSuccess(this.xhrObject, resolve, reject)\n };\n xhrObject.onloadend = () => {\n this.onDone(this.xhrObject, resolve, reject);\n };\n xhrObject.onerror = (errorData: any) => {\n this.onError(errorData, resolve, reject);\n };\n }\n\n /*\n * xhr processing callbacks\n *\n * Those methods are the callbacks called by\n * the xhr object depending on its own state\n */\n\n protected onAbort(resolve: Consumer<any>, reject: Consumer<any>) {\n reject();\n }\n\n protected onTimeout(resolve: Consumer<any>, reject: Consumer<any>) {\n this.sendEvent(STATE_EVT_TIMEOUT);\n reject();\n }\n\n protected onSuccess(data: any, resolve: Consumer<any>, reject: Consumer<any>) {\n\n this.sendEvent(COMPLETE);\n\n //malforms always result in empty response xml\n if (!this?.xhrObject?.responseXML) {\n this.handleMalFormedXML(resolve);\n return;\n }\n\n jsf.ajax.response(this.xhrObject, this.responseContext.value ?? {});\n }\n\n private handleMalFormedXML(resolve: Function) {\n this.stopProgress = true;\n let errorData = {\n type: ERROR,\n status: MALFORMEDXML,\n responseCode: 200,\n responseText: this.xhrObject?.responseText,\n source: {\n id: this.source.id.value\n }\n };\n try {\n Implementation.sendError(<any>errorData);\n } finally {\n resolve(errorData);\n }\n //non blocking non clearing\n }\n\n protected onDone(data: any, resolve: Consumer<any>, reject: Consumer<any>) {\n if (this.stopProgress) {\n return;\n }\n resolve(data);\n }\n\n protected onError(errorData: any, resolve: Consumer<any>, reject: Consumer<any>) {\n this.handleError(errorData);\n reject();\n }\n\n /*\n * other helpers\n */\n private sendEvent(evtType: string) {\n let eventData = EventData.createFromRequest(this.xhrObject, this.requestContext, evtType);\n try {\n //user code error, we might cover\n //this in onError but also we cannot swallow it\n //we need to resolve the local handlers lazyly,\n //because some frameworks might decorate them over the context in the response\n let eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_EVENT);\n\n Implementation.sendEvent(eventData, eventHandler);\n } catch (e) {\n this.handleError(e);\n throw e;\n }\n }\n\n private handleError(exception) {\n let errorData = ErrorData.fromClient(exception);\n\n let eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_ERROR);\n Implementation.sendError(errorData, eventHandler);\n }\n\n protected sendRequest(formData: XhrFormData) {\n let isPost = this.ajaxType != REQ_TYPE_GET;\n if (formData.isMultipartRequest) {\n //in case of a multipart request we send in a formData object as body\n this.xhrObject.send((isPost) ? formData.toFormData() : null);\n } else {\n //in case of a normal request we send it normally\n this.xhrObject.send((isPost) ? formData.toString() : null);\n }\n }\n\n}","import {AsyncRunnable} from \"./AsyncRunnable\";\n\n/**\n * Asynchronous queue which starts to work\n * through the callbacks until the queue is empty\n *\n * Every callback must be of async runnable\n * which is sort of an extended promise which has\n * added a decicated cancel and start point\n *\n * This interface can be used as wrapper contract\n * for normal promises if needed.\n */\nexport class AsynchronouseQueue<T extends AsyncRunnable<any>> {\n\n private runnableQueue = [];\n private delayTimeout: number;\n\n currentlyRunning: AsyncRunnable<any>;\n\n constructor() {\n }\n\n get isEmpty(): boolean {\n return !this.runnableQueue.length;\n }\n\n /**\n * enequeues an element and starts the\n * asynchronous work loop if not already running\n *\n * @param element the element to be queued and processed\n * @param delay possible delay after our usual process or drop if something newer is incoming algorithm\n */\n enqueue(element: T, delay = 0) {\n if (this.delayTimeout) {\n clearTimeout(this.delayTimeout);\n this.delayTimeout = null;\n }\n if (delay) {\n this.delayTimeout = setTimeout(() => {\n this.appendElement(element);\n });\n } else {\n this.appendElement(element);\n }\n }\n\n dequeue(): T {\n return this.runnableQueue.shift();\n }\n\n cleanup() {\n this.currentlyRunning = null;\n this.runnableQueue.length = 0;\n }\n\n private appendElement(element: T) {\n //only if the first element is added we start with a trigger\n //otherwise a process already is running and not finished yet at that\n //time\n this.runnableQueue.push(element);\n if (!this.currentlyRunning) {\n this.runEntry();\n }\n }\n\n private runEntry() {\n if (this.isEmpty) {\n this.currentlyRunning = null;\n return;\n }\n this.currentlyRunning = this.dequeue();\n this.currentlyRunning\n .catch((e) => {\n //in case of an error we always clean up the remaining calls\n //to allow a clean recovery of the application\n this.cleanup();\n throw e;\n })\n .then(\n //the idea is to trigger the next over an event to reduce\n //the number of recursive calls (stacks might be limited\n //compared to ram)\n //naturally give we have a DOM, the DOM is the natural event dispatch system\n //which we can use, to decouple the calls from a recursive stack call\n //(the browser engine will take care of that)\n () => this.callForNextElementToProcess()\n ).start();\n }\n\n cancel() {\n try {\n if (this.currentlyRunning) {\n this.currentlyRunning.cancel();\n }\n } finally {\n this.cleanup();\n }\n }\n\n private callForNextElementToProcess() {\n this.runEntry();\n }\n}","/**\n * Typescript port of the jsf.push part in the myfaces implementation\n */\n\n//TODO still work in progress\n//this is a 1:1 port for the time being\nimport {jsf} from \"../api/Jsf\";\nimport {MAX_RECONNECT_ATTEMPTS, REASON_EXPIRED, RECONNECT_INTERVAL} from \"./core/Const\";\n\n\n/**\n * Implementation class for the push functionality\n */\nexport module PushImpl {\n\n\n\n const URL_PROTOCOL = window.location.protocol.replace(\"http\", \"ws\") + \"//\";\n\n\n //we expose the member variables for testing purposes\n //they are not directly touched outside of tests\n\n /* socket map by token */\n export let sockets = {};\n /* component attributes by clientId */\n export let components = {};\n /* client ids by token (share websocket connection) */\n export let clientIdsByTokens = {};\n\n\n //needed for testing\n export function reset() {\n sockets = {};\n components = {}\n clientIdsByTokens = {}\n }\n\n /*\n * Api implementations, exposed functions\n */\n\n /**\n *\n * @param {function} onopen The function to be invoked when the web socket is opened.\n * @param {function} onmessage The function to be invoked when a message is received.\n * @param {function} onclose The function to be invoked when the web socket is closed.\n * @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.\n */\n export function init(socketClientId: string,\n uri: string,\n channel: string,\n onopen: Function,\n onmessage: Function,\n onclose: Function,\n behaviorScripts: any,\n autoconnect: boolean) {\n onclose = resolveFunction(onclose);\n\n if (!window.WebSocket) { // IE6-9.\n onclose(-1, channel);\n return;\n }\n\n let channelToken = uri.substr(uri.indexOf('?') + 1);\n\n if (!components[socketClientId]) {\n components[socketClientId] = {\n 'channelToken': channelToken,\n 'onopen': resolveFunction(onopen),\n 'onmessage' : resolveFunction(onmessage),\n 'onclose': onclose,\n 'behaviors': behaviorScripts,\n 'autoconnect': autoconnect};\n if (!clientIdsByTokens[channelToken]) {\n clientIdsByTokens[channelToken] = [];\n }\n clientIdsByTokens[channelToken].push(socketClientId);\n if (!sockets[channelToken]){\n sockets[channelToken] = new Socket(channelToken,\n getBaseURL(uri), channel);\n }\n }\n\n if (autoconnect) {\n jsf.push.open(socketClientId);\n }\n }\n\n export function open(socketClientId: string) {\n getSocket(components?.[socketClientId]?.channelToken).open();\n }\n\n export function close(socketClientId: string) {\n getSocket(components?.[socketClientId].channelToken).close();\n }\n\n // Private helper classes\n // Private classes functions ----------------------------------------------------------------------------------\n /**\n * Creates a reconnecting web socket. When the web socket successfully connects on first attempt, then it will\n * automatically reconnect on timeout with cumulative intervals of 500ms with a maximum of 25 attempts (~3 minutes).\n * The <code>onclose</code> function will be called with the error code of the last attempt.\n * @constructor\n * @param {string} channelToken the channel token associated with this websocket connection\n * @param {string} url The URL of the web socket\n * @param {string} channel The name of the web socket channel.\n */\n\n class Socket {\n\n socket: WebSocket;\n reconnectAttempts = 0;\n\n constructor(private channelToken: string, private url: string, private channel: string) {\n }\n\n open() {\n if (this.socket && this.socket.readyState == 1) {\n return;\n }\n this.socket = new WebSocket(this.url);\n\n this.bindCallbacks();\n }\n\n onopen(event: any) {\n if (!this.reconnectAttempts) {\n let clientIds = clientIdsByTokens[this.channelToken];\n for (let i = clientIds.length - 1; i >= 0; i--) {\n let socketClientId = clientIds[i];\n components[socketClientId]['onopen'](this.channel);\n }\n }\n this.reconnectAttempts = 0;\n }\n\n onmmessage(event: any) {\n let message = JSON.parse(event.data);\n for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {\n let socketClientId = clientIdsByTokens[this.channelToken][i];\n if (document.getElementById(socketClientId)) {\n try {\n components[socketClientId]['onmessage'](message, this.channel, event);\n } catch (e) {\n //Ignore\n }\n let behaviors = components[socketClientId]['behaviors'];\n let functions = behaviors[message];\n if (functions && functions.length) {\n for (let j = 0; j < functions.length; j++) {\n try {\n functions[j](null);\n } catch (e) {\n //Ignore\n }\n }\n }\n } else {\n clientIdsByTokens[this.channelToken].splice(i, 1);\n }\n }\n if (clientIdsByTokens[this.channelToken].length == 0) {\n //tag dissapeared\n this.close();\n }\n }\n\n onclose(event: any) {\n if (!this.socket\n || (event.code == 1000 && event.reason == REASON_EXPIRED)\n || (event.code == 1008)\n || (!this.reconnectAttempts)\n || (this.reconnectAttempts >= MAX_RECONNECT_ATTEMPTS)) {\n let clientIds = clientIdsByTokens[this.channelToken];\n for (let i = clientIds.length - 1; i >= 0; i--) {\n let socketClientId = clientIds[i];\n components[socketClientId]['onclose'](event?.code, this?.channel, event);\n }\n } else {\n setTimeout(this.open, RECONNECT_INTERVAL * this.reconnectAttempts++);\n }\n };\n\n close() {\n if (this.socket) {\n let s = this.socket;\n this.socket = null;\n s.close();\n }\n }\n\n /**\n * bind the callbacks to the socket callbacks\n */\n private bindCallbacks() {\n this.socket.onopen = (event: Event) => this.onopen(event);\n this.socket.onmessage = (event: Event) => this.onmmessage(event);\n this.socket.onclose = (event: Event) => this.onclose(event);\n }\n }\n\n // Private static functions ---------------------------------------------------------------------------------------\n\n function getBaseURL(url: string) {\n if (url.indexOf(\"://\") < 0) {\n let base = window.location.hostname + \":\" + window.location.port;\n return URL_PROTOCOL + base + url;\n } else {\n return url;\n }\n }\n\n /**\n * Get socket associated with given channelToken.\n * @param {string} channelToken The name of the web socket channelToken.\n * @return {Socket} Socket associated with given channelToken.\n * @throws {Error} When channelToken is unknown, you may need to initialize\n * it first via <code>init()</code> function.\n */\n function getSocket(channelToken: string): Socket {\n let socket = sockets[channelToken];\n if (socket) {\n return socket;\n } else {\n throw new Error(\"Unknown channelToken: \" + channelToken);\n }\n }\n\n function resolveFunction(fn: Function | string = () => {\n }): Function {\n return <Function>((typeof fn !== \"function\") && (fn = window[fn]), fn);\n }\n\n}"],"sourceRoot":""}