@squide/msw 3.2.1 → 3.2.3
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 +53 -35
- package/README.md +2 -2
- package/dist/index.d.ts +3 -5
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -0
- package/dist/mswPlugin.d.ts +5 -8
- package/dist/mswPlugin.js +35 -3
- package/dist/mswPlugin.js.map +1 -0
- package/dist/mswState.d.ts +8 -10
- package/dist/mswState.js +54 -1
- package/dist/mswState.js.map +1 -0
- package/dist/requestHandlerRegistry.d.ts +2 -5
- package/dist/requestHandlerRegistry.js +24 -2
- package/dist/requestHandlerRegistry.js.map +1 -0
- package/package.json +20 -22
- package/src/index.ts +4 -0
- package/src/mswPlugin.ts +33 -0
- package/src/mswState.ts +65 -0
- package/src/requestHandlerRegistry.ts +21 -0
- package/dist/chunk-CL6F3JZI.js +0 -19
- package/dist/chunk-NDT73ZLW.js +0 -26
- package/dist/chunk-YBOXRDQQ.js +0 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,55 @@
|
|
|
1
1
|
# @squide/msw
|
|
2
2
|
|
|
3
|
+
## 3.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#244](https://github.com/workleap/wl-squide/pull/244) [`5d13eb0`](https://github.com/workleap/wl-squide/commit/5d13eb038a724b499b820d7e1dc864c87954510b) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated dependencies.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`5d13eb0`](https://github.com/workleap/wl-squide/commit/5d13eb038a724b499b820d7e1dc864c87954510b)]:
|
|
10
|
+
- @squide/core@5.4.3
|
|
11
|
+
|
|
12
|
+
## 3.2.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#231](https://github.com/workleap/wl-squide/pull/231) [`3c6bce0`](https://github.com/workleap/wl-squide/commit/3c6bce0cd559d0b8517d644661b6fb2b818ab2f6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Packages now includes source code and sourcemap.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`3c6bce0`](https://github.com/workleap/wl-squide/commit/3c6bce0cd559d0b8517d644661b6fb2b818ab2f6)]:
|
|
19
|
+
- @squide/core@5.4.2
|
|
20
|
+
|
|
3
21
|
## 3.2.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
6
24
|
|
|
7
|
-
- [#221](https://github.com/
|
|
25
|
+
- [#221](https://github.com/workleap/wl-squide/pull/221) [`8411080`](https://github.com/workleap/wl-squide/commit/8411080dfd0df6d0eafb01888298154fa5e5d925) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fix deferred registrations.
|
|
8
26
|
|
|
9
|
-
- Updated dependencies [[`8411080`](https://github.com/
|
|
27
|
+
- Updated dependencies [[`8411080`](https://github.com/workleap/wl-squide/commit/8411080dfd0df6d0eafb01888298154fa5e5d925)]:
|
|
10
28
|
- @squide/core@5.4.1
|
|
11
29
|
|
|
12
30
|
## 3.2.0
|
|
13
31
|
|
|
14
32
|
### Minor Changes
|
|
15
33
|
|
|
16
|
-
- [#219](https://github.com/
|
|
34
|
+
- [#219](https://github.com/workleap/wl-squide/pull/219) [`25cb482`](https://github.com/workleap/wl-squide/commit/25cb482779ee280f3f7109de4607b92dcfeef7f3) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Now dispatching events to enable instrumentation packages for observability platforms.
|
|
17
35
|
|
|
18
36
|
### Patch Changes
|
|
19
37
|
|
|
20
|
-
- Updated dependencies [[`25cb482`](https://github.com/
|
|
38
|
+
- Updated dependencies [[`25cb482`](https://github.com/workleap/wl-squide/commit/25cb482779ee280f3f7109de4607b92dcfeef7f3)]:
|
|
21
39
|
- @squide/core@5.4.0
|
|
22
40
|
|
|
23
41
|
## 3.1.1
|
|
24
42
|
|
|
25
43
|
### Patch Changes
|
|
26
44
|
|
|
27
|
-
- Updated dependencies [[`8ee26fd`](https://github.com/
|
|
45
|
+
- Updated dependencies [[`8ee26fd`](https://github.com/workleap/wl-squide/commit/8ee26fd6ab7126bacf3dec900629fbd045dfd180)]:
|
|
28
46
|
- @squide/core@5.3.0
|
|
29
47
|
|
|
30
48
|
## 3.1.0
|
|
31
49
|
|
|
32
50
|
### Minor Changes
|
|
33
51
|
|
|
34
|
-
- [#204](https://github.com/
|
|
52
|
+
- [#204](https://github.com/workleap/wl-squide/pull/204) [`d3f7b9c`](https://github.com/workleap/wl-squide/commit/d3f7b9c6aa80249cd898916f6315ea27c4526812) Thanks [@patricklafrance](https://github.com/patricklafrance)! - The `registerNavigationItem` function now accepts a `sectionId` option to nest the item under a specific navigation section:
|
|
35
53
|
|
|
36
54
|
```ts
|
|
37
55
|
runtime.registerNavigationItem(
|
|
@@ -48,30 +66,30 @@
|
|
|
48
66
|
|
|
49
67
|
### Patch Changes
|
|
50
68
|
|
|
51
|
-
- Updated dependencies [[`d3f7b9c`](https://github.com/
|
|
69
|
+
- Updated dependencies [[`d3f7b9c`](https://github.com/workleap/wl-squide/commit/d3f7b9c6aa80249cd898916f6315ea27c4526812)]:
|
|
52
70
|
- @squide/core@5.2.0
|
|
53
71
|
|
|
54
72
|
## 3.0.2
|
|
55
73
|
|
|
56
74
|
### Patch Changes
|
|
57
75
|
|
|
58
|
-
- Updated dependencies [[`98e4839`](https://github.com/
|
|
76
|
+
- Updated dependencies [[`98e4839`](https://github.com/workleap/wl-squide/commit/98e48393fda27ebb2974ecc1e2f71b09f4e84953)]:
|
|
59
77
|
- @squide/core@5.1.0
|
|
60
78
|
|
|
61
79
|
## 3.0.1
|
|
62
80
|
|
|
63
81
|
### Patch Changes
|
|
64
82
|
|
|
65
|
-
- [#191](https://github.com/
|
|
83
|
+
- [#191](https://github.com/workleap/wl-squide/pull/191) [`2b62c53`](https://github.com/workleap/wl-squide/commit/2b62c539b0f3123cb47475566181e0b446ea6b40) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated packages description.
|
|
66
84
|
|
|
67
|
-
- Updated dependencies [[`2b62c53`](https://github.com/
|
|
85
|
+
- Updated dependencies [[`2b62c53`](https://github.com/workleap/wl-squide/commit/2b62c539b0f3123cb47475566181e0b446ea6b40)]:
|
|
68
86
|
- @squide/core@5.0.1
|
|
69
87
|
|
|
70
88
|
## 3.0.0
|
|
71
89
|
|
|
72
90
|
### Major Changes
|
|
73
91
|
|
|
74
|
-
- [#182](https://github.com/
|
|
92
|
+
- [#182](https://github.com/workleap/wl-squide/pull/182) [`58cf066`](https://github.com/workleap/wl-squide/commit/58cf066e87e23611510c254cca96016bd2bad08a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - ## Firefly v9
|
|
75
93
|
|
|
76
94
|
This major version of @squide/firefly introduces TanStack Query as the official library for fetching the global data of a Squide's application and features a complete rewrite of the AppRouter component, which now uses a state machine to manage the application's bootstrapping flow.
|
|
77
95
|
|
|
@@ -79,7 +97,7 @@
|
|
|
79
97
|
|
|
80
98
|
Finally, with v9, Squide's philosophy has evolved. We used to describe Squide as a shell for federated applications. Now, we refer to Squide as a shell for modular applications. After playing with Squide's local module feature for a while, we discovered that Squide offers significant value even for non-federated applications, which triggered this shift in philosophy.
|
|
81
99
|
|
|
82
|
-
> For a full breakdown of the changres and a migration procedure, read the following [documentation](https://
|
|
100
|
+
> For a full breakdown of the changres and a migration procedure, read the following [documentation](https://workleap.github.io/wl-squide/guides/migrate-to-firefly-v9/).
|
|
83
101
|
|
|
84
102
|
## Breaking changes
|
|
85
103
|
|
|
@@ -121,124 +139,124 @@
|
|
|
121
139
|
- Navigation items now include a `$canRender` option, enabling modules to control whether a navigation item should be rendered.
|
|
122
140
|
- New `$key` option for navigation items.
|
|
123
141
|
|
|
124
|
-
For more details about the changes and a migration procedure, read the following [documentation](https://
|
|
142
|
+
For more details about the changes and a migration procedure, read the following [documentation](https://workleap.github.io/wl-squide/guides/migrate-to-firefly-v9/).
|
|
125
143
|
|
|
126
144
|
### Patch Changes
|
|
127
145
|
|
|
128
|
-
- Updated dependencies [[`58cf066`](https://github.com/
|
|
146
|
+
- Updated dependencies [[`58cf066`](https://github.com/workleap/wl-squide/commit/58cf066e87e23611510c254cca96016bd2bad08a)]:
|
|
129
147
|
- @squide/core@5.0.0
|
|
130
148
|
|
|
131
149
|
## 2.0.14
|
|
132
150
|
|
|
133
151
|
### Patch Changes
|
|
134
152
|
|
|
135
|
-
- Updated dependencies [[`89ace29`](https://github.com/
|
|
153
|
+
- Updated dependencies [[`89ace29`](https://github.com/workleap/wl-squide/commit/89ace29b9aeadbbe83cfa71dd137b9f1a115c283)]:
|
|
136
154
|
- @squide/core@4.0.0
|
|
137
155
|
|
|
138
156
|
## 2.0.13
|
|
139
157
|
|
|
140
158
|
### Patch Changes
|
|
141
159
|
|
|
142
|
-
- [#154](https://github.com/
|
|
160
|
+
- [#154](https://github.com/workleap/wl-squide/pull/154) [`e440515`](https://github.com/workleap/wl-squide/commit/e4405150a3c364fd4029c345399891614a434176) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated packages.
|
|
143
161
|
|
|
144
|
-
- Updated dependencies [[`e440515`](https://github.com/
|
|
162
|
+
- Updated dependencies [[`e440515`](https://github.com/workleap/wl-squide/commit/e4405150a3c364fd4029c345399891614a434176)]:
|
|
145
163
|
- @squide/core@3.4.0
|
|
146
164
|
|
|
147
165
|
## 2.0.12
|
|
148
166
|
|
|
149
167
|
### Patch Changes
|
|
150
168
|
|
|
151
|
-
- [#152](https://github.com/
|
|
169
|
+
- [#152](https://github.com/workleap/wl-squide/pull/152) [`d27fe71`](https://github.com/workleap/wl-squide/commit/d27fe717f899e395c3f01af86aac3e015159d719) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated dependency versions.
|
|
152
170
|
|
|
153
|
-
- Updated dependencies [[`d27fe71`](https://github.com/
|
|
171
|
+
- Updated dependencies [[`d27fe71`](https://github.com/workleap/wl-squide/commit/d27fe717f899e395c3f01af86aac3e015159d719)]:
|
|
154
172
|
- @squide/core@3.3.2
|
|
155
173
|
|
|
156
174
|
## 2.0.11
|
|
157
175
|
|
|
158
176
|
### Patch Changes
|
|
159
177
|
|
|
160
|
-
- Updated dependencies [[`d091846`](https://github.com/
|
|
178
|
+
- Updated dependencies [[`d091846`](https://github.com/workleap/wl-squide/commit/d091846502bed6b783b69ab8eff7ae36d8e25449)]:
|
|
161
179
|
- @squide/core@3.3.1
|
|
162
180
|
|
|
163
181
|
## 2.0.10
|
|
164
182
|
|
|
165
183
|
### Patch Changes
|
|
166
184
|
|
|
167
|
-
- Updated dependencies [[`39d0bbe4`](https://github.com/
|
|
185
|
+
- Updated dependencies [[`39d0bbe4`](https://github.com/workleap/wl-squide/commit/39d0bbe45902d54832e9aa8deb2c1949a2cf3c5f)]:
|
|
168
186
|
- @squide/core@3.3.0
|
|
169
187
|
|
|
170
188
|
## 2.0.9
|
|
171
189
|
|
|
172
190
|
### Patch Changes
|
|
173
191
|
|
|
174
|
-
- Updated dependencies [[`1cda1be`](https://github.com/
|
|
192
|
+
- Updated dependencies [[`1cda1be`](https://github.com/workleap/wl-squide/commit/1cda1be30779d1a1d5d2e21eac043baff20c0f7e)]:
|
|
175
193
|
- @squide/core@3.2.1
|
|
176
194
|
|
|
177
195
|
## 2.0.8
|
|
178
196
|
|
|
179
197
|
### Patch Changes
|
|
180
198
|
|
|
181
|
-
- Updated dependencies [[`7caa44b`](https://github.com/
|
|
199
|
+
- Updated dependencies [[`7caa44b`](https://github.com/workleap/wl-squide/commit/7caa44ba81a97d0705caf2f56e6536ae285c920d)]:
|
|
182
200
|
- @squide/core@3.2.0
|
|
183
201
|
|
|
184
202
|
## 2.0.7
|
|
185
203
|
|
|
186
204
|
### Patch Changes
|
|
187
205
|
|
|
188
|
-
- [#128](https://github.com/
|
|
206
|
+
- [#128](https://github.com/workleap/wl-squide/pull/128) [`4c3b6f1`](https://github.com/workleap/wl-squide/commit/4c3b6f1929364844dda6c1190fc45c3b037e8df9) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Internally changed the usage of `setInterval` for `useSyncExternalStore`.
|
|
189
207
|
|
|
190
|
-
- Updated dependencies [[`4c3b6f1`](https://github.com/
|
|
208
|
+
- Updated dependencies [[`4c3b6f1`](https://github.com/workleap/wl-squide/commit/4c3b6f1929364844dda6c1190fc45c3b037e8df9)]:
|
|
191
209
|
- @squide/core@3.1.1
|
|
192
210
|
|
|
193
211
|
## 2.0.6
|
|
194
212
|
|
|
195
213
|
### Patch Changes
|
|
196
214
|
|
|
197
|
-
- [#122](https://github.com/
|
|
215
|
+
- [#122](https://github.com/workleap/wl-squide/pull/122) [`cda7873`](https://github.com/workleap/wl-squide/commit/cda7873dcffbf424a625cf40c56a12eacbb2632e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Internal minor changes
|
|
198
216
|
|
|
199
217
|
## 2.0.5
|
|
200
218
|
|
|
201
219
|
### Patch Changes
|
|
202
220
|
|
|
203
|
-
- [#115](https://github.com/
|
|
221
|
+
- [#115](https://github.com/workleap/wl-squide/pull/115) [`568255a`](https://github.com/workleap/wl-squide/commit/568255a50a519e7d19c8c2b03909559686cd24c4) Thanks [@patricklafrance](https://github.com/patricklafrance)! - - Request handlers registeration are now printed to the debug logs.
|
|
204
222
|
|
|
205
|
-
- Updated dependencies [[`568255a`](https://github.com/
|
|
223
|
+
- Updated dependencies [[`568255a`](https://github.com/workleap/wl-squide/commit/568255a50a519e7d19c8c2b03909559686cd24c4)]:
|
|
206
224
|
- @squide/core@3.1.0
|
|
207
225
|
|
|
208
226
|
## 2.0.4
|
|
209
227
|
|
|
210
228
|
### Patch Changes
|
|
211
229
|
|
|
212
|
-
- Updated dependencies [[`a9dda1c`](https://github.com/
|
|
230
|
+
- Updated dependencies [[`a9dda1c`](https://github.com/workleap/wl-squide/commit/a9dda1c3b010f616556fc3313c1934e20a26bc11)]:
|
|
213
231
|
- @squide/core@3.0.0
|
|
214
232
|
|
|
215
233
|
## 2.0.3
|
|
216
234
|
|
|
217
235
|
### Patch Changes
|
|
218
236
|
|
|
219
|
-
- [#108](https://github.com/
|
|
237
|
+
- [#108](https://github.com/workleap/wl-squide/pull/108) [`58097a2`](https://github.com/workleap/wl-squide/commit/58097a2fbaa7e5942cbe6f9b765fe471d52758d8) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated types in the function signatures for MSW 2.0
|
|
220
238
|
|
|
221
239
|
## 2.0.2
|
|
222
240
|
|
|
223
241
|
### Patch Changes
|
|
224
242
|
|
|
225
|
-
- [#103](https://github.com/
|
|
243
|
+
- [#103](https://github.com/workleap/wl-squide/pull/103) [`b72fca3`](https://github.com/workleap/wl-squide/commit/b72fca38385ddacbcd80376c9afd0c9485658d90) Thanks [@patricklafrance](https://github.com/patricklafrance)! - The `msw` dependency is now an optional `peerDependency`.
|
|
226
244
|
|
|
227
|
-
- Updated dependencies [[`b72fca3`](https://github.com/
|
|
245
|
+
- Updated dependencies [[`b72fca3`](https://github.com/workleap/wl-squide/commit/b72fca38385ddacbcd80376c9afd0c9485658d90)]:
|
|
228
246
|
- @squide/core@2.2.0
|
|
229
247
|
|
|
230
248
|
## 2.0.1
|
|
231
249
|
|
|
232
250
|
### Patch Changes
|
|
233
251
|
|
|
234
|
-
- Updated dependencies [[`1e77dca`](https://github.com/
|
|
252
|
+
- Updated dependencies [[`1e77dca`](https://github.com/workleap/wl-squide/commit/1e77dcaf26660e42f2d5054b3fa1cd018c2ec009)]:
|
|
235
253
|
- @squide/core@2.1.0
|
|
236
254
|
|
|
237
255
|
## 2.0.0
|
|
238
256
|
|
|
239
257
|
### Major Changes
|
|
240
258
|
|
|
241
|
-
- [#93](https://github.com/
|
|
259
|
+
- [#93](https://github.com/workleap/wl-squide/pull/93) [`d66a196`](https://github.com/workleap/wl-squide/commit/d66a196db9346803e1c996ef64089eda9aeff180) Thanks [@patricklafrance](https://github.com/patricklafrance)! - This is a new package to help with [Mock Service Worker](https://mswjs.io/) in a federated application.
|
|
242
260
|
|
|
243
261
|
It helps to register their request handlers:
|
|
244
262
|
|
|
@@ -267,5 +285,5 @@
|
|
|
267
285
|
|
|
268
286
|
### Patch Changes
|
|
269
287
|
|
|
270
|
-
- Updated dependencies [[`d66a196`](https://github.com/
|
|
288
|
+
- Updated dependencies [[`d66a196`](https://github.com/workleap/wl-squide/commit/d66a196db9346803e1c996ef64089eda9aeff180)]:
|
|
271
289
|
- @squide/core@2.0.0
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
|
-
View the [user's documentation](https://
|
|
5
|
+
View the [user's documentation](https://workleap.github.io/wl-squide/).
|
|
6
6
|
|
|
7
7
|
## 🤝 Contributing
|
|
8
8
|
|
|
@@ -10,4 +10,4 @@ View the [contributor's documentation](../../CONTRIBUTING.md).
|
|
|
10
10
|
|
|
11
11
|
## License
|
|
12
12
|
|
|
13
|
-
Copyright © 2024, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/
|
|
13
|
+
Copyright © 2024, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/workleap/workleap-license/blob/master/LICENSE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
import '@squide/core';
|
|
5
|
-
import 'msw';
|
|
1
|
+
export * from "./mswPlugin.ts";
|
|
2
|
+
export * from "./mswState.ts";
|
|
3
|
+
export * from "./requestHandlerRegistry.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from "./mswPlugin.js";
|
|
2
|
+
export * from "./mswState.js";
|
|
3
|
+
export * from "./requestHandlerRegistry.js";
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/index.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["webpack://@squide/msw/./src/index.ts"],"sourcesContent":["export * from \"./mswPlugin.ts\";\nexport * from \"./mswState.ts\";\nexport * from \"./requestHandlerRegistry.ts\";\n\n"],"names":[],"mappings":";;;;;AAA+B;AACD;AACc"}
|
package/dist/mswPlugin.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { Plugin, Runtime } from
|
|
2
|
-
import { RequestHandler } from
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
declare class MswPlugin extends Plugin {
|
|
1
|
+
import { Plugin, type Runtime } from "@squide/core";
|
|
2
|
+
import type { RequestHandler } from "msw";
|
|
3
|
+
export declare const MswPluginName = "msw-plugin";
|
|
4
|
+
export declare class MswPlugin extends Plugin {
|
|
6
5
|
#private;
|
|
7
6
|
constructor(runtime: Runtime);
|
|
8
7
|
registerRequestHandlers(handlers: RequestHandler[]): void;
|
|
9
8
|
get requestHandlers(): RequestHandler[];
|
|
10
9
|
}
|
|
11
|
-
declare function getMswPlugin(runtime: Runtime): MswPlugin;
|
|
12
|
-
|
|
13
|
-
export { MswPlugin, MswPluginName, getMswPlugin };
|
|
10
|
+
export declare function getMswPlugin(runtime: Runtime): MswPlugin;
|
package/dist/mswPlugin.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__requestHandlerRegistry_js_564606de__ from "./requestHandlerRegistry.js";
|
|
3
|
+
|
|
4
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "./requestHandlerRegistry.js"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: ./src/mswPlugin.ts?__rslib_entry__
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const MswPluginName = "msw-plugin";
|
|
12
|
+
class MswPlugin extends __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.Plugin {
|
|
13
|
+
#requestHandlerRegistry = new __WEBPACK_EXTERNAL_MODULE__requestHandlerRegistry_js_564606de__.RequestHandlerRegistry();
|
|
14
|
+
constructor(runtime){
|
|
15
|
+
super(MswPluginName, runtime);
|
|
16
|
+
}
|
|
17
|
+
registerRequestHandlers(handlers) {
|
|
18
|
+
this.#requestHandlerRegistry.add(handlers);
|
|
19
|
+
this._runtime.logger.debug("[squide] The following MSW request handlers has been registered: ", handlers);
|
|
20
|
+
}
|
|
21
|
+
get requestHandlers() {
|
|
22
|
+
return this.#requestHandlerRegistry.handlers;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getMswPlugin(runtime) {
|
|
26
|
+
const plugin = runtime.getPlugin(MswPluginName);
|
|
27
|
+
if ((0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.isNil)(plugin)) {
|
|
28
|
+
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.");
|
|
29
|
+
}
|
|
30
|
+
return plugin;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { MswPlugin, MswPluginName, getMswPlugin };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=mswPlugin.js.map
|
|
@@ -0,0 +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.debug(\"[squide] The following MSW request handlers has been registered: \", handlers);\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,wDAAMA;IACxB,uBAAuB,GAAG,IAAIE,sFAAsBA,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,CAAC,KAAK,CAAC,qEAAqEA;IACpG;IAEA,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ;IAChD;AACJ;AAEO,SAASC,aAAaF,OAAgB;IACzC,MAAMG,SAASH,QAAQ,SAAS,CAACF;IAEjC,IAAIF,2DAAKA,CAACO,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
package/dist/mswState.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
type MswStateChangedListener = () => void;
|
|
2
|
-
declare class MswState {
|
|
1
|
+
export type MswStateChangedListener = () => void;
|
|
2
|
+
export declare class MswState {
|
|
3
3
|
#private;
|
|
4
4
|
addStateChangedListener(callback: MswStateChangedListener): void;
|
|
5
5
|
removeStateChangedListener(callback: MswStateChangedListener): void;
|
|
6
6
|
setAsReady(): void;
|
|
7
7
|
get isReady(): boolean;
|
|
8
8
|
}
|
|
9
|
-
declare function __setMswState(state: MswState): void;
|
|
10
|
-
declare function __clearMswState(): void;
|
|
11
|
-
declare function setMswAsReady(): void;
|
|
12
|
-
declare function isMswReady(): boolean;
|
|
13
|
-
declare function addMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
14
|
-
declare function removeMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
15
|
-
|
|
16
|
-
export { MswState, type MswStateChangedListener, __clearMswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady };
|
|
9
|
+
export declare function __setMswState(state: MswState): void;
|
|
10
|
+
export declare function __clearMswState(): void;
|
|
11
|
+
export declare function setMswAsReady(): void;
|
|
12
|
+
export declare function isMswReady(): boolean;
|
|
13
|
+
export declare function addMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
14
|
+
export declare function removeMswStateChangedListener(callback: MswStateChangedListener): void;
|
package/dist/mswState.js
CHANGED
|
@@ -1 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/mswState.ts?__rslib_entry__
|
|
3
|
+
class MswState {
|
|
4
|
+
#isReady = false;
|
|
5
|
+
#stateChangedListeners = new Set();
|
|
6
|
+
addStateChangedListener(callback) {
|
|
7
|
+
this.#stateChangedListeners.add(callback);
|
|
8
|
+
}
|
|
9
|
+
removeStateChangedListener(callback) {
|
|
10
|
+
this.#stateChangedListeners.delete(callback);
|
|
11
|
+
}
|
|
12
|
+
setAsReady() {
|
|
13
|
+
if (!this.#isReady) {
|
|
14
|
+
this.#isReady = true;
|
|
15
|
+
this.#stateChangedListeners.forEach((x)=>{
|
|
16
|
+
x();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get isReady() {
|
|
21
|
+
return this.#isReady;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let mswState;
|
|
25
|
+
function getMswState() {
|
|
26
|
+
if (!mswState) {
|
|
27
|
+
mswState = new MswState();
|
|
28
|
+
}
|
|
29
|
+
return mswState;
|
|
30
|
+
}
|
|
31
|
+
// This function should only be used by tests.
|
|
32
|
+
function __setMswState(state) {
|
|
33
|
+
mswState = state;
|
|
34
|
+
}
|
|
35
|
+
// This function should only be used by tests.
|
|
36
|
+
function __clearMswState() {
|
|
37
|
+
mswState = undefined;
|
|
38
|
+
}
|
|
39
|
+
function setMswAsReady() {
|
|
40
|
+
getMswState().setAsReady();
|
|
41
|
+
}
|
|
42
|
+
function isMswReady() {
|
|
43
|
+
return getMswState().isReady;
|
|
44
|
+
}
|
|
45
|
+
function addMswStateChangedListener(callback) {
|
|
46
|
+
getMswState().addStateChangedListener(callback);
|
|
47
|
+
}
|
|
48
|
+
function removeMswStateChangedListener(callback) {
|
|
49
|
+
getMswState().removeStateChangedListener(callback);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { MswState, __clearMswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=mswState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mswState.js","sources":["webpack://@squide/msw/./src/mswState.ts"],"sourcesContent":["export type MswStateChangedListener = () => void;\n\nexport class MswState {\n #isReady = false;\n\n readonly #stateChangedListeners = new Set<MswStateChangedListener>();\n\n addStateChangedListener(callback: MswStateChangedListener) {\n this.#stateChangedListeners.add(callback);\n }\n\n removeStateChangedListener(callback: MswStateChangedListener) {\n this.#stateChangedListeners.delete(callback);\n }\n\n setAsReady() {\n if (!this.#isReady) {\n this.#isReady = true;\n\n this.#stateChangedListeners.forEach(x => {\n x();\n });\n }\n }\n\n get isReady() {\n return this.#isReady;\n }\n}\n\nlet mswState: MswState | undefined;\n\nfunction getMswState() {\n if (!mswState) {\n mswState = new MswState();\n }\n\n return mswState;\n}\n\n// This function should only be used by tests.\nexport function __setMswState(state: MswState) {\n mswState = state;\n}\n\n// This function should only be used by tests.\nexport function __clearMswState() {\n mswState = undefined;\n}\n\nexport function setMswAsReady() {\n getMswState().setAsReady();\n}\n\nexport function isMswReady() {\n return getMswState().isReady;\n}\n\nexport function addMswStateChangedListener(callback: MswStateChangedListener) {\n getMswState().addStateChangedListener(callback);\n}\n\nexport function removeMswStateChangedListener(callback: MswStateChangedListener) {\n getMswState().removeStateChangedListener(callback);\n}\n"],"names":["MswState","Set","callback","x","mswState","getMswState","__setMswState","state","__clearMswState","undefined","setMswAsReady","isMswReady","addMswStateChangedListener","removeMswStateChangedListener"],"mappings":";;AAEO,MAAMA;IACT,QAAQ,GAAG,MAAM;IAER,sBAAsB,GAAG,IAAIC,MAA+B;IAErE,wBAAwBC,QAAiC,EAAE;QACvD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACA;IACpC;IAEA,2BAA2BA,QAAiC,EAAE;QAC1D,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAACA;IACvC;IAEA,aAAa;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG;YAEhB,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAACC,CAAAA;gBAChCA;YACJ;QACJ;IACJ;IAEA,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ;AAEA,IAAIC;AAEJ,SAASC;IACL,IAAI,CAACD,UAAU;QACXA,WAAW,IAAIJ;IACnB;IAEA,OAAOI;AACX;AAEA,8CAA8C;AACvC,SAASE,cAAcC,KAAe;IACzCH,WAAWG;AACf;AAEA,8CAA8C;AACvC,SAASC;IACZJ,WAAWK;AACf;AAEO,SAASC;IACZL,cAAc,UAAU;AAC5B;AAEO,SAASM;IACZ,OAAON,cAAc,OAAO;AAChC;AAEO,SAASO,2BAA2BV,QAAiC;IACxEG,cAAc,uBAAuB,CAACH;AAC1C;AAEO,SAASW,8BAA8BX,QAAiC;IAC3EG,cAAc,0BAA0B,CAACH;AAC7C"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { RequestHandler } from
|
|
2
|
-
|
|
3
|
-
declare class RequestHandlerRegistry {
|
|
1
|
+
import type { RequestHandler } from "msw";
|
|
2
|
+
export declare class RequestHandlerRegistry {
|
|
4
3
|
#private;
|
|
5
4
|
add(handlers: RequestHandler[]): void;
|
|
6
5
|
get handlers(): RequestHandler[];
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
export { RequestHandlerRegistry };
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__mswState_js_15009c7d__ from "./mswState.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./mswState.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/requestHandlerRegistry.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
class RequestHandlerRegistry {
|
|
8
|
+
#handlers = [];
|
|
9
|
+
add(handlers) {
|
|
10
|
+
if ((0,__WEBPACK_EXTERNAL_MODULE__mswState_js_15009c7d__.isMswReady)()) {
|
|
11
|
+
throw new Error("[squide] MSW request handlers cannot be registered once MSW is started. Did you defer the registration of a MSW request handler?");
|
|
12
|
+
}
|
|
13
|
+
this.#handlers.push(...handlers);
|
|
14
|
+
}
|
|
15
|
+
// Must specify the return type, otherwise we get a TS2742: The inferred type cannot be named without a reference to X. This is likely not portable.
|
|
16
|
+
// A type annotation is necessary.
|
|
17
|
+
get handlers() {
|
|
18
|
+
return this.#handlers;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { RequestHandlerRegistry };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=requestHandlerRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestHandlerRegistry.js","sources":["webpack://@squide/msw/./src/requestHandlerRegistry.ts"],"sourcesContent":["import type { RequestHandler } from \"msw\";\nimport { isMswReady } from \"./mswState.ts\";\n\nexport class RequestHandlerRegistry {\n readonly #handlers: RequestHandler[] = [];\n\n add(handlers: RequestHandler[]) {\n if (isMswReady()) {\n throw new Error(\"[squide] MSW request handlers cannot be registered once MSW is started. Did you defer the registration of a MSW request handler?\");\n }\n\n this.#handlers.push(...handlers);\n }\n\n // Must specify the return type, otherwise we get a TS2742: The inferred type cannot be named without a reference to X. This is likely not portable.\n // A type annotation is necessary.\n get handlers(): RequestHandler[] {\n return this.#handlers;\n }\n}\n\n"],"names":["isMswReady","RequestHandlerRegistry","handlers","Error"],"mappings":";;;;;AAC2C;AAEpC,MAAMC;IACA,SAAS,GAAqB,EAAE,CAAC;IAE1C,IAAIC,QAA0B,EAAE;QAC5B,IAAIF,gEAAUA,IAAI;YACd,MAAM,IAAIG,MAAM;QACpB;QAEA,IAAI,CAAC,SAAS,CAAC,IAAI,IAAID;IAC3B;IAEA,oJAAoJ;IACpJ,kCAAkC;IAClC,IAAI,WAA6B;QAC7B,OAAO,IAAI,CAAC,SAAS;IACzB;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/msw",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.3",
|
|
5
5
|
"description": "Add support for MSW to @squide application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/workleap/wl-squide.git",
|
|
10
10
|
"directory": "packages/msw"
|
|
11
11
|
},
|
|
12
|
+
"type": "module",
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"access": "public",
|
|
14
15
|
"provenance": true
|
|
15
16
|
},
|
|
16
|
-
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
@@ -22,42 +22,40 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"
|
|
25
|
+
"src",
|
|
26
|
+
"dist",
|
|
26
27
|
"CHANGELOG.md",
|
|
27
28
|
"README.md"
|
|
28
29
|
],
|
|
29
30
|
"peerDependencies": {
|
|
30
|
-
"msw": "*"
|
|
31
|
-
"react": "*",
|
|
32
|
-
"react-dom": "*"
|
|
31
|
+
"msw": "*"
|
|
33
32
|
},
|
|
34
33
|
"peerDependenciesMeta": {
|
|
35
34
|
"msw": {
|
|
36
35
|
"optional": true
|
|
37
36
|
}
|
|
38
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@squide/core": "5.4.3"
|
|
40
|
+
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@workleap/
|
|
42
|
+
"@rsbuild/core": "1.2.19",
|
|
43
|
+
"@rslib/core": "0.5.4",
|
|
44
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
45
|
+
"@workleap/eslint-plugin": "3.3.0",
|
|
46
|
+
"@workleap/rslib-configs": "1.0.2",
|
|
44
47
|
"@workleap/typescript-configs": "3.0.2",
|
|
45
48
|
"eslint": "8.57.0",
|
|
46
|
-
"msw": "2.
|
|
47
|
-
"
|
|
48
|
-
"react-dom": "18.3.1",
|
|
49
|
-
"tsup": "8.3.5",
|
|
50
|
-
"typescript": "5.5.4"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@squide/core": "5.4.1"
|
|
49
|
+
"msw": "2.7.3",
|
|
50
|
+
"typescript": "5.8.2"
|
|
54
51
|
},
|
|
55
52
|
"sideEffects": false,
|
|
56
53
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
54
|
+
"node": ">=21.1.0"
|
|
58
55
|
},
|
|
59
56
|
"scripts": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
57
|
+
"build": "rslib build --config ./rslib.build.ts",
|
|
58
|
+
"eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
|
|
59
|
+
"typecheck": "tsc"
|
|
62
60
|
}
|
|
63
61
|
}
|
package/src/index.ts
ADDED
package/src/mswPlugin.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Plugin, isNil, type Runtime } from "@squide/core";
|
|
2
|
+
import type { RequestHandler } from "msw";
|
|
3
|
+
import { RequestHandlerRegistry } from "./requestHandlerRegistry.ts";
|
|
4
|
+
|
|
5
|
+
export const MswPluginName = "msw-plugin";
|
|
6
|
+
|
|
7
|
+
export class MswPlugin extends Plugin {
|
|
8
|
+
readonly #requestHandlerRegistry = new RequestHandlerRegistry();
|
|
9
|
+
|
|
10
|
+
constructor(runtime: Runtime) {
|
|
11
|
+
super(MswPluginName, runtime);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
registerRequestHandlers(handlers: RequestHandler[]) {
|
|
15
|
+
this.#requestHandlerRegistry.add(handlers);
|
|
16
|
+
|
|
17
|
+
this._runtime.logger.debug("[squide] The following MSW request handlers has been registered: ", handlers);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get requestHandlers(): RequestHandler[] {
|
|
21
|
+
return this.#requestHandlerRegistry.handlers;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getMswPlugin(runtime: Runtime) {
|
|
26
|
+
const plugin = runtime.getPlugin(MswPluginName);
|
|
27
|
+
|
|
28
|
+
if (isNil(plugin)) {
|
|
29
|
+
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return plugin as MswPlugin;
|
|
33
|
+
}
|
package/src/mswState.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type MswStateChangedListener = () => void;
|
|
2
|
+
|
|
3
|
+
export class MswState {
|
|
4
|
+
#isReady = false;
|
|
5
|
+
|
|
6
|
+
readonly #stateChangedListeners = new Set<MswStateChangedListener>();
|
|
7
|
+
|
|
8
|
+
addStateChangedListener(callback: MswStateChangedListener) {
|
|
9
|
+
this.#stateChangedListeners.add(callback);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
removeStateChangedListener(callback: MswStateChangedListener) {
|
|
13
|
+
this.#stateChangedListeners.delete(callback);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setAsReady() {
|
|
17
|
+
if (!this.#isReady) {
|
|
18
|
+
this.#isReady = true;
|
|
19
|
+
|
|
20
|
+
this.#stateChangedListeners.forEach(x => {
|
|
21
|
+
x();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get isReady() {
|
|
27
|
+
return this.#isReady;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let mswState: MswState | undefined;
|
|
32
|
+
|
|
33
|
+
function getMswState() {
|
|
34
|
+
if (!mswState) {
|
|
35
|
+
mswState = new MswState();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return mswState;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// This function should only be used by tests.
|
|
42
|
+
export function __setMswState(state: MswState) {
|
|
43
|
+
mswState = state;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// This function should only be used by tests.
|
|
47
|
+
export function __clearMswState() {
|
|
48
|
+
mswState = undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function setMswAsReady() {
|
|
52
|
+
getMswState().setAsReady();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function isMswReady() {
|
|
56
|
+
return getMswState().isReady;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function addMswStateChangedListener(callback: MswStateChangedListener) {
|
|
60
|
+
getMswState().addStateChangedListener(callback);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function removeMswStateChangedListener(callback: MswStateChangedListener) {
|
|
64
|
+
getMswState().removeStateChangedListener(callback);
|
|
65
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RequestHandler } from "msw";
|
|
2
|
+
import { isMswReady } from "./mswState.ts";
|
|
3
|
+
|
|
4
|
+
export class RequestHandlerRegistry {
|
|
5
|
+
readonly #handlers: RequestHandler[] = [];
|
|
6
|
+
|
|
7
|
+
add(handlers: RequestHandler[]) {
|
|
8
|
+
if (isMswReady()) {
|
|
9
|
+
throw new Error("[squide] MSW request handlers cannot be registered once MSW is started. Did you defer the registration of a MSW request handler?");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.#handlers.push(...handlers);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Must specify the return type, otherwise we get a TS2742: The inferred type cannot be named without a reference to X. This is likely not portable.
|
|
16
|
+
// A type annotation is necessary.
|
|
17
|
+
get handlers(): RequestHandler[] {
|
|
18
|
+
return this.#handlers;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
package/dist/chunk-CL6F3JZI.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isMswReady } from './chunk-YBOXRDQQ.js';
|
|
2
|
-
|
|
3
|
-
// src/requestHandlerRegistry.ts
|
|
4
|
-
var RequestHandlerRegistry = class {
|
|
5
|
-
#handlers = [];
|
|
6
|
-
add(handlers) {
|
|
7
|
-
if (isMswReady()) {
|
|
8
|
-
throw new Error("[squide] MSW request handlers cannot be registered once MSW is started. Did you defer the registration of a MSW request handler?");
|
|
9
|
-
}
|
|
10
|
-
this.#handlers.push(...handlers);
|
|
11
|
-
}
|
|
12
|
-
// Must specify the return type, otherwise we get a TS2742: The inferred type cannot be named without a reference to X. This is likely not portable.
|
|
13
|
-
// A type annotation is necessary.
|
|
14
|
-
get handlers() {
|
|
15
|
-
return this.#handlers;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { RequestHandlerRegistry };
|
package/dist/chunk-NDT73ZLW.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { RequestHandlerRegistry } from './chunk-CL6F3JZI.js';
|
|
2
|
-
import { Plugin, isNil } from '@squide/core';
|
|
3
|
-
|
|
4
|
-
var MswPluginName = "msw-plugin";
|
|
5
|
-
var MswPlugin = class extends Plugin {
|
|
6
|
-
#requestHandlerRegistry = new RequestHandlerRegistry();
|
|
7
|
-
constructor(runtime) {
|
|
8
|
-
super(MswPluginName, runtime);
|
|
9
|
-
}
|
|
10
|
-
registerRequestHandlers(handlers) {
|
|
11
|
-
this.#requestHandlerRegistry.add(handlers);
|
|
12
|
-
this._runtime.logger.debug("[squide] The following MSW request handlers has been registered: ", handlers);
|
|
13
|
-
}
|
|
14
|
-
get requestHandlers() {
|
|
15
|
-
return this.#requestHandlerRegistry.handlers;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
function getMswPlugin(runtime) {
|
|
19
|
-
const plugin = runtime.getPlugin(MswPluginName);
|
|
20
|
-
if (isNil(plugin)) {
|
|
21
|
-
throw new Error("[squide] The getMswPlugin function is called but no MswPlugin instance has been registered with the runtime.");
|
|
22
|
-
}
|
|
23
|
-
return plugin;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { MswPlugin, MswPluginName, getMswPlugin };
|
package/dist/chunk-YBOXRDQQ.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// src/mswState.ts
|
|
2
|
-
var MswState = class {
|
|
3
|
-
#isReady = false;
|
|
4
|
-
#stateChangedListeners = /* @__PURE__ */ new Set();
|
|
5
|
-
addStateChangedListener(callback) {
|
|
6
|
-
this.#stateChangedListeners.add(callback);
|
|
7
|
-
}
|
|
8
|
-
removeStateChangedListener(callback) {
|
|
9
|
-
this.#stateChangedListeners.delete(callback);
|
|
10
|
-
}
|
|
11
|
-
setAsReady() {
|
|
12
|
-
if (!this.#isReady) {
|
|
13
|
-
this.#isReady = true;
|
|
14
|
-
this.#stateChangedListeners.forEach((x) => {
|
|
15
|
-
x();
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
get isReady() {
|
|
20
|
-
return this.#isReady;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var mswState;
|
|
24
|
-
function getMswState() {
|
|
25
|
-
if (!mswState) {
|
|
26
|
-
mswState = new MswState();
|
|
27
|
-
}
|
|
28
|
-
return mswState;
|
|
29
|
-
}
|
|
30
|
-
function __setMswState(state) {
|
|
31
|
-
mswState = state;
|
|
32
|
-
}
|
|
33
|
-
function __clearMswState() {
|
|
34
|
-
mswState = void 0;
|
|
35
|
-
}
|
|
36
|
-
function setMswAsReady() {
|
|
37
|
-
getMswState().setAsReady();
|
|
38
|
-
}
|
|
39
|
-
function isMswReady() {
|
|
40
|
-
return getMswState().isReady;
|
|
41
|
-
}
|
|
42
|
-
function addMswStateChangedListener(callback) {
|
|
43
|
-
getMswState().addStateChangedListener(callback);
|
|
44
|
-
}
|
|
45
|
-
function removeMswStateChangedListener(callback) {
|
|
46
|
-
getMswState().removeStateChangedListener(callback);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { MswState, __clearMswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady };
|