@stacksjs/stx-vscode 0.2.381 → 0.2.382

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.381",
3
+ "version": "0.2.382",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -35,7 +35,7 @@ ${q.join(`
35
35
  `);v.forEach((O,M)=>{let D=w.startLine-1+M;if(D<K.length)K[D]=M===0?a2(w)+O:O,z.add(D)}),V.push(w.startLine-1+v.length-1)}for(let w of V){let F=K[w]?.trim()===""?w:w+1;if(F<K.length&&K[F].trim()===""&&(F===w||!z.has(F)))K[F]=";"}let q=(w,F)=>{for(let[v,O]of w.split(`
36
36
  `).entries())if(K.push(O),F)Y.set(K.length,v===0?F:{...F,line:F.line+v,column:1,prefixLength:0})};if(Q.globals!==!1){q("");let w=new Set([...J.flatMap((M)=>e(M.code)),...J.flatMap((M)=>o2(M.code))]),F=(M)=>{if(!w.has(M))q(`declare var ${M}: any`)};if(Q.runtimeGlobals!==!1){if(!w.has("window"))q("declare var window: any");for(let M of p)F(M)}let v=[...new Set([...h$,...j$,...p$])].filter((M)=>Q.runtimeGlobals!==!1||!p.includes(M));if(Q.contextScope==="global"){q("declare global {");for(let M of v)q(` var ${M}: any`);q("}")}else{for(let M of h$)F(M);for(let M of j$)F(M);for(let M of p$)F(M)}q(`declare var ${V$}: any`);let O=new Set(J.flatMap((M)=>e(M.code)));q(`type ${b$}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let M of d2($)){if(O.has(M.name))continue;let D=M.iterable&&O.has(M.iterable)?`${b$}<typeof ${M.iterable}>`:"any";q(`declare var ${M.name}: ${D}`)}}if(Q.templateExpressions!==!1){if(j?.declarations)for(let F of j.declarations.split(`
37
37
  `))q(F);let w=p2($).map((F)=>{let v=j?.events.get(F.offset??-1);if(v){F.anchor=!0;let O=F.code.trim(),M=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(O),D=M?`void ((${M[2]}) satisfies __StxAssignedValue<typeof ${M[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(O)?`${O} satisfies (($event: ${v}) => unknown)`:O,P=`;(($event: ${v}): void => { `;return{expression:F,statement:{text:`${P}${D} });`,prefixLength:P.length}}}return{expression:F,statement:n2(F)}}).filter((F)=>F.statement!==null);if(w.push(...j?.checks||[]),w.length>0){let F=J$($),v=c2(J.map((P)=>P.code)),M=[...new Set(J.flatMap((P)=>e(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),D=0;if(M.length>0){q(g2);for(let P of M)q(`type __StxT_${P} = ${d$}<typeof ${P}>`);q(`;((${M.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),D=1}for(let{expression:P,statement:C}of w){let L=" ".repeat(D),y=P.offset===void 0?[]:s2(F,P.offset),T=y.length>0?`${y.map((x)=>`if (${c$(x,v)}) `).join("")}{ `:"",A=y.length>0?" }":"";q(L+T+C.text+A,{line:P.line,column:P.column,expression:P,prefixLength:C.prefixLength+L.length+T.length,guardPrefixLength:L.length+T.length})}if(D>0)q("});")}}let G=!1;if(Q.reference&&K[0]!==void 0&&K[0].trim()==="")K[0]=`/// <reference path=${JSON.stringify(Q.reference.replace(/\\/g,"/"))} />`,G=!0;return q("export {}"),{text:K.join(`
38
- `),lineMap:Y,sourceLineCount:Z.length,componentDependencies:j?.dependencies,referenced:G}}function q$($){let Q=[0];for(let J=0;J<$.length;J++)if($.charCodeAt(J)===10)Q.push(J+1);return Q}function Q$($,Q){let J=0,Z=$.length-1;while(J<Z){let K=Math.ceil((J+Z)/2);if($[K]<=Q)J=K;else Z=K-1}return{line:J+1,column:Q-$[J]+1}}function K$($,Q,J){let Z=Math.min(Math.max(Q,1),$.length)-1,K=Z+1<$.length?$[Z+1]-1:Number.MAX_SAFE_INTEGER;return Math.min($[Z]+Math.max(J,1)-1,K)}function n$($,Q){if(!$.expression)return!1;return $.inGuard===!0||Q===2774}function i$($,Q,J){let Z=$.lineMap.get(Q);if(!Z)return Q<=$.sourceLineCount?{line:Q,column:J}:null;let K=Z.expression?.anchor?0:Math.max(0,J-1-(Z.prefixLength??0));return{line:Z.line,column:Z.column+K,expression:Z.expression,inGuard:J<=(Z.guardPrefixLength??0)}}var a$=["module","exports","require","props","$props","$bool","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var t2=new Set(["module","exports","require","$bool","window","document","console","confirm","alert","fetch"]),t$=a$.filter(($)=>!t2.has($)).sort(),e$=[...p].sort(),e2=[...new Set([...t$,...e$])].sort(),$4=new Set(t$),J4=new Set(e$),Z4=new Set(e2),o$=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Q4($,Q){if(Q==="server")return`'${$}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${$}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${$}', so it is undefined in the browser.`}function $2($,Q){let J=[];for(let Z of Q){if(Z.offset===void 0)continue;let K=Z.kind==="server"?$4:J4;o$.lastIndex=0;for(let Y of Z.code.matchAll(o$)){let j=Y.index+Y[0].indexOf("{")+1;for(let z of Y[1].matchAll(/[^,]+/g)){let V=z[0];if(/^\s*type\s/.test(V))continue;let q=/^\s*([A-Za-z_$][\w$]*)/.exec(V);if(!q)continue;let G=q[1];if(!Z4.has(G)||K.has(G))continue;let w=Z.offset+j+z.index+q[0].length-G.length,F=$.slice(0,w),v=F.split(`
38
+ `),lineMap:Y,sourceLineCount:Z.length,componentDependencies:j?.dependencies,referenced:G}}function q$($){let Q=[0];for(let J=0;J<$.length;J++)if($.charCodeAt(J)===10)Q.push(J+1);return Q}function Q$($,Q){let J=0,Z=$.length-1;while(J<Z){let K=Math.ceil((J+Z)/2);if($[K]<=Q)J=K;else Z=K-1}return{line:J+1,column:Q-$[J]+1}}function K$($,Q,J){let Z=Math.min(Math.max(Q,1),$.length)-1,K=Z+1<$.length?$[Z+1]-1:Number.MAX_SAFE_INTEGER;return Math.min($[Z]+Math.max(J,1)-1,K)}function n$($,Q){if(!$.expression)return!1;return $.inGuard===!0||Q===2774}function i$($,Q,J){let Z=$.lineMap.get(Q);if(!Z)return Q<=$.sourceLineCount?{line:Q,column:J}:null;let K=Z.expression?.anchor?0:Math.max(0,J-1-(Z.prefixLength??0));return{line:Z.line,column:Z.column+K,expression:Z.expression,inGuard:J<=(Z.guardPrefixLength??0)}}var a$=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var t2=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),t$=a$.filter(($)=>!t2.has($)).sort(),e$=[...p].sort(),e2=[...new Set([...t$,...e$])].sort(),$4=new Set(t$),J4=new Set(e$),Z4=new Set(e2),o$=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Q4($,Q){if(Q==="server")return`'${$}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${$}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${$}', so it is undefined in the browser.`}function $2($,Q){let J=[];for(let Z of Q){if(Z.offset===void 0)continue;let K=Z.kind==="server"?$4:J4;o$.lastIndex=0;for(let Y of Z.code.matchAll(o$)){let j=Y.index+Y[0].indexOf("{")+1;for(let z of Y[1].matchAll(/[^,]+/g)){let V=z[0];if(/^\s*type\s/.test(V))continue;let q=/^\s*([A-Za-z_$][\w$]*)/.exec(V);if(!q)continue;let G=q[1];if(!Z4.has(G)||K.has(G))continue;let w=Z.offset+j+z.index+q[0].length-G.length,F=$.slice(0,w),v=F.split(`
39
39
  `).length;J.push({line:v,column:w-(F.lastIndexOf(`
40
40
  `)+1)+1,offset:w,length:G.length,name:G,kind:Z.kind,message:Q4(G,Z.kind)})}}}return J}var u=h(require("node:path")),K4="@stacksjs/stx-typescript-plugin";function z4($,Q){let J=u.default.resolve($);for(;;){let Z=u.default.join(J,"tsconfig.json");if(Q(Z))return Z;let K=u.default.dirname(J);if(K===J)return;J=K}}function J2($,Q,J){let Z=z4($,J);if(!Z)return;let K=new Set,Y=(j)=>{if(K.has(j))return;K.add(j);let z=Q(j);if(!z)return;let V=z.compilerOptions?.plugins;if(Array.isArray(V)){let G=V.find((F)=>F?.name===K4),w=Array.isArray(G?.libs)?G.libs.filter((F)=>typeof F==="string"):[];return G?{configPath:j,libs:w.map((F)=>u.default.resolve(u.default.dirname(j),F))}:null}let q=typeof z.extends==="string"?[z.extends]:Array.isArray(z.extends)?z.extends:[];for(let G of[...q].reverse()){if(typeof G!=="string"||!G.startsWith("."))continue;let w=u.default.resolve(u.default.dirname(j),G.endsWith(".json")?G:`${G}.json`),F=Y(w);if(F!==void 0)return F}return};return Y(Z)??void 0}var Z2=Symbol.for("@stacksjs/stx-typescript-plugin"),j4=new Set([2300,2451,2403]);function n($){return $.endsWith(".stx")}function Q2($){return n($)||$.endsWith(".md")}function Y4($){if(!$)return;return b.existsSync(k.default.join($,"stx-module.d.ts"))&&b.existsSync(k.default.join($,"stx.d.ts"))?k.default.join($,"stx-module.d.ts"):void 0}function V4($,Q=b.existsSync){let J=$;for(;;){let Z=k.default.join(J,"node_modules","@stacksjs","stx","stx-module.d.ts");if(Q(Z))return Z;let K=k.default.dirname(J);if(K===J)return;J=K}}function W4($,Q=k.default.join(z2.tmpdir(),"stx-typescript-plugin")){let J=$.map((K)=>`/// <reference path=${JSON.stringify(K.replace(/\\/g,"/"))} />`).join(`
41
41
  `)+`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.381",
4
+ "version": "0.2.382",
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",