@stacksjs/stx-vscode 0.2.709 → 0.2.711

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-typescript-plugin",
3
- "version": "0.2.709",
3
+ "version": "0.2.711",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -782,6 +782,7 @@ declare function withDefaults<T extends Record<string, any>>(_props: T, _default
782
782
  * @example
783
783
  * const emit = defineEmits<{ view: [record: Row], remove: [id: number] }>()
784
784
  */
785
+ declare function defineEmits(_events: readonly string[]): (_event: string, ..._args: unknown[]) => void
785
786
  declare function defineEmits<T extends string = string>(): (_event: T, ..._args: unknown[]) => void
786
787
  declare function defineEmits<T extends Record<string, unknown[]>>(): <K extends keyof T & string>(_event: K, ..._args: T[K]) => void
787
788
  declare function defineExpose<T extends Record<string, any>>(_exposed: T): void
@@ -22,7 +22,7 @@ namespace ${s} {
22
22
  ${o}
23
23
  ${u.join(`
24
24
  `)}
25
- }`,props:p,events:m}}var Z=G(require("node:fs"),1),A=G(require("node:path"),1);function Pe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var De=new Map;function Ie(e,s=!0){let t=De.get(e);if(s&&t)return t;let n=new Map,i=[A.default.join(e,"src"),A.default.join(e,"dist"),e];function o(r,a){if(a>6)return;let c;try{c=Z.default.readdirSync(r,{withFileTypes:!0})}catch{return}for(let u of c){let p=A.default.join(r,u.name);if(u.isDirectory()){if(u.name==="node_modules"||u.name.startsWith("."))continue;o(p,a+1)}else if(u.isFile()&&u.name.endsWith(".stx")){let m=u.name.slice(0,-4);if(!n.has(m))n.set(m,p);let g=m.toLowerCase();if(!n.has(g))n.set(g,p);let S=Pe(m);if(!n.has(S))n.set(S,p)}}}for(let r of i)if(o(r,0),n.size>0)break;if(s)De.set(e,n);return n}function Le(e,s){if(e.startsWith(".")||e.startsWith("/"))return null;let t=s;while(!0){let n=A.default.join(t,"node_modules",e);try{if(Z.default.statSync(n).isDirectory())return n}catch{}let i=A.default.dirname(t);if(i===t)return null;t=i}}function Oe(e,s,t={}){return[A.default.resolve(A.default.dirname(s),`${e}.stx`),A.default.resolve(A.default.dirname(s),e),A.default.resolve(t.componentsDir||"components",`${e}.stx`),A.default.resolve(t.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Me(e){let s=e.endsWith(".stx")?e.slice(0,-4):e,t=s.split("-").map((i)=>i.charAt(0).toUpperCase()+i.slice(1)).join(""),n=Pe(s);return[s,t,n]}function Lt(e,s){let[t,n,i]=Me(e);for(let o of[t,t.toLowerCase(),n,i]){let r=s?.__importedComponents?.get(o);if(r!==void 0)return r}}function*Ot(e,s,t={},n){let i=Me(e);if(i[0].startsWith("./")||i[0].startsWith("../")){yield A.default.resolve(A.default.dirname(s),`${i[0]}.stx`);return}let o=[...new Set(i.map((c)=>`${c}.stx`))],r=t.projectRoot||process.cwd(),a=[...n?.__originalFilePath?[A.default.join(A.default.dirname(n.__originalFilePath),"components")]:[],...t.componentsDir?[t.componentsDir]:[],A.default.join(A.default.dirname(s),"components"),A.default.resolve(r,"src/components"),A.default.resolve(r,"components"),A.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let u of o)yield A.default.join(c,u);try{for(let u of Z.default.readdirSync(c,{withFileTypes:!0}))if(u.isDirectory())for(let p of o)yield A.default.join(c,u.name,p)}catch{}}}function Ne(e,s,t={},n){let i=Lt(e,n);if(i!==void 0)return i;for(let o of Ot(e,s,t,n))try{if(Z.default.statSync(o,{throwIfNoEntry:!1})?.isFile())return o}catch{}return null}var je=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Be(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...je].some((s)=>s.toLowerCase()===e.toLowerCase());return je.has(e)||/[A-Z]/.test(e)}function*Mt(e){let s=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,t;while(t=s.exec(e)){let n=s.lastIndex,i=[];while(n<e.length){while(/\s/.test(e[n]||""))n++;if(e[n]===">"||e.slice(n,n+2)==="/>"){n+=e[n]===">"?1:2;break}let o=/^[^\s=/>]+/.exec(e.slice(n))?.[0];if(!o){n++;continue}let r=n;n+=o.length;while(/\s/.test(e[n]||""))n++;if(e[n]!=="="){i.push({name:o,value:!0,offset:r,braced:!1});continue}n++;while(/\s/.test(e[n]||""))n++;let a=e[n],c=a==="{",u=a==='"'||a==="'";if(u||c)n++;let p=n;if(c){let m=L(e.slice(n)),g=1,S=0;for(;S<m.length;S++){if(m[S]==="{")g++;if(m[S]==="}"&&--g===0)break}n+=S}else if(u)while(n<e.length&&e[n]!==a)n++;else while(n<e.length&&!/[\s/>]/.test(e[n]))n++;if(i.push({name:o,value:e.slice(p,n),offset:p,braced:c}),u||c)n++}s.lastIndex=n,yield{name:t[1],offset:t.index,attributes:i}}}function Fe(e,s,t){let n=[],i=[Ae,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],o=new Map,r=new Map,a=new Map,c=t.scriptCode(e,t.filePath),u=L(c);for(let w of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(u.slice(w.index,w.index+6)!=="import")continue;let b=w[2],v=z.default.isAbsolute(b)||b.startsWith(".")?z.default.resolve(z.default.dirname(t.filePath),b):Le(b,z.default.dirname(t.filePath));if(!v)continue;let k=v.endsWith(".stx")?v:J.default.existsSync(`${v}.stx`)?`${v}.stx`:void 0,y=k?null:Ie(v,!1),_=w[1].startsWith("{")?w[1].slice(1,-1).split(","):[w[1]];for(let C of _){let[O,T=O]=C.trim().split(/\s+as\s+/),N=k||y?.get(O)||y?.get(O.toLowerCase());if(N)a.set(T,N),a.set(T.toLowerCase(),N),a.set(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),N)}}for(let w of s.matchAll(/@import\s*\(([^)]+)\)/g))for(let b of w[1].matchAll(/['"]([^'"]+)['"]/g)){let v=Oe(b[1],t.filePath,t).find((k)=>J.default.statSync(k,{throwIfNoEntry:!1})?.isFile());if(v)a.set(z.default.basename(b[1]).replace(/\.stx$/,""),v)}let p={__importedComponents:a},m=new Map,g=(w,b,v)=>{let k=e.slice(0,w);return{code:b,offset:w,attribute:v,anchor:!0,kind:"directive",line:k.split(`
25
+ }`,props:p,events:m}}var Z=G(require("node:fs"),1),A=G(require("node:path"),1);function Pe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var De=new Map;function Ie(e,s=!0){let t=De.get(e);if(s&&t)return t;let n=new Map,i=[A.default.join(e,"src"),A.default.join(e,"dist"),e];function o(r,a){if(a>6)return;let c;try{c=Z.default.readdirSync(r,{withFileTypes:!0})}catch{return}for(let u of c){let p=A.default.join(r,u.name);if(u.isDirectory()){if(u.name==="node_modules"||u.name.startsWith("."))continue;o(p,a+1)}else if(u.isFile()&&u.name.endsWith(".stx")){let m=u.name.slice(0,-4);if(!n.has(m))n.set(m,p);let g=m.toLowerCase();if(!n.has(g))n.set(g,p);let S=Pe(m);if(!n.has(S))n.set(S,p)}}}for(let r of i)if(o(r,0),n.size>0)break;if(s)De.set(e,n);return n}function Le(e,s){if(e.startsWith(".")||e.startsWith("/"))return null;let t=s;while(!0){let n=A.default.join(t,"node_modules",e);try{if(Z.default.statSync(n).isDirectory())return n}catch{}let i=A.default.dirname(t);if(i===t)return null;t=i}}function Oe(e,s,t={}){return[A.default.resolve(A.default.dirname(s),`${e}.stx`),A.default.resolve(A.default.dirname(s),e),A.default.resolve(t.componentsDir||"components",`${e}.stx`),A.default.resolve(t.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Me(e){let s=e.endsWith(".stx")?e.slice(0,-4):e,t=s.split("-").map((i)=>i.charAt(0).toUpperCase()+i.slice(1)).join(""),n=Pe(s);return[s,t,n]}function Lt(e,s){let[t,n,i]=Me(e);for(let o of[t,t.toLowerCase(),n,i]){let r=s?.__importedComponents?.get(o);if(r!==void 0)return r}}function*Ot(e,s,t={},n){let i=Me(e);if(i[0].startsWith("./")||i[0].startsWith("../")){yield A.default.resolve(A.default.dirname(s),`${i[0]}.stx`);return}let o=[...new Set(i.map((c)=>`${c}.stx`))],r=t.projectRoot||process.cwd(),a=[...n?.__originalFilePath?[A.default.join(A.default.dirname(n.__originalFilePath),"components")]:[],...t.componentsDir?[t.componentsDir]:[],A.default.join(A.default.dirname(s),"components"),A.default.resolve(r,"src/components"),A.default.resolve(r,"components"),A.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let u of o)yield A.default.join(c,u);try{for(let u of Z.default.readdirSync(c,{withFileTypes:!0}))if(u.isDirectory())for(let p of o)yield A.default.join(c,u.name,p)}catch{}}}function Ne(e,s,t={},n){let i=Lt(e,n);if(i!==void 0)return i;for(let o of Ot(e,s,t,n))try{if(Z.default.statSync(o,{throwIfNoEntry:!1})?.isFile())return o}catch{}return null}var je=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Be(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...je].some((s)=>s.toLowerCase()===e.toLowerCase());return je.has(e)||/[A-Z]/.test(e)}function*Mt(e){let s=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,t;while(t=s.exec(e)){let n=s.lastIndex,i=[];while(n<e.length){while(/\s/.test(e[n]||""))n++;if(e[n]===">"||e.slice(n,n+2)==="/>"){n+=e[n]===">"?1:2;break}let o=/^[^\s=/>]+/.exec(e.slice(n))?.[0];if(!o){n++;continue}let r=n;n+=o.length;while(/\s/.test(e[n]||""))n++;if(e[n]!=="="){i.push({name:o,value:!0,offset:r,braced:!1});continue}n++;while(/\s/.test(e[n]||""))n++;let a=e[n],c=a==="{",u=a==='"'||a==="'";if(u||c)n++;let p=n;if(c){let m=L(e.slice(n)),g=1,S=0;for(;S<m.length;S++){if(m[S]==="{")g++;if(m[S]==="}"&&--g===0)break}n+=S}else if(u)while(n<e.length&&e[n]!==a)n++;else while(n<e.length&&!/[\s/>]/.test(e[n]))n++;if(i.push({name:o,value:e.slice(p,n),offset:p,braced:c}),u||c)n++}s.lastIndex=n,yield{name:t[1],offset:t.index,attributes:i}}}function Fe(e,s,t){let n=[],i=[Ae,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],o=new Map,r=new Map,a=new Map,c=t.scriptCode(e,t.filePath),u=L(c);for(let w of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(u.slice(w.index,w.index+6)!=="import")continue;let b=w[2],v=z.default.isAbsolute(b)||b.startsWith(".")?z.default.resolve(z.default.dirname(t.filePath),b):Le(b,z.default.dirname(t.filePath));if(!v)continue;let k=v.endsWith(".stx")?v:J.default.existsSync(`${v}.stx`)?`${v}.stx`:void 0,y=k?null:Ie(v,!1),_=w[1].startsWith("{")?w[1].slice(1,-1).split(","):[w[1]];for(let C of _){let[O,T=O]=C.trim().split(/\s+as\s+/),N=k||y?.get(O)||y?.get(O.toLowerCase());if(N)a.set(T,N),a.set(T.toLowerCase(),N),a.set(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),N)}}for(let w of s.matchAll(/@import\s*\(([^)]+)\)/g))for(let b of w[1].matchAll(/['"]([^'"]+)['"]/g)){let v=Oe(b[1],t.filePath,t).find((k)=>J.default.statSync(k,{throwIfNoEntry:!1})?.isFile());if(v)a.set(z.default.basename(b[1]).replace(/\.stx$/,""),v)}let p={__importedComponents:a},m=new Map,g=(w,b,v)=>{let k=e.slice(0,w);return{code:b,offset:w,attribute:v,anchor:!0,kind:"directive",line:k.split(`
26
26
  `).length,column:w-k.lastIndexOf(`
