@squide/msw 3.5.0 → 4.0.1

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,67 @@
1
1
  # @squide/msw
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`bea660b`](https://github.com/workleap/wl-squide/commit/bea660bf827dd123a52f6062a7be8865dc99055b)]:
8
+ - @squide/core@6.1.0
9
+
10
+ ## 4.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - [#311](https://github.com/workleap/wl-squide/pull/311) [`cc52e8b`](https://github.com/workleap/wl-squide/commit/cc52e8bfbe9d3d215f51d12755743f17c0c69772) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Deferred registration functions now receives a runtime instance as the first argument. This new scope runtime instance should used whenever runtime access is required within a deferred registration function scope.
15
+
16
+ Before:
17
+
18
+ The `runtime` argument of the registration function is used to register the navigation item.
19
+
20
+ ```ts !#1,2,4
21
+ export const register: ModuleRegisterFunction<
22
+ FireflyRuntime,
23
+ unknown,
24
+ DeferredRegistrationData
25
+ > = (runtime) => {
26
+ return ({ featureFlags }, operation) => {
27
+ if (featureFlags.featureA) {
28
+ runtime.registerNavigationItem({
29
+ $id: "feature-a",
30
+ $label: operation === "register" ? "Feature A" : "Feature A updated",
31
+ to: "/feature-a",
32
+ });
33
+ }
34
+ };
35
+ };
36
+ ```
37
+
38
+ After:
39
+
40
+ The `deferredRuntime` argument of the **deferred** registration function is used to register the navigation item.
41
+
42
+ ```ts !#2,4
43
+ export const register: ModuleRegisterFunction<
44
+ FireflyRuntime,
45
+ unknown,
46
+ DeferredRegistrationData
47
+ > = (runtime) => {
48
+ return (deferredRuntime, { featureFlags }, operation) => {
49
+ if (featureFlags.featureA) {
50
+ deferredRuntime.registerNavigationItem({
51
+ $id: "feature-a",
52
+ $label: operation === "register" ? "Feature A" : "Feature A updated",
53
+ to: "/feature-a",
54
+ });
55
+ }
56
+ };
57
+ };
58
+ ```
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`cc52e8b`](https://github.com/workleap/wl-squide/commit/cc52e8bfbe9d3d215f51d12755743f17c0c69772)]:
63
+ - @squide/core@6.0.0
64
+
3
65
  ## 3.5.0
4
66
 
5
67
  ### Minor Changes
@@ -1,10 +1,14 @@
1
1
  import { Plugin, type Runtime } from "@squide/core";
2
+ import type { Logger } from "@workleap/logging";
2
3
  import type { RequestHandler } from "msw";
3
4
  export declare const MswPluginName = "msw-plugin";
5
+ export interface MswPluginRegisterRequestHandlersOptions {
6
+ logger?: Logger;
7
+ }
4
8
  export declare class MswPlugin extends Plugin {
5
9
  #private;
6
10
  constructor(runtime: Runtime);
7
- registerRequestHandlers(handlers: RequestHandler[]): void;
11
+ registerRequestHandlers(handlers: RequestHandler[], options?: MswPluginRegisterRequestHandlersOptions): void;
8
12
  get requestHandlers(): RequestHandler[];
9
13
  }
10
14
  export declare function getMswPlugin(runtime: Runtime): MswPlugin;
package/dist/mswPlugin.js CHANGED
@@ -14,9 +14,10 @@ class MswPlugin extends Plugin {
14
14
  constructor(runtime){
15
15
  super(MswPluginName, runtime);
16
16
  }
17
- registerRequestHandlers(handlers) {
17
+ registerRequestHandlers(handlers, options = {}) {
18
+ const { logger } = options;
18
19
  this.#requestHandlerRegistry.add(handlers);
19
- this._runtime.logger.withText("[squide] The following MSW request handlers has been registered:").withObject(handlers).debug();
20
+ (logger ? logger : this._runtime.logger).withText("[squide] The following MSW request handlers has been registered:").withObject(handlers).debug();
20
21
  }
21
22
  get requestHandlers() {
22
23
  return this.#requestHandlerRegistry.handlers;
@@ -1 +1 @@
1
- {"version":3,"file":"mswPlugin.js","sources":["webpack://@squide/msw/./src/mswPlugin.ts"],"sourcesContent":["import { Plugin, isNil, type Runtime } from \"@squide/core\";\nimport type { RequestHandler } from \"msw\";\nimport { RequestHandlerRegistry } from \"./requestHandlerRegistry.ts\";\n\nexport const MswPluginName = \"msw-plugin\";\n\nexport class MswPlugin extends Plugin {\n readonly #requestHandlerRegistry = new RequestHandlerRegistry();\n\n constructor(runtime: Runtime) {\n super(MswPluginName, runtime);\n }\n\n registerRequestHandlers(handlers: RequestHandler[]) {\n this.#requestHandlerRegistry.add(handlers);\n\n 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","RequestHandlerRegistry","MswPluginName","MswPlugin","runtime","handlers","getMswPlugin","plugin","Error"],"mappings":";;;;;;;;AAA2D;AAEU;AAE9D,MAAMG,gBAAgB,aAAa;AAEnC,MAAMC,kBAAkBJ,MAAMA;IACxB,uBAAuB,GAAG,IAAIE,sBAAsBA,GAAG;IAEhE,YAAYG,OAAgB,CAAE;QAC1B,KAAK,CAACF,eAAeE;IACzB;IAEA,wBAAwBC,QAA0B,EAAE;QAChD,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAACA;QAEjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CACf,QAAQ,CAAC,oEACT,UAAU,CAACA,UACX,KAAK;IACd;IAEA,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ;IAChD;AACJ;AAEO,SAASC,aAAaF,OAAgB;IACzC,MAAMG,SAASH,QAAQ,SAAS,CAACF;IAEjC,IAAIF,KAAKA,CAACO,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
1
+ {"version":3,"file":"mswPlugin.js","sources":["webpack://@squide/msw/./src/mswPlugin.ts"],"sourcesContent":["import { Plugin, isNil, type Runtime } from \"@squide/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport type { RequestHandler } from \"msw\";\nimport { RequestHandlerRegistry } from \"./requestHandlerRegistry.ts\";\n\nexport const MswPluginName = \"msw-plugin\";\n\nexport interface MswPluginRegisterRequestHandlersOptions {\n logger?: Logger;\n}\n\nexport class MswPlugin extends Plugin {\n readonly #requestHandlerRegistry = new RequestHandlerRegistry();\n\n constructor(runtime: Runtime) {\n super(MswPluginName, runtime);\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","RequestHandlerRegistry","MswPluginName","MswPlugin","runtime","handlers","options","logger","getMswPlugin","plugin","Error"],"mappings":";;;;;;;;AAA2D;AAGU;AAE9D,MAAMG,gBAAgB,aAAa;AAMnC,MAAMC,kBAAkBJ,MAAMA;IACxB,uBAAuB,GAAG,IAAIE,sBAAsBA,GAAG;IAEhE,YAAYG,OAAgB,CAAE;QAC1B,KAAK,CAACF,eAAeE;IACzB;IAEA,wBAAwBC,QAA0B,EAAEC,UAAmD,CAAC,CAAC,EAAE;QACvG,MAAM,EACFC,MAAM,EACT,GAAGD;QAEJ,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAACD;QAEhCE,CAAAA,SAASA,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAK,EACjC,QAAQ,CAAC,oEACT,UAAU,CAACF,UACX,KAAK;IACd;IAEA,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ;IAChD;AACJ;AAEO,SAASG,aAAaJ,OAAgB;IACzC,MAAMK,SAASL,QAAQ,SAAS,CAACF;IAEjC,IAAIF,KAAKA,CAACS,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/msw",
3
3
  "author": "Workleap",
4
- "version": "3.5.0",
4
+ "version": "4.0.1",
5
5
  "description": "Add support for MSW to @squide application shell.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,20 +28,21 @@
28
28
  "README.md"
29
29
  ],
30
30
  "peerDependencies": {
31
- "msw": "^2.10.4"
31
+ "msw": "^2.11.1"
32
32
  },
33
33
  "dependencies": {
34
- "@squide/core": "5.7.0"
34
+ "@workleap/logging": "^1.3.0",
35
+ "@squide/core": "6.1.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@rsbuild/core": "1.4.7",
38
- "@rslib/core": "0.10.6",
39
- "@typescript-eslint/parser": "8.37.0",
38
+ "@rsbuild/core": "1.5.4",
39
+ "@rslib/core": "0.12.4",
40
+ "@typescript-eslint/parser": "8.42.0",
40
41
  "@workleap/eslint-plugin": "3.5.0",
41
42
  "@workleap/rslib-configs": "1.1.0",
42
43
  "@workleap/typescript-configs": "3.0.4",
43
44
  "eslint": "8.57.0",
44
- "typescript": "5.8.3"
45
+ "typescript": "5.9.2"
45
46
  },
46
47
  "sideEffects": false,
47
48
  "engines": {
package/src/mswPlugin.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Plugin, isNil, type Runtime } from "@squide/core";
2
+ import type { Logger } from "@workleap/logging";
2
3
  import type { RequestHandler } from "msw";
3
4
  import { RequestHandlerRegistry } from "./requestHandlerRegistry.ts";
4
5
 
5
6
  export const MswPluginName = "msw-plugin";
6
7
 
8
+ export interface MswPluginRegisterRequestHandlersOptions {
9
+ logger?: Logger;
10
+ }
11
+
7
12
  export class MswPlugin extends Plugin {
8
13
  readonly #requestHandlerRegistry = new RequestHandlerRegistry();
9
14
 
@@ -11,10 +16,14 @@ export class MswPlugin extends Plugin {
11
16
  super(MswPluginName, runtime);
12
17
  }
13
18
 
14
- registerRequestHandlers(handlers: RequestHandler[]) {
19
+ registerRequestHandlers(handlers: RequestHandler[], options: MswPluginRegisterRequestHandlersOptions = {}) {
20
+ const {
21
+ logger
22
+ } = options;
23
+
15
24
  this.#requestHandlerRegistry.add(handlers);
16
25
 
17
- this._runtime.logger
26
+ (logger ? logger : this._runtime.logger)
18
27
  .withText("[squide] The following MSW request handlers has been registered:")
19
28
  .withObject(handlers)
20
29
  .debug();