@solidjs/html 2.0.0-beta.13 → 2.0.0-beta.15

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/html.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var web = require('@solidjs/web');
4
4
 
5
- const e=e=>t(e)||e>=48&&e<=58||e===46||e===45,t=e=>e>=65&&e<=90||e>=97&&e<=122||e===95||e===36,n=e=>e>=9&&e<=13||e===32,r=(r,i)=>{let a=[],o=0,s=``,c=0;for(let l=0;l<r.length;l++){let u=r[l],d=u.length;for(c=0;c<d;)switch(o){case 0:{s=``;let e=u.indexOf(`<`,c);e===-1?(c<d&&a.push({type:6,value:u.slice(c)}),c=d):(e>c&&a.push({type:6,value:u.slice(c,e)}),u[e+1]===`!`&&u[e+2]===`-`&&u[e+3]===`-`?(o=3,c=e+4):(a.push({type:0}),o=1,c=e+1));break}case 1:{let r=u.charCodeAt(c);if(n(r))c++;else if(r===62)i.has(s)&&a[a.length-2]?.type!==2?o=2:(o=0,s=``),a.push({type:1}),c++;else if(r===61)a.push({type:4}),c++;else if(r===47){let e=u.charCodeAt(c+1),t=u.slice(c+2).search(/\S/),n=e===47&&a[a.length-1]?.type===0&&t!==-1&&u[c+2+t]===`>`;e===47&&!n?o=4:e===42?o=5:(a.push({type:2}),c++);}else if(r===34||r===39){let e=u[c],t=u.indexOf(e,c+1);if(t===-1)throw Error(`Unterminated string`);a.push({type:5,value:u.slice(c+1,t),quote:e}),c=t+1;}else if(t(r)){let t=c;for(;c<d&&e(u.charCodeAt(c));)c++;let n=u.slice(t,c);s===``&&(s=n),a.push({type:3,value:n});}else if(r===46&&u[c+1]===`.`&&u[c+2]===`.`)a.push({type:8}),c+=3;else throw Error(`Unexpected Character: ${u[c]}`);break}case 2:{let e=RegExp(`<\\s*/\\s*${s}\\s*>`,`g`);e.lastIndex=c;let t=e.exec(u);if(t){let e=t.index;e>c&&a.push({type:6,value:u.slice(c,e)}),o=0,c=e,s=``;}else a.push({type:6,value:u.slice(c)}),c=d;break}case 3:case 4:case 5:{let e=o===4?`
6
- `:o===5?`*/`:`-->`,t=u.indexOf(e,c);t===-1?c=d:(o=o===3?0:1,c=t+e.length);break}}l<r.length-1&&(o===0||o===1||o===2)&&a.push({type:7,value:l});}return a},i=e=>{let t=e.charCodeAt(0);return t>=65&&t<=90},a=(e,t)=>{let n={type:0,children:[]},r=[n],a=0,o=e.length;for(;a<o;){let n=e[a],s=r[r.length-1];switch(n.type){case 6:{let t=n.value;if(t.trim()===``){let t=e[a-1]?.type,n=e[a+1]?.type;if(t===1||n===0){a++;continue}}s.children.push({type:3,value:t}),a++;continue}case 7:s.children.push({type:4,value:n.value}),a++;continue;case 0:{let n=e[++a];if(n.type===2){let n=e[++a],i=e[++a],o=r[r.length-1];if(r.length>1&&i.type===1&&(n?.type===3&&o.name===n.value||(n?.type===7||n.type===2)&&typeof o.name==`number`)){let e=r.pop();e?.type===1&&t.has(e.name)&&(e.children=[]),a++;continue}throw Error(`Mismatched closing tag.`)}if(n.type===3||n.type===7){let t=n.value,c={type:typeof t==`number`||i(t)?2:1,name:t,props:[],children:[]};for(s.children.push(c),a++;a<o;){let t=e[a];if(t.type===1||t.type===2)break;if(t.type===8){let t=e[a+1];if(t?.type===7)c.props.push({type:3,value:t.value}),a+=2;else throw Error(`Spread operator must be followed by an expression.`)}else if(t.type===3){let n=t.value;if(e[a+1]?.type===4){a+=2;let t=e[a];if(t.type===7)c.props.push({name:n,type:2,value:t.value}),a++;else if(t.type===5){let e=t.quote;c.props.push({name:n,value:t.value,quote:e,type:1}),a++;}else throw Error(`Attribute value must be an expression or a string.`)}else c.props.push({type:0,name:n,value:true}),a++;}else throw Error(`Invalid attribute.`)}let l=e[a];l.type===2?a+=2:l.type===1&&(a++,r.push(c));continue}}default:throw Error(`Unexpected token: ${JSON.stringify(n)}`)}}if(r.length>1)throw Error(`Unclosed tag found.`);return n},o=e=>e.length===1?e[0]:e;function s(e){let t=new WeakMap,n=new Set(e.RawTextElements);n.delete(`template`);let i=document.createTreeWalker(document,129),s=t=>e.SVGElements.has(t)?document.createElementNS(`http://www.w3.org/2000/svg`,t):e.MathMLElements.has(t)?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,t):document.createElement(t),c=e=>{let t=(t,...n)=>m(l(t),n,e);return t.components=e,t.sld=t,t.define=t=>c({...e,...t}),t},l=i=>{let o=t.get(i);return o||(o=a(r(i,n),e.VoidElements),u(o),t.set(i,o)),o},u=e=>{if(e.type===0||e.type===2){if(e.children.some(e=>e.type===1)){let t=document.createElement(`template`);t.content.append(...e.children.map(f)),e.template=t;}e.children.forEach(u);}else e.type===1&&e.children.forEach(u);},d=document.createElement(`template`),f=e=>{switch(e.type){case 3:return d.innerHTML=e.value,document.createTextNode(d.content.textContent??``);case 4:return document.createComment(`+`);case 2:return document.createComment(e.name);case 1:let t=false,n=s(e.name);return e.props=e.props.filter(e=>e.type===1?e.name.startsWith(`prop:`)?true:(n.setAttribute(e.name,e.value),t):e.type===0?(n.setAttribute(e.name,``),t):e.type===3?(t=true,t):true),(e.name===`template`?n.content:n).append(...e.children.map(f)),n}},p=(t,n,r)=>{switch(t.type){case 3:return t.value;case 4:return n[t.value];case 2:let i=typeof t.name==`string`?r[t.name]:n[t.name];if(i&&typeof i==`function`)return e.createComponent(i,h(t,n,r));throw Error(`Component "${t.name}" not found in registry`);case 1:let a=t.name,o=s(a),c=h(t,n,r);return e.spread(o,c,true),o}},m=(t,n,r)=>{if(!t.template)return o(t.children.map(e=>p(e,n,r)));let a=t.template.content.cloneNode(true);i.currentNode=a;let s=(t,i)=>{for(let a of t)if(a.type===1||a.type===4||a.type===2){let t=i.nextNode();if(a.type===4||a.type===2)e.insert(t.parentNode,p(a,n,r),t),i.currentNode=t;else {if(a.props.length){let i=h(a,n,r);e.spread(t,i,true);}s(a.children,a.name===`template`?document.createTreeWalker(t.content,129):i);}}};return s(t.children,i),a.childNodes.length===1?a.firstChild:Array.from(a.childNodes)},h=(t,n,r,i={})=>{for(let r of t.props)switch(r.type){case 0:i[r.name]=true;break;case 1:i[r.name]=r.value;break;case 2:g(i,r.name,n[r.value]);break;case 3:let t=n[r.value];if(!t||typeof t!=`object`)throw Error(`Can only spread objects`);i=e.mergeProps(i,t);break}return t.type===2&&t.children.length&&Object.defineProperty(i,`children`,{get(){return m(t,n,r)}}),i},g=(e,t,n)=>{typeof n==`function`&&n.length===0&&t!==`ref`&&!t.startsWith(`on`)?Object.defineProperty(e,t,{get(){return n()},enumerable:true}):e[t]=n;};return c({})}
5
+ const e=e=>t(e)||e>=48&&e<=58||e===46||e===45,t=e=>e>=65&&e<=90||e>=97&&e<=122||e===95||e===36,n=e=>e>=9&&e<=13||e===32,r=(r,i)=>{let a=[],o=0,s=``,c=0;for(let l=0;l<r.length;l++){let u=r[l],d=u.length;for(c=0;c<d;)switch(o){case 0:{s=``;let e=u.indexOf(`<`,c);e===-1?(c<d&&a.push({type:6,value:u.slice(c)}),c=d):(e>c&&a.push({type:6,value:u.slice(c,e)}),u[e+1]===`!`&&u[e+2]===`-`&&u[e+3]===`-`?(o=3,c=e+4):(a.push({type:0}),o=1,c=e+1));break}case 1:{let r=u.charCodeAt(c);if(n(r))c++;else if(r===62)i.has(s)&&a[a.length-2]?.type!==2?o=2:(o=0,s=``),a.push({type:1}),c++;else if(r===61)a.push({type:4}),c++;else if(r===47){let e=u.charCodeAt(c+1),t=u.slice(c+2).search(/\S/),n=e===47&&a[a.length-1]?.type===0&&t!==-1&&u[c+2+t]===`>`;e===47&&!n?o=4:e===42?o=5:(a.push({type:2}),c++);}else if(r===34||r===39){let e=u[c],t=u.indexOf(e,c+1);if(t===-1)throw Error(`Unterminated string at ${l}:${c}`);a.push({type:5,value:u.slice(c+1,t),quote:e}),c=t+1;}else if(t(r)){let t=c;for(;c<d&&e(u.charCodeAt(c));)c++;let n=u.slice(t,c);s===``&&(s=n),a.push({type:3,value:n});}else if(r===46&&u[c+1]===`.`&&u[c+2]===`.`)a.push({type:8}),c+=3;else throw Error(`Unexpected Character: ${u[c]} at ${l}:${c}`);break}case 2:{let e=RegExp(`<\\s*/\\s*${s}\\s*>`,`g`);e.lastIndex=c;let t=e.exec(u);if(t){let e=t.index;e>c&&a.push({type:6,value:u.slice(c,e)}),o=0,c=e,s=``;}else a.push({type:6,value:u.slice(c)}),c=d;break}case 3:case 4:case 5:{let e=o===4?`
6
+ `:o===5?`*/`:`-->`,t=u.indexOf(e,c);t===-1?c=d:(o=o===3?0:1,c=t+e.length);break}}l<r.length-1&&(o===0||o===1||o===2)&&a.push({type:7,value:l});}return a},i=e=>{let t=e.charCodeAt(0);return t>=65&&t<=90},a=(e,t)=>{let n={type:0,children:[]},r=[n],a=0,o=e.length;for(;a<o;){let n=e[a],s=r[r.length-1];switch(n.type){case 6:{let t=n.value;if(t.trim()===``){let t=e[a-1]?.type,n=e[a+1]?.type;if(t===1||n===0){a++;continue}}s.children.push({type:3,value:t}),a++;continue}case 7:s.children.push({type:4,value:n.value}),a++;continue;case 0:{let n=e[++a];if(n.type===2){let n=e[++a],i=e[++a],o=r[r.length-1];if(r.length>1&&i.type===1&&(n?.type===3&&o.name===n.value||(n?.type===7||n.type===2)&&typeof o.name==`number`)){let e=r.pop();e?.type===1&&t.has(e.name)&&(e.children=[]),a++;continue}throw Error(`Mismatched closing tag for <${o.name}>`)}if(n.type===3||n.type===7){let t=n.value,c={type:typeof t==`number`||i(t)?2:1,name:t,props:[],children:[]};for(s.children.push(c),a++;a<o;){let t=e[a];if(t.type===1||t.type===2)break;if(t.type===8){let t=e[a+1];if(t?.type===7)c.props.push({type:3,value:t.value}),a+=2;else throw Error(`Spread operator in <${c.name}> must be followed by an expression`)}else if(t.type===3){let n=t.value;if(e[a+1]?.type===4){a+=2;let t=e[a];if(t.type===7)c.props.push({name:n,type:2,value:t.value}),a++;else if(t.type===5){let e=t.quote;c.props.push({name:n,value:t.value,quote:e,type:1}),a++;}else throw Error(`Attribute value for "${n}" in <${c.name}> must be an expression or a string`)}else c.props.push({type:0,name:n,value:true}),a++;}else throw Error(`Invalid attribute in <${c.name}>`)}let l=e[a];l.type===2?a+=2:l.type===1&&(a++,r.push(c));continue}}default:throw Error(`Unexpected token: ${JSON.stringify(n)} after <${r[r.length-1].name}>`)}}if(r.length>1)throw Error(`Unclosed tag for <${r[r.length-1].name}>`);return n},o=e=>e.length===1?e[0]:e;function s(e){let t=new WeakMap,n=new Set(e.RawTextElements);n.delete(`template`);let i=document.createTreeWalker(document,129),s=t=>e.SVGElements.has(t)?document.createElementNS(`http://www.w3.org/2000/svg`,t):e.MathMLElements.has(t)?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,t):document.createElement(t),c=e=>{let t=(t,...n)=>m(l(t),n,e);return t.components=e,t.sld=t,t.define=t=>c({...e,...t}),t},l=i=>{let o=t.get(i);return o||(o=a(r(i,n),e.VoidElements),u(o,false),t.set(i,o)),o},u=(e,t)=>{if(e.type===1){if(!t){let n=document.createElement(`template`);n.content.appendChild(f(e)),e.template=n,t=true;}e.children.forEach(e=>u(e,t));}else e.type===2||e.type===0?e.children.forEach(e=>u(e,false)):e.type===3&&!t&&(d.innerHTML=e.value,e.value=d.content.textContent??``);},d=document.createElement(`template`),f=e=>{switch(e.type){case 3:return d.innerHTML=e.value,document.createTextNode(d.content.textContent??``);case 4:return document.createComment(`+`);case 2:return document.createComment(e.name);case 1:let t=false,n=s(e.name);return e.props=e.props.filter(e=>e.type===1?e.name.startsWith(`prop:`)?true:(n.setAttribute(e.name,e.value),t):e.type===0?(n.setAttribute(e.name,``),t):e.type===3?(t=true,t):true),(e.name===`template`?n.content:n).append(...e.children.map(f)),n}},p=(t,n,r)=>{switch(t.type){case 3:return t.value;case 4:return n[t.value];case 2:let i=typeof t.name==`string`?r[t.name]:n[t.name];if(i&&typeof i==`function`)return e.createComponent(i,h(t,n,r));throw Error(`Component "${t.name}" not found in registry`);case 1:t.name;let a=m(t,n,r),o=h(t,n,r);return e.spread(a,o,true),a}},m=(t,n,r)=>{if(t.type!==1||!t.template)return o(t.children.map(e=>p(e,n,r)));let a=t.template.content.firstChild.cloneNode(true);i.currentNode=a;let s=(t,i)=>{for(let a of t)if(a.type===1||a.type===4||a.type===2){let t=i.nextNode();if(a.type===4||a.type===2)e.insert(t.parentNode,p(a,n,r),t),i.currentNode=t;else {if(a.props.length){let i=h(a,n,r);e.spread(t,i,true);}s(a.children,a.name===`template`?document.createTreeWalker(t.content,129):i);}}};return s(t.children,t.name===`template`?document.createTreeWalker(a.content,129):i),a},h=(t,n,r,i={})=>{for(let r of t.props)switch(r.type){case 0:i[r.name]=true;break;case 1:i[r.name]=r.value;break;case 2:g(i,r.name,n[r.value]);break;case 3:let t=n[r.value];if(!t||typeof t!=`object`)throw Error(`Can only spread objects`);i=e.mergeProps(i,t);break}return t.type===2&&t.children.length&&Object.defineProperty(i,`children`,{get(){return m(t,n,r)}}),i},g=(e,t,n)=>{typeof n==`function`&&n.length===0&&t!==`ref`&&!t.startsWith(`on`)?Object.defineProperty(e,t,{get(){return n()},enumerable:true}):e[t]=n;};return c({})}
7
7
 
