quantum-component-library 1.4.63 → 1.4.64
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/README.md +115 -115
- package/dist/generated/graphql.d.ts +52 -2
- package/dist/hooks.cjs +8 -1
- package/dist/hooks.js +108 -79
- package/dist/lib/hooks/use-graphql-client.d.ts +5 -2
- package/dist/lib/providers/quantum-library-provider.d.ts +4 -1
- package/dist/lib/services/rom.json.d.ts +223 -223
- package/dist/providers.cjs +1 -1
- package/dist/providers.js +26 -26
- package/package.json +133 -133
package/README.md
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
# Quantum Component Library
|
|
2
|
-
|
|
3
|
-
A modular React component library built with TypeScript and Vite, featuring code splitting for optimal bundle sizes.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install quantum-component-library
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Full Library Import (Default)
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
// Import everything (not recommended for production)
|
|
17
|
-
import * from 'quantum-component-library';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Modular Imports (Recommended)
|
|
21
|
-
|
|
22
|
-
The library is split into several modules for optimal tree-shaking and bundle sizes:
|
|
23
|
-
|
|
24
|
-
#### Components
|
|
25
|
-
```typescript
|
|
26
|
-
// Import only UI components
|
|
27
|
-
import { UpsertActivityForm, ParameterEditList } from 'quantum-component-library/components';
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
#### Hooks
|
|
31
|
-
```typescript
|
|
32
|
-
// Import only custom hooks
|
|
33
|
-
import { useGraphqlClient, useJointsForLimbIds } from 'quantum-component-library/hooks';
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
#### Types
|
|
37
|
-
```typescript
|
|
38
|
-
// Import only type definitions
|
|
39
|
-
import type { Activity, Analysis, Human } from 'quantum-component-library/types';
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
#### Authentication
|
|
43
|
-
```typescript
|
|
44
|
-
// Import only auth utilities
|
|
45
|
-
import { useAuthContext, useIsAuthenticated } from 'quantum-component-library/auth';
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
#### GraphQL
|
|
49
|
-
```typescript
|
|
50
|
-
// Import only GraphQL fragments and operations
|
|
51
|
-
import { ActivityFragment, SessionQueries } from 'quantum-component-library/graphql';
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
#### Generated GraphQL Code
|
|
55
|
-
```typescript
|
|
56
|
-
// Import only generated GraphQL types and utilities
|
|
57
|
-
import { FragmentMasking, gql } from 'quantum-component-library/generated';
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
#### Utilities
|
|
61
|
-
```typescript
|
|
62
|
-
// Import only utility functions
|
|
63
|
-
import { convertUnits, memoizeWithExpiry } from 'quantum-component-library/utils';
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
#### Services
|
|
67
|
-
```typescript
|
|
68
|
-
// Import only service functions
|
|
69
|
-
import { humanService } from 'quantum-component-library/services';
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Code Splitting Benefits
|
|
73
|
-
|
|
74
|
-
- **Reduced Bundle Size**: Import only what you need
|
|
75
|
-
- **Better Tree Shaking**: Webpack and other bundlers can eliminate unused code more effectively
|
|
76
|
-
- **Faster Loading**: Smaller initial bundles load faster
|
|
77
|
-
- **Better Caching**: Changes to one module don't invalidate others
|
|
78
|
-
|
|
79
|
-
## Build Configuration
|
|
80
|
-
|
|
81
|
-
This library uses Vite with multiple entry points and manual chunk splitting:
|
|
82
|
-
|
|
83
|
-
- **Multiple Entry Points**: Each module has its own entry point for granular imports
|
|
84
|
-
- **Manual Chunk Splitting**: Vendor dependencies are split into logical chunks (UI, GraphQL, React, etc.)
|
|
85
|
-
- **Automatic Type Generation**: TypeScript definitions are generated for all entry points
|
|
86
|
-
|
|
87
|
-
### Available Modules
|
|
88
|
-
|
|
89
|
-
| Module | Entry Point | Description |
|
|
90
|
-
|--------|-------------|-------------|
|
|
91
|
-
| `components` | `src/components/index.ts` | UI components |
|
|
92
|
-
| `hooks` | `src/lib/hooks/index.ts` | Custom React hooks |
|
|
93
|
-
| `types` | `src/lib/types/index.ts` | TypeScript type definitions |
|
|
94
|
-
| `auth` | `src/lib/auth/index.ts` | Authentication utilities |
|
|
95
|
-
| `graphql` | `src/graphql/index.ts` | GraphQL fragments and operations |
|
|
96
|
-
| `generated` | `src/generated/index.ts` | Generated GraphQL code |
|
|
97
|
-
| `utils` | `src/lib/utils/index.ts` | Utility functions |
|
|
98
|
-
| `services` | `src/lib/services/index.ts` | Service functions |
|
|
99
|
-
|
|
100
|
-
## Development
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
# Install dependencies
|
|
104
|
-
npm install
|
|
105
|
-
|
|
106
|
-
# Start development server
|
|
107
|
-
npm run dev
|
|
108
|
-
|
|
109
|
-
# Build the library
|
|
110
|
-
npm run build
|
|
111
|
-
|
|
112
|
-
# Build for specific environments
|
|
113
|
-
npm run build:admin-prod
|
|
114
|
-
npm run build:client-qa
|
|
115
|
-
```
|
|
1
|
+
# Quantum Component Library
|
|
2
|
+
|
|
3
|
+
A modular React component library built with TypeScript and Vite, featuring code splitting for optimal bundle sizes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install quantum-component-library
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Full Library Import (Default)
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Import everything (not recommended for production)
|
|
17
|
+
import * from 'quantum-component-library';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Modular Imports (Recommended)
|
|
21
|
+
|
|
22
|
+
The library is split into several modules for optimal tree-shaking and bundle sizes:
|
|
23
|
+
|
|
24
|
+
#### Components
|
|
25
|
+
```typescript
|
|
26
|
+
// Import only UI components
|
|
27
|
+
import { UpsertActivityForm, ParameterEditList } from 'quantum-component-library/components';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### Hooks
|
|
31
|
+
```typescript
|
|
32
|
+
// Import only custom hooks
|
|
33
|
+
import { useGraphqlClient, useJointsForLimbIds } from 'quantum-component-library/hooks';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Types
|
|
37
|
+
```typescript
|
|
38
|
+
// Import only type definitions
|
|
39
|
+
import type { Activity, Analysis, Human } from 'quantum-component-library/types';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Authentication
|
|
43
|
+
```typescript
|
|
44
|
+
// Import only auth utilities
|
|
45
|
+
import { useAuthContext, useIsAuthenticated } from 'quantum-component-library/auth';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### GraphQL
|
|
49
|
+
```typescript
|
|
50
|
+
// Import only GraphQL fragments and operations
|
|
51
|
+
import { ActivityFragment, SessionQueries } from 'quantum-component-library/graphql';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Generated GraphQL Code
|
|
55
|
+
```typescript
|
|
56
|
+
// Import only generated GraphQL types and utilities
|
|
57
|
+
import { FragmentMasking, gql } from 'quantum-component-library/generated';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Utilities
|
|
61
|
+
```typescript
|
|
62
|
+
// Import only utility functions
|
|
63
|
+
import { convertUnits, memoizeWithExpiry } from 'quantum-component-library/utils';
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Services
|
|
67
|
+
```typescript
|
|
68
|
+
// Import only service functions
|
|
69
|
+
import { humanService } from 'quantum-component-library/services';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Code Splitting Benefits
|
|
73
|
+
|
|
74
|
+
- **Reduced Bundle Size**: Import only what you need
|
|
75
|
+
- **Better Tree Shaking**: Webpack and other bundlers can eliminate unused code more effectively
|
|
76
|
+
- **Faster Loading**: Smaller initial bundles load faster
|
|
77
|
+
- **Better Caching**: Changes to one module don't invalidate others
|
|
78
|
+
|
|
79
|
+
## Build Configuration
|
|
80
|
+
|
|
81
|
+
This library uses Vite with multiple entry points and manual chunk splitting:
|
|
82
|
+
|
|
83
|
+
- **Multiple Entry Points**: Each module has its own entry point for granular imports
|
|
84
|
+
- **Manual Chunk Splitting**: Vendor dependencies are split into logical chunks (UI, GraphQL, React, etc.)
|
|
85
|
+
- **Automatic Type Generation**: TypeScript definitions are generated for all entry points
|
|
86
|
+
|
|
87
|
+
### Available Modules
|
|
88
|
+
|
|
89
|
+
| Module | Entry Point | Description |
|
|
90
|
+
|--------|-------------|-------------|
|
|
91
|
+
| `components` | `src/components/index.ts` | UI components |
|
|
92
|
+
| `hooks` | `src/lib/hooks/index.ts` | Custom React hooks |
|
|
93
|
+
| `types` | `src/lib/types/index.ts` | TypeScript type definitions |
|
|
94
|
+
| `auth` | `src/lib/auth/index.ts` | Authentication utilities |
|
|
95
|
+
| `graphql` | `src/graphql/index.ts` | GraphQL fragments and operations |
|
|
96
|
+
| `generated` | `src/generated/index.ts` | Generated GraphQL code |
|
|
97
|
+
| `utils` | `src/lib/utils/index.ts` | Utility functions |
|
|
98
|
+
| `services` | `src/lib/services/index.ts` | Service functions |
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Install dependencies
|
|
104
|
+
npm install
|
|
105
|
+
|
|
106
|
+
# Start development server
|
|
107
|
+
npm run dev
|
|
108
|
+
|
|
109
|
+
# Build the library
|
|
110
|
+
npm run build
|
|
111
|
+
|
|
112
|
+
# Build for specific environments
|
|
113
|
+
npm run build:admin-prod
|
|
114
|
+
npm run build:client-qa
|
|
115
|
+
```
|
|
@@ -188,6 +188,7 @@ export type AnalysisSubClassification = {
|
|
|
188
188
|
export type AuthSession = {
|
|
189
189
|
__typename?: 'AuthSession';
|
|
190
190
|
accessToken: Scalars['String']['output'];
|
|
191
|
+
refreshToken?: Maybe<Scalars['String']['output']>;
|
|
191
192
|
};
|
|
192
193
|
export type ChangePasswordInput = {
|
|
193
194
|
newPassword: Scalars['String']['input'];
|
|
@@ -210,6 +211,14 @@ export type ComparativeMetricInput = {
|
|
|
210
211
|
valueA: Scalars['Float']['input'];
|
|
211
212
|
valueB: Scalars['Float']['input'];
|
|
212
213
|
};
|
|
214
|
+
export type CompleteLoginChallengeInput = {
|
|
215
|
+
address?: InputMaybe<Scalars['String']['input']>;
|
|
216
|
+
gender?: InputMaybe<Scalars['String']['input']>;
|
|
217
|
+
name?: InputMaybe<Scalars['String']['input']>;
|
|
218
|
+
newPassword: Scalars['String']['input'];
|
|
219
|
+
session: Scalars['String']['input'];
|
|
220
|
+
username: Scalars['String']['input'];
|
|
221
|
+
};
|
|
213
222
|
export type CopyActionsInput = {
|
|
214
223
|
actionIds: Array<Scalars['ID']['input']>;
|
|
215
224
|
sourceGroupId: Scalars['ID']['input'];
|
|
@@ -226,6 +235,7 @@ export type CreateAccountInput = {
|
|
|
226
235
|
groupId?: InputMaybe<Scalars['ID']['input']>;
|
|
227
236
|
lastName: Scalars['String']['input'];
|
|
228
237
|
password: Scalars['String']['input'];
|
|
238
|
+
roles?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
229
239
|
username: Scalars['String']['input'];
|
|
230
240
|
};
|
|
231
241
|
export type CreateAccountResult = {
|
|
@@ -451,8 +461,10 @@ export type LoginInput = {
|
|
|
451
461
|
};
|
|
452
462
|
export type LoginResult = {
|
|
453
463
|
__typename?: 'LoginResult';
|
|
454
|
-
|
|
455
|
-
|
|
464
|
+
challengeName?: Maybe<Scalars['String']['output']>;
|
|
465
|
+
challengeSession?: Maybe<Scalars['String']['output']>;
|
|
466
|
+
session?: Maybe<AuthSession>;
|
|
467
|
+
user?: Maybe<CurrentUser>;
|
|
456
468
|
};
|
|
457
469
|
export type MetadataGroup = {
|
|
458
470
|
__typename?: 'MetadataGroup';
|
|
@@ -500,10 +512,14 @@ export type MovementCoordinationReport = {
|
|
|
500
512
|
};
|
|
501
513
|
export type Mutation = {
|
|
502
514
|
__typename?: 'Mutation';
|
|
515
|
+
activateUser: Scalars['Boolean']['output'];
|
|
503
516
|
addActionToModule: ActionModule;
|
|
504
517
|
archiveUser: Scalars['Boolean']['output'];
|
|
505
518
|
assignTestToRoutine: Scalars['Boolean']['output'];
|
|
519
|
+
assignUserRole: Scalars['Boolean']['output'];
|
|
506
520
|
changePassword: Scalars['Boolean']['output'];
|
|
521
|
+
completeLoginChallenge: LoginResult;
|
|
522
|
+
confirmForgotPassword: Scalars['Boolean']['output'];
|
|
507
523
|
convertActionToQuantumOwned: Action;
|
|
508
524
|
copyActions: Scalars['Boolean']['output'];
|
|
509
525
|
copyModules: Scalars['Boolean']['output'];
|
|
@@ -531,6 +547,7 @@ export type Mutation = {
|
|
|
531
547
|
createTrial: Trial;
|
|
532
548
|
createTrialParameter: TrialParameter;
|
|
533
549
|
createUserProfile: UserProfile;
|
|
550
|
+
deactivateUser: Scalars['Boolean']['output'];
|
|
534
551
|
deleteAction: Scalars['Boolean']['output'];
|
|
535
552
|
deleteModule: Scalars['Boolean']['output'];
|
|
536
553
|
deleteRoutine: Scalars['Boolean']['output'];
|
|
@@ -541,8 +558,11 @@ export type Mutation = {
|
|
|
541
558
|
deleteTrialParameter: Scalars['Boolean']['output'];
|
|
542
559
|
deleteUserProfile: Scalars['Boolean']['output'];
|
|
543
560
|
duplicateAction: Scalars['Boolean']['output'];
|
|
561
|
+
forgotPassword: Scalars['Boolean']['output'];
|
|
544
562
|
login?: Maybe<LoginResult>;
|
|
563
|
+
refresh: LoginResult;
|
|
545
564
|
removeActionFromModule: ActionModule;
|
|
565
|
+
removeUserRole: Scalars['Boolean']['output'];
|
|
546
566
|
replaceTrialParameters: Array<TrialParameter>;
|
|
547
567
|
requestPoseProcessing: Scalars['Boolean']['output'];
|
|
548
568
|
unarchiveUserProfile: UserProfile;
|
|
@@ -557,6 +577,9 @@ export type Mutation = {
|
|
|
557
577
|
updateUserProfile: UserProfile;
|
|
558
578
|
updateVideoDataOffset: TestFile;
|
|
559
579
|
};
|
|
580
|
+
export type MutationActivateUserArgs = {
|
|
581
|
+
id: Scalars['ID']['input'];
|
|
582
|
+
};
|
|
560
583
|
export type MutationAddActionToModuleArgs = {
|
|
561
584
|
actionId: Scalars['ID']['input'];
|
|
562
585
|
moduleId: Scalars['ID']['input'];
|
|
@@ -568,9 +591,21 @@ export type MutationAssignTestToRoutineArgs = {
|
|
|
568
591
|
routineId?: InputMaybe<Scalars['ID']['input']>;
|
|
569
592
|
testId: Scalars['ID']['input'];
|
|
570
593
|
};
|
|
594
|
+
export type MutationAssignUserRoleArgs = {
|
|
595
|
+
roleName: Scalars['String']['input'];
|
|
596
|
+
userId: Scalars['ID']['input'];
|
|
597
|
+
};
|
|
571
598
|
export type MutationChangePasswordArgs = {
|
|
572
599
|
input: ChangePasswordInput;
|
|
573
600
|
};
|
|
601
|
+
export type MutationCompleteLoginChallengeArgs = {
|
|
602
|
+
input: CompleteLoginChallengeInput;
|
|
603
|
+
};
|
|
604
|
+
export type MutationConfirmForgotPasswordArgs = {
|
|
605
|
+
code: Scalars['String']['input'];
|
|
606
|
+
email: Scalars['String']['input'];
|
|
607
|
+
newPassword: Scalars['String']['input'];
|
|
608
|
+
};
|
|
574
609
|
export type MutationConvertActionToQuantumOwnedArgs = {
|
|
575
610
|
id: Scalars['ID']['input'];
|
|
576
611
|
};
|
|
@@ -661,6 +696,9 @@ export type MutationCreateTrialParameterArgs = {
|
|
|
661
696
|
export type MutationCreateUserProfileArgs = {
|
|
662
697
|
input: CreateUserProfileInput;
|
|
663
698
|
};
|
|
699
|
+
export type MutationDeactivateUserArgs = {
|
|
700
|
+
id: Scalars['ID']['input'];
|
|
701
|
+
};
|
|
664
702
|
export type MutationDeleteActionArgs = {
|
|
665
703
|
id: Scalars['ID']['input'];
|
|
666
704
|
};
|
|
@@ -691,13 +729,23 @@ export type MutationDeleteUserProfileArgs = {
|
|
|
691
729
|
export type MutationDuplicateActionArgs = {
|
|
692
730
|
id: Scalars['ID']['input'];
|
|
693
731
|
};
|
|
732
|
+
export type MutationForgotPasswordArgs = {
|
|
733
|
+
email: Scalars['String']['input'];
|
|
734
|
+
};
|
|
694
735
|
export type MutationLoginArgs = {
|
|
695
736
|
input: LoginInput;
|
|
696
737
|
};
|
|
738
|
+
export type MutationRefreshArgs = {
|
|
739
|
+
refreshToken: Scalars['String']['input'];
|
|
740
|
+
};
|
|
697
741
|
export type MutationRemoveActionFromModuleArgs = {
|
|
698
742
|
actionId: Scalars['ID']['input'];
|
|
699
743
|
moduleId: Scalars['ID']['input'];
|
|
700
744
|
};
|
|
745
|
+
export type MutationRemoveUserRoleArgs = {
|
|
746
|
+
roleName: Scalars['String']['input'];
|
|
747
|
+
userId: Scalars['ID']['input'];
|
|
748
|
+
};
|
|
701
749
|
export type MutationReplaceTrialParametersArgs = {
|
|
702
750
|
input: Array<ReplaceTrialParameterInput>;
|
|
703
751
|
trialId: Scalars['ID']['input'];
|
|
@@ -851,6 +899,8 @@ export type QueryGetTestFileArgs = {
|
|
|
851
899
|
id: Scalars['ID']['input'];
|
|
852
900
|
};
|
|
853
901
|
export type QueryGetTestsForSessionArgs = {
|
|
902
|
+
limit?: InputMaybe<Scalars['Int']['input']>;
|
|
903
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
854
904
|
sessionId: Scalars['ID']['input'];
|
|
855
905
|
};
|
|
856
906
|
export type QueryGroupArgs = {
|
package/dist/hooks.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),c=require("./services-human-DFPelsei.cjs"),l=require("./types.cjs");require("./lodash-vendor-CfNg9qwP.cjs");require("./moment-vendor-1cRqq0AH.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),c=require("./services-human-DFPelsei.cjs"),l=require("./types.cjs");require("./lodash-vendor-CfNg9qwP.cjs");require("./moment-vendor-1cRqq0AH.cjs");const L=require("./graphql-vendor-CSrUjvOC.cjs"),f=require("urql"),A=require("./providers.cjs");require("./react-jsx-runtime-vendor-Dszzpdy0.cjs");require("./graphql-C2l-Swfm.cjs");const d=(e,n)=>u.useMemo(()=>e.flatMap(i=>c.getEnabledJointPlanes(i,n).map(r=>({id:{joint:i},plane:r,...c.getDefaultJointRange(i,r),sensorOnly:n===l.AngleDataSource.Sensor}))),[e,n]),b=(e,n)=>{const o=u.useMemo(()=>{const r=c.getAllAvailableLimbs();return e.filter(a=>r.some(t=>t.id===a))},[e]);return u.useMemo(()=>o.flatMap(r=>c.getEnabledSegmentPlanes(r,n).map(a=>({id:{segment:r},plane:a,...c.getDefaultLimbRange(r,a),sensorOnly:n===l.AngleDataSource.Sensor}))),[o,n])},S=()=>{const e=u.useMemo(()=>c.getAllAvailableLimbs(),[]),n=u.useMemo(()=>c.getAllAvailablePoseJoints(),[]),o=b(e.map(t=>t.id),l.AngleDataSource.Pose),i=d(n.map(t=>t.id),l.AngleDataSource.Pose),r=b(e.map(t=>t.id),l.AngleDataSource.Sensor),a=d(n.map(t=>t.id),l.AngleDataSource.Sensor);return u.useMemo(()=>{const t=new Map;return[...i,...o].forEach(s=>{const m="joint"in s.id?`joint:${s.id.joint}:${s.plane}`:`segment:${s.id.segment}:${s.plane}`;t.set(m,{...s,sensorOnly:!1})}),[...a,...r].forEach(s=>{const m="joint"in s.id?`joint:${s.id.joint}:${s.plane}`:`segment:${s.id.segment}:${s.plane}`;t.has(m)||t.set(m,{...s,sensorOnly:!0})}),Array.from(t.values())},[i,o,a,r])},q=({url:e,getAuthToken:n,getRefreshToken:o,onSessionRefreshed:i,onAuthError:r})=>new f.Client({url:e,requestPolicy:"cache-and-network",exchanges:[L.authExchange(async a=>(n(),{addAuthToOperation(t){const s=n();return s?a.appendHeaders(t,{Authorization:`Bearer ${s}`}):t},didAuthError:t=>t.graphQLErrors.some(s=>s.extensions?.code==="UNAUTHORIZED"||s.extensions?.code==="UNAUTHENTICATED"||s.message.includes("Unauthorized")),refreshAuth:async()=>{const t=o();if(!t){r();return}try{const s=await a.mutate(`mutation Refresh($refreshToken: String!) {
|
|
2
|
+
refresh(refreshToken: $refreshToken) {
|
|
3
|
+
session {
|
|
4
|
+
accessToken
|
|
5
|
+
refreshToken
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}`,{refreshToken:t});s.data?.refresh?.session?i(s.data.refresh.session.accessToken,s.data.refresh.session.refreshToken):(console.error("Refresh failed:",s.error),r())}catch(s){console.error("Refresh handling error:",s),r()}}})),f.fetchExchange]}),O=({url:e,getAuthToken:n,getRefreshToken:o,onSessionRefreshed:i,onAuthError:r})=>u.useMemo(()=>q({url:e,getAuthToken:n,getRefreshToken:o,onSessionRefreshed:i,onAuthError:r}),[e,n,o,i,r]),p=e=>{const n=c.getAllAvailableJoints();return u.useMemo(()=>n.filter(o=>o.id==="NavalSpine"||o.id==="ChestSpine"?!1:c.limbsRequiredForJoints[o.id].every(r=>e.includes(r))),[e,n])},g=e=>{const n=u.useMemo(()=>e.map(l.sensorLocationToLimbId).filter(i=>!!i),[e]);return p(n)},h=e=>u.useMemo(()=>{const o=c.getAllAvailableLimbs(),i=e.map(l.sensorLocationToLimbId);return o.filter(r=>i.includes(r.id))},[e]),P=e=>{const n=h(e),o=g(e),i=d(o.map(a=>a.id),l.AngleDataSource.Sensor),r=b(n.map(a=>a.id),l.AngleDataSource.Sensor);return[...i,...r]},y=()=>{const e=u.useContext(A.UiLabelContext);if(e===void 0)throw new Error("useUiLabelContext must be used within a UiLabelProvider");return e};exports.useAllPartParameters=S;exports.useGraphqlClient=O;exports.useJointsForLimbIds=p;exports.useJointsForSensorLocations=g;exports.useLimbsForSensorLocations=h;exports.usePartOptionsForJoints=d;exports.usePartOptionsForLimbs=b;exports.usePartOptionsForSensorLocations=P;exports.useUiLabelContext=y;
|
package/dist/hooks.js
CHANGED
|
@@ -1,127 +1,156 @@
|
|
|
1
|
-
import { useMemo as l, useContext as
|
|
2
|
-
import { h as
|
|
3
|
-
import { AngleDataSource as
|
|
1
|
+
import { useMemo as l, useContext as h } from "react";
|
|
2
|
+
import { h as b, i as g, j as f, k as L, l as O, m as P, n as y, o as T } from "./services-human-D5IllQkM.js";
|
|
3
|
+
import { AngleDataSource as c, sensorLocationToLimbId as p } from "./types.js";
|
|
4
4
|
import "./lodash-vendor-CY4G3-79.js";
|
|
5
5
|
import "./moment-vendor-DMLRxgRE.js";
|
|
6
|
-
import { a as
|
|
7
|
-
import { Client as
|
|
8
|
-
import { UiLabelContext as
|
|
6
|
+
import { a as x } from "./graphql-vendor-ipMKtdBu.js";
|
|
7
|
+
import { Client as A, fetchExchange as J } from "urql";
|
|
8
|
+
import { UiLabelContext as $ } from "./providers.js";
|
|
9
9
|
import "./react-jsx-runtime-vendor-OVHDjVDe.js";
|
|
10
10
|
import "./graphql-D_TLPK-5.js";
|
|
11
|
-
const
|
|
11
|
+
const u = (e, n) => l(
|
|
12
12
|
() => e.flatMap(
|
|
13
|
-
(
|
|
14
|
-
id: { joint:
|
|
13
|
+
(i) => b(i, n).map((t) => ({
|
|
14
|
+
id: { joint: i },
|
|
15
15
|
plane: t,
|
|
16
|
-
...
|
|
17
|
-
sensorOnly:
|
|
16
|
+
...g(i, t),
|
|
17
|
+
sensorOnly: n === c.Sensor
|
|
18
18
|
}))
|
|
19
19
|
),
|
|
20
|
-
[e,
|
|
21
|
-
), d = (e,
|
|
22
|
-
const
|
|
23
|
-
const t =
|
|
20
|
+
[e, n]
|
|
21
|
+
), d = (e, n) => {
|
|
22
|
+
const o = l(() => {
|
|
23
|
+
const t = f();
|
|
24
24
|
return e.filter((a) => t.some((r) => r.id === a));
|
|
25
25
|
}, [e]);
|
|
26
26
|
return l(
|
|
27
|
-
() =>
|
|
28
|
-
(t) => L(t,
|
|
27
|
+
() => o.flatMap(
|
|
28
|
+
(t) => L(t, n).map((a) => ({
|
|
29
29
|
id: { segment: t },
|
|
30
30
|
plane: a,
|
|
31
|
-
...
|
|
32
|
-
sensorOnly:
|
|
31
|
+
...O(t, a),
|
|
32
|
+
sensorOnly: n === c.Sensor
|
|
33
33
|
}))
|
|
34
34
|
),
|
|
35
|
-
[
|
|
35
|
+
[o, n]
|
|
36
36
|
);
|
|
37
|
-
},
|
|
38
|
-
const e = l(() =>
|
|
37
|
+
}, N = () => {
|
|
38
|
+
const e = l(() => f(), []), n = l(() => P(), []), o = d(
|
|
39
39
|
e.map((r) => r.id),
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
c.Pose
|
|
41
|
+
), i = u(
|
|
42
|
+
n.map((r) => r.id),
|
|
43
|
+
c.Pose
|
|
44
44
|
), t = d(
|
|
45
45
|
e.map((r) => r.id),
|
|
46
|
-
|
|
47
|
-
), a =
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
c.Sensor
|
|
47
|
+
), a = u(
|
|
48
|
+
n.map((r) => r.id),
|
|
49
|
+
c.Sensor
|
|
50
50
|
);
|
|
51
51
|
return l(() => {
|
|
52
52
|
const r = /* @__PURE__ */ new Map();
|
|
53
|
-
return [...
|
|
54
|
-
const
|
|
55
|
-
r.set(
|
|
56
|
-
}), [...a, ...t].forEach((
|
|
57
|
-
const
|
|
58
|
-
r.has(
|
|
53
|
+
return [...i, ...o].forEach((s) => {
|
|
54
|
+
const m = "joint" in s.id ? `joint:${s.id.joint}:${s.plane}` : `segment:${s.id.segment}:${s.plane}`;
|
|
55
|
+
r.set(m, { ...s, sensorOnly: !1 });
|
|
56
|
+
}), [...a, ...t].forEach((s) => {
|
|
57
|
+
const m = "joint" in s.id ? `joint:${s.id.joint}:${s.plane}` : `segment:${s.id.segment}:${s.plane}`;
|
|
58
|
+
r.has(m) || r.set(m, { ...s, sensorOnly: !0 });
|
|
59
59
|
}), Array.from(r.values());
|
|
60
60
|
}, [
|
|
61
|
+
i,
|
|
61
62
|
o,
|
|
62
|
-
n,
|
|
63
63
|
a,
|
|
64
64
|
t
|
|
65
65
|
]);
|
|
66
|
-
},
|
|
66
|
+
}, k = ({
|
|
67
67
|
url: e,
|
|
68
|
-
getAuthToken:
|
|
69
|
-
|
|
68
|
+
getAuthToken: n,
|
|
69
|
+
getRefreshToken: o,
|
|
70
|
+
onSessionRefreshed: i,
|
|
71
|
+
onAuthError: t
|
|
72
|
+
}) => new A({
|
|
70
73
|
url: e,
|
|
71
74
|
requestPolicy: "cache-and-network",
|
|
72
75
|
exchanges: [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
x(async (a) => (n(), {
|
|
77
|
+
addAuthToOperation(r) {
|
|
78
|
+
const s = n();
|
|
79
|
+
return s ? a.appendHeaders(r, {
|
|
80
|
+
Authorization: `Bearer ${s}`
|
|
81
|
+
}) : r;
|
|
82
|
+
},
|
|
83
|
+
didAuthError: (r) => r.graphQLErrors.some((s) => s.extensions?.code === "UNAUTHORIZED" || s.extensions?.code === "UNAUTHENTICATED" || s.message.includes("Unauthorized")),
|
|
84
|
+
refreshAuth: async () => {
|
|
85
|
+
const r = o();
|
|
86
|
+
if (!r) {
|
|
87
|
+
t();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const s = await a.mutate(
|
|
92
|
+
`mutation Refresh($refreshToken: String!) {
|
|
93
|
+
refresh(refreshToken: $refreshToken) {
|
|
94
|
+
session {
|
|
95
|
+
accessToken
|
|
96
|
+
refreshToken
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}`,
|
|
100
|
+
{ refreshToken: r }
|
|
101
|
+
);
|
|
102
|
+
s.data?.refresh?.session ? i(
|
|
103
|
+
s.data.refresh.session.accessToken,
|
|
104
|
+
s.data.refresh.session.refreshToken
|
|
105
|
+
) : (console.error("Refresh failed:", s.error), t());
|
|
106
|
+
} catch (s) {
|
|
107
|
+
console.error("Refresh handling error:", s), t();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})),
|
|
111
|
+
J
|
|
86
112
|
]
|
|
87
|
-
}),
|
|
113
|
+
}), H = ({
|
|
88
114
|
url: e,
|
|
89
|
-
getAuthToken:
|
|
115
|
+
getAuthToken: n,
|
|
116
|
+
getRefreshToken: o,
|
|
117
|
+
onSessionRefreshed: i,
|
|
118
|
+
onAuthError: t
|
|
90
119
|
}) => l(
|
|
91
|
-
() =>
|
|
92
|
-
[e,
|
|
120
|
+
() => k({ url: e, getAuthToken: n, getRefreshToken: o, onSessionRefreshed: i, onAuthError: t }),
|
|
121
|
+
[e, n, o, i, t]
|
|
93
122
|
), C = (e) => {
|
|
94
|
-
const
|
|
95
|
-
return l(() =>
|
|
123
|
+
const n = y();
|
|
124
|
+
return l(() => n.filter((o) => o.id === "NavalSpine" || o.id === "ChestSpine" ? !1 : T[o.id].every((t) => e.includes(t))), [e, n]);
|
|
96
125
|
}, E = (e) => {
|
|
97
|
-
const
|
|
98
|
-
return C(
|
|
99
|
-
},
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
}, [e]),
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
const n = l(() => e.map(p).filter((i) => !!i), [e]);
|
|
127
|
+
return C(n);
|
|
128
|
+
}, S = (e) => l(() => {
|
|
129
|
+
const o = f(), i = e.map(p);
|
|
130
|
+
return o.filter((t) => i.includes(t.id));
|
|
131
|
+
}, [e]), z = (e) => {
|
|
132
|
+
const n = S(e), o = E(e), i = u(
|
|
133
|
+
o.map((a) => a.id),
|
|
134
|
+
c.Sensor
|
|
106
135
|
), t = d(
|
|
107
|
-
|
|
108
|
-
|
|
136
|
+
n.map((a) => a.id),
|
|
137
|
+
c.Sensor
|
|
109
138
|
);
|
|
110
|
-
return [...
|
|
111
|
-
},
|
|
112
|
-
const e =
|
|
139
|
+
return [...i, ...t];
|
|
140
|
+
}, B = () => {
|
|
141
|
+
const e = h($);
|
|
113
142
|
if (e === void 0)
|
|
114
143
|
throw new Error("useUiLabelContext must be used within a UiLabelProvider");
|
|
115
144
|
return e;
|
|
116
145
|
};
|
|
117
146
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
N as useAllPartParameters,
|
|
148
|
+
H as useGraphqlClient,
|
|
120
149
|
C as useJointsForLimbIds,
|
|
121
150
|
E as useJointsForSensorLocations,
|
|
122
|
-
|
|
123
|
-
|
|
151
|
+
S as useLimbsForSensorLocations,
|
|
152
|
+
u as usePartOptionsForJoints,
|
|
124
153
|
d as usePartOptionsForLimbs,
|
|
125
|
-
|
|
126
|
-
|
|
154
|
+
z as usePartOptionsForSensorLocations,
|
|
155
|
+
B as useUiLabelContext
|
|
127
156
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Client } from 'urql';
|
|
2
|
-
export declare const useGraphqlClient: ({ url, getAuthToken, }: {
|
|
2
|
+
export declare const useGraphqlClient: ({ url, getAuthToken, getRefreshToken, onSessionRefreshed, onAuthError, }: {
|
|
3
3
|
url: string;
|
|
4
|
-
getAuthToken: () => string;
|
|
4
|
+
getAuthToken: () => string | null;
|
|
5
|
+
getRefreshToken: () => string | null;
|
|
6
|
+
onSessionRefreshed: (accessToken: string, refreshToken?: string) => void;
|
|
7
|
+
onAuthError: () => void;
|
|
5
8
|
}) => Client;
|