@squide/msw 2.0.5 → 2.0.7
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 +15 -0
- package/dist/chunk-4FYK3XXP.js +44 -0
- package/dist/{chunk-OKIK46QG.js → chunk-BH5GURQ4.js} +1 -1
- package/dist/chunk-ETD3TDL4.js +20 -0
- package/dist/{chunk-2J7GQPWR.js → chunk-UJ4YM7IF.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/mswPlugin.js +3 -3
- package/dist/mswState.d.ts +16 -0
- package/dist/mswState.js +1 -0
- package/dist/requestHandlerRegistry.js +2 -2
- package/dist/useIsMswStarted.d.ts +2 -5
- package/dist/useIsMswStarted.js +2 -2
- package/package.json +6 -6
- package/dist/chunk-JLS7DBDX.js +0 -13
- package/dist/chunk-P5ONHQEP.js +0 -27
- package/dist/setMswAsStarted.d.ts +0 -5
- package/dist/setMswAsStarted.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @squide/msw
|
|
2
2
|
|
|
3
|
+
## 2.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#128](https://github.com/gsoft-inc/wl-squide/pull/128) [`4c3b6f1`](https://github.com/gsoft-inc/wl-squide/commit/4c3b6f1929364844dda6c1190fc45c3b037e8df9) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Internally changed the usage of `setInterval` for `useSyncExternalStore`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4c3b6f1`](https://github.com/gsoft-inc/wl-squide/commit/4c3b6f1929364844dda6c1190fc45c3b037e8df9)]:
|
|
10
|
+
- @squide/core@3.1.1
|
|
11
|
+
|
|
12
|
+
## 2.0.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#122](https://github.com/gsoft-inc/wl-squide/pull/122) [`cda7873`](https://github.com/gsoft-inc/wl-squide/commit/cda7873dcffbf424a625cf40c56a12eacbb2632e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Internal minor changes
|
|
17
|
+
|
|
3
18
|
## 2.0.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/mswState.ts
|
|
2
|
+
var MswState = class {
|
|
3
|
+
#isStarted = 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
|
+
setAsStarted() {
|
|
12
|
+
if (!this.#isStarted) {
|
|
13
|
+
this.#isStarted = true;
|
|
14
|
+
this.#stateChangedListeners.forEach((x) => {
|
|
15
|
+
x();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
get isStarted() {
|
|
20
|
+
return this.#isStarted;
|
|
21
|
+
}
|
|
22
|
+
// Strictly for Jest tests, this is NOT ideal.
|
|
23
|
+
_reset() {
|
|
24
|
+
this.#isStarted = false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var mswState = new MswState();
|
|
28
|
+
function setMswAsStarted() {
|
|
29
|
+
mswState.setAsStarted();
|
|
30
|
+
}
|
|
31
|
+
function isMswStarted() {
|
|
32
|
+
return mswState.isStarted;
|
|
33
|
+
}
|
|
34
|
+
function addMswStateChangedListener(callback) {
|
|
35
|
+
mswState.addStateChangedListener(callback);
|
|
36
|
+
}
|
|
37
|
+
function removeMswStateChangedListener(callback) {
|
|
38
|
+
mswState.removeStateChangedListener(callback);
|
|
39
|
+
}
|
|
40
|
+
function __resetMswStatus() {
|
|
41
|
+
mswState._reset();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { MswState, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isMswStarted, addMswStateChangedListener, removeMswStateChangedListener } from './chunk-4FYK3XXP.js';
|
|
2
|
+
import { useLogger } from '@squide/core';
|
|
3
|
+
import { useSyncExternalStore, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
function subscribe(callback) {
|
|
6
|
+
addMswStateChangedListener(callback);
|
|
7
|
+
return () => removeMswStateChangedListener(callback);
|
|
8
|
+
}
|
|
9
|
+
function useIsMswStarted(enabled) {
|
|
10
|
+
const isStarted = useSyncExternalStore(subscribe, isMswStarted);
|
|
11
|
+
const logger = useLogger();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (isStarted) {
|
|
14
|
+
logger.debug("[squide] %cMSW is ready%c.", "color: white; background-color: green;", "");
|
|
15
|
+
}
|
|
16
|
+
}, [isStarted, logger]);
|
|
17
|
+
return isStarted || !enabled;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { useIsMswStarted };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { MswPlugin, getMswPlugin } from './mswPlugin.js';
|
|
2
|
+
export { MswState, MswStateChangedListener, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted } from './mswState.js';
|
|
2
3
|
export { RequestHandlerRegistry } from './requestHandlerRegistry.js';
|
|
3
|
-
export {
|
|
4
|
-
export { UseIsMswStartedOptions, useIsMswStarted } from './useIsMswStarted.js';
|
|
4
|
+
export { useIsMswStarted } from './useIsMswStarted.js';
|
|
5
5
|
import '@squide/core';
|
|
6
6
|
import 'msw';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { MswPlugin, getMswPlugin } from './chunk-
|
|
2
|
-
export { RequestHandlerRegistry } from './chunk-
|
|
3
|
-
export { useIsMswStarted } from './chunk-
|
|
4
|
-
export { __resetMswStatus, isMswStarted, setMswAsStarted } from './chunk-
|
|
1
|
+
export { MswPlugin, getMswPlugin } from './chunk-BH5GURQ4.js';
|
|
2
|
+
export { RequestHandlerRegistry } from './chunk-UJ4YM7IF.js';
|
|
3
|
+
export { useIsMswStarted } from './chunk-ETD3TDL4.js';
|
|
4
|
+
export { MswState, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted } from './chunk-4FYK3XXP.js';
|
package/dist/mswPlugin.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MswPlugin, getMswPlugin } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { MswPlugin, getMswPlugin } from './chunk-BH5GURQ4.js';
|
|
2
|
+
import './chunk-UJ4YM7IF.js';
|
|
3
|
+
import './chunk-4FYK3XXP.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type MswStateChangedListener = () => void;
|
|
2
|
+
declare class MswState {
|
|
3
|
+
#private;
|
|
4
|
+
addStateChangedListener(callback: MswStateChangedListener): void;
|
|
5
|
+
removeStateChangedListener(callback: MswStateChangedListener): void;
|
|
6
|
+
setAsStarted(): void;
|
|
7
|
+
get isStarted(): boolean;
|
|
8
|
+
_reset(): void;
|
|
9
|
+
}
|
|
10
|
+
declare function setMswAsStarted(): void;
|
|
11
|
+
declare function isMswStarted(): boolean;
|
|
12
|
+
declare function addMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
13
|
+
declare function removeMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
14
|
+
declare function __resetMswStatus(): void;
|
|
15
|
+
|
|
16
|
+
export { MswState, type MswStateChangedListener, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted };
|
package/dist/mswState.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MswState, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted } from './chunk-4FYK3XXP.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RequestHandlerRegistry } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { RequestHandlerRegistry } from './chunk-UJ4YM7IF.js';
|
|
2
|
+
import './chunk-4FYK3XXP.js';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
interval?: number;
|
|
3
|
-
}
|
|
4
|
-
declare function useIsMswStarted(enabled: boolean, { interval }?: UseIsMswStartedOptions): boolean;
|
|
1
|
+
declare function useIsMswStarted(enabled: boolean): boolean;
|
|
5
2
|
|
|
6
|
-
export {
|
|
3
|
+
export { useIsMswStarted };
|
package/dist/useIsMswStarted.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useIsMswStarted } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { useIsMswStarted } from './chunk-ETD3TDL4.js';
|
|
2
|
+
import './chunk-4FYK3XXP.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/msw",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.7",
|
|
5
5
|
"description": "Add support for MSW to @squide federated application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "18.2.
|
|
41
|
-
"@types/react-dom": "18.2.
|
|
40
|
+
"@types/react": "18.2.39",
|
|
41
|
+
"@types/react-dom": "18.2.17",
|
|
42
42
|
"@workleap/eslint-plugin": "3.0.0",
|
|
43
43
|
"@workleap/tsup-configs": "3.0.1",
|
|
44
44
|
"@workleap/typescript-configs": "3.0.2",
|
|
45
|
-
"msw": "2.0.
|
|
45
|
+
"msw": "2.0.9",
|
|
46
46
|
"react": "18.2.0",
|
|
47
47
|
"react-dom": "18.2.0",
|
|
48
|
-
"tsup": "
|
|
48
|
+
"tsup": "8.0.1",
|
|
49
49
|
"typescript": "5.2.2"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@squide/core": "3.1.
|
|
52
|
+
"@squide/core": "3.1.1"
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"engines": {
|
package/dist/chunk-JLS7DBDX.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/setMswAsStarted.ts
|
|
2
|
-
var isStarted = false;
|
|
3
|
-
function setMswAsStarted() {
|
|
4
|
-
isStarted = true;
|
|
5
|
-
}
|
|
6
|
-
function isMswStarted() {
|
|
7
|
-
return isStarted;
|
|
8
|
-
}
|
|
9
|
-
function __resetMswStatus() {
|
|
10
|
-
isStarted = false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { __resetMswStatus, isMswStarted, setMswAsStarted };
|
package/dist/chunk-P5ONHQEP.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isMswStarted } from './chunk-JLS7DBDX.js';
|
|
2
|
-
import { useLogger } from '@squide/core';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
function useIsMswStarted(enabled, { interval = 10 } = {}) {
|
|
6
|
-
const logger = useLogger();
|
|
7
|
-
const [value, setIsStarted] = useState(!enabled);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (enabled) {
|
|
10
|
-
const intervalId = setInterval(() => {
|
|
11
|
-
if (isMswStarted()) {
|
|
12
|
-
logger.debug("[squide] %cMSW is ready%c.", "color: white; background-color: green;", "");
|
|
13
|
-
clearInterval(intervalId);
|
|
14
|
-
setIsStarted(true);
|
|
15
|
-
}
|
|
16
|
-
}, interval);
|
|
17
|
-
return () => {
|
|
18
|
-
if (intervalId) {
|
|
19
|
-
clearInterval(intervalId);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}, [enabled]);
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { useIsMswStarted };
|
package/dist/setMswAsStarted.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { __resetMswStatus, isMswStarted, setMswAsStarted } from './chunk-JLS7DBDX.js';
|