@squide/msw 4.0.5 → 4.0.6
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/CHANGELOG.md +9 -0
- package/dist/MswPlugin.d.ts +1 -1
- package/dist/MswPlugin.js +2 -2
- package/dist/MswPlugin.js.map +1 -1
- package/dist/MswState.d.ts +4 -0
- package/dist/MswState.js +5 -1
- package/dist/MswState.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/MswPlugin.ts +3 -3
- package/src/MswState.ts +13 -2
- package/src/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @squide/msw
|
|
2
2
|
|
|
3
|
+
## 4.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#342](https://github.com/workleap/wl-squide/pull/342) [`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Minor fine tuning following v16 release.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11)]:
|
|
10
|
+
- @squide/core@6.1.5
|
|
11
|
+
|
|
3
12
|
## 4.0.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/MswPlugin.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { RequestHandler } from "msw";
|
|
|
4
4
|
import { MswState } from "./MswState.ts";
|
|
5
5
|
export declare const MswPluginName = "msw-plugin";
|
|
6
6
|
export interface MswPluginOptions {
|
|
7
|
-
|
|
7
|
+
state?: MswState;
|
|
8
8
|
}
|
|
9
9
|
export interface MswPluginRegisterRequestHandlersOptions {
|
|
10
10
|
logger?: Logger;
|
package/dist/MswPlugin.js
CHANGED
|
@@ -17,9 +17,9 @@ class MswPlugin extends Plugin {
|
|
|
17
17
|
#mswState;
|
|
18
18
|
#requestHandlerRegistry;
|
|
19
19
|
constructor(runtime, options = {}){
|
|
20
|
-
const {
|
|
20
|
+
const { state = new MswState() } = options;
|
|
21
21
|
super(MswPluginName, runtime);
|
|
22
|
-
this.#mswState =
|
|
22
|
+
this.#mswState = state;
|
|
23
23
|
this.#requestHandlerRegistry = new RequestHandlerRegistry(this.#mswState);
|
|
24
24
|
}
|
|
25
25
|
get mswState() {
|
package/dist/MswPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MswPlugin.js","sources":["../src/MswPlugin.ts"],"sourcesContent":["import { Plugin, isNil, type Runtime } from \"@squide/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport type { RequestHandler } from \"msw\";\nimport { MswState } from \"./MswState.ts\";\nimport { RequestHandlerRegistry } from \"./RequestHandlerRegistry.ts\";\n\nexport const MswPluginName = \"msw-plugin\";\n\nexport interface MswPluginOptions {\n
|
|
1
|
+
{"version":3,"file":"MswPlugin.js","sources":["../src/MswPlugin.ts"],"sourcesContent":["import { Plugin, isNil, type Runtime } from \"@squide/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport type { RequestHandler } from \"msw\";\nimport { MswState } from \"./MswState.ts\";\nimport { RequestHandlerRegistry } from \"./RequestHandlerRegistry.ts\";\n\nexport const MswPluginName = \"msw-plugin\";\n\nexport interface MswPluginOptions {\n state?: MswState;\n}\n\nexport interface MswPluginRegisterRequestHandlersOptions {\n logger?: Logger;\n}\n\nexport class MswPlugin extends Plugin {\n readonly #mswState: MswState;\n readonly #requestHandlerRegistry: RequestHandlerRegistry;\n\n constructor(runtime: Runtime, options: MswPluginOptions = {}) {\n const {\n state = new MswState()\n } = options;\n\n super(MswPluginName, runtime);\n\n this.#mswState = state;\n this.#requestHandlerRegistry = new RequestHandlerRegistry(this.#mswState);\n }\n\n get mswState() {\n return this.#mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: MswPluginRegisterRequestHandlersOptions = {}) {\n const {\n logger\n } = options;\n\n this.#requestHandlerRegistry.add(handlers);\n\n (logger ? logger : this._runtime.logger)\n .withText(\"[squide] The following MSW request handlers has been registered:\")\n .withObject(handlers)\n .debug();\n }\n\n get requestHandlers(): RequestHandler[] {\n return this.#requestHandlerRegistry.handlers;\n }\n}\n\nexport function getMswPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(MswPluginName);\n\n if (isNil(plugin)) {\n throw new Error(\"[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.\");\n }\n\n return plugin as MswPlugin;\n}\n"],"names":["Plugin","isNil","MswState","RequestHandlerRegistry","MswPluginName","MswPlugin","runtime","options","state","handlers","logger","getMswPlugin","plugin","Error"],"mappings":";;;;;;;;;;;AAA2D;AAGlB;AAC4B;AAE9D,MAAMI,gBAAgB,aAAa;AAUnC,MAAMC,kBAAkBL,MAAMA;IACxB,SAAS,CAAW;IACpB,uBAAuB,CAAyB;IAEzD,YAAYM,OAAgB,EAAEC,UAA4B,CAAC,CAAC,CAAE;QAC1D,MAAM,EACFC,QAAQ,IAAIN,QAAQA,EAAE,EACzB,GAAGK;QAEJ,KAAK,CAACH,eAAeE;QAErB,IAAI,CAAC,SAAS,GAAGE;QACjB,IAAI,CAAC,uBAAuB,GAAG,IAAIL,sBAAsBA,CAAC,IAAI,CAAC,SAAS;IAC5E;IAEA,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,SAAS;IACzB;IAEA,wBAAwBM,QAA0B,EAAEF,UAAmD,CAAC,CAAC,EAAE;QACvG,MAAM,EACFG,MAAM,EACT,GAAGH;QAEJ,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAACE;QAEhCC,CAAAA,SAASA,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAK,EACjC,QAAQ,CAAC,oEACT,UAAU,CAACD,UACX,KAAK;IACd;IAEA,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ;IAChD;AACJ;AAEO,SAASE,aAAaL,OAAgB;IACzC,MAAMM,SAASN,QAAQ,SAAS,CAACF;IAEjC,IAAIH,KAAKA,CAACW,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
package/dist/MswState.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export type MswReadyListener = () => void;
|
|
2
|
+
export interface MswStateOptions {
|
|
3
|
+
isReady?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare class MswState {
|
|
3
6
|
#private;
|
|
7
|
+
constructor(options?: MswStateOptions);
|
|
4
8
|
addMswReadyListener(callback: MswReadyListener): void;
|
|
5
9
|
removeMswReadyListener(callback: MswReadyListener): void;
|
|
6
10
|
setAsReady(): void;
|
package/dist/MswState.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
;// CONCATENATED MODULE: ./src/MswState.ts
|
|
3
3
|
class MswState {
|
|
4
|
-
#isReady
|
|
4
|
+
#isReady;
|
|
5
5
|
#mswReadyListeners = new Set();
|
|
6
|
+
constructor(options = {}){
|
|
7
|
+
const { isReady = false } = options;
|
|
8
|
+
this.#isReady = isReady;
|
|
9
|
+
}
|
|
6
10
|
addMswReadyListener(callback) {
|
|
7
11
|
this.#mswReadyListeners.add(callback);
|
|
8
12
|
}
|
package/dist/MswState.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MswState.js","sources":["../src/MswState.ts"],"sourcesContent":["export type MswReadyListener = () => void;\n\nexport class MswState {\n #isReady
|
|
1
|
+
{"version":3,"file":"MswState.js","sources":["../src/MswState.ts"],"sourcesContent":["export type MswReadyListener = () => void;\n\nexport interface MswStateOptions {\n isReady?: boolean;\n}\n\nexport class MswState {\n #isReady: boolean;\n readonly #mswReadyListeners = new Set<MswReadyListener>();\n\n constructor(options: MswStateOptions = {}) {\n const {\n isReady = false\n } = options;\n\n this.#isReady = isReady;\n }\n\n addMswReadyListener(callback: MswReadyListener) {\n this.#mswReadyListeners.add(callback);\n }\n\n removeMswReadyListener(callback: MswReadyListener) {\n this.#mswReadyListeners.delete(callback);\n }\n\n setAsReady() {\n if (!this.#isReady) {\n this.#isReady = true;\n\n this.#mswReadyListeners.forEach(x => {\n x();\n });\n }\n }\n\n get isReady() {\n return this.#isReady;\n }\n}\n"],"names":["MswState","Set","options","isReady","callback","x"],"mappings":";;AAMO,MAAMA;IACT,QAAQ,CAAU;IACT,kBAAkB,GAAG,IAAIC,MAAwB;IAE1D,YAAYC,UAA2B,CAAC,CAAC,CAAE;QACvC,MAAM,EACFC,UAAU,KAAK,EAClB,GAAGD;QAEJ,IAAI,CAAC,QAAQ,GAAGC;IACpB;IAEA,oBAAoBC,QAA0B,EAAE;QAC5C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAACA;IAChC;IAEA,uBAAuBA,QAA0B,EAAE;QAC/C,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAACA;IACnC;IAEA,aAAa;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG;YAEhB,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC,CAAAA;gBAC5BA;YACJ;QACJ;IACJ;IAEA,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { getMswPlugin, MswPlugin, MswPluginName, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions } from "./MswPlugin.ts";
|
|
2
|
-
export { type MswReadyListener, type
|
|
2
|
+
export { MswState, type MswReadyListener, type MswStateOptions } from "./MswState.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { MswPlugin, MswPluginName, getMswPlugin } from "./MswPlugin.js";
|
|
2
|
+
import { MswState } from "./MswState.js";
|
|
2
3
|
|
|
3
4
|
;// CONCATENATED MODULE: external "./MswPlugin.js"
|
|
4
5
|
|
|
6
|
+
;// CONCATENATED MODULE: external "./MswState.js"
|
|
7
|
+
|
|
5
8
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
6
9
|
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
export { MswPlugin, MswPluginName, MswState, getMswPlugin };
|
|
9
13
|
|
|
10
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export { getMswPlugin, MswPlugin, MswPluginName, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions } from \"./MswPlugin.ts\";\nexport { type MswReadyListener, type
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export { getMswPlugin, MswPlugin, MswPluginName, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions } from \"./MswPlugin.ts\";\nexport { MswState, type MswReadyListener, type MswStateOptions } from \"./MswState.ts\";\n\n"],"names":["getMswPlugin","MswPlugin","MswPluginName","MswState"],"mappings":";;;;;;;;AAA6I;AACvD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/msw",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.6",
|
|
5
5
|
"description": "Add support for MSW to @squide application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@workleap/logging": "^1.3.2",
|
|
39
|
-
"@squide/core": "6.1.
|
|
39
|
+
"@squide/core": "6.1.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "9.39.1",
|
package/src/MswPlugin.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { RequestHandlerRegistry } from "./RequestHandlerRegistry.ts";
|
|
|
7
7
|
export const MswPluginName = "msw-plugin";
|
|
8
8
|
|
|
9
9
|
export interface MswPluginOptions {
|
|
10
|
-
|
|
10
|
+
state?: MswState;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface MswPluginRegisterRequestHandlersOptions {
|
|
@@ -20,12 +20,12 @@ export class MswPlugin extends Plugin {
|
|
|
20
20
|
|
|
21
21
|
constructor(runtime: Runtime, options: MswPluginOptions = {}) {
|
|
22
22
|
const {
|
|
23
|
-
|
|
23
|
+
state = new MswState()
|
|
24
24
|
} = options;
|
|
25
25
|
|
|
26
26
|
super(MswPluginName, runtime);
|
|
27
27
|
|
|
28
|
-
this.#mswState =
|
|
28
|
+
this.#mswState = state;
|
|
29
29
|
this.#requestHandlerRegistry = new RequestHandlerRegistry(this.#mswState);
|
|
30
30
|
}
|
|
31
31
|
|
package/src/MswState.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
export type MswReadyListener = () => void;
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export interface MswStateOptions {
|
|
4
|
+
isReady?: boolean;
|
|
5
|
+
}
|
|
5
6
|
|
|
7
|
+
export class MswState {
|
|
8
|
+
#isReady: boolean;
|
|
6
9
|
readonly #mswReadyListeners = new Set<MswReadyListener>();
|
|
7
10
|
|
|
11
|
+
constructor(options: MswStateOptions = {}) {
|
|
12
|
+
const {
|
|
13
|
+
isReady = false
|
|
14
|
+
} = options;
|
|
15
|
+
|
|
16
|
+
this.#isReady = isReady;
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
addMswReadyListener(callback: MswReadyListener) {
|
|
9
20
|
this.#mswReadyListeners.add(callback);
|
|
10
21
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getMswPlugin, MswPlugin, MswPluginName, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions } from "./MswPlugin.ts";
|
|
2
|
-
export { type MswReadyListener, type
|
|
2
|
+
export { MswState, type MswReadyListener, type MswStateOptions } from "./MswState.ts";
|
|
3
3
|
|