web-component-wrapper 0.0.601 → 0.0.604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Web.js CHANGED
@@ -1 +1,615 @@
1
- "use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerWarningHelper","clientnode","clientnode/property-types"],t);else{var r="object"==typeof exports?t(require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types")):t(e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerWarningHelper"],e.clientnode,e["clientnode/property-types"]);for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,((e,t,r,s,i)=>(()=>{var n=[e=>{e.exports=s},e=>{e.exports=i},(e,t,r)=>{r.d(t,{default:()=>n});var s=r(0),i=r(1);const n=function(e={}){return e={readAttribute:!0,type:i.string,...e},function(t,r){if("string"!=typeof r)return;const i=t.self||t.constructor;if(e.readAttribute){Object.prototype.hasOwnProperty.call(i,"observedAttributes")||(i.observedAttributes=i.observedAttributes?[...i.observedAttributes]:[]);const e=(0,s.camelCaseToDelimited)(r);i.observedAttributes&&!i.observedAttributes.includes(e)&&i.observedAttributes.push(e)}if(e.type&&(Object.prototype.hasOwnProperty.call(i,"propertyTypes")||(i.propertyTypes=i.propertyTypes?{...i.propertyTypes}:{}),!i.propertyTypes||!e.update&&Object.prototype.hasOwnProperty.call(i,r)||(i.propertyTypes[r]=e.type)),e.writeAttribute&&(Object.prototype.hasOwnProperty.call(i,"propertiesToReflectAsAttributes")||(i.propertiesToReflectAsAttributes=i.propertiesToReflectAsAttributes?(0,s.copy)(i.propertiesToReflectAsAttributes):[]),e.update||i.propertiesToReflectAsAttributes instanceof Map&&!i.propertiesToReflectAsAttributes.has(r)||Array.isArray(i.propertiesToReflectAsAttributes)&&!i.propertiesToReflectAsAttributes.includes(r)||"object"==typeof i.propertiesToReflectAsAttributes&&!Object.prototype.hasOwnProperty.call(i.propertiesToReflectAsAttributes,r))){let t;"boolean"==typeof e.writeAttribute?e.writeAttribute&&i.propertyTypes&&Object.prototype.hasOwnProperty.call(i.propertyTypes,r)&&(t=i.propertyTypes[r]):t=e.writeAttribute,void 0!==t&&(Array.isArray(i.propertiesToReflectAsAttributes)&&(!0===e.writeAttribute?i.propertiesToReflectAsAttributes.push(r):i.normalizePropertyTypeList&&(i.propertiesToReflectAsAttributes=i.normalizePropertyTypeList(i.propertiesToReflectAsAttributes))),i.propertiesToReflectAsAttributes instanceof Map&&i.propertiesToReflectAsAttributes.set(r,t),"object"==typeof i.propertiesToReflectAsAttributes&&(i.propertiesToReflectAsAttributes[r]=t))}e.alias&&(Object.prototype.hasOwnProperty.call(i,"propertyAliases")||(i.propertyAliases=i.propertyAliases?{...i.propertyAliases}:{}),!i.propertyAliases||!e.update&&Object.prototype.hasOwnProperty.call(i,r)||(i.propertyAliases[r]=e.alias))}}},,t=>{t.exports=e},e=>{e.exports=t},e=>{e.exports=r}],o={};function a(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};a.r(l),a.d(l,{GenericHTMLElement:()=>v,Web:()=>w,api:()=>T,default:()=>O,log:()=>A});var p,c,h,d,u=a(4),f=a.n(u),y=a(5),b=a.n(y),m=(a(6),a(0)),g=a(1),P=a(2);const A=new m.Logger({name:"web-component-wrapper-web"}),v="undefined"==typeof HTMLElement?class{}:HTMLElement;let w=(p=(0,P.default)({type:g.boolean,writeAttribute:!0}),d=class e extends v{constructor(){super(),this.renderState={promise:Promise.resolve(""),pending:!1,resolve:m.NOOP},this.childComponentInstances=[],this.batchAttributeUpdates=!0,this.batchPropertyUpdates=!0,this.batchUpdates=!0,this.batchedAttributeUpdateRunning=!0,this.batchedPropertyUpdateRunning=!0,this.batchedUpdateRunning=!0,this.connectionRegistered=!1,this.pendingAttributeUpdates=[],this.parentInstance=null,this.rootInstance=void 0,this.hostDomNode=void 0,this.scope={...m.UTILITY_SCOPE},this.domNodeEventBindings=new Map,this.domNodeTemplateCache=new Map,this.externalProperties={},this.ignoreAttributeUpdateObservations=!1,this.internalProperties={},this.outputEventNames=new Set,this.instance=null,f()(this,"isRoot",h,this),this.runDomConnectionAndRenderingInSameEventQueue=!1,this.self=e,this.slots={},this.prepareNewRenderingPromise(),this.self=this.constructor,this.self._propertiesToReflectAsAttributes||(this.self._propertiesToReflectAsAttributes=this.self.normalizePropertyTypeList(this.self.propertiesToReflectAsAttributes)),this.generateAliasIndex(),this.hostDomNode=this,this.rootInstance=this,this.defineGetterAndSetterInterface()}attributeChangedCallback(e,t,r){this.ignoreAttributeUpdateObservations||t===r||this.onUpdateAttribute(e,r)}onUpdateAttribute(e,t){const r=new Promise((r=>this.pendingAttributeUpdates.push((()=>{this.evaluateStringOrNullAndSetAsProperty(e,t),this.batchAttributeUpdates?this.batchedAttributeUpdateRunning||this.batchedUpdateRunning||(this.batchedAttributeUpdateRunning=!0,this.batchedUpdateRunning=!0,(0,m.timeout)((()=>{this.batchedAttributeUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("attributeChanged")}))):this.render("attributeChanged"),r()}))));if(this.connectionRegistered)for(;this.pendingAttributeUpdates.length;)this.pendingAttributeUpdates.shift()();return r}connectedCallback(){try{this.isConnected=!0}catch{}for(this.connectionRegistered=!0,this.parentInstance=this,this.rootInstance=this,this.attachEventHandler(),this.self.determineRootBinding&&(this.determineRootBinding(),this.parentInstance!==this&&this.parentInstance.childComponentInstances&&this.parentInstance.childComponentInstances.push(this)),this.self.applyRootBinding&&this.isRoot&&(this.determineRenderScope(),this.applyBinding(this,this.scope));this.pendingAttributeUpdates.length;)this.pendingAttributeUpdates.shift()();this.batchedAttributeUpdateRunning=!1,this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.grabGivenSlots(),this.reflectExternalProperties(this.externalProperties),this.runDomConnectionAndRenderingInSameEventQueue?this.render("connected"):(0,m.timeout)((()=>{this.render("connected")}))}disconnectedCallback(){this.unRender("disconnected"),this.unregisterConnectionState()}defineGetterAndSetterInterface(){const e=(0,m.unique)(Object.keys(this.self.propertyTypes).concat(this.self._propertyAliasIndex?Object.keys(this.self._propertyAliasIndex):[]));for(const t of e)Object.prototype.hasOwnProperty.call(this,t)&&this.setPropertyValue(t,this[t]),Object.defineProperty(this,t,{configurable:!0,get:()=>this.getPropertyValue(t),set:e=>{this.setPropertyValue(t,e),this.triggerPropertySpecificRendering(t,e)}})}getPropertyAlias(e){return this.self._propertyAliasIndex&&Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,e)?this.self._propertyAliasIndex[e]:null}getPropertyValue(t){var r;const s=this.instance?.current?.properties&&(Object.prototype.hasOwnProperty.call(!e.propertyTypes,t)||Object.prototype.hasOwnProperty.call(this.instance.current.properties,t))?this.instance.current.properties[t]:null!==(r=this.internalProperties[t])&&void 0!==r?r:this.externalProperties[t];return this.instance?.current?.state&&Object.prototype.hasOwnProperty.call(this.instance.current.state,t)?this.instance.current.state[t]:s}setExternalPropertyValue(e,t){this.externalProperties[e]=t;const r=this.getPropertyAlias(e);r&&(this.externalProperties[r]=t)}setInternalPropertyValue(e,t){this.internalProperties[e]=t;const r=this.getPropertyAlias(e);r&&(this.internalProperties[r]=t)}setPropertyValue(e,t){this.reflectProperties({[e]:t}),this.setInternalPropertyValue(e,t)}triggerPropertySpecificRendering(e,t){if(this.batchPropertyUpdates)this.batchedPropertyUpdateRunning||this.batchedUpdateRunning||(this.batchedPropertyUpdateRunning=!0,this.batchedUpdateRunning=!0,(0,m.timeout)((()=>{void 0!==t&&this.isStateProperty(e)?(this.render("preStatePropertyChanged"),(0,m.timeout)((()=>{this.setInternalPropertyValue(e,void 0),this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("postStatePropertyChanged"),this.triggerOutputEvents()}))):(this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("propertyChanged"),this.triggerOutputEvents())})));else{const r=this.isStateProperty(e);this.render(r?"preStatePropertyChanged":"propertyChanged"),void 0!==t&&r&&(this.setInternalPropertyValue(e,void 0),this.render("postStatePropertyChanged")),this.triggerOutputEvents()}}unregisterConnectionState(){try{this.isConnected=!1}catch{}this.connectionRegistered=!1,this.slots={}}unregisterDomNodeEventBindings(){for(const e of this.domNodeEventBindings.values())for(const t of e.values())t()}applyBinding(e,t){if(e.getAttributeNames)for(const r of e.getAttributeNames()){let s;if(r.startsWith("data-bind-")?s=r.substring(10):r.startsWith("bind-")&&(s=r.substring(5)),s){const i=e.getAttribute(r);if(null===i)continue;if(s.startsWith("attribute-")||s.startsWith("property-")){const n=(0,m.evaluate)(i,t,!1,!0,e);if(n.error){A.warn("Error occurred during processing given",`attribute binding "${r}" on node:`,e,n.error);continue}s.startsWith("attribute-")?e.setAttribute(s.substring(10),n.result):e[(0,m.delimitedToCamelCase)(s.substring(9))]=n.result}else if(s.startsWith("on-")){s=(0,m.delimitedToCamelCase)(s.substring(3)),t={log:A,event:void 0,parameters:void 0,...t};const n=(0,m.compile)(i,t,!0,!0,e);n.error?A.warn("Error occurred during compiling given event",`binding "${r}" on node:`,e,n.error):this.addSecureEventListener(e,s,((...s)=>{t.event=s[0],t.parameters=s;try{n.templateFunction(...n.originalScopeNames.map((e=>t[e])))}catch(t){A.warn("Error occurred during processing","given event binding",`"${r}" on node:`,e,`Given expression "${i}" could`,"not be evaluated with given scope",'names "'+n.scopeNames.join('", "')+`": ${(0,m.represent)(t)}`)}}))}}}}applyBindings(e,t,r=!0){for(;e;)!e.attributes?.length||!r&&e.getAttribute("slot")||this.applyBinding(e,t),e.nodeName.toLowerCase().includes("-")||this.applyBindings(e.firstChild,t),e=e.nextSibling}compileDomNodeTemplate(e,t=[],r={}){r={ignoreComponents:!0,ignoreNestedComponents:!0,unsafe:this.self.renderUnsafe,...r};const s=e.nodeName.toLowerCase();if(r.ignoreComponents&&s.includes("-"))return null;if(r.unsafe){let r=e.innerHTML;if(!r&&e.template&&(r=e.template),this.self.hasCode(r)){const s=(0,m.compile)(`\`${r}\``,t);return{domNode:e,children:[],error:s.error,scopeNames:s.scopeNames,template:r,templateFunction:s.templateFunction}}return null}let i=null;if("#text"===s){const t=e.textContent;t&&this.self.hasCode(t)&&(i=t.replace(/&nbsp;/g," ").trim())}const n=[],o={children:n,domNode:e};if(i){const e=(0,m.compile)(`\`${i}\``,t);o.error=e.error,o.scopeNames=e.scopeNames,o.template=i,o.templateFunction=e.templateFunction}let a=e.firstChild;for(;a;){if(!r.filter||r.filter(a)){const e=this.compileDomNodeTemplate(a,t,{...r,ignoreComponents:r.ignoreNestedComponents});e&&n.push(e)}a=a.nextSibling}return o}evaluateCompiledDomNodeTemplate(e,t){const{domNode:r,error:s,templateFunction:i,scopeNames:n}=e;if(!i||!n)return null;if(s)return A.warn("Error occurred during compiling node content:",s),null;let o=null;try{o=i(...n.map((e=>t[e])))}catch(s){A.warn(`Error occurred when "${this.self._name}" is running`,`"${String(i)}": with bound`,`names "${n.join('", "')}":`,`"${s}". Rendering node:`,r)}return o}evaluateDomNodeTemplate(e,t={},r={}){const s=(r={domNodeTemplateCache:this.domNodeTemplateCache,ignoreComponents:!0,ignoreNestedComponents:!0,unsafe:this.self.renderUnsafe,...r}).domNodeTemplateCache;if(!s.has(e)){const i={filter:r.filter,ignoreComponents:r.ignoreComponents,ignoreNestedComponents:r.ignoreNestedComponents,unsafe:r.unsafe},n=this.compileDomNodeTemplate(e,t,i);n&&s.set(e,n)}if(s.has(e)){const i=s.get(e),n=this.evaluateCompiledDomNodeTemplate(i,t);if(null!==n&&(r.unsafe&&e.innerHTML?e.innerHTML=n:e.textContent=n),i.children.length){const e=r=>{for(const s of r){const r=this.evaluateCompiledDomNodeTemplate(s,t);null!==r&&(s.domNode.textContent=r),s.children.length&&e(s.children)}};e(i.children)}}r.applyBindings&&this.applyBindings(e,t)}addSecureEventListener(e,t,r,s,i){this.domNodeEventBindings.has(e)||this.domNodeEventBindings.set(e,new Map);const n=this.domNodeEventBindings.get(e),o=n.get(t);o&&o!==r&&o();const a=()=>{e.removeEventListener(t,r,i),n.delete(t),0===n.size&&this.domNodeEventBindings.delete(e)};return n.set(t,a),e.addEventListener(t,r,s),a}determineRootBinding(){let t=this.parentNode;for(;t;){const r=t instanceof e||t.nodeName.includes("-")&&"#document-fragment"!==t.nodeName,s=null===t.parentNode&&"[object ShadowRoot]"===t.toString();r?(this.rootInstance===this&&(this.parentInstance=t,this.setPropertyValue("isRoot",!1)),this.rootInstance=t):s&&this.setPropertyValue("isRoot",!1),t=t.parentNode}}static hasCode(e){return"string"==typeof e&&e.includes("${")&&e.includes("}")&&/\${[\s\S]+}/.test(e)}static normalizePropertyTypeList(t){if("string"==typeof t&&(t=[t]),Array.isArray(t)){const r=t,s=new Map;for(const t of r)Object.prototype.hasOwnProperty.call(e.propertyTypes,t)&&s.set(t,e.propertyTypes[t]);return s}return(0,m.convertPlainObjectToMap)(t)}attachEventHandler(){if(null===this.self.eventToPropertyMapping)return;const e=this.attachExplicitDefinedOutputEventHandler();this.attachImplicitDefinedOutputEventHandler(!e)}attachExplicitDefinedOutputEventHandler(){if(!this.self.eventToPropertyMapping)return!1;let e=!1;for(const t of Object.keys(this.self.eventToPropertyMapping))Object.prototype.hasOwnProperty.call(this.internalProperties,t)||(e=!0,this.outputEventNames.add(t),this.setInternalPropertyValue(t,(async(...e)=>{const r=await this.reflectEventToProperties(t,e);r&&(e[0]=r),this.forwardEvent(t,e)})));return e}attachImplicitDefinedOutputEventHandler(e=!0){for(const[t,r]of Object.entries(this.self.propertyTypes))Object.prototype.hasOwnProperty.call(this.internalProperties,t)||![g.func,"function"].includes(r)||this.self.renderProperties.includes(t)||(this.outputEventNames.add(t),this.setInternalPropertyValue(t,((...r)=>{e&&this.reflectEventToProperties(t,r),this.forwardEvent(t,r)})))}triggerOutputEvents(){for(const e of this.outputEventNames)this.forwardEvent(e,[this.externalProperties])}forwardEvent(e,t){return e.length>3&&e.startsWith("on")&&(e=(0,m.lowerCase)(e.substring(2))),this.dispatchEvent(new CustomEvent(e,{detail:{parameters:t}}))}applySlots(t,r){for(const s of Array.from(t.querySelectorAll("slot"))){const t=s.getAttribute("name");if(null===t||"default"===t)if(this.slots.default){if(this.self.renderSlots){if(this.self.evaluateSlots)for(const e of this.slots.default)this.evaluateDomNodeTemplate(e,r);(0,m.replace)(s,this.slots.default,e.trimSlots)}}else this.slots.default=(0,m.unwrap)(s).map((e=>this.grabSlotContent(e)));else this.slots[t]?this.self.renderSlots&&(this.self.evaluateSlots&&this.evaluateDomNodeTemplate(this.slots[t],r),(0,m.replace)(s,this.slots[t],e.trimSlots)):this.slots[t]=this.grabSlotContent((0,m.unwrap)(s).filter((e=>"#text"!==e.nodeName.toLowerCase()))[0])}}grabSlotContent(e){const t=g.node.firstElementChild?e:null;if(t&&"textarea"===t.firstElementChild?.nodeName.toLowerCase()&&(!t.firstElementChild.hasAttribute("data-no-template")||"false"===t.firstElementChild.getAttribute("data-no-template"))){const e=t.firstElementChild.value;t.classList.remove("web-component-template");const r=t.cloneNode();return t.classList.add("web-component-template"),r.innerHTML="",r.template=e,r}return this.self.cloneSlots?e.cloneNode(!0):e}grabGivenSlots(){this.slots={};for(const e of Array.from(this.querySelectorAll("[slot]"))){let t=e.parentNode,r=!0;for(;t;){if(t.nodeName.includes("-")){t===this&&(r=!1);break}t=t.parentNode}if(r)continue;const s=e.getAttribute("slot")?.trim();this.slots[null!=s?s:e.nodeName.toLowerCase()]=this.grabSlotContent(e)}this.slots.default?this.slots.default=[].concat(this.slots.default):this.childNodes.length>0?this.slots.default=Array.from(this.childNodes).map((e=>this.grabSlotContent(e))):this.slots.default=[]}isStateProperty(e){return Boolean(this.instance?.current?.state&&(Object.prototype.hasOwnProperty.call(this.instance.current.state,e)||this.instance.current.state.modelState&&Object.prototype.hasOwnProperty.call(this.instance.current.state.modelState,e)))}generateAliasIndex(){if(!this.self._propertyAliasIndex){this.self._propertyAliasIndex={...this.self.propertyAliases};for(const[e,t]of Object.entries(this.self._propertyAliasIndex))Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,t)||(this.self._propertyAliasIndex[t]=e)}}reflectExternalProperties(e){this.ignoreAttributeUpdateObservations=!0;for(const[t,r]of Object.entries(e)){if(this.setExternalPropertyValue(t,r),!this.isConnected)continue;const e=(0,m.camelCaseToDelimited)(t);if(this.self._propertiesToReflectAsAttributes?.has(t))switch(this.self._propertiesToReflectAsAttributes.get(t)){case g.boolean:case"boolean":r?""!==this.getAttribute(e)&&this.setAttribute(e,""):this.hasAttribute(e)&&this.removeAttribute(e);break;case g.func:case"function":break;case"json":if(r){const t=JSON.stringify(r);if(t&&this.getAttribute(e)!==t){this.setAttribute(e,t);break}}this.hasAttribute(e)&&this.removeAttribute(e);break;case g.number:case"number":if("number"!=typeof r||isNaN(r))this.hasAttribute(e)&&this.removeAttribute(e);else{const t=String(r);this.getAttribute(e)!==t&&this.setAttribute(e,t)}break;case g.string:case"string":r?this.getAttribute(e)!==r&&this.setAttribute(e,r):this.hasAttribute(e)&&this.removeAttribute(e);break;case g.any:case g.array:case g.arrayOf:case g.element:case g.elementType:case g.instanceOf:case g.node:case g.object:case"object":case g.objectOf:case g.shape:case g.exact:case g.symbol:default:if(r){const t=(0,m.represent)(r);if(t&&this.getAttribute(e)!==t){this.setAttribute(e,t);break}}this.hasAttribute(e)&&this.removeAttribute(e)}}this.ignoreAttributeUpdateObservations=!1}reflectProperties(e){if(this.reflectExternalProperties(e),this.instance?.current?.state&&"object"==typeof this.instance.current.state)for(const e of Object.keys(this.instance.current.state).concat(this.instance.current.state.modelState?Object.keys(this.instance.current.state.modelState):[]))Object.prototype.hasOwnProperty.call(this.internalProperties,e)&&this.setInternalPropertyValue(e,void 0);this.internalProperties.model?.state&&(delete this.internalProperties.model.state,this.setInternalPropertyValue("model",this.internalProperties.model));for(const t of this.self.controllableProperties)Object.prototype.hasOwnProperty.call(e,t)&&this.setInternalPropertyValue(t,e[t])}async reflectEventToProperties(e,t){const r=this.batchUpdates;this.batchUpdates=!1;let s=null,i=!1;if(this.self.eventToPropertyMapping&&Object.prototype.hasOwnProperty.call(this.self.eventToPropertyMapping,e)&&(0,m.isFunction)(this.self.eventToPropertyMapping[e])){const r=this.self.eventToPropertyMapping[e](...t,this),n=r&&"then"in r&&(0,m.isFunction)(r.then)?await r:r;i=!0,Array.isArray(n)?(s=n[0],this.reflectProperties(s),(0,m.extend)(!0,this.internalProperties,n[1])):null===n?i=!1:"object"==typeof n&&(s=n,this.reflectProperties(n))}if(!i&&t.length>0&&(0,m.isObject)(t[0])){let e=t[0];if("persist"in t[0]&&(0,m.isFunction)(t[0].persist)){e={};for(const r of Object.keys(this.self.propertyTypes))for(const s of[r].concat(null!==(n=this.getPropertyAlias(r))&&void 0!==n?n:[])){var n;const r=t[0].currentTarget&&Object.prototype.hasOwnProperty.call(t[0].currentTarget,s)?t[0].currentTarget[s]:this.getPropertyValue(s);r!==this.externalProperties[s]&&(e[s]=r)}}else[null,void 0].includes(e.detail?.value)||(e={...e.detail});s=e,this.reflectProperties(e)}return this.triggerRender("propertyReflected"),this.batchUpdates=r,s}evaluateStringOrNullAndSetAsProperty(e,t){const r=e.startsWith("-"),s=r?e.substring(1):e;let i=(0,m.delimitedToCamelCase)(s);const n=this.getPropertyAlias(i);if(n&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,n)&&(i=n),Object.prototype.hasOwnProperty.call(this.self.propertyTypes,i)){const s=this.self.propertyTypes[i];if(r){if(t){const r=(0,m.evaluate)(t,{...m.UTILITY_SCOPE},!1,!0,this);r.error?(A.warn("Failed to process pre-evaluation attribute",`"${e}": ${r.error}. Will be`,'set to "undefined".'),this.setInternalPropertyValue(i,void 0)):(this.setInternalPropertyValue(i,r.result),this.setExternalPropertyValue(i,r.result))}}else switch(s){case g.boolean:case"boolean":{const e=![null,"false"].includes(t);this.setInternalPropertyValue(i,e),this.setExternalPropertyValue(i,e);break}case g.func:case"function":{let r,s=null;const n=["data","event","firstArgument","firstParameter","options"];if(t){const i=(0,m.compile)(t,n.concat("parameters","scope",m.UTILITY_SCOPE_NAMES),!0,!0,this);s=i.error,r=i.templateFunction,s&&A.warn("Failed to compile given handler",`"${e}": ${s}.`)}this.setInternalPropertyValue(i,((...o)=>{let a;if(this.outputEventNames.has(i)&&this.reflectEventToProperties(i,o),!s){const s={parameters:o,...m.UTILITY_SCOPE};for(const e of n)s[e]=o[0];try{a=r?.(...n.map((e=>s[e])),o,s,...m.UTILITY_SCOPE_NAMES.map((e=>m.UTILITY_SCOPE[e])))}catch(r){A.warn("Failed to evaluate function",`"${e}" with expression`,`"${t}" and scope`,"variables",`"${n.join('", "')}" set to`,`"${(0,m.represent)(o)}":`,`${r}. Set property`,'to "undefined".')}}return this.self.renderProperties.includes(i)||this.forwardEvent(i,o),a})),s||this.setExternalPropertyValue(i,r);break}case"json":if(t){let r;try{r=JSON.parse(t)}catch(t){A.warn("Error occurred during parsing given json",`attribute "${e}":`,(0,m.represent)(t));break}this.setInternalPropertyValue(i,r),this.setExternalPropertyValue(i,(0,m.copy)(r,!1,1))}else this.setInternalPropertyValue(i,null),this.setExternalPropertyValue(i,null);break;case g.number:case"number":{if(null===t){this.setInternalPropertyValue(i,t),this.setExternalPropertyValue(i,t);break}let e=parseFloat(t);isNaN(e)&&(e=void 0),this.setInternalPropertyValue(i,e),this.setExternalPropertyValue(i,e);break}case g.string:case"string":this.setInternalPropertyValue(i,t),this.setExternalPropertyValue(i,t);break;case g.any:case g.array:case g.arrayOf:case g.element:case g.elementType:case g.instanceOf:case g.node:case g.object:case"object":case g.objectOf:case g.oneOf:case g.oneOfType:case g.shape:case g.exact:case g.symbol:default:if(t){const r=(0,m.evaluate)(t,{},!1,!0,this);if(r.error){A.warn("Error occurred during processing given",`attribute configuration "${e}":`,r.error);break}this.setInternalPropertyValue(i,r.result),this.setExternalPropertyValue(i,(0,m.copy)(r.result,!1,1))}else this.hasAttribute(e)?(this.setInternalPropertyValue(i,!0),this.setExternalPropertyValue(i,!0)):(this.setInternalPropertyValue(i,null),this.setExternalPropertyValue(i,null))}}}async waitForNestedComponentRendering(){this.childComponentInstances&&await Promise.all(this.childComponentInstances.map((e=>e.renderState.pending?e.renderState.promise:Promise.resolve())))}async resolveRenderingPromiseIfSet(e,t){t&&(await this.waitForNestedComponentRendering(),this.renderState.pending=!1,this.renderState.resolve(e),this.prepareNewRenderingPromise())}prepareNewRenderingPromise(){this.renderState.pending||(this.renderState.promise=new Promise((e=>{this.renderState.resolve=t=>{this.renderState.pending=!1,e(t)}})))}triggerRender(e){this.batchUpdates?this.batchedUpdateRunning||(this.batchedUpdateRunning=!0,(0,m.timeout)((()=>{this.batchedUpdateRunning=!1,this.render(e)}))):this.render(e)}applyShadowRootIfNotExisting(){this.self.shadowDOM&&this.hostDomNode===this&&(this.hostDomNode=(!("attachShadow"in this)&&"ShadyDOM"in window?window.ShadyDOM.wrap(this):this).attachShadow((0,m.isObject)(this.self.shadowDOM)?this.self.shadowDOM:{mode:"open"}))}determineRenderScope(e={}){this.scope={...this.parentInstance?.scope||{},...this.scope,...this.internalProperties,parentInstance:this.parentInstance,rootInstance:this.rootInstance,self:this,[(0,m.lowerCase)(this.self._name)||"instance"]:this,...e},this.scope.scope=this.scope}async render(e="unknown",t=!0){if(this.unRender("reRender",e),this.childComponentInstances=[],this.renderState.pending=!0,this.isRoot&&(await this.resolveRenderingPromiseIfSet(e,t),t&&(await Promise.all(this.self.pendingRenderPromises),this.self.pendingRenderPromises=[])),this.self.pendingRenderPromises.push(this.renderState.promise),this.determineRenderScope(),!this.self.doRender||!this.dispatchEvent(new CustomEvent("render",{detail:{reason:e,scope:this.scope}})))return void await this.resolveRenderingPromiseIfSet(e,t);const r=(0,m.evaluate)(`\`${this.self.content}\``,this.scope);if(r.error)return A.warn(`Failed to process template: ${r.error}`),this.renderState.resolve(e),void await Promise.all(this.self.pendingRenderPromises);this.applyShadowRootIfNotExisting();const s=document.createElement("div");s.innerHTML=r.result,this.applySlots(s,{...this.scope,parentInstance:this}),this.hostDomNode.innerHTML=s.innerHTML,await(0,m.timeout)(),this.waitForNestedComponentRendering().then((()=>{this.applyBindings(this.hostDomNode.firstChild,this.scope,this.self.renderSlots)})),await this.resolveRenderingPromiseIfSet(e,t)}unRender(e="unknown",t){this.unregisterDomNodeEventBindings()}},d.applyRootBinding=!0,d.pendingRenderPromises=[],d.content="<slot>Please provide a template to transclude.</slot>",d.determineRootBinding=!0,d.shadowDOM=null,d.observedAttributes=[],d.controllableProperties=[],d.eventToPropertyMapping={},d.propertyAliases={},d.propertyTypes={onClick:g.func},d.propertiesToReflectAsAttributes=[],d.renderProperties=["children"],d.doRender=!1,d.cloneSlots=!1,d.evaluateSlots=!1,d.renderSlots=!0,d.trimSlots=!0,d.renderUnsafe=!1,d._name="BaseWeb",d._propertyAliasIndex=void 0,d._propertiesToReflectAsAttributes=void 0,c=d,h=b()(c.prototype,"isRoot",[p],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),c);const T={component:w,register:(e=(0,m.camelCaseToDelimited)(w._name))=>{customElements.define(e,w)}},O=w;return l})()));
1
+ if(typeof window==='undefined'||window===null)var window=(typeof global==='undefined'||global===null)?{}:global;import * as __WEBPACK_EXTERNAL_MODULE_clientnode__ from "clientnode";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__ from "clientnode/property-types";
3
+ /******/ var __webpack_modules__ = ([
4
+ /* 0 */
5
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6
+
7
+ const x = (y) => {
8
+ const x = {}; __webpack_require__.d(x, y); return x
9
+ }
10
+ const y = (x) => (() => (x))
11
+ module.exports = x({ ["Logger"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.Logger), ["NOOP"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.NOOP), ["UTILITY_SCOPE"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.UTILITY_SCOPE), ["UTILITY_SCOPE_NAMES"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.UTILITY_SCOPE_NAMES), ["camelCaseToDelimited"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.camelCaseToDelimited), ["compile"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.compile), ["convertPlainObjectToMap"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.convertPlainObjectToMap), ["copy"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.copy), ["delimitedToCamelCase"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.delimitedToCamelCase), ["evaluate"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.evaluate), ["extend"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.extend), ["isFunction"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isFunction), ["isObject"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isObject), ["lowerCase"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.lowerCase), ["replace"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.replace), ["represent"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.represent), ["timeout"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.timeout), ["unique"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.unique), ["unwrap"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.unwrap) });
12
+
13
+ /***/ }),
14
+ /* 1 */
15
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16
+
17
+ const x = (y) => {
18
+ const x = {}; __webpack_require__.d(x, y); return x
19
+ }
20
+ const y = (x) => (() => (x))
21
+ module.exports = x({ ["any"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.any), ["array"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.array), ["arrayOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.arrayOf), ["boolean"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.boolean), ["element"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.element), ["elementType"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.elementType), ["exact"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.exact), ["func"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.func), ["instanceOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.instanceOf), ["node"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.node), ["number"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.number), ["object"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.object), ["objectOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.objectOf), ["oneOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.oneOf), ["oneOfType"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.oneOfType), ["shape"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.shape), ["string"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.string), ["symbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.symbol) });
22
+
23
+ /***/ }),
24
+ /* 2 */
25
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
26
+
27
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
28
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
29
+ /* harmony export */ });
30
+ /* unused harmony export property */
31
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
32
+ /* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
33
+ // #!/usr/bin/env babel-node
34
+ // -*- coding: utf-8 -*-
35
+ /** @module decorator *//* !
36
+ region header
37
+ [Project page](https://torben.website/web-component-wrapper)
38
+
39
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
40
+
41
+ License
42
+ -------
43
+
44
+ This library written by Torben Sickert stands under a creative commons
45
+ naming 3.0 unported license.
46
+ See https://creativecommons.org/licenses/by/3.0/deed.de
47
+ endregion
48
+ */// region imports
49
+ // endregion
50
+ /**
51
+ * Generates a decorator based on given configuration.
52
+ * @param options - Property configuration to define how to transfer attributes
53
+ * and properties into each other.
54
+ * @param options.alias - Alternate property name.
55
+ * @param options.readAttribute - Indicates whether to read from existing
56
+ * attribute also.
57
+ * @param options.type - Value type to parse value.
58
+ * @param options.update - Indicates whether to overwrite already existing
59
+ * property configurations.
60
+ * @param options.writeAttribute - Indicates whether to sync attribute
61
+ * representation back into dom.
62
+ * @returns Generated decorator.
63
+ */function property(options={}){options={readAttribute:true,type:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string,...options};/**
64
+ * Registers given property to different property / attribute conversion
65
+ * data structures.
66
+ * NOTE: It is important to set static configuration properties on its
67
+ * "own" properties instead of some inherited one. So we have to check via
68
+ * "hasOwnProperty" for existence in this decorator.
69
+ * @param target - Instance to apply given property to.
70
+ * @param name - Field name to apply.
71
+ */return function(target,name){if(typeof name!=="string")return;const self=target.self||target.constructor;if(options.readAttribute){if(!Object.prototype.hasOwnProperty.call(self,"observedAttributes"))self.observedAttributes=self.observedAttributes?[...self.observedAttributes]:[];const attributeName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name);if(self.observedAttributes&&!self.observedAttributes.includes(attributeName))self.observedAttributes.push(attributeName)}if(options.type){if(!Object.prototype.hasOwnProperty.call(self,"propertyTypes"))self.propertyTypes=self.propertyTypes?{...self.propertyTypes}:{};if(self.propertyTypes&&(options.update||!Object.prototype.hasOwnProperty.call(self,name)))self.propertyTypes[name]=options.type}if(options.writeAttribute){if(!Object.prototype.hasOwnProperty.call(self,"propertiesToReflectAsAttributes"))self.propertiesToReflectAsAttributes=self.propertiesToReflectAsAttributes?(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(self.propertiesToReflectAsAttributes):[];if(options.update||self.propertiesToReflectAsAttributes instanceof Map&&!self.propertiesToReflectAsAttributes.has(name)||Array.isArray(self.propertiesToReflectAsAttributes)&&!self.propertiesToReflectAsAttributes.includes(name)||typeof self.propertiesToReflectAsAttributes==="object"&&!Object.prototype.hasOwnProperty.call(self.propertiesToReflectAsAttributes,name)){let result;if(typeof options.writeAttribute==="boolean"){if(options.writeAttribute&&self.propertyTypes&&Object.prototype.hasOwnProperty.call(self.propertyTypes,name))result=self.propertyTypes[name]}else result=options.writeAttribute;if(result!==undefined){if(Array.isArray(self.propertiesToReflectAsAttributes))if(options.writeAttribute===true)self.propertiesToReflectAsAttributes.push(name);else if(self.normalizePropertyTypeList)self.propertiesToReflectAsAttributes=self.normalizePropertyTypeList(self.propertiesToReflectAsAttributes);if(self.propertiesToReflectAsAttributes instanceof Map)self.propertiesToReflectAsAttributes.set(name,result);if(typeof self.propertiesToReflectAsAttributes==="object")self.propertiesToReflectAsAttributes[name]=result}}}if(options.alias){if(!Object.prototype.hasOwnProperty.call(self,"propertyAliases"))self.propertyAliases=self.propertyAliases?{...self.propertyAliases}:{};if(self.propertyAliases&&(options.update||!Object.prototype.hasOwnProperty.call(self,name)))self.propertyAliases[name]=options.alias}}}/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (property);
72
+
73
+ /***/ })
74
+ /******/ ]);
75
+ /************************************************************************/
76
+ /******/ // The module cache
77
+ /******/ const __webpack_module_cache__ = {};
78
+ /******/
79
+ /******/ // The require function
80
+ /******/ function __webpack_require__(moduleId) {
81
+ /******/ // Check if module is in cache
82
+ /******/ const cachedModule = __webpack_module_cache__[moduleId];
83
+ /******/ if (cachedModule !== undefined) {
84
+ /******/ return cachedModule.exports;
85
+ /******/ }
86
+ /******/ // Create a new module (and put it into the cache)
87
+ /******/ const module = __webpack_module_cache__[moduleId] = {
88
+ /******/ // no module.id needed
89
+ /******/ // no module.loaded needed
90
+ /******/ exports: {}
91
+ /******/ };
92
+ /******/
93
+ /******/ // Execute the module function
94
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
95
+ /******/
96
+ /******/ // Return the exports of the module
97
+ /******/ return module.exports;
98
+ /******/ }
99
+ /******/
100
+ /************************************************************************/
101
+ /******/ /* webpack/runtime/define property getters */
102
+ /******/ (() => {
103
+ /******/ // define getter/value functions for harmony exports
104
+ /******/ __webpack_require__.d = (exports, definition) => {
105
+ /******/ if(Array.isArray(definition)) {
106
+ /******/ var i = 0;
107
+ /******/ while(i < definition.length) {
108
+ /******/ var key = definition[i++];
109
+ /******/ var binding = definition[i++];
110
+ /******/ if(!__webpack_require__.o(exports, key)) {
111
+ /******/ if(binding === 0) {
112
+ /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
113
+ /******/ } else {
114
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
115
+ /******/ }
116
+ /******/ } else if(binding === 0) { i++; }
117
+ /******/ }
118
+ /******/ } else {
119
+ /******/ for(var key in definition) {
120
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
121
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
122
+ /******/ }
123
+ /******/ }
124
+ /******/ }
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
129
+ /******/ (() => {
130
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
131
+ /******/ })();
132
+ /******/
133
+ /************************************************************************/
134
+ let __webpack_exports__ = {};
135
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
136
+ /* harmony export */ Ay: () => (src_Web),
137
+ /* harmony export */ FH: () => (/* binding */ api),
138
+ /* harmony export */ Hh: () => (/* binding */ GenericHTMLElement),
139
+ /* harmony export */ Nc: () => (/* binding */ Web),
140
+ /* harmony export */ Rm: () => (/* binding */ log)
141
+ /* harmony export */ });
142
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
143
+ /* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
144
+ /* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
145
+ // #!/usr/bin/env babel-node
146
+ // -*- coding: utf-8 -*-
147
+ /** @module web *//* !
148
+ region header
149
+ [Project page](https://torben.website/web-component-wrapper)
150
+
151
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
152
+
153
+ License
154
+ -------
155
+
156
+ This library written by Torben Sickert stands under a creative commons
157
+ naming 3.0 unported license.
158
+ See https://creativecommons.org/licenses/by/3.0/deed.de
159
+ endregion
160
+ */// region imports
161
+ var _dec,_class,_descriptor,_Web;function _initializerDefineProperty(e,i,r,l){r&&Object.defineProperty(e,i,{enumerable:r.enumerable,configurable:r.configurable,writable:r.writable,value:r.initializer?r.initializer.call(l):void 0})}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _applyDecoratedDescriptor(i,e,r,n,l){var a={};return Object.keys(n).forEach(function(i){a[i]=n[i]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(r,n){return n(i,e,r)||r},a),l&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(l):void 0,a.initializer=void 0),void 0===a.initializer?(Object.defineProperty(i,e,a),null):a}function _initializerWarningHelper(r,e){throw Error("Decorating class property failed. Please ensure that transform-class-properties is enabled and runs after the decorators transform.")}// endregion
162
+ const log=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Logger({name:"web-component-wrapper.web"});/*
163
+ NOTE: We mock HTMLElement to be able to load this class and derived one
164
+ into node environments.
165
+ */const GenericHTMLElement=typeof HTMLElement==="undefined"?// eslint-disable-next-line @typescript-eslint/no-extraneous-class
166
+ class HTMLElement{}:HTMLElement;/**
167
+ * Generic web component to render a content against instance-specific values.
168
+ * @property applyRootBinding - If determined itself as root declarative event
169
+ * and property bindings will be applied to itself.
170
+ * @property content - Content to render when changes happened.
171
+ * @property determineRootBinding - If checked this component determines if it
172
+ * is a root component (not wrapped by another web-component).
173
+ * @property shadowDOM - Configures if a shadow dom should be used during
174
+ * web-component instantiation. Can hold initialize configuration.
175
+ * @property observedAttributes - Attribute names to observe for changes.
176
+ * @property controllableProperties - A list of controllable property names.
177
+ * @property eventToPropertyMapping - Explicitly defined output events (a
178
+ * mapping of event names to a potential parameter to properties-transformer).
179
+ * @property propertyAliases - A mapping of property names to be treated as
180
+ * equal.
181
+ * @property propertyTypes - Configuration defining how to convert attributes
182
+ * into properties and reflect property changes back to attributes.
183
+ * @property propertiesToReflectAsAttributes - An Item, List, or Mapping of
184
+ * properties to reflect as attributes.
185
+ * @property renderProperties - List of known render properties.
186
+ * @property cloneSlots - Indicates whether to clone slot before to transclude
187
+ * content into them. If a slot should be used multiple times (for example,
188
+ * when it works as a template node.) they should be copied to avoid unexpected
189
+ * mutations.
190
+ * @property doRender - Configures whether this component instance should
191
+ * evaluate its given body content.
192
+ * @property evaluateSlots - Indicates whether to evaluate slot content when
193
+ * before rendering them.
194
+ * @property renderSlots - Indicates whether determined slots should be
195
+ * rendered into root node.
196
+ * @property trimSlots - Ignore empty text nodes while applying slots.
197
+ * @property renderUnsafe - Defines default render behavior.
198
+ * @property _name - Name to access instance-evaluated content or used
199
+ * to derive default component name. This is also useful for logging.
200
+ * @property _propertyAliasIndex - Internal alias index to quickly match
201
+ * properties in both directions.
202
+ * @property _propertiesToReflectAsAttributes - A mapping of property names to
203
+ * set as attributes when they are set/updated. Uses a map to hold order and
204
+ * determine if a property exists in constant runtime.
205
+ * @property renderState - Holds data about currently running render state.
206
+ * @property renderState.promise - Promise resolving when next rendering has
207
+ * been finished.
208
+ * @property renderState.pending - Indicates whether a rendering task is
209
+ * performing.
210
+ * @property renderState.resolve - Callback to trigger when rendering has been
211
+ * finished.
212
+ * @property childComponentInstances - List of direct child components (needed
213
+ * to wait for them to finish dom manipulation).
214
+ * @property batchAttributeUpdates - Indicates whether to directly update dom
215
+ * after each attribute mutation or to wait and batch mutations after current
216
+ * queue has been finished.
217
+ * @property batchPropertyUpdates - Indicates whether to directly update dom
218
+ * after each property mutation or to wait and batch mutations after current
219
+ * queue has been finished.
220
+ * @property batchUpdates - Indicates whether to directly perform a
221
+ * re-rendering after changes on properties have been made.
222
+ * @property batchedAttributeUpdateRunning - A boolean indicator to identify if
223
+ * an attribute update is currently batched.
224
+ * @property batchedPropertyUpdateRunning - A boolean indicator to identify if
225
+ * a property update is currently batched.
226
+ * @property batchedUpdateRunning - Indicates whether a batched render update
227
+ * is currently running.
228
+ * @param connectionRegistered - Indicates whether this component is connected
229
+ * to DOM and could run its connectedCallback.
230
+ * @param pendingAttributeUpdates - Holds pending attribute updates which
231
+ * should be performed when the component is connected to DOM.
232
+ * @property parentInstance - Parent component instance.
233
+ * @property rootInstance - Root component instance.
234
+ * @property scope - Render scope.
235
+ * @property domNodeEventBindings - Holds a mapping from nodes with registered
236
+ * event handlers mapped to their deregistration function.
237
+ * @property domNodeTemplateCache - Caches template compilation results.
238
+ * @property externalProperties - Holds currently evaluated or seen properties.
239
+ * @property ignoreAttributeUpdateObservations - Indicates whether attribute
240
+ * updates should be considered (usually only needed internally).
241
+ * @property internalProperties - Holds currently evaluated properties which
242
+ * are owned by this instance and should always be delegated.
243
+ * @property outputEventNames - Set of determined output event names.
244
+ * @property instance - Wrapped component instance.
245
+ * @property isRoot - Indicates whether their exists another web-derived
246
+ * component up the tree or not.
247
+ * @property root - Hosting dom node.
248
+ * @property runDomConnectionAndRenderingInSameEventQueue - Indicates whether
249
+ * we should render initial dom immediately after the component is connected to
250
+ * dom. Deactivating this allows wrapped components to detect their parents
251
+ * since their parent-connected callback will be called before the children's
252
+ * render method.
253
+ * @property self - Back-reference to this class.
254
+ * @property slots - Grabbed slots that where present in the connecting phase.
255
+ */let Web=(_dec=(0,_decorator_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)({type:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean,writeAttribute:true}),_class=(_Web=class Web extends GenericHTMLElement{// endregion
256
+ // region live cycle hooks
257
+ /**
258
+ * Initializes host dom content and properties.
259
+ * @returns Nothing.
260
+ */constructor(){super();_defineProperty(this,"renderState",{promise:Promise.resolve(""),pending:false,resolve:clientnode__WEBPACK_IMPORTED_MODULE_0__.NOOP});// Constructor might be executed when accessed via child components.
261
+ _defineProperty(this,"childComponentInstances",[]);_defineProperty(this,"batchAttributeUpdates",true);_defineProperty(this,"batchPropertyUpdates",true);_defineProperty(this,"batchUpdates",true);/*
262
+ NOTE: We set these properties to true initially since we want to
263
+ prevent any updates until the component is connected to dom.
264
+ */_defineProperty(this,"batchedAttributeUpdateRunning",true);_defineProperty(this,"batchedPropertyUpdateRunning",true);_defineProperty(this,"batchedUpdateRunning",true);_defineProperty(this,"connectionRegistered",false);_defineProperty(this,"pendingAttributeUpdates",[]);_defineProperty(this,"parentInstance",null);_defineProperty(this,"rootInstance",void 0);_defineProperty(this,"hostDomNode",void 0);_defineProperty(this,"scope",{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE});_defineProperty(this,"domNodeEventBindings",new Map);_defineProperty(this,"domNodeTemplateCache",new Map);_defineProperty(this,"externalProperties",{});_defineProperty(this,"ignoreAttributeUpdateObservations",false);_defineProperty(this,"internalProperties",{});_defineProperty(this,"outputEventNames",new Set);_defineProperty(this,"instance",null);_initializerDefineProperty(this,"isRoot",_descriptor,this);_defineProperty(this,"runDomConnectionAndRenderingInSameEventQueue",false);_defineProperty(this,"self",Web);_defineProperty(this,"slots",{});this.prepareNewRenderingPromise();/*
265
+ NOTE: We cannot use something like "this." e.g. "this.self" to
266
+ determine class properties since instance properties like "self"
267
+ may not set properly yet because this method is called during
268
+ constructing this instance itself.
269
+ */this.self=this.constructor;if(!this.self._propertiesToReflectAsAttributes)this.self._propertiesToReflectAsAttributes=this.self.normalizePropertyTypeList(this.self.propertiesToReflectAsAttributes);this.generateAliasIndex();// NOTE: Shadow root will be applied when rendering the first time.
270
+ this.hostDomNode=this;this.rootInstance=this;/*
271
+ NOTE: We define getter and setter at the end to avoid shadowing
272
+ existing property names.
273
+ */this.defineGetterAndSetterInterface()}/**
274
+ * Triggered when ever a given attribute has changed and triggers to update
275
+ * configured dom content.
276
+ * @param name - Attribute name which was updates.
277
+ * @param oldValue - Old attribute value.
278
+ * @param newValue - New updated value.
279
+ */attributeChangedCallback(name,oldValue,newValue){if(this.ignoreAttributeUpdateObservations||oldValue===newValue)return;void this.onUpdateAttribute(name,newValue)}/**
280
+ * Updates given attribute representation.
281
+ * @param name - Attribute name which was updates.
282
+ * @param newValue - New updated value.
283
+ * @returns Promise resolving when attribute has been updated.
284
+ */onUpdateAttribute(name,newValue){const promise=new Promise(resolve=>this.pendingAttributeUpdates.push(()=>{this.evaluateStringOrNullAndSetAsProperty(name,newValue);if(this.batchAttributeUpdates){if(!(this.batchedAttributeUpdateRunning||this.batchedUpdateRunning)){this.batchedAttributeUpdateRunning=true;this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.batchedAttributeUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("attributeChanged")})}}else void this.render("attributeChanged");resolve()}));if(this.connectionRegistered)while(this.pendingAttributeUpdates.length)this.pendingAttributeUpdates.shift()();return promise}/**
285
+ * Triggered when this component is mounted into the document.
286
+ * Attaches event handler, grabs given slots, reflects external properties,
287
+ * and enqueues first rendering.
288
+ */connectedCallback(){// NOTE: Hack to support IE 11 here.
289
+ try{this.isConnected=true}catch{// Ignore error.
290
+ }this.connectionRegistered=true;// NOTE: Can be overwritten during optional root determining.
291
+ this.parentInstance=this;this.rootInstance=this;this.attachEventHandler();if(this.self.determineRootBinding){this.determineRootBinding();if(this.parentInstance!==this&&this.parentInstance.childComponentInstances)this.parentInstance.childComponentInstances.push(this)}if(this.self.applyRootBinding&&this.isRoot){this.determineRenderScope();this.applyBinding(this,this.scope)}while(this.pendingAttributeUpdates.length)this.pendingAttributeUpdates.shift()();this.batchedAttributeUpdateRunning=false;this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;this.grabGivenSlots();this.reflectExternalProperties(this.externalProperties);if(this.runDomConnectionAndRenderingInSameEventQueue)void this.render("connected");else void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{void this.render("connected")})}/**
292
+ * Triggered when this component is unmounted from the document. Event
293
+ * handlers will be removed and state updated accordingly.
294
+ */disconnectedCallback(){this.unRender("disconnected");this.unregisterConnectionState()}// endregion
295
+ // region getter/setter
296
+ /**
297
+ * Registers needed getter and setter to get notified about changes and
298
+ * reflect them.
299
+ */defineGetterAndSetterInterface(){const allPropertyNames=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unique)(Object.keys(this.self.propertyTypes).concat(this.self._propertyAliasIndex?Object.keys(this.self._propertyAliasIndex):[]));for(const propertyName of allPropertyNames){// If there already exists a local value, use them.
300
+ if(Object.prototype.hasOwnProperty.call(this,propertyName))this.setPropertyValue(/* eslint-disable @typescript-eslint/unbound-method */propertyName,this[propertyName]/* eslint-enable @typescript-eslint/unbound-method */);Object.defineProperty(this,propertyName,{configurable:true,get:()=>this.getPropertyValue(propertyName),set:value=>{this.setPropertyValue(propertyName,value);this.triggerPropertySpecificRendering(propertyName,value)}})}}/**
301
+ * Creates an index to match alias source and target against each other on
302
+ * constant runtime.
303
+ * @param name - Name to search an alternate name for.
304
+ * @returns Found alias or "null".
305
+ */getPropertyAlias(name){if(this.self._propertyAliasIndex&&Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,name))return this.self._propertyAliasIndex[name];return null}/**
306
+ * Generic property getter. Forwards properties from the "properties"
307
+ * field.
308
+ * @param name - Property name to retrieve.
309
+ * @returns Retrieved property value.
310
+ */getPropertyValue(name){const result=this.instance?.current?.properties&&(// NOTE: Base properties should not be shadowed.
311
+ Object.prototype.hasOwnProperty.call(!Web.propertyTypes,name)||Object.prototype.hasOwnProperty.call(this.instance.current.properties,name))?this.instance.current.properties[name]:this.internalProperties[name]??this.externalProperties[name];if(this.instance?.current?.state&&Object.prototype.hasOwnProperty.call(this.instance.current.state,name))return this.instance.current.state[name];return result}/**
312
+ * External property setter. Respects configured aliases.
313
+ * @param name - Property name to write.
314
+ * @param value - New value to write.
315
+ */setExternalPropertyValue(name,value){this.externalProperties[name]=value;const alias=this.getPropertyAlias(name);if(alias)this.externalProperties[alias]=value}/**
316
+ * Internal property setter. Respects configured aliases.
317
+ * @param name - Property name to write.
318
+ * @param value - New value to write.
319
+ */setInternalPropertyValue(name,value){this.internalProperties[name]=value;const alias=this.getPropertyAlias(name);if(alias)this.internalProperties[alias]=value}/**
320
+ * Generic property setter. Forwards field writes into internal and
321
+ * external property representations.
322
+ * @param name - Property name to write.
323
+ * @param value - New value to write.
324
+ */setPropertyValue(name,value){this.reflectProperties({[name]:value});this.setInternalPropertyValue(name,value)}/**
325
+ * Triggers a new rendering cycle and respects property-specific state
326
+ * connection.
327
+ * @param name - Property name to write.
328
+ * @param value - New value to write.
329
+ */triggerPropertySpecificRendering(name,value){if(this.batchPropertyUpdates){if(!(this.batchedPropertyUpdateRunning||this.batchedUpdateRunning)){this.batchedPropertyUpdateRunning=true;this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{if(value!==undefined&&this.isStateProperty(name)){void this.render("preStatePropertyChanged");void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.setInternalPropertyValue(name,undefined);this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("postStatePropertyChanged");this.triggerOutputEvents()})}else{this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("propertyChanged");this.triggerOutputEvents()}})}}else{const isStateProperty=this.isStateProperty(name);void this.render(isStateProperty?"preStatePropertyChanged":"propertyChanged");if(value!==undefined&&isStateProperty){this.setInternalPropertyValue(name,undefined);void this.render("postStatePropertyChanged")}this.triggerOutputEvents()}}// endregion
330
+ // region helper
331
+ /// region utility
332
+ unregisterConnectionState(){// NOTE: Hack to support IE 11 here.
333
+ try{this.isConnected=false}catch{// Ignore error.
334
+ }this.connectionRegistered=false;this.slots={}}unregisterDomNodeEventBindings(){for(const map of this.domNodeEventBindings.values())for(const deregister of map.values())deregister()}//// region dom nodes
335
+ /**
336
+ * Binds properties and event handler to the given dom node.
337
+ * @param domNode - Node to start traversing from.
338
+ * @param scope - Scope to render property value again.
339
+ */applyBinding(domNode,scope){if(!domNode.getAttributeNames)return;for(const attributeName of domNode.getAttributeNames()){let name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){const value=domNode.getAttribute(attributeName);if(value===null)continue;if(name.startsWith("attribute-")||name.startsWith("property-")){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,scope,false,true,domNode);if(evaluated.error){log.warn("Error occurred during processing given",`attribute binding "${attributeName}" on node:`,domNode,evaluated.error);continue}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
340
+ NOTE: Cast to "textContent" to have a writable
341
+ property here.
342
+ */domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope={log,event:undefined,parameters:undefined,...scope};/*
343
+ NOTE: We pre-compile event listener since they should
344
+ usually be called more often than binded.
345
+ */const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,scope,true,true,domNode);if(compilation.error)log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,compilation.error);else this.addSecureEventListener(domNode,name,(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction(/*
346
+ NOTE: We want to be sure to have
347
+ the same ordering as we have for
348
+ the scope names and to call
349
+ internal registered getter by
350
+ retrieving values. So simple using
351
+ "...Object.values(scope)" is not
352
+ appreciate here.
353
+ */...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){log.warn("Error occurred during processing","given event binding",`"${attributeName}" on node:`,domNode,`Given expression "${value}" could`,"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+`": ${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)}`)}})}}}}/**
354
+ * Binds properties and event handler to given, sibling, and nested nodes.
355
+ * @param domNode - Node to start traversing from.
356
+ * @param scope - Scope to render property value again.
357
+ * @param renderSlots - Indicates whether to render nested elements of
358
+ * slots (determined by an existing corresponding attribute).
359
+ */applyBindings(domNode,scope,renderSlots=true){while(domNode){if(domNode.attributes?.length&&(renderSlots||!domNode.getAttribute("slot")))this.applyBinding(domNode,scope);/*
360
+ NOTE: Slots of nested custom components (recognized by their
361
+ dash in name) should be rendered by their own.
362
+ */if(!domNode.nodeName.toLowerCase().includes("-"))this.applyBindings(domNode.firstChild,scope);domNode=domNode.nextSibling}}/**
363
+ * Compiles given node content and their children. Provides a corresponding
364
+ * map of compiled template functions connected to their (sub) nodes and
365
+ * expected scope names.
366
+ * @param domNode - Node to compile.
367
+ * @param scope - Scope to extract names from.
368
+ * @param options - Additional compile options.
369
+ * @param options.filter - Callback to exclude some node from being
370
+ * compiled.
371
+ * @param options.ignoreComponents - Indicates if component properties
372
+ * should be traversed or not.
373
+ * @param options.ignoreNestedComponents - Indicates if nested components
374
+ * should be traversed or not.
375
+ * @param options.unsafe - Indicates if full HTML generation should be
376
+ * allowed.
377
+ * @returns Map of compiled templates.
378
+ */compileDomNodeTemplate(domNode,scope=[],options={}){options={ignoreComponents:true,ignoreNestedComponents:true,unsafe:this.self.renderUnsafe,...options};const nodeName=domNode.nodeName.toLowerCase();/*
379
+ NOTE: Slots of nested custom components (recognized by their dash
380
+ in name) should be rendered / controlled by them on their own.
381
+ */if(options.ignoreComponents&&nodeName.includes("-"))return null;if(options.unsafe){let template=domNode.innerHTML;if(!template&&domNode.template)template=domNode.template;if(this.self.hasCode(template)){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(`\`${template}\``,scope);return{domNode,children:[],error:result.error,scopeNames:result.scopeNames,template,templateFunction:result.templateFunction}}return null}let template=null;if(nodeName==="#text"){const content=domNode.textContent;if(content&&this.self.hasCode(content))template=content.replace(/&nbsp;/g," ").trim()}const children=[];const result={children,domNode};if(template){const compilationResult=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(`\`${template}\``,scope);result.error=compilationResult.error;result.scopeNames=compilationResult.scopeNames;result.template=template;result.templateFunction=compilationResult.templateFunction}// Compile content of each nested node.
382
+ let currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||options.filter(currentDomNode)){const result=this.compileDomNodeTemplate(currentDomNode,scope,{...options,ignoreComponents:options.ignoreNestedComponents});if(result)children.push(result)}currentDomNode=currentDomNode.nextSibling}return result}/**
383
+ * @param options - Evaluation options.
384
+ * @param scope - Scope to evaluate against.
385
+ * @returns Evaluated string result or null.
386
+ */evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
387
+ * Compiles and evaluates given node content and their children. Replaces
388
+ * each node content with their evaluated representation.
389
+ * @param domNode - Node to evaluate.
390
+ * @param scope - Scope to render against.
391
+ * @param options - Compile options.
392
+ * @param options.applyBindings - Indicates whether to apply bindings to
393
+ * given dom nodes.
394
+ * @param options.filter - Callback to exclude some node from being
395
+ * compiled.
396
+ * @param options.ignoreComponents - Indicates if component properties
397
+ * should be traversed or not.
398
+ * @param options.ignoreNestedComponents - Indicates if nested components
399
+ * should be traversed or not.
400
+ * @param options.domNodeTemplateCache - Yet compiled dom nodes to just
401
+ * reference instead of recompiling.
402
+ * @param options.unsafe - Indicates if full HTML generation should be
403
+ * allowed.
404
+ */evaluateDomNodeTemplate(domNode,scope={},options={}){options={domNodeTemplateCache:this.domNodeTemplateCache,ignoreComponents:true,ignoreNestedComponents:true,unsafe:this.self.renderUnsafe,...options};const domNodeTemplateCache=options.domNodeTemplateCache;if(!domNodeTemplateCache.has(domNode)){const compilerOptions={filter:options.filter,ignoreComponents:options.ignoreComponents,ignoreNestedComponents:options.ignoreNestedComponents,unsafe:options.unsafe};const compiledDomNode=this.compileDomNodeTemplate(domNode,scope,compilerOptions);if(compiledDomNode)domNodeTemplateCache.set(domNode,compiledDomNode)}if(domNodeTemplateCache.has(domNode)){const compiledDomNode=domNodeTemplateCache.get(domNode);const output=this.evaluateCompiledDomNodeTemplate(compiledDomNode,scope);if(output!==null)if(options.unsafe&&domNode.innerHTML)domNode.innerHTML=output;else domNode.textContent=output;if(compiledDomNode.children.length){const evaluateChildDomNode=children=>{for(const childCompiledDomNode of children){const output=this.evaluateCompiledDomNodeTemplate(childCompiledDomNode,scope);if(output!==null)childCompiledDomNode.domNode.textContent=output;if(childCompiledDomNode.children.length)evaluateChildDomNode(childCompiledDomNode.children)}};evaluateChildDomNode(compiledDomNode.children)}}if(options.applyBindings)this.applyBindings(domNode,scope)}/**
405
+ * Adds an event listener to the given dom node so that it will be
406
+ * deregistered when the component instance is destroyed.
407
+ * @param domNode - Node to assign event handler to.
408
+ * @param name - Event name.
409
+ * @param handler - Callback to trigger when given event occurs.
410
+ * @param options - Add event listener options.
411
+ * @param removeOptions - Remove event listener options.
412
+ * @returns Deregister function.
413
+ */addSecureEventListener(domNode,name,handler,options,removeOptions){if(!this.domNodeEventBindings.has(domNode))this.domNodeEventBindings.set(// eslint-disable-next-line func-call-spacing
414
+ domNode,new Map);const eventMap=this.domNodeEventBindings.get(domNode);const oldHandler=eventMap.get(name);if(oldHandler&&oldHandler!==handler)oldHandler();const deregister=()=>{domNode.removeEventListener(name,handler,removeOptions);eventMap.delete(name);if(eventMap.size===0)this.domNodeEventBindings.delete(domNode)};eventMap.set(name,deregister);domNode.addEventListener(name,handler,options);return deregister}//// endregion
415
+ /**
416
+ * Determines initial root which initializes rendering digest.
417
+ */determineRootBinding(){/*
418
+ If this component is the root component, we have to trigger
419
+ nested event handler by our own in global context since there is no
420
+ parent doing that for us.
421
+ */let currentElement=this.parentNode;while(currentElement){const isComponent=currentElement instanceof Web||currentElement.nodeName.includes("-")&&currentElement.nodeName!=="#document-fragment";const isInShadowDOM=currentElement.parentNode===null&&/* eslint-disable @typescript-eslint/no-base-to-string */currentElement.toString()==="[object ShadowRoot]";/* eslint-enable @typescript-eslint/no-base-to-string */if(isComponent){// Check whether we found the first parent component.
422
+ if(this.rootInstance===this){this.parentInstance=currentElement;/*
423
+ NOTE: There is at least one parent, so we can set
424
+ "isRoot" to "false".
425
+ */this.setPropertyValue("isRoot",false)}this.rootInstance=currentElement}else if(isInShadowDOM)/*
426
+ NOTE: Assume none root if determined a wrapped closed
427
+ shadow DOM.
428
+ */this.setPropertyValue("isRoot",false);currentElement=currentElement.parentNode}}/**
429
+ * Checks if given content hast code (to compile and render).
430
+ * @param content - Potential string with code inside.
431
+ * @returns A boolean indicating whether given content has code.
432
+ */static hasCode(content){return(// NOTE: First three conditions are only for performance.
433
+ typeof content==="string"&&content.includes("${")&&content.includes("}")&&/\${[\s\S]+}/.test(content))}/**
434
+ * Converts given the list, item, or map to a map (with ordering).
435
+ * @param value - Attribute reflection configuration.
436
+ * @returns Generated map.
437
+ */static normalizePropertyTypeList(value){if(typeof value==="string")value=[value];if(Array.isArray(value)){const givenValue=value;const newValue=new Map;for(const name of givenValue)if(Object.prototype.hasOwnProperty.call(Web.propertyTypes,name))newValue.set(name,Web.propertyTypes[name]);return newValue}return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.convertPlainObjectToMap)(value)}/// endregion
438
+ /// region events
439
+ /**
440
+ * Attaches event handler to keep in sync with nested components properties
441
+ * states.
442
+ */attachEventHandler(){if(this.self.eventToPropertyMapping===null)return;/*
443
+ NOTE: We only reflect properties by implicit determined events if
444
+ their where no explicitly defined.
445
+ */const somethingDefined=this.attachExplicitDefinedOutputEventHandler();this.attachImplicitDefinedOutputEventHandler(!somethingDefined)}/**
446
+ * Attach explicitly defined event handler to synchronize internal and
447
+ * external property states.
448
+ * @returns Returns "true" if there are some defined and "false" otherwise.
449
+ */attachExplicitDefinedOutputEventHandler(){if(!this.self.eventToPropertyMapping)return false;// Grab all existing output to property definitions
450
+ let result=false;for(const name of Object.keys(this.self.eventToPropertyMapping))if(!Object.prototype.hasOwnProperty.call(this.internalProperties,name)){result=true;this.outputEventNames.add(name);this.setInternalPropertyValue(name,async(...parameters)=>{const result=await this.reflectEventToProperties(name,parameters);if(result)parameters[0]=result;this.forwardEvent(name,parameters)})}return result}/**
451
+ * Attach implicitly defined event handler to synchronize internal and
452
+ * external property states.
453
+ * @param reflectProperties - Indicates whether implicitly determined
454
+ * properties should be reflected.
455
+ */attachImplicitDefinedOutputEventHandler(reflectProperties=true){// Determine all event handlers to inject
456
+ for(const[name,type]of Object.entries(this.self.propertyTypes))if(!Object.prototype.hasOwnProperty.call(this.internalProperties,name)&&[clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func,"function"].includes(type)&&!this.self.renderProperties.includes(name)){this.outputEventNames.add(name);this.setInternalPropertyValue(name,(...parameters)=>{if(reflectProperties)void this.reflectEventToProperties(name,parameters);this.forwardEvent(name,parameters)})}}/**
457
+ * Triggers all identified events to communicate internal property / state
458
+ * changes.
459
+ */triggerOutputEvents(){for(const name of this.outputEventNames)this.forwardEvent(name,[this.externalProperties])}/**
460
+ * Forwards given event as the native web event.
461
+ * @param name - Event name.
462
+ * @param parameters - Event parameters.
463
+ * @returns False if event is cancelable, and at least one of the event
464
+ * handlers which received event called "Event.preventDefault()",
465
+ * otherwise true will be returned.
466
+ */forwardEvent(name,parameters){if(name.length>"onX".length&&name.startsWith("on"))name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.lowerCase)(name.substring(2));return this.dispatchEvent(new CustomEvent(name,{detail:{parameters}}))}/// endregion
467
+ /// region slots
468
+ /**
469
+ * Renders component given slot contents into the given dom node. If
470
+ * expected slots are not given but a fallback is specified, they will be
471
+ * loaded into internal slot mapping.
472
+ * @param targetDomNode - Target dom node to render slots into.
473
+ * @param scope - Environment to render slots again if specified.
474
+ */applySlots(targetDomNode,scope){for(const domNode of Array.from(targetDomNode.querySelectorAll("slot"))){const name=domNode.getAttribute("name");if(name===null||name==="default"){if(this.slots.default){if(this.self.renderSlots){if(this.self.evaluateSlots)for(const domNode of this.slots.default)this.evaluateDomNodeTemplate(domNode,scope);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.replace)(domNode,this.slots.default,Web.trimSlots)}}else this.slots.default=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unwrap)(domNode).map(domNode=>this.grabSlotContent(domNode));}else if(this.slots[name]){if(this.self.renderSlots){if(this.self.evaluateSlots)this.evaluateDomNodeTemplate(this.slots[name],scope);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.replace)(domNode,this.slots[name],Web.trimSlots)}}else this.slots[name]=this.grabSlotContent((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unwrap)(domNode).filter(domNode=>domNode.nodeName.toLowerCase()!=="#text")[0])}}/**
475
+ * Determines slot content from the given node.
476
+ * @param slot - Node to grab slot content from.
477
+ * @returns Determined slot.
478
+ */grabSlotContent(slot){/*
479
+ If real (template) code is wrapped in a "textarea" tag, unwrap it
480
+ now. This extra wrapping can be used to avoid first dom rendering
481
+ before template code has been evaluated.
482
+ */const element=clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node.firstElementChild?slot:null;if(element&&element.firstElementChild?.nodeName.toLowerCase()==="textarea"&&(!element.firstElementChild.hasAttribute("data-no-template")||element.firstElementChild.getAttribute("data-no-template")==="false")){const content=element.firstElementChild.value;/*
483
+ NOTE: These kinds of slots are always used as a template and
484
+ should therefore be copied in every case.
485
+ NOTE: A flat copy should suffice since we will replace nested
486
+ content.
487
+ NOTE: Remove template content in copied node to avoid rendering
488
+ them before being evaluated. We cannot remove template code
489
+ from the source node since this would make it impossible to
490
+ re-instantiate this slot during whole component
491
+ re-instantiation.
492
+ */element.classList.remove("web-component-template");const newSlot=element.cloneNode();element.classList.add("web-component-template");newSlot.innerHTML="";newSlot.template=content;return newSlot}return this.self.cloneSlots?slot.cloneNode(true):slot}/**
493
+ * Saves given slots.
494
+ */grabGivenSlots(){this.slots={};for(const slot of Array.from(this.querySelectorAll("[slot]"))){// NOTE: This is how we avoid grabbing slots from nested components.
495
+ let currentElement=slot.parentNode;let skip=true;while(currentElement){if(currentElement.nodeName.includes("-")){if(currentElement===this)skip=false;break}currentElement=currentElement.parentNode}if(skip)continue;const slotValue=slot.getAttribute("slot")?.trim();this.slots[slotValue??slot.nodeName.toLowerCase()]=this.grabSlotContent(slot)}if(this.slots.default)this.slots.default=[].concat(this.slots.default);else if(this.childNodes.length>0)this.slots.default=Array.from(this.childNodes).map(domNode=>this.grabSlotContent(domNode));else this.slots.default=[]}/// endregion
496
+ /// region properties
497
+ /**
498
+ * Determines if a given property name exists in wrapped component state.
499
+ * @param name - Property name to check if exists in state.
500
+ * @returns Boolean result.
501
+ */isStateProperty(name){return Boolean(this.instance?.current?.state&&(Object.prototype.hasOwnProperty.call(this.instance.current.state,name)||this.instance.current.state.modelState&&Object.prototype.hasOwnProperty.call(this.instance.current.state.modelState,name)))}/**
502
+ * Generates an alias to name and the other way around mapping if not
503
+ * exists.
504
+ */generateAliasIndex(){if(!this.self._propertyAliasIndex){this.self._propertyAliasIndex={...this.self.propertyAliases};// Align alias mapping for better performance while mapping them.
505
+ for(const[name,value]of Object.entries(this.self._propertyAliasIndex))if(!Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,value))this.self._propertyAliasIndex[value]=name}}/**
506
+ * Reflects wrapped component state back to web-component's attributes.
507
+ * @param properties - Properties to update in reflected attribute state.
508
+ */reflectExternalProperties(properties){/*
509
+ NOTE: We can avoid an additional attribute parsing for
510
+ reflections.
511
+ */this.ignoreAttributeUpdateObservations=true;for(const[name,value]of Object.entries(properties)){this.setExternalPropertyValue(name,value);if(!this.isConnected)continue;const attributeName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name);if(this.self._propertiesToReflectAsAttributes?.has(name))switch(this.self._propertiesToReflectAsAttributes.get(name)){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":if(value){if(this.getAttribute(attributeName)!=="")this.setAttribute(attributeName,"")}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":break;case"json":if(value){const representation=JSON.stringify(value);if(representation&&this.getAttribute(attributeName)!==representation){this.setAttribute(attributeName,representation);break}}if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":if(typeof value==="number"&&!isNaN(value)){const valueAsString=String(value);if(this.getAttribute(attributeName)!==valueAsString)this.setAttribute(attributeName,valueAsString)}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":if(value){if(this.getAttribute(attributeName)!==value)this.setAttribute(attributeName,value)}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:if(value){const representation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(value);if(representation&&this.getAttribute(attributeName)!==representation){this.setAttribute(attributeName,representation);break}}if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break}}this.ignoreAttributeUpdateObservations=false}/**
512
+ * Reflects wrapped component state back to web-component's attributes and
513
+ * properties.
514
+ * @param properties - Properties to update in reflected property state.
515
+ */reflectProperties(properties){this.reflectExternalProperties(properties);/*
516
+ NOTE: Do not reflect properties which are hold in state. These
517
+ values are only set once when they are explicitly set
518
+ (see "setPropertyValue").
519
+ */if(this.instance?.current?.state&&typeof this.instance.current.state==="object")for(const name of Object.keys(this.instance.current.state).concat(this.instance.current.state.modelState?Object.keys(this.instance.current.state.modelState):[]))if(Object.prototype.hasOwnProperty.call(this.internalProperties,name))/*
520
+ We want to avoid fully deleting this property to know
521
+ which properties exist in the underlying instance.
522
+ */this.setInternalPropertyValue(name,undefined);if(this.internalProperties.model?.state){delete this.internalProperties.model.state;this.setInternalPropertyValue("model",this.internalProperties.model)}for(const name of this.self.controllableProperties)if(Object.prototype.hasOwnProperty.call(properties,name))this.setInternalPropertyValue(name,properties[name])}/**
523
+ * Reflect the given event handler call with the given parameter back to
524
+ * current properties state.
525
+ * @param name - Event name.
526
+ * @param parameters - List of parameter to given event handler call.
527
+ * @returns Mapped properties or null if nothing could be mapped.
528
+ */async reflectEventToProperties(name,parameters){/*
529
+ NOTE: We enforce to update component state immediately after an
530
+ event occurs since batching usually does not make sense here. An
531
+ event runs within its own context.
532
+ On the other hand, it can be necessary to immediately reflect a
533
+ property change to the component internal state to avoid
534
+ contradicting internal render cycles.
535
+ */const oldBatchUpdatesConfiguration=this.batchUpdates;this.batchUpdates=false;let result=null;let handled=false;// region check if there exists an explicit mapper
536
+ if(this.self.eventToPropertyMapping&&Object.prototype.hasOwnProperty.call(this.self.eventToPropertyMapping,name)&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(this.self.eventToPropertyMapping[name])){const wrappedMapping=this.self.eventToPropertyMapping[name](...parameters,this);const mapping=wrappedMapping&&"then"in wrappedMapping&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(wrappedMapping.then)?await wrappedMapping:wrappedMapping;handled=true;if(Array.isArray(mapping)){result=mapping[0];this.reflectProperties(result);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.extend)(true,this.internalProperties,mapping[1])}else if(mapping===null)handled=false;else if(typeof mapping==="object"){result=mapping;this.reflectProperties(mapping)}}// endregion
537
+ if(!handled&&parameters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(parameters[0])){/*
538
+ Identified as somehow throw data back event (no synthetic
539
+ event; derived from a user-triggered one) when following
540
+ condition does not hold.
541
+ */let newProperties=parameters[0];if("persist"in parameters[0]&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(parameters[0].persist)){newProperties={};for(const propertyName of Object.keys(this.self.propertyTypes))for(const name of[propertyName].concat(this.getPropertyAlias(propertyName)??[])){const currentValue=parameters[0].currentTarget&&Object.prototype.hasOwnProperty.call(parameters[0].currentTarget,name)?/*
542
+ Update all known properties from event
543
+ target instance.
544
+ */parameters[0].currentTarget[name]:/*
545
+ Update all known properties from adapter
546
+ instance.
547
+ */this.getPropertyValue(name);if(currentValue!==this.externalProperties[name])newProperties[name]=currentValue}}else if(![null,undefined].includes(newProperties.detail?.value))newProperties={...newProperties.detail};result=newProperties;this.reflectProperties(newProperties)}this.triggerRender("propertyReflected");this.batchUpdates=oldBatchUpdatesConfiguration;return result}/**
548
+ * Evaluates the given property value depending on its property definition
549
+ * and registers in a property mapping object.
550
+ * @param attributeName - Name of given value.
551
+ * @param value - Value to evaluate.
552
+ */evaluateStringOrNullAndSetAsProperty(attributeName,value){const preEvaluate=attributeName.startsWith("-");const effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;let name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);const alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){const type=this.self.propertyTypes[name];if(preEvaluate){if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},false,true,this);if(result.error){log.warn(`Failed to process pre-evaluation attribute`,`"${attributeName}": ${result.error}. Will be`,"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{const booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{let error=null;let templateFunction;const scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),true,true,this);error=result.error;templateFunction=result.templateFunction;if(error)log.warn("Failed to compile given handler",`"${attributeName}": ${error}.`)}this.setInternalPropertyValue(name,(...parameters)=>{if(this.outputEventNames.has(name))void this.reflectEventToProperties(name,parameters);let result=undefined;if(!error){const scope={parameters,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE};for(const name of scopeNames)scope[name]=parameters[0];try{result=templateFunction?.(...scopeNames.map(name=>scope[name]),parameters,scope,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(name=>clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]))}catch(error){log.warn("Failed to evaluate function",`"${attributeName}" with expression`,`"${value}" and scope`,"variables",`"${scopeNames.join("\", \"")}" set to`,`"${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters)}":`,`${error}. Set property`,`to "undefined".`)}}if(!this.self.renderProperties.includes(name))this.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){let evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json",`attribute "${attributeName}":`,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
553
+ this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
554
+ NOTE: You should not name this variable "number" since
555
+ babel gets confused caused by existing module wide
556
+ property type variable "number".
557
+ */let numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{},false,true,this);if(evaluated.error){log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
558
+ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
559
+ /// region render
560
+ /**
561
+ * Produces a promise resolving when all nested rendering promises have
562
+ * been resolved. This only waits for registered nested components. That
563
+ * means that nested components which where connected before the parent
564
+ * component got initialized will not be waited for. That might happen
565
+ * when nested component types got registered before the parent ones.
566
+ */async waitForNestedComponentRendering(){if(!this.childComponentInstances)return;await Promise.all(this.childComponentInstances.map(component=>component.renderState.pending?component.renderState.promise:Promise.resolve()))}/**
567
+ * Resolves the rendering promise.
568
+ * @param reason - Rendering reason description.
569
+ * @param resolveRendering - Indicates whether to resolve the rendering or
570
+ * just return a resolving promise directly.
571
+ * @returns A promise resolving when all nested render promises have been
572
+ * resolved.
573
+ */async resolveRenderingPromiseIfSet(reason,resolveRendering){if(resolveRendering){await this.waitForNestedComponentRendering();this.renderState.pending=false;this.renderState.resolve(reason);this.prepareNewRenderingPromise()}}/**
574
+ * Sets up a new rendering cycle representing promise.
575
+ */prepareNewRenderingPromise(){if(!this.renderState.pending)this.renderState.promise=new Promise(resolve=>{this.renderState.resolve=reason=>{this.renderState.pending=false;resolve(reason)}})}/**
576
+ * Triggers a new rendering cycle by respecting batch configuration.
577
+ * @param reason - A description why rendering should be triggered.
578
+ */triggerRender(reason){if(this.batchUpdates){if(!this.batchedUpdateRunning){this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.batchedUpdateRunning=false;void this.render(reason)})}}else void this.render(reason)}/**
579
+ * Creates shadow root if not created yet and assigns to the current root
580
+ * property.
581
+ */applyShadowRootIfNotExisting(){if(this.self.shadowDOM&&this.hostDomNode===this)this.hostDomNode=(!("attachShadow"in this)&&"ShadyDOM"in window?window.ShadyDOM.wrap(this):this).attachShadow((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(this.self.shadowDOM)?this.self.shadowDOM:{mode:"open"})}/**
582
+ * Determines a new scope object with a useful default set of environment
583
+ * values.
584
+ * @param scope - To apply to generated scope.
585
+ */determineRenderScope(scope={}){this.scope={...(this.parentInstance?.scope||{}),...this.scope,...this.internalProperties,parentInstance:this.parentInstance,rootInstance:this.rootInstance,self:this,[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.lowerCase)(this.self._name)||"instance"]:this,...scope};this.scope.scope=this.scope}/**
586
+ * Does the rendering job. Should be called when ever state changes should
587
+ * be projected to the hosts dom content.
588
+ * @param reason - Description why rendering is necessary.
589
+ * @param resolveRendering - Indicates whether rendering should be resolved
590
+ * finally. Should be set to "false" via super calls in inherited render
591
+ * methods which do further dom manipulations afterward and resolve the
592
+ * rendering process by their own.
593
+ * @returns A promise resolving when rendering has been finished. A promise
594
+ * may be needed for classes inheriting from this class.
595
+ */async render(reason="unknown",resolveRendering=true){this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(this.isRoot){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);if(resolveRendering){await Promise.all(this.self.pendingRenderPromises);this.self.pendingRenderPromises=[]}}this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(!(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason,scope:this.scope}})))){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);return}const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(`\`${this.self.content}\``,this.scope);if(evaluated.error){log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
596
+ NOTE: We first render into an intermediate render target and apply
597
+ slot content until we finally publish everything to the document.
598
+ This avoids painting twice and internetexplorer bugs with an empty
599
+ node after first overwriting the content of "this.rootInstance".
600
+ */const renderTargetDomNode=document.createElement("div");renderTargetDomNode.innerHTML=evaluated.result;this.applySlots(renderTargetDomNode,{...this.scope,parentInstance:this});this.hostDomNode.innerHTML=renderTargetDomNode.innerHTML;/*
601
+ NOTE: Wait until nested components have registered themselves to be
602
+ able to wait for their rendering.
603
+ */await (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)();void this.waitForNestedComponentRendering().then(()=>{this.applyBindings(this.hostDomNode.firstChild,this.scope,this.self.renderSlots)});await this.resolveRenderingPromiseIfSet(reason,resolveRendering)}/**
604
+ * Should free up memory listeners related to deprecated HTML.
605
+ * @param _reason - Description why rendering is necessary.
606
+ * @param _reRenderReason - Description why a re-rendering is necessary.
607
+ */unRender(_reason="unknown",_reRenderReason){this.unregisterDomNodeEventBindings()}/// endregion
608
+ // endregion
609
+ },_defineProperty(_Web,"applyRootBinding",true),_defineProperty(_Web,"pendingRenderPromises",[]),_defineProperty(_Web,"content","<slot>Please provide a template to transclude.</slot>"),_defineProperty(_Web,"determineRootBinding",true),_defineProperty(_Web,"shadowDOM",null),_defineProperty(_Web,"observedAttributes",[]),_defineProperty(_Web,"controllableProperties",[]),_defineProperty(_Web,"eventToPropertyMapping",{}),_defineProperty(_Web,"propertyAliases",{}),_defineProperty(_Web,"propertyTypes",{onClick:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func}),_defineProperty(_Web,"propertiesToReflectAsAttributes",[]),_defineProperty(_Web,"renderProperties",["children"]),_defineProperty(_Web,"doRender",false),_defineProperty(_Web,"cloneSlots",false),_defineProperty(_Web,"evaluateSlots",false),_defineProperty(_Web,"renderSlots",true),_defineProperty(_Web,"trimSlots",true),_defineProperty(_Web,"renderUnsafe",false),_defineProperty(_Web,"_name","BaseWeb"),_defineProperty(_Web,"_propertyAliasIndex",void 0),_defineProperty(_Web,"_propertiesToReflectAsAttributes",void 0),_Web),_descriptor=_applyDecoratedDescriptor(_class.prototype,"isRoot",[_dec],{configurable:true,enumerable:true,writable:true,initializer:function(){return true}}),_class);const api={component:Web,register:(tagName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(Web._name))=>{customElements.define(tagName,Web)}};/* harmony default export */ const src_Web = (Web);
610
+ const __webpack_exports__GenericHTMLElement = __webpack_exports__.Hh;
611
+ const __webpack_exports__Web = __webpack_exports__.Nc;
612
+ const __webpack_exports__api = __webpack_exports__.FH;
613
+ const __webpack_exports__default = __webpack_exports__.Ay;
614
+ const __webpack_exports__log = __webpack_exports__.Rm;
615
+ export { __webpack_exports__GenericHTMLElement as GenericHTMLElement, __webpack_exports__Web as Web, __webpack_exports__api as api, __webpack_exports__default as default, __webpack_exports__log as log };