Comparing version 0.11.4 to 0.11.5
@@ -10,3 +10,3 @@ /** | ||
const INTEGRITY_CHECKSUM = '582e1e1f1f2b85a3997e0537abd5fe4d' | ||
const INTEGRITY_CHECKSUM = '2579d4c0118e1d20d98165a260d9134e' | ||
const bannerStyle = 'color:orangered;font-weight:bold;' | ||
@@ -24,7 +24,7 @@ const bypassHeaderName = 'x-msw-bypass' | ||
self.addEventListener('message', async function(event) { | ||
const clientId = event.source.id | ||
const client = await event.currentTarget.clients.get(clientId) | ||
switch (event.data) { | ||
case 'INTEGRITY_CHECK_REQUEST': { | ||
const clientId = event.source.id | ||
const client = await event.currentTarget.clients.get(clientId) | ||
messageClient(client, { | ||
@@ -39,2 +39,7 @@ type: 'INTEGRITY_CHECK_RESPONSE', | ||
self.__isMswEnabled = true | ||
messageClient(client, { | ||
type: 'MOCKING_ENABLED', | ||
payload: true, | ||
}) | ||
console.groupCollapsed('%c[MSW] Mocking enabled.', bannerStyle) | ||
@@ -41,0 +46,0 @@ console.log( |
@@ -0,1 +1,5 @@ | ||
export interface ServiceWorkerMessage<T> { | ||
type: string; | ||
payload: T; | ||
} | ||
/** | ||
@@ -11,1 +15,3 @@ * Creates a communication channel between the client | ||
}; | ||
export declare type ServiceWorkerMessageHandler<T> = (message: ServiceWorkerMessage<T>, event: MessageEvent) => void; | ||
export declare const addMessageListener: <T>(type: string, handler: ServiceWorkerMessageHandler<T>, errorHandler?: () => void) => void; |
{ | ||
"name": "msw", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"description": "Client-side API mocking using Service Workers.", | ||
@@ -15,3 +15,3 @@ "main": "lib/index.js", | ||
"test:unit": "cross-env BABEL_ENV=test jest --runInBand", | ||
"test:integration": "jest --config=test/jest.config.js --runInBand", | ||
"test:integration": "node --max_old_space_size=8000 node_modules/.bin/jest --config=test/jest.config.js --runInBand", | ||
"test:focused": "node_modules/.bin/ts-node --project=test/tsconfig.json test/focusedTest.ts", | ||
@@ -18,0 +18,0 @@ "prepublishOnly": "yarn test:unit && yarn build && yarn test:integration" |
Sorry, the diff of this file is too big to display
186427
31
5038