@remotex-labs/xjet 1.1.0 → 1.2.0
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 +39 -25
- package/dist/bash.js +2 -2
- package/dist/bash.js.map +3 -3
- package/dist/index.d.ts +275 -74
- package/dist/index.js +21 -21
- package/dist/index.js.map +3 -3
- package/dist/shared.d.ts +354 -153
- package/dist/shared.js +35 -35
- package/dist/shared.js.map +5 -5
- package/package.json +15 -11
package/dist/index.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
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
|
|
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.originalImplementation=t||(()=>{}),new Proxy(this,{apply:this.invokeFunction,construct:this.invokeClass})}getMockName(){return this.name}get mock(){return Object.freeze({...this.state})}get original(){return this.originalImplementation}mockClear(){return this.state=this.initState(),this}mockReset(){return this.mockClear(),this.queuedImplementations=[],this}mockRestore(){this.mockReset();let t=this.restore?.();typeof t=="function"?this.implementation=t:this.implementation=this.originalImplementation;let i=e.mocks.indexOf(this);return i!==-1&&e.mocks.splice(i,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,"d");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,"g");var C=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 Te(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(Te,"it");l(Te,"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"?Te(e,t,i):!1}a(b,"g");l(b,"equals");function Ce(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(Ce,"de");l(Ce,"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
|
-
`);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
|
|
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=C.dim,ci=C.lightOrange,u=C.lightCoral,d=C.oliveGreen,We=C.cyan,B=C.inverse,Vi=C.whiteBright;function R(e){return e===null?"null":e===!0?"true":e===!1?"false":e&&typeof e=="object"?e.constructor?.name??"Object":typeof e}a(R,"k");l(R,"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(`
|
|
5
5
|
`);i.push(We(`
|
|
6
6
|
@@ -1,${n.length} +1,${s.length} @@
|
|
7
|
-
`));let o=Math.max(n.length,s.length);for(let c=0;c<o;c++){let h=n[c],f=s[c];if(h===f){h&&i.push(
|
|
8
|
-
`)}a(Ge,"bt");l(Ge,"diffStrings");function Y(e,t){let i=[];[e,t]=D(e,t,!0);let r=E(e,""),n=E(t,""),s=oe(r,n);for(let[o,c]of s){let h=c,f="";h.endsWith(",")&&(h=h.slice(0,-1),f=","),o===0?i.push(
|
|
7
|
+
`));let o=Math.max(n.length,s.length);for(let c=0;c<o;c++){let h=n[c],f=s[c];if(h===f){h&&i.push(k(` ${h}`));continue}let g=[],m=[];if(h!==void 0&&f!==void 0){let w=se(h||" ",f||" ");r&&(w=ae(w));for(let[v,$]of w)v===0?(g.push($),m.push($)):v===-1?g.push(B($)):v===1&&m.push(B($))}h===void 0&&m.push(f),!f===void 0&&g.push(h),g.length>0&&i.push(d(`- ${g.join("")}`)),m.length>0&&i.push(u(`+ ${m.join("")}`))}return i.join(`
|
|
8
|
+
`)}a(Ge,"bt");l(Ge,"diffStrings");function Y(e,t){let i=[];[e,t]=D(e,t,!0);let r=E(e,""),n=E(t,""),s=oe(r,n);for(let[o,c]of s){let h=c,f="";h.endsWith(",")&&(h=h.slice(0,-1),f=","),o===0?i.push(k(h)+f):o===1&&i.push(u(h)+f)}return i}a(Y,"te");l(Y,"diffArgs");function Z(e,t,i=!0){let r=R(e),n=R(t),s=[];if(r!==n&&(s.push("Expected type: "+d(r)),s.push("Received type: "+u(n))),r==="string"&&n==="string")return Ge(e,t,s,i);let[o,c]=D(e,t,i),h=E(o),f=E(c);s.push(We(`
|
|
9
9
|
@@ -1,${h.length} +1,${f.length} @@
|
|
10
|
-
`));let g=oe(h,f);for(let[m,w]of g)m===0?s.push(
|
|
11
|
-
`)}a(Z,"D");l(Z,"diffComponent");var ce=class extends Error{static{a(this,"C")}static{l(this,"xJetBaseError")}constructor(e,t="xJetError"){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return Ce(this)}};function Q(e){let{comment:t,assertionChain:i,expectedLabels:r=[],receivedLabeled:n="received"}=e;if(!i.length)throw new Error('Expected non-empty matcher chain (e.g., ["toEqual"]). Received an empty array.');let s=[
|
|
10
|
+
`));let g=oe(h,f);for(let[m,w]of g)m===0?s.push(k(` ${w}`)):m===-1?s.push(d(`- ${w}`)):m===1&&s.push(u(`+ ${w}`));return s.join(`
|
|
11
|
+
`)}a(Z,"D");l(Z,"diffComponent");var ce=class extends Error{static{a(this,"C")}static{l(this,"xJetBaseError")}constructor(e,t="xJetError"){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return Ce(this)}};function Q(e){let{comment:t,assertionChain:i,expectedLabels:r=[],receivedLabeled:n="received"}=e;if(!i.length)throw new Error('Expected non-empty matcher chain (e.g., ["toEqual"]). Received an empty array.');let s=[k("expect("),u(n),k(")"),".",i.join(".")];return r.length>0?(s.push("("),s.push(r.map(o=>d(o)).join(", ")),s.push(")")):s.push("()"),t&&s.push(k(" // "+t)),s.join("")}a(Q,"O");l(Q,"composeStatement");var j=class extends ce{static{a(this,"w")}static{l(this,"xJetTypeError")}constructor(e){let t=[`${Q(e)}
|
|
12
12
|
`,`Matcher error: ${e.message}
|
|
13
13
|
`];e.expected&&(e.expected.type&&t.push(`Expected has type: ${e.expected.type}`),t.push(`Expected has value: ${d(E(e.expected.value).join(`
|
|
14
14
|
`))}`)),e.received&&(e.received.type&&t.push(`Received has type: ${e.received.type}`),t.push(`Received has value: ${u(E(e.received.value).join(`
|
|
15
15
|
`))}`)),super(t.join(`
|
|
16
16
|
`),"xJetTypeError")}},li=class extends ce{static{a(this,"re")}static{l(this,"xJetExpectError")}matcherResult;constructor(e){let t=[`${Q(e)}
|
|
17
17
|
`];e.info&&t.push(...e.info),super(t.join(`
|
|
18
|
-
`),"xJetExpectError"),e.assertion&&(this.matcherResult=e.assertion,this.matcherResult.message=this.message)}};function x(e,t,i,r=[]){let n=R(e);if(!t.includes(n)&&!t.includes(typeof e))throw new j({expectedLabels:r,assertionChain:this.assertionChain,message:`${(i==="Received"?u:d)(i)} value must be a ${t.join(" or ")}`,[i==="Expected"?"expected":"received"]:{value:e,type:n}})}a(x,"E");l(x,"ensureType");function le(e,t,i=[]){if(e==null)throw new j({expectedLabels:i,assertionChain:this.assertionChain,message:`${(t==="Received"?u:d)(t)} value must not be null nor undefined`,[t==="Expected"?"expected":"received"]:{value:e}})}a(le,"he");l(le,"ensureNotNullish");function p(e){return E(e,"").join(" ")}a(p,"l");l(p,"serializeOneLine");function y(e){let{pass:t}=e;if(!(t&&this.notModifier||!t&&!this.notModifier))return;let i=[],r={pass:t,name:this.macherName,received:this.received,expected:e.expected};throw this.notModifier?e.handleNot?.call(this,i):e.handleInfo?.call(this,i),new li({info:i,assertion:r,...e,assertionChain:this.assertionChain})}a(y,"y");l(y,"handleFailure");function T(e){y.call(this,{...e,handleNot(t){t.push(`Expected: not ${d(p(this.received))}`)},handleInfo(t){e.note&&t.push(
|
|
18
|
+
`),"xJetExpectError"),e.assertion&&(this.matcherResult=e.assertion,this.matcherResult.message=this.message)}};function x(e,t,i,r=[]){let n=R(e);if(!t.includes(n)&&!t.includes(typeof e))throw new j({expectedLabels:r,assertionChain:this.assertionChain,message:`${(i==="Received"?u:d)(i)} value must be a ${t.join(" or ")}`,[i==="Expected"?"expected":"received"]:{value:e,type:n}})}a(x,"E");l(x,"ensureType");function le(e,t,i=[]){if(e==null)throw new j({expectedLabels:i,assertionChain:this.assertionChain,message:`${(t==="Received"?u:d)(t)} value must not be null nor undefined`,[t==="Expected"?"expected":"received"]:{value:e}})}a(le,"he");l(le,"ensureNotNullish");function p(e){return E(e,"").join(" ")}a(p,"l");l(p,"serializeOneLine");function y(e){let{pass:t}=e;if(!(t&&this.notModifier||!t&&!this.notModifier))return;let i=[],r={pass:t,name:this.macherName,received:this.received,expected:e.expected};throw this.notModifier?e.handleNot?.call(this,i):e.handleInfo?.call(this,i),new li({info:i,assertion:r,...e,assertionChain:this.assertionChain})}a(y,"y");l(y,"handleFailure");function T(e){y.call(this,{...e,handleNot(t){t.push(`Expected: not ${d(p(this.received))}`)},handleInfo(t){e.note&&t.push(k(e.note),""),t.push(Z(e.expected,this.received,!0))}})}a(T,"M");l(T,"handleDiffFailure");function Ke(e,t){let i=" ".repeat(t.length);y.call(this,{...e,handleNot(r){r.push(`Expected: not ${t} ${d(p(e.expected))}`),r.push(`Received: ${i} ${u(p(this.received))}`)},handleInfo(r){r.push(`Expected: ${t} ${d(p(e.expected))}`),r.push(`Received: ${i} ${u(p(this.received))}`)}})}a(Ke,"be");l(Ke,"handleComparisonFailure");function ie(e){let t=e,i=t!=null&&typeof t.message=="string",r=i&&typeof t.name=="string"&&typeof t.stack=="string";return{isError:r,value:e,message:String(i?t.message:e),hasMessage:r?!0:i,serializedError:H(e)}}a(ie,"xe");l(ie,"getThrown");function q(e,t,i,r=!1){return[l(n=>{n.push(`Expected ${e}: not ${d(t)}`),i?.hasMessage?n.push(`Received message: ${u(p(r?i.message:B(i.message)))}
|
|
19
19
|
`):n.push(`Received value: ${u(p(i?.value))}`)},"handleNot"),l(n=>{n.push(`Expected ${e}: ${d(t)}`),i?.hasMessage?(r&&n.push(`Received name: ${u(p(i.value?.name))}`),n.push(`Received message: ${u(p(i.message))}
|
|
20
20
|
`)):n.push(`Received value: ${u(p(i?.value))}`)},"handleInfo")]}a(q,"ne");l(q,"buildInfo");function Ye(e,t){let i=t!=null&&t.value instanceof e,[r,n]=q("constructor",e.name,t);return[i,r,n]}a(Ye,"xt");l(Ye,"toThrowExpectedClass");function Xe(e,t){let i=t!=null&&t.message.includes(e),[r,n]=q("substring",`"${e}"`,t);return[i,r,n]}a(Xe,"St");l(Xe,"toThrowExpectedString");function Ze(e,t){let i=t!=null&&e.test(t.message),[r,n]=q("pattern",p(e),t);return[i,r,n]}a(Ze,"Tt");l(Ze,"toThrowExpectedRegExp");function Qe(e,t){let i=t!=null&&e.matches(t.value),[r,n]=q("asymmetric",p(e),t,!0);return[i,r,n]}a(Qe,"wt");l(Qe,"toThrowExpectedAsymmetric");function et(e,t){return[t!=null&&b(H(e),t.serializedError),l(i=>{i.push(`Expected: not ${d(p(t.serializedError))}`)},"handleNot"),l(i=>{i.push(Z(e,t.serializedError,!0))},"handleInfo")]}a(et,"$t");l(et,"toThrowExpectedObject");function tt(e){let t=null,i=e?["expected"]:[];if(this.rejectsModifier)t=ie(this.received);else if(typeof this.received=="function")try{this.received()}catch(o){t=ie(o)}else x.call(this,this.received,["function"],"Received",i);let r=!1,n,s;e?typeof e=="function"?[r,n,s]=Ye.call(this,e,t):typeof e=="string"?[r,n,s]=Xe.call(this,e,t):e instanceof RegExp?[r,n,s]=Ze.call(this,e,t):S(e)?[r,n,s]=Qe.call(this,e,t):t!==null&&typeof e=="object"?[r,n,s]=et.call(this,e,t):x.call(this,e,["string","function","RegExp","object"],"Expected",i):(r=t!=null,n=l(o=>{t?.hasMessage?(o.push(`Error name: ${u(t.value?.name)}`),o.push(`Error message: ${u(p(t.message))}
|
|
21
21
|
`)):o.push(`Error value: ${u(p(t?.value))}`)},"handleNot")),y.call(Object.assign({},this,{received:t?.serializedError}),{pass:r,expected:e,expectedLabels:i,handleNot(o){n?.call(this,o)},handleInfo(o){t?s?.call(this,o):o.push(`${u("Received")} function did not throw`)}})}a(tt,"Se");l(tt,"toThrow");function it(e){let t=["length"];if(x.call(this,e,["number","bigint"],"Expected",t),!Object.hasOwn(this.received,"length")||!Number.isSafeInteger(this.received.length))throw new j({expectedLabels:t,message:`${u("received")} value must have a length property whose value must be a number`,received:{value:this.received,type:R(this.received)},assertionChain:this.assertionChain});let i=this.received,r=i.length==e;y.call(this,{pass:r,expectedLabels:t,handleNot(n){n.push(`Expected length: not ${d(p(e))}`),n.push(`Received string: ${u(p(i))}`)},handleInfo(n){n.push(`Expected length: ${d(p(e))}`),n.push(`Received length: ${u(p(i.length))}`),n.push(`Received string: ${u(p(i))}`)}})}a(it,"Te");l(it,"toHaveLength");function rt(e){let t=["expected"];x.call(this,this.received,["string"],"Received",t),x.call(this,e,["string","RegExp"],"Expected",t);let i=this.received,r=typeof e=="string"?i.includes(e):new RegExp(e).test(i);y.call(this,{pass:r,expectedLabels:t,handleNot(n){n.push(`Expected: not ${d(p(i))}`)},handleInfo(n){e instanceof RegExp?(n.push(`Expected pattern: ${d(p(e))}`),n.push(`Received string: ${u(p(i))}`)):n.push(Z(e,i,!0))}})}a(rt,"we");l(rt,"toMatch");function W(e,t,i=[]){if(x.call(this,e,["number","bigint"],t,i),e<0)throw new j({expectedLabels:i,assertionChain:this.assertionChain,message:`${(t==="Received"?u:d)(t)} value must be positive number`,[t==="Received"?"received":"expected"]:{value:e,type:R(e)}})}a(W,"z");l(W,"ensurePositiveNumber");function _(e,t){let i=this.received,r=["Expected"];x.call(this,e,["number","bigint"],"Expected",r),x.call(this,i,["number","bigint"],"Received",r);let n;switch(t){case">":n=i>e;break;case">=":n=i>=e;break;case"<":n=i<e;break;case"<=":n=i<=e;break;default:n=!1}Ke.call(this,{pass:n,expectedLabels:r,expected:e},t)}a(_,"F");l(_,"handleNumericComparison");function nt(e,t=2){let i=["expected","precision"];x.call(this,e,["number"],"Expected",i),x.call(this,this.received,["number"],"Received",i);let r=this.received,n=Math.abs(e-r),s=Math.pow(10,-t)/2,o=t<20?s.toFixed(t+1):s.toString(),c=this.notModifier?" ":" ",h=this.notModifier?"not < ":"< ",f=n<s,g=[`Expected precision: ${c}${d(t.toString())}`,`Expected difference: ${h}${d(o)}`,`Received difference: ${c}${u(n.toString())}`];y.call(this,{pass:f,expectedLabels:i,handleNot(m){m.push(`Expected: not ${d(p(e))}`),m.push(`Received: ${u(p(r))}
|
|
22
22
|
`),m.push(...g)},handleInfo(m){m.push(`Expected: ${d(p(e))}`),m.push(`Received: ${u(p(r))}
|
|
23
|
-
`),m.push(...g)}})}a(nt,"$e");l(nt,"toBeCloseTo");function st(e){_.call(this,e,">")}a(st,"ke");l(st,"toBeGreaterThan");function ot(e){_.call(this,e,">=")}a(ot,"Ae");l(ot,"toBeGreaterThanOrEqual");function at(e){_.call(this,e,"<")}a(at,"Re");l(at,"toBeLessThan");function ct(e){_.call(this,e,"<=")}a(ct,"Me");l(ct,"toBeLessThanOrEqual");function
|
|
23
|
+
`),m.push(...g)}})}a(nt,"$e");l(nt,"toBeCloseTo");function st(e){_.call(this,e,">")}a(st,"ke");l(st,"toBeGreaterThan");function ot(e){_.call(this,e,">=")}a(ot,"Ae");l(ot,"toBeGreaterThanOrEqual");function at(e){_.call(this,e,"<")}a(at,"Re");l(at,"toBeLessThan");function ct(e){_.call(this,e,"<=")}a(ct,"Me");l(ct,"toBeLessThanOrEqual");function I(e=[]){if(!this.received?.xJetMock||!this.received?.mock)throw new j({expectedLabels:e,assertionChain:this.assertionChain,message:`${u("Received")} value must be a mock or spy function`,received:{value:this.received}})}a(I,"I");l(I,"ensureMock");function A(e){return E(e,"").slice(1,-1).map(t=>d(t.replace(",",""))).join(", ")}a(A,"L");l(A,"serializeCallArgs");function he(e,t,i,r="->",n=!1,s=3){if(!t?.length)return"";let o=0,c=-1,h=t.length;i&&i>=1&&i<=h&&(c=i-1,o=Math.max(0,Math.min(c-1,h-(s-1))));let f=Math.min(o+s,h),g=String(f).length,m=" ".repeat(r.length+1),w=new Array(f-o);for(let v=o;v<f;v++){let $=t[v],ge=String(v+1).padStart(g," "),me=v===c?`${r} `:m;if(n&&Array.isArray($)&&$.length<1){w[v-o]=`${me}${ge}: called with 0 arguments`;continue}let ei=n?Y(e,$).slice(1,-1):Y(e,$);w[v-o]=`${me}${ge}: ${ei.join(" ")}`}return w.join(`
|
|
24
24
|
`)}a(he,"Ie");l(he,"serializeList");function lt(e,t,i=[],r=3){if(!t?.length||!i.length)return"";let n=t.length,s=String(n).length+3,o=[];for(let c=0;c<i.length;c++){let h=i[c]-1;if(h<0||h>=n)continue;let f=Y(e,t[h]).slice(1,-1);if(o.push(`${String(h+1).padStart(s," ")}: ${f.join(" ")}`),o.length>=r)break}return o.join(`
|
|
25
|
-
`)}a(lt,"Ce");l(lt,"serializeHighlightedCalls");function z(e,t,i,r){return he(e,t,i,r,!0)}a(z,"N");l(z,"serializeCallList");function N(e,t,i,r){return he(e,t,i,r,!1)}a(N,"P");l(N,"serializeReturnList");function ht(){
|
|
25
|
+
`)}a(lt,"Ce");l(lt,"serializeHighlightedCalls");function z(e,t,i,r){return he(e,t,i,r,!0)}a(z,"N");l(z,"serializeCallList");function N(e,t,i,r){return he(e,t,i,r,!1)}a(N,"P");l(N,"serializeReturnList");function ht(){I.call(this);let e=this.received.mock.calls,t=this.received.mock.calls.length;y.call(this,{pass:t>0,receivedLabeled:this.received.name,handleNot(i){i.push(`Expected calls: ${d("0")}`),i.push(`Received calls: ${u(t.toString())}
|
|
26
26
|
`),i.push(z([],e))},handleInfo(i){i.push(`Expected calls: >= ${d("1")}`),i.push(`Received calls: ${u(t.toString())}
|
|
27
|
-
`)}})}a(ht,"je");l(ht,"toHaveBeenCalled");function ut(e){let t=["expected"];
|
|
28
|
-
`)}})}a(ut,"Le");l(ut,"toHaveBeenCalledTimes");function pt(...e){let t=["...args"];
|
|
27
|
+
`)}})}a(ht,"je");l(ht,"toHaveBeenCalled");function ut(e){let t=["expected"];I.call(this,t),W.call(this,e,"expected",t);let i=this.received.mock.calls.length;y.call(this,{expected:e,pass:i==e,expectedLabels:t,receivedLabeled:this.received.name,handleNot(r){r.push(`Expected calls: != ${d(e.toString())}`)},handleInfo(r){r.push(`Expected calls: ${d(e.toString())}`),r.push(`Received calls: ${u(i.toString())}
|
|
28
|
+
`)}})}a(ut,"Le");l(ut,"toHaveBeenCalledTimes");function pt(...e){let t=["...args"];I.call(this,t);let i=this.received.mock.calls,r=this.received.mock.calls.length,n=[];i.forEach((o,c)=>{o.length===e.length&&b(e,o)&&n.push(c+1)});let s=n.length>0;y.call(this,{pass:s,expectedLabels:t,expected:e,receivedLabeled:this.received.name,handleNot(o){o.push(`Expected: not ${A(e)}`),o.push(`Received:
|
|
29
29
|
|
|
30
30
|
${lt(e,i,n)}
|
|
31
31
|
`),o.push(`Calls: ${u(r.toString())}`)},handleInfo(o){o.push(`Expected: ${A(e)}`),o.push(`Received:
|
|
32
32
|
|
|
33
33
|
${z(e,i)}
|
|
34
|
-
`),o.push(`Calls: ${u(r.toString())}`)}})}a(pt,"Ne");l(pt,"toHaveBeenCalledWith");function ft(...e){let t=["...args"];
|
|
34
|
+
`),o.push(`Calls: ${u(r.toString())}`)}})}a(pt,"Ne");l(pt,"toHaveBeenCalledWith");function ft(...e){let t=["...args"];I.call(this,t);let i=this.received.mock.calls,r=i.length,n=this.received.mock.calls.at(-1),s=n!==void 0&&b(e,n);y.call(this,{pass:s,expectedLabels:t,expected:e,receivedLabeled:this.received.name,handleNot(o){o.push(`Expected: not ${A(e)}`),o.push(`Received:
|
|
35
35
|
|
|
36
36
|
${z(e,i,i.length)}
|
|
37
37
|
`),o.push(`Calls: ${u(r.toString())}`)},handleInfo(o){o.push(`Expected: ${A(e)}`),o.push(`Received:
|
|
38
38
|
|
|
39
39
|
${z(e,i,i.length)}
|
|
40
|
-
`),o.push(`Calls: ${u(r.toString())}`)}})}a(ft,"De");l(ft,"toHaveBeenLastCalledWith");function dt(e,...t){let i=["nthCall","...args"];
|
|
40
|
+
`),o.push(`Calls: ${u(r.toString())}`)}})}a(ft,"De");l(ft,"toHaveBeenLastCalledWith");function dt(e,...t){let i=["nthCall","...args"];I.call(this,i),W.call(this,e,"nthCall",i);let r=this.received.mock.calls,n=r.length,s=this.received.mock.calls.at(e-1),o=s!==void 0&&b(t,s);y.call(this,{pass:o,expectedLabels:i,expected:t,receivedLabeled:this.received.name,handleNot(c){c.push(`nthCall: ${e}`),c.push(`Expected: not ${A(t)}`),c.push(`Received:
|
|
41
41
|
|
|
42
42
|
${z(t,r,e)}
|
|
43
43
|
`),c.push(`Calls: ${u(n.toString())}`)},handleInfo(c){c.push(`nthCall: ${e}`),c.push(`Expected: ${A(t)}`),c.push(`Received:
|
|
44
44
|
|
|
45
45
|
${z(t,r,e)}
|
|
46
|
-
`),c.push(`Calls: ${u(n.toString())}`)}})}a(dt,"Oe");l(dt,"toHaveBeenNthCalledWith");function gt(){
|
|
46
|
+
`),c.push(`Calls: ${u(n.toString())}`)}})}a(dt,"Oe");l(dt,"toHaveBeenNthCalledWith");function gt(){I.call(this);let e=[],t=this.received.mock.calls.length,i=this.received.mock.results.reduce((r,n)=>n.type==="return"?(e.push(n.value),r+1):r,0);y.call(this,{pass:i>0,receivedLabeled:this.received.name,handleNot(r){r.push(`Expected returns: ${d("0")}`),r.push(`Received returns: ${u(i.toString())}
|
|
47
47
|
`),r.push(N(void 0,e)),r.push(`
|
|
48
|
-
Calls: ${u(t.toString())}`)},handleInfo(r){r.push(`Expected returns: >= ${d("1")}`),r.push(`Received returns: ${u(i.toString())}`),r.push(`Calls: ${u(t.toString())}`)}})}a(gt,"Pe");l(gt,"toHaveReturned");function mt(e){let t=["expected"];
|
|
48
|
+
Calls: ${u(t.toString())}`)},handleInfo(r){r.push(`Expected returns: >= ${d("1")}`),r.push(`Received returns: ${u(i.toString())}`),r.push(`Calls: ${u(t.toString())}`)}})}a(gt,"Pe");l(gt,"toHaveReturned");function mt(e){let t=["expected"];I.call(this,t),W.call(this,e,"expected",t);let i=this.received.mock.calls.length,r=this.received.mock.results.reduce((n,s)=>s.type==="return"?n+1:n,0);y.call(this,{expectedLabels:t,pass:r==e,expected:e,receivedLabeled:this.received.name,handleNot(n){n.push(`Expected returns: != ${d(e.toString())}`),n.push(`Calls: ${u(i.toString())}`)},handleInfo(n){n.push(`Expected returns: ${d(e.toString())}`),n.push(`Received returns: ${u(r.toString())}`),n.push(`Calls: ${u(i.toString())}`)}})}a(mt,"Be");l(mt,"toHaveReturnedTimes");function yt(e){let t=["expected"];I.call(this,t);let i=[],r=this.received.mock.calls.length,n=this.received.mock.results.reduce((c,h)=>h.type==="return"?(i.push(h.value),c+1):c,0),s=i.at(-1),o=i.length>0&&b(e,s);y.call(this,{pass:o,expectedLabels:t,expected:e,receivedLabeled:this.received.name,handleNot(c){c.push(`Expected returns: not ${d(p(e))}`),c.push(`Received returns:
|
|
49
49
|
`),c.push(N(e,i,n)),c.push(`
|
|
50
50
|
Calls: ${u(r.toString())}`)},handleInfo(c){c.push(`Expected returns: ${d(p(e))}`),i.length>0&&(c.push(`Received returns:
|
|
51
51
|
`),c.push(N(e,i,n))),c.push(`
|
|
52
|
-
Returns: ${u(n.toString())}`),c.push(`Calls: ${u(r.toString())}`)}})}a(yt,"ze");l(yt,"toHaveLastReturnedWith");function vt(e,t){let i=["nthCall","expected"];
|
|
52
|
+
Returns: ${u(n.toString())}`),c.push(`Calls: ${u(r.toString())}`)}})}a(yt,"ze");l(yt,"toHaveLastReturnedWith");function vt(e,t){let i=["nthCall","expected"];I.call(this,i),W.call(this,e,"nthCall",i);let r=[],n=this.received.mock.calls.length,s=this.received.mock.results.reduce((h,f)=>f.type==="return"?(r.push(f.value),h+1):h,0),o=r.at(e-1),c=e<=r.length&&b(t,o);y.call(this,{pass:c,expectedLabels:i,expected:t,receivedLabeled:this.received.name,handleNot(h){h.push(`nthCall: ${e}`),h.push(`Expected returns: not ${d(p(t))}`),h.push(`Received returns:
|
|
53
53
|
`),h.push(N(t,r,e)),h.push(`
|
|
54
54
|
Returns: ${u(s.toString())}`),h.push(`Calls: ${u(n.toString())}`)},handleInfo(h){h.push(`nthCall: ${e}`),h.push(`Expected returns: ${d(p(t))}`),h.push(`Received returns:
|
|
55
55
|
`),h.push(N(t,r,e)),h.push(`
|
|
56
|
-
Returns: ${u(s.toString())}`),h.push(`Calls: ${u(n.toString())}`)}})}a(vt,"Fe");l(vt,"toHaveNthReturnedWith");function bt(e){let t=S(e)?e.matches(this.received):Object.is(this.received,e),i=!t&&b(this.received,e)?'If it should pass with deep equality, replace "toBe" with "toEqual"':void 0;T.call(this,{note:i,pass:t,expected:e,comment:"Object.is equality",expectedLabels:["expected"]})}a(bt,"He");l(bt,"toBe");function xt(e){let t=b(this.received,e);T.call(this,{pass:t,expected:e,comment:"deep equality",expectedLabels:["expected"]})}a(xt,"qe");l(xt,"toEqual");function Et(){let e=this.received===null;T.call(this,{pass:e,expected:null})}a(Et,"Ve");l(Et,"toBeNull");function $t(){let e=this.received===void 0;T.call(this,{pass:e,expected:void 0})}a($t,"We");l($t,"toBeUndefined");function St(){let e=Number.isNaN(this.received);T.call(this,{pass:e,expected:NaN})}a(St,"Je");l(St,"toBeNaN");function wt(){let e=!!this.received;T.call(this,{pass:e,expected:!0})}a(wt,"Ke");l(wt,"toBeTruthy");function Rt(){let e=!this.received;T.call(this,{pass:e,expected:!1})}a(Rt,"Ue");l(Rt,"toBeFalsy");function
|
|
57
|
-
`),t?c.push(`Expected value: ${d(p(t))}`):c.push(`Received value: ${u(p(n))}`)},handleInfo(c){c.push(`Expected path: ${d(p(o))}`),Object.is(s.join(""),o.join(""))||c.push(`Received path: ${u(p(s))}`),c.push(""),t&&c.push(`Expected value: ${d(p(t))}`),c.push(`Received value: ${u(p(n))}`)}})}a(
|
|
56
|
+
Returns: ${u(s.toString())}`),h.push(`Calls: ${u(n.toString())}`)}})}a(vt,"Fe");l(vt,"toHaveNthReturnedWith");function bt(e){let t=S(e)?e.matches(this.received):Object.is(this.received,e),i=!t&&b(this.received,e)?'If it should pass with deep equality, replace "toBe" with "toEqual"':void 0;T.call(this,{note:i,pass:t,expected:e,comment:"Object.is equality",expectedLabels:["expected"]})}a(bt,"He");l(bt,"toBe");function xt(e){let t=b(this.received,e);T.call(this,{pass:t,expected:e,comment:"deep equality",expectedLabels:["expected"]})}a(xt,"qe");l(xt,"toEqual");function Et(){let e=this.received===null;T.call(this,{pass:e,expected:null})}a(Et,"Ve");l(Et,"toBeNull");function $t(){let e=this.received===void 0;T.call(this,{pass:e,expected:void 0})}a($t,"We");l($t,"toBeUndefined");function St(){let e=Number.isNaN(this.received);T.call(this,{pass:e,expected:NaN})}a(St,"Je");l(St,"toBeNaN");function wt(){let e=!!this.received;T.call(this,{pass:e,expected:!0})}a(wt,"Ke");l(wt,"toBeTruthy");function Rt(){let e=!this.received;T.call(this,{pass:e,expected:!1})}a(Rt,"Ue");l(Rt,"toBeFalsy");function It(){let e=this.received!==void 0;y.call(this,{pass:e,expected:void 0,handleNot(t){t.push(`Expected: ${d(p(void 0))}`)},handleInfo(t){t.push(`Received: ${u(p(this.received))}`)}})}a(It,"Xe");l(It,"toBeDefined");function kt(e,t){let i=["path","value"];le.call(this,this.received,"Received",i),x.call(this,e,["string","Array"],"Expected path",i);let r=!0,n=this.received,s=[],o=typeof e=="string"?e.split(".").filter(Boolean):e;for(let c of o){if(!n||!Object.hasOwn(n,c)){r=!1;break}s.push(c),n=n[c]}r&&t!==void 0&&(r=b(n,t)),y.call(this,{pass:r,expectedLabels:i,handleNot(c){c.push(`Expected: not ${d(p(o))}
|
|
57
|
+
`),t?c.push(`Expected value: ${d(p(t))}`):c.push(`Received value: ${u(p(n))}`)},handleInfo(c){c.push(`Expected path: ${d(p(o))}`),Object.is(s.join(""),o.join(""))||c.push(`Received path: ${u(p(s))}`),c.push(""),t&&c.push(`Expected value: ${d(p(t))}`),c.push(`Received value: ${u(p(n))}`)}})}a(kt,"Qe");l(kt,"toHaveProperty");function Tt(e){let t=["expected"];x.call(this,e,["function"],"Received",t);let i=this.received,r=i instanceof e;y.call(this,{pass:r,expectedLabels:t,handleNot(n){n.push(`Expected constructor: not ${d(e.name)}
|
|
58
58
|
`)},handleInfo(n){n.push(`Expected constructor: ${d(e.name)}`),i!==null&&typeof i=="object"&&Object.getPrototypeOf(i)!==null&&"constructor"in i?n.push(`Received constructor: ${u(i.constructor.name)}`):(n.push(`
|
|
59
59
|
Received value has no prototype`),n.push(`Received value: ${u(p(i))}`))}})}a(Tt,"Ye");l(Tt,"toBeInstanceOf");function Ct(e){let t=["expected"];x.call(this,this.received,["string","Array"],"Received",t);let i=this.received,r=R(i);if(typeof i=="string"&&typeof e!="string")throw new j({expectedLabels:t,message:`${d("expected")} value must be a string if ${u("received")} value is a string`,expected:{value:e,type:R(e)},received:{value:i,type:r},assertionChain:this.assertionChain});let n=i.indexOf(e)!==-1;y.call(this,{pass:n,expectedLabels:t,comment:"indexOf",handleNot(s){r==="string"?(s.push(`Expected substring: not ${d(p(e))}`),s.push(`Received string: ${u(p(i)).replace(String(e),B(String(e)))}`)):(s.push(`Expected value: not ${d(p(e))}`),s.push(`Received array: ${u(p(i)).replace(p(e),B(p(e)))}`))},handleInfo(s){r==="string"?(s.push(`Expected substring: ${d(E(e,"").join(`
|
|
60
60
|
`))}`),s.push(`Received string: ${u(E(r,"").join(`
|
|
61
|
-
`))}`)):([...i].findIndex(o=>b(o,e))!==-1&&s.push(
|
|
61
|
+
`))}`)):([...i].findIndex(o=>b(o,e))!==-1&&s.push(k(`Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher.
|
|
62
62
|
You probably need to use \`${ci("toContainEqual")}\` instead.
|
|
63
|
-
`)),s.push(`Expected value: ${d(p(e))}`),s.push(`Received array: ${u(p(r))}`))}})}a(Ct,"Ge");l(Ct,"toContain");function Bt(e){let t=["expected"];x.call(this,this.received,["string","Array"],"Received",t);let i=this.received,r=R(i),n=[...i].findIndex(s=>b(s,e))!==-1;y.call(this,{pass:n,expectedLabels:t,comment:"deep equality",handleNot(s){s.push(`Expected value: not ${d(p(e))}`),s.push(`Received array: ${u(p(i)).replace(p(e),B(p(e)))}`)},handleInfo(s){r==="string"&&typeof e=="string"&&i.indexOf(e)!==-1&&s.push(
|
|
63
|
+
`)),s.push(`Expected value: ${d(p(e))}`),s.push(`Received array: ${u(p(r))}`))}})}a(Ct,"Ge");l(Ct,"toContain");function Bt(e){let t=["expected"];x.call(this,this.received,["string","Array"],"Received",t);let i=this.received,r=R(i),n=[...i].findIndex(s=>b(s,e))!==-1;y.call(this,{pass:n,expectedLabels:t,comment:"deep equality",handleNot(s){s.push(`Expected value: not ${d(p(e))}`),s.push(`Received array: ${u(p(i)).replace(p(e),B(p(e)))}`)},handleInfo(s){r==="string"&&typeof e=="string"&&i.indexOf(e)!==-1&&s.push(k("Looks like you wanted to test for string equality with the stricter `toContainEqual` matcher. You probably need to use `toContain` instead.\n")),s.push(`Expected: ${d(p(e))}`),s.push(`Received: ${u(p(i))}`)}})}a(Bt,"Ze");l(Bt,"toContainEqual");function Lt(e){let t=["expected"];le.call(this,this.received,"Received",t),x.call(this,this.received,["object"],"Received",t),x.call(this,e,["object"],"Expected",t);let i=this.received,r=b(e,i,!1);T.call(this,{pass:r,expected:e,expectedLabels:t})}a(Lt,"_e");l(Lt,"toMatchObject");var xe={toThrow:tt,toMatch:rt,toHaveLength:it,toContain:Ct,toMatchObject:Lt,toHaveProperty:kt,toBeInstanceOf:Tt,toContainEqual:Bt,toBe:bt,toEqual:xt,toBeNaN:St,toBeNull:Et,toBeFalsy:Rt,toBeTruthy:wt,toBeDefined:It,toBeUndefined:$t,toBeCloseTo:nt,toBeLessThan:at,toBeGreaterThan:st,toBeLessThanOrEqual:ct,toBeGreaterThanOrEqual:ot,toHaveReturned:gt,toHaveBeenCalled:ht,toHaveReturnedTimes:mt,toHaveBeenCalledWith:pt,toHaveBeenCalledTimes:ut,toHaveNthReturnedWith:vt,toHaveLastReturnedWith:yt,toHaveBeenNthCalledWith:dt,toHaveBeenLastCalledWith:ft},L=class{static{a(this,"T")}constructor(e,t=!1){this.name=e,this.isInverse=t}static{l(this,"AbstractPattern")}applyInverse(e){return this.isInverse?!e:e}},hi=class K extends L{static{a(this,"e")}constructor(t){super(`Any<${t.name}>`),this.expected=t}static{l(this,"AnyPattern")}static TYPE_CHECKS={String:l(t=>typeof t=="string"||t instanceof String,"String"),Number:l(t=>typeof t=="number"||t instanceof Number,"Number"),Function:l(t=>typeof t=="function"||t instanceof Function,"Function"),Boolean:l(t=>typeof t=="boolean"||t instanceof Boolean,"Boolean"),BigInt:l(t=>typeof t=="bigint"||t instanceof BigInt,"BigInt"),Symbol:l(t=>typeof t=="symbol"||t instanceof Symbol,"Symbol"),Object:l(t=>typeof t=="object","Object"),Array:Array.isArray};static create(t){if(t===void 0)throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");return new K(t)}get expectedLabel(){return`Any<${this.expected.name}>`}matches(t){return this.expected.name in K.TYPE_CHECKS?K.TYPE_CHECKS[this.expected.name](t):t instanceof this.expected}},Ee=class At extends L{static{a(this,"e")}constructor(t,i){super("ArrayOf",t),this.expected=i}static{l(this,"ArrayOfPattern")}static create(t,i){if(i===void 0)throw new TypeError("arrayOf() expects a matcher or value.");return new At(t,i)}get expectedLabel(){return`${this.isInverse?"Not ":""}ArrayOf( ${this.describe(this.expected)} )`}matches(t){if(!Array.isArray(t))return this.applyInverse(!1);let i=t.every(r=>this.matchElement(r,this.expected));return this.applyInverse(i)}matchElement(t,i){return S(i)?i.matches(t):b(t,i)}describe(t){return S(t)?t.expectedLabel:typeof t=="string"?`"${t}"`:E(t,"").join(" ")}},$e=class zt extends L{static{a(this,"e")}constructor(t,i,r=2){super("CloseTo",t),this.expected=i,this.precision=r}static{l(this,"CloseToPattern")}static create(t,i,r){return new zt(t,i,r)}get expectedLabel(){let t=this.isInverse?"Not ":"",i=this.precision!==1?"s":"";return`${t}CloseTo(${this.expected}, ${this.precision} digit${i})`}matches(t){let i=this.expected;return typeof t!="number"||typeof i!="number"?this.applyInverse(!1):this.applyInverse(Math.abs(t-i)<Math.pow(10,-this.precision)/2)}},ui=class jt extends L{static{a(this,"e")}static{l(this,"AnythingPattern")}constructor(){super("Anything")}static create(){return new jt}get expectedLabel(){return"Anything"}matches(t){return t!=null}},Se=class Ot extends L{static{a(this,"e")}constructor(t,i){super("StringMatching",t),this.expected=i}static{l(this,"StringMatchingPattern")}static create(t,i){let r=typeof i;if(i==null)throw new TypeError("stringMatching() expects a string or RegExp.");if(r!=="string"&&!(i instanceof RegExp))throw new TypeError("stringMatching() expects a string or RegExp.");return new Ot(t,i)}get expectedLabel(){let t=this.isInverse?"Not ":"";return typeof this.expected=="string"?`${t}stringMatching("${this.expected}")`:`${t}stringMatching(${this.expected.toString()})`}matches(t){if(typeof t!="string")return this.applyInverse(!1);let i;return typeof this.expected=="string"?i=t.includes(this.expected):i=this.expected.test(t),this.applyInverse(i)}},we=class Mt extends L{static{a(this,"e")}constructor(t,i){super("ArrayContaining",t),this.expected=i}static{l(this,"ArrayContainingPattern")}static create(t,i){if(!Array.isArray(i))throw new TypeError("arrayContaining() expects an array.");return new Mt(t,i)}get expectedLabel(){return`${this.isInverse?"Not ":""}ArrayContaining(${this.describe(this.expected)})`}matches(t){if(!Array.isArray(t))return this.applyInverse(!1);let i=this.expected.every(r=>t.some(n=>this.matchElement(n,r)));return this.applyInverse(i)}matchElement(t,i){return S(i)?i.matches(t):b(t,i)}describe(t){return S(t)?t.expectedLabel:E(t,"").join(" ")}},Re=class Pt extends L{static{a(this,"e")}constructor(t,i){super("ObjectContaining",t),this.expected=i}static{l(this,"ObjectContainingPattern")}static create(t,i){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError("objectContaining() expects a plain object.");return new Pt(t,i)}get expectedLabel(){return`${this.isInverse?"Not ":""}ObjectContaining(${this.describe(this.expected)})`}matches(t){if(typeof t!="object"||t===null)return this.applyInverse(!1);let i=Object.keys(this.expected).every(r=>X(t,r)?this.matchElement(t[r],this.expected[r]):!1);return this.applyInverse(i)}matchElement(t,i){return S(i)?i.matches(t):b(t,i)}describe(t){return S(t)?t.expectedLabel:E(t,"").join(" ")}},Ie=class Nt extends L{static{a(this,"e")}constructor(t,i){super("StringContaining",t),this.expected=i}static{l(this,"StringContainingPattern")}static create(t,i){if(typeof i!="string")throw new TypeError("stringContaining() expects a string.");return new Nt(t,i)}get expectedLabel(){return`${this.isInverse?"Not ":""}stringContaining("${this.expected}")`}matches(t){return typeof t!="string"?this.applyInverse(!1):this.applyInverse(t.includes(this.expected))}},pi={any:hi.create,anything:ui.create,closeTo:$e.create.bind(null,!1),arrayOf:Ee.create.bind(null,!1),stringMatching:Se.create.bind(null,!1),arrayContaining:we.create.bind(null,!1),objectContaining:Re.create.bind(null,!1),stringContaining:Ie.create.bind(null,!1),not:{closeTo:$e.create.bind(null,!0),arrayOf:Ee.create.bind(null,!0),stringMatching:Se.create.bind(null,!0),arrayContaining:we.create.bind(null,!0),objectContaining:Re.create.bind(null,!1),stringContaining:Ie.create.bind(null,!0)}},fi=class extends ce{static{a(this,"oe")}static{l(this,"xJetPromiseError")}constructor(e){let t=[`${Q(e)}
|
|
64
64
|
`,`Matcher error: ${e.message}`,`${e.promiseKind} to value: ${u(E(e.received,"").join(" "))}`];super(t.join(`
|
|
65
|
-
`),"xJetPromiseError")}},Ft=class{static{a(this,"U")}constructor(e){this.received=e}static{l(this,"MatcherService")}macherName="";promise;notModifier=!1;assertionChain=[];rejectsModifier=!1;resolvesModifier=!1;get not(){return this.notModifier=!0,this}get rejects(){if(this.resolvesModifier)throw new Error('Cannot use "rejects" modifier after "resolved" modifier.');return this.rejectsModifier=!0,this}get resolves(){if(this.rejectsModifier)throw new Error('Cannot use "resolved" modifier after "rejects" modifier.');return this.resolvesModifier=!0,this}invoke(e,t,i){return this.macherName=e,this.rejectsModifier||this.resolvesModifier?(this.pushToChain(e),this.promise=this.resolvesModifier?"resolves":"rejects",this.invokeAsync(t,i)):(this.pushToChain(e),t.call(this,...i))}async invokeAsync(e,t){let i=!1,r=typeof this.received=="function"?this.received():this.received;if(!Be(r))throw new j({message:`${u("received")} value must be a promise or a function returning a promise`,assertionChain:this.assertionChain,received:{type:R(r),value:r}});try{this.received=await r,i=!0}catch(n){this.resolvesModifier&&this.throwPromiseError("Rejected",n),this.received=n}return i&&this.rejectsModifier&&this.throwPromiseError("Resolved",this.received),e.call(this,...t)}pushToChain(e){this.promise&&this.assertionChain.push(this.promise),this.notModifier&&this.assertionChain.push("not"),this.assertionChain.push(e)}throwPromiseError(e,t){let i=e==="Resolved"?"resolved":"rejected",r=e==="Resolved"?"rejected":"resolved";throw new fi({message:`${u("received")} promise ${i} instead of ${r}`,received:t,promiseKind:e,assertionChain:this.assertionChain})}};for(let e of Object.keys(xe)){let t=Ft.prototype,i=xe[e];Object.defineProperty(t,e,{value:l(function(...r){return this.invoke(e,i,r)},"value")}),Object.defineProperty(t[e],"name",{value:e})}var di=l((e,...t)=>{if(t.length>0)throw new Error(`Expect takes at most one argument. Received ${t.length+1} arguments instead.`);return new Ft(e)},"coreExpect"),Gi=Object.assign(di,pi);function Dt(e,t,i){let r=`${t}${i}`,n=e[r];if(!i)throw new Error(`Invalid type(${i}) parameter`);if(!(r in e))throw new Error(`Method "${r.toString()}" does not exist on Buffer`);return n.bind(e)}a(Dt,"b");function qt(e,t){return Dt(e,"read",t)}a(qt,"h");function Wt(e,t){return Dt(e,"write",t)}a(Wt,"d");function ue(e,t,i=0){if(t<0)throw new Error("Split position cannot be negative");if(t>e.length)throw new Error("Split position cannot exceed buffer length");let r=e.subarray(0,t),n=t+i;return n>=e.length?[r,Buffer.alloc(0)]:[r,e.subarray(n)]}a(ue,"f");function _t(e=0){let{position:t,type:i}=this.descriptor,r=this.offset+t+e;return i.toObject(this.buffer.subarray(r),n=>{this.offset+=n})}a(_t,"l");function gi(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=_t.call(this,r*i);return e}a(gi,"U");function mi(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?gi.call(this):_t.call(this)}a(mi,"S");function Jt(e,t=0){e??={};let{position:i,type:r,size:n}=this.descriptor,s=r.toBuffer(e),o=this.offset+i+t,[c,h]=ue(this.buffer,o,n);this.buffer=Buffer.concat([c,s,h]),s.length>n&&(this.offset+=s.length-n)}a(Jt,"T");function yi(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:{};Jt.call(this,n,r*i)}}a(yi,"W");function vi(e){return"arraySize"in this.descriptor&&this.descriptor.arraySize?yi.call(this,Array.isArray(e)?e:[e]):Jt.call(this,Array.isArray(e)?e[0]||{}:e)}a(vi,"I");var O={Int8:8,UInt8:8,Int16LE:16,Int16BE:16,UInt16LE:16,UInt16BE:16,FloatLE:32,FloatBE:32,Int32LE:32,Int32BE:32,UInt32LE:32,UInt32BE:32,DoubleLE:64,DoubleBE:64,BigInt64LE:64,BigInt64BE:64,BigUInt64LE:64,BigUInt64BE:64};function bi(e,t=0){let i=/^([A-Za-z][A-Za-z0-9]*)(?:\[(\d+)\])?$/i,r=e.match(i);if(!r)throw new Error(`Invalid primitive descriptor: ${e}`);let n=O[r[1]];if(!n)throw new Error(`Invalid primitive type: ${r[1]}`);let s=r[1],o=r[2]?parseInt(r[2]):void 0;return{type:s,position:t,size:n/8,arraySize:o,kind:"primitive"}}a(bi,"x");function Vt(e=0){let{position:t,type:i}=this.descriptor,r=this.offset+t+e;return qt(this.buffer,i)(r)}a(Vt,"z");function xi(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=Vt.call(this,r*i);return e}a(xi,"N");function Ei(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?xi.call(this):Vt.call(this)}a(Ei,"w");function Gt(e,t=0){e??=0;let{position:i,type:r}=this.descriptor,n=r.includes("Big");if(n&&e===0&&(e=BigInt(0)),n&&typeof e!="bigint")throw new TypeError(`Expected a BigInt for field "${r}", but received ${e}`);if(!n&&typeof e!="number")throw new TypeError(`Expected a number for field "${r}", but received ${e}`);let s=this.offset+i+t;Wt(this.buffer,r)(e,s)}a(Gt,"B");function $i(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:0;Gt.call(this,n,r*i)}}a($i,"_");function Si(e){if("arraySize"in this.descriptor&&this.descriptor.arraySize)return $i.call(this,Array.isArray(e)?e:[e]);Gt.call(this,Array.isArray(e)?e[0]||0:e)}a(Si,"P");var Ut=new Map;function fe(e){return e.startsWith("Int")}a(fe,"y");function Kt(e){let t=Ut.get(e);return t===void 0&&(t=(1<<e)-1,Ut.set(e,t)),t}a(Kt,"D");function wi(e,t){return fe(e.type)?Number(BigInt.asIntN(e.bitSize,BigInt(t))):t}a(wi,"j");function Ri(e,t){let i=fe(e.type),{bitSize:r,type:n}=e,s=i?(1<<r-1)-1:(1<<r)-1,o=i?-(1<<r-1):0;if(t<o||t>s)throw new RangeError(`Value ${t} does not fit within ${r} bits for type ${n}`)}a(Ri,"G");function Yt(e,t){if(e.bitSize<1||e.bitPosition<0)throw new Error(`bitSize(${e.bitSize}) and bitPosition(${e.bitPosition}) must be greater than bitSize(1) and bitPosition(0) for ${t}`);if(O[e.type]>32)throw new Error(`${e.type} is not supported yet`);if(e.bitPosition+e.bitSize>O[e.type])throw new Error(`bitPosition(${e.bitPosition}) + bitSize(${e.bitSize}) exceeds ${e.type} size for ${t}`)}a(Yt,"v");function ki(e,t){Yt(t,"read operation");let{type:i,bitPosition:r,bitSize:n}=t,s=Kt(n),o=e>>r&s;return fe(i)&&o&1<<n-1?o|~s:o}a(ki,"Z");function Ii(e,t,i){Yt(t,"write operation"),Ri(t,i);let{bitPosition:r,bitSize:n}=t,s=wi(t,i),o=Kt(n)<<r;return e&~o|s<<r&o}a(Ii,"q");function Ti(e,t=0,i=0){let[r,n]=e.split(":",2),s=parseInt(n,10),o=O[r],c=r.endsWith("BE");if(!o)throw new Error(`${r} is not supported`);if(i<0||i>=o)throw new Error(`Bitfield position ${i} is out of bounds (must be between 0 and ${o-1})`);if(!s)throw new Error(`${e} is not valid`);if(s+i>=o)throw new Error(`${r} size (${o}) is not enough to hold ${s} bits starting at position ${i}`);return{kind:"bitfield",type:r,size:o/8,position:t,bitSize:s,bitPosition:i,isBigEndian:c}}a(Ti,"$");function Ci(){let e=this.descriptor.position+this.offset,t=this.descriptor.isBigEndian?"BE":"LE",i=this.buffer[`readUInt${t}`](e,this.descriptor.size);return ki(i,this.descriptor)}a(Ci,"C");function Bi(e){let t=this.descriptor.position+this.offset,i=this.descriptor.isBigEndian?"BE":"LE",r=this.buffer[`readUInt${i}`](t,this.descriptor.size),n=Ii(r,this.descriptor,e);this.buffer[`writeUInt${i}`](n,t,this.descriptor.size)}a(Bi,"F");var Ht=new Set(["utf8","ascii","string"]);function Li(e,t=0){let i=/^(utf8|ascii|string)(?:\[(\d+)\])?$/i,r=e.match(i);if(!r)throw new Error(`Invalid string descriptor: ${e}`);let n=r[1].toLowerCase(),s=r[2]?parseInt(r[2]):void 0;return{type:n,arraySize:s,position:t,size:2,lengthType:"UInt16LE",kind:"string"}}a(Li,"A");function Xt(e=0){let{position:t,type:i,size:r}=this.descriptor,n=this.offset+t+e,s=i==="string"?"utf8":i;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let o=this.descriptor.lengthType,c=Number(qt(this.buffer,o)(n)),h=n+r;if(this.offset+=c,h+c>this.buffer.length)throw new Error(`String prefix length exceeds buffer position: ${h} size: ${c} > ${this.buffer.length}`);return this.buffer.subarray(h,h+c).toString(s)}if("nullTerminated"in this.descriptor){let o=n,c="maxLength"in this.descriptor?this.descriptor.maxLength:0;for(;o<this.buffer.length&&this.buffer[o]!==0;){if(c&&o>c)throw new Error(`NullTerminated String exceeds maximum length of ${c}`);o++}let h=o-n;return this.offset+=h+1,this.buffer.subarray(n,o).toString(s)}return this.buffer.subarray(n,n+r).toString(s)}a(Xt,"M");function Ai(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=Xt.call(this,r*i);return e}a(Ai,"Y");function zi(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Ai.call(this):Xt.call(this)}a(zi,"L");function Zt(e,t=0){e??="";let{position:i,type:r,size:n}=this.descriptor,s=this.offset+i+t,o=r==="string"?"utf8":r;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let c=Buffer.from(e,o);Wt(this.buffer,this.descriptor.lengthType)(c.length,s);let[h,f]=ue(this.buffer,s+n);this.buffer=Buffer.concat([h,c,f]),this.offset+=c.length;return}if("nullTerminated"in this.descriptor){"maxLength"in this.descriptor&&this.descriptor.maxLength&&(e=e.length>this.descriptor.maxLength?e.slice(0,this.descriptor.maxLength):e);let c=e.endsWith("\0")?e:`${e}\0`,h=Buffer.from(c,o),[f,g]=ue(this.buffer,s,n);this.buffer=Buffer.concat([f,h,g]),this.offset+=h.length;return}this.buffer.write(e,s,n,o)}a(Zt,"k");function ji(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:"";Zt.call(this,n,r*i)}}a(ji,"O");function Oi(e){return"arraySize"in this.descriptor&&this.descriptor.arraySize?ji.call(this,Array.isArray(e)?e:[e]):Zt.call(this,Array.isArray(e)?e[0]||"":e)}a(Oi,"V");var M=class pe{static{a(this,"e")}size;schema=new Map;constructor(t){this.size=this.compileSchema(t)}toObject(t,i){if(!Buffer.isBuffer(t))throw new Error(`Expected a buffer, but received ${typeof t}`);if(t.length<this.size)throw new Error(`Buffer size is less than expected: ${t.length} < ${this.size}`);let r={},n={buffer:t,offset:0};for(let[s,o]of this.schema)n.descriptor=o,r[s]=this.readValue(n,o.kind);return i&&typeof i=="function"&&i(n.offset),r}toBuffer(t){if(!t||typeof t!="object")throw new Error(`Expected an object of fields, but received ${typeof t}`);let i={buffer:Buffer.alloc(this.size),offset:0};for(let[r,n]of this.schema){i.descriptor=n;let s=t[r];this.writeValue(i,n.kind,s)}return i.buffer}readValue(t,i){switch(i){case"struct":return mi.call(t);case"bitfield":return Ci.call(t);case"string":return zi.call(t);default:return Ei.call(t)}}writeValue(t,i,r){switch(i){case"struct":vi.call(t,r);break;case"bitfield":Bi.call(t,r);break;case"string":Oi.call(t,r);break;default:Si.call(t,r)}}computeFieldSize(t,i){if(t.type instanceof pe)return{...t,position:i,size:t.type.size,kind:"struct"};if(Ht.has(t.type))return this.computeStringFieldSize(t,i);let r=O[t.type];if(r!==void 0)return{...t,position:i,size:r/8,kind:"primitive"};throw new Error(`Invalid field type: ${t.type}`)}computeStringFieldSize(t,i){let r={...t,position:i,kind:"string"};if("lengthType"in t&&t.lengthType){let n=O[t.lengthType];if(!n)throw new Error(`Invalid length type: ${t.lengthType}`);r.size=n/8}else"nullTerminated"in t&&t.nullTerminated?r.size=0:(!("size"in t)||!t.size)&&(r.lengthType="UInt16LE",r.size=O.UInt16LE/8);return r}parseStringNotation(t,i){return t.includes(":")?Ti(t,i):[...Ht].find(r=>t.startsWith(r))?Li(t,i):bi(t,i)}convertToSizedField(t,i){return t instanceof pe?{type:t,position:i,size:t.size,kind:"struct"}:typeof t=="string"?this.parseStringNotation(t,i):this.computeFieldSize(t,i)}compileSchema(t){let i={bits:0,bytes:0,bitFieldSize:0,bitFieldType:"UInt8"};for(let[r,n]of Object.entries(t)){let s=this.convertToSizedField(n,i.bytes);if("arraySize"in s&&s.arraySize&&s.arraySize>=Number.MAX_SAFE_INTEGER)throw new Error(`Array size exceeds maximum safe integer: ${s.arraySize}`);"bitSize"in s&&s.bitSize>0?this.processBitfield(i,r,s):this.processStandardField(i,r,s)}return i.bits>0&&(i.bytes+=i.bitFieldSize),i.bytes}processBitfield(t,i,r){let n=r.size*8,s=r.bitSize;(t.bits+s>n||t.bitFieldType!==r.type||t.bitFieldSize!==r.size)&&(t.bytes+=t.bitFieldSize,t.bits=0,r.position=t.bytes),r.bitPosition=t.bits,this.schema.set(i,r),t.bits+=s,t.bitFieldType=r.type,t.bitFieldSize=r.size}processStandardField(t,i,r){t.bits>0&&(t.bytes+=t.bitFieldSize,t.bits=0,r.position=t.bytes),this.schema.set(i,r);let n="arraySize"in r&&r.arraySize||0,s=n>0?r.size*n:r.size;t.bytes+=s}};var Mi=new M({line:"UInt32LE",column:"UInt32LE",source:"string"}),Qt=new M({kind:"UInt8:4",suiteId:{type:"string",size:14},runnerId:{type:"string",size:14},timestamp:"string"}),Pi=new M({level:"UInt8",message:{type:"string",lengthType:"UInt32LE"},ancestry:{type:"string",lengthType:"UInt32LE"},invocation:Mi}),de=new M({error:{type:"string",lengthType:"UInt32LE"}}),Ni=new M({type:"UInt8:5",todo:"UInt8:1",skipped:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"}}),Fi=new M({type:"UInt8:5",passed:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"},errors:{type:"string",lengthType:"UInt32LE"}});function Ui(e,t,i){let r=Qt.toBuffer({kind:2,suiteId:t??"",runnerId:i??"",timestamp:new Date().toISOString()}),n=de.toBuffer({error:JSON.stringify(H(e))});return Buffer.concat([r,n])}a(Ui,"encodeErrorSchema");export{ee as MockState,Ui as encodeErrorSchema};
|
|
65
|
+
`),"xJetPromiseError")}},Ft=class{static{a(this,"U")}constructor(e){this.received=e}static{l(this,"MatcherService")}macherName="";promise;notModifier=!1;assertionChain=[];rejectsModifier=!1;resolvesModifier=!1;get not(){return this.notModifier=!0,this}get rejects(){if(this.resolvesModifier)throw new Error('Cannot use "rejects" modifier after "resolved" modifier.');return this.rejectsModifier=!0,this}get resolves(){if(this.rejectsModifier)throw new Error('Cannot use "resolved" modifier after "rejects" modifier.');return this.resolvesModifier=!0,this}invoke(e,t,i){return this.macherName=e,this.rejectsModifier||this.resolvesModifier?(this.pushToChain(e),this.promise=this.resolvesModifier?"resolves":"rejects",this.invokeAsync(t,i)):(this.pushToChain(e),t.call(this,...i))}async invokeAsync(e,t){let i=!1,r=typeof this.received=="function"?this.received():this.received;if(!Be(r))throw new j({message:`${u("received")} value must be a promise or a function returning a promise`,assertionChain:this.assertionChain,received:{type:R(r),value:r}});try{this.received=await r,i=!0}catch(n){this.resolvesModifier&&this.throwPromiseError("Rejected",n),this.received=n}return i&&this.rejectsModifier&&this.throwPromiseError("Resolved",this.received),e.call(this,...t)}pushToChain(e){this.promise&&this.assertionChain.push(this.promise),this.notModifier&&this.assertionChain.push("not"),this.assertionChain.push(e)}throwPromiseError(e,t){let i=e==="Resolved"?"resolved":"rejected",r=e==="Resolved"?"rejected":"resolved";throw new fi({message:`${u("received")} promise ${i} instead of ${r}`,received:t,promiseKind:e,assertionChain:this.assertionChain})}};for(let e of Object.keys(xe)){let t=Ft.prototype,i=xe[e];Object.defineProperty(t,e,{value:l(function(...r){return this.invoke(e,i,r)},"value")}),Object.defineProperty(t[e],"name",{value:e})}var di=l((e,...t)=>{if(t.length>0)throw new Error(`Expect takes at most one argument. Received ${t.length+1} arguments instead.`);return new Ft(e)},"coreExpect"),Gi=Object.assign(di,pi);function Dt(e,t,i){let r=`${t}${i}`,n=e[r];if(!i)throw new Error(`Invalid type(${i}) parameter`);if(!(r in e))throw new Error(`Method "${r.toString()}" does not exist on Buffer`);return n.bind(e)}a(Dt,"b");function qt(e,t){return Dt(e,"read",t)}a(qt,"h");function Wt(e,t){return Dt(e,"write",t)}a(Wt,"d");function ue(e,t,i=0){if(t<0)throw new Error("Split position cannot be negative");if(t>e.length)throw new Error("Split position cannot exceed buffer length");let r=e.subarray(0,t),n=t+i;return n>=e.length?[r,Buffer.alloc(0)]:[r,e.subarray(n)]}a(ue,"f");function _t(e=0){let{position:t,type:i}=this.descriptor,r=this.offset+t+e;return i.toObject(this.buffer.subarray(r),n=>{this.offset+=n})}a(_t,"l");function gi(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=_t.call(this,r*i);return e}a(gi,"U");function mi(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?gi.call(this):_t.call(this)}a(mi,"S");function Jt(e,t=0){e??={};let{position:i,type:r,size:n}=this.descriptor,s=r.toBuffer(e),o=this.offset+i+t,[c,h]=ue(this.buffer,o,n);this.buffer=Buffer.concat([c,s,h]),s.length>n&&(this.offset+=s.length-n)}a(Jt,"T");function yi(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:{};Jt.call(this,n,r*i)}}a(yi,"W");function vi(e){return"arraySize"in this.descriptor&&this.descriptor.arraySize?yi.call(this,Array.isArray(e)?e:[e]):Jt.call(this,Array.isArray(e)?e[0]||{}:e)}a(vi,"I");var O={Int8:8,UInt8:8,Int16LE:16,Int16BE:16,UInt16LE:16,UInt16BE:16,FloatLE:32,FloatBE:32,Int32LE:32,Int32BE:32,UInt32LE:32,UInt32BE:32,DoubleLE:64,DoubleBE:64,BigInt64LE:64,BigInt64BE:64,BigUInt64LE:64,BigUInt64BE:64};function bi(e,t=0){let i=/^([A-Za-z][A-Za-z0-9]*)(?:\[(\d+)\])?$/i,r=e.match(i);if(!r)throw new Error(`Invalid primitive descriptor: ${e}`);let n=O[r[1]];if(!n)throw new Error(`Invalid primitive type: ${r[1]}`);let s=r[1],o=r[2]?parseInt(r[2]):void 0;return{type:s,position:t,size:n/8,arraySize:o,kind:"primitive"}}a(bi,"x");function Vt(e=0){let{position:t,type:i}=this.descriptor,r=this.offset+t+e;return qt(this.buffer,i)(r)}a(Vt,"z");function xi(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=Vt.call(this,r*i);return e}a(xi,"N");function Ei(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?xi.call(this):Vt.call(this)}a(Ei,"w");function Gt(e,t=0){e??=0;let{position:i,type:r}=this.descriptor,n=r.includes("Big");if(n&&e===0&&(e=BigInt(0)),n&&typeof e!="bigint")throw new TypeError(`Expected a BigInt for field "${r}", but received ${e}`);if(!n&&typeof e!="number")throw new TypeError(`Expected a number for field "${r}", but received ${e}`);let s=this.offset+i+t;Wt(this.buffer,r)(e,s)}a(Gt,"B");function $i(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:0;Gt.call(this,n,r*i)}}a($i,"_");function Si(e){if("arraySize"in this.descriptor&&this.descriptor.arraySize)return $i.call(this,Array.isArray(e)?e:[e]);Gt.call(this,Array.isArray(e)?e[0]||0:e)}a(Si,"P");var Ut=new Map;function fe(e){return e.startsWith("Int")}a(fe,"y");function Kt(e){let t=Ut.get(e);return t===void 0&&(t=(1<<e)-1,Ut.set(e,t)),t}a(Kt,"D");function wi(e,t){return fe(e.type)?Number(BigInt.asIntN(e.bitSize,BigInt(t))):t}a(wi,"j");function Ri(e,t){let i=fe(e.type),{bitSize:r,type:n}=e,s=i?(1<<r-1)-1:(1<<r)-1,o=i?-(1<<r-1):0;if(t<o||t>s)throw new RangeError(`Value ${t} does not fit within ${r} bits for type ${n}`)}a(Ri,"G");function Yt(e,t){if(e.bitSize<1||e.bitPosition<0)throw new Error(`bitSize(${e.bitSize}) and bitPosition(${e.bitPosition}) must be greater than bitSize(1) and bitPosition(0) for ${t}`);if(O[e.type]>32)throw new Error(`${e.type} is not supported yet`);if(e.bitPosition+e.bitSize>O[e.type])throw new Error(`bitPosition(${e.bitPosition}) + bitSize(${e.bitSize}) exceeds ${e.type} size for ${t}`)}a(Yt,"v");function Ii(e,t){Yt(t,"read operation");let{type:i,bitPosition:r,bitSize:n}=t,s=Kt(n),o=e>>r&s;return fe(i)&&o&1<<n-1?o|~s:o}a(Ii,"Z");function ki(e,t,i){Yt(t,"write operation"),Ri(t,i);let{bitPosition:r,bitSize:n}=t,s=wi(t,i),o=Kt(n)<<r;return e&~o|s<<r&o}a(ki,"q");function Ti(e,t=0,i=0){let[r,n]=e.split(":",2),s=parseInt(n,10),o=O[r],c=r.endsWith("BE");if(!o)throw new Error(`${r} is not supported`);if(i<0||i>=o)throw new Error(`Bitfield position ${i} is out of bounds (must be between 0 and ${o-1})`);if(!s)throw new Error(`${e} is not valid`);if(s+i>=o)throw new Error(`${r} size (${o}) is not enough to hold ${s} bits starting at position ${i}`);return{kind:"bitfield",type:r,size:o/8,position:t,bitSize:s,bitPosition:i,isBigEndian:c}}a(Ti,"$");function Ci(){let e=this.descriptor.position+this.offset,t=this.descriptor.isBigEndian?"BE":"LE",i=this.buffer[`readUInt${t}`](e,this.descriptor.size);return Ii(i,this.descriptor)}a(Ci,"C");function Bi(e){let t=this.descriptor.position+this.offset,i=this.descriptor.isBigEndian?"BE":"LE",r=this.buffer[`readUInt${i}`](t,this.descriptor.size),n=ki(r,this.descriptor,e);this.buffer[`writeUInt${i}`](n,t,this.descriptor.size)}a(Bi,"F");var Ht=new Set(["utf8","ascii","string"]);function Li(e,t=0){let i=/^(utf8|ascii|string)(?:\[(\d+)\])?$/i,r=e.match(i);if(!r)throw new Error(`Invalid string descriptor: ${e}`);let n=r[1].toLowerCase(),s=r[2]?parseInt(r[2]):void 0;return{type:n,arraySize:s,position:t,size:2,lengthType:"UInt16LE",kind:"string"}}a(Li,"A");function Xt(e=0){let{position:t,type:i,size:r}=this.descriptor,n=this.offset+t+e,s=i==="string"?"utf8":i;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let o=this.descriptor.lengthType,c=Number(qt(this.buffer,o)(n)),h=n+r;if(this.offset+=c,h+c>this.buffer.length)throw new Error(`String prefix length exceeds buffer position: ${h} size: ${c} > ${this.buffer.length}`);return this.buffer.subarray(h,h+c).toString(s)}if("nullTerminated"in this.descriptor){let o=n,c="maxLength"in this.descriptor?this.descriptor.maxLength:0;for(;o<this.buffer.length&&this.buffer[o]!==0;){if(c&&o>c)throw new Error(`NullTerminated String exceeds maximum length of ${c}`);o++}let h=o-n;return this.offset+=h+1,this.buffer.subarray(n,o).toString(s)}return this.buffer.subarray(n,n+r).toString(s)}a(Xt,"M");function Ai(){let e=[],{arraySize:t=0,size:i}=this.descriptor;e.length=t;for(let r=0;r<t;r++)e[r]=Xt.call(this,r*i);return e}a(Ai,"Y");function zi(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Ai.call(this):Xt.call(this)}a(zi,"L");function Zt(e,t=0){e??="";let{position:i,type:r,size:n}=this.descriptor,s=this.offset+i+t,o=r==="string"?"utf8":r;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let c=Buffer.from(e,o);Wt(this.buffer,this.descriptor.lengthType)(c.length,s);let[h,f]=ue(this.buffer,s+n);this.buffer=Buffer.concat([h,c,f]),this.offset+=c.length;return}if("nullTerminated"in this.descriptor){"maxLength"in this.descriptor&&this.descriptor.maxLength&&(e=e.length>this.descriptor.maxLength?e.slice(0,this.descriptor.maxLength):e);let c=e.endsWith("\0")?e:`${e}\0`,h=Buffer.from(c,o),[f,g]=ue(this.buffer,s,n);this.buffer=Buffer.concat([f,h,g]),this.offset+=h.length;return}this.buffer.write(e,s,n,o)}a(Zt,"k");function ji(e){let{arraySize:t=0,size:i}=this.descriptor;for(let r=0;r<t;r++){let n=r<e.length?e[r]:"";Zt.call(this,n,r*i)}}a(ji,"O");function Oi(e){return"arraySize"in this.descriptor&&this.descriptor.arraySize?ji.call(this,Array.isArray(e)?e:[e]):Zt.call(this,Array.isArray(e)?e[0]||"":e)}a(Oi,"V");var M=class pe{static{a(this,"e")}size;schema=new Map;constructor(t){this.size=this.compileSchema(t)}toObject(t,i){if(!Buffer.isBuffer(t))throw new Error(`Expected a buffer, but received ${typeof t}`);if(t.length<this.size)throw new Error(`Buffer size is less than expected: ${t.length} < ${this.size}`);let r={},n={buffer:t,offset:0};for(let[s,o]of this.schema)n.descriptor=o,r[s]=this.readValue(n,o.kind);return i&&typeof i=="function"&&i(n.offset),r}toBuffer(t){if(!t||typeof t!="object")throw new Error(`Expected an object of fields, but received ${typeof t}`);let i={buffer:Buffer.alloc(this.size),offset:0};for(let[r,n]of this.schema){i.descriptor=n;let s=t[r];this.writeValue(i,n.kind,s)}return i.buffer}readValue(t,i){switch(i){case"struct":return mi.call(t);case"bitfield":return Ci.call(t);case"string":return zi.call(t);default:return Ei.call(t)}}writeValue(t,i,r){switch(i){case"struct":vi.call(t,r);break;case"bitfield":Bi.call(t,r);break;case"string":Oi.call(t,r);break;default:Si.call(t,r)}}computeFieldSize(t,i){if(t.type instanceof pe)return{...t,position:i,size:t.type.size,kind:"struct"};if(Ht.has(t.type))return this.computeStringFieldSize(t,i);let r=O[t.type];if(r!==void 0)return{...t,position:i,size:r/8,kind:"primitive"};throw new Error(`Invalid field type: ${t.type}`)}computeStringFieldSize(t,i){let r={...t,position:i,kind:"string"};if("lengthType"in t&&t.lengthType){let n=O[t.lengthType];if(!n)throw new Error(`Invalid length type: ${t.lengthType}`);r.size=n/8}else"nullTerminated"in t&&t.nullTerminated?r.size=0:(!("size"in t)||!t.size)&&(r.lengthType="UInt16LE",r.size=O.UInt16LE/8);return r}parseStringNotation(t,i){return t.includes(":")?Ti(t,i):[...Ht].find(r=>t.startsWith(r))?Li(t,i):bi(t,i)}convertToSizedField(t,i){return t instanceof pe?{type:t,position:i,size:t.size,kind:"struct"}:typeof t=="string"?this.parseStringNotation(t,i):this.computeFieldSize(t,i)}compileSchema(t){let i={bits:0,bytes:0,bitFieldSize:0,bitFieldType:"UInt8"};for(let[r,n]of Object.entries(t)){let s=this.convertToSizedField(n,i.bytes);if("arraySize"in s&&s.arraySize&&s.arraySize>=Number.MAX_SAFE_INTEGER)throw new Error(`Array size exceeds maximum safe integer: ${s.arraySize}`);"bitSize"in s&&s.bitSize>0?this.processBitfield(i,r,s):this.processStandardField(i,r,s)}return i.bits>0&&(i.bytes+=i.bitFieldSize),i.bytes}processBitfield(t,i,r){let n=r.size*8,s=r.bitSize;(t.bits+s>n||t.bitFieldType!==r.type||t.bitFieldSize!==r.size)&&(t.bytes+=t.bitFieldSize,t.bits=0,r.position=t.bytes),r.bitPosition=t.bits,this.schema.set(i,r),t.bits+=s,t.bitFieldType=r.type,t.bitFieldSize=r.size}processStandardField(t,i,r){t.bits>0&&(t.bytes+=t.bitFieldSize,t.bits=0,r.position=t.bytes),this.schema.set(i,r);let n="arraySize"in r&&r.arraySize||0,s=n>0?r.size*n:r.size;t.bytes+=s}};var Mi=new M({line:"UInt32LE",column:"UInt32LE",source:"string"}),Qt=new M({kind:"UInt8:4",suiteId:{type:"string",size:14},runnerId:{type:"string",size:14},timestamp:"string"}),Pi=new M({level:"UInt8",message:{type:"string",lengthType:"UInt32LE"},ancestry:{type:"string",lengthType:"UInt32LE"},invocation:Mi}),de=new M({error:{type:"string",lengthType:"UInt32LE"}}),Ni=new M({type:"UInt8:5",todo:"UInt8:1",skipped:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"}}),Fi=new M({type:"UInt8:5",passed:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"},errors:{type:"string",lengthType:"UInt32LE"}});function Ui(e,t,i){let r=Qt.toBuffer({kind:2,suiteId:t??"",runnerId:i??"",timestamp:new Date().toISOString()}),n=de.toBuffer({error:JSON.stringify(H(e))});return Buffer.concat([r,n])}a(Ui,"encodeErrorSchema");export{ee as MockState,Ui as encodeErrorSchema};
|
|
66
66
|
//# sourceMappingURL=index.js.map
|