@remotex-labs/xjet 1.0.0 → 1.0.1
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 +1 -1
- package/dist/bash.js +1 -1
- package/dist/bash.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/shared.d.ts +0 -1
- package/dist/shared.js +31 -31
- package/dist/shared.js.map +4 -4
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -210,7 +210,6 @@ export declare class MockState<ReturnType = unknown, Args extends Array<unknown>
|
|
|
210
210
|
/**
|
|
211
211
|
* Flag to detect mock functions
|
|
212
212
|
*/
|
|
213
|
-
readonly isMock: boolean;
|
|
214
213
|
readonly xJetMock: boolean;
|
|
215
214
|
/**
|
|
216
215
|
* The `state` property holds the detailed state of the mock invocations.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ti=Object.defineProperty;var a=(e,t)=>ti(e,"name",{value:t,configurable:!0});var ii="xJet.mock()",ee=class e extends Function{static{a(this,"MockState")}static mocks=[];name;
|
|
1
|
+
var ti=Object.defineProperty;var a=(e,t)=>ti(e,"name",{value:t,configurable:!0});var ii="xJet.mock()",ee=class e extends Function{static{a(this,"MockState")}static mocks=[];name;xJetMock=!0;state;restore;queuedImplementations=[];implementation;originalImplementation;constructor(t,i,r){return super(),this.name=r??ii,this.state=this.initState(),this.implementation=t,this.restore=i||(()=>{this.implementation=t}),this.originalImplementation=t||(()=>{}),new Proxy(this,{apply:this.invokeFunction,construct:this.invokeClass})}getMockName(){return this.name}get mock(){return this.state}get original(){return this.originalImplementation}mockClear(){return this.state=this.initState(),this}mockReset(){return this.mockClear(),this.queuedImplementations=[],this}mockRestore(){this.restore(),this.mockReset();let t=e.mocks.indexOf(this);return t!==-1&&e.mocks.splice(t,1),this}getMockImplementation(){return this.implementation}getNextImplementation(){return this.queuedImplementations.length?this.queuedImplementations.shift():this.implementation}mockImplementation(t){return this.implementation=t,this}mockImplementationOnce(t){return this.queuedImplementations.push(t),this}mockReturnValue(t){return this.mockImplementation(()=>t),this}mockResolvedValue(t){return this.mockImplementation(()=>Promise.resolve(t)),this}mockResolvedValueOnce(t){return this.mockImplementationOnce(()=>Promise.resolve(t)),this}mockReturnValueOnce(t){return this.mockImplementationOnce(()=>t),this}mockRejectedValue(t){return this.mockImplementation(()=>Promise.reject(t)),this}mockRejectedValueOnce(t){return this.mockImplementationOnce(()=>Promise.reject(t)),this}[Symbol.for("nodejs.util.inspect.custom")](){return`<Mock Constructor ${this.name}>`}initState(){return{calls:[],results:[],lastCall:void 0,contexts:[],instances:[],invocationCallOrder:[]}}invoke(t,i){let r=t,n=this.getNextImplementation(),s=i;typeof n=="function"&&(n.__boundArgs&&s.unshift(...n.__boundArgs),n.__boundThis&&(r=n.__boundThis)),this.state.calls.push(s),this.state.contexts.push(r),this.state.invocationCallOrder.push(this.state.invocationCallOrder.length+1);let o,c=this.state.results.push({value:void 0,type:"incomplete"})-1;if(n)try{o={type:"return",value:n.call(void 0,...i)}}catch(h){o={value:h,type:"throw"}}else o={type:"return",value:void 0};return this.state.lastCall=i,this.state.results[c]=o,o.value}invokeFunction(t,i,r){return t.state.instances.push(i),t.invoke.call(t,i,r)}invokeClass(t,i,r){let n=t.invoke.call(t,r,i),s=typeof n=="object"&&n!==null&&n.constructor;return t.state.instances.push(s?n:r),typeof n=="object"?n:r}};var ri={dim:[2,22],bold:[1,22],reset:[0,0],hidden:[8,28],inverse:[7,27]},ni={red:[31,39],gray:[90,39],blue:[34,39],cyan:[36,39],black:[30,39],white:[37,39],green:[32,39],yellow:[33,39],magenta:[35,39],redBright:[91,39],blueBright:[94,39],cyanBright:[96,39],whiteBright:[97,39],greenBright:[92,39],blackBright:[90,39],yellowBright:[93,39],magentaBright:[95,39],darkGray:["38;5;238",39],lightGray:["38;5;252",39],lightCyan:["38;5;81",39],lightCoral:["38;5;203",39],oliveGreen:["38;5;149",39],deepOrange:["38;5;166",39],brightPink:["38;5;197",39],lightOrange:["38;5;215",39],burntOrange:["38;5;208",39],lightYellow:["38;5;230",39],canaryYellow:["38;5;227",39],lightGoldenrodYellow:["38;5;221",39]},si={bgRed:[41,49],bgBlue:[44,49],bgCyan:[46,49],bgGray:[100,49],bgBlack:[40,49],bgGreen:[42,49],bgWhite:[47,49],bgYellow:[43,49],bgMagenta:[45,49],bgRedBright:[101,49],bgBlueBright:[104,49],bgCyanBright:[106,49],bgBlackBright:[100,49],bgWhiteBright:[107,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgMagentaBright:[105,49]},ye={...ri,...ni,...si},J="\x1B[",V="m";function ve(e,t){if(globalThis.NO_COLOR)return t;let i=e.length;if(i===0)return t;if(i===1)return`${J}${e[0][0]}${V}${t}${J}${e[0][1]}${V}`;let r=new Array(i),n=new Array(i);for(let s=0;s<i;s++)n[s]=`${J}${e[s][0]}${V}`,r[i-s-1]=`${J}${e[s][1]}${V}`;return n.concat(t,r).join("")}a(ve,"I");function G(e,t,i,r){if(typeof t!="number"||typeof i!="number"||typeof r!="number")throw new Error(`RGB values must be numbers, received: r=${typeof t}, g=${typeof i}, b=${typeof r}`);let n=e==="fg"?38:48,s=e==="fg"?39:49;return[`${n};2;${t};${i};${r}`,s]}a(G,"y");function be(e){let t=e.replace(/^#/,"").toLowerCase();if(!/^([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(t))throw new Error(`Invalid hex color format: "${e}". Expected 3 or 6 hex digits.`);if(t.length===3){let s=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),c=parseInt(t[2]+t[2],16);return[s,o,c]}let i=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return[i,r,n]}a(be,"_");function P(e=[]){let t=a((...r)=>{if(Array.isArray(r[0])&&"raw"in r[0]){let[n,...s]=r,o=n.reduce((c,h,f)=>c+h+(f<s.length?String(s[f]??""):""),"");return ve(e,o)}return ve(e,r.join(" "))},"e"),i={rgb:a((r,n,s)=>P([...e,G("fg",r,n,s)]),"rgb"),bgRgb:a((r,n,s)=>P([...e,G("bg",r,n,s)]),"bgRgb"),hex:a(r=>P([...e,G("fg",...be(r))]),"hex"),bgHex:a(r=>P([...e,G("bg",...be(r))]),"bgHex")};return new Proxy(t,{get(r,n){if(typeof n!="string")throw new Error(`Invalid property: ${String(n)}`);return n in ye?P([...e,ye[n]]):n in i?i[n]:Reflect.get(r,n)}})}a(P,"m");var T=P();var oi=Object.defineProperty,l=a((e,t)=>oi(e,"name",{value:t,configurable:!0}),"o");function ke(e,t){return t!=null&&(t.constructor===e||typeof t=="function")}a(ke,"nt");l(ke,"isA");function X(e,t){return e==null||typeof e!="object"&&typeof e!="function"?!1:t in e||Object.prototype.hasOwnProperty.call(e,t)}a(X,"X");l(X,"hasKey");function S(e){return!!e&&X(e,"expectedLabel")&&ke(Function,e.matches)}a(S,"b");l(S,"isAsymmetric");function re(e,t){let i=S(e),r=S(t);if(!(i&&r)){if(i)return e.matches(t);if(r)return t.matches(e)}}a(re,"ce");l(re,"asymmetricMatch");function Ce(e,t,i=!0){if(Array.isArray(e)&&Array.isArray(t))return i&&e.length!==t.length?!1:e.every((s,o)=>b(s,t[o],i));let r=Object.keys(e),n=Object.keys(t);if(i&&r.length!==n.length)return!1;for(let s of r)if(!X(t,s)||!b(e[s],t[s],i))return!1;return!0}a(Ce,"it");l(Ce,"deepEquals");function b(e,t,i=!0){if(e===t||Object.is(e,t))return!0;if(e===null||t===null)return!1;let r=re(e,t);return r!==void 0?r:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof RegExp&&t instanceof RegExp?e.source===t.source&&e.flags===t.flags:globalThis.URL&&e instanceof globalThis.URL&&t instanceof globalThis.URL?e.href===t.href:typeof e=="object"&&typeof t=="object"?Ce(e,t,i):!1}a(b,"g");l(b,"equals");function Te(e){let t={};for(let i of Object.keys(e)){let r=e[i];r&&(t[i]=r)}return t.name=e.name,t.stack=e.stack,t.message=e.message,t}a(Te,"de");l(Te,"serializesError");function Be(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}a(Be,"me");l(Be,"isPromise");var Le=" ";function Ae(e){return typeof e=="string"?e.includes(`
|
|
2
2
|
`)?null:`"${e}"`:typeof e=="number"?`${Number.isFinite(e)?e:e.toString()}`:typeof e=="boolean"?`${e}`:typeof e=="symbol"?`${e.toString()}`:typeof e=="bigint"?`${e}n`:typeof e=="function"?`[Function: ${e.name||"anonymous"}]`:e===null?"null":e===void 0?"undefined":S(e)?e.expectedLabel??e.constructor.name:e instanceof Date?`[Date: ${e.toISOString()}]`:e instanceof RegExp?e.toString():e instanceof Error?`[${e.name}: ${e.message}]`:e instanceof Promise?"[Promise <pending>]":e instanceof ArrayBuffer?`ArrayBuffer { byteLength: ${e.byteLength} }`:e instanceof DataView?`DataView { byteLength: ${e.byteLength}, byteOffset: ${e.byteOffset} }`:null}a(Ae,"st");l(Ae,"serializePrimitive");function ze(e){return e===null?"null":e===void 0?"undefined":typeof e=="object"?Object.prototype.toString.call(e):JSON.stringify(e)}a(ze,"ot");l(ze,"serializeMapKey");function U(e,t,i,r,n=""){if(e.length===0)return;if(e.length<2){let o=`${n}${i}${e[e.length-1]}`;t.push(r?o:`${o},`);return}t.push(`${n}${i}${e[0]}`);for(let o=1;o<e.length-1;o++)t.push(n+e[o]);let s=`${n}${e[e.length-1]}`;t.push(r?s:`${s},`)}a(U,"Q");l(U,"appendLines");function je(e,t,i,r){if(e.size===0){t.push("Map {}");return}t.push("Map {");let n=Array.from(e.entries());n.forEach(([s,o],c)=>{let h=ze(s),f=[];F(o,f,i,r),U(f,t,`${h} => `,c===n.length-1,i)}),t.push("}")}a(je,"ct");l(je,"serializeMap");function Oe(e,t,i,r){if(e.length===0){t.push("[]");return}t.push("["),e.forEach((n,s)=>{let o=[];F(n,o,i,r),U(o,t,"",s===e.length-1,i)}),t.push("]")}a(Oe,"at");l(Oe,"serializeArray");function Me(e,t,i,r){if(e.size===0){t.push("Set {}");return}t.push("Set {");let n=Array.from(e);n.forEach((s,o)=>{let c=[];F(s,c,i,r),U(c,t,"",o===n.length-1,i)}),t.push("}")}a(Me,"ut");l(Me,"serializeSet");function Pe(e,t,i){let r=Array.from(e);if(r.length===0){t.push("Buffer {}");return}t.push("Buffer {");for(let n=0;n<r.length;n++){let s=r[n],o=n===r.length-1?"":",";t.push(`${i}${s}${o}`)}t.push("}")}a(Pe,"ht");l(Pe,"serializeBuffer");function Ne(e,t,i){let r=Object.prototype.toString.call(e).slice(8,-1),n=Array.from(e);if(n.length===0){t.push(`${r} []`);return}t.push(`${r} [`);for(let s=0;s<n.length;s++){let o=n[s],c=s===n.length-1?"":",";t.push(`${i}${o}${c}`)}t.push("]")}a(Ne,"pt");l(Ne,"serializeTypedArray");function te(e,t,i,r){let n=e.constructor&&e.constructor!==Object?e.constructor.name:"Object",s=Object.entries(e);if(s.length===0){t.push(`${n} {}`);return}t.push(`${n} {`),s.forEach(([o,c],h)=>{let f=[];F(c,f,i,r),U(f,t,`${String(o)}: `,h===s.length-1,i)}),t.push("}")}a(te,"ye");l(te,"serializeObject");function F(e,t,i=Le,r){let n=Ae(e);if(n!==null){t.push(n);return}if(typeof e=="string"){let s=e.split(`
|
|
3
3
|
`);t.push('String "');for(let o of s)t.push(`${i}${o}`);t.push('"');return}if(typeof e=="object"&&e!==null){if(r.has(e)){t.push("[Circular]");return}r.add(e),e instanceof Map?je(e,t,i,r):Array.isArray(e)?Oe(e,t,i,r):e instanceof Set?Me(e,t,i,r):e instanceof Buffer?Pe(e,t,i):ArrayBuffer.isView(e)&&!(e instanceof DataView)?Ne(e,t,i):te(e,t,i,r);return}te(e,t,i,r)}a(F,"B");l(F,"serializeValue");function H(e){if(e&&typeof e=="object"){if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();let t={};for(let[i,r]of Object.entries(e))r!==void 0&&(t[i]=r);return t.name=e?.name??t.name,t.message=e?.message??t.message,t.stack=e?.stack??t.stack,t}return e}a(H,"ae");l(H,"serializeError");function E(e,t=Le){let i=[];return F(e,i,t,new WeakSet),i}a(E,"v");l(E,"serialize");var ai=(e=>(e[e.DELETE=-1]="DELETE",e[e.EQUAL=0]="EQUAL",e[e.INSERT=1]="INSERT",e))(ai||{});function Fe(){let e=0;for(;this.aStart+e<this.aEnd&&this.bStart+e<this.bEnd&&this.isMatch(this.aStart+e,this.bStart+e);)e++;return e}a(Fe,"lt");l(Fe,"countCommonForward");function Ue(){let e=0;for(;this.aEnd-1-e>=this.aStart&&this.bEnd-1-e>=this.bStart&&this.isMatch(this.aEnd-1-e,this.bEnd-1-e);)e++;return e}a(Ue,"ft");l(Ue,"countCommonBackward");function He(e,t,i){let r=this.aEnd-this.aStart,n=this.bEnd-this.bStart,s=[];for(let o=i;o>0;o--){let c=e[o-1],h=r-n,f,g=c[h-1+t],m=c[h+1+t];h===-o||h!==o&&g<m?f=h+1:f=h-1;let w=f+t,v=c[w],$=v-f;for(;r>v&&n>$;)--r,--n,s.push([1,this.aStart+r,this.bStart+n]);r===v?s.push([0,this.aStart+v,this.bStart+$]):s.push([0,this.aStart+v,this.bStart+$]),r=v,n=$}for(let o of s.reverse())this.foundSubsequence(...o)}a(He,"dt");l(He,"backtrackFlat");function De(){let e=this.aEnd-this.aStart,t=this.bEnd-this.bStart,i=e+t,r=0,n=new Array(2*i+1).fill(0),s=[];for(let o=0;o<=i;o++){let c=new Array(2*i+1);s[o]=c;for(let h=-o;h<=o;h+=2){let f=h+i,g;h===-o||h!==o&&n[h-1+i]<n[h+1+i]?g=n[h+1+i]:g=n[h-1+i]+1;let m=g-h;for(;g<e&&m<t&&this.isMatch(this.aStart+g,this.bStart+m);)g++,m++;if(n[f]=g,c[f]=g,g>=e&&m>=t)return r=o,He.call(this,s,i,r)}}}a(De,"mt");l(De,"findMiddleSnake");function qe(){let e=Fe.call(this),t=this.aStart+e>=this.aEnd&&this.bStart+e>=this.bEnd;if(e>0&&(this.foundSubsequence(e,this.aStart,this.bStart),t))return;this.aStart+=e,this.bStart+=e;let i=Ue.call(this);this.aEnd-=i,this.bEnd-=i,(this.aStart<this.aEnd||this.bStart<this.bEnd)&&De.call(this),i>0&&this.foundSubsequence(i,this.aEnd,this.bEnd)}a(qe,"yt");l(qe,"diffSequence");function ne(e,t,i,r){let n={aStart:0,bStart:0,aEnd:e,bEnd:t,isMatch:i,foundSubsequence:r};qe.call(n)}a(ne,"ve");l(ne,"createDiff");function se(e,t){let i=0,r=0,n="",s="",o=[];function c(h,f){let g=o[o.length-1];g&&g[0]===h?g[1]+=f:o.push([h,f])}return a(c,"a"),l(c,"pushDiff"),ne(e.length,t.length,(h,f)=>e[h]===t[f],(h,f,g)=>{i!==f&&(s+=e.slice(i,f)),r!==g&&(n+=t.slice(r,g)),h>0&&(s&&(c(-1,s),s=""),n&&(c(1,n),n=""),c(0,t.slice(g,g+h))),i=f+h,r=g+h}),i!==e.length&&(s+=e.slice(i)),r!==t.length&&(n+=t.slice(r)),s&&o.push([-1,s]),n&&o.push([1,n]),o}a(se,"G");l(se,"diffStringsRaw");function oe(e,t){let i=0,r=0,n=[];for(ne(e.length,t.length,(s,o)=>{let c=e[s].trimEnd().endsWith(","),h=t[o].trimEnd().endsWith(",");return c&&!h?t[o]+=",":!c&&h&&(e[s]+=","),e[s]===t[o]},(s,o,c)=>{for(;i!==o;i+=1)n.push([-1,e[i]]);for(;r!==c;r+=1)n.push([1,t[r]]);for(;s!==0;s-=1,i+=1,r+=1)n.push([0,t[r]])});i!==e.length;i+=1)n.push([-1,e[i]]);for(;r!==t.length;r+=1)n.push([1,t[r]]);return n}a(oe,"Z");l(oe,"diffLinesRaw");function ae(e){let t=[],i=[],r=[],n=l(()=>{t.length&&(r.push([-1,t.join("")]),t=[]),i.length&&(r.push([1,i.join("")]),i=[])},"flushBuffers");for(let s=0;s<e.length;s++){let[o,c]=e[s];if(o===0){if(c.length<=1){let h=s>0?e[s-1][0]:null,f=s+1<e.length?e[s+1][0]:null,g=l(m=>m===-1||m===1,"isEdit");if(g(h)&&g(f)){for(let m of c)t.push(m),i.push(m);continue}}n(),r.push([0,c])}else if(o===-1)for(let h of c)t.push(h);else if(o===1)for(let h of c)i.push(h);else n(),r.push([o,c])}return n(),r}a(ae,"_");l(ae,"cleanupSemantic");var k=T.dim,ci=T.lightOrange,u=T.lightCoral,d=T.oliveGreen,We=T.cyan,B=T.inverse,Vi=T.whiteBright;function I(e){return e===null?"null":e===!0?"true":e===!1?"false":e&&typeof e=="object"?e.constructor?.name??"Object":typeof e}a(I,"k");l(I,"getType");function _e(e,t,i=!0){let r="",n="",s=se(e||" ",t||" ");i&&(s=ae(s));for(let[o,c]of s)o===0?(r+=c,n+=c):o===-1?r+=B(c):o===1&&(n+=B(c));return[r,n]}a(_e,"gt");l(_e,"normalizeStrings");function Je(e,t){let i=[...e],r=[...t],n=Math.max(e.length,t.length);for(let s=0;s<n;s++)[i[s],r[s]]=D(e[s],t[s]);return[i,r]}a(Je,"vt");l(Je,"normalizeArrays");function Ve(e,t){let i={...e},r={...t},n=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of n)s in e&&s in t&&([i[s],r[s]]=D(e[s],t[s]));return[i,r]}a(Ve,"Et");l(Ve,"normalizeObjects");function D(e,t,i=!0){if(e===t)return[e,t];let r=typeof e,n=typeof t;return re(e,t)===!0?(S(e)&&(e=t),S(t)&&(t=e),[e,t]):r==="string"&&n==="string"?_e(e,t,i):!e||!t||r!=="object"||n!=="object"?[e,t]:Array.isArray(e)&&Array.isArray(t)?Je(e,t):Ve(e,t)}a(D,"ee");l(D,"normalizeAsymmetric");function Ge(e,t,i,r=!0){let n=e.split(`
|
|
4
4
|
`),s=t.split(`
|