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/index.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 exports log, GenericHTMLElement, Web */
|
|
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
|
|
@@ -575,15 +575,15 @@ var property_types_ = __webpack_require__(1);
|
|
|
575
575
|
;// external "react-dom/client"
|
|
576
576
|
|
|
577
577
|
// EXTERNAL MODULE: ./src/Web.ts
|
|
578
|
-
var Web = __webpack_require__(3);
|
|
578
|
+
var Web = /*#__PURE__*/__webpack_require__(3);
|
|
579
579
|
;// ./src/ReactWeb.ts
|
|
580
580
|
// #!/usr/bin/env babel-node
|
|
581
581
|
// -*- coding: utf-8 -*-
|
|
582
582
|
/** @module react *//* !
|
|
583
583
|
region header
|
|
584
|
-
[Project page](https://
|
|
584
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
585
585
|
|
|
586
|
-
Copyright Torben Sickert (info["~at~"]
|
|
586
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
587
587
|
|
|
588
588
|
License
|
|
589
589
|
-------
|
|
@@ -593,7 +593,7 @@ var Web = __webpack_require__(3);
|
|
|
593
593
|
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
594
594
|
endregion
|
|
595
595
|
*/// region imports
|
|
596
|
-
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,
|
|
596
|
+
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
|
|
597
597
|
const log=new external_clientnode_.Logger({name:"web-component-wrapper.react-web"});/*
|
|
598
598
|
Live cycle:
|
|
599
599
|
|
|
@@ -718,17 +718,17 @@ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)dom
|
|
|
718
718
|
actually rendering the nested component.
|
|
719
719
|
*/if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
|
|
720
720
|
/// region pre-compile dynamic properties
|
|
721
|
-
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"];/*
|
|
721
|
+
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"];/*
|
|
722
722
|
NOTE: We pre-compile event listener since they should
|
|
723
723
|
usually be called more than it would be re-rendered.
|
|
724
|
-
*/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(/*
|
|
724
|
+
*/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(/*
|
|
725
725
|
NOTE: We want to be ensured to have the same
|
|
726
726
|
ordering as we have for the scope names and to
|
|
727
727
|
call internal registered getter by retrieving
|
|
728
728
|
values. So simple using
|
|
729
729
|
"...Object.values(scope)" is not appreciate
|
|
730
730
|
here.
|
|
731
|
-
*/...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}".
|
|
731
|
+
*/...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}".
|
|
732
732
|
compiledProperties[extend?"":name]=value;else if(!isComponent)/*
|
|
733
733
|
NOTE: Properties of components are evaluated already by
|
|
734
734
|
them self and set as "internalProperties". Those
|
|
@@ -846,18 +846,17 @@ for(const name of["isRoot","isTrusted","__composed"])if(Object.prototype.hasOwnP
|
|
|
846
846
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
|
|
847
847
|
/******/
|
|
848
848
|
/************************************************************************/
|
|
849
|
-
let __webpack_exports__ = {};
|
|
850
849
|
/* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
851
|
-
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
852
|
-
/* harmony import */ var _ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
853
|
-
/* harmony import */ var _Web_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
|
|
850
|
+
/* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_1__ = /*#__PURE__*/__webpack_require__(2);
|
|
851
|
+
/* harmony import */ var _ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__ = /*#__PURE__*/__webpack_require__(4);
|
|
852
|
+
/* harmony import */ var _Web_js__WEBPACK_IMPORTED_MODULE_3__ = /*#__PURE__*/__webpack_require__(3);
|
|
854
853
|
// #!/usr/bin/env babel-node
|
|
855
854
|
// -*- coding: utf-8 -*-
|
|
856
855
|
/** @module index *//* !
|
|
857
856
|
region header
|
|
858
|
-
[Project page](https://
|
|
857
|
+
[Project page](https://tsickert.com/web-component-wrapper)
|
|
859
858
|
|
|
860
|
-
Copyright Torben Sickert (info["~at~"]
|
|
859
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
861
860
|
|
|
862
861
|
License
|
|
863
862
|
-------
|
|
@@ -867,7 +866,7 @@ let __webpack_exports__ = {};
|
|
|
867
866
|
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
868
867
|
endregion
|
|
869
868
|
*/// region imports
|
|
870
|
-
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,
|
|
869
|
+
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
|
|
871
870
|
const property=_decorator_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A;const ReactWeb=_ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Ay;const reactWebAPI=_ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__/* .api */ .FH;const webAPI=_Web_js__WEBPACK_IMPORTED_MODULE_3__/* .api */ .FH;const Web=_Web_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Ay;/**
|
|
872
871
|
* Wraps given react component as web component.
|
|
873
872
|
* @param component - React component to wrap.
|
|
@@ -885,15 +884,4 @@ let propertiesToReflectAsAttributes=configuration.propertiesToReflectAsAttribute
|
|
|
885
884
|
* Runtime generated web component.
|
|
886
885
|
*/class ConcreteComponent extends ReactWeb{constructor(...args){super(...args);_defineProperty(this,"self",ConcreteComponent);_defineProperty(this,"internalProperties",configuration.internalProperties?{...configuration.internalProperties}:component.internalProperties?{...component.internalProperties}:{});_defineProperty(this,"unmountOnDisconnect",configuration.unmountOnDisconnect??true)}}_defineProperty(ConcreteComponent,"attachWebComponentAdapterIfNotExists",typeof configuration.attachWebComponentAdapterIfNotExists==="boolean"?configuration.attachWebComponentAdapterIfNotExists:true);_defineProperty(ConcreteComponent,"content",component);_defineProperty(ConcreteComponent,"observedAttributes",ReactWeb.observedAttributes.concat(attributeNames)// NOTE: Respect pre-evaluation indicator attributes.
|
|
887
886
|
.concat(attributeNames.map(name=>`-${name}`)));_defineProperty(ConcreteComponent,"controllableProperties",component.controllableProperties||configuration.controllableProperties||[]);_defineProperty(ConcreteComponent,"eventToPropertyMapping",configuration.eventToPropertyMapping===null?configuration.eventToPropertyMapping:configuration.eventToPropertyMapping?{...configuration.eventToPropertyMapping}:component.eventToPropertyMapping===null?component.eventToPropertyMapping:component.eventToPropertyMapping?{...component.eventToPropertyMapping}:{});_defineProperty(ConcreteComponent,"propertyAliases",{...ReactWeb.propertyAliases,...propertyAliases});_defineProperty(ConcreteComponent,"propertiesToReflectAsAttributes",propertiesToReflectAsAttributes);_defineProperty(ConcreteComponent,"propertyTypes",{...ReactWeb.propertyTypes,...propertyTypes});_defineProperty(ConcreteComponent,"renderProperties",configuration.renderProperties??component.renderProperties??ReactWeb.renderProperties);_defineProperty(ConcreteComponent,"_name",name);const webComponentAPI={component:ConcreteComponent,register:(tagName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name))=>{customElements.define(tagName,ConcreteComponent)}};return webComponentAPI};/* harmony default export */ const src = (wrapAsWebComponent);
|
|
888
|
-
|
|
889
|
-
/* harmony export */ "Ay", 0, /* export default binding */ src,
|
|
890
|
-
/* harmony export */ "MZ", 0, /* binding */ property,
|
|
891
|
-
/* harmony export */ "Nc", 0, /* binding */ Web,
|
|
892
|
-
/* harmony export */ "YF", 0, /* binding */ wrapAsWebComponent,
|
|
893
|
-
/* harmony export */ "Z1", 0, /* binding */ webAPI,
|
|
894
|
-
/* harmony export */ "g0", 0, /* binding */ ReactWeb,
|
|
895
|
-
/* harmony export */ "mT", 0, /* binding */ reactWebAPI
|
|
896
|
-
/* harmony export */ ]);
|
|
897
|
-
|
|
898
|
-
const __webpack_exports__default = __webpack_exports__.Ay;
|
|
899
|
-
export { ReactWeb, Web, __webpack_exports__default as default, property, reactWebAPI, webAPI, wrapAsWebComponent };
|
|
887
|
+
export { ReactWeb, Web, src as default, property, reactWebAPI, webAPI, wrapAsWebComponent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-component-wrapper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.616",
|
|
4
4
|
"description": "Generic web-component base class and framework specific wrapper.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"webcomponent",
|
|
13
13
|
"web-component"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://
|
|
15
|
+
"homepage": "https://tsickert.com/web-component-wrapper",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"email": "info@
|
|
17
|
+
"email": "info@tsickert.com",
|
|
18
18
|
"url": "https://github.com/thaibault/web-component-wrapper/issues"
|
|
19
19
|
},
|
|
20
20
|
"license": "CC-BY-3.0",
|
|
21
21
|
"author": {
|
|
22
|
-
"email": "info@
|
|
22
|
+
"email": "info@tsickert.com",
|
|
23
23
|
"name": "Torben Sickert",
|
|
24
|
-
"url": "https://
|
|
24
|
+
"url": "https://tsickert.com"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
],
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"scripts": {
|
|
56
|
-
"build": "yarn build:types
|
|
56
|
+
"build": "yarn build:types && yarn build:plain && yarn build:compatible && yarn build:bundle && yarn build:bundle:compatible",
|
|
57
57
|
"build:bundle": "weboptimizer build '{__reference__: \"target:bundle\"}'",
|
|
58
58
|
"build:bundle:compatible": "weboptimizer build '{__reference__: [\"target:bundle\", \"target:compatible\", \"target:bundle:compatible\"]}'",
|
|
59
59
|
"build:compatible": "weboptimizer build '{__reference__: \"target:compatible\"}'",
|
|
60
60
|
"build:plain": "weboptimizer build",
|
|
61
61
|
"build:types": "weboptimizer build:types",
|
|
62
|
-
"check": "yarn check:types
|
|
62
|
+
"check": "yarn check:types && yarn lint",
|
|
63
63
|
"check:types": "weboptimizer check:types",
|
|
64
64
|
"clear": "weboptimizer clear",
|
|
65
65
|
"document": "weboptimizer document",
|
|
@@ -67,39 +67,39 @@
|
|
|
67
67
|
"prepare": "yarn build",
|
|
68
68
|
"serve": "weboptimizer serve",
|
|
69
69
|
"start": "yarn serve",
|
|
70
|
-
"test": "yarn clear
|
|
71
|
-
"test:browser": "yarn clear
|
|
72
|
-
"test:coverage": "yarn clear
|
|
73
|
-
"test:coverage:report": "yarn clear
|
|
70
|
+
"test": "yarn clear && weboptimizer test",
|
|
71
|
+
"test:browser": "yarn clear && weboptimizer test:browser",
|
|
72
|
+
"test:coverage": "yarn clear && weboptimizer test:coverage",
|
|
73
|
+
"test:coverage:report": "yarn clear && weboptimizer test:coverage:report",
|
|
74
74
|
"update:documentation": "web-documentation",
|
|
75
75
|
"watch": "weboptimizer build --watch"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@babel/eslint-parser": "^8.0.
|
|
78
|
+
"@babel/eslint-parser": "^8.0.7",
|
|
79
79
|
"@eslint/js": "^10.0.1",
|
|
80
80
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
81
81
|
"@types/ejs": "^3.1.5",
|
|
82
82
|
"@types/html-minifier": "^4.0.6",
|
|
83
83
|
"@types/jsdom": "^30.0.0",
|
|
84
|
-
"@types/node": "^26.5
|
|
84
|
+
"@types/node": "^26.6.5",
|
|
85
85
|
"@types/react": "^19.3.0",
|
|
86
86
|
"@types/react-dom": "^19.3.0",
|
|
87
87
|
"@types/webpack-env": "^1.18.8",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
89
|
-
"@typescript-eslint/parser": "^8.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^8.71.2",
|
|
89
|
+
"@typescript-eslint/parser": "^8.71.2",
|
|
90
90
|
"@webcomponents/webcomponentsjs": "^2.8.0",
|
|
91
|
-
"clientnode": "^4.0.
|
|
92
|
-
"eslint": "^10.
|
|
91
|
+
"clientnode": "^4.0.1522",
|
|
92
|
+
"eslint": "^10.12.0",
|
|
93
93
|
"eslint-config-google": "^0.14.0",
|
|
94
|
-
"eslint-plugin-jsdoc": "^
|
|
95
|
-
"jest": "30.5.
|
|
94
|
+
"eslint-plugin-jsdoc": "^65.3.6",
|
|
95
|
+
"jest": "30.5.2",
|
|
96
96
|
"jsdoc": "^4.0.5",
|
|
97
97
|
"prop-types": "^15.8.1",
|
|
98
|
-
"react": "^19.3.
|
|
99
|
-
"react-dom": "^19.3.
|
|
100
|
-
"typescript-eslint": "^8.
|
|
101
|
-
"web-documentation": "^1.0.
|
|
102
|
-
"weboptimizer": "^4.0.
|
|
98
|
+
"react": "^19.3.1",
|
|
99
|
+
"react-dom": "^19.3.1",
|
|
100
|
+
"typescript-eslint": "^8.71.2",
|
|
101
|
+
"web-documentation": "^1.0.61",
|
|
102
|
+
"weboptimizer": "^4.0.87",
|
|
103
103
|
"webpack-dev-server": "^6.0.0"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- !/usr/bin/env markdown
|
|
2
2
|
-*- coding: utf-8 -*-
|
|
3
3
|
region header
|
|
4
|
-
Copyright Torben Sickert (info["~at~"]
|
|
4
|
+
Copyright Torben Sickert (info["~at~"]tsickert.com) 16.12.2012
|
|
5
5
|
|
|
6
6
|
License
|
|
7
7
|
-------
|
|
@@ -10,7 +10,8 @@ This library written by Torben Sickert stands under a creative commons naming
|
|
|
10
10
|
3.0 unported license. See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
11
11
|
endregion -->
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
<!--|deDE:Projektstatus-->
|
|
14
|
+
Project Status
|
|
14
15
|
--------------
|
|
15
16
|
|
|
16
17
|
[](https://www.npmjs.com/package/web-component-wrapper)
|
|
@@ -26,9 +27,9 @@ Project status
|
|
|
26
27
|
[](https://coveralls.io/github/thaibault/web-component-wrapper)
|
|
27
28
|
|
|
28
29
|
[](https://github.com/thaibault/web-component-wrapper/actions/workflows/deploy-web-documentation.yaml)
|
|
29
|
-
[](https://tsickert.com/web-component-wrapper)
|
|
30
31
|
|
|
31
|
-
<!--|deDE:
|
|
32
|
+
<!--|deDE:Verwendung-->
|
|
32
33
|
Use case
|
|
33
34
|
--------
|
|
34
35
|
|
|
@@ -39,7 +40,6 @@ Encapsulate your components as web-components.
|
|
|
39
40
|
<!--wd-table-of-contents-->
|
|
40
41
|
</div>
|
|
41
42
|
|
|
42
|
-
<!--|deDE:Installation-->
|
|
43
43
|
Installation
|
|
44
44
|
------------
|
|
45
45
|
|
|
@@ -55,10 +55,14 @@ zip file here and inject or request via cdn in HTML:
|
|
|
55
55
|
npm install web-component-wrapper
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
<!--|deDE:Beispiele-->
|
|
59
|
+
<!--|frFR:Exemples-->
|
|
60
|
+
Examples
|
|
61
|
+
--------
|
|
62
|
+
|
|
58
63
|
```TypeScript
|
|
59
64
|
import {func, object} from 'clientnode/property-types'
|
|
60
|
-
import {property} from 'web-component-wrapper
|
|
61
|
-
import {Web} from 'web-component-wrapper/Web'
|
|
65
|
+
import {property, Web} from 'web-component-wrapper'
|
|
62
66
|
|
|
63
67
|
export class MyWebComponent<
|
|
64
68
|
TElement = HTMLElement,
|
|
@@ -128,35 +132,24 @@ export class MyWebComponent<
|
|
|
128
132
|
customElements.define('my-web-component', MyWebComponent)
|
|
129
133
|
```
|
|
130
134
|
|
|
131
|
-
<!--|deDE:Beispiele-->
|
|
132
|
-
Examples
|
|
133
|
-
--------
|
|
134
|
-
|
|
135
|
-
<!--|deDE:Lade via CDN-->
|
|
136
|
-
### Load via CDN
|
|
137
|
-
|
|
138
|
-
<!--showExample:hidden-->
|
|
139
|
-
|
|
140
|
-
```HTML
|
|
141
|
-
<script
|
|
142
|
-
src="https://unpkg.com/web-component-wrapper@latest/dist/bundle/index.js"
|
|
143
|
-
></script>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
135
|
<!--|deDE:Einfaches Web-Component Beispiel-->
|
|
147
136
|
### Simple Web-Component
|
|
148
137
|
|
|
149
138
|
<!--showExample:JavaScript-->
|
|
150
139
|
|
|
151
140
|
```JavaScript
|
|
152
|
-
|
|
141
|
+
import {
|
|
142
|
+
property, Web
|
|
143
|
+
} from 'https://unpkg.com/web-component-wrapper@latest/dist/bundle/index.js'
|
|
144
|
+
|
|
145
|
+
class MyGreeting extends Web {
|
|
153
146
|
static doRender = true
|
|
154
147
|
static evaluateSlots = true
|
|
155
148
|
static determineRootBinding = false
|
|
156
149
|
static content = '<div>Hello ${rootInstance.greetingName}</div>'
|
|
157
150
|
}
|
|
158
151
|
// Alternative to the decorator syntax:
|
|
159
|
-
|
|
152
|
+
property()({self: MyGreeting}, 'greetingName')
|
|
160
153
|
|
|
161
154
|
customElements.define('my-greeting', MyGreeting)
|
|
162
155
|
```
|
|
@@ -171,14 +164,18 @@ customElements.define('my-greeting', MyGreeting)
|
|
|
171
164
|
### Simple React-Web-Component
|
|
172
165
|
|
|
173
166
|
```JavaScript
|
|
174
|
-
|
|
167
|
+
import {
|
|
168
|
+
property, ReactWeb
|
|
169
|
+
} from 'https://unpkg.com/web-component-wrapper@latest/dist/bundle/index.js'
|
|
170
|
+
|
|
171
|
+
class MyReactGreeting extends ReactWeb {
|
|
175
172
|
static doRender = true
|
|
176
173
|
static evaluateSlots = true
|
|
177
174
|
// Content has a react component to wrap.
|
|
178
175
|
static content = ({name}) => <div>Hello {name}</div>
|
|
179
176
|
}
|
|
180
177
|
// Alternative to the decorator syntax:
|
|
181
|
-
|
|
178
|
+
property()({self: MyReactGreeting}, 'name')
|
|
182
179
|
|
|
183
180
|
customElements.define('my-react-greeting', MyReactGreeting)
|
|
184
181
|
```
|