@squide/msw 2.0.13 → 3.0.0
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 +68 -0
- package/dist/chunk-2FX5W4F5.js +46 -0
- package/dist/{chunk-UJ4YM7IF.js → chunk-AMKPYN4M.js} +2 -2
- package/dist/{chunk-BH5GURQ4.js → chunk-W5GMS2JV.js} +4 -8
- package/dist/index.d.ts +1 -2
- package/dist/index.js +3 -4
- package/dist/mswPlugin.d.ts +1 -2
- package/dist/mswPlugin.js +3 -3
- package/dist/mswState.d.ts +6 -7
- package/dist/mswState.js +1 -1
- package/dist/requestHandlerRegistry.js +2 -2
- package/package.json +14 -13
- package/dist/chunk-4FYK3XXP.js +0 -44
- package/dist/chunk-67NM4MII.js +0 -20
- package/dist/useIsMswStarted.d.ts +0 -3
- package/dist/useIsMswStarted.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @squide/msw
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#182](https://github.com/gsoft-inc/wl-squide/pull/182) [`58cf066`](https://github.com/gsoft-inc/wl-squide/commit/58cf066e87e23611510c254cca96016bd2bad08a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - ## Firefly v9
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
Prior to v9, Squide applications couldn't use TanStack Query to fetch global data, making it challenging for Workleap's applications to keep their global data in sync with the server state. With v9, applications can now leverage custom wrappers of the useQueries hook to fetch and keep their global data up-to-date with the server state. Additionally, the new deferred registrations update feature allows applications to even keep their conditional navigation items in sync with the server state.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
> For a full breakdown of the changres and a migration procedure, read the following [documentation](https://gsoft-inc.github.io/wl-squide/guides/migrate-to-firefly-v9/).
|
|
16
|
+
|
|
17
|
+
## Breaking changes
|
|
18
|
+
|
|
19
|
+
- The `useAreModulesRegistered` hook has been removed, use the `useIsBootstrapping` hook instead.
|
|
20
|
+
- The `useAreModulesReady` hook has been removed, use the `useIsBootstrapping` hook instead.
|
|
21
|
+
- The `useIsMswStarted` hook has been removed, use the `useIsBootstrapping` hook instead.
|
|
22
|
+
- The `completeModuleRegistrations` function as been removed use the `useDeferredRegistrations` hook instead.
|
|
23
|
+
- The `completeLocalModulesRegistrations` function has been removed use the `useDeferredRegistrations` hook instead.
|
|
24
|
+
- The `completeRemoteModuleRegistrations` function has been removed use the `useDeferredRegistrations` hook instead.
|
|
25
|
+
- The `useSession` hook has been removed, define your own React context instead.
|
|
26
|
+
- The `useIsAuthenticated` hook has been removed, define your own React context instead.
|
|
27
|
+
- The `sessionAccessor` option has been removed from the `FireflyRuntime` options, define your own React context instead.
|
|
28
|
+
- Removed supports for deferred routes.
|
|
29
|
+
- Plugin's constructor now requires a runtime instance argument.
|
|
30
|
+
- Plugins now registers with a factory function.
|
|
31
|
+
- Full rewrite of the `AppRouter` component.
|
|
32
|
+
|
|
33
|
+
## Renamed
|
|
34
|
+
|
|
35
|
+
- The `setMswAsStarted` function has been renamed to `setMswIsReady`.
|
|
36
|
+
|
|
37
|
+
## Others
|
|
38
|
+
|
|
39
|
+
- The `@squide/firefly` package now takes a peerDependency on `@tanstack/react-query`.
|
|
40
|
+
- The `@squide/firefly` package doesn't takes a peerDependency on `react-error-boundary` anymore.
|
|
41
|
+
|
|
42
|
+
## New hooks and functions
|
|
43
|
+
|
|
44
|
+
- A new `useIsBoostrapping` hook is now available.
|
|
45
|
+
- A new `useDeferredRegistrations` hook is now available.
|
|
46
|
+
- A new `usePublicDataQueries` hook is now available.
|
|
47
|
+
- A new `useProtectedDataQueries` hook is now available.
|
|
48
|
+
- A new `isGlobalDataQueriesError` function is now available.
|
|
49
|
+
|
|
50
|
+
## Improvements
|
|
51
|
+
|
|
52
|
+
- Deferred registration functions now always receive a `data` argument.
|
|
53
|
+
- Deferred registration functions now receives a new `operation` argument.
|
|
54
|
+
- Navigation items now include a `$canRender` option, enabling modules to control whether a navigation item should be rendered.
|
|
55
|
+
- New `$key` option for navigation items.
|
|
56
|
+
|
|
57
|
+
For more details about the changes and a migration procedure, read the following [documentation](https://gsoft-inc.github.io/wl-squide/guides/migrate-to-firefly-v9/).
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [[`58cf066`](https://github.com/gsoft-inc/wl-squide/commit/58cf066e87e23611510c254cca96016bd2bad08a)]:
|
|
62
|
+
- @squide/core@5.0.0
|
|
63
|
+
|
|
64
|
+
## 2.0.14
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [[`89ace29`](https://github.com/gsoft-inc/wl-squide/commit/89ace29b9aeadbbe83cfa71dd137b9f1a115c283)]:
|
|
69
|
+
- @squide/core@4.0.0
|
|
70
|
+
|
|
3
71
|
## 2.0.13
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
|
@@ -0,0 +1,46 @@
|
|
|
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 setMswAsReady() {
|
|
34
|
+
getMswState().setAsReady();
|
|
35
|
+
}
|
|
36
|
+
function isMswReady() {
|
|
37
|
+
return getMswState().isReady;
|
|
38
|
+
}
|
|
39
|
+
function addMswStateChangedListener(callback) {
|
|
40
|
+
getMswState().addStateChangedListener(callback);
|
|
41
|
+
}
|
|
42
|
+
function removeMswStateChangedListener(callback) {
|
|
43
|
+
getMswState().removeStateChangedListener(callback);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { MswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isMswReady } from './chunk-2FX5W4F5.js';
|
|
2
2
|
|
|
3
3
|
// src/requestHandlerRegistry.ts
|
|
4
4
|
var RequestHandlerRegistry = class {
|
|
5
5
|
#handlers = [];
|
|
6
6
|
add(handlers) {
|
|
7
|
-
if (
|
|
7
|
+
if (isMswReady()) {
|
|
8
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
9
|
}
|
|
10
10
|
this.#handlers.push(...handlers);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { RequestHandlerRegistry } from './chunk-
|
|
1
|
+
import { RequestHandlerRegistry } from './chunk-AMKPYN4M.js';
|
|
2
2
|
import { Plugin, isNil } from '@squide/core';
|
|
3
3
|
|
|
4
4
|
var MswPlugin = class _MswPlugin extends Plugin {
|
|
5
|
-
#runtime;
|
|
6
5
|
#requestHandlerRegistry = new RequestHandlerRegistry();
|
|
7
|
-
constructor() {
|
|
8
|
-
super(_MswPlugin.name);
|
|
9
|
-
}
|
|
10
|
-
_setRuntime(runtime) {
|
|
11
|
-
this.#runtime = runtime;
|
|
6
|
+
constructor(runtime) {
|
|
7
|
+
super(_MswPlugin.name, runtime);
|
|
12
8
|
}
|
|
13
9
|
registerRequestHandlers(handlers) {
|
|
14
10
|
this.#requestHandlerRegistry.add(handlers);
|
|
15
|
-
this
|
|
11
|
+
this._runtime.logger.debug("[squide] The following MSW request handlers has been registered: ", handlers);
|
|
16
12
|
}
|
|
17
13
|
get requestHandlers() {
|
|
18
14
|
return this.#requestHandlerRegistry.handlers;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { MswPlugin, getMswPlugin } from './mswPlugin.js';
|
|
2
|
-
export { MswState, MswStateChangedListener,
|
|
2
|
+
export { MswState, MswStateChangedListener, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady } from './mswState.js';
|
|
3
3
|
export { RequestHandlerRegistry } from './requestHandlerRegistry.js';
|
|
4
|
-
export { useIsMswStarted } from './useIsMswStarted.js';
|
|
5
4
|
import '@squide/core';
|
|
6
5
|
import 'msw';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { MswPlugin, getMswPlugin } from './chunk-
|
|
2
|
-
export { RequestHandlerRegistry } from './chunk-
|
|
3
|
-
export {
|
|
4
|
-
export { MswState, __resetMswStatus, addMswStateChangedListener, isMswStarted, removeMswStateChangedListener, setMswAsStarted } from './chunk-4FYK3XXP.js';
|
|
1
|
+
export { MswPlugin, getMswPlugin } from './chunk-W5GMS2JV.js';
|
|
2
|
+
export { RequestHandlerRegistry } from './chunk-AMKPYN4M.js';
|
|
3
|
+
export { MswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady } from './chunk-2FX5W4F5.js';
|
package/dist/mswPlugin.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { RequestHandler } from 'msw';
|
|
|
3
3
|
|
|
4
4
|
declare class MswPlugin extends Plugin {
|
|
5
5
|
#private;
|
|
6
|
-
constructor();
|
|
7
|
-
_setRuntime(runtime: Runtime): void;
|
|
6
|
+
constructor(runtime: Runtime);
|
|
8
7
|
registerRequestHandlers(handlers: RequestHandler[]): void;
|
|
9
8
|
get requestHandlers(): RequestHandler[];
|
|
10
9
|
}
|
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-W5GMS2JV.js';
|
|
2
|
+
import './chunk-AMKPYN4M.js';
|
|
3
|
+
import './chunk-2FX5W4F5.js';
|
package/dist/mswState.d.ts
CHANGED
|
@@ -3,14 +3,13 @@ declare class MswState {
|
|
|
3
3
|
#private;
|
|
4
4
|
addStateChangedListener(callback: MswStateChangedListener): void;
|
|
5
5
|
removeStateChangedListener(callback: MswStateChangedListener): void;
|
|
6
|
-
|
|
7
|
-
get
|
|
8
|
-
_reset(): void;
|
|
6
|
+
setAsReady(): void;
|
|
7
|
+
get isReady(): boolean;
|
|
9
8
|
}
|
|
10
|
-
declare function
|
|
11
|
-
declare function
|
|
9
|
+
declare function __setMswState(state: MswState): void;
|
|
10
|
+
declare function setMswAsReady(): void;
|
|
11
|
+
declare function isMswReady(): boolean;
|
|
12
12
|
declare function addMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
13
13
|
declare function removeMswStateChangedListener(callback: MswStateChangedListener): void;
|
|
14
|
-
declare function __resetMswStatus(): void;
|
|
15
14
|
|
|
16
|
-
export { MswState, type MswStateChangedListener,
|
|
15
|
+
export { MswState, type MswStateChangedListener, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady };
|
package/dist/mswState.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MswState,
|
|
1
|
+
export { MswState, __setMswState, addMswStateChangedListener, isMswReady, removeMswStateChangedListener, setMswAsReady } from './chunk-2FX5W4F5.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RequestHandlerRegistry } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { RequestHandlerRegistry } from './chunk-AMKPYN4M.js';
|
|
2
|
+
import './chunk-2FX5W4F5.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/msw",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"description": "Add support for MSW to @squide federated application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"import": "./dist/index.js",
|
|
20
19
|
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
21
|
"default": "./dist/index.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -37,23 +37,24 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "18.
|
|
41
|
-
"@types/react-dom": "18.
|
|
42
|
-
"@workleap/eslint-plugin": "3.
|
|
43
|
-
"@workleap/tsup-configs": "3.0.
|
|
40
|
+
"@types/react": "18.3.3",
|
|
41
|
+
"@types/react-dom": "18.3.0",
|
|
42
|
+
"@workleap/eslint-plugin": "3.2.2",
|
|
43
|
+
"@workleap/tsup-configs": "3.0.6",
|
|
44
44
|
"@workleap/typescript-configs": "3.0.2",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"react
|
|
48
|
-
"
|
|
49
|
-
"
|
|
45
|
+
"eslint": "8.57.0",
|
|
46
|
+
"msw": "2.3.1",
|
|
47
|
+
"react": "18.3.1",
|
|
48
|
+
"react-dom": "18.3.1",
|
|
49
|
+
"tsup": "8.1.2",
|
|
50
|
+
"typescript": "5.5.3"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@squide/core": "
|
|
53
|
+
"@squide/core": "5.0.0"
|
|
53
54
|
},
|
|
54
55
|
"sideEffects": false,
|
|
55
56
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
57
|
+
"node": ">=20.0.0"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"dev": "tsup --config ./tsup.dev.ts",
|
package/dist/chunk-4FYK3XXP.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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 };
|
package/dist/chunk-67NM4MII.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isMswStarted, addMswStateChangedListener, removeMswStateChangedListener } from './chunk-4FYK3XXP.js';
|
|
2
|
-
import { useLogOnceLogger } 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 = useLogOnceLogger();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (isStarted) {
|
|
14
|
-
logger.debugOnce("msw-is-started", "[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/useIsMswStarted.js
DELETED