@squide/msw 4.0.6 → 4.0.8
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 +18 -0
- package/dist/MswPlugin.js +6 -4
- package/dist/MswPlugin.js.map +1 -1
- package/dist/MswState.js +1 -1
- package/dist/MswState.js.map +1 -1
- package/package.json +13 -9
- package/src/MswPlugin.ts +7 -5
- package/src/MswState.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @squide/msw
|
|
2
2
|
|
|
3
|
+
## 4.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#352](https://github.com/workleap/wl-squide/pull/352) [`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bump dependency versions.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787)]:
|
|
10
|
+
- @squide/core@6.1.7
|
|
11
|
+
|
|
12
|
+
## 4.0.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#347](https://github.com/workleap/wl-squide/pull/347) [`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped package versions.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a)]:
|
|
19
|
+
- @squide/core@6.1.6
|
|
20
|
+
|
|
3
21
|
## 4.0.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/MswPlugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin
|
|
1
|
+
import { Plugin } from "@squide/core";
|
|
2
2
|
import { MswState } from "./MswState.js";
|
|
3
3
|
import { RequestHandlerRegistry } from "./RequestHandlerRegistry.js";
|
|
4
4
|
|
|
@@ -35,9 +35,11 @@ class MswPlugin extends Plugin {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
function getMswPlugin(runtime) {
|
|
38
|
-
const plugin = runtime.getPlugin(MswPluginName
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const plugin = runtime.getPlugin(MswPluginName, {
|
|
39
|
+
throwOnNotFound: false
|
|
40
|
+
});
|
|
41
|
+
if (!plugin) {
|
|
42
|
+
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime. Did you provide a MswPlugin instance to the runtime instance or set the useMsw option of the initializeFirefly function to true?");
|
|
41
43
|
}
|
|
42
44
|
return plugin;
|
|
43
45
|
}
|
package/dist/MswPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MswPlugin.js","sources":["../src/MswPlugin.ts"],"sourcesContent":["import { Plugin,
|
|
1
|
+
{"version":3,"file":"MswPlugin.js","sources":["../src/MswPlugin.ts"],"sourcesContent":["import { Plugin, 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 throwOnNotFound: false\n }) as MswPlugin;\n\n if (!plugin) {\n throw new Error(\"[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime. Did you provide a MswPlugin instance to the runtime instance or set the useMsw option of the initializeFirefly function to true?\");\n }\n\n return plugin;\n}\n"],"names":["Plugin","MswState","RequestHandlerRegistry","MswPluginName","MswPlugin","runtime","options","state","handlers","logger","getMswPlugin","plugin","Error"],"mappings":";;;;;;;;;;;AAAoD;AAGX;AAC4B;AAE9D,MAAMG,gBAAgB,aAAa;AAUnC,MAAMC,kBAAkBJ,MAAMA;IACxB,SAAS,CAAW;IACpB,uBAAuB,CAAyB;IAEzD,YAAYK,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,eAAe;QAC5C,iBAAiB;IACrB;IAEA,IAAI,CAACQ,QAAQ;QACT,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
package/dist/MswState.js
CHANGED
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 interface MswStateOptions {\n isReady?: boolean;\n}\n\nexport class MswState {\n
|
|
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 readonly #mswReadyListeners = new Set<MswReadyListener>();\n #isReady: boolean;\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;IACA,kBAAkB,GAAG,IAAIC,MAAwB;IAC1D,QAAQ,CAAU;IAElB,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/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.8",
|
|
5
5
|
"description": "Add support for MSW to @squide application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -32,28 +32,32 @@
|
|
|
32
32
|
"CHANGELOG.md"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"msw": "^2.12.
|
|
35
|
+
"msw": "^2.12.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@workleap/logging": "^1.3.2",
|
|
39
|
-
"@squide/core": "6.1.
|
|
39
|
+
"@squide/core": "6.1.7"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "9.39.1",
|
|
43
|
-
"@rsbuild/core": "1.6.
|
|
44
|
-
"@rslib/core": "0.18.
|
|
45
|
-
"@typescript-eslint/parser": "8.
|
|
46
|
-
"@
|
|
43
|
+
"@rsbuild/core": "1.6.14",
|
|
44
|
+
"@rslib/core": "0.18.4",
|
|
45
|
+
"@typescript-eslint/parser": "8.49.0",
|
|
46
|
+
"@vitejs/plugin-react": "5.1.2",
|
|
47
|
+
"@workleap/eslint-configs": "1.1.6",
|
|
47
48
|
"@workleap/rslib-configs": "1.1.3",
|
|
48
49
|
"@workleap/typescript-configs": "3.0.7",
|
|
49
50
|
"eslint": "9.39.1",
|
|
51
|
+
"happy-dom": "20.0.11",
|
|
50
52
|
"typescript": "5.9.3",
|
|
51
|
-
"typescript-eslint": "8.
|
|
53
|
+
"typescript-eslint": "8.49.0",
|
|
54
|
+
"vitest": "4.0.15"
|
|
52
55
|
},
|
|
53
56
|
"sideEffects": false,
|
|
54
57
|
"scripts": {
|
|
55
58
|
"build": "rslib build --config ./rslib.build.ts",
|
|
56
59
|
"eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
|
|
57
|
-
"typecheck": "tsc"
|
|
60
|
+
"typecheck": "tsc",
|
|
61
|
+
"test": "vitest --config vitest.config.ts --no-watch"
|
|
58
62
|
}
|
|
59
63
|
}
|
package/src/MswPlugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin,
|
|
1
|
+
import { Plugin, type Runtime } from "@squide/core";
|
|
2
2
|
import type { Logger } from "@workleap/logging";
|
|
3
3
|
import type { RequestHandler } from "msw";
|
|
4
4
|
import { MswState } from "./MswState.ts";
|
|
@@ -52,11 +52,13 @@ export class MswPlugin extends Plugin {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export function getMswPlugin(runtime: Runtime) {
|
|
55
|
-
const plugin = runtime.getPlugin(MswPluginName
|
|
55
|
+
const plugin = runtime.getPlugin(MswPluginName, {
|
|
56
|
+
throwOnNotFound: false
|
|
57
|
+
}) as MswPlugin;
|
|
56
58
|
|
|
57
|
-
if (
|
|
58
|
-
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.");
|
|
59
|
+
if (!plugin) {
|
|
60
|
+
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime. Did you provide a MswPlugin instance to the runtime instance or set the useMsw option of the initializeFirefly function to true?");
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
return plugin
|
|
63
|
+
return plugin;
|
|
62
64
|
}
|
package/src/MswState.ts
CHANGED