8
8
  const html = s({
9
9
  insert: web.insert,
package/dist/html.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RawTextElements, VoidElements, MathMLElements, SVGElements, mergeProps, createComponent, spread, insert } from '@solidjs/web';
2
2
 
3
- const e=e=>t(e)||e>=48&&e<=58||e===46||e===45,t=e=>e>=65&&e<=90||e>=97&&e<=122||e===95||e===36,n=e=>e>=9&&e<=13||e===32,r=(r,i)=>{let a=[],o=0,s=``,c=0;for(let l=0;l<r.length;l++){let u=r[l],d=u.length;for(c=0;c<d;)switch(o){case 0:{s=``;let e=u.indexOf(`<`,c);e===-1?(c<d&&a.push({type:6,value:u.slice(c)}),c=d):(e>c&&a.push({type:6,value:u.slice(c,e)}),u[e+1]===`!`&&u[e+2]===`-`&&u[e+3]===`-`?(o=3,c=e+4):(a.push({type:0}),o=1,c=e+1));break}case 1:{let r=u.charCodeAt(c);if(n(r))c++;else if(r===62)i.has(s)&&a[a.length-2]?.type!==2?o=2:(o=0,s=``),a.push({type:1}),c++;else if(r===61)a.push({type:4}),c++;else if(r===47){let e=u.charCodeAt(c+1),t=u.slice(c+2).search(/\S/),n=e===47&&a[a.length-1]?.type===0&&t!==-1&&u[c+2+t]===`>`;e===47&&!n?o=4:e===42?o=5:(a.push({type:2}),c++);}else if(r===34||r===39){let e=u[c],t=u.indexOf(e,c+1);if(t===-1)throw Error(`Unterminated string`);a.push({type:5,value:u.slice(c+1,t),quote:e}),c=t+1;}else if(t(r)){let t=c;for(;c<d&&e(u.charCodeAt(c));)c++;let n=u.slice(t,c);s===``&&(s=n),a.push({type:3,value:n});}else if(r===46&&u[c+1]===`.`&&u[c+2]===`.`)a.push({type:8}),c+=3;else throw Error(`Unexpected Character: ${u[c]}`);break}case 2:{let e=RegExp(`<\\s*/\\s*${s}\\s*>`,`g`);e.lastIndex=c;let t=e.exec(u);if(t){let e=t.index;e>c&&a.push({type:6,value:u.slice(c,e)}),o=0,c=e,s=``;}else a.push({type:6,value:u.slice(c)}),c=d;break}case 3:case 4:case 5:{let e=o===4?`
4
- `:o===5?`*/`:`-->`,t=u.indexOf(e,c);t===-1?c=d:(o=o===3?0:1,c=t+e.length);break}}l<r.length-1&&(o===0||o===1||o===2)&&a.push({type:7,value:l});}return a},i=e=>{let t=e.charCodeAt(0);return t>=65&&t<=90},a=(e,t)=>{let n={type:0,children:[]},r=[n],a=0,o=e.length;for(;a<o;){let n=e[a],s=r[r.length-1];switch(n.type){case 6:{let t=n.value;if(t.trim()===``){let t=e[a-1]?.type,n=e[a+1]?.type;if(t===1||n===0){a++;continue}}s.children.push({type:3,value:t}),a++;continue}case 7:s.children.push({type:4,value:n.value}),a++;continue;case 0:{let n=e[++a];if(n.type===2){let n=e[++a],i=e[++a],o=r[r.length-1];if(r.length>1&&i.type===1&&(n?.type===3&&o.name===n.value||(n?.type===7||n.type===2)&&typeof o.name==`number`)){let e=r.pop();e?.type===1&&t.has(e.name)&&(e.children=[]),a++;continue}throw Error(`Mismatched closing tag.`)}if(n.type===3||n.type===7){let t=n.value,c={type:typeof t==`number`||i(t)?2:1,name:t,props:[],children:[]};for(s.children.push(c),a++;a<o;){let t=e[a];if(t.type===1||t.type===2)break;if(t.type===8){let t=e[a+1];if(t?.type===7)c.props.push({type:3,value:t.value}),a+=2;else throw Error(`Spread operator must be followed by an expression.`)}else if(t.type===3){let n=t.value;if(e[a+1]?.type===4){a+=2;let t=e[a];if(t.type===7)c.props.push({name:n,type:2,value:t.value}),a++;else if(t.type===5){let e=t.quote;c.props.push({name:n,value:t.value,quote:e,type:1}),a++;}else throw Error(`Attribute value must be an expression or a string.`)}else c.props.push({type:0,name:n,value:true}),a++;}else throw Error(`Invalid attribute.`)}let l=e[a];l.type===2?a+=2:l.type===1&&(a++,r.push(c));continue}}default:throw Error(`Unexpected token: ${JSON.stringify(n)}`)}}if(r.length>1)throw Error(`Unclosed tag found.`);return n},o=e=>e.length===1?e[0]:e;function s(e){let t=new WeakMap,n=new Set(e.RawTextElements);n.delete(`template`);let i=document.createTreeWalker(document,129),s=t=>e.SVGElements.has(t)?document.createElementNS(`http://www.w3.org/2000/svg`,t):e.MathMLElements.has(t)?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,t):document.createElement(t),c=e=>{let t=(t,...n)=>m(l(t),n,e);return t.components=e,t.sld=t,t.define=t=>c({...e,...t}),t},l=i=>{let o=t.get(i);return o||(o=a(r(i,n),e.VoidElements),u(o),t.set(i,o)),o},u=e=>{if(e.type===0||e.type===2){if(e.children.some(e=>e.type===1)){let t=document.createElement(`template`);t.content.append(...e.children.map(f)),e.template=t;}e.children.forEach(u);}else e.type===1&&e.children.forEach(u);},d=document.createElement(`template`),f=e=>{switch(e.type){case 3:return d.innerHTML=e.value,document.createTextNode(d.content.textContent??``);case 4:return document.createComment(`+`);case 2:return document.createComment(e.name);case 1:let t=false,n=s(e.name);return e.props=e.props.filter(e=>e.type===1?e.name.startsWith(`prop:`)?true:(n.setAttribute(e.name,e.value),t):e.type===0?(n.setAttribute(e.name,``),t):e.type===3?(t=true,t):true),(e.name===`template`?n.content:n).append(...e.children.map(f)),n}},p=(t,n,r)=>{switch(t.type){case 3:return t.value;case 4:return n[t.value];case 2:let i=typeof t.name==`string`?r[t.name]:n[t.name];if(i&&typeof i==`function`)return e.createComponent(i,h(t,n,r));throw Error(`Component "${t.name}" not found in registry`);case 1:let a=t.name,o=s(a),c=h(t,n,r);return e.spread(o,c,true),o}},m=(t,n,r)=>{if(!t.template)return o(t.children.map(e=>p(e,n,r)));let a=t.template.content.cloneNode(true);i.currentNode=a;let s=(t,i)=>{for(let a of t)if(a.type===1||a.type===4||a.type===2){let t=i.nextNode();if(a.type===4||a.type===2)e.insert(t.parentNode,p(a,n,r),t),i.currentNode=t;else {if(a.props.length){let i=h(a,n,r);e.spread(t,i,true);}s(a.children,a.name===`template`?document.createTreeWalker(t.content,129):i);}}};return s(t.children,i),a.childNodes.length===1?a.firstChild:Array.from(a.childNodes)},h=(t,n,r,i={})=>{for(let r of t.props)switch(r.type){case 0:i[r.name]=true;break;case 1:i[r.name]=r.value;break;case 2:g(i,r.name,n[r.value]);break;case 3:let t=n[r.value];if(!t||typeof t!=`object`)throw Error(`Can only spread objects`);i=e.mergeProps(i,t);break}return t.type===2&&t.children.length&&Object.defineProperty(i,`children`,{get(){return m(t,n,r)}}),i},g=(e,t,n)=>{typeof n==`function`&&n.length===0&&t!==`ref`&&!t.startsWith(`on`)?Object.defineProperty(e,t,{get(){return n()},enumerable:true}):e[t]=n;};return c({})}
3
+ const e=e=>t(e)||e>=48&&e<=58||e===46||e===45,t=e=>e>=65&&e<=90||e>=97&&e<=122||e===95||e===36,n=e=>e>=9&&e<=13||e===32,r=(r,i)=>{let a=[],o=0,s=``,c=0;for(let l=0;l<r.length;l++){let u=r[l],d=u.length;for(c=0;c<d;)switch(o){case 0:{s=``;let e=u.indexOf(`<`,c);e===-1?(c<d&&a.push({type:6,value:u.slice(c)}),c=d):(e>c&&a.push({type:6,value:u.slice(c,e)}),u[e+1]===`!`&&u[e+2]===`-`&&u[e+3]===`-`?(o=3,c=e+4):(a.push({type:0}),o=1,c=e+1));break}case 1:{let r=u.charCodeAt(c);if(n(r))c++;else if(r===62)i.has(s)&&a[a.length-2]?.type!==2?o=2:(o=0,s=``),a.push({type:1}),c++;else if(r===61)a.push({type:4}),c++;else if(r===47){let e=u.charCodeAt(c+1),t=u.slice(c+2).search(/\S/),n=e===47&&a[a.length-1]?.type===0&&t!==-1&&u[c+2+t]===`>`;e===47&&!n?o=4:e===42?o=5:(a.push({type:2}),c++);}else if(r===34||r===39){let e=u[c],t=u.indexOf(e,c+1);if(t===-1)throw Error(`Unterminated string at ${l}:${c}`);a.push({type:5,value:u.slice(c+1,t),quote:e}),c=t+1;}else if(t(r)){let t=c;for(;c<d&&e(u.charCodeAt(c));)c++;let n=u.slice(t,c);s===``&&(s=n),a.push({type:3,value:n});}else if(r===46&&u[c+1]===`.`&&u[c+2]===`.`)a.push({type:8}),c+=3;else throw Error(`Unexpected Character: ${u[c]} at ${l}:${c}`);break}case 2:{let e=RegExp(`<\\s*/\\s*${s}\\s*>`,`g`);e.lastIndex=c;let t=e.exec(u);if(t){let e=t.index;e>c&&a.push({type:6,value:u.slice(c,e)}),o=0,c=e,s=``;}else a.push({type:6,value:u.slice(c)}),c=d;break}case 3:case 4:case 5:{let e=o===4?`
4
+ `:o===5?`*/`:`-->`,t=u.indexOf(e,c);t===-1?c=d:(o=o===3?0:1,c=t+e.length);break}}l<r.length-1&&(o===0||o===1||o===2)&&a.push({type:7,value:l});}return a},i=e=>{let t=e.charCodeAt(0);return t>=65&&t<=90},a=(e,t)=>{let n={type:0,children:[]},r=[n],a=0,o=e.length;for(;a<o;){let n=e[a],s=r[r.length-1];switch(n.type){case 6:{let t=n.value;if(t.trim()===``){let t=e[a-1]?.type,n=e[a+1]?.type;if(t===1||n===0){a++;continue}}s.children.push({type:3,value:t}),a++;continue}case 7:s.children.push({type:4,value:n.value}),a++;continue;case 0:{let n=e[++a];if(n.type===2){let n=e[++a],i=e[++a],o=r[r.length-1];if(r.length>1&&i.type===1&&(n?.type===3&&o.name===n.value||(n?.type===7||n.type===2)&&typeof o.name==`number`)){let e=r.pop();e?.type===1&&t.has(e.name)&&(e.children=[]),a++;continue}throw Error(`Mismatched closing tag for <${o.name}>`)}if(n.type===3||n.type===7){let t=n.value,c={type:typeof t==`number`||i(t)?2:1,name:t,props:[],children:[]};for(s.children.push(c),a++;a<o;){let t=e[a];if(t.type===1||t.type===2)break;if(t.type===8){let t=e[a+1];if(t?.type===7)c.props.push({type:3,value:t.value}),a+=2;else throw Error(`Spread operator in <${c.name}> must be followed by an expression`)}else if(t.type===3){let n=t.value;if(e[a+1]?.type===4){a+=2;let t=e[a];if(t.type===7)c.props.push({name:n,type:2,value:t.value}),a++;else if(t.type===5){let e=t.quote;c.props.push({name:n,value:t.value,quote:e,type:1}),a++;}else throw Error(`Attribute value for "${n}" in <${c.name}> must be an expression or a string`)}else c.props.push({type:0,name:n,value:true}),a++;}else throw Error(`Invalid attribute in <${c.name}>`)}let l=e[a];l.type===2?a+=2:l.type===1&&(a++,r.push(c));continue}}default:throw Error(`Unexpected token: ${JSON.stringify(n)} after <${r[r.length-1].name}>`)}}if(r.length>1)throw Error(`Unclosed tag for <${r[r.length-1].name}>`);return n},o=e=>e.length===1?e[0]:e;function s(e){let t=new WeakMap,n=new Set(e.RawTextElements);n.delete(`template`);let i=document.createTreeWalker(document,129),s=t=>e.SVGElements.has(t)?document.createElementNS(`http://www.w3.org/2000/svg`,t):e.MathMLElements.has(t)?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,t):document.createElement(t),c=e=>{let t=(t,...n)=>m(l(t),n,e);return t.components=e,t.sld=t,t.define=t=>c({...e,...t}),t},l=i=>{let o=t.get(i);return o||(o=a(r(i,n),e.VoidElements),u(o,false),t.set(i,o)),o},u=(e,t)=>{if(e.type===1){if(!t){let n=document.createElement(`template`);n.content.appendChild(f(e)),e.template=n,t=true;}e.children.forEach(e=>u(e,t));}else e.type===2||e.type===0?e.children.forEach(e=>u(e,false)):e.type===3&&!t&&(d.innerHTML=e.value,e.value=d.content.textContent??``);},d=document.createElement(`template`),f=e=>{switch(e.type){case 3:return d.innerHTML=e.value,document.createTextNode(d.content.textContent??``);case 4:return document.createComment(`+`);case 2:return document.createComment(e.name);case 1:let t=false,n=s(e.name);return e.props=e.props.filter(e=>e.type===1?e.name.startsWith(`prop:`)?true:(n.setAttribute(e.name,e.value),t):e.type===0?(n.setAttribute(e.name,``),t):e.type===3?(t=true,t):true),(e.name===`template`?n.content:n).append(...e.children.map(f)),n}},p=(t,n,r)=>{switch(t.type){case 3:return t.value;case 4:return n[t.value];case 2:let i=typeof t.name==`string`?r[t.name]:n[t.name];if(i&&typeof i==`function`)return e.createComponent(i,h(t,n,r));throw Error(`Component "${t.name}" not found in registry`);case 1:t.name;let a=m(t,n,r),o=h(t,n,r);return e.spread(a,o,true),a}},m=(t,n,r)=>{if(t.type!==1||!t.template)return o(t.children.map(e=>p(e,n,r)));let a=t.template.content.firstChild.cloneNode(true);i.currentNode=a;let s=(t,i)=>{for(let a of t)if(a.type===1||a.type===4||a.type===2){let t=i.nextNode();if(a.type===4||a.type===2)e.insert(t.parentNode,p(a,n,r),t),i.currentNode=t;else {if(a.props.length){let i=h(a,n,r);e.spread(t,i,true);}s(a.children,a.name===`template`?document.createTreeWalker(t.content,129):i);}}};return s(t.children,t.name===`template`?document.createTreeWalker(a.content,129):i),a},h=(t,n,r,i={})=>{for(let r of t.props)switch(r.type){case 0:i[r.name]=true;break;case 1:i[r.name]=r.value;break;case 2:g(i,r.name,n[r.value]);break;case 3:let t=n[r.value];if(!t||typeof t!=`object`)throw Error(`Can only spread objects`);i=e.mergeProps(i,t);break}return t.type===2&&t.children.length&&Object.defineProperty(i,`children`,{get(){return m(t,n,r)}}),i},g=(e,t,n)=>{typeof n==`function`&&n.length===0&&t!==`ref`&&!t.startsWith(`on`)?Object.defineProperty(e,t,{get(){return n()},enumerable:true}):e[t]=n;};return c({})}
5
5
 
