@clerc/plugin-not-found
Version:
Clerc plugin not found (did you mean)
2 lines • 2.21 kB
JavaScript
import{NoCommandSpecifiedError as e,NoSuchCommandError as t,definePlugin as n}from"@clerc/core";import*as r from"@uttr/tint";var i=((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports))((e=>{e.__esModule=!0,e.distance=e.closest=void 0;var t=new Uint32Array(65536),n=function(e,n){for(var r=e.length,i=n.length,a=1<<r-1,o=-1,s=0,c=r,l=r;l--;)t[e.charCodeAt(l)]|=1<<l;for(l=0;l<i;l++){var u=t[n.charCodeAt(l)],d=u|s;u|=(u&o)+o^o,s|=~(u|o),o&=u,s&a&&c++,o&a&&c--,s=s<<1|1,o=o<<1|~(d|s),s&=d}for(l=r;l--;)t[e.charCodeAt(l)]=0;return c},r=function(e,n){for(var r=n.length,i=e.length,a=[],o=[],s=Math.ceil(r/32),c=Math.ceil(i/32),l=0;l<s;l++)o[l]=-1,a[l]=0;for(var u=0;u<c-1;u++){for(var d=0,f=-1,p=u*32,m=Math.min(32,i)+p,h=p;h<m;h++)t[e.charCodeAt(h)]|=1<<h;for(var l=0;l<r;l++){var g=t[n.charCodeAt(l)],_=o[l/32|0]>>>l&1,v=a[l/32|0]>>>l&1,y=g|d,b=((g|v)&f)+f^f|g|v,x=d|~(b|f),S=f&b;x>>>31^_&&(o[l/32|0]^=1<<l),S>>>31^v&&(a[l/32|0]^=1<<l),x=x<<1|_,S=S<<1|v,f=S|~(y|x),d=x&y}for(var h=p;h<m;h++)t[e.charCodeAt(h)]=0}for(var C=0,w=-1,T=u*32,E=Math.min(32,i-T)+T,h=T;h<E;h++)t[e.charCodeAt(h)]|=1<<h;for(var D=i,l=0;l<r;l++){var g=t[n.charCodeAt(l)],_=o[l/32|0]>>>l&1,v=a[l/32|0]>>>l&1,y=g|C,b=((g|v)&w)+w^w|g|v,x=C|~(b|w),S=w&b;D+=x>>>i-1&1,D-=S>>>i-1&1,x>>>31^_&&(o[l/32|0]^=1<<l),S>>>31^v&&(a[l/32|0]^=1<<l),x=x<<1|_,S=S<<1|v,w=S|~(y|x),C=x&y}for(var h=T;h<E;h++)t[e.charCodeAt(h)]=0;return D},i=function(e,t){if(e.length<t.length){var i=t;t=e,e=i}return t.length===0?e.length:e.length<=32?n(e,t):r(e,t)};e.distance=i,e.closest=function(e,t){for(var n=1/0,r=0,a=0;a<t.length;a++){var o=i(e,t[a]);o<n&&(n=o,r=a)}return t[r]}}))();const a=({distanceThreshold:a=5}={})=>n({setup:n=>n.interceptor({enforce:`post`,handler:async(o,s)=>{let c=[...n._commands.keys()],l=c.length>0;try{await s()}catch(n){if(!(n instanceof t)&&!(n instanceof e))throw n;if(n instanceof e){let t=`No command specified.`;throw l&&(t+=`\nPossible commands: ${c.join(`, `)}.`),new e(t)}let{commandName:o}=n,s=(0,i.closest)(o,c);(0,i.distance)(o,s)>a&&(s=void 0);let u=`Command "${r.strikethrough(o)}" not found.`;throw l&&s?u+=`\nDid you mean "${r.bold(s)}"?`:l||(u+=`
No commands registered.`),new t(o,u)}}})});export{a as notFoundPlugin};