New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mockyeah/fetch

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mockyeah/fetch - npm Package Compare versions

Comparing version

to
1.0.0-alpha.9

dist/Expectation.js

1

dist/index.d.ts

@@ -0,1 +1,2 @@

/// <reference lib="dom" />
import { BootOptions, FetchOptions, MockFunction, MockReturn, Match, ResponseOptions, MakeMockOptions, MakeMockReturn } from './types';

@@ -2,0 +3,0 @@ declare class Mockyeah {

2

dist/main.js

@@ -1,1 +0,1 @@

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t){e.exports=require("@babel/runtime/regenerator")},function(e,t){e.exports=require("lodash/isPlainObject")},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("debug")},function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t){e.exports=require("qs")},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("match-deep")},function(e,t){e.exports=require("lodash/isEmpty")},function(e,t){e.exports=require("lodash/isEqual")},function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},function(e,t){e.exports=require("cookie")},function(e,t){e.exports=require("lodash/isRegExp")},function(e,t){e.exports=require("lodash/mapValues")},function(e,t){e.exports=require("lodash/flatten")},function(e,t){e.exports=require("path-to-regexp")},function(e,t){e.exports=require("mime")},function(e,t){e.exports=require("@babel/runtime/helpers/typeof")},function(e,t){e.exports=require("lodash/fromPairs")},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(7),i=r.n(a),c=r(8),s=r.n(c),u=r(3),l=r.n(u),f=r(13),p=r.n(f),d=r(14),h=r.n(d),v=r(5),m=r.n(v),y=r(9),k=r(6),x=r.n(k),b=r(1),g=r.n(b),w=r(18),O=r.n(w),P=r(15),q=r.n(P),_=r(4),j=r.n(_),S=r(10),E=r.n(S),T=r(19),W=r.n(T),R=r(11),$=r.n(R),C=r(16),D=r.n(C),H=r(17),I=r.n(H);function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F=/^(\/?https?.{3}[^/:?]+):/,N=/^(\/?https?).{3}/,U=/^(\/?https?.{3}[^/:?]+)~/,A=/^(\/?https?).{3}/,K=function(e){return e.replace(A,"$1://").replace(U,"$1:")},J=function(e){return e.replace(F,"$1~").replace(N,"$1~~~")},B=/^\//,V=/^(https?)%3A%2F%2F/,X=function(e){return/^\/+https?[:~][/~]{2}/.test(e)?K(function(e){return e.replace(B,"")}(e).replace(V,(function(e,t){return"".concat(t,"://")}))):e},Y=function(e,t){if("function"==typeof e)return e;var r,n=g()(e)?L({},e):e;(r=g()(e)?L({},e):{url:e}).query=$()(r.query)?void 0:r.query,r.headers=$()(r.headers)?void 0:Object.entries(r.headers).reduce((function(e,t){var r=s()(t,2),n=r[0],o=r[1];return e[n.toLowerCase()]=o,e}),{}),r.method&&"all"!==r.method&&"ALL"!==r.method&&"*"!==r.method?"string"==typeof r.method&&(r.method=r.method.toLowerCase()):delete r.method;var o=L({},r.$meta||{});if(r.path&&(r.url=r.path,delete r.path),"*"===r.url&&delete r.url,"string"==typeof r.url){r.url=X(r.url);var a=function(e){var t;return/^https?:/.test(e)?(t=Object(y.parse)(e),e="".concat(t.protocol||"http:","//").concat(t.hostname).concat(t.port&&!["80","443"].includes(t.port)?":".concat(t.port):"").concat(t.pathname)):(t=Object(y.parse)("http://example.com".concat(e.startsWith("/")?e:"/".concat(e))),e=t.pathname||""),{url:e,query:t.query?x.a.parse(t.query):void 0}}(r.url);r.url=a.url.replace(/\/+$/,"")||"/",r.query=g()(r.query)?L({},a.query,{},r.query):r.query||a.query}$()(r.query)&&delete r.query,$()(r.cookies)&&delete r.cookies;var i=L({},r);r.url||(i.url="*"),o.original=n,o.originalNormal=i,o.originalSerialized=function e(t){return I()(t,(function(t){return D()(t)?{$regex:{source:t.source,flags:t.flags}}:g()(t)?I()(t,(function(t){return e(t)})):t}))}(i);var c=r.url;if("string"==typeof r.url){if(!t){var u=[],l=W()(J(r.url),u);r.url=function(e){return l.test(J(e)||J("/".concat(e)))},o.regex=l,o.matchKeys=u,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return'"'.concat(null==c?void 0:c.toString(),'"')}}}else if(D()(r.url)){if(!t){var f=r.url;r.url=function(e){return f.test(K(e))||f.test(K("/".concat(e)))},o.regex=f,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return null==c?void 0:c.toString()}}}else if("function"==typeof r.url){var p=r.url;r.url=function(e){return p(e)||p("/".concat(e))}}return L({},r,{$meta:o})},z=r(12),G=r.n(z),Q=function(e,t){var r=e.$meta?e.$meta.originalNormal:void 0,n=t.$meta?t.$meta.originalNormal:void 0;return g()(r)&&g()(n)?!(!r||!n)&&(r.url===n.url&&r.path===n.path&&r.method===n.method&&G()(r.query,n.query)&&G()(r.body,n.body)&&G()(r.headers,n.headers)&&G()(r.cookies,n.cookies)):r===n},Z=r(20),ee=r.n(Z);function te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?te(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ne=function(e,t,r){return"function"==typeof e?e(t,r):e},oe=function(){var e=l()(o.a.mark((function e(t,r,n,a){var i,c,s,u,l,f,p,d,h,v,m,y,k,x,b,g;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.responseHeaders,c=n.fixtureResolver,s=n.fileResolver,u=t[1]||{},e.t1=u.status,!e.t1){e.next=7;break}return e.next=6,ne(u.status,r,a);case 6:e.t1=e.sent;case 7:if(e.t0=e.t1,e.t0){e.next=10;break}e.t0=200;case 10:if(l=e.t0,e.t2=u.type,!e.t2){e.next=16;break}return e.next=15,ne(u.type,r,a);case 15:e.t2=e.sent;case 16:if(p=e.t2,!u.fixture){e.next=34;break}if(c){e.next=20;break}throw new Error("Using `fixture` in mock response options requires a `fixtureResolver`.");case 20:return e.next=22,ne(u.fixture,r,a);case 22:if(v=e.sent,p=p||v,!v){e.next=30;break}return e.next=27,c(v);case 27:e.t3=e.sent,e.next=31;break;case 30:e.t3=void 0;case 31:f=e.t3,e.next=78;break;case 34:if(!u.filePath){e.next=51;break}if(s){e.next=37;break}throw new Error("Using `filePath` in mock response options requires a `fileResolver`.");case 37:return e.next=39,ne(u.filePath,r,a);case 39:if(m=e.sent,p=p||m,!m){e.next=47;break}return e.next=44,s(m);case 44:e.t4=e.sent,e.next=48;break;case 47:e.t4=void 0;case 48:f=e.t4,e.next=78;break;case 51:if(!u.json){e.next=59;break}return e.next=54,ne(u.json,r,a);case 54:h=e.sent,f=JSON.stringify(h),d="application/json; charset=UTF-8",e.next=78;break;case 59:if(!u.text){e.next=66;break}return e.next=62,ne(u.text,r,a);case 62:f=e.sent,d="text/plain; charset=UTF-8",e.next=78;break;case 66:if(!u.html){e.next=73;break}return e.next=69,ne(u.html,r,a);case 69:f=e.sent,d="text/html; charset=UTF-8",e.next=78;break;case 73:if(!u.raw){e.next=78;break}return e.next=76,ne(u.raw,r,a);case 76:f=e.sent,d=void 0;case 78:if(f=f||"",d=p?ee.a.getType(p)||p:d,!u.headers){e.next=89;break}return e.t6=re,e.t7={},e.next=85,ne(u.headers,r,a);case 85:e.t8=e.sent,e.t5=(0,e.t6)(e.t7,e.t8),e.next=90;break;case 89:e.t5={};case 90:if(y=e.t5,i&&(y["x-mockyeah-mocked"]="true"),d&&(y["content-type"]=d),k={status:l,headers:y},!(x=u.latency||n.latency)){e.next=101;break}return e.next=98,ne(x,r,a);case 98:return b=e.sent,e.next=101,new Promise((function(e){return setTimeout(e,b)}));case 101:return g=new Response(f,k),e.abrupt("return",{response:g,body:f,headers:y,json:h});case 103:case"end":return e.stop()}}),e)})));return function(t,r,n,o){return e.apply(this,arguments)}}(),ae=r(21),ie=r.n(ae),ce=r(2),se=r.n(ce),ue=function(e){return e&&(e instanceof Promise||!(!e.then||!e.catch))},le=function(e,t,r){var n=E()(e,t,{skipKeys:["$meta"]}),o=n.result,a=n.message;se()(o,"".concat(r,": ").concat(a))},fe=function(){function e(t){p()(this,e);var r=t.$meta&&t.$meta.originalNormal?t.$meta.originalNormal:t;this.prefix="[".concat(r.method||"all","] ").concat(r.path||r.url," --"),this.called=0,this.assertions=[],this.handlers=[],this.verifier=this.verifier.bind(this),this.run=this.run.bind(this),this.verify=this.verify.bind(this)}return h()(e,[{key:"request",value:function(e){var t=this;this.called+=1,this.handlers.forEach((function(r){t.assertions.push(r.bind(t,e))}))}},{key:"api",value:function(e){var t=this;if("function"==typeof e){var r=e;this.handlers.push((function(e){try{var n=r(e);if(void 0!==n&&!n)throw new Error("function returned false")}catch(e){var o="".concat(t.prefix," Expect function did not match").concat(e&&e.message?": ".concat(e.message):"");se()(!1,o)}}))}else if("object"===ie()(e)){var n=Y(e);this.handlers.push((function(e){var t=E()(e,n,{skipKeys:["$meta"]}),r=t.result,o=t.message;se()(r,"Expect object did not match: ".concat(o))}))}return this}},{key:"atLeast",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called>=e,"".concat(t.prefix," Expected route to be called at least ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"atMost",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called<=e,"".concat(t.prefix," Expected route to be called at most ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"never",value:function(){var e=this;return this.assertions.push((function(){se()(0===e.called,"".concat(e.prefix," Expected route to be called never, but it was called ").concat(e.called," times"))})),this}},{key:"once",value:function(){var e=this;return this.assertions.push((function(){se()(1===e.called,"".concat(e.prefix," Expected route to be called once, but it was called ").concat(e.called," times"))})),this}},{key:"twice",value:function(){var e=this;return this.assertions.push((function(){se()(2===e.called,"".concat(e.prefix," Expected route to be called twice, but it was called ").concat(e.called," times"))})),this}},{key:"thrice",value:function(){var e=this;return this.assertions.push((function(){se()(3===e.called,"".concat(e.prefix," Expected route to be called thrice, but it was called ").concat(e.called," times"))})),this}},{key:"exactly",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called===e,"".concat(t.prefix," Expected route to be called ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"path",value:function(e){var t="".concat(this.prefix," Path did not match expected");return this.handlers.push((function(r){var n=r.path;le(n,e,t)})),this}},{key:"url",value:function(e){return this.path(e)}},{key:"header",value:function(e,t){var r="".concat(this.prefix,' Header "').concat(e,'" did not match expected');return this.handlers.push((function(n){le(n.headers&&(n.headers[e]||n.headers[e.toLowerCase()]),t,r)})),this}},{key:"params",value:function(e){var t="".concat(this.prefix," Params did not match expected");return this.handlers.push((function(r){le(r.query||{},e||{},t)})),this}},{key:"query",value:function(e){return this.params(e)}},{key:"body",value:function(e){var t="".concat(this.prefix," Body did not match expected");return this.handlers.push((function(r){le(r.body,e,t)})),this}},{key:"verifier",value:function(e){var t=this;return function(r){r?e(r):t.verify(e)}}},{key:"run",value:function(e){return ue(e)?this.runPromise=e:this.runPromise=new Promise((function(t,r){setTimeout((function(){var n=e((function(e){e?r(e):t()}));ue(n)&&n.then(t).catch(r)}))})),this}},{key:"verify",value:function(e){var t=this,r=function(t){if(!e)throw t;e(t)},n=function(){try{t.assertions.forEach((function(e){return e()})),e&&e()}catch(e){r(e)}};if(this.runPromise)return this.runPromise.then(n).catch(r);n()}}]),e}(),pe=function(){var e=l()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(204!==t.status){e.next=3;break}return e.abrupt("return","");case 3:return e.abrupt("return",t.text()||"");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),de=function(e,t){var r=e&&e.get("Content-Type"),n=null==r?void 0:r.includes("application/json"),o=null==r?void 0:r.includes("application/x-www-form-urlencoded");if(t){if(n)return JSON.parse(t);if(o)return x.a.parse(t)}return t},he=r(22),ve=r.n(he),me=function(e){if(!e)return{};if(e.entries){var t=e.entries();return ve()(i()(t).map((function(e){return[e[0].toLowerCase(),e[1]]})))}if(e.forEach){var r={};return e.forEach((function(e,t){r[t]=e})),r}return{}},ye=function(e){var t=e.url,r=e.scope;"undefined"!=typeof navigator&&navigator.serviceWorker.register(t,{scope:r}).then((function(e){console.log("@mockyeah/fetch service worker registration succeeded.")})).catch((function(e){console.log("@mockyeah/fetch service worker registration failed.",e)}))},ke=function(e){var t;if("undefined"!=typeof navigator&&(null===(t=navigator.serviceWorker)||void 0===t?void 0:t.controller))try{navigator.serviceWorker.controller.postMessage(e)}catch(e){console.error(e)}},xe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},be=["json","text","html","raw","filePath","fixture","status","type","latency","headers"];function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Oe=j()("mockyeah:fetch:mock"),Pe=j()("mockyeah:fetch:hit"),qe=j()("mockyeah:fetch:miss"),_e=j()("mockyeah:fetch:miss:each"),je=j()("mockyeah:fetch:error"),Se=j()("mockyeah:fetch:admin"),Ee=j()("mockyeah:fetch:admin:error"),Te=0,We={},Re={},$e=function(e,t){return we({},g()(e)?e:{url:e},{method:t})},Ce=function(e){var t=e.name,r=void 0===t?"default":t,n=e.noProxy,o=void 0!==n&&n,a=e.prependServerURL,i=void 0!==a&&a,c=e.noPolyfill,s=void 0!==c&&c,u=e.noWebSocket,l=void 0!==u&&u,f=e.host,p=void 0===f?"localhost":f,d=e.port,h=void 0===d?4001:d,v=e.portHttps,m=e.adminHost,y=void 0===m?p:m,k=e.adminPort,x=void 0===k?4777:k,b=e.suiteHeader,g=void 0===b?"x-mockyeah-suite":b,w=e.suiteCookie,O=void 0===w?"mockyeahSuite":w,P=e.latency,q=e.ignorePrefix,_=void 0===q?"http".concat(v?"s":"","://").concat(p,":").concat(v||h,"/"):q,j=e.aliases,S=void 0===j?[]:j,E=e.responseHeaders,T=void 0===E||E,W=e.fetch,R=void 0===W?global.fetch:W,$=e.fileResolver,C=e.fixtureResolver,D=e.mockSuiteResolver,H=e.devTools,I=void 0!==H&&H,M=e.devToolsTimeout,L=void 0===M?2e3:M,F=e.devToolsInterval,N=void 0===F?100:F,U=e.serviceWorker,A=e.serviceWorkerRegister,K=void 0===A?U:A,J=e.serviceWorkerURL,B=void 0===J?"/__mockyeahServiceWorker.js":J,V=e.serviceWorkerScope;return{name:r,noProxy:o,prependServerURL:i,noPolyfill:s,noWebSocket:l,host:p,port:h,portHttps:v,adminHost:y,adminPort:x,suiteHeader:g,suiteCookie:O,latency:P,ignorePrefix:_,aliases:S,responseHeaders:T,fetch:R,fileResolver:$,fixtureResolver:C,mockSuiteResolver:D,devTools:I,devToolsTimeout:L,devToolsInterval:N,serviceWorker:U,serviceWorkerRegister:K,serviceWorkerURL:B,serviceWorkerScope:void 0===V?"/":V}},De=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Re;p()(this,e);var r=Ce(t),n=r.name,o=r.noPolyfill,a=r.aliases,i=r.fetch,c=r.serviceWorker,s=r.serviceWorkerRegister,u=r.serviceWorkerURL,l=r.serviceWorkerScope;this.__private={recording:!1,bootOptions:r,logPrefix:"[".concat(n,"]"),mocks:[],devToolsFound:!1,skipDevToolsCheck:!1};var f=this.__private.logPrefix;if(!i){var d="".concat(f," @mockyeah/fetch requires a fetch implementation");throw je(d),new Error(d)}var h={};(a||[]).forEach((function(e){e.forEach((function(t){h[t]=e}))})),this.__private.aliasReplacements=h,o||(global.fetch=this.fetch.bind(this));var v={all:this.all.bind(this),get:this.get.bind(this),post:this.post.bind(this),put:this.put.bind(this),delete:this.delete.bind(this),options:this.options.bind(this),patch:this.patch.bind(this)};this.methods=v,c&&"undefined"!=typeof window&&(s&&ye({url:u,scope:l}),navigator.serviceWorker.addEventListener("message",(function(e){if(e.data&&"mockyeahRequestReady"===e.data.type){var t=e.data.payload.requestId;We[t]&&We[t]()}})))}var t,r,n;return h()(e,[{key:"fetch",value:(n=l()(o.a.mark((function e(t,r){var n,a,c,u,l,f,p,d,h,v,k,b,w,P,_,j,S,T,W,R,$,C,D,H,I,M,L,F,N,U,A,K,J,B,V,X,z,G,Q,Z,ee,te,re,ne,ae,ie,ce,se,ue,le,fe,pe,he,ve,ye,xe,ge,Oe,Se,Ee,Re=this,$e=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=$e.length>2&&void 0!==$e[2]?$e[2]:{},a=this.__private,c=a.logPrefix,u=a.mocks,l=a.bootOptions,f=a.aliasReplacements,p=a.skipDevToolsCheck,d=l.noWebSocket,h=l.ignorePrefix,v=l.noProxy,k=l.prependServerURL,b=l.suiteCookie,w=l.suiteHeader,P=l.port,_=l.portHttps,j=l.host,S=l.mockSuiteResolver,T=l.fetch,W=l.devTools,R=l.devToolsTimeout,$=l.devToolsInterval,C=l.serviceWorker,D=n.dynamicMocks,H=n.dynamicMockSuite,I=n.noProxy,M=void 0===I?v:I,d){e.next=12;break}return e.prev=5,e.next=8,this.connectWebSocket();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(5);case 12:if(!W||"undefined"==typeof window||p){e.next=18;break}return e.next=15,new Promise((function(e){var t=0,r=setInterval((function(){t+=1,window.__MOCKYEAH_DEVTOOLS_EXTENSION__?(Re.__private.devToolsFound=!0,clearInterval(r),e()):t>R/$&&(Re.__private.skipDevToolsCheck=!0,clearInterval(r),e())}),$)}));case 15:if(!this.__private.devToolsFound){e.next=18;break}return e.next=18,new Promise((function(e){var t=0,r=setInterval((function(){var n;t+=1,(null===(n=window.__MOCKYEAH_DEVTOOLS_EXTENSION__)||void 0===n?void 0:n.loadedMocks)?(clearInterval(r),e()):t>R/$&&(clearInterval(r),e())}),$)}));case 18:if(L="string"==typeof t?t:t.url,F=r||{},N=(D||[]).map((function(e){return e&&Re.makeMock(e[0],e[1],{keepExisting:!0}).mock})).filter(Boolean),U=Object(y.parse)(L),A=F.headers?F.headers instanceof Headers?F.headers:new Headers(F.headers):void 0,!F.body||"string"==typeof F.body){e.next=26;break}return je("".concat(c," @mockyeah/fetch does not yet support non-string request bodies, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:M}));case 26:if(K=A&&de(A,F.body),J=U.query?x.a.parse(U.query):void 0,B=F.method?F.method.toLowerCase():"get",!F.headers||g()(F.headers)){e.next=32;break}return je("".concat(c," @mockyeah/fetch does not yet support non-object request headers, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:M}));case 32:V=F.headers;try{(z=V&&(V.cookie||V.Cookie))?X=q.a.parse(z):"undefined"!=typeof window&&(X=q.a.parse(window.document.cookie))}catch(e){je("".concat(c," @mockyeah/fetch couldn't parse cookies: ").concat(e.message))}if(!(G=H||X&&X[b])||!S){e.next=42;break}return Q=G.split(",").map((function(e){return e.trim()})),Z=Q.map(S),e.next=40,Promise.all(Z);case 40:e.sent.forEach((function(e,t){var r=Q[t];(e.default||e).forEach((function(e){var t=s()(e,2),n=t[0],o=t[1],a=g()(n)?we({},n):{url:n};a.cookies=we({},a.cookies,{mockSuite:function(e){return!!e&&e.split(",").map((function(e){return e.trim()})).includes(r)}}),N.push(Re.makeMock(a,o,{keepExisting:!0}).mock)}))}));case 42:if(ee={url:L.replace(h,""),query:J,headers:V,body:K,method:B,cookies:X},[te=Y(ee,!0)].concat(i()(g()(te)?O()(f&&Object.entries(f).map((function(e){var t=s()(e,2),r=t[0],n=t[1],o=te.url;return"string"==typeof o&&o.replace(/^\//,"").startsWith(r)?n.map((function(e){return we({},te,{url:o.replace(r,e)})})):[]}))):[])).filter(Boolean).find((function(e){return[].concat(i()((N||[]).filter(Boolean)),i()(u)).find((function(t){var r=Y(t[0]),n=E()(e,r,{skipKeys:["$meta"]});return n.result?(re=t,!0):(_e("".concat(c," @mockyeah/fetch missed mock for"),L,n.message,{request:ee}),!1)}))})),ne="".concat(U.protocol?"".concat(U.protocol,"//"):"").concat(U.host||"").concat(U.pathname||"/"),ae={url:ne,path:ne,query:J,method:B,headers:V,body:K,cookies:X},!re){e.next=72;break}if(re[0]&&re[0].$meta&&re[0].$meta.expectation&&re[0].$meta.expectation.request(ae),!(ce=re[1])||!be.some((function(e){return"function"==typeof ce[e]&&ce[e].length>1}))){e.next=62;break}return e.next=54,this.fallbackFetch(L,F);case 54:return se=e.sent,e.t1=de,e.t2=se.headers,e.next=59,se.text();case 59:e.t3=e.sent,ue=(0,e.t1)(e.t2,e.t3),ie={status:se.status,body:ue,headers:me(se.headers)};case 62:return e.next=64,oe(re,ae,l,ie);case 64:return le=e.sent,fe=le.response,pe=le.json,he=le.body,ve=le.headers,C&&(ye={status:fe.status,body:he,headers:ve},ke({type:"mockyeahRequest",payload:{requestId:xe=Te+=1,request:ae,response:ye}}),We[xe]=function(){T(L,we({},F,{headers:we({},F.headers,{"x-mockyeah-service-worker-request":xe})}))}),Pe("".concat(c," @mockyeah/fetch matched mock for"),L,{request:ae,response:fe,json:pe,mock:re}),e.abrupt("return",fe);case 72:return qe("".concat(c," @mockyeah/fetch missed all mocks for"),L,{request:ae}),ge="http".concat(_?"s":"","://").concat(j,":").concat(_||P),Oe=F,k&&ge&&(L="".concat(ge,"/").concat(L.replace("://","~~~")),"undefined"!=typeof document&&(Ee=document.cookie.match("\\b".concat(b,"=([^;]+)\\b")),Se=Ee&&Ee[1]),Oe=we({},F,{headers:we({},F.headers,{},Se&&m()({},w,Se))})),e.abrupt("return",this.fallbackFetch(L,Oe,{noProxy:M}));case 77:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e,t){return n.apply(this,arguments)})},{key:"fallbackFetch",value:(r=l()(o.a.mark((function e(t,r){var n,a,i,c,s,u,l,f,p,d,h,v,m,y,k,x,b,g,w,O,P=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=P.length>2&&void 0!==P[2]?P[2]:{},a=n.noProxy,i=this.__private.bootOptions,c=i.responseHeaders,s=i.fetch,u="string"==typeof t?t:t.url,!a&&u.startsWith("http")){e.next=8;break}return l={},c&&(l["x-mockyeah-missed"]="true"),e.abrupt("return",new Response("",{status:404,headers:l}));case 8:return f=(new Date).getTime(),e.next=11,s(t,r);case 11:return p=e.sent,e.next=14,pe(p);case 14:return d=e.sent,h=this.__private,v=h.ws,h.recording&&(m=p.status,y=me(p.headers),v&&(k={type:"recordPush",payload:{reqUrl:u,req:{method:r&&r.method,body:r&&r.body},startTime:f,body:d,headers:y,status:m}},v.send(JSON.stringify(k)))),c&&(b=(x=p).status,g=x.statusText,w=x.headers,(O=w&&new Headers(w))&&(O.set("x-mockyeah-proxied","true"),O.set("x-mockyeah-missed","true")),p=new Response(d,{headers:O,status:b,statusText:g})),e.abrupt("return",p);case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"expect",value:function(e){return this.all("*").expect(e)}},{key:"all",value:function(e,t){return this.mock(e,t)}},{key:"get",value:function(e,t){return this.mock($e(e,"get"),t)}},{key:"post",value:function(e,t){return this.mock($e(e,"post"),t)}},{key:"put",value:function(e,t){return this.mock($e(e,"put"),t)}},{key:"delete",value:function(e,t){return this.mock($e(e,"delete"),t)}},{key:"options",value:function(e,t){return this.mock($e(e,"options"),t)}},{key:"patch",value:function(e,t){return this.mock($e(e,"patch"),t)}},{key:"reset",value:function(){this.__private.mocks=[]}},{key:"makeMock",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.keepExisting,a=Y(e),i=this.__private.mocks,c=[];if(!o){var s,u=i.findIndex((function(e){return Q(a,e[0])}));if(u>=0)r=null!==(s=r)&&void 0!==s?s:u,c.push(i[u]),i.splice(u,1)}var l="string"==typeof t?{text:t}:t;return l=l||{status:200},a.$meta&&(a.$meta.expectation=new fe(a),a.$meta.id=xe()),{mock:[a,l],removed:c,removedIndex:r}}},{key:"mock",value:function(e,t){var r,n=this.makeMock(e,t),o=n.mock,a=n.removed,i=n.removedIndex,c=null===(r=o[0].$meta)||void 0===r?void 0:r.id,s=this.__private,u=s.mocks,l=s.logPrefix;Oe("".concat(l," mocked"),e,t),null!=i?u.splice(i,0,o):u.push(o);var f=o[0].$meta&&o[0].$meta.expectation,p=a.map((function(e){var t,r;return null===(t=e[0])||void 0===t?void 0:null===(r=t.$meta)||void 0===r?void 0:r.id})),d=f.api.bind(f);return{id:c,removedIds:p,expect:function(e){return d(e)}}}},{key:"unmock",value:function(e){var t=this.__private,r=t.mocks,n=t.logPrefix,o=r.findIndex((function(t){var r;return(null===(r=t[0].$meta)||void 0===r?void 0:r.id)===e}));return-1===o?(Oe("".concat(n," didn't find id to unmock"),e),!1):(r.splice(o,1),Oe("".concat(n," unmocked"),e),!0)}},{key:"connectWebSocket",value:(t=l()(o.a.mark((function e(){var t,r,n,a,i=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof WebSocket){e.next=2;break}return e.abrupt("return");case 2:if(!this.__private.ws){e.next=4;break}return e.abrupt("return");case 4:t=this.__private.bootOptions,r=t.adminPort,n=t.adminHost,a="ws://".concat(n,":").concat(r),Se("WebSocket trying to connect to '".concat(a,"'.")),e.prev=7,this.__private.ws=new WebSocket(a),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(7),Ee("WebSocket couldn't connect to '".concat(a,"':"),e.t0),delete this.__private.ws,e.t0;case 16:return e.next=18,new Promise((function(e,t){var r=i.__private.ws;r&&(r.onopen=function(){Se("WebSocket opened"),r.send(JSON.stringify({type:"opened"})),e()},r.onerror=function(e){Ee("WebSocket errored",e),t(e)},r.onclose=function(){Ee("WebSocket closed"),i.__private.recording=!1,delete i.__private.ws,t(new Error("WebSocket closed"))},r.onmessage=function(e){var t;Se("WebSocket message",e);try{t=JSON.parse(e.data)}catch(t){return void Ee("Couldn't parse WebSocket message data '".concat(e.data,"':"),t)}t&&(Se("WebSocket action",t),"record"===t.type?i.__private.recording=!0:"recordStop"===t.type&&(i.__private.recording=!1))})}));case 18:case"end":return e.stop()}}),e,this,[[7,11]])}))),function(){return t.apply(this,arguments)})}]),e}();t.default=De}]).default;
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t){e.exports=require("@babel/runtime/regenerator")},function(e,t){e.exports=require("lodash/isPlainObject")},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("debug")},function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t){e.exports=require("qs")},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("match-deep")},function(e,t){e.exports=require("lodash/isEmpty")},function(e,t){e.exports=require("lodash/isEqual")},function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},function(e,t){e.exports=require("cookie")},function(e,t){e.exports=require("lodash/isRegExp")},function(e,t){e.exports=require("lodash/mapValues")},function(e,t){e.exports=require("lodash/flatten")},function(e,t){e.exports=require("path-to-regexp")},function(e,t){e.exports=require("mime")},function(e,t){e.exports=require("@babel/runtime/helpers/typeof")},function(e,t){e.exports=require("lodash/fromPairs")},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(7),i=r.n(a),c=r(8),s=r.n(c),u=r(3),l=r.n(u),f=r(13),p=r.n(f),d=r(14),h=r.n(d),v=r(5),m=r.n(v),y=r(9),k=r(6),x=r.n(k),b=r(1),g=r.n(b),w=r(18),O=r.n(w),P=r(15),_=r.n(P),q=r(4),S=r.n(q),j=r(10),E=r.n(j),W=r(19),T=r.n(W),$=r(11),R=r.n($),D=r(16),C=r.n(D),H=r(17),I=r.n(H);function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F=/^(\/?https?.{3}[^/:?]+):/,N=/^(\/?https?).{3}/,U=/^(\/?https?.{3}[^/:?]+)~/,A=/^(\/?https?).{3}/,K=function(e){return e.replace(A,"$1://").replace(U,"$1:")},J=function(e){return e.replace(F,"$1~").replace(N,"$1~~~")},B=/^\//,V=/^(https?)%3A%2F%2F/,X=function(e){return/^\/+https?[:~][/~]{2}/.test(e)?K(function(e){return e.replace(B,"")}(e).replace(V,(function(e,t){return"".concat(t,"://")}))):e},Y=function(e,t){if("function"==typeof e)return e;var r,n=g()(e)?L({},e):e;(r=g()(e)?L({},e):{url:e}).query=R()(r.query)?void 0:r.query,r.headers=R()(r.headers)?void 0:Object.entries(r.headers).reduce((function(e,t){var r=s()(t,2),n=r[0],o=r[1];return e[n.toLowerCase()]=o,e}),{}),r.method&&"all"!==r.method&&"ALL"!==r.method&&"*"!==r.method?"string"==typeof r.method&&(r.method=r.method.toLowerCase()):delete r.method;var o=L({},r.$meta||{});if(r.path&&(r.url=r.path,delete r.path),"*"===r.url&&delete r.url,"string"==typeof r.url){r.url=X(r.url);var a=function(e){var t;return/^https?:/.test(e)?(t=Object(y.parse)(e),e="".concat(t.protocol||"http:","//").concat(t.hostname).concat(t.port&&!["80","443"].includes(t.port)?":".concat(t.port):"").concat(t.pathname)):(t=Object(y.parse)("http://example.com".concat(e.startsWith("/")?e:"/".concat(e))),e=t.pathname||""),{url:e,query:t.query?x.a.parse(t.query):void 0}}(r.url);r.url=a.url.replace(/\/+$/,"")||"/",r.query=g()(r.query)?L({},a.query,{},r.query):r.query||a.query}R()(r.query)&&delete r.query,R()(r.cookies)&&delete r.cookies;var i=L({},r);r.url||(i.url="*"),o.original=n,o.originalNormal=i,o.originalSerialized=function e(t){return I()(t,(function(t){return C()(t)?{$regex:{source:t.source,flags:t.flags}}:g()(t)?I()(t,(function(t){return e(t)})):t}))}(i);var c=r.url;if("string"==typeof r.url){if(!t){var u=[],l=T()(J(r.url),u);r.url=function(e){return l.test(J(e)||J("/".concat(e)))},o.regex=l,o.matchKeys=u,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return'"'.concat(null==c?void 0:c.toString(),'"')}}}else if(C()(r.url)){if(!t){var f=r.url;r.url=function(e){return f.test(K(e))||f.test(K("/".concat(e)))},o.regex=f,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return null==c?void 0:c.toString()}}}else if("function"==typeof r.url){var p=r.url;r.url=function(e){return p(e)||p("/".concat(e))}}return L({},r,{$meta:o})},z=r(12),G=r.n(z),Q=function(e,t){var r=e.$meta?e.$meta.originalNormal:void 0,n=t.$meta?t.$meta.originalNormal:void 0;return g()(r)&&g()(n)?!(!r||!n)&&(r.url===n.url&&r.path===n.path&&r.method===n.method&&G()(r.query,n.query)&&G()(r.body,n.body)&&G()(r.headers,n.headers)&&G()(r.cookies,n.cookies)):r===n},Z=r(20),ee=r.n(Z);function te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?te(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ne=function(e,t,r){return"function"==typeof e?e(t,r):e},oe=function(){var e=l()(o.a.mark((function e(t,r,n,a){var i,c,s,u,l,f,p,d,h,v,m,y,k,x,b,g;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.responseHeaders,c=n.fixtureResolver,s=n.fileResolver,u=t[1]||{},e.t1=u.status,!e.t1){e.next=7;break}return e.next=6,ne(u.status,r,a);case 6:e.t1=e.sent;case 7:if(e.t0=e.t1,e.t0){e.next=10;break}e.t0=200;case 10:if(l=e.t0,e.t2=u.type,!e.t2){e.next=16;break}return e.next=15,ne(u.type,r,a);case 15:e.t2=e.sent;case 16:if(p=e.t2,!u.fixture){e.next=34;break}if(c){e.next=20;break}throw new Error("Using `fixture` in mock response options requires a `fixtureResolver`.");case 20:return e.next=22,ne(u.fixture,r,a);case 22:if(v=e.sent,p=p||v,!v){e.next=30;break}return e.next=27,c(v);case 27:e.t3=e.sent,e.next=31;break;case 30:e.t3=void 0;case 31:f=e.t3,e.next=78;break;case 34:if(!u.filePath){e.next=51;break}if(s){e.next=37;break}throw new Error("Using `filePath` in mock response options requires a `fileResolver`.");case 37:return e.next=39,ne(u.filePath,r,a);case 39:if(m=e.sent,p=p||m,!m){e.next=47;break}return e.next=44,s(m);case 44:e.t4=e.sent,e.next=48;break;case 47:e.t4=void 0;case 48:f=e.t4,e.next=78;break;case 51:if(!u.json){e.next=59;break}return e.next=54,ne(u.json,r,a);case 54:h=e.sent,f=JSON.stringify(h),d="application/json; charset=UTF-8",e.next=78;break;case 59:if(!u.text){e.next=66;break}return e.next=62,ne(u.text,r,a);case 62:f=e.sent,d="text/plain; charset=UTF-8",e.next=78;break;case 66:if(!u.html){e.next=73;break}return e.next=69,ne(u.html,r,a);case 69:f=e.sent,d="text/html; charset=UTF-8",e.next=78;break;case 73:if(!u.raw){e.next=78;break}return e.next=76,ne(u.raw,r,a);case 76:f=e.sent,d=void 0;case 78:if(f=f||"",d=p?ee.a.getType(p)||p:d,!u.headers){e.next=89;break}return e.t6=re,e.t7={},e.next=85,ne(u.headers,r,a);case 85:e.t8=e.sent,e.t5=(0,e.t6)(e.t7,e.t8),e.next=90;break;case 89:e.t5={};case 90:if(y=e.t5,i&&(y["x-mockyeah-mocked"]="true"),d&&(y["content-type"]=d),k={status:l,headers:y},!(x=u.latency||n.latency)){e.next=101;break}return e.next=98,ne(x,r,a);case 98:return b=e.sent,e.next=101,new Promise((function(e){return setTimeout(e,b)}));case 101:return g=new Response(f,k),e.abrupt("return",{response:g,body:f,headers:y,json:h});case 103:case"end":return e.stop()}}),e)})));return function(t,r,n,o){return e.apply(this,arguments)}}(),ae=r(21),ie=r.n(ae),ce=r(2),se=r.n(ce),ue=function(e){return e&&(e instanceof Promise||!(!e.then||!e.catch))},le=function(e,t,r){var n=E()(e,t,{skipKeys:["$meta"]}),o=n.result,a=n.message;se()(o,"".concat(r,": ").concat(a))},fe=function(){function e(t){p()(this,e);var r=t.$meta&&t.$meta.originalNormal?t.$meta.originalNormal:t;this.prefix="[".concat(r.method||"all","] ").concat(r.path||r.url," --"),this.called=0,this.assertions=[],this.handlers=[],this.verifier=this.verifier.bind(this),this.run=this.run.bind(this),this.verify=this.verify.bind(this)}return h()(e,[{key:"request",value:function(e){var t=this;this.called+=1,this.handlers.forEach((function(r){t.assertions.push(r.bind(t,e))}))}},{key:"api",value:function(e){var t=this;if("function"==typeof e){var r=e;this.handlers.push((function(e){try{var n=r(e);if(void 0!==n&&!n)throw new Error("function returned false")}catch(e){var o="".concat(t.prefix," Expect function did not match").concat(e&&e.message?": ".concat(e.message):"");se()(!1,o)}}))}else if("object"===ie()(e)){var n=Y(e);this.handlers.push((function(e){var t=E()(e,n,{skipKeys:["$meta"]}),r=t.result,o=t.message;se()(r,"Expect object did not match: ".concat(o))}))}return this}},{key:"atLeast",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called>=e,"".concat(t.prefix," Expected route to be called at least ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"atMost",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called<=e,"".concat(t.prefix," Expected route to be called at most ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"never",value:function(){var e=this;return this.assertions.push((function(){se()(0===e.called,"".concat(e.prefix," Expected route to be called never, but it was called ").concat(e.called," times"))})),this}},{key:"once",value:function(){var e=this;return this.assertions.push((function(){se()(1===e.called,"".concat(e.prefix," Expected route to be called once, but it was called ").concat(e.called," times"))})),this}},{key:"twice",value:function(){var e=this;return this.assertions.push((function(){se()(2===e.called,"".concat(e.prefix," Expected route to be called twice, but it was called ").concat(e.called," times"))})),this}},{key:"thrice",value:function(){var e=this;return this.assertions.push((function(){se()(3===e.called,"".concat(e.prefix," Expected route to be called thrice, but it was called ").concat(e.called," times"))})),this}},{key:"exactly",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called===e,"".concat(t.prefix," Expected route to be called ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"path",value:function(e){var t="".concat(this.prefix," Path did not match expected");return this.handlers.push((function(r){var n=r.path;le(n,e,t)})),this}},{key:"url",value:function(e){return this.path(e)}},{key:"header",value:function(e,t){var r="".concat(this.prefix,' Header "').concat(e,'" did not match expected');return this.handlers.push((function(n){le(n.headers&&(n.headers[e]||n.headers[e.toLowerCase()]),t,r)})),this}},{key:"params",value:function(e){var t="".concat(this.prefix," Params did not match expected");return this.handlers.push((function(r){le(r.query||{},e||{},t)})),this}},{key:"query",value:function(e){return this.params(e)}},{key:"body",value:function(e){var t="".concat(this.prefix," Body did not match expected");return this.handlers.push((function(r){le(r.body,e,t)})),this}},{key:"verifier",value:function(e){var t=this;return function(r){r?e(r):t.verify(e)}}},{key:"run",value:function(e){return ue(e)?this.runPromise=e:this.runPromise=new Promise((function(t,r){setTimeout((function(){var n=e((function(e){e?r(e):t()}));ue(n)&&n.then(t).catch(r)}))})),this}},{key:"verify",value:function(e){var t=this,r=function(t){if(!e)throw t;e(t)},n=function(){try{t.assertions.forEach((function(e){return e()})),e&&e()}catch(e){r(e)}};if(this.runPromise)return this.runPromise.then(n).catch(r);n()}}]),e}(),pe=function(){var e=l()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(204!==t.status){e.next=3;break}return e.abrupt("return","");case 3:return e.abrupt("return",t.text()||"");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),de=function(e,t){var r=e&&e.get("Content-Type"),n=null==r?void 0:r.includes("application/json"),o=null==r?void 0:r.includes("application/x-www-form-urlencoded");if(t){if(n)return JSON.parse(t);if(o)return x.a.parse(t)}return t},he=r(22),ve=r.n(he),me=function(e){if(!e)return{};if(e.entries){var t=e.entries();return ve()(i()(t).map((function(e){return[e[0].toLowerCase(),e[1]]})))}if(e.forEach){var r={};return e.forEach((function(e,t){r[t]=e})),r}return{}},ye=function(e){var t=e.url,r=e.scope;"undefined"!=typeof navigator&&navigator.serviceWorker.register(t,{scope:r}).then((function(e){console.log("@mockyeah/fetch service worker registration succeeded.")})).catch((function(e){console.log("@mockyeah/fetch service worker registration failed.",e)}))},ke=function(e){var t;if("undefined"!=typeof navigator&&(null===(t=navigator.serviceWorker)||void 0===t?void 0:t.controller))try{navigator.serviceWorker.controller.postMessage(e)}catch(e){console.error(e)}},xe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},be=["json","text","html","raw","filePath","fixture","status","type","latency","headers"];function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Oe=S()("mockyeah:fetch:mock"),Pe=S()("mockyeah:fetch:hit"),_e=S()("mockyeah:fetch:miss"),qe=S()("mockyeah:fetch:miss:each"),Se=S()("mockyeah:fetch:error"),je=S()("mockyeah:fetch:admin"),Ee=S()("mockyeah:fetch:admin:error"),We=0,Te={},$e={},Re=function(e,t){return we({},g()(e)?e:{url:e},{method:t})},De=function(e){var t=e.name,r=void 0===t?"default":t,n=e.noProxy,o=void 0!==n&&n,a=e.prependServerURL,i=void 0!==a&&a,c=e.noPolyfill,s=void 0!==c&&c,u=e.noWebSocket,l=void 0!==u&&u,f=e.host,p=void 0===f?"localhost":f,d=e.port,h=void 0===d?4001:d,v=e.portHttps,m=e.adminHost,y=void 0===m?p:m,k=e.adminPort,x=void 0===k?4777:k,b=e.suiteHeader,g=void 0===b?"x-mockyeah-suite":b,w=e.suiteCookie,O=void 0===w?"mockyeahSuite":w,P=e.latency,_=e.ignorePrefix,q=void 0===_?"http".concat(v?"s":"","://").concat(p,":").concat(v||h,"/"):_,S=e.aliases,j=void 0===S?[]:S,E=e.responseHeaders,W=void 0===E||E,T=e.fetch,$=void 0===T?global.fetch:T,R=e.fileResolver,D=e.fixtureResolver,C=e.mockSuiteResolver,H=e.devTools,I=void 0!==H&&H,M=e.devToolsTimeout,L=void 0===M?2e3:M,F=e.devToolsInterval,N=void 0===F?100:F,U=e.serviceWorker,A=e.serviceWorkerRegister,K=void 0===A?U:A,J=e.serviceWorkerURL,B=void 0===J?"/__mockyeahServiceWorker.js":J,V=e.serviceWorkerScope;return{name:r,noProxy:o,prependServerURL:i,noPolyfill:s,noWebSocket:l,host:p,port:h,portHttps:v,adminHost:y,adminPort:x,suiteHeader:g,suiteCookie:O,latency:P,ignorePrefix:q,aliases:j,responseHeaders:W,fetch:$,fileResolver:R,fixtureResolver:D,mockSuiteResolver:C,devTools:I,devToolsTimeout:L,devToolsInterval:N,serviceWorker:U,serviceWorkerRegister:K,serviceWorkerURL:B,serviceWorkerScope:void 0===V?"/":V}},Ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$e;p()(this,e);var r=De(t),n=r.name,o=r.noPolyfill,a=r.aliases,i=r.fetch,c=r.serviceWorker,s=r.serviceWorkerRegister,u=r.serviceWorkerURL,l=r.serviceWorkerScope;this.__private={recording:!1,bootOptions:r,logPrefix:"[".concat(n,"]"),mocks:[],devToolsFound:!1,skipDevToolsCheck:!1};var f=this.__private.logPrefix;if(!i){var d="".concat(f," @mockyeah/fetch requires a fetch implementation");throw Se(d),new Error(d)}var h={};(a||[]).forEach((function(e){e.forEach((function(t){h[t]=e}))})),this.__private.aliasReplacements=h,o||(global.fetch=this.fetch.bind(this));var v={all:this.all.bind(this),get:this.get.bind(this),post:this.post.bind(this),put:this.put.bind(this),delete:this.delete.bind(this),options:this.options.bind(this),patch:this.patch.bind(this)};this.methods=v,c&&"undefined"!=typeof window&&(s&&ye({url:u,scope:l}),navigator.serviceWorker.addEventListener("message",(function(e){if(e.data&&"mockyeahServiceWorkerDataRequest"===e.data.type){var t=(e.data.payload||{}).requestId;if(!t)return;if(Te[t]){var r={type:"mockyeahServiceWorkerDataResponse",payload:{requestId:t,response:Te[t].response}};ke(r)}}})))}var t,r,n;return h()(e,[{key:"fetch",value:(n=l()(o.a.mark((function e(t,r){var n,a,c,u,l,f,p,d,h,v,k,b,w,P,q,S,j,W,T,$,R,D,C,H,I,M,L,F,N,U,A,K,J,B,V,X,z,G,Q,Z,ee,te,re,ne,ae,ie,ce,se,ue,le,fe,pe,he,ve,ye,ke,xe,ge,Oe,je,Ee=this,$e=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=$e.length>2&&void 0!==$e[2]?$e[2]:{},a=this.__private,c=a.logPrefix,u=a.mocks,l=a.bootOptions,f=a.aliasReplacements,p=a.skipDevToolsCheck,d=l.noWebSocket,h=l.ignorePrefix,v=l.noProxy,k=l.prependServerURL,b=l.suiteCookie,w=l.suiteHeader,P=l.port,q=l.portHttps,S=l.host,j=l.mockSuiteResolver,W=l.fetch,T=l.devTools,$=l.devToolsTimeout,R=l.devToolsInterval,D=l.serviceWorker,C=n.dynamicMocks,H=n.dynamicMockSuite,I=n.noProxy,M=void 0===I?v:I,d){e.next=12;break}return e.prev=5,e.next=8,this.connectWebSocket();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(5);case 12:if(!T||"undefined"==typeof window||p){e.next=18;break}return e.next=15,new Promise((function(e){var t=0,r=setInterval((function(){t+=1,window.__MOCKYEAH_DEVTOOLS_EXTENSION__?(Ee.__private.devToolsFound=!0,clearInterval(r),e()):t>$/R&&(Ee.__private.skipDevToolsCheck=!0,clearInterval(r),e())}),R)}));case 15:if(!this.__private.devToolsFound){e.next=18;break}return e.next=18,new Promise((function(e){var t=0,r=setInterval((function(){var n;t+=1,(null===(n=window.__MOCKYEAH_DEVTOOLS_EXTENSION__)||void 0===n?void 0:n.loadedMocks)?(clearInterval(r),e()):t>$/R&&(clearInterval(r),e())}),R)}));case 18:if(L="string"==typeof t?t:t.url,F=r||{},N=(C||[]).map((function(e){return e&&Ee.makeMock(e[0],e[1],{keepExisting:!0}).mock})).filter(Boolean),U=Object(y.parse)(L),A=F.headers?F.headers instanceof Headers?F.headers:new Headers(F.headers):void 0,!F.body||"string"==typeof F.body){e.next=26;break}return Se("".concat(c," @mockyeah/fetch does not yet support non-string request bodies, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:M}));case 26:if(K=A&&de(A,F.body),J=U.query?x.a.parse(U.query):void 0,B=F.method?F.method.toLowerCase():"get",!F.headers||g()(F.headers)){e.next=32;break}return Se("".concat(c," @mockyeah/fetch does not yet support non-object request headers, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:M}));case 32:V=F.headers;try{(z=V&&(V.cookie||V.Cookie))?X=_.a.parse(z):"undefined"!=typeof window&&(X=_.a.parse(window.document.cookie))}catch(e){Se("".concat(c," @mockyeah/fetch couldn't parse cookies: ").concat(e.message))}if(!(G=H||X&&X[b])||!j){e.next=42;break}return Q=G.split(",").map((function(e){return e.trim()})),Z=Q.map(j),e.next=40,Promise.all(Z);case 40:e.sent.forEach((function(e,t){var r=Q[t];(e.default||e).forEach((function(e){var t=s()(e,2),n=t[0],o=t[1],a=g()(n)?we({},n):{url:n};a.cookies=we({},a.cookies,{mockSuite:function(e){return!!e&&e.split(",").map((function(e){return e.trim()})).includes(r)}}),N.push(Ee.makeMock(a,o,{keepExisting:!0}).mock)}))}));case 42:if(ee={url:L.replace(h,""),query:J,headers:V,body:K,method:B,cookies:X},[te=Y(ee,!0)].concat(i()(g()(te)?O()(f&&Object.entries(f).map((function(e){var t=s()(e,2),r=t[0],n=t[1],o=te.url;return"string"==typeof o&&o.replace(/^\//,"").startsWith(r)?n.map((function(e){return we({},te,{url:o.replace(r,e)})})):[]}))):[])).filter(Boolean).find((function(e){return[].concat(i()((N||[]).filter(Boolean)),i()(u)).find((function(t){var r=Y(t[0]),n=E()(e,r,{skipKeys:["$meta"]});return n.result?(re=t,!0):(qe("".concat(c," @mockyeah/fetch missed mock for"),L,n.message,{request:ee}),!1)}))})),ne="".concat(U.protocol?"".concat(U.protocol,"//"):"").concat(U.host||"").concat(U.pathname||"/"),ae={url:ne,path:ne,query:J,method:B,headers:V,body:K,cookies:X},!re){e.next=72;break}if(re[0]&&re[0].$meta&&re[0].$meta.expectation&&re[0].$meta.expectation.request(ae),!(ce=re[1])||!be.some((function(e){return"function"==typeof ce[e]&&ce[e].length>1}))){e.next=62;break}return e.next=54,this.fallbackFetch(L,F);case 54:return se=e.sent,e.t1=de,e.t2=se.headers,e.next=59,se.text();case 59:e.t3=e.sent,ue=(0,e.t1)(e.t2,e.t3),ie={status:se.status,body:ue,headers:me(se.headers)};case 62:return e.next=64,oe(re,ae,l,ie);case 64:return le=e.sent,fe=le.response,pe=le.json,he=le.body,ve=le.headers,D&&(ye={status:fe.status,body:he,headers:ve},Te[ke=We+=1]={response:ye},W(L,we({},F,{headers:we({},F.headers,{"x-mockyeah-service-worker-request":ke})}))),Pe("".concat(c," @mockyeah/fetch matched mock for"),L,{request:ae,response:fe,json:pe,mock:re}),e.abrupt("return",fe);case 72:return _e("".concat(c," @mockyeah/fetch missed all mocks for"),L,{request:ae}),xe="http".concat(q?"s":"","://").concat(S,":").concat(q||P),ge=F,k&&xe&&(L="".concat(xe,"/").concat(L.replace("://","~~~")),"undefined"!=typeof document&&(je=document.cookie.match("\\b".concat(b,"=([^;]+)\\b")),Oe=je&&je[1]),ge=we({},F,{headers:we({},F.headers,{},Oe&&m()({},w,Oe))})),e.abrupt("return",this.fallbackFetch(L,ge,{noProxy:M}));case 77:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e,t){return n.apply(this,arguments)})},{key:"fallbackFetch",value:(r=l()(o.a.mark((function e(t,r){var n,a,i,c,s,u,l,f,p,d,h,v,m,y,k,x,b,g,w,O,P=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=P.length>2&&void 0!==P[2]?P[2]:{},a=n.noProxy,i=this.__private.bootOptions,c=i.responseHeaders,s=i.fetch,u="string"==typeof t?t:t.url,!a&&u.startsWith("http")){e.next=8;break}return l={},c&&(l["x-mockyeah-missed"]="true"),e.abrupt("return",new Response("",{status:404,headers:l}));case 8:return f=(new Date).getTime(),e.next=11,s(t,r);case 11:return p=e.sent,e.next=14,pe(p);case 14:return d=e.sent,h=this.__private,v=h.ws,h.recording&&(m=p.status,y=me(p.headers),v&&(k={type:"recordPush",payload:{reqUrl:u,req:{method:r&&r.method,body:r&&r.body},startTime:f,body:d,headers:y,status:m}},v.send(JSON.stringify(k)))),c&&(b=(x=p).status,g=x.statusText,w=x.headers,(O=w&&new Headers(w))&&(O.set("x-mockyeah-proxied","true"),O.set("x-mockyeah-missed","true")),p=new Response(d,{headers:O,status:b,statusText:g})),e.abrupt("return",p);case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"expect",value:function(e){return this.all("*").expect(e)}},{key:"all",value:function(e,t){return this.mock(e,t)}},{key:"get",value:function(e,t){return this.mock(Re(e,"get"),t)}},{key:"post",value:function(e,t){return this.mock(Re(e,"post"),t)}},{key:"put",value:function(e,t){return this.mock(Re(e,"put"),t)}},{key:"delete",value:function(e,t){return this.mock(Re(e,"delete"),t)}},{key:"options",value:function(e,t){return this.mock(Re(e,"options"),t)}},{key:"patch",value:function(e,t){return this.mock(Re(e,"patch"),t)}},{key:"reset",value:function(){this.__private.mocks=[]}},{key:"makeMock",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.keepExisting,a=Y(e),i=this.__private.mocks,c=[];if(!o){var s,u=i.findIndex((function(e){return Q(a,e[0])}));if(u>=0)r=null!==(s=r)&&void 0!==s?s:u,c.push(i[u]),i.splice(u,1)}var l="string"==typeof t?{text:t}:t;return l=l||{status:200},a.$meta&&(a.$meta.expectation=new fe(a),a.$meta.id=xe()),{mock:[a,l],removed:c,removedIndex:r}}},{key:"mock",value:function(e,t){var r,n=this.makeMock(e,t),o=n.mock,a=n.removed,i=n.removedIndex,c=null===(r=o[0].$meta)||void 0===r?void 0:r.id,s=this.__private,u=s.mocks,l=s.logPrefix;Oe("".concat(l," mocked"),e,t),null!=i?u.splice(i,0,o):u.push(o);var f=o[0].$meta&&o[0].$meta.expectation,p=a.map((function(e){var t,r;return null===(t=e[0])||void 0===t?void 0:null===(r=t.$meta)||void 0===r?void 0:r.id})),d=f.api.bind(f);return{id:c,removedIds:p,expect:function(e){return d(e)}}}},{key:"unmock",value:function(e){var t=this.__private,r=t.mocks,n=t.logPrefix,o=r.findIndex((function(t){var r;return(null===(r=t[0].$meta)||void 0===r?void 0:r.id)===e}));return-1===o?(Oe("".concat(n," didn't find id to unmock"),e),!1):(r.splice(o,1),Oe("".concat(n," unmocked"),e),!0)}},{key:"connectWebSocket",value:(t=l()(o.a.mark((function e(){var t,r,n,a,i=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof WebSocket){e.next=2;break}return e.abrupt("return");case 2:if(!this.__private.ws){e.next=4;break}return e.abrupt("return");case 4:t=this.__private.bootOptions,r=t.adminPort,n=t.adminHost,a="ws://".concat(n,":").concat(r),je("WebSocket trying to connect to '".concat(a,"'.")),e.prev=7,this.__private.ws=new WebSocket(a),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(7),Ee("WebSocket couldn't connect to '".concat(a,"':"),e.t0),delete this.__private.ws,e.t0;case 16:return e.next=18,new Promise((function(e,t){var r=i.__private.ws;r&&(r.onopen=function(){je("WebSocket opened"),r.send(JSON.stringify({type:"opened"})),e()},r.onerror=function(e){Ee("WebSocket errored",e),t(e)},r.onclose=function(){Ee("WebSocket closed"),i.__private.recording=!1,delete i.__private.ws,t(new Error("WebSocket closed"))},r.onmessage=function(e){var t;je("WebSocket message",e);try{t=JSON.parse(e.data)}catch(t){return void Ee("Couldn't parse WebSocket message data '".concat(e.data,"':"),t)}t&&(je("WebSocket action",t),"record"===t.type?i.__private.recording=!0:"recordStop"===t.type&&(i.__private.recording=!1))})}));case 18:case"end":return e.stop()}}),e,this,[[7,11]])}))),function(){return t.apply(this,arguments)})}]),e}();t.default=Ce}]).default;

