@equinor/fusion-framework-react-app 14.0.0 → 15.0.0-next.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 +69 -0
- package/README.md +9 -2
- package/dist/esm/create-component.js +1 -1
- package/dist/esm/msal/useToken.js +12 -3
- package/dist/esm/msal/useToken.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/create-component.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/docs/bookmark.md +7 -0
- package/docs/context.md +3 -1
- package/docs/framework.md +2 -2
- package/docs/msal.md +3 -3
- package/package.json +33 -25
- package/src/__tests__/Apploader.test.tsx +51 -0
- package/src/__tests__/fixtures/apploader-child-script.ts +9 -0
- package/src/__tests__/testApp.test.tsx +47 -0
- package/src/__tests__/useAccessToken.test.tsx +51 -0
- package/src/__tests__/useAppSetting.test.tsx +133 -0
- package/src/__tests__/useAppSettings.test.tsx +147 -0
- package/src/__tests__/useCurrentAccount.test.tsx +32 -0
- package/src/__tests__/useCurrentBookmark.test.tsx +108 -0
- package/src/__tests__/useCurrentContext.test.tsx +72 -0
- package/src/__tests__/useFeature.test.tsx +104 -0
- package/src/__tests__/useHelpCenter.test.tsx +64 -0
- package/src/__tests__/useStateSyncEvents.test.ts +12 -11
- package/src/__tests__/useToken.test.tsx +71 -0
- package/src/__tests__/useTrackFeature.test.tsx +83 -0
- package/src/create-component.tsx +1 -1
- package/src/msal/useToken.ts +14 -3
- package/src/version.ts +1 -1
- package/tsconfig.json +3 -0
- package/vitest.config.ts +2 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 15.0.0-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e8aae1f: Internal: publish every package on the `next` pre-release tag so the whole framework can be installed as a coherent set.
|
|
8
|
+
|
|
9
|
+
Packages without their own changes are bumped only to receive a `-next.N` version and the `next` dist-tag on npm. Install with:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @equinor/fusion-framework-react-app@next
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- 2836e0b: Fix documentation accuracy issues found while adding hook test coverage:
|
|
16
|
+
|
|
17
|
+
- The README and a deprecated `createComponent` example showed `configurator.http.configureClient(...)` for registering an app's HTTP client. That property only exists on the test/mock configurator (`AppMockConfigurator`) — real app configuration must use `configurator.configureHttpClient(...)` from `IAppConfigurator`. Both examples now use the correct API.
|
|
18
|
+
- `docs/context.md` and `docs/framework.md` documented `setCurrentContext`/`useFrameworkCurrentContext`'s setter as returning `void`. It actually returns `void | Promise<ContextItem | null>` — `void` when clearing the context, a `Promise` when setting by id or by item — and can be awaited to know when the switch completes.
|
|
19
|
+
- `docs/msal.md` documented `AuthenticationResult.account`/`expiresOn` as non-nullable; both are actually nullable (`AccountInfo | null`, `Date | null`), and the `useToken` example has been updated to guard against a `null` `expiresOn`.
|
|
20
|
+
- `docs/bookmark.md` now documents `useCurrentBookmark`'s deprecated fallback to the framework-scoped bookmark provider (and the `@deprecation` console warning it logs) when an app hasn't called `enableBookmark`.
|
|
21
|
+
|
|
22
|
+
- 2836e0b: Remove `docs/testing.md` and replace the README's testing section with a pointer to `@equinor/fusion-framework-vitest-plugin-react-app`, now that `renderAppHook`, `renderAppComponent`, `testApp`, and the `appTestVitePlugin` Vite plugin live in that separate package instead of this one. Both described the old `./vitest` entry-point as requiring a legacy DOM test renderer and returning a top-level `modules` field, which no longer applies now that the helpers are built on `vitest-browser-react` and return a nested `fusion: { framework, app }` object. The README's API-reference table no longer lists a `/vitest` entry-point.
|
|
23
|
+
- 2836e0b: Document the supported `renderAppHook` and `renderAppComponent` testing helpers so app teams can verify app-scoped hooks and components against a real, mock-backed application module scope.
|
|
24
|
+
|
|
25
|
+
Closes equinor/fusion-core-tasks#1716.
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [e8aae1f]
|
|
28
|
+
- Updated dependencies [2836e0b]
|
|
29
|
+
- Updated dependencies [2836e0b]
|
|
30
|
+
- Updated dependencies [2836e0b]
|
|
31
|
+
- Updated dependencies [2836e0b]
|
|
32
|
+
- Updated dependencies [2836e0b]
|
|
33
|
+
- Updated dependencies [2836e0b]
|
|
34
|
+
- Updated dependencies [2836e0b]
|
|
35
|
+
- Updated dependencies [2836e0b]
|
|
36
|
+
- Updated dependencies [2836e0b]
|
|
37
|
+
- Updated dependencies [2836e0b]
|
|
38
|
+
- Updated dependencies [2836e0b]
|
|
39
|
+
- Updated dependencies [2836e0b]
|
|
40
|
+
- Updated dependencies [2836e0b]
|
|
41
|
+
- Updated dependencies [2836e0b]
|
|
42
|
+
- Updated dependencies [2836e0b]
|
|
43
|
+
- Updated dependencies [2836e0b]
|
|
44
|
+
- Updated dependencies [2836e0b]
|
|
45
|
+
- Updated dependencies [2836e0b]
|
|
46
|
+
- Updated dependencies [2836e0b]
|
|
47
|
+
- Updated dependencies [2836e0b]
|
|
48
|
+
- Updated dependencies [2836e0b]
|
|
49
|
+
- Updated dependencies [2836e0b]
|
|
50
|
+
- Updated dependencies [2836e0b]
|
|
51
|
+
- Updated dependencies [2836e0b]
|
|
52
|
+
- Updated dependencies [2836e0b]
|
|
53
|
+
- @equinor/fusion-framework@8.1.0-next.0
|
|
54
|
+
- @equinor/fusion-framework-app@14.0.0-next.0
|
|
55
|
+
- @equinor/fusion-framework-module@6.1.3-next.0
|
|
56
|
+
- @equinor/fusion-framework-module-app@8.1.0-next.0
|
|
57
|
+
- @equinor/fusion-framework-module-http@8.1.0-next.0
|
|
58
|
+
- @equinor/fusion-framework-module-msal@11.0.0-next.0
|
|
59
|
+
- @equinor/fusion-framework-module-navigation@7.0.8-next.0
|
|
60
|
+
- @equinor/fusion-framework-module-state@2.0.1-next.0
|
|
61
|
+
- @equinor/fusion-framework-react@9.0.0-next.0
|
|
62
|
+
- @equinor/fusion-framework-react-module@4.0.3-next.0
|
|
63
|
+
- @equinor/fusion-framework-react-module-http@12.0.0-next.0
|
|
64
|
+
- @equinor/fusion-framework-react-router@2.4.1-next.0
|
|
65
|
+
|
|
66
|
+
## 14.0.1
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- @equinor/fusion-framework-app@13.0.1
|
|
71
|
+
|
|
3
72
|
## 14.0.0
|
|
4
73
|
|
|
5
74
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ pnpm add @equinor/fusion-framework-react-app
|
|
|
25
25
|
import type { AppModuleInitiator } from '@equinor/fusion-framework-react-app';
|
|
26
26
|
|
|
27
27
|
export const configure: AppModuleInitiator = (configurator) => {
|
|
28
|
-
configurator.
|
|
28
|
+
configurator.configureHttpClient('my-api', {
|
|
29
29
|
baseUri: 'https://api.example.com',
|
|
30
30
|
defaultScopes: ['api://my-api/.default'],
|
|
31
31
|
});
|
|
@@ -372,6 +372,13 @@ const EnvInfo = () => {
|
|
|
372
372
|
};
|
|
373
373
|
```
|
|
374
374
|
|
|
375
|
+
### Testing
|
|
376
|
+
|
|
377
|
+
Testing utilities (`renderAppHook`, `renderAppComponent`, `testApp`, and a Vitest plugin
|
|
378
|
+
resolving an app's own manifest/config as virtual modules) have moved to their own package,
|
|
379
|
+
[`@equinor/fusion-framework-vitest-plugin-react-app`](../../vitest-plugin/react-app/README.md) —
|
|
380
|
+
see that package's README for usage.
|
|
381
|
+
|
|
375
382
|
## API Reference
|
|
376
383
|
|
|
377
384
|
### Core exports (main entry-point)
|
|
@@ -412,7 +419,7 @@ Application configuration is done via a callback passed to `renderApp` (or `make
|
|
|
412
419
|
```ts
|
|
413
420
|
const configure: AppModuleInitiator = (configurator) => {
|
|
414
421
|
// HTTP clients
|
|
415
|
-
configurator.
|
|
422
|
+
configurator.configureHttpClient('my-api', { baseUri: '...' });
|
|
416
423
|
|
|
417
424
|
// Feature flags
|
|
418
425
|
enableFeatureFlag(configurator, [{ key: 'beta', title: 'Beta' }]);
|
|
@@ -21,7 +21,7 @@ import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-r
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```tsx
|
|
23
23
|
* const configCallback: AppConfigurator = (configurator) => {
|
|
24
|
-
* configurator.
|
|
24
|
+
* configurator.configureHttpClient(
|
|
25
25
|
* 'bar', {
|
|
26
26
|
* baseUri: 'https://somewhere-test.com',
|
|
27
27
|
* defaultScopes: ['foo/.default']
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import useAppModule from '../useAppModule';
|
|
3
3
|
/**
|
|
4
4
|
* React hook that acquires a full MSAL {@link AuthenticationResult} for the
|
|
@@ -26,11 +26,20 @@ export const useToken = (req) => {
|
|
|
26
26
|
const [token, setToken] = useState(undefined);
|
|
27
27
|
const [pending, setPending] = useState(false);
|
|
28
28
|
const [error, setError] = useState(null);
|
|
29
|
+
// `req` is typically a fresh object literal each render; key the effect on its
|
|
30
|
+
// scopes' content instead of identity, so it doesn't re-run (and reset `pending`
|
|
31
|
+
// to `true` forever) every time the caller re-renders. `JSON.stringify` (rather than
|
|
32
|
+
// `.join(',')`) keeps scopes with different array boundaries (e.g. `['a,b']` vs.
|
|
33
|
+
// `['a', 'b']`) from colliding on the same key.
|
|
34
|
+
const scopesKey = JSON.stringify(req.scopes);
|
|
35
|
+
const reqRef = useRef(req);
|
|
36
|
+
reqRef.current = req;
|
|
37
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: scopesKey is a re-run trigger, not read in the body
|
|
29
38
|
useEffect(() => {
|
|
30
39
|
setPending(true);
|
|
31
40
|
setToken(undefined);
|
|
32
41
|
msalProvider
|
|
33
|
-
.acquireToken({ request:
|
|
42
|
+
.acquireToken({ request: reqRef.current })
|
|
34
43
|
.then((result) => {
|
|
35
44
|
// Only update state when a token was actually acquired
|
|
36
45
|
if (result) {
|
|
@@ -39,7 +48,7 @@ export const useToken = (req) => {
|
|
|
39
48
|
})
|
|
40
49
|
.catch(setError)
|
|
41
50
|
.finally(() => setPending(false));
|
|
42
|
-
}, [msalProvider,
|
|
51
|
+
}, [msalProvider, scopesKey]);
|
|
43
52
|
return { token, pending, error };
|
|
44
53
|
};
|
|
45
54
|
export default useToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToken.js","sourceRoot":"","sources":["../../../src/msal/useToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useToken.js","sourceRoot":"","sources":["../../../src/msal/useToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIpD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAExB,EAAsE,EAAE;IACvE,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAmC,SAAS,CAAC,CAAC;IAChF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAU,IAAI,CAAC,CAAC;IAElD,+EAA+E;IAC/E,iFAAiF;IACjF,qFAAqF;IACrF,iFAAiF;IACjF,gDAAgD;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC;IAErB,+GAA+G;IAC/G,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpB,YAAY;aACT,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;aACzC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,uDAAuD;YACvD,IAAI,MAAM,EAAE,CAAC;gBACX,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,QAAQ,CAAC;aACf,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC"}
|