web-component-wrapper 0.0.614 → 0.0.616
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/ReactWeb.js +20 -20
- package/dist/Web.js +14 -23
- package/dist/bundle/ReactWeb.js +325 -305
- package/dist/bundle/Web.js +302 -291
- package/dist/bundle/compatible/ReactWeb.js +325 -305
- package/dist/bundle/compatible/Web.js +301 -287
- package/dist/bundle/compatible/decorator.js +289 -272
- package/dist/bundle/compatible/index.js +332 -320
- package/dist/bundle/decorator.js +289 -275
- package/dist/bundle/index.js +333 -325
- package/dist/compatible/ReactWeb.js +20 -20
- package/dist/compatible/Web.js +13 -19
- package/dist/compatible/decorator.js +3 -6
- package/dist/compatible/index.js +26 -34
- package/dist/decorator.js +3 -9
- package/dist/index.js +27 -39
- package/package.json +24 -24
- package/readme.md +23 -26
package/dist/ReactWeb.js
CHANGED
|
@@ -37,9 +37,9 @@ module.exports = x({ ["NullSymbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode
|
|
|
37
37
|
// -*- coding: utf-8 -*-
|
|
38
38
|
/** @module decorator *//* !
|
|
39
39
|
region header
|
|
40
|
-
[Project page](https://
|
|
40
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
41
41
|
|
|
42
|
-
Copyright Torben Sickert (info["~at~"]
|
|
42
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
43
43
|
|
|
44
44
|
License
|
|
45
45
|
-------
|
|
@@ -84,14 +84,14 @@ module.exports = x({ ["NullSymbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode
|
|
|
84
84
|
/* unused harmony import specifier */ var camelCaseToDelimited;
|
|
85
85
|
/* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
86
86
|
/* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
87
|
-
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
87
|
+
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = /*#__PURE__*/__webpack_require__(2);
|
|
88
88
|
// #!/usr/bin/env babel-node
|
|
89
89
|
// -*- coding: utf-8 -*-
|
|
90
90
|
/** @module web *//* !
|
|
91
91
|
region header
|
|
92
|
-
[Project page](https://
|
|
92
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
93
93
|
|
|
94
|
-
Copyright Torben Sickert (info["~at~"]
|
|
94
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
95
95
|
|
|
96
96
|
License
|
|
97
97
|
-------
|
|
@@ -101,7 +101,7 @@ module.exports = x({ ["NullSymbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode
|
|
|
101
101
|
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
102
102
|
endregion
|
|
103
103
|
*/// region imports
|
|
104
|
-
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,
|
|
104
|
+
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,e){if("object"!=typeof t||!t)return t;var r;if("undefined"!=typeof Symbol&&void 0!==(r=t[Symbol.toPrimitive])){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?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
|
|
105
105
|
const log=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Logger({name:"web-component-wrapper.web"});/*
|
|
106
106
|
NOTE: We mock HTMLElement to be able to load this class and derived one
|
|
107
107
|
into node environments.
|
|
@@ -279,13 +279,13 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
279
279
|
* Binds properties and event handler to the given dom node.
|
|
280
280
|
* @param domNode - Node to start traversing from.
|
|
281
281
|
* @param scope - Scope to render property value again.
|
|
282
|
-
*/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,binding: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/*
|
|
282
|
+
*/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,binding:domNode});if(evaluated.error){void 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/*
|
|
283
283
|
NOTE: Cast to "textContent" to have a writable
|
|
284
284
|
property here.
|
|
285
285
|
*/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};/*
|
|
286
286
|
NOTE: We pre-compile event listener since they should
|
|
287
287
|
usually be called more often than binded.
|
|
288
|
-
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding: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(/*
|
|
288
|
+
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding:domNode});if(compilation.error)void 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(/*
|
|
289
289
|
NOTE: We want to be sure to have
|
|
290
290
|
the same ordering as we have for
|
|
291
291
|
the scope names and to call
|
|
@@ -293,7 +293,7 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
293
293
|
retrieving values. So simple using
|
|
294
294
|
"...Object.values(scope)" is not
|
|
295
295
|
appreciate here.
|
|
296
|
-
*/...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)}`)}})}}}}/**
|
|
296
|
+
*/...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){void 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)}`)}})}}}}/**
|
|
297
297
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
298
298
|
* @param domNode - Node to start traversing from.
|
|
299
299
|
* @param scope - Scope to render property value again.
|
|
@@ -326,7 +326,7 @@ let currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
326
326
|
* @param options - Evaluation options.
|
|
327
327
|
* @param scope - Scope to evaluate against.
|
|
328
328
|
* @returns Evaluated string result or null.
|
|
329
|
-
*/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}/**
|
|
329
|
+
*/evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){void log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
|
|
330
330
|
* Compiles and evaluates given node content and their children. Replaces
|
|
331
331
|
* each node content with their evaluated representation.
|
|
332
332
|
* @param domNode - Node to evaluate.
|
|
@@ -492,12 +492,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
492
492
|
* and registers in a property mapping object.
|
|
493
493
|
* @param attributeName - Name of given value.
|
|
494
494
|
* @param value - Value to evaluate.
|
|
495
|
-
*/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,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding: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,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding: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.
|
|
495
|
+
*/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,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding:this});if(result.error){void 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,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=result.error;templateFunction=result.templateFunction;if(error)void 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){void 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){void 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.
|
|
496
496
|
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}/*
|
|
497
497
|
NOTE: You should not name this variable "number" since
|
|
498
498
|
babel gets confused caused by existing module wide
|
|
499
499
|
property type variable "number".
|
|
500
|
-
*/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,{binding: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.
|
|
500
|
+
*/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,{binding:this});if(evaluated.error){void log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
501
501
|
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
|
|
502
502
|
/// region render
|
|
503
503
|
/**
|
|
@@ -535,7 +535,7 @@ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyVal
|
|
|
535
535
|
* rendering process by their own.
|
|
536
536
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
537
537
|
* may be needed for classes inheriting from this class.
|
|
538
|
-
*/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}\``,{scope: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();/*
|
|
538
|
+
*/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}\``,{scope:this.scope});if(evaluated.error){void log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
|
|
539
539
|
NOTE: We first render into an intermediate render target and apply
|
|
540
540
|
slot content until we finally publish everything to the document.
|
|
541
541
|
This avoids painting twice and internetexplorer bugs with an empty
|
|
@@ -605,15 +605,15 @@ var property_types_ = __webpack_require__(1);
|
|
|
605
605
|
;// external "react-dom/client"
|
|
606
606
|
|
|
607
607
|
// EXTERNAL MODULE: ./src/Web.ts
|
|
608
|
-
var Web = __webpack_require__(3);
|
|
608
|
+
var Web = /*#__PURE__*/__webpack_require__(3);
|
|
609
609
|
;// ./src/ReactWeb.ts
|
|
610
610
|
// #!/usr/bin/env babel-node
|
|
611
611
|
// -*- coding: utf-8 -*-
|
|
612
612
|
/** @module react *//* !
|
|
613
613
|
region header
|
|
614
|
-
[Project page](https://
|
|
614
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
615
615
|
|
|
616
|
-
Copyright Torben Sickert (info["~at~"]
|
|
616
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
617
617
|
|
|
618
618
|
License
|
|
619
619
|
-------
|
|
@@ -623,7 +623,7 @@ var Web = __webpack_require__(3);
|
|
|
623
623
|
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
624
624
|
endregion
|
|
625
625
|
*/// region imports
|
|
626
|
-
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,
|
|
626
|
+
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,e){if("object"!=typeof t||!t)return t;var r;if("undefined"!=typeof Symbol&&void 0!==(r=t[Symbol.toPrimitive])){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)};// endregion
|
|
627
627
|
const log=new external_clientnode_.Logger({name:"web-component-wrapper.react-web"});/*
|
|
628
628
|
Live cycle:
|
|
629
629
|
|
|
@@ -748,17 +748,17 @@ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)dom
|
|
|
748
748
|
actually rendering the nested component.
|
|
749
749
|
*/if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
|
|
750
750
|
/// region pre-compile dynamic properties
|
|
751
|
-
let knownScopeNames=Object.keys(scope);const compiledProperties={};for(const attributeName of domNode.getAttributeNames()){let value=domNode.getAttribute(attributeName);if(value===null)continue;let extend=false;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.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){const{error,originalScopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames});if(error){log.warn("Error occurred during compiling given attribute",`binding "${attributeName}" on node:`,domNode,error);continue}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);value={originalScopeNames,templateFunction:templateFunction.bind(this)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[...knownScopeNames,"event"];if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[...knownScopeNames,"parameters"];/*
|
|
751
|
+
let knownScopeNames=Object.keys(scope);const compiledProperties={};for(const attributeName of domNode.getAttributeNames()){let value=domNode.getAttribute(attributeName);if(value===null)continue;let extend=false;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.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){const{error,originalScopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames});if(error){void log.warn("Error occurred during compiling given attribute",`binding "${attributeName}" on node:`,domNode,error);continue}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);value={originalScopeNames,templateFunction:templateFunction.bind(this)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[...knownScopeNames,"event"];if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[...knownScopeNames,"parameters"];/*
|
|
752
752
|
NOTE: We pre-compile event listener since they should
|
|
753
753
|
usually be called more than it would be re-rendered.
|
|
754
|
-
*/const{error,originalScopeNames,scopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames,execute:true});if(error){log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,error);continue}const eventHandler=templateFunction.bind(this);value=(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{eventHandler(/*
|
|
754
|
+
*/const{error,originalScopeNames,scopeNames,templateFunction}=(0,external_clientnode_.compile)(value,{scope:knownScopeNames,execute:true});if(error){void log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,error);continue}const eventHandler=templateFunction.bind(this);value=(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{eventHandler(/*
|
|
755
755
|
NOTE: We want to be ensured to have the same
|
|
756
756
|
ordering as we have for the scope names and to
|
|
757
757
|
call internal registered getter by retrieving
|
|
758
758
|
values. So simple using
|
|
759
759
|
"...Object.values(scope)" is not appreciate
|
|
760
760
|
here.
|
|
761
|
-
*/...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",`"${scopeNames.join("\", \"")}":`,(0,external_clientnode_.represent)(error))}}}else name=attributeName;const mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if(value?.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
761
|
+
*/...originalScopeNames.map(name=>scope[name]))}catch(error){void log.warn("Error occurred during processing given",`event binding "${attributeName}" on node: `,domNode,`Given expression "${value}" could`,"not be evaluated with given scope names",`"${scopeNames.join("\", \"")}":`,(0,external_clientnode_.represent)(error))}}}else name=attributeName;const mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if(value?.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
|
|
762
762
|
compiledProperties[extend?"":name]=value;else if(!isComponent)/*
|
|
763
763
|
NOTE: Properties of components are evaluated already by
|
|
764
764
|
them self and set as "internalProperties". Those
|
package/dist/Web.js
CHANGED
|
@@ -34,9 +34,9 @@ module.exports = x({ ["any"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_proper
|
|
|
34
34
|
// -*- coding: utf-8 -*-
|
|
35
35
|
/** @module decorator *//* !
|
|
36
36
|
region header
|
|
37
|
-
[Project page](https://
|
|
37
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
38
38
|
|
|
39
|
-
Copyright Torben Sickert (info["~at~"]
|
|
39
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
40
40
|
|
|
41
41
|
License
|
|
42
42
|
-------
|
|
@@ -112,24 +112,16 @@ module.exports = x({ ["any"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_proper
|
|
|
112
112
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
|
|
113
113
|
/******/
|
|
114
114
|
/************************************************************************/
|
|
115
|
-
let __webpack_exports__ = {};
|
|
116
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
117
|
-
/* harmony export */ Ay: () => (src_Web),
|
|
118
|
-
/* harmony export */ FH: () => (/* binding */ api),
|
|
119
|
-
/* harmony export */ Hh: () => (/* binding */ GenericHTMLElement),
|
|
120
|
-
/* harmony export */ Nc: () => (/* binding */ Web),
|
|
121
|
-
/* harmony export */ Rm: () => (/* binding */ log)
|
|
122
|
-
/* harmony export */ });
|
|
123
115
|
/* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
124
116
|
/* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
125
|
-
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
117
|
+
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = /*#__PURE__*/__webpack_require__(2);
|
|
126
118
|
// #!/usr/bin/env babel-node
|
|
127
119
|
// -*- coding: utf-8 -*-
|
|
128
120
|
/** @module web *//* !
|
|
129
121
|
region header
|
|
130
|
-
[Project page](https://
|
|
122
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
131
123
|
|
|
132
|
-
Copyright Torben Sickert (info["~at~"]
|
|
124
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
133
125
|
|
|
134
126
|
License
|
|
135
127
|
-------
|
|
@@ -139,7 +131,7 @@ let __webpack_exports__ = {};
|
|
|
139
131
|
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
140
132
|
endregion
|
|
141
133
|
*/// region imports
|
|
142
|
-
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,
|
|
134
|
+
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,e){if("object"!=typeof t||!t)return t;var r;if("undefined"!=typeof Symbol&&void 0!==(r=t[Symbol.toPrimitive])){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?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
|
|
143
135
|
const log=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Logger({name:"web-component-wrapper.web"});/*
|
|
144
136
|
NOTE: We mock HTMLElement to be able to load this class and derived one
|
|
145
137
|
into node environments.
|
|
@@ -317,13 +309,13 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
317
309
|
* Binds properties and event handler to the given dom node.
|
|
318
310
|
* @param domNode - Node to start traversing from.
|
|
319
311
|
* @param scope - Scope to render property value again.
|
|
320
|
-
*/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,binding: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/*
|
|
312
|
+
*/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,binding:domNode});if(evaluated.error){void 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/*
|
|
321
313
|
NOTE: Cast to "textContent" to have a writable
|
|
322
314
|
property here.
|
|
323
315
|
*/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};/*
|
|
324
316
|
NOTE: We pre-compile event listener since they should
|
|
325
317
|
usually be called more often than binded.
|
|
326
|
-
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding: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(/*
|
|
318
|
+
*/const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,{scope,execute:true,binding:domNode});if(compilation.error)void 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(/*
|
|
327
319
|
NOTE: We want to be sure to have
|
|
328
320
|
the same ordering as we have for
|
|
329
321
|
the scope names and to call
|
|
@@ -331,7 +323,7 @@ try{this.isConnected=false}catch{// Ignore error.
|
|
|
331
323
|
retrieving values. So simple using
|
|
332
324
|
"...Object.values(scope)" is not
|
|
333
325
|
appreciate here.
|
|
334
|
-
*/...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)}`)}})}}}}/**
|
|
326
|
+
*/...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){void 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)}`)}})}}}}/**
|
|
335
327
|
* Binds properties and event handler to given, sibling, and nested nodes.
|
|
336
328
|
* @param domNode - Node to start traversing from.
|
|
337
329
|
* @param scope - Scope to render property value again.
|
|
@@ -364,7 +356,7 @@ let currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||
|
|
|
364
356
|
* @param options - Evaluation options.
|
|
365
357
|
* @param scope - Scope to evaluate against.
|
|
366
358
|
* @returns Evaluated string result or null.
|
|
367
|
-
*/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}/**
|
|
359
|
+
*/evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){void log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){void log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
|
|
368
360
|
* Compiles and evaluates given node content and their children. Replaces
|
|
369
361
|
* each node content with their evaluated representation.
|
|
370
362
|
* @param domNode - Node to evaluate.
|
|
@@ -530,12 +522,12 @@ if(!handled&¶meters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isO
|
|
|
530
522
|
* and registers in a property mapping object.
|
|
531
523
|
* @param attributeName - Name of given value.
|
|
532
524
|
* @param value - Value to evaluate.
|
|
533
|
-
*/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,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding: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,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding: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.
|
|
525
|
+
*/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,{scope:{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},binding:this});if(result.error){void 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,{scope:scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),execute:true,binding:this});error=result.error;templateFunction=result.templateFunction;if(error)void 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){void 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){void 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.
|
|
534
526
|
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}/*
|
|
535
527
|
NOTE: You should not name this variable "number" since
|
|
536
528
|
babel gets confused caused by existing module wide
|
|
537
529
|
property type variable "number".
|
|
538
|
-
*/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,{binding: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.
|
|
530
|
+
*/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,{binding:this});if(evaluated.error){void log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
|
|
539
531
|
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
|
|
540
532
|
/// region render
|
|
541
533
|
/**
|
|
@@ -573,7 +565,7 @@ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyVal
|
|
|
573
565
|
* rendering process by their own.
|
|
574
566
|
* @returns A promise resolving when rendering has been finished. A promise
|
|
575
567
|
* may be needed for classes inheriting from this class.
|
|
576
|
-
*/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}\``,{scope: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();/*
|
|
568
|
+
*/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}\``,{scope:this.scope});if(evaluated.error){void log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
|
|
577
569
|
NOTE: We first render into an intermediate render target and apply
|
|
578
570
|
slot content until we finally publish everything to the document.
|
|
579
571
|
This avoids painting twice and internetexplorer bugs with an empty
|
|
@@ -588,5 +580,4 @@ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyVal
|
|
|
588
580
|
*/unRender(_reason="unknown",_reRenderReason){this.unregisterDomNodeEventBindings()}/// endregion
|
|
589
581
|
// endregion
|
|
590
582
|
},_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);
|
|
591
|
-
|
|
592
|
-
export { GenericHTMLElement, Web, api, __webpack_exports__default as default, log };
|
|
583
|
+
export { GenericHTMLElement, Web, api, src_Web as default, log };
|