@@ -1,1 +0,1 @@

!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){t.exports=r(2)},function(t,e){function r(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=w(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=u(t,e,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===s)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function f(){}function h(){}function l(){}var p={};p[o]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(E([])));v&&v!==e&&r.call(v,o)&&(p=v);var y=l.prototype=f.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function m(t){var e;this._invoke=function(n,o){function i(){return new Promise((function(e,i){!function e(n,o,i,a){var c=u(t[n],t,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(n,o,e,i)}))}return e=e?e.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return h.prototype=y.constructor=l,l.constructor=h,l[a]=h.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(m.prototype),m.prototype[i]=function(){return this},t.AsyncIterator=m,t.async=function(e,r,n,o){var i=new m(c(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(y),y[a]="Generator",y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(0),o=r.n(n),i=r(1),a=r.n(i),c={},u=function(t){var e=t.event,r=e.request,n=e.clientId;if(r.headers){var o=r.headers.get("x-mockyeah-service-worker-request"),i=c[n];if(i){var a=i.requests;if(a)return a[o]}}},s=function(t){var e=t.event;try{var r=u({event:e}).response,n=r.status,o=r.body,i=r.headers,a=new Response(o,{status:n,headers:i});return function(t){var e=t.event,r=e.request,n=e.clientId,o=r.headers.get("x-mockyeah-service-worker-request"),i=c[n];if(i){var a=i.requests;a&&(delete a[o],0===Object.keys(a).length&&delete i[n])}}({event:e}),a}catch(t){return console.log("@mockyeah/fetch service worker handler error",t),fetch(e.request)}};self.addEventListener("message",function(){var t=a()(o.a.mark((function t(e){var r,n,i,a,u,s,f;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.data||"mockyeahRequest"!==e.data.type){t.next=12;break}if(r=e.data,n=(r=void 0===r?{}:r).payload,i=n.requestId,a=n.request,u=n.response,s=e.source,i){t.next=6;break}return t.abrupt("return");case 6:c[s.id]=c[s.id]||{},(f=c[s.id]).requests=f.requests||{},c[s.id].requests[i]={request:a,response:u},s.postMessage({type:"mockyeahRequestReady",payload:{requestId:i}});case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),self.addEventListener("fetch",(function(t){if(function(t){var e=t.event;try{return Boolean(u({event:e}))}catch(t){return console.log("@mockyeah/fetch service worker match error",t),!1}}({event:t})){var e=s({event:t});t.respondWith(e)}else t.respondWith(fetch(t.request))}))}]);
!function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=4)}([function(e,r,t){var n=t(1),o=t(2),u=t(3);e.exports=function(e,r){return n(e)||o(e,r)||u()}},function(e,r){e.exports=function(e){if(Array.isArray(e))return e}},function(e,r){e.exports=function(e,r){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var t=[],n=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}return t}}},function(e,r){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,r,t){"use strict";t.r(r);var n=t(0),o=t.n(n),u={};self.addEventListener("message",(function(e){var r=e,t=r.source,n=r.data;if(t){var o=t.id;if(o&&n&&"mockyeahServiceWorkerDataResponse"===n.type){var a=n.payload||{},i=a.requestId,c=a.response;if(!i)return;if(!c)return;u[o]=u[o]||{};var s=u[o][i];if(!s)return;s.resolve({response:c})}}}));self.addEventListener("fetch",(function(e){if(function(e){var r=e.event;try{return Boolean(r.request.headers.get("x-mockyeah-service-worker-request"))}catch(e){return console.log("@mockyeah/fetch service worker match error",e),!1}}({event:e})){var r=function(e){var r=e.event;try{Object.entries(u).forEach((function(e){var r=o()(e,2),t=r[0],n=r[1];Object.entries(n).forEach((function(e){var r=o()(e,2),t=r[0],u=r[1];Date.now()-u.timestamp>12e4&&delete n[t]})),0===Object.keys(n).length&&delete u[t]}));var t=r.request,n=r.clientId,a=t.headers.get("x-mockyeah-service-worker-request");if(!a)return fetch(r.request);var i=new Promise((function(e,r){u[n]=u[n]||{},u[n][a]={resolve:e,reject:r,timestamp:Date.now()}}));return self.clients.get(n).then((function(e){var r={type:"mockyeahServiceWorkerDataRequest",payload:{requestId:a}};return e.postMessage(r),i.then((function(e){var r=e.response,t=r.status,n=r.body,o=r.headers;return new Response(n,{status:t,headers:o})}))}))}catch(e){return console.log("@mockyeah/fetch service worker handler error",e),fetch(r.request)}}({event:e});e.respondWith(r)}else e.respondWith(fetch(e.request))}))}]);

@@ -167,2 +167,15 @@ import pathToRegexp from 'path-to-regexp';

}
export { Json, BootOptions, FetchOptions, Method, MethodOrAll, ResponseOptions, ResponseOptionsObject, Responder, ResponderFunction, ResponderResult, ResponseObject, Matcher, MatcherDeepObjectOfStrings, MatcherObjectOfStrings, Match, MatchFunction, MatchObject, MatchString, MatchNormal, Mock, MockSuite, MockSuiteResolver, MockNormal, MockFunction, MockReturn, RequestForHandler, Expectation, VerifyCallback, RunHandler, RunHandlerOrPromise, Action, MakeMockOptions, MakeMockReturn, responseOptionsResponderKeys };
interface ActionMockyeahServiceWorkerDataResponse {
type?: 'mockyeahServiceWorkerDataResponse';
payload?: {
requestId?: string;
response?: ResponseObject;
};
}
interface ActionMockyeahServiceWorkerDataRequest {
type?: 'mockyeahServiceWorkerDataRequest';
payload?: {
requestId?: string;
};
}
export { Json, BootOptions, FetchOptions, Method, MethodOrAll, ResponseOptions, ResponseOptionsObject, Responder, ResponderFunction, ResponderResult, ResponseObject, Matcher, MatcherDeepObjectOfStrings, MatcherObjectOfStrings, Match, MatchFunction, MatchObject, MatchString, MatchNormal, Mock, MockSuite, MockSuiteResolver, MockNormal, MockFunction, MockReturn, RequestForHandler, Expectation, VerifyCallback, RunHandler, RunHandlerOrPromise, Action, MakeMockOptions, MakeMockReturn, responseOptionsResponderKeys, ActionMockyeahServiceWorkerDataResponse, ActionMockyeahServiceWorkerDataRequest };
{
"name": "@mockyeah/fetch",
"version": "1.0.0-alpha.8",
"version": "1.0.0-alpha.9",
"description": "fetch integration for mockyeah request mocking utility.",

@@ -68,3 +68,3 @@ "main": "dist/main.js",

"@babel/register": "^7.4.4",
"@mockyeah/tools": "^1.0.0-alpha.8",
"@mockyeah/tools": "^1.0.0-alpha.9",
"@types/cookie": "^0.3.3",

@@ -103,3 +103,3 @@ "@types/debug": "^4.1.5",

"lodash": "^4.17.15",
"match-deep": "^1.0.0-alpha.8",
"match-deep": "^1.0.0-alpha.9",
"mime": "^2.4.4",

@@ -109,3 +109,3 @@ "path-to-regexp": "^3.1.0",

},
"gitHead": "fa0cc4ded724693c13f8d82d96a9f94afb6b12af"
"gitHead": "1d8d29c0381bc6542881e95c3ebc07d144db9e2c"
}

Sorry, the diff of this file is too big to display