27
27
  `)}},S=(w,b,v)=>n.push({expression:w,statement:{text:b+w.code+v,prefixLength:b.length}});for(let w of Mt(s)){if(Be(w.name)||w.name==="component")continue;let b=Ne(w.name,t.filePath,t,p);if(!b)continue;let v=m.get(b);if(!v){let y;try{y=t.readComponent?t.readComponent(b):J.default.readFileSync(b,"utf8")}catch{continue}if(y===void 0)continue;r.set(b,y),v=Re(t.scriptCode(y,b),`__StxComponent${m.size}`),m.set(b,v),i.push(v.declarations)}let k=[];for(let y of w.attributes){let{name:_,offset:C}=y,O=y.value===!0?"true":y.value;if(_.startsWith("@")||_.startsWith("v-on:")){if(v.events&&y.value!==!0)o.set(C,`__StxEvent<${v.events}, ${JSON.stringify(_.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let T=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(_);if(_.startsWith("v-")&&!_.startsWith("v-bind:")&&!T)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(_))continue;let N=(T?T[1]||"modelValue":_.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(M,j)=>j.toUpperCase());if(k.push(N),!v.props)continue;let P=_.startsWith(":")||_.startsWith("v-bind:")||!!T||y.braced?O:y.value!==!0?JSON.stringify(O):"true";S(g(C,P,_),";void ((",`) satisfies __StxProp<${v.props}, ${JSON.stringify(N)}>);`)}if(v.props){let y=[...new Set(k)].map((C)=>`${JSON.stringify(C)}: undefined as any`).join(", "),_=g(w.offset,`<${w.name}>`);n.push({expression:_,statement:{text:`;void ({ ${y} } satisfies ${v.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:m.size?i.join(`
28
28
  `):"",checks:n,events:o,dependencies:r}}function Ve(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let s=[],t=[],n=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let i of e.matchAll(n)){let o=i[0];if(/^<\/template\s*>$/i.test(o)){let r=t.pop();if(r)r.end=i.index}else if(/^<template\b/i.test(o)&&!/\/\s*>$/.test(o)){let a=[...o.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(p[1])),c=(a?.[2]??a?.[3])?.trim();if(c&&a?.[1]==="data-stx-slot-binding")try{c=decodeURIComponent(c)}catch{c=void 0}let u=c?{start:i.index+o.length,end:e.length,binding:c}:void 0;if(t.push(u),u)s.push(u)}}return s}var We=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Nt(e){let s=(t)=>t.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,s).replace(/\{\{--[\s\S]*?--\}\}/g,s)}function te(e){let s=[],t=Nt(e);We.lastIndex=0;let n;while((n=We.exec(t))!==null){let i=(n[1]||"").trim(),o=(n[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,r=(n[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,a=n.index+o,c=n.index+n[0].length-r,u=e.slice(a,c);if(/\bsrc\s*=/.test(i))continue;let p=i.match(/\btype\s*=\s*["']([^"']+)["']/i);if(p&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(p[1]))continue;let m=/\bserver\b/.test(i)?"server":/\bclient\b/.test(i)?"client":"plain",g=U(e,a);s.push({kind:m,code:u,startLine:g,startColumn:q(e,a),offset:a,attrs:i})}return s}function U(e,s){let t=1;for(let n=0;n<s&&n<e.length;n++)if(e.charCodeAt(n)===10)t++;return t}function q(e,s){let t=e.lastIndexOf(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.709",
4
+ "version": "0.2.711",
5
5
  "description": "stx language support for VS Code extensions to embed: the hovers, completions, diagnostics, grammar, snippets, language configuration and TypeScript server plugin behind the stx extension.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",