6
6
  const html = s({
7
7
  insert,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/html",
3
3
  "description": "Tagged-template-literal templating for Solid — write components with no build step.",
4
- "version": "2.0.0-beta.13",
4
+ "version": "2.0.0-beta.15",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -37,11 +37,11 @@
37
37
  }
38
38
  },
39
39
  "peerDependencies": {
40
- "@solidjs/web": "^2.0.0-beta.13"
40
+ "@solidjs/web": "^2.0.0-beta.15"
41
41
  },
42
42
  "devDependencies": {
43
- "@solidjs/web": "2.0.0-beta.13",
44
- "solid-js": "2.0.0-beta.13"
43
+ "@solidjs/web": "2.0.0-beta.15",
44
+ "solid-js": "2.0.0-beta.15"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "npm-run-all -nl build:*",
package/types/sld.d.ts CHANGED
@@ -9293,7 +9293,7 @@ type SkipPropsFrom = HTMLUnknownElement & HTMLElement & Element & Node;
9293
9293
  * - `HTMLButtonElement.popoverTargetElement` / `commandForElement` (and the same via
9294
9294
  * `PopoverTargetAttributes` mixin on `HTMLInputElement`)
9295
9295
  */
9296
- type PropValue = string | number | boolean | null | MediaStream | MediaSource | Blob | File | Element;
9296
+ type PropValue = string | number | boolean | null | MediaStream | MediaSource | Blob | File | Date | Element;
9297
9297
  /**
9298
9298
  * Ergonomics widening for emitted `prop:*` value types:
9299
9299
  *
@@ -9499,7 +9499,7 @@ declare namespace JSX {
9499
9499
  }): void;
9500
9500
  }
9501
9501
  type FocusEventHandlerUnion<T, E extends FocusEvent> = EventHandlerUnion<T, E, FocusEventHandler<T, E>>; // end event handlers
9502
- type ClassList = Record<string, boolean> | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
9502
+ export type ClassValue = string | number | boolean | null | undefined | Record<string, boolean> | ClassValue[];
9503
9503
  const SERIALIZABLE: unique symbol;
9504
9504
  interface SerializableAttributeValue {
9505
9505
  toString(): string;
@@ -9529,10 +9529,6 @@ declare namespace JSX {
9529
9529
  [key: `-${string}`]: string | number | undefined;
9530
9530
  } // TODO: Should we allow this?
9531
9531
  // type ClassKeys = `class:${string}`;
9532
- // type CSSKeys = Exclude<keyof csstype.PropertiesHyphen, `-${string}`>;
9533
- // type CSSAttributes = {
9534
- // [key in CSSKeys as `style:${key}`]: csstype.PropertiesHyphen[key];
9535
- // };
9536
9532
  // BOOLEAN
9537
9533
  /**
9538
9534
  * Boolean and Pseudo-Boolean Attributes Helpers.
@@ -9987,7 +9983,9 @@ declare namespace JSX {
9987
9983
  onWaiting?: EventHandlerUnion<T, Event> | undefined;
9988
9984
  onWheel?: EventHandlerUnion<T, WheelEvent> | undefined;
9989
9985
  } // EventName = "click" | "mousedown" ...
9990
- type EventName = (keyof EventHandlersWindow<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (keyof EventHandlersElement<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (string & {}); // GLOBAL ATTRIBUTES
9986
+ type EventName = (keyof EventHandlersWindow<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (keyof EventHandlersElement<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (string & {});
9987
+ type ExtractEventType<T> = { [K in keyof T as K extends `on${infer Name}` ? Name : never]: T[K] extends EventHandlerUnion<Element, infer E> ? E : never }; // EventType["click"] = MouseEvent
9988
+ type EventType = ExtractEventType<EventHandlersElement<Element>> & ExtractEventType<EventHandlersWindow<Element>>; // GLOBAL ATTRIBUTES
9991
9989
  /**
9992
9990
  * Global `Element` + `Node` interface keys, shared by all tags regardless of their namespace:
9993
9991
  *
@@ -10013,7 +10011,7 @@ declare namespace JSX {
10013
10011
  * with reactive values directly; manually-built strings re-run the whole
10014
10012
  * concatenation on every change instead of toggling the affected classes.
10015
10013
  */
10016
- class?: string | ClassList | RemoveAttribute;
10014
+ class?: ClassValue | RemoveAttribute;
10017
10015
  elementtiming?: string | RemoveAttribute;
10018
10016
  id?: string | RemoveAttribute;
10019
10017
  nonce?: string | RemoveAttribute;
@@ -10455,7 +10453,10 @@ declare namespace JSX {
10455
10453
  loop?: BooleanAttribute | RemoveAttribute;
10456
10454
  preload?: "none" | "metadata" | "auto" | EnumeratedAcceptsEmpty | RemoveAttribute;
10457
10455
  src?: string | RemoveAttribute;
10458
- onEncrypted?: EventHandlerUnion<T, MediaEncryptedEvent> | undefined; // special cases locked to properties
10456
+ onEncrypted?: EventHandlerUnion<T, MediaEncryptedEvent> | undefined;
10457
+ onWaitingForKey?: EventHandlerUnion<T, Event> | undefined;
10458
+ /** @deprecated */
10459
+ mediagroup?: string | RemoveAttribute; // special cases locked to properties
10459
10460
  muted?: BooleanProperty | RemoveProperty;
10460
10461
  /** @error use `<video/audio muted={..}/>` instead */
10461
10462
  "prop:muted"?: never;
@@ -10738,6 +10739,10 @@ declare namespace JSX {
10738
10739
  poster?: string | RemoveAttribute;
10739
10740
  width?: number | string | RemoveAttribute;
10740
10741
  onEnterPictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
10742
+ onLeavePictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
10743
+ }
10744
+ interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
10745
+ allowpopups?: BooleanAttribute | RemoveAttribute;
10741
10746
  disableblinkfeatures?: string | RemoveAttribute;
10742
10747
  disablewebsecurity?: BooleanAttribute | RemoveAttribute;
10743
10748
  enableblinkfeatures?: string | RemoveAttribute;
@@ -10776,7 +10781,7 @@ declare namespace JSX {
10776
10781
  * with reactive values directly; manually-built strings re-run the whole
10777
10782
  * concatenation on every change instead of toggling the affected classes.
10778
10783
  */
10779
- class?: string | ClassList | RemoveAttribute;
10784
+ class?: ClassValue | RemoveAttribute;
10780
10785
  style?: CSSProperties | string | RemoveAttribute;
10781
10786
  }
10782
10787
  interface TransformableSVGAttributes {
@@ -10883,6 +10888,12 @@ declare namespace JSX {
10883
10888
  }
10884
10889
  interface AnimationElementSVGAttributes<T> extends SVGAttributes<T>, ExternalResourceSVGAttributes, ConditionalProcessingSVGAttributes {
10885
10890
  onBegin?: EventHandlerUnion<T, TimeEvent> | undefined;
10891
+ onEnd?: EventHandlerUnion<T, TimeEvent> | undefined;
10892
+ onRepeat?: EventHandlerUnion<T, TimeEvent> | undefined;
10893
+ }
10894
+ interface ContainerElementSVGAttributes<T> extends SVGAttributes<T>, ShapeElementSVGAttributes<T>, Pick<PresentationSVGAttributes, "clip-path" | "mask" | "cursor" | "opacity" | "filter" | "enable-background" | "color-interpolation" | "color-rendering"> {}
10895
+ interface FilterPrimitiveElementSVGAttributes<T> extends SVGAttributes<T>, Pick<PresentationSVGAttributes, "color-interpolation-filters"> {
10896
+ height?: number | string | RemoveAttribute;
10886
10897
  result?: string | RemoveAttribute;
10887
10898
  width?: number | string | RemoveAttribute;
10888
10899
  x?: number | string | RemoveAttribute;
@@ -9293,7 +9293,7 @@ type SkipPropsFrom = HTMLUnknownElement & HTMLElement & Element & Node;
9293
9293
  * - `HTMLButtonElement.popoverTargetElement` / `commandForElement` (and the same via
9294
9294
  * `PopoverTargetAttributes` mixin on `HTMLInputElement`)
9295
9295
  */
9296
- type PropValue = string | number | boolean | null | MediaStream | MediaSource | Blob | File | Element;
9296
+ type PropValue = string | number | boolean | null | MediaStream | MediaSource | Blob | File | Date | Element;
9297
9297
  /**
9298
9298
  * Ergonomics widening for emitted `prop:*` value types:
9299
9299
  *
@@ -9499,7 +9499,7 @@ declare namespace JSX {
9499
9499
  }): void;
9500
9500
  }
9501
9501
  type FocusEventHandlerUnion<T, E extends FocusEvent> = EventHandlerUnion<T, E, FocusEventHandler<T, E>>; // end event handlers
9502
- type ClassList = Record<string, boolean> | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
9502
+ export type ClassValue = string | number | boolean | null | undefined | Record<string, boolean> | ClassValue[];
9503
9503
  const SERIALIZABLE: unique symbol;
9504
9504
  interface SerializableAttributeValue {
9505
9505
  toString(): string;
@@ -9529,10 +9529,6 @@ declare namespace JSX {
9529
9529
  [key: `-${string}`]: string | number | undefined;
9530
9530
  } // TODO: Should we allow this?
9531
9531
  // type ClassKeys = `class:${string}`;
9532
- // type CSSKeys = Exclude<keyof csstype.PropertiesHyphen, `-${string}`>;
9533
- // type CSSAttributes = {
9534
- // [key in CSSKeys as `style:${key}`]: csstype.PropertiesHyphen[key];
9535
- // };
9536
9532
  // BOOLEAN
9537
9533
  /**
9538
9534
  * Boolean and Pseudo-Boolean Attributes Helpers.
@@ -9987,7 +9983,9 @@ declare namespace JSX {
9987
9983
  onWaiting?: EventHandlerUnion<T, Event> | undefined;
9988
9984
  onWheel?: EventHandlerUnion<T, WheelEvent> | undefined;
9989
9985
  } // EventName = "click" | "mousedown" ...
9990
- type EventName = (keyof EventHandlersWindow<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (keyof EventHandlersElement<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (string & {}); // GLOBAL ATTRIBUTES
9986
+ type EventName = (keyof EventHandlersWindow<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (keyof EventHandlersElement<any> extends infer K ? K extends `on${infer T}` ? Lowercase<T> : never : never) | (string & {});
9987
+ type ExtractEventType<T> = { [K in keyof T as K extends `on${infer Name}` ? Name : never]: T[K] extends EventHandlerUnion<Element, infer E> ? E : never }; // EventType["click"] = MouseEvent
9988
+ type EventType = ExtractEventType<EventHandlersElement<Element>> & ExtractEventType<EventHandlersWindow<Element>>; // GLOBAL ATTRIBUTES
9991
9989
  /**
9992
9990
  * Global `Element` + `Node` interface keys, shared by all tags regardless of their namespace:
9993
9991
  *
@@ -10013,7 +10011,7 @@ declare namespace JSX {
10013
10011
  * with reactive values directly; manually-built strings re-run the whole
10014
10012
  * concatenation on every change instead of toggling the affected classes.
10015
10013
  */
10016
- class?: string | ClassList | RemoveAttribute;
10014
+ class?: ClassValue | RemoveAttribute;
10017
10015
  elementtiming?: string | RemoveAttribute;
10018
10016
  id?: string | RemoveAttribute;
10019
10017
  nonce?: string | RemoveAttribute;
@@ -10455,7 +10453,10 @@ declare namespace JSX {
10455
10453
  loop?: BooleanAttribute | RemoveAttribute;
10456
10454
  preload?: "none" | "metadata" | "auto" | EnumeratedAcceptsEmpty | RemoveAttribute;
10457
10455
  src?: string | RemoveAttribute;
10458
- onEncrypted?: EventHandlerUnion<T, MediaEncryptedEvent> | undefined; // special cases locked to properties
10456
+ onEncrypted?: EventHandlerUnion<T, MediaEncryptedEvent> | undefined;
10457
+ onWaitingForKey?: EventHandlerUnion<T, Event> | undefined;
10458
+ /** @deprecated */
10459
+ mediagroup?: string | RemoveAttribute; // special cases locked to properties
10459
10460
  muted?: BooleanProperty | RemoveProperty;
10460
10461
  /** @error use `<video/audio muted={..}/>` instead */
10461
10462
  "prop:muted"?: never;
@@ -10738,6 +10739,10 @@ declare namespace JSX {
10738
10739
  poster?: string | RemoveAttribute;
10739
10740
  width?: number | string | RemoveAttribute;
10740
10741
  onEnterPictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
10742
+ onLeavePictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
10743
+ }
10744
+ interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
10745
+ allowpopups?: BooleanAttribute | RemoveAttribute;
10741
10746
  disableblinkfeatures?: string | RemoveAttribute;
10742
10747
  disablewebsecurity?: BooleanAttribute | RemoveAttribute;
10743
10748
  enableblinkfeatures?: string | RemoveAttribute;
@@ -10776,7 +10781,7 @@ declare namespace JSX {
10776
10781
  * with reactive values directly; manually-built strings re-run the whole
10777
10782
  * concatenation on every change instead of toggling the affected classes.
10778
10783
  */
10779
- class?: string | ClassList | RemoveAttribute;
10784
+ class?: ClassValue | RemoveAttribute;
10780
10785
  style?: CSSProperties | string | RemoveAttribute;
10781
10786
  }
10782
10787
  interface TransformableSVGAttributes {
@@ -10883,6 +10888,12 @@ declare namespace JSX {
10883
10888
  }
10884
10889
  interface AnimationElementSVGAttributes<T> extends SVGAttributes<T>, ExternalResourceSVGAttributes, ConditionalProcessingSVGAttributes {
10885
10890
  onBegin?: EventHandlerUnion<T, TimeEvent> | undefined;
10891
+ onEnd?: EventHandlerUnion<T, TimeEvent> | undefined;
10892
+ onRepeat?: EventHandlerUnion<T, TimeEvent> | undefined;
10893
+ }
10894
+ interface ContainerElementSVGAttributes<T> extends SVGAttributes<T>, ShapeElementSVGAttributes<T>, Pick<PresentationSVGAttributes, "clip-path" | "mask" | "cursor" | "opacity" | "filter" | "enable-background" | "color-interpolation" | "color-rendering"> {}
10895
+ interface FilterPrimitiveElementSVGAttributes<T> extends SVGAttributes<T>, Pick<PresentationSVGAttributes, "color-interpolation-filters"> {
10896
+ height?: number | string | RemoveAttribute;
10886
10897
  result?: string | RemoveAttribute;
10887
10898
  width?: number | string | RemoveAttribute;
10888
10899
  x?: number | string | RemoveAttribute;