tailwint 1.1.11 → 1.1.12
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/lsp.js +4 -4
- package/package.json +1 -1
package/dist/lsp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{spawn as
|
|
1
|
+
import{spawn as H}from"child_process";import{resolve as $}from"path";import{existsSync as N,readFileSync as K}from"fs";const O=process.env.DEBUG==="1";let L="",m=null;function Q(){if(m!==null)return m;const e=$(L,".vscode/settings.json");if(!N(e))return m={},m;try{const t=K(e,"utf-8").replace(/\/\/[^\n]*/g,"").replace(/,\s*([\]}])/g,"$1");m=JSON.parse(t)}catch{m={}}return m}function X(e){const t=Q(),n=e+".",s={};for(const[l,y]of Object.entries(t)){if(!l.startsWith(n))continue;const c=l.slice(n.length).split(".");let p=s;for(let r=0;r<c.length-1;r++)(!(c[r]in p)||typeof p[c[r]]!="object")&&(p[c[r]]={}),p=p[c[r]];p[c[c.length-1]]=y}return s}let a,d=!1,A=0;const f=[];let x=0;const h=new Map,P=new Map;let F=!1,J=0,M=0,W=0,R=0,k=!1,j=0;const _=[];let v=null,i=null,o=null,w=null;const g=new Map;let B={predictedRoots:0,maxProjects:0,initTimeoutMs:5e3,debounceMs:500};function ae(){A=0,d=!1,f.length=0,x=0,h.clear(),P.clear(),F=!1,J=0,M=0,W=0,R=0,k=!1,j=0,_.length=0,v=null,b=!1,D=0,i&&(clearTimeout(i),i=null),o&&(clearTimeout(o),o=null),w&&(clearTimeout(w),w=null),g.clear(),m=null}function Y(){i&&(clearTimeout(i),i=null),o&&(clearTimeout(o),o=null),w&&(clearTimeout(w),w=null)}function S(){if(!v)return;const e=v;v=null,Y(),e()}function z(){return M+W>=B.maxProjects}function C(){o&&clearTimeout(o),o=setTimeout(()=>{j>0&&!b?(b=!0,G()):j>0?U():S()},B.initTimeoutMs)}function Z(){J++;const e=Date.now();F=!0,R>0&&e-R<500?k||(k=!0,W++,_.push("A CSS file failed to initialize (likely an @apply referencing an unknown utility). That project's files will not receive diagnostics. See https://github.com/tailwindlabs/tailwindcss-intellisense/issues/1121"),i&&(clearTimeout(i),i=null)):(k=!1,j=0,o&&(clearTimeout(o),o=null),i&&(clearTimeout(i),i=null),C()),R=e,z()&&S()}function U(){M++,z()?S():C()}function G(){i&&clearTimeout(i),o&&(clearTimeout(o),o=null),i=setTimeout(U,B.debounceMs)}let b=!1,D=0;function ee(){if(!v)return;j++;const e=Date.now(),t=D>0?e-D:0;D=e,b||t>=100&&(b=!0),b&&G()}function ue(e,t,n=5e3,s=500){return d||t===0?Promise.resolve():(B={predictedRoots:e,maxProjects:t,initTimeoutMs:n,debounceMs:s},new Promise(l=>{v=l,C();const y=n+t*3e3+5e3;w=setTimeout(S,Math.min(y,3e4))}))}function fe(e,t=1e4){return d?Promise.resolve([]):(P.delete(e),new Promise(n=>{const s=setTimeout(()=>{g.has(e)&&(g.delete(e),n([]))},t);g.set(e,l=>{clearTimeout(s),n(l)})}))}function I(e){const t=JSON.stringify(e);return`Content-Length: ${Buffer.byteLength(t)}\r
|
|
2
2
|
\r
|
|
3
|
-
${t}`}function
|
|
3
|
+
${t}`}function te(){if(f.length===0)return Buffer.alloc(0);if(f.length===1)return f[0];const e=Buffer.concat(f,x);return f.length=0,f.push(e),e}function E(e){f.length=0,e.length>0?(f.push(e),x=e.length):x=0}function ne(){for(;;){const e=te();if(e.length===0)break;const t=e.toString("ascii",0,Math.min(e.length,256)),n=t.indexOf(`\r
|
|
4
4
|
\r
|
|
5
|
-
`);if(n===-1){E(e);break}const l=t.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!l){E(e.subarray(n+4));continue}const y=parseInt(l[1],10),c=n+4;if(e.length<c+y){E(e);break}const p=e.subarray(c,c+y).toString("utf-8");E(e.subarray(c+y));let r;try{r=JSON.parse(p)}catch{continue}if(
|
|
5
|
+
`);if(n===-1){E(e);break}const l=t.slice(0,n).match(/Content-Length:\s*(\d+)/i);if(!l){E(e.subarray(n+4));continue}const y=parseInt(l[1],10),c=n+4;if(e.length<c+y){E(e);break}const p=e.subarray(c,c+y).toString("utf-8");E(e.subarray(c+y));let r;try{r=JSON.parse(p)}catch{continue}if(O&&console.error(`<- ${r.method||`response#${r.id}`}`),r.id!=null&&!r.method&&h.has(r.id)){const u=h.get(r.id);h.delete(r.id),r.error?u.reject(r.error):u.resolve(r.result);continue}if(r.id!=null&&r.method){let u=null;r.method==="workspace/configuration"&&(u=(r.params?.items||[]).map(T=>T.section?X(T.section):{})),a.stdin.write(I({jsonrpc:"2.0",id:r.id,result:u}));continue}if(r.method==="textDocument/publishDiagnostics"&&r.params){const u=r.params.uri,T=r.params.diagnostics||[];if(P.set(u,T),g.has(u)){const V=g.get(u);g.delete(u),V(T)}ee()}r.method==="@/tailwindCSS/projectInitialized"&&Z()}}function re(e){const t=$(e,"node_modules/.bin/tailwindcss-language-server");return N(t)?t:"tailwindcss-language-server"}function q(e){d=!0;for(const t of h.values())t.reject(e);h.clear(),S();for(const t of g.values())t([]);g.clear()}function de(e){L=e;const t=re(e);a=H(t,["--stdio"],{stdio:["pipe","pipe","pipe"]}),a.on("error",n=>{n.code==="ENOENT"&&(console.error(`
|
|
6
6
|
\x1B[38;5;203m\x1B[1mERROR\x1B[0m @tailwindcss/language-server not found.`),console.error(` Install it: \x1B[1mnpm install -D @tailwindcss/language-server\x1B[0m
|
|
7
|
-
`)),
|
|
7
|
+
`)),q(new Error(n.code==="ENOENT"?"@tailwindcss/language-server not found":`language server error: ${n.message}`))}),a.on("close",(n,s)=>{d||q(new Error(s?`language server killed by ${s}`:`language server exited with code ${n}`))}),a.stdout.on("data",n=>{f.push(n),x+=n.length,ne()}),a.stderr.on("data",n=>{O&&process.stderr.write(n)})}function ie(e,t){if(d)return Promise.reject(new Error("language server is not running"));const n=++A;return new Promise((s,l)=>{h.set(n,{resolve:s,reject:l});try{a.stdin.write(I({jsonrpc:"2.0",id:n,method:e,params:t}))}catch{h.delete(n),l(new Error("language server is not running"))}})}function oe(e,t){if(!d)try{a.stdin.write(I({jsonrpc:"2.0",method:e,params:t}))}catch{}}async function ge(){if(!d){await Promise.race([ie("shutdown",{}).catch(()=>{}),new Promise(e=>setTimeout(e,500))]),oe("exit",{}),d=!0;try{a.stdin.end()}catch{}try{a.stdout.destroy()}catch{}try{a.stderr.destroy()}catch{}a.kill()}}function pe(e){return`file://${e}`}function me(e){return e.endsWith(".css")?"css":e.endsWith(".html")||e.endsWith(".vue")||e.endsWith(".svelte")||e.endsWith(".astro")?"html":e.endsWith(".mdx")?"mdx":e.endsWith(".jsx")?"javascriptreact":"typescriptreact"}export{W as brokenProjects,P as diagnosticsReceived,pe as fileUri,me as langId,oe as notify,J as projectInitCount,F as projectReady,ae as resetState,ie as send,M as settledProjects,ge as shutdown,de as startServer,ue as waitForAllProjects,fe as waitForDiagnostic,_ as warnings};
|