@indietabletop/appkit 6.1.6 → 7.0.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/dist/AppConfig/AppConfig.d.ts +29 -0
- package/dist/AuthCard/AuthCard.d.ts +10 -0
- package/dist/AuthCard/AuthCard.stories.d.ts +34 -0
- package/dist/AuthCard/style.css.d.ts +23 -0
- package/dist/DialogTrigger/index.d.ts +13 -0
- package/dist/DocumentTitle/DocumentTitle.d.ts +3 -0
- package/dist/EnumMapper.d.ts +25 -0
- package/dist/ExternalLink.d.ts +3 -0
- package/dist/FullscreenDismissBlocker.d.ts +5 -0
- package/{lib/HistoryState.ts → dist/HistoryState.d.ts} +2 -5
- package/dist/IndieTabletopClubLogo.d.ts +7 -0
- package/dist/IndieTabletopClubSymbol.d.ts +7 -0
- package/dist/InfoPage/index.d.ts +8 -0
- package/dist/InfoPage/pages.d.ts +2 -0
- package/dist/InfoPage/style.css.d.ts +5 -0
- package/dist/Letterhead/index.d.ts +19 -0
- package/dist/Letterhead/stories.d.ts +13 -0
- package/dist/Letterhead/style.css.d.ts +46 -0
- package/dist/LetterheadForm/LetterheadReadonlyTextField.stories.d.ts +17 -0
- package/dist/LetterheadForm/LetterheadSubmitError.stories.d.ts +11 -0
- package/dist/LetterheadForm/LetterheadTextField.stories.d.ts +336 -0
- package/dist/LetterheadForm/index.d.ts +44 -0
- package/dist/LetterheadForm/style.css.d.ts +8 -0
- package/dist/LoadingIndicator.d.ts +3 -0
- package/dist/MiddotSeparated/MiddotSeparated.d.ts +8 -0
- package/dist/MiddotSeparated/MiddotSeparated.stories.d.ts +586 -0
- package/dist/MiddotSeparated/style.css.d.ts +1 -0
- package/dist/ModalDialog/index.d.ts +12 -0
- package/dist/ModalDialog/style.css.d.ts +58 -0
- package/dist/ModernIDB/Cursor.d.ts +56 -0
- package/dist/ModernIDB/ModernIDB.d.ts +66 -0
- package/dist/ModernIDB/ModernIDBError.d.ts +3 -0
- package/dist/ModernIDB/ObjectStore.d.ts +112 -0
- package/dist/ModernIDB/ObjectStoreIndex.d.ts +53 -0
- package/dist/ModernIDB/Transaction.d.ts +16 -0
- package/dist/ModernIDB/VersionChangeManager.d.ts +30 -0
- package/dist/ModernIDB/bindings/factory.d.ts +12 -0
- package/dist/ModernIDB/bindings/index.d.ts +2 -0
- package/{lib/ModernIDB/bindings/types.ts → dist/ModernIDB/bindings/types.d.ts} +13 -32
- package/dist/ModernIDB/bindings/utils.d.ts +2 -0
- package/dist/ModernIDB/index.d.ts +10 -0
- package/dist/ModernIDB/types.d.ts +88 -0
- package/dist/ModernIDB/utils.d.ts +4 -0
- package/dist/QRCode/QRCode.d.ts +7 -0
- package/dist/QRCode/QRCode.stories.d.ts +33 -0
- package/dist/QRCode/style.css.d.ts +4 -0
- package/dist/ReleaseInfo/index.d.ts +5 -0
- package/dist/RulesetResolver.d.ts +87 -0
- package/dist/SafariCheck/SafariCheck.d.ts +23 -0
- package/dist/SafariCheck/SafariCheck.stories.d.ts +73 -0
- package/dist/SafariCheck/style.css.d.ts +17 -0
- package/dist/ServiceWorkerHandler.d.ts +11 -0
- package/dist/ShareButton/ShareButton.d.ts +57 -0
- package/dist/ShareButton/ShareButton.stories.d.ts +1577 -0
- package/dist/ShareButton/test.css.d.ts +1 -0
- package/dist/SubscribeCard/LetterheadInfoCard.d.ts +2 -0
- package/dist/SubscribeCard/SubscribeByEmailCard.d.ts +24 -0
- package/dist/SubscribeCard/SubscribeByEmailCard.stories.d.ts +10 -0
- package/dist/SubscribeCard/SubscribeByPledgeCard.d.ts +36 -0
- package/dist/SubscribeCard/SubscribeByPledgeCard.stories.d.ts +65 -0
- package/dist/SubscribeCard/style.css.d.ts +4 -0
- package/dist/account/AccountIssueView.d.ts +3 -0
- package/dist/account/AlreadyLoggedInView.d.ts +5 -0
- package/dist/account/CurrentUserFetcher.d.ts +20 -0
- package/dist/account/CurrentUserFetcher.stories.d.ts +136 -0
- package/dist/account/FailureFallbackView.d.ts +1 -0
- package/dist/account/JoinCard.d.ts +14 -0
- package/dist/account/JoinCard.stories.d.ts +143 -0
- package/dist/account/LoadingView.d.ts +1 -0
- package/dist/account/LoginCard.d.ts +39 -0
- package/dist/account/LoginCard.stories.d.ts +217 -0
- package/dist/account/LoginView.d.ts +10 -0
- package/dist/account/NoConnectionView.d.ts +4 -0
- package/dist/account/PasswordResetCard.d.ts +15 -0
- package/dist/account/PasswordResetCard.stories.d.ts +128 -0
- package/dist/account/UserMismatchView.d.ts +6 -0
- package/dist/account/VerifyPage.d.ts +13 -0
- package/dist/account/style.css.d.ts +10 -0
- package/{lib/account/types.ts → dist/account/types.d.ts} +3 -6
- package/dist/account/useFetchCurrentUser.d.ts +28 -0
- package/dist/account/useRedirectPath.d.ts +6 -0
- package/dist/animations.css.d.ts +3 -0
- package/dist/append-copy-to-text.d.ts +10 -0
- package/dist/append-copy-to-text.test.d.ts +1 -0
- package/dist/appkit.css +1 -0
- package/dist/appkit.js +10692 -0
- package/dist/async-op.d.ts +101 -0
- package/dist/atomic.css.d.ts +6 -0
- package/{lib/caught-value.ts → dist/caught-value.d.ts} +1 -11
- package/{lib/class-names.ts → dist/class-names.d.ts} +6 -17
- package/dist/client.d.ts +424 -0
- package/dist/common.css.d.ts +5 -0
- package/dist/copyrightRange.d.ts +1 -0
- package/dist/copyrightRange.test.d.ts +1 -0
- package/dist/createSafeStorage.d.ts +34 -0
- package/dist/failureMessages.d.ts +20 -0
- package/dist/failureMessages.test.d.ts +1 -0
- package/dist/form/FormSubmitButton.d.ts +17 -0
- package/dist/form/SubmitErrorAlert.d.ts +5 -0
- package/dist/form/style.css.d.ts +3 -0
- package/dist/globals.css.d.ts +0 -0
- package/dist/groupBy.d.ts +1 -0
- package/dist/groupBy.test.d.ts +1 -0
- package/dist/hrefs.d.ts +32 -0
- package/dist/hrefs.test.d.ts +1 -0
- package/dist/idToDate.d.ts +5 -0
- package/dist/idToDate.test.d.ts +1 -0
- package/dist/ids.d.ts +1 -0
- package/dist/ids.test.d.ts +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/internal.css.d.ts +2 -0
- package/dist/mailto.d.ts +8 -0
- package/dist/mailto.test.d.ts +1 -0
- package/dist/media.d.ts +39 -0
- package/dist/random.d.ts +3 -0
- package/dist/result/swr.d.ts +4 -0
- package/{lib/sleep.ts → dist/sleep.d.ts} +1 -3
- package/dist/store/index.d.ts +237 -0
- package/dist/store/store.d.ts +144 -0
- package/dist/store/types.d.ts +49 -0
- package/dist/store/utils.d.ts +10 -0
- package/dist/storybook/decorators.d.ts +3 -0
- package/dist/structs.d.ts +1 -0
- package/{lib/typeguards.ts → dist/typeguards.d.ts} +1 -3
- package/dist/typeguards.test.d.ts +1 -0
- package/{lib/types.ts → dist/types.d.ts} +12 -23
- package/dist/unique.d.ts +10 -0
- package/dist/unique.test.d.ts +1 -0
- package/dist/use-async-op.d.ts +6 -0
- package/dist/use-document-background-color.d.ts +4 -0
- package/dist/use-form.d.ts +29 -0
- package/dist/use-is-installed.d.ts +8 -0
- package/dist/use-media-query.d.ts +1 -0
- package/dist/use-reverting-state.d.ts +5 -0
- package/dist/use-scroll-restoration.d.ts +25 -0
- package/dist/useEnsureValue.d.ts +6 -0
- package/dist/useInvokeClient.d.ts +25 -0
- package/dist/useIsVisible.d.ts +4 -0
- package/dist/utm.d.ts +58 -0
- package/dist/utm.test.d.ts +1 -0
- package/dist/validations.d.ts +3 -0
- package/dist/vars.css.d.ts +10 -0
- package/package.json +12 -5
- package/lib/AppConfig/AppConfig.tsx +0 -61
- package/lib/AuthCard/AuthCard.stories.ts +0 -34
- package/lib/AuthCard/AuthCard.tsx +0 -64
- package/lib/AuthCard/style.css.ts +0 -49
- package/lib/DialogTrigger/index.tsx +0 -36
- package/lib/DocumentTitle/DocumentTitle.tsx +0 -10
- package/lib/EnumMapper.ts +0 -50
- package/lib/ExternalLink.tsx +0 -10
- package/lib/FullscreenDismissBlocker.tsx +0 -23
- package/lib/IndieTabletopClubLogo.tsx +0 -44
- package/lib/IndieTabletopClubSymbol.tsx +0 -37
- package/lib/InfoPage/index.tsx +0 -46
- package/lib/InfoPage/pages.tsx +0 -36
- package/lib/InfoPage/style.css.ts +0 -36
- package/lib/Letterhead/index.tsx +0 -85
- package/lib/Letterhead/stories.tsx +0 -41
- package/lib/Letterhead/style.css.ts +0 -152
- package/lib/LetterheadForm/LetterheadReadonlyTextField.stories.tsx +0 -17
- package/lib/LetterheadForm/LetterheadSubmitError.stories.tsx +0 -19
- package/lib/LetterheadForm/LetterheadTextField.stories.tsx +0 -19
- package/lib/LetterheadForm/index.tsx +0 -137
- package/lib/LetterheadForm/style.css.ts +0 -89
- package/lib/LoadingIndicator.tsx +0 -40
- package/lib/MiddotSeparated/MiddotSeparated.stories.ts +0 -26
- package/lib/MiddotSeparated/MiddotSeparated.tsx +0 -26
- package/lib/MiddotSeparated/style.css.ts +0 -10
- package/lib/ModalDialog/index.tsx +0 -28
- package/lib/ModalDialog/style.css.ts +0 -88
- package/lib/ModernIDB/Cursor.ts +0 -91
- package/lib/ModernIDB/ModernIDB.ts +0 -337
- package/lib/ModernIDB/ModernIDBError.ts +0 -9
- package/lib/ModernIDB/ObjectStore.ts +0 -195
- package/lib/ModernIDB/ObjectStoreIndex.ts +0 -102
- package/lib/ModernIDB/README.md +0 -9
- package/lib/ModernIDB/Transaction.ts +0 -40
- package/lib/ModernIDB/VersionChangeManager.ts +0 -57
- package/lib/ModernIDB/bindings/factory.tsx +0 -165
- package/lib/ModernIDB/bindings/index.ts +0 -2
- package/lib/ModernIDB/bindings/utils.tsx +0 -32
- package/lib/ModernIDB/index.ts +0 -10
- package/lib/ModernIDB/types.ts +0 -120
- package/lib/ModernIDB/utils.ts +0 -51
- package/lib/QRCode/QRCode.stories.tsx +0 -41
- package/lib/QRCode/QRCode.tsx +0 -54
- package/lib/QRCode/style.css.ts +0 -23
- package/lib/ReleaseInfo/index.tsx +0 -29
- package/lib/RulesetResolver.ts +0 -214
- package/lib/SafariCheck/SafariCheck.stories.tsx +0 -99
- package/lib/SafariCheck/SafariCheck.tsx +0 -273
- package/lib/SafariCheck/addToDock.svg +0 -13
- package/lib/SafariCheck/addToHomeScreen.svg +0 -12
- package/lib/SafariCheck/safari.svg +0 -32
- package/lib/SafariCheck/shareIcon.svg +0 -11
- package/lib/SafariCheck/style.css.ts +0 -106
- package/lib/ServiceWorkerHandler.tsx +0 -53
- package/lib/ShareButton/ShareButton.stories.tsx +0 -58
- package/lib/ShareButton/ShareButton.tsx +0 -153
- package/lib/ShareButton/test.css.ts +0 -3
- package/lib/SubscribeCard/LetterheadInfoCard.tsx +0 -23
- package/lib/SubscribeCard/SubscribeByEmailCard.stories.tsx +0 -69
- package/lib/SubscribeCard/SubscribeByEmailCard.tsx +0 -183
- package/lib/SubscribeCard/SubscribeByPledgeCard.stories.tsx +0 -133
- package/lib/SubscribeCard/SubscribeByPledgeCard.tsx +0 -127
- package/lib/SubscribeCard/style.css.ts +0 -14
- package/lib/account/AccountIssueView.tsx +0 -44
- package/lib/account/AlreadyLoggedInView.tsx +0 -47
- package/lib/account/CurrentUserFetcher.stories.tsx +0 -292
- package/lib/account/CurrentUserFetcher.tsx +0 -118
- package/lib/account/FailureFallbackView.tsx +0 -36
- package/lib/account/JoinCard.stories.tsx +0 -257
- package/lib/account/JoinCard.tsx +0 -301
- package/lib/account/LoadingView.tsx +0 -14
- package/lib/account/LoginCard.stories.tsx +0 -288
- package/lib/account/LoginCard.tsx +0 -100
- package/lib/account/LoginView.tsx +0 -151
- package/lib/account/NoConnectionView.tsx +0 -34
- package/lib/account/PasswordResetCard.stories.tsx +0 -242
- package/lib/account/PasswordResetCard.tsx +0 -296
- package/lib/account/UserMismatchView.tsx +0 -62
- package/lib/account/VerifyPage.tsx +0 -195
- package/lib/account/style.css.ts +0 -57
- package/lib/account/useFetchCurrentUser.tsx +0 -63
- package/lib/account/useRedirectPath.ts +0 -21
- package/lib/animations.css.ts +0 -17
- package/lib/append-copy-to-text.ts +0 -35
- package/lib/async-op.ts +0 -286
- package/lib/atomic.css.ts +0 -11
- package/lib/client.ts +0 -662
- package/lib/common.css.ts +0 -48
- package/lib/copyrightRange.ts +0 -10
- package/lib/createSafeStorage.ts +0 -91
- package/lib/failureMessages.ts +0 -108
- package/lib/form/FormSubmitButton.tsx +0 -58
- package/lib/form/SubmitErrorAlert.tsx +0 -21
- package/lib/form/style.css.ts +0 -9
- package/lib/globals.css.ts +0 -62
- package/lib/groupBy.ts +0 -25
- package/lib/hrefs.ts +0 -48
- package/lib/idToDate.ts +0 -8
- package/lib/ids.ts +0 -6
- package/lib/index.ts +0 -71
- package/lib/internal.css.ts +0 -10
- package/lib/mailto.ts +0 -40
- package/lib/media.ts +0 -50
- package/lib/random.ts +0 -19
- package/lib/result/swr.ts +0 -18
- package/lib/store/index.tsx +0 -241
- package/lib/store/store.ts +0 -479
- package/lib/store/types.ts +0 -45
- package/lib/store/utils.ts +0 -54
- package/lib/storybook/decorators.tsx +0 -10
- package/lib/structs.ts +0 -3
- package/lib/unique.ts +0 -24
- package/lib/use-async-op.ts +0 -16
- package/lib/use-document-background-color.ts +0 -16
- package/lib/use-form.ts +0 -78
- package/lib/use-is-installed.ts +0 -17
- package/lib/use-media-query.ts +0 -21
- package/lib/use-reverting-state.ts +0 -32
- package/lib/use-scroll-restoration.ts +0 -99
- package/lib/useEnsureValue.ts +0 -31
- package/lib/useInvokeClient.ts +0 -54
- package/lib/useIsVisible.ts +0 -27
- package/lib/utm.ts +0 -92
- package/lib/validations.ts +0 -25
- package/lib/vars.css.ts +0 -13
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
type Falsy = null | undefined | false | 0 | 0n | "";
|
|
2
|
+
type Truthy<T> = Exclude<T, Falsy>;
|
|
3
|
+
interface Operation<SuccessValue, FailureValue> {
|
|
4
|
+
readonly type: "SUCCESS" | "FAILURE" | "PENDING";
|
|
5
|
+
readonly isPending: boolean;
|
|
6
|
+
readonly isSuccess: boolean;
|
|
7
|
+
readonly isFailure: boolean;
|
|
8
|
+
val: SuccessValue | FailureValue | null;
|
|
9
|
+
valueOrNull(): SuccessValue | null;
|
|
10
|
+
valueOrThrow(): SuccessValue;
|
|
11
|
+
hasTruthyValue(): boolean;
|
|
12
|
+
failureValueOrNull(): FailureValue | null;
|
|
13
|
+
failureValueOrThrow(): FailureValue;
|
|
14
|
+
flatMap<T extends AsyncOp<unknown, unknown>>(mappingFn: (value: SuccessValue) => T): T | Failure<FailureValue> | Pending;
|
|
15
|
+
mapSuccess<MappedSuccess>(mappingFn: (value: SuccessValue) => MappedSuccess): Operation<MappedSuccess, FailureValue>;
|
|
16
|
+
mapFailure<MappedFailure>(mappingFn: (value: FailureValue) => MappedFailure): Operation<SuccessValue, MappedFailure>;
|
|
17
|
+
unpack<S, F, P>(mapS: (value: SuccessValue) => S, mapF: (failure: FailureValue) => F, mapP: () => P): S | F | P;
|
|
18
|
+
toJSON(): object;
|
|
19
|
+
}
|
|
20
|
+
export declare class Pending implements Operation<never, never> {
|
|
21
|
+
readonly type: "PENDING";
|
|
22
|
+
readonly isPending: true;
|
|
23
|
+
readonly isSuccess: false;
|
|
24
|
+
readonly isFailure: false;
|
|
25
|
+
val: null;
|
|
26
|
+
valueOrNull(): null;
|
|
27
|
+
valueOrThrow(): never;
|
|
28
|
+
hasTruthyValue(): false;
|
|
29
|
+
failureValueOrNull(): null;
|
|
30
|
+
failureValueOrThrow(): never;
|
|
31
|
+
flatMap(): Pending;
|
|
32
|
+
mapSuccess(): Pending;
|
|
33
|
+
mapFailure(): Pending;
|
|
34
|
+
unpack<S, F, P>(_mapS: (value: never) => S, _mapF: (failure: never) => F, mapP: () => P): S | F | P;
|
|
35
|
+
toJSON(): {
|
|
36
|
+
type: "PENDING";
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare class Success<SuccessValue> implements Operation<SuccessValue, never> {
|
|
40
|
+
readonly type: "SUCCESS";
|
|
41
|
+
readonly isPending: false;
|
|
42
|
+
readonly isSuccess: true;
|
|
43
|
+
readonly isFailure: false;
|
|
44
|
+
readonly value: SuccessValue;
|
|
45
|
+
readonly val: SuccessValue;
|
|
46
|
+
constructor(value: SuccessValue);
|
|
47
|
+
valueOrNull(): SuccessValue;
|
|
48
|
+
valueOrThrow(): SuccessValue;
|
|
49
|
+
hasTruthyValue(): this is Success<Truthy<SuccessValue>>;
|
|
50
|
+
failureValueOrNull(): null;
|
|
51
|
+
failureValueOrThrow(): never;
|
|
52
|
+
flatMap<T extends AsyncOp<unknown, unknown>>(mappingFn: (value: SuccessValue) => T): T;
|
|
53
|
+
mapSuccess<MappedValue>(mappingFn: (value: SuccessValue) => MappedValue): Success<MappedValue>;
|
|
54
|
+
mapFailure(): Success<SuccessValue>;
|
|
55
|
+
unpack<S, F, P>(mapS: (value: SuccessValue) => S, _mapF: (failure: never) => F, _mapP: () => P): S | F | P;
|
|
56
|
+
toJSON(): {
|
|
57
|
+
type: "SUCCESS";
|
|
58
|
+
value: SuccessValue;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export declare class Failure<FailureValue> implements Operation<never, FailureValue> {
|
|
62
|
+
readonly type: "FAILURE";
|
|
63
|
+
readonly isPending: false;
|
|
64
|
+
readonly isSuccess: false;
|
|
65
|
+
readonly isFailure: true;
|
|
66
|
+
readonly failure: FailureValue;
|
|
67
|
+
readonly val: FailureValue;
|
|
68
|
+
constructor(failure: FailureValue);
|
|
69
|
+
valueOrNull(): null;
|
|
70
|
+
valueOrThrow(): never;
|
|
71
|
+
hasTruthyValue(): false;
|
|
72
|
+
failureValueOrNull(): FailureValue;
|
|
73
|
+
failureValueOrThrow(): FailureValue;
|
|
74
|
+
flatMap(): Failure<FailureValue>;
|
|
75
|
+
mapSuccess(): Failure<FailureValue>;
|
|
76
|
+
mapFailure<MappedFailure>(mappingFn: (value: FailureValue) => MappedFailure): Failure<MappedFailure>;
|
|
77
|
+
unpack<S, F, P>(_mapS: (value: never) => S, mapF: (failure: FailureValue) => F, _mapP: () => P): S | F | P;
|
|
78
|
+
toJSON(): {
|
|
79
|
+
type: "FAILURE";
|
|
80
|
+
failure: FailureValue;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Folds multiple ops into a single op.
|
|
85
|
+
*
|
|
86
|
+
* To return a Success, all ops provided must be a Success. If any Failures are
|
|
87
|
+
* encountered, will return the first one found.
|
|
88
|
+
*
|
|
89
|
+
* If neither of these conditions is true, will return Pending.
|
|
90
|
+
*
|
|
91
|
+
* Note that if passed an empty array, will always return a Success (with an
|
|
92
|
+
* empty array as value). This mimics the semantics of many JS constructs, like
|
|
93
|
+
* Promise.all or Array.prototype.every.
|
|
94
|
+
*/
|
|
95
|
+
export declare function fold<Ops extends readonly AsyncOp<unknown, unknown>[] | []>(ops: Ops): AsyncOp<{
|
|
96
|
+
-readonly [Index in keyof Ops]: Ops[Index] extends AsyncOp<infer S, unknown> ? S : never;
|
|
97
|
+
}, Ops[number] extends AsyncOp<unknown, infer F> ? F : never>;
|
|
98
|
+
export declare function isAsyncOp(value: unknown): value is AsyncOp<unknown, unknown>;
|
|
99
|
+
export type AsyncOp<SuccessValue, FailureValue> = Pending | Success<SuccessValue> | Failure<FailureValue>;
|
|
100
|
+
export declare function fromTryCatch<T>(callback: () => T): Failure<unknown> | Success<T>;
|
|
101
|
+
export {};
|
|
@@ -12,14 +12,4 @@
|
|
|
12
12
|
* if so, returns its message. If a string was caught, it returns that.
|
|
13
13
|
* Otherwise, it returns "Unknown error".
|
|
14
14
|
*/
|
|
15
|
-
export function caughtValueToString(value: unknown): string
|
|
16
|
-
if (value instanceof Error) {
|
|
17
|
-
return value.message;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (typeof value === "string") {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return "Unknown error.";
|
|
25
|
-
}
|
|
15
|
+
export declare function caughtValueToString(value: unknown): string;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
type Falsy = false | null | undefined;
|
|
2
|
-
|
|
3
2
|
type PropsWithClassName = {
|
|
4
|
-
|
|
3
|
+
className?: ClassName;
|
|
5
4
|
};
|
|
6
|
-
|
|
7
5
|
type ClassName = string | PropsWithClassName | Falsy;
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Combines a list of strings or objects with className property into a single
|
|
11
8
|
* string. Falsy values are ignored.
|
|
12
9
|
*/
|
|
13
|
-
export function classNames(...classNames: ClassName[])
|
|
14
|
-
return classNames
|
|
15
|
-
.filter((cn) => !!cn)
|
|
16
|
-
.map((cn) => (typeof cn === "object" ? cn?.className : cn))
|
|
17
|
-
.join(" ");
|
|
18
|
-
}
|
|
19
|
-
|
|
10
|
+
export declare function classNames(...classNames: ClassName[]): string;
|
|
20
11
|
/**
|
|
21
12
|
* Given a list of strings or objects with the className property, returns an
|
|
22
13
|
* object with className property and combined className. Falsy values will
|
|
@@ -25,9 +16,7 @@ export function classNames(...classNames: ClassName[]) {
|
|
|
25
16
|
* @example
|
|
26
17
|
* <h1 {...cx(props, 'heading', 'bold')}>Hello world!</h1>
|
|
27
18
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
}
|
|
19
|
+
export declare function cx(...cns: ClassName[]): {
|
|
20
|
+
className: string;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { FeatureUnlock, UserGameData } from '@indietabletop/types';
|
|
2
|
+
import { Struct, Infer } from 'superstruct';
|
|
3
|
+
import { Failure, Success } from './async-op.ts';
|
|
4
|
+
import { CurrentUser, FailurePayload, SessionInfo } from './types.ts';
|
|
5
|
+
export type GameCode = keyof UserGameData;
|
|
6
|
+
export type ClientEventType = keyof ClientEventMap;
|
|
7
|
+
type ClientEventMap = {
|
|
8
|
+
/**
|
|
9
|
+
* Triggered every time currentUser is received.
|
|
10
|
+
*/
|
|
11
|
+
currentUser: {
|
|
12
|
+
currentUser: CurrentUser;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Triggered when new session info is received.
|
|
16
|
+
*/
|
|
17
|
+
sessionInfo: {
|
|
18
|
+
sessionInfo: SessionInfo;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Triggered when token refresh fails due to a 401 error.
|
|
22
|
+
*/
|
|
23
|
+
sessionExpired: undefined;
|
|
24
|
+
};
|
|
25
|
+
type ClientEventArgs<T extends ClientEventType> = ClientEventMap[T] extends undefined ? [type: T] : [type: T, detail: ClientEventMap[T]];
|
|
26
|
+
export declare class ClientEvent<T extends keyof ClientEventMap> extends CustomEvent<ClientEventMap[T]> {
|
|
27
|
+
constructor(...args: ClientEventArgs<T>);
|
|
28
|
+
}
|
|
29
|
+
declare const logLevelToInt: {
|
|
30
|
+
off: number;
|
|
31
|
+
error: number;
|
|
32
|
+
warn: number;
|
|
33
|
+
info: number;
|
|
34
|
+
};
|
|
35
|
+
type LogLevel = keyof typeof logLevelToInt;
|
|
36
|
+
export declare class IndieTabletopClient {
|
|
37
|
+
origin: string;
|
|
38
|
+
private refreshTokenPromise?;
|
|
39
|
+
private maxLogLevel;
|
|
40
|
+
private eventTarget;
|
|
41
|
+
constructor(props: {
|
|
42
|
+
apiOrigin: string;
|
|
43
|
+
/**
|
|
44
|
+
* Runs every time the current user is fetched from the API. Typically, this
|
|
45
|
+
* happens during login, signup, and when the current user is fetched.
|
|
46
|
+
*/
|
|
47
|
+
onCurrentUser?: (currentUser: CurrentUser) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Runs ever time new session info is fetched from the API. Typically, this
|
|
50
|
+
* happends during login, signup, and when tokens are refreshed.
|
|
51
|
+
*/
|
|
52
|
+
onSessionInfo?: (sessionInfo: SessionInfo) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Runs when token refresh is attempted, but fails due to 401 error.
|
|
55
|
+
*/
|
|
56
|
+
onSessionExpired?: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Controls how much to log to the console.
|
|
59
|
+
*
|
|
60
|
+
* This is useful e.g. in Storybook, where errors are reported by MSW, and
|
|
61
|
+
* we don't want to pollute the console with duplicate data.
|
|
62
|
+
*
|
|
63
|
+
* @default 'info'
|
|
64
|
+
*/
|
|
65
|
+
logLevel?: LogLevel;
|
|
66
|
+
});
|
|
67
|
+
private dispatchEvent;
|
|
68
|
+
addEventListener<T extends ClientEventType>(type: T, callback: (event: ClientEvent<T>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
69
|
+
removeEventListener<T extends ClientEventType>(type: T, callback: (event: ClientEvent<T>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
70
|
+
private log;
|
|
71
|
+
private fetchWithTokenRefresh;
|
|
72
|
+
fetch<T, S>(path: string, struct: Struct<T, S>, init?: RequestInit & {
|
|
73
|
+
json?: object;
|
|
74
|
+
}): Promise<Success<Infer<Struct<T, S>>> | Failure<FailurePayload>>;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use the instance `fetch` method instead. Token refresh
|
|
77
|
+
* is determined dynamically by server response.
|
|
78
|
+
*/
|
|
79
|
+
protected fetchWithAuth<T, S>(path: string, struct: Struct<T, S>, init?: RequestInit & {
|
|
80
|
+
json?: object;
|
|
81
|
+
}): Promise<Success<Infer<Struct<T, S>>> | Failure<FailurePayload>>;
|
|
82
|
+
login(payload: {
|
|
83
|
+
email: string;
|
|
84
|
+
password: string;
|
|
85
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
86
|
+
currentUser: {
|
|
87
|
+
id: string;
|
|
88
|
+
email: string;
|
|
89
|
+
isVerified: boolean;
|
|
90
|
+
prefersScrollbarVisibility?: "ALWAYS" | undefined;
|
|
91
|
+
};
|
|
92
|
+
sessionInfo: {
|
|
93
|
+
createdTs: number;
|
|
94
|
+
expiresTs: number;
|
|
95
|
+
};
|
|
96
|
+
}>>;
|
|
97
|
+
userAgent(): Promise<Failure<FailurePayload> | Success<{
|
|
98
|
+
browser?: {
|
|
99
|
+
name?: string | undefined;
|
|
100
|
+
version?: string | undefined;
|
|
101
|
+
major?: string | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
device?: {
|
|
104
|
+
type?: string | undefined;
|
|
105
|
+
model?: string | undefined;
|
|
106
|
+
vendor?: string | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
engine?: {
|
|
109
|
+
name?: string | undefined;
|
|
110
|
+
version?: string | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
os?: {
|
|
113
|
+
name?: string | undefined;
|
|
114
|
+
version?: string | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
}>>;
|
|
117
|
+
logout(): Promise<Failure<FailurePayload> | Success<{
|
|
118
|
+
message: string;
|
|
119
|
+
}>>;
|
|
120
|
+
join(payload: {
|
|
121
|
+
email: string;
|
|
122
|
+
password: string;
|
|
123
|
+
acceptedTos: boolean;
|
|
124
|
+
subscribedToNewsletter: boolean;
|
|
125
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
126
|
+
currentUser: {
|
|
127
|
+
id: string;
|
|
128
|
+
email: string;
|
|
129
|
+
isVerified: boolean;
|
|
130
|
+
prefersScrollbarVisibility?: "ALWAYS" | undefined;
|
|
131
|
+
};
|
|
132
|
+
sessionInfo: {
|
|
133
|
+
createdTs: number;
|
|
134
|
+
expiresTs: number;
|
|
135
|
+
};
|
|
136
|
+
tokenId: string;
|
|
137
|
+
}>>;
|
|
138
|
+
/**
|
|
139
|
+
* Triggers token refresh process.
|
|
140
|
+
*
|
|
141
|
+
* Note that we do not want to perform multiple concurrent token refresh
|
|
142
|
+
* actions, as that will result in unnecessary 401s. For this reason, a
|
|
143
|
+
* reference to t
|
|
144
|
+
*/
|
|
145
|
+
refreshTokens(): Promise<Success<{
|
|
146
|
+
sessionInfo: SessionInfo;
|
|
147
|
+
}> | Failure<FailurePayload>>;
|
|
148
|
+
requestPasswordReset(payload: {
|
|
149
|
+
email: string;
|
|
150
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
151
|
+
message: string;
|
|
152
|
+
tokenId: string;
|
|
153
|
+
}>>;
|
|
154
|
+
checkPasswordResetCode(payload: {
|
|
155
|
+
tokenId: string;
|
|
156
|
+
code: string;
|
|
157
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
158
|
+
message: string;
|
|
159
|
+
}>>;
|
|
160
|
+
setNewPassword(payload: {
|
|
161
|
+
tokenId: string;
|
|
162
|
+
code: string;
|
|
163
|
+
password: string;
|
|
164
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
165
|
+
message: string;
|
|
166
|
+
}>>;
|
|
167
|
+
requestUserVerification(): Promise<Failure<FailurePayload> | Success<{
|
|
168
|
+
message: string;
|
|
169
|
+
tokenId: string;
|
|
170
|
+
}>>;
|
|
171
|
+
verifyUser(payload: {
|
|
172
|
+
tokenId: string;
|
|
173
|
+
code: string;
|
|
174
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
175
|
+
message: string;
|
|
176
|
+
}>>;
|
|
177
|
+
getSnapshot<T, S>(gameCode: string, snapshotId: string, struct: Struct<T, S>): Promise<Failure<FailurePayload> | Success<T>>;
|
|
178
|
+
createSnapshot(gameCode: string, payload: object): Promise<Failure<FailurePayload> | Success<{
|
|
179
|
+
snapshotId: string;
|
|
180
|
+
}>>;
|
|
181
|
+
getCurrentUser(): Promise<Failure<FailurePayload> | Success<{
|
|
182
|
+
id: string;
|
|
183
|
+
email: string;
|
|
184
|
+
isVerified: boolean;
|
|
185
|
+
prefersScrollbarVisibility?: "ALWAYS" | undefined;
|
|
186
|
+
}>>;
|
|
187
|
+
getRuleset(game: string, version: string): Promise<Success<unknown> | Failure<FailurePayload>>;
|
|
188
|
+
/**
|
|
189
|
+
* Uploads a file given S3 presigned config.
|
|
190
|
+
*/
|
|
191
|
+
uploadFile(file: File, presigned: {
|
|
192
|
+
url: string;
|
|
193
|
+
key: string;
|
|
194
|
+
fields: Record<string, string>;
|
|
195
|
+
}): Promise<Success<string> | Failure<FailurePayload>>;
|
|
196
|
+
redeemPledge(campaignCode: string, id: string): Promise<Failure<FailurePayload> | Success<{
|
|
197
|
+
id: string;
|
|
198
|
+
email: string;
|
|
199
|
+
downloadUrl: string;
|
|
200
|
+
downloadUrlExpiresTs: number;
|
|
201
|
+
contactSubscribed: boolean;
|
|
202
|
+
}>>;
|
|
203
|
+
subscribeToNewsletterByPledgeId(newsletterCode: string, pledgeId: string): Promise<Failure<FailurePayload> | Success<{
|
|
204
|
+
message: string;
|
|
205
|
+
}>>;
|
|
206
|
+
subscribeToNewsletterByEmail(newsletterCode: string, email: string): Promise<Failure<FailurePayload> | Success<{
|
|
207
|
+
message: string;
|
|
208
|
+
tokenId: string;
|
|
209
|
+
}>>;
|
|
210
|
+
confirmNewsletterSignup(newsletterCode: string, tokenId: string, plaintextCode: string): Promise<Failure<FailurePayload> | Success<{
|
|
211
|
+
message: string;
|
|
212
|
+
}>>;
|
|
213
|
+
pullUserData(props: {
|
|
214
|
+
sinceTs: number | null;
|
|
215
|
+
include: GameCode | GameCode[];
|
|
216
|
+
expectCurrentUserId: string;
|
|
217
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
218
|
+
spacegits?: {
|
|
219
|
+
gangs?: ({
|
|
220
|
+
id: string;
|
|
221
|
+
name: string;
|
|
222
|
+
updatedTs: number;
|
|
223
|
+
deleted: true;
|
|
224
|
+
} | {
|
|
225
|
+
id: string;
|
|
226
|
+
description: string;
|
|
227
|
+
name: string;
|
|
228
|
+
updatedTs: number;
|
|
229
|
+
deleted: false;
|
|
230
|
+
gits: {
|
|
231
|
+
id: string;
|
|
232
|
+
type: {
|
|
233
|
+
id: string;
|
|
234
|
+
};
|
|
235
|
+
name: string;
|
|
236
|
+
weapons: {
|
|
237
|
+
id: string;
|
|
238
|
+
count: number;
|
|
239
|
+
}[];
|
|
240
|
+
gear: {
|
|
241
|
+
id: string;
|
|
242
|
+
}[];
|
|
243
|
+
offenses: {
|
|
244
|
+
id: string;
|
|
245
|
+
}[];
|
|
246
|
+
treatments: {
|
|
247
|
+
id: string;
|
|
248
|
+
locationId: string;
|
|
249
|
+
}[];
|
|
250
|
+
}[];
|
|
251
|
+
vehicles: {
|
|
252
|
+
id: string;
|
|
253
|
+
type: {
|
|
254
|
+
id: string;
|
|
255
|
+
};
|
|
256
|
+
name: string;
|
|
257
|
+
mods: {
|
|
258
|
+
id: string;
|
|
259
|
+
}[];
|
|
260
|
+
repairs: {
|
|
261
|
+
id: string;
|
|
262
|
+
locationId: string;
|
|
263
|
+
}[];
|
|
264
|
+
weapons: {
|
|
265
|
+
id: string;
|
|
266
|
+
count: number;
|
|
267
|
+
placement: "FIXED" | "PINTLE_MOUNTED";
|
|
268
|
+
}[];
|
|
269
|
+
}[];
|
|
270
|
+
buildMode: "A_LA_CARTE" | "CHEFS_RECOMMENDATION" | "CHAOS_MODE" | "SANDBOX";
|
|
271
|
+
snapshotId: string | null;
|
|
272
|
+
faction: {
|
|
273
|
+
id: string;
|
|
274
|
+
} | null;
|
|
275
|
+
createdTs: number;
|
|
276
|
+
rulesetVersion: string;
|
|
277
|
+
})[] | undefined;
|
|
278
|
+
settings?: {
|
|
279
|
+
id: "PRINT_SETTINGS";
|
|
280
|
+
updatedTs: number;
|
|
281
|
+
printWeaponRules: boolean;
|
|
282
|
+
printGitRules: boolean;
|
|
283
|
+
printVehicleRules: boolean;
|
|
284
|
+
}[] | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
}>>;
|
|
287
|
+
pushUserData(props: {
|
|
288
|
+
currentSyncTs: number;
|
|
289
|
+
pullSinceTs: number | null;
|
|
290
|
+
data: UserGameData;
|
|
291
|
+
expectCurrentUserId: string | null | undefined;
|
|
292
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
293
|
+
spacegits?: {
|
|
294
|
+
gangs?: ({
|
|
295
|
+
id: string;
|
|
296
|
+
name: string;
|
|
297
|
+
updatedTs: number;
|
|
298
|
+
deleted: true;
|
|
299
|
+
} | {
|
|
300
|
+
id: string;
|
|
301
|
+
description: string;
|
|
302
|
+
name: string;
|
|
303
|
+
updatedTs: number;
|
|
304
|
+
deleted: false;
|
|
305
|
+
gits: {
|
|
306
|
+
id: string;
|
|
307
|
+
type: {
|
|
308
|
+
id: string;
|
|
309
|
+
};
|
|
310
|
+
name: string;
|
|
311
|
+
weapons: {
|
|
312
|
+
id: string;
|
|
313
|
+
count: number;
|
|
314
|
+
}[];
|
|
315
|
+
gear: {
|
|
316
|
+
id: string;
|
|
317
|
+
}[];
|
|
318
|
+
offenses: {
|
|
319
|
+
id: string;
|
|
320
|
+
}[];
|
|
321
|
+
treatments: {
|
|
322
|
+
id: string;
|
|
323
|
+
locationId: string;
|
|
324
|
+
}[];
|
|
325
|
+
}[];
|
|
326
|
+
vehicles: {
|
|
327
|
+
id: string;
|
|
328
|
+
type: {
|
|
329
|
+
id: string;
|
|
330
|
+
};
|
|
331
|
+
name: string;
|
|
332
|
+
mods: {
|
|
333
|
+
id: string;
|
|
334
|
+
}[];
|
|
335
|
+
repairs: {
|
|
336
|
+
id: string;
|
|
337
|
+
locationId: string;
|
|
338
|
+
}[];
|
|
339
|
+
weapons: {
|
|
340
|
+
id: string;
|
|
341
|
+
count: number;
|
|
342
|
+
placement: "FIXED" | "PINTLE_MOUNTED";
|
|
343
|
+
}[];
|
|
344
|
+
}[];
|
|
345
|
+
buildMode: "A_LA_CARTE" | "CHEFS_RECOMMENDATION" | "CHAOS_MODE" | "SANDBOX";
|
|
346
|
+
snapshotId: string | null;
|
|
347
|
+
faction: {
|
|
348
|
+
id: string;
|
|
349
|
+
} | null;
|
|
350
|
+
createdTs: number;
|
|
351
|
+
rulesetVersion: string;
|
|
352
|
+
})[] | undefined;
|
|
353
|
+
settings?: {
|
|
354
|
+
id: "PRINT_SETTINGS";
|
|
355
|
+
updatedTs: number;
|
|
356
|
+
printWeaponRules: boolean;
|
|
357
|
+
printGitRules: boolean;
|
|
358
|
+
printVehicleRules: boolean;
|
|
359
|
+
}[] | undefined;
|
|
360
|
+
} | undefined;
|
|
361
|
+
}>>;
|
|
362
|
+
getUnlocks<T extends FeatureUnlock["gameCode"]>(gameCode: T): Promise<Failure<FailurePayload> | Success<{
|
|
363
|
+
unlocks: (Extract<{
|
|
364
|
+
feature: "SPACE_GITS_CORE_RULES";
|
|
365
|
+
gameCode: "spacegits";
|
|
366
|
+
}, {
|
|
367
|
+
gameCode: T;
|
|
368
|
+
}> | Extract<{
|
|
369
|
+
feature: "GREATHELM_CORE_RULES";
|
|
370
|
+
gameCode: "greathelm";
|
|
371
|
+
}, {
|
|
372
|
+
gameCode: T;
|
|
373
|
+
}>)[];
|
|
374
|
+
}>>;
|
|
375
|
+
getOwnedProduct(productCode: string): Promise<Failure<FailurePayload> | Success<{
|
|
376
|
+
id: string;
|
|
377
|
+
type: "DIGITAL";
|
|
378
|
+
name: string;
|
|
379
|
+
code: string;
|
|
380
|
+
downloadUrl?: string | undefined;
|
|
381
|
+
downloadUrlExpiresTs?: number | undefined;
|
|
382
|
+
unlocks?: ({
|
|
383
|
+
feature: "SPACE_GITS_CORE_RULES";
|
|
384
|
+
gameCode: "spacegits";
|
|
385
|
+
} | {
|
|
386
|
+
feature: "GREATHELM_CORE_RULES";
|
|
387
|
+
gameCode: "greathelm";
|
|
388
|
+
})[] | undefined;
|
|
389
|
+
downloadFileSize?: string | undefined;
|
|
390
|
+
downloadFileVersion?: string | undefined;
|
|
391
|
+
}>>;
|
|
392
|
+
startCheckoutSession(payload: {
|
|
393
|
+
products: {
|
|
394
|
+
code: string;
|
|
395
|
+
quantity: number;
|
|
396
|
+
}[];
|
|
397
|
+
successUrl: string;
|
|
398
|
+
cancelUrl: string;
|
|
399
|
+
}): Promise<Failure<FailurePayload> | Success<{
|
|
400
|
+
redirectTo: string;
|
|
401
|
+
}>>;
|
|
402
|
+
getCheckoutSession(sessionId: string): Promise<Failure<FailurePayload> | Success<{
|
|
403
|
+
status: string;
|
|
404
|
+
orderRef: string;
|
|
405
|
+
products: {
|
|
406
|
+
id: string;
|
|
407
|
+
type: "DIGITAL";
|
|
408
|
+
name: string;
|
|
409
|
+
code: string;
|
|
410
|
+
downloadUrl?: string | undefined;
|
|
411
|
+
downloadUrlExpiresTs?: number | undefined;
|
|
412
|
+
unlocks?: ({
|
|
413
|
+
feature: "SPACE_GITS_CORE_RULES";
|
|
414
|
+
gameCode: "spacegits";
|
|
415
|
+
} | {
|
|
416
|
+
feature: "GREATHELM_CORE_RULES";
|
|
417
|
+
gameCode: "greathelm";
|
|
418
|
+
})[] | undefined;
|
|
419
|
+
downloadFileSize?: string | undefined;
|
|
420
|
+
downloadFileVersion?: string | undefined;
|
|
421
|
+
}[];
|
|
422
|
+
}>>;
|
|
423
|
+
}
|
|
424
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyrightRange(yearSince: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Struct } from 'superstruct';
|
|
2
|
+
type AnyStruct = Struct<any, any>;
|
|
3
|
+
type StructsConfig = Record<string, AnyStruct>;
|
|
4
|
+
type SafeStorage<T extends Record<string, AnyStruct>> = ReturnType<typeof createSafeStorage<T>>;
|
|
5
|
+
export type SafeStorageKey<T extends SafeStorage<StructsConfig>> = ReturnType<T["keys"]>[number];
|
|
6
|
+
type StructValue<T> = T extends Struct<infer V> ? V : never;
|
|
7
|
+
/**
|
|
8
|
+
* Creates an object with an interface similar to localStorage, but that
|
|
9
|
+
* enforces that values are parsed and validated before being retrieved,
|
|
10
|
+
* stringified when being set, and that both keys and values typecheck.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const safeStorage = createSafeStorage({
|
|
15
|
+
* currentUser: currentUser(),
|
|
16
|
+
* sessionInfo: sessionInfo(),
|
|
17
|
+
* lastSuccessfulSyncTs: number(),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* safeStorage.getItem("currentUser") // Will be valid current user or `null`
|
|
21
|
+
* safeStorage.setItem("currentUser", { ... }) // Typechecked key and value
|
|
22
|
+
* safeStorage.removeItem("currentUser") // Typechecked key
|
|
23
|
+
* safeStorage.clear() // Removes all "owned" keys
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSafeStorage<T extends StructsConfig>(structs: T): {
|
|
28
|
+
getItem<K extends keyof T & string>(key: K): StructValue<T[K]> | null;
|
|
29
|
+
setItem<K extends keyof T & string>(key: K, value: StructValue<T[K]>): void;
|
|
30
|
+
removeItem(key: keyof T & string): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
keys(): (keyof T)[];
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FailurePayload } from './types.ts';
|
|
2
|
+
export type FetchFailureAction = {
|
|
3
|
+
type: "LINK";
|
|
4
|
+
href: string;
|
|
5
|
+
label: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "RELOAD" | "REFETCH";
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
export type FetchFailureMessages = {
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
action: FetchFailureAction;
|
|
14
|
+
};
|
|
15
|
+
export declare const getFetchFailureMessages: (failure: FailurePayload, overrides?: Record<number, Partial<FetchFailureMessages>>) => FetchFailureMessages;
|
|
16
|
+
export declare const getSubmitFailureMessage: (failure: FailurePayload, overrides?: Record<number, string>) => string;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use {@link getSubmitFailureMessage} instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toKnownFailureMessage(failure: FailurePayload): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FormSubmitProps } from '@ariakit/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type FormSubmitButtonProps = FormSubmitProps & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
loading: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Renders Ariakit FormSubmit component.
|
|
9
|
+
*
|
|
10
|
+
* It's main responsibility is to render the loading component (provided via
|
|
11
|
+
* the `loading` prop) when the form is in the submitting state. This component
|
|
12
|
+
* will be rendered over the usual content of the button, which will be hidden
|
|
13
|
+
* as long as the form is submitting.
|
|
14
|
+
*
|
|
15
|
+
* @remarks Must be rendered within Ariakit Form Context.
|
|
16
|
+
*/
|
|
17
|
+
export declare function FormSubmitButton(props: FormSubmitButtonProps): import("react/jsx-runtime").JSX.Element;
|