@solidjs/html 2.0.0-beta.15 → 2.0.0-beta.16
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/README.md +4 -2
- package/dist/html.cjs +1 -1
- package/dist/html.js +1 -1
- package/package.json +5 -5
- package/types/index.d.ts +2 -2
- package/types/{sld.d.ts → tagged-jsx.d.ts} +17 -17
- package/types-cjs/index.d.cts +2 -2
- package/types-cjs/{sld.d.cts → tagged-jsx.d.cts} +17 -17
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@ This sub module provides a Tagged Template Literal `html` method for Solid. This
|
|
|
4
4
|
|
|
5
5
|
`html` uses `${}` to escape into JavaScript expressions. Components are closed with `<//>`.
|
|
6
6
|
|
|
7
|
-
Since Solid 2.0, `html` is backed by [
|
|
7
|
+
Since Solid 2.0, `html` is backed by [`@dom-expressions/tagged-jsx`](https://www.npmjs.com/package/@dom-expressions/tagged-jsx), an AST-based tagged-template runtime. Templates are parsed at runtime (no `new Function` / `eval`, so it is CSP-safe) and reactive bindings are installed against the resulting DOM.
|
|
8
|
+
|
|
9
|
+
For editor support, the [Tagged JSX Tools VS Code extension](https://marketplace.visualstudio.com/items?itemName=DanielRKling.tagged-jsx-vscode) provides syntax highlighting, formatting, conversion commands, and TypeScript diagnostics for JSX inside tagged template literals.
|
|
8
10
|
|
|
9
11
|
```js
|
|
10
12
|
// create an element with a title attribute
|
|
@@ -42,7 +44,7 @@ render(Counter, document.getElementById("app"));
|
|
|
42
44
|
|
|
43
45
|
## Component registry
|
|
44
46
|
|
|
45
|
-
Inline expression holes (`<${Component} />`) work without any setup, but the
|
|
47
|
+
Inline expression holes (`<${Component} />`) work without any setup, but the Tagged JSX runtime also supports a named component registry. `html.define({ ... })` returns a new tag with the supplied components merged into the registry; capitalized tag names in the template are then looked up by name. The original `html` tag is unchanged.
|
|
46
48
|
|
|
47
49
|
```js
|
|
48
50
|
import html from "@solidjs/html";
|
package/dist/html.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var web = require('@solidjs/web');
|
|
4
4
|
|
|
5
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.
|
|
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.jsx=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: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
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.
|
|
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.jsx=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: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.
|
|
4
|
+
"version": "2.0.0-beta.16",
|
|
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.
|
|
40
|
+
"@solidjs/web": "^2.0.0-beta.16"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@solidjs/web": "2.0.0-beta.
|
|
44
|
-
"solid-js": "2.0.0-beta.
|
|
43
|
+
"@solidjs/web": "2.0.0-beta.16",
|
|
44
|
+
"solid-js": "2.0.0-beta.16"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "npm-run-all -nl build:*",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"build:js": "rollup -c",
|
|
50
50
|
"types": "npm-run-all -nl types:clean types:html types:cjs",
|
|
51
51
|
"types:clean": "rimraf types/ types-cjs/",
|
|
52
|
-
"types:html": "tsc --project ./tsconfig.json && ncp ../../node_modules
|
|
52
|
+
"types:html": "tsc --project ./tsconfig.json && ncp ../../node_modules/@dom-expressions/tagged-jsx/dist/index.d.mts ./types/tagged-jsx.d.ts",
|
|
53
53
|
"types:cjs": "node ../../scripts/sync-dual-types.mjs ./types ./types-cjs",
|
|
54
54
|
"test": "vitest run"
|
|
55
55
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const html:
|
|
1
|
+
import type { TaggedJSXInstance } from "./tagged-jsx.js";
|
|
2
|
+
declare const html: TaggedJSXInstance<{}>;
|
|
3
3
|
export default html;
|
|
@@ -9270,7 +9270,7 @@ declare namespace DataType {
|
|
|
9270
9270
|
type VisualBox = "border-box" | "content-box" | "padding-box";
|
|
9271
9271
|
}
|
|
9272
9272
|
//#endregion
|
|
9273
|
-
//#region ../
|
|
9273
|
+
//#region ../runtime/src/jsx-properties.d.ts
|
|
9274
9274
|
/**
|
|
9275
9275
|
* Shared type-level helpers used to derive `prop:*` attribute typings from
|
|
9276
9276
|
* DOM element interfaces (e.g. `HTMLInputElement`, `HTMLButtonElement`).
|
|
@@ -9331,7 +9331,7 @@ type IsReadonlyKey<T, K extends keyof T> = IfEquals<Pick<T, K>, Readonly<Pick<T,
|
|
|
9331
9331
|
*/
|
|
9332
9332
|
type PropKey<T, K extends keyof T> = K extends keyof SkipPropsFrom ? never : K extends string ? string extends K ? never : K extends `aria${string}` ? never : T[K] extends PropValue ? IsReadonlyKey<T, K> extends true ? never : `prop:${K}` : never : never;
|
|
9333
9333
|
//#endregion
|
|
9334
|
-
//#region ../
|
|
9334
|
+
//#region ../runtime/src/jsx.d.ts
|
|
9335
9335
|
/**
|
|
9336
9336
|
* Originally based on JSX types for Surplus and Inferno and adapted for `dom-expressions`.
|
|
9337
9337
|
*
|
|
@@ -12488,39 +12488,39 @@ type FunctionComponent = (...args: any[]) => any;
|
|
|
12488
12488
|
*/
|
|
12489
12489
|
type ComponentRegistry = Record<string, FunctionComponent>;
|
|
12490
12490
|
/**
|
|
12491
|
-
*
|
|
12491
|
+
* Tagged JSX instance type
|
|
12492
12492
|
* @template T Component registry
|
|
12493
12493
|
*/
|
|
12494
|
-
type
|
|
12494
|
+
type TaggedJSXInstance<T extends ComponentRegistry> = {
|
|
12495
12495
|
/**
|
|
12496
|
-
*
|
|
12496
|
+
* Tagged JSX template function
|
|
12497
12497
|
* @example
|
|
12498
12498
|
* ```tsx
|
|
12499
|
-
* const myTemplate =
|
|
12499
|
+
* const myTemplate = html`<div>Hello World</div>`
|
|
12500
12500
|
* ```
|
|
12501
12501
|
*/
|
|
12502
12502
|
(strings: TemplateStringsArray, ...values: any[]): JSX.Element;
|
|
12503
12503
|
/**
|
|
12504
|
-
* Self reference to
|
|
12504
|
+
* Self reference to tagged JSX instance for tooling
|
|
12505
12505
|
* @example
|
|
12506
12506
|
* ```tsx
|
|
12507
12507
|
* const MyComponent: FunctionComponent = (props) => {
|
|
12508
|
-
* // Use
|
|
12509
|
-
* return
|
|
12508
|
+
* // Use html to create a template inside a component
|
|
12509
|
+
* return myTaggedJSX.jsx`<div>Hello ${props.name}</div>`
|
|
12510
12510
|
* ```
|
|
12511
12511
|
*/
|
|
12512
|
-
|
|
12512
|
+
jsx: TaggedJSXInstance<T>;
|
|
12513
12513
|
/**
|
|
12514
|
-
* Create a new
|
|
12514
|
+
* Create a new tagged JSX instance with additional components added to the registry
|
|
12515
12515
|
* @param components New components to add to the registry
|
|
12516
12516
|
* @example
|
|
12517
12517
|
* ```tsx
|
|
12518
12518
|
* const MyComponent: FunctionComponent = (props) => <div>Hello {props.name}</div>
|
|
12519
|
-
* const
|
|
12520
|
-
* const myTemplate =
|
|
12519
|
+
* const myTaggedJSX = html.define({MyComponent})
|
|
12520
|
+
* const myTemplate = myTaggedJSX`<MyComponent name="World" />`
|
|
12521
12521
|
* ```
|
|
12522
12522
|
*/
|
|
12523
|
-
define<TNew extends ComponentRegistry>(components: TNew):
|
|
12523
|
+
define<TNew extends ComponentRegistry>(components: TNew): TaggedJSXInstance<T & TNew>;
|
|
12524
12524
|
/**
|
|
12525
12525
|
* Component registry
|
|
12526
12526
|
*/
|
|
@@ -12538,7 +12538,7 @@ interface Runtime {
|
|
|
12538
12538
|
MathMLElements: Set<string>;
|
|
12539
12539
|
}
|
|
12540
12540
|
//#endregion
|
|
12541
|
-
//#region src/
|
|
12542
|
-
declare function
|
|
12541
|
+
//#region src/tagged-jsx.d.ts
|
|
12542
|
+
declare function createTaggedJSXRuntime(r: Runtime): TaggedJSXInstance<{}>;
|
|
12543
12543
|
//#endregion
|
|
12544
|
-
export { type ComponentRegistry, type FunctionComponent, type Runtime, type
|
|
12544
|
+
export { type ComponentRegistry, type FunctionComponent, type Runtime, type TaggedJSXInstance, createTaggedJSXRuntime };
|
package/types-cjs/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const html:
|
|
1
|
+
import type { TaggedJSXInstance } from "./tagged-jsx.cjs";
|
|
2
|
+
declare const html: TaggedJSXInstance<{}>;
|
|
3
3
|
export default html;
|
|
@@ -9270,7 +9270,7 @@ declare namespace DataType {
|
|
|
9270
9270
|
type VisualBox = "border-box" | "content-box" | "padding-box";
|
|
9271
9271
|
}
|
|
9272
9272
|
//#endregion
|
|
9273
|
-
//#region ../
|
|
9273
|
+
//#region ../runtime/src/jsx-properties.d.ts
|
|
9274
9274
|
/**
|
|
9275
9275
|
* Shared type-level helpers used to derive `prop:*` attribute typings from
|
|
9276
9276
|
* DOM element interfaces (e.g. `HTMLInputElement`, `HTMLButtonElement`).
|
|
@@ -9331,7 +9331,7 @@ type IsReadonlyKey<T, K extends keyof T> = IfEquals<Pick<T, K>, Readonly<Pick<T,
|
|
|
9331
9331
|
*/
|
|
9332
9332
|
type PropKey<T, K extends keyof T> = K extends keyof SkipPropsFrom ? never : K extends string ? string extends K ? never : K extends `aria${string}` ? never : T[K] extends PropValue ? IsReadonlyKey<T, K> extends true ? never : `prop:${K}` : never : never;
|
|
9333
9333
|
//#endregion
|
|
9334
|
-
//#region ../
|
|
9334
|
+
//#region ../runtime/src/jsx.d.ts
|
|
9335
9335
|
/**
|
|
9336
9336
|
* Originally based on JSX types for Surplus and Inferno and adapted for `dom-expressions`.
|
|
9337
9337
|
*
|
|
@@ -12488,39 +12488,39 @@ type FunctionComponent = (...args: any[]) => any;
|
|
|
12488
12488
|
*/
|
|
12489
12489
|
type ComponentRegistry = Record<string, FunctionComponent>;
|
|
12490
12490
|
/**
|
|
12491
|
-
*
|
|
12491
|
+
* Tagged JSX instance type
|
|
12492
12492
|
* @template T Component registry
|
|
12493
12493
|
*/
|
|
12494
|
-
type
|
|
12494
|
+
type TaggedJSXInstance<T extends ComponentRegistry> = {
|
|
12495
12495
|
/**
|
|
12496
|
-
*
|
|
12496
|
+
* Tagged JSX template function
|
|
12497
12497
|
* @example
|
|
12498
12498
|
* ```tsx
|
|
12499
|
-
* const myTemplate =
|
|
12499
|
+
* const myTemplate = html`<div>Hello World</div>`
|
|
12500
12500
|
* ```
|
|
12501
12501
|
*/
|
|
12502
12502
|
(strings: TemplateStringsArray, ...values: any[]): JSX.Element;
|
|
12503
12503
|
/**
|
|
12504
|
-
* Self reference to
|
|
12504
|
+
* Self reference to tagged JSX instance for tooling
|
|
12505
12505
|
* @example
|
|
12506
12506
|
* ```tsx
|
|
12507
12507
|
* const MyComponent: FunctionComponent = (props) => {
|
|
12508
|
-
* // Use
|
|
12509
|
-
* return
|
|
12508
|
+
* // Use html to create a template inside a component
|
|
12509
|
+
* return myTaggedJSX.jsx`<div>Hello ${props.name}</div>`
|
|
12510
12510
|
* ```
|
|
12511
12511
|
*/
|
|
12512
|
-
|
|
12512
|
+
jsx: TaggedJSXInstance<T>;
|
|
12513
12513
|
/**
|
|
12514
|
-
* Create a new
|
|
12514
|
+
* Create a new tagged JSX instance with additional components added to the registry
|
|
12515
12515
|
* @param components New components to add to the registry
|
|
12516
12516
|
* @example
|
|
12517
12517
|
* ```tsx
|
|
12518
12518
|
* const MyComponent: FunctionComponent = (props) => <div>Hello {props.name}</div>
|
|
12519
|
-
* const
|
|
12520
|
-
* const myTemplate =
|
|
12519
|
+
* const myTaggedJSX = html.define({MyComponent})
|
|
12520
|
+
* const myTemplate = myTaggedJSX`<MyComponent name="World" />`
|
|
12521
12521
|
* ```
|
|
12522
12522
|
*/
|
|
12523
|
-
define<TNew extends ComponentRegistry>(components: TNew):
|
|
12523
|
+
define<TNew extends ComponentRegistry>(components: TNew): TaggedJSXInstance<T & TNew>;
|
|
12524
12524
|
/**
|
|
12525
12525
|
* Component registry
|
|
12526
12526
|
*/
|
|
@@ -12538,7 +12538,7 @@ interface Runtime {
|
|
|
12538
12538
|
MathMLElements: Set<string>;
|
|
12539
12539
|
}
|
|
12540
12540
|
//#endregion
|
|
12541
|
-
//#region src/
|
|
12542
|
-
declare function
|
|
12541
|
+
//#region src/tagged-jsx.d.ts
|
|
12542
|
+
declare function createTaggedJSXRuntime(r: Runtime): TaggedJSXInstance<{}>;
|
|
12543
12543
|
//#endregion
|
|
12544
|
-
export { type ComponentRegistry, type FunctionComponent, type Runtime, type
|
|
12544
|
+
export { type ComponentRegistry, type FunctionComponent, type Runtime, type TaggedJSXInstance, createTaggedJSXRuntime };
|