@squide/msw 4.0.7 → 4.0.9

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @squide/msw
2
2
 
3
+ ## 4.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#361](https://github.com/workleap/wl-squide/pull/361) [`0479f4b`](https://github.com/workleap/wl-squide/commit/0479f4bb0bf17282dbd19dba92b3ac097cf01614) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependency versions.
8
+
9
+ - Updated dependencies [[`0479f4b`](https://github.com/workleap/wl-squide/commit/0479f4bb0bf17282dbd19dba92b3ac097cf01614)]:
10
+ - @squide/core@6.1.8
11
+
12
+ ## 4.0.8
13
+
14
+ ### Patch Changes
15
+
16
+ - [#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.
17
+
18
+ - Updated dependencies [[`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787)]:
19
+ - @squide/core@6.1.7
20
+
3
21
  ## 4.0.7
4
22
 
5
23
  ### Patch Changes
package/dist/MswPlugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin, isNil } from "@squide/core";
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
- if (isNil(plugin)) {
40
- throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.");
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
  }
@@ -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 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"}
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
@@ -1,8 +1,8 @@
1
1
 
2
2
  ;// CONCATENATED MODULE: ./src/MswState.ts
3
3
  class MswState {
4
- #isReady;
5
4
  #mswReadyListeners = new Set();
5
+ #isReady;
6
6
  constructor(options = {}){
7
7
  const { isReady = false } = options;
8
8
  this.#isReady = isReady;
@@ -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 #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"}
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.7",
4
+ "version": "4.0.9",
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.3"
35
+ "msw": "^2.12.4"
36
36
  },
37
37
  "dependencies": {
38
- "@workleap/logging": "^1.3.2",
39
- "@squide/core": "6.1.6"
38
+ "@workleap/logging": "^1.3.3",
39
+ "@squide/core": "6.1.8"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@eslint/js": "9.39.1",
43
- "@rsbuild/core": "1.6.9",
44
- "@rslib/core": "0.18.2",
45
- "@typescript-eslint/parser": "8.48.0",
46
- "@workleap/eslint-configs": "1.1.5",
47
- "@workleap/rslib-configs": "1.1.3",
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.7",
48
+ "@workleap/rslib-configs": "1.1.4",
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.48.0"
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, isNil, type Runtime } from "@squide/core";
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 (isNil(plugin)) {
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 as MswPlugin;
63
+ return plugin;
62
64
  }
package/src/MswState.ts CHANGED
@@ -5,8 +5,8 @@ export interface MswStateOptions {
5
5
  }
6
6
 
7
7
  export class MswState {
8
- #isReady: boolean;
9
8
  readonly #mswReadyListeners = new Set<MswReadyListener>();
9
+ #isReady: boolean;
10
10
 
11
11
  constructor(options: MswStateOptions = {}) {
12
12
  const {