diff --git a/dist/webscript.esm.js b/dist/webscript.esm.js index e9a24b8..38e61a0 100644 --- a/dist/webscript.esm.js +++ b/dist/webscript.esm.js @@ -1,2 +1,2 @@ -function r(){return(r=Object.assign||function(r){for(var e=1;er.length)&&(e=r.length);for(var n=0,t=new Array(e);n=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=r[Symbol.iterator]()).next.bind(t)}function t(r){for(var e,t=r[0],o=r.slice(1),i=[],a=n(t.entries());!(e=a()).done;){var u=e.value,l=u[0],p=u[1];""!==p&&i.push(p);var c=o[l];void 0!==c&&i.push(c)}return i}function o(e,n){function o(){var e,n=[].slice.call(arguments),o=n,i=o[0],u=this.__element_info__,l=u.props,p=u.prop;return void 0===i?(delete(l=r({},l))[p],a({props:l,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),a({props:l=r({},l,((e={})[p]=i,e)),prop:null}))}function i(e){return a({props:e=r({},this.__element_info__.props,e),prop:null})}function a(r){var a=new Proxy(function(){},{apply:function(r,o,i){var u=a.__element_info__.props;if("function"==typeof u.exec){var l=u.exec;delete u.exec;var p=l(a,i);return u.exec=l,p}var c,f=i[0];Array.isArray(f)&&Object.isFrozen(f)&&(i=t(i)),Array.isArray(u.children)&&((c=u.children).push.apply(c,i),i=u.children,delete u.children);for(var s=0;s5?r.__element_info__.props[e.slice(0,-5)]:(r.__element_info__.prop=e,o):void 0}});return a.__element_info__=r,a}return a({props:{},prop:null})}export default function(r,e){if(void 0===e&&(e=[]),"function"!=typeof r)throw Error("elementConstructor argument must be present and it must be a function.");if(e.length>0){for(var t,i=[],a=n(e);!(t=a()).done;)i.push(o(r,t.value));return i}return new Proxy(function(){},{get:function(e,n){var t=e[n];return void 0!==t?t:(e[n]=o(r,n),e[n])}})} +function r(){return(r=Object.assign||function(r){for(var e=1;er.length)&&(e=r.length);for(var n=0,t=new Array(e);n=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=r[Symbol.iterator]()).next.bind(t)}function t(r){for(var e,t=r[0],o=r.slice(1),i=[],a=n(t.entries());!(e=a()).done;){var u=e.value,l=u[0],p=u[1];""!==p&&i.push(p);var c=o[l];void 0!==c&&i.push(c)}return i}var o=new RegExp("·","g");function i(e,n){function i(){var e,n=[].slice.call(arguments),o=n,i=o[0],a=this.__element_info__,l=a.props,p=a.prop;return void 0===i?(delete(l=r({},l))[p],u({props:l,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),u({props:l=r({},l,((e={})[p]=i,e)),prop:null}))}function a(e){return u({props:e=r({},this.__element_info__.props,e),prop:null})}function u(r){var u=new Proxy(function(){},{apply:function(r,o,i){var a=u.__element_info__.props;if("function"==typeof a.exec){var l=a.exec;delete a.exec;var p=l(u,i);return a.exec=l,p}var c,f=i[0];Array.isArray(f)&&Object.isFrozen(f)&&(i=t(i)),Array.isArray(a.children)&&((c=a.children).push.apply(c,i),i=a.children,delete a.children);for(var s=0;s5?r.__element_info__.props[e.slice(0,-5)]:(r.__element_info__.prop=e,i)):void 0}});return u.__element_info__=r,u}return u({props:{},prop:null})}export default function(r,e){if(void 0===e&&(e=[]),"function"!=typeof r)throw Error("elementConstructor argument must be present and it must be a function.");if(e.length>0){for(var t,o=[],a=n(e);!(t=a()).done;)o.push(i(r,t.value));return o}return new Proxy(function(){},{get:function(e,n){var t=e[n];return void 0!==t?t:(e[n]=i(r,n),e[n])}})} //# sourceMappingURL=webscript.esm.js.map diff --git a/dist/webscript.esm.js.map b/dist/webscript.esm.js.map index 73897d4..12a33f9 100644 --- a/dist/webscript.esm.js.map +++ b/dist/webscript.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"webscript.esm.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","endsWith","slice","types","Error","builders"],"mappings":"8gCAAA,SAASA,EAAeC,GAGtB,UAFOC,EAA4BD,KAAhBE,EAAgBF,WAC7BG,EAAS,OACUF,EAAQG,0BAAW,eAAhCC,OAAOC,OACP,KAANA,GACFH,EAAOI,KAAKD,GAEd,IAAIE,EAAMN,EAAaG,QACJ,IAARG,GACTL,EAAOI,KAAKC,GAGhB,OAAOL,EAGT,SAASM,EAAqBC,EAAaC,GACzC,SAASC,UAAoBZ,6BACbA,EAATa,SACiBC,KAAKC,iBAArBC,IAAAA,MAAOC,IAAAA,KACb,YAAqB,IAAVJ,UACTG,OAAaA,IACAC,GACNC,EAAc,CAAEF,MAAAA,EAAOC,KAAM,SAE7BE,MAAMC,QAAQP,IAAUQ,OAAOC,SAAST,GAC/CA,EAAQd,EAAeC,GAAMuB,KAAK,IAE3BvB,EAAKwB,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T,MAAM8B,MAAM,0EAEd,GAAID,EAAMf,OAAS,EAAG,CAEpB,IADA,MAAIiB,EAAW,OACOF,kBACpBE,EAASlC,KAAKE,EAAqBC,YAErC,OAAO+B,EAGP,WAAWb,MAAM,aAAW,CAC1BQ,aAAIN,EAAQb,GACV,IAAMd,EAAS2B,EAAOb,GACtB,YAAsB,IAAXd,EACFA,GAET2B,EAAOb,GAAQR,EAAqBC,EAAaO,GAC1Ca,EAAOb"} \ No newline at end of file +{"version":3,"file":"webscript.esm.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nlet interpunct = new RegExp(\"·\",\"g\");\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if(prop.indexOf(\"·\") !== -1) {\r\n prop = prop.replace(interpunct, \"-\");\r\n }\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","interpunct","RegExp","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","indexOf","replace","endsWith","slice","types","Error","builders"],"mappings":"8gCAAA,SAASA,EAAeC,GAGtB,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,IAAI7B,EAAM0B,EAASG,GACA,mBAAR7B,GAAsBA,EAAIS,mBACnCiB,EAASG,GAAK7B,KAGlB,OAAOI,gBAAYC,EAAMK,UAAUgB,KAErCI,aAAIN,EAAQb,GACV,IAAMhB,EAAS6B,EAAOb,GACtB,YAAsB,IAAXhB,EACFA,EAEI,UAATgB,EACKQ,EAEgB,iBAATR,IACY,IAAvBA,EAAKoB,QAAQ,OACdpB,EAAOA,EAAKqB,QAAQ/B,EAAY,MAE9BU,EAAKsB,SAAS,UAAYtB,EAAKO,OAAS,EACnCM,EAAOf,iBAAiBC,MAAMC,EAAKuB,MAAM,GAAI,KAEtDV,EAAOf,iBAAiBE,KAAOA,EACxBL,cAKb,OADAe,EAAQZ,iBAAmBW,EACpBC,EAET,OAAOT,EAAc,CAAEF,MAAO,GAAIC,KAAM,sBAI1C,SAAkBP,EAAa+B,GAC7B,YAD6BA,IAAAA,EAAQ,IACV,mBAAhB/B,EACT,MAAMgC,MAAM,0EAEd,GAAID,EAAMjB,OAAS,EAAG,CAEpB,IADA,MAAImB,EAAW,OACOF,kBACpBE,EAAStC,KAAKI,EAAqBC,YAErC,OAAOiC,EAGP,WAAWf,MAAM,aAAW,CAC1BQ,aAAIN,EAAQb,GACV,IAAMhB,EAAS6B,EAAOb,GACtB,YAAsB,IAAXhB,EACFA,GAET6B,EAAOb,GAAQR,EAAqBC,EAAaO,GAC1Ca,EAAOb"} \ No newline at end of file diff --git a/dist/webscript.js b/dist/webscript.js index 6f977b4..19b8c79 100644 --- a/dist/webscript.js +++ b/dist/webscript.js @@ -1,2 +1,2 @@ -function r(){return(r=Object.assign||function(r){for(var e=1;er.length)&&(e=r.length);for(var n=0,t=new Array(e);n=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=r[Symbol.iterator]()).next.bind(t)}function t(r){for(var e,t=r[0],o=r.slice(1),i=[],a=n(t.entries());!(e=a()).done;){var u=e.value,l=u[0],p=u[1];""!==p&&i.push(p);var c=o[l];void 0!==c&&i.push(c)}return i}function o(e,n){function o(){var e,n=[].slice.call(arguments),o=n,i=o[0],u=this.__element_info__,l=u.props,p=u.prop;return void 0===i?(delete(l=r({},l))[p],a({props:l,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),a({props:l=r({},l,((e={})[p]=i,e)),prop:null}))}function i(e){return a({props:e=r({},this.__element_info__.props,e),prop:null})}function a(r){var a=new Proxy(function(){},{apply:function(r,o,i){var u=a.__element_info__.props;if("function"==typeof u.exec){var l=u.exec;delete u.exec;var p=l(a,i);return u.exec=l,p}var c,f=i[0];Array.isArray(f)&&Object.isFrozen(f)&&(i=t(i)),Array.isArray(u.children)&&((c=u.children).push.apply(c,i),i=u.children,delete u.children);for(var s=0;s5?r.__element_info__.props[e.slice(0,-5)]:(r.__element_info__.prop=e,o):void 0}});return a.__element_info__=r,a}return a({props:{},prop:null})}module.exports=function(r,e){if(void 0===e&&(e=[]),"function"!=typeof r)throw Error("elementConstructor argument must be present and it must be a function.");if(e.length>0){for(var t,i=[],a=n(e);!(t=a()).done;)i.push(o(r,t.value));return i}return new Proxy(function(){},{get:function(e,n){var t=e[n];return void 0!==t?t:(e[n]=o(r,n),e[n])}})}; +function r(){return(r=Object.assign||function(r){for(var e=1;er.length)&&(e=r.length);for(var n=0,t=new Array(e);n=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=r[Symbol.iterator]()).next.bind(t)}function t(r){for(var e,t=r[0],o=r.slice(1),i=[],a=n(t.entries());!(e=a()).done;){var u=e.value,l=u[0],p=u[1];""!==p&&i.push(p);var c=o[l];void 0!==c&&i.push(c)}return i}var o=new RegExp("·","g");function i(e,n){function i(){var e,n=[].slice.call(arguments),o=n,i=o[0],a=this.__element_info__,l=a.props,p=a.prop;return void 0===i?(delete(l=r({},l))[p],u({props:l,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),u({props:l=r({},l,((e={})[p]=i,e)),prop:null}))}function a(e){return u({props:e=r({},this.__element_info__.props,e),prop:null})}function u(r){var u=new Proxy(function(){},{apply:function(r,o,i){var a=u.__element_info__.props;if("function"==typeof a.exec){var l=a.exec;delete a.exec;var p=l(u,i);return a.exec=l,p}var c,f=i[0];Array.isArray(f)&&Object.isFrozen(f)&&(i=t(i)),Array.isArray(a.children)&&((c=a.children).push.apply(c,i),i=a.children,delete a.children);for(var s=0;s5?r.__element_info__.props[e.slice(0,-5)]:(r.__element_info__.prop=e,i)):void 0}});return u.__element_info__=r,u}return u({props:{},prop:null})}module.exports=function(r,e){if(void 0===e&&(e=[]),"function"!=typeof r)throw Error("elementConstructor argument must be present and it must be a function.");if(e.length>0){for(var t,o=[],a=n(e);!(t=a()).done;)o.push(i(r,t.value));return o}return new Proxy(function(){},{get:function(e,n){var t=e[n];return void 0!==t?t:(e[n]=i(r,n),e[n])}})}; //# sourceMappingURL=webscript.js.map diff --git a/dist/webscript.js.map b/dist/webscript.js.map index 954789b..8b9a0b5 100644 --- a/dist/webscript.js.map +++ b/dist/webscript.js.map @@ -1 +1 @@ -{"version":3,"file":"webscript.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","endsWith","slice","types","Error","builders"],"mappings":"8gCAAA,SAASA,EAAeC,GAGtB,UAFOC,EAA4BD,KAAhBE,EAAgBF,WAC7BG,EAAS,OACUF,EAAQG,0BAAW,eAAhCC,OAAOC,OACP,KAANA,GACFH,EAAOI,KAAKD,GAEd,IAAIE,EAAMN,EAAaG,QACJ,IAARG,GACTL,EAAOI,KAAKC,GAGhB,OAAOL,EAGT,SAASM,EAAqBC,EAAaC,GACzC,SAASC,UAAoBZ,6BACbA,EAATa,SACiBC,KAAKC,iBAArBC,IAAAA,MAAOC,IAAAA,KACb,YAAqB,IAAVJ,UACTG,OAAaA,IACAC,GACNC,EAAc,CAAEF,MAAAA,EAAOC,KAAM,SAE7BE,MAAMC,QAAQP,IAAUQ,OAAOC,SAAST,GAC/CA,EAAQd,EAAeC,GAAMuB,KAAK,IAE3BvB,EAAKwB,OAAS,IACrBX,EAAQb,GAGHkB,EAAc,CAAEF,MADvBA,OAAaA,UAAQC,GAAOJ,MACEI,KAAM,QAEtC,SAASQ,EAAeT,GAGtB,OAAOE,EAAc,CAAEF,MADvBA,OAD+BF,KAAKC,iBAA9BC,MACyBA,GACDC,KAAM,OAEtC,SAASC,EAAcQ,GACrB,IAAIC,EAAU,IAAIC,MAAM,aAAW,CACjCC,eAAMC,EAAQC,EAASC,OACfhB,EAAUW,EAAQZ,iBAAlBC,MACN,GAA0B,mBAAfA,EAAMiB,KAAqB,CACpC,IAAIA,EAAOjB,EAAMiB,YACVjB,EAAMiB,KACb,IAAI9B,EAAS8B,EAAKN,EAASK,GAE3B,OADAhB,EAAMiB,KAAOA,EACN9B,EAPsB,MAS1B+B,EAASF,KACVb,MAAMC,QAAQc,IAAUb,OAAOC,SAASY,KAC1CF,EAAWjC,EAAeiC,IAExBb,MAAMC,QAAQJ,EAAMgB,eACtBhB,EAAMgB,UAASzB,aAAQyB,GACvBA,EAAWhB,EAAMgB,gBACVhB,EAAMgB,UAEf,IAAK,IAAIG,EAAI,EAAGA,EAAIH,EAASR,OAAQW,IAAK,CACxC,IAAI3B,EAAMwB,EAASG,GACA,mBAAR3B,GAAsBA,EAAIO,mBACnCiB,EAASG,GAAK3B,KAGlB,OAAOE,gBAAYC,EAAMK,UAAUgB,KAErCI,aAAIN,EAAQb,GACV,IAAMd,EAAS2B,EAAOb,GACtB,YAAsB,IAAXd,EACFA,EAEI,UAATc,EACKQ,EAEgB,iBAATR,EACVA,EAAKoB,SAAS,UAAYpB,EAAKO,OAAS,EACnCM,EAAOf,iBAAiBC,MAAMC,EAAKqB,MAAM,GAAI,KAEtDR,EAAOf,iBAAiBE,KAAOA,EACxBL,aAKb,OADAe,EAAQZ,iBAAmBW,EACpBC,EAET,OAAOT,EAAc,CAAEF,MAAO,GAAIC,KAAM,sBAI1C,SAAkBP,EAAa6B,GAC7B,YAD6BA,IAAAA,EAAQ,IACV,mBAAhB7B,EACT,MAAM8B,MAAM,0EAEd,GAAID,EAAMf,OAAS,EAAG,CAEpB,IADA,MAAIiB,EAAW,OACOF,kBACpBE,EAASlC,KAAKE,EAAqBC,YAErC,OAAO+B,EAGP,WAAWb,MAAM,aAAW,CAC1BQ,aAAIN,EAAQb,GACV,IAAMd,EAAS2B,EAAOb,GACtB,YAAsB,IAAXd,EACFA,GAET2B,EAAOb,GAAQR,EAAqBC,EAAaO,GAC1Ca,EAAOb"} \ No newline at end of file +{"version":3,"file":"webscript.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nlet interpunct = new RegExp(\"·\",\"g\");\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if(prop.indexOf(\"·\") !== -1) {\r\n prop = prop.replace(interpunct, \"-\");\r\n }\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","interpunct","RegExp","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","indexOf","replace","endsWith","slice","types","Error","builders"],"mappings":"8gCAAA,SAASA,EAAeC,GAGtB,UAFOC,EAA4BD,KAAhBE,EAAgBF,WAC7BG,EAAS,OACUF,EAAQG,0BAAW,eAAhCC,OAAOC,OACP,KAANA,GACFH,EAAOI,KAAKD,GAEd,IAAIE,EAAMN,EAAaG,QACJ,IAARG,GACTL,EAAOI,KAAKC,GAGhB,OAAOL,EAGT,IAAIM,EAAa,IAAIC,OAAO,IAAI,KAEhC,SAASC,EAAqBC,EAAaC,GACzC,SAASC,UAAoBd,6BACbA,EAATe,SACiBC,KAAKC,iBAArBC,IAAAA,MAAOC,IAAAA,KACb,YAAqB,IAAVJ,UACTG,OAAaA,IACAC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EAAKuB,MAAM,GAAI,KAEtDV,EAAOf,iBAAiBE,KAAOA,EACxBL,cAKb,OADAe,EAAQZ,iBAAmBW,EACpBC,EAET,OAAOT,EAAc,CAAEF,MAAO,GAAIC,KAAM,sBAI1C,SAAkBP,EAAa+B,GAC7B,YAD6BA,IAAAA,EAAQ,IACV,mBAAhB/B,EACT,MAAMgC,MAAM,0EAEd,GAAID,EAAMjB,OAAS,EAAG,CAEpB,IADA,MAAImB,EAAW,OACOF,kBACpBE,EAAStC,KAAKI,EAAqBC,YAErC,OAAOiC,EAGP,WAAWf,MAAM,aAAW,CAC1BQ,aAAIN,EAAQb,GACV,IAAMhB,EAAS6B,EAAOb,GACtB,YAAsB,IAAXhB,EACFA,GAET6B,EAAOb,GAAQR,EAAqBC,EAAaO,GAC1Ca,EAAOb"} \ No newline at end of file diff --git a/dist/webscript.modern.js b/dist/webscript.modern.js index c6a9c6e..9f056d9 100644 --- a/dist/webscript.modern.js +++ b/dist/webscript.modern.js @@ -1,2 +1,2 @@ -function e(e){const[n,...t]=e,r=[];for(const[e,o]of n.entries()){""!==o&&r.push(o);let n=t[e];void 0!==n&&r.push(n)}return r}function n(n,t){function r(...n){let[t]=n,{props:r,prop:o}=this.__element_info__;return void 0===t?(r={...r},delete r[o],i({props:r,prop:null})):(Array.isArray(t)&&Object.isFrozen(t)?t=e(n).join(""):n.length>1&&(t=n),r={...r,[o]:t},i({props:r,prop:null}))}function o(e){let{props:n}=this.__element_info__;return i({props:e={...n,...e},prop:null})}function i(i){let l=new Proxy(()=>{},{apply(r,o,i){let{props:p}=l.__element_info__;if("function"==typeof p.exec){let e=p.exec;delete p.exec;let n=e(l,i);return p.exec=e,n}let[u]=i;Array.isArray(u)&&Object.isFrozen(u)&&(i=e(i)),Array.isArray(p.children)&&(p.children.push(...i),i=p.children,delete p.children);for(let e=0;e5?e.__element_info__.props[n.slice(0,-5)]:(e.__element_info__.prop=n,r):void 0}});return l.__element_info__=i,l}return i({props:{},prop:null})}export default function(e,t=[]){if("function"!=typeof e)throw Error("elementConstructor argument must be present and it must be a function.");if(t.length>0){let r=[];for(const o of t)r.push(n(e,o));return r}return new Proxy(()=>{},{get(t,r){const o=t[r];return void 0!==o?o:(t[r]=n(e,r),t[r])}})} +function e(e){const[n,...t]=e,r=[];for(const[e,o]of n.entries()){""!==o&&r.push(o);let n=t[e];void 0!==n&&r.push(n)}return r}let n=new RegExp("·","g");function t(t,r){function o(...n){let[t]=n,{props:r,prop:o}=this.__element_info__;return void 0===t?(r={...r},delete r[o],p({props:r,prop:null})):(Array.isArray(t)&&Object.isFrozen(t)?t=e(n).join(""):n.length>1&&(t=n),r={...r,[o]:t},p({props:r,prop:null}))}function l(e){let{props:n}=this.__element_info__;return p({props:e={...n,...e},prop:null})}function p(p){let i=new Proxy(()=>{},{apply(n,o,l){let{props:p}=i.__element_info__;if("function"==typeof p.exec){let e=p.exec;delete p.exec;let n=e(i,l);return p.exec=e,n}let[u]=l;Array.isArray(u)&&Object.isFrozen(u)&&(l=e(l)),Array.isArray(p.children)&&(p.children.push(...l),l=p.children,delete p.children);for(let e=0;e5?e.__element_info__.props[t.slice(0,-5)]:(e.__element_info__.prop=t,o)):void 0}});return i.__element_info__=p,i}return p({props:{},prop:null})}export default function(e,n=[]){if("function"!=typeof e)throw Error("elementConstructor argument must be present and it must be a function.");if(n.length>0){let r=[];for(const o of n)r.push(t(e,o));return r}return new Proxy(()=>{},{get(n,r){const o=n[r];return void 0!==o?o:(n[r]=t(e,r),n[r])}})} //# sourceMappingURL=webscript.modern.js.map diff --git a/dist/webscript.modern.js.map b/dist/webscript.modern.js.map index 51b1a0d..8328a0b 100644 --- a/dist/webscript.modern.js.map +++ b/dist/webscript.modern.js.map @@ -1 +1 @@ -{"version":3,"file":"webscript.modern.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","index","s","entries","push","arg","createInitialBuilder","constructor","type","setPropertyValue","value","props","prop","this","__element_info__","createBuilder","Array","isArray","Object","isFrozen","join","length","[object Object]","setPropsValues","existingProps","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","endsWith","slice","types","Error","builders","element"],"mappings":"AAAA,SAASA,EAAeC,GACtB,MAAOC,KAAYC,GAAgBF,EAC7BG,EAAS,GACf,IAAK,MAAOC,EAAOC,KAAMJ,EAAQK,UAAW,CAChC,KAAND,GACFF,EAAOI,KAAKF,GAEd,IAAIG,EAAMN,EAAaE,QACJ,IAARI,GACTL,EAAOI,KAAKC,GAGhB,OAAOL,EAGT,SAASM,EAAqBC,EAAaC,GACzC,SAASC,KAAoBZ,GAC3B,IAAKa,GAASb,GACVc,MAAEA,EAAFC,KAASA,GAASC,KAAKC,iBAC3B,YAAqB,IAAVJ,GACTC,EAAQ,IAAKA,UACNA,EAAMC,GACNG,EAAc,CAAEJ,MAAAA,EAAOC,KAAM,SAE7BI,MAAMC,QAAQP,IAAUQ,OAAOC,SAAST,GAC/CA,EAAQd,EAAeC,GAAMuB,KAAK,IAE3BvB,EAAKwB,OAAS,IACrBX,EAAQb,GAEVc,EAAQ,IAAKA,EAAOW,CAACV,GAAOF,GACrBK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AID,EAAMjB,OAAS,EAAG,CACpB,IAAImB,EAAW,GACf,IAAK,MAAMC,KAAWH,EACpBE,EAASpC,KAAKE,EAAqBC,EAAakC,IAElD,OAAOD,EAGP,WAAWb,MAAM,OAAW,CAC1BQ,IAAIN,EAAQjB,GACV,MAAMZ,EAAS6B,EAAOjB,GACtB,YAAsB,IAAXZ,EACFA,GAET6B,EAAOjB,GAAQN,EAAqBC,EAAaK,GAC1CiB,EAAOjB"} \ No newline at end of file +{"version":3,"file":"webscript.modern.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nlet interpunct = new RegExp(\"·\",\"g\");\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if(prop.indexOf(\"·\") !== -1) {\r\n prop = prop.replace(interpunct, \"-\");\r\n }\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","index","s","entries","push","arg","interpunct","RegExp","createInitialBuilder","constructor","type","setPropertyValue","value","props","prop","this","__element_info__","createBuilder","Array","isArray","Object","isFrozen","join","length","[object Object]","setPropsValues","existingProps","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","indexOf","replace","endsWith","slice","types","Error","builders","element"],"mappings":"AAAA,SAASA,EA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EAAMoB,gBACVpB,EAAMoB,UAEf,IAAK,IAAIG,EAAI,EAAGA,EAAIH,EAASV,OAAQa,IAAK,CACxC,IAAI/B,EAAM4B,EAASG,GACA,mBAAR/B,GAAsBA,EAAIW,mBACnCiB,EAASG,GAAK/B,KAGlB,OAAOI,EAAYC,EAAMG,KAAUoB,IAErCI,IAAIN,EAAQjB,GACV,MAAMd,EAAS+B,EAAOjB,GACtB,YAAsB,IAAXd,EACFA,EAEI,UAATc,EACKW,EAEgB,iBAATX,IACY,IAAvBA,EAAKwB,QAAQ,OACdxB,EAAOA,EAAKyB,QAAQjC,EAAY,MAE9BQ,EAAK0B,SAAS,UAAY1B,EAAKS,OAAS,EACnCQ,EAAOf,iBAAiBH,MAAMC,EAAK2B,MAAM,GAAI,KAEtDV,EAAOf,iBAAiBF,KAAOA,EACxBH,cAKb,OADAiB,EAAQZ,iBAAmBW,EACpBC,EAET,OAAOX,EAAc,CAAEJ,MAAO,GAAIC,KAAM,sBAI1C,SAAkBL,EAAaiC,EAAQ,IACrC,GAA2B,mBAAhBjC,EACT,MAAMkC,MAAM,0EAEd,GAAID,EAAMnB,OAAS,EAAG,CACpB,IAAIqB,EAAW,GACf,IAAK,MAAMC,KAAWH,EACpBE,EAASxC,KAAKI,EAAqBC,EAAaoC,IAElD,OAAOD,EAGP,WAAWf,MAAM,OAAW,CAC1BQ,IAAIN,EAAQjB,GACV,MAAMd,EAAS+B,EAAOjB,GACtB,YAAsB,IAAXd,EACFA,GAET+B,EAAOjB,GAAQN,EAAqBC,EAAaK,GAC1CiB,EAAOjB"} \ No newline at end of file diff --git a/dist/webscript.umd.js b/dist/webscript.umd.js index 9c4b5d7..bd60098 100644 --- a/dist/webscript.umd.js +++ b/dist/webscript.umd.js @@ -1,2 +1,2 @@ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).webscript=r()}(this,function(){function e(){return(e=Object.assign||function(e){for(var r=1;re.length)&&(r=e.length);for(var n=0,t=new Array(r);n=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function t(e){for(var r,t=e[0],o=e.slice(1),i=[],u=n(t.entries());!(r=u()).done;){var a=r.value,l=a[0],p=a[1];""!==p&&i.push(p);var f=o[l];void 0!==f&&i.push(f)}return i}function o(r,n){function o(){var r,n=[].slice.call(arguments),o=n,i=o[0],a=this.__element_info__,l=a.props,p=a.prop;return void 0===i?(delete(l=e({},l))[p],u({props:l,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),u({props:l=e({},l,((r={})[p]=i,r)),prop:null}))}function i(r){return u({props:r=e({},this.__element_info__.props,r),prop:null})}function u(e){var u=new Proxy(function(){},{apply:function(e,o,i){var a=u.__element_info__.props;if("function"==typeof a.exec){var l=a.exec;delete a.exec;var p=l(u,i);return a.exec=l,p}var f,c=i[0];Array.isArray(c)&&Object.isFrozen(c)&&(i=t(i)),Array.isArray(a.children)&&((f=a.children).push.apply(f,i),i=a.children,delete a.children);for(var s=0;s5?e.__element_info__.props[r.slice(0,-5)]:(e.__element_info__.prop=r,o):void 0}});return u.__element_info__=e,u}return u({props:{},prop:null})}return function(e,r){if(void 0===r&&(r=[]),"function"!=typeof e)throw Error("elementConstructor argument must be present and it must be a function.");if(r.length>0){for(var t,i=[],u=n(r);!(t=u()).done;)i.push(o(e,t.value));return i}return new Proxy(function(){},{get:function(r,n){var t=r[n];return void 0!==t?t:(r[n]=o(e,n),r[n])}})}}); +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).webscript=r()}(this,function(){function e(){return(e=Object.assign||function(e){for(var r=1;re.length)&&(r=e.length);for(var n=0,t=new Array(r);n=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function t(e){for(var r,t=e[0],o=e.slice(1),i=[],u=n(t.entries());!(r=u()).done;){var a=r.value,p=a[0],l=a[1];""!==l&&i.push(l);var f=o[p];void 0!==f&&i.push(f)}return i}var o=new RegExp("·","g");function i(r,n){function i(){var r,n=[].slice.call(arguments),o=n,i=o[0],u=this.__element_info__,p=u.props,l=u.prop;return void 0===i?(delete(p=e({},p))[l],a({props:p,prop:null})):(Array.isArray(i)&&Object.isFrozen(i)?i=t(n).join(""):n.length>1&&(i=n),a({props:p=e({},p,((r={})[l]=i,r)),prop:null}))}function u(r){return a({props:r=e({},this.__element_info__.props,r),prop:null})}function a(e){var a=new Proxy(function(){},{apply:function(e,o,i){var u=a.__element_info__.props;if("function"==typeof u.exec){var p=u.exec;delete u.exec;var l=p(a,i);return u.exec=p,l}var f,c=i[0];Array.isArray(c)&&Object.isFrozen(c)&&(i=t(i)),Array.isArray(u.children)&&((f=u.children).push.apply(f,i),i=u.children,delete u.children);for(var s=0;s5?e.__element_info__.props[r.slice(0,-5)]:(e.__element_info__.prop=r,i)):void 0}});return a.__element_info__=e,a}return a({props:{},prop:null})}return function(e,r){if(void 0===r&&(r=[]),"function"!=typeof e)throw Error("elementConstructor argument must be present and it must be a function.");if(r.length>0){for(var t,o=[],u=n(r);!(t=u()).done;)o.push(i(e,t.value));return o}return new Proxy(function(){},{get:function(r,n){var t=r[n];return void 0!==t?t:(r[n]=i(e,n),r[n])}})}}); //# sourceMappingURL=webscript.umd.js.map diff --git a/dist/webscript.umd.js.map b/dist/webscript.umd.js.map index e408dbe..220245e 100644 --- a/dist/webscript.umd.js.map +++ b/dist/webscript.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"webscript.umd.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","endsWith","slice","types","Error","builders"],"mappings":"gsCAAA,SAASA,EAAeC,GAGtB,UAFOC,EAA4BD,KAAhBE,EAAgBF,WAC7BG,EAAS,OACUF,EAAQG,0BAAW,eAAhCC,OAAOC,OACP,KAANA,GACFH,EAAOI,KAAKD,GAEd,IAAIE,EAAMN,EAAaG,QACJ,IAARG,GACTL,EAAOI,KAAKC,GAGhB,OAAOL,EAGT,SAASM,EAAqBC,EAAaC,GACzC,SAASC,UAAoBZ,6BACbA,EAATa,SACiBC,KAAKC,iBAArBC,IAAAA,MAAOC,IAAAA,KACb,YAAqB,IAAVJ,UACTG,OAAaA,IACAC,GACNC,EAAc,CAAEF,MAAAA,EAAOC,KAAM,SAE7BE,MAAMC,QAAQP,IAAUQ,OAAOC,SAAST,GAC/CA,EAAQd,EAAeC,GAAMuB,KAAK,IAE3BvB,EAAKwB,OAAS,IACrBX,EAAQb,GAGHkB,EAAc,CAAEF,MADvBA,OAAaA,UAAQC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AIiB,EAAW,OACOF,kBACpBE,EAASlC,KAAKE,EAAqBC,YAErC,OAAO+B,EAGP,WAAWb,MAAM,aAAW,CAC1BQ,aAAIN,EAAQb,GACV,IAAMd,EAAS2B,EAAOb,GACtB,YAAsB,IAAXd,EACFA,GAET2B,EAAOb,GAAQR,EAAqBC,EAAaO,GAC1Ca,EAAOb"} \ No newline at end of file +{"version":3,"file":"webscript.umd.js","sources":["../src/webscript.js"],"sourcesContent":["function templateValues(args) {\r\n const [strings, ...templateArgs] = args;\r\n const result = [];\r\n for (const [index, s] of strings.entries()) {\r\n if (s !== \"\") {\r\n result.push(s);\r\n }\r\n let arg = templateArgs[index];\r\n if (typeof arg !== \"undefined\") {\r\n result.push(arg);\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nlet interpunct = new RegExp(\"·\",\"g\");\r\n\r\nfunction createInitialBuilder(constructor, type) {\r\n function setPropertyValue(...args) {\r\n let [value] = args;\r\n let { props, prop } = this.__element_info__;\r\n if (typeof value === \"undefined\") {\r\n props = { ...props };\r\n delete props[prop];\r\n return createBuilder({ props, prop: null });\r\n }\r\n else if (Array.isArray(value) && Object.isFrozen(value)) {\r\n value = templateValues(args).join(\"\");\r\n }\r\n else if (args.length > 1) {\r\n value = args;\r\n }\r\n props = { ...props, [prop]: value };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function setPropsValues(props) {\r\n let { props: existingProps } = this.__element_info__;\r\n props = { ...existingProps, ...props };\r\n return createBuilder({ props, prop: null });\r\n }\r\n function createBuilder(propsInfo) {\r\n let builder = new Proxy(() => { }, {\r\n apply(target, thisArg, children) {\r\n let { props } = builder.__element_info__;\r\n if (typeof props.exec === \"function\") {\r\n let exec = props.exec;\r\n delete props.exec;\r\n let result = exec(builder, children);\r\n props.exec = exec;\r\n return result;\r\n }\r\n let [first] = children;\r\n if (Array.isArray(first) && Object.isFrozen(first)) {\r\n children = templateValues(children);\r\n }\r\n if (Array.isArray(props.children)) {\r\n props.children.push(...children)\r\n children = props.children;\r\n delete props.children;\r\n }\r\n for (let i = 0; i < children.length; i++) {\r\n let arg = children[i];\r\n if (typeof arg === \"function\" && arg.__element_info__) {\r\n children[i] = arg();\r\n }\r\n }\r\n return constructor(type, props, ...children);\r\n },\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n if (prop === \"props\") {\r\n return setPropsValues;\r\n }\r\n else if (typeof prop === \"string\") {\r\n if(prop.indexOf(\"·\") !== -1) {\r\n prop = prop.replace(interpunct, \"-\");\r\n }\r\n if (prop.endsWith(\"Value\") && prop.length > 5) {\r\n return target.__element_info__.props[prop.slice(0, -5)];\r\n }\r\n target.__element_info__.prop = prop;\r\n return setPropertyValue;\r\n }\r\n }\r\n })\r\n builder.__element_info__ = propsInfo;\r\n return builder;\r\n }\r\n return createBuilder({ props: {}, prop: null });\r\n}\r\n\r\n\r\nfunction builders(constructor, types = []) {\r\n if (typeof constructor !== \"function\") {\r\n throw Error(\"elementConstructor argument must be present and it must be a function.\");\r\n }\r\n if (types.length > 0) {\r\n let builders = [];\r\n for (const element of types) {\r\n builders.push(createInitialBuilder(constructor, element));\r\n }\r\n return builders;\r\n }\r\n else {\r\n return new Proxy(() => { }, {\r\n get(target, prop) {\r\n const result = target[prop];\r\n if (typeof result !== \"undefined\") {\r\n return result;\r\n }\r\n target[prop] = createInitialBuilder(constructor, prop);\r\n return target[prop];\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport default builders;\r\n"],"names":["templateValues","args","strings","templateArgs","result","entries","index","s","push","arg","interpunct","RegExp","createInitialBuilder","constructor","type","setPropertyValue","value","this","__element_info__","props","prop","createBuilder","Array","isArray","Object","isFrozen","join","length","setPropsValues","propsInfo","builder","Proxy","apply","target","thisArg","children","exec","first","i","get","indexOf","replace","endsWith","slice","types","Error","builders"],"mappings":"gsCAAA,SAASA,EAAeC,GAGtB,UAFOC,EAA4BD,KAAhBE,EAAgBF,WAC7BG,EAAS,OACUF,EAAQG,0BA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