@rexezuge/web 0.0.0-stage → 1.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/LICENSE +21 -0
- package/dist/Badge.d.ts +42 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +25 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Button.d.ts +69 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +39 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +42 -0
- package/dist/Card.d.ts.map +1 -0
- package/dist/Card.js +42 -0
- package/dist/Card.js.map +1 -0
- package/dist/FocusInput.d.ts +32 -0
- package/dist/FocusInput.d.ts.map +1 -0
- package/dist/FocusInput.js +19 -0
- package/dist/FocusInput.js.map +1 -0
- package/dist/Input.d.ts +52 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +49 -0
- package/dist/Input.js.map +1 -0
- package/dist/LoadingButton.d.ts +46 -0
- package/dist/LoadingButton.d.ts.map +1 -0
- package/dist/LoadingButton.js +30 -0
- package/dist/LoadingButton.js.map +1 -0
- package/dist/Pagination.d.ts +63 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +75 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/Spinner.d.ts +31 -0
- package/dist/Spinner.d.ts.map +1 -0
- package/dist/Spinner.js +14 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/api.d.ts +132 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +258 -0
- package/dist/api.js.map +1 -0
- package/dist/constants.d.ts +49 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +49 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/theme.d.ts +79 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +134 -0
- package/dist/theme.js.map +1 -0
- package/dist/useCurrentUser.d.ts +67 -0
- package/dist/useCurrentUser.d.ts.map +1 -0
- package/dist/useCurrentUser.js +49 -0
- package/dist/useCurrentUser.js.map +1 -0
- package/dist/useNotice.d.ts +60 -0
- package/dist/useNotice.d.ts.map +1 -0
- package/dist/useNotice.js +34 -0
- package/dist/useNotice.js.map +1 -0
- package/dist/useSpaLanguage.d.ts +81 -0
- package/dist/useSpaLanguage.d.ts.map +1 -0
- package/dist/useSpaLanguage.js +149 -0
- package/dist/useSpaLanguage.js.map +1 -0
- package/dist/utils.d.ts +53 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +346 -0
- package/dist/utils.js.map +1 -0
- package/package.json +51 -3
- package/README.md +0 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timing and path constants the SPA primitives share.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `lib/constants.ts` in **CalDAV-Bridge**, **Durable-DAV**, **Durable-DAV-Router**,
|
|
7
|
+
* **Edge-Git**, **Edge-Sonic**, **Mail-Meow**, **Mail-Otter** and
|
|
8
|
+
* **AWS-AccessBridge** — eight copies, of which only three values are shared by
|
|
9
|
+
* most:
|
|
10
|
+
*
|
|
11
|
+
* | Value | Repos |
|
|
12
|
+
* | --------------------------------- | ----- |
|
|
13
|
+
* | `NOTICE_TIMEOUT_MS = 6000` | 7 of 8 (all but AWS-AccessBridge, which has no notice bar) |
|
|
14
|
+
* | `ZERO_TRUST_AUTHENTICATION_PATH` | 7 of 8 (all but CalDAV-Bridge) |
|
|
15
|
+
* | `COPY_FEEDBACK_TIMEOUT_MS = 1500` | 5 of 8 |
|
|
16
|
+
*
|
|
17
|
+
* Everything else stayed in exactly one repo and is therefore *not* here — a
|
|
18
|
+
* constant with a single consumer is that consumer's vocabulary, not the
|
|
19
|
+
* family's. Consumers re-declaring these locally should delete them and import
|
|
20
|
+
* from `@rexezuge/web`:
|
|
21
|
+
*
|
|
22
|
+
* - `SCAN_POLL_INTERVAL_MS` (Edge-Sonic) — a library-scan poll cadence.
|
|
23
|
+
* - `FORM_HIGHLIGHT_TIMEOUT_MS` (Mail-Otter) — form highlight animation.
|
|
24
|
+
* - `OAUTH2_FEATURES` / `OAUTH2_FEATURE_SCOPES` (Mail-Otter) — provider tables.
|
|
25
|
+
* - `DEFAULT_TEAM_ID` (AWS-AccessBridge) — re-exported from its own `shared`.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* How long a notice stays on screen before it dismisses itself.
|
|
29
|
+
*
|
|
30
|
+
* Six seconds in every repo that has one: long enough to read a sentence, short
|
|
31
|
+
* enough that a stale error is not still on screen after the user has fixed it.
|
|
32
|
+
*/
|
|
33
|
+
declare const NOTICE_TIMEOUT_MS = 6000;
|
|
34
|
+
/**
|
|
35
|
+
* How long a "Copied" affordance stays visible after a clipboard write.
|
|
36
|
+
*/
|
|
37
|
+
declare const COPY_FEEDBACK_TIMEOUT_MS = 1500;
|
|
38
|
+
/**
|
|
39
|
+
* The path that is always behind Cloudflare Access.
|
|
40
|
+
*
|
|
41
|
+
* Navigating here starts the Zero Trust login flow for a caller with no valid
|
|
42
|
+
* session; after login, Access redirects back to the URL it interrupted, which
|
|
43
|
+
* is why each app also registers this path — Edge-Sonic answers it with a
|
|
44
|
+
* redirect to `/` so a returning signer-in does not land on a JSON
|
|
45
|
+
* `Exception{NotFound}` from what they were told was the app home.
|
|
46
|
+
*/
|
|
47
|
+
declare const ZERO_TRUST_AUTHENTICATION_PATH = "/user/";
|
|
48
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH };
|
|
49
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,OAAO,CAAC;AAE/B;;GAEG;AACH,QAAA,MAAM,wBAAwB,OAAO,CAAC;AAEtC;;;;;;;;GAQG;AACH,QAAA,MAAM,8BAA8B,WAAW,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timing and path constants the SPA primitives share.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `lib/constants.ts` in **CalDAV-Bridge**, **Durable-DAV**, **Durable-DAV-Router**,
|
|
7
|
+
* **Edge-Git**, **Edge-Sonic**, **Mail-Meow**, **Mail-Otter** and
|
|
8
|
+
* **AWS-AccessBridge** — eight copies, of which only three values are shared by
|
|
9
|
+
* most:
|
|
10
|
+
*
|
|
11
|
+
* | Value | Repos |
|
|
12
|
+
* | --------------------------------- | ----- |
|
|
13
|
+
* | `NOTICE_TIMEOUT_MS = 6000` | 7 of 8 (all but AWS-AccessBridge, which has no notice bar) |
|
|
14
|
+
* | `ZERO_TRUST_AUTHENTICATION_PATH` | 7 of 8 (all but CalDAV-Bridge) |
|
|
15
|
+
* | `COPY_FEEDBACK_TIMEOUT_MS = 1500` | 5 of 8 |
|
|
16
|
+
*
|
|
17
|
+
* Everything else stayed in exactly one repo and is therefore *not* here — a
|
|
18
|
+
* constant with a single consumer is that consumer's vocabulary, not the
|
|
19
|
+
* family's. Consumers re-declaring these locally should delete them and import
|
|
20
|
+
* from `@rexezuge/web`:
|
|
21
|
+
*
|
|
22
|
+
* - `SCAN_POLL_INTERVAL_MS` (Edge-Sonic) — a library-scan poll cadence.
|
|
23
|
+
* - `FORM_HIGHLIGHT_TIMEOUT_MS` (Mail-Otter) — form highlight animation.
|
|
24
|
+
* - `OAUTH2_FEATURES` / `OAUTH2_FEATURE_SCOPES` (Mail-Otter) — provider tables.
|
|
25
|
+
* - `DEFAULT_TEAM_ID` (AWS-AccessBridge) — re-exported from its own `shared`.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* How long a notice stays on screen before it dismisses itself.
|
|
29
|
+
*
|
|
30
|
+
* Six seconds in every repo that has one: long enough to read a sentence, short
|
|
31
|
+
* enough that a stale error is not still on screen after the user has fixed it.
|
|
32
|
+
*/
|
|
33
|
+
const NOTICE_TIMEOUT_MS = 6000;
|
|
34
|
+
/**
|
|
35
|
+
* How long a "Copied" affordance stays visible after a clipboard write.
|
|
36
|
+
*/
|
|
37
|
+
const COPY_FEEDBACK_TIMEOUT_MS = 1500;
|
|
38
|
+
/**
|
|
39
|
+
* The path that is always behind Cloudflare Access.
|
|
40
|
+
*
|
|
41
|
+
* Navigating here starts the Zero Trust login flow for a caller with no valid
|
|
42
|
+
* session; after login, Access redirects back to the URL it interrupted, which
|
|
43
|
+
* is why each app also registers this path — Edge-Sonic answers it with a
|
|
44
|
+
* redirect to `/` so a returning signer-in does not land on a JSON
|
|
45
|
+
* `Exception{NotFound}` from what they were told was the app home.
|
|
46
|
+
*/
|
|
47
|
+
const ZERO_TRUST_AUTHENTICATION_PATH = '/user/';
|
|
48
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH };
|
|
49
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;GAEG;AACH,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,8BAA8B,GAAG,QAAQ,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@rexezuge/web` — the SPA layer of the kit.
|
|
3
|
+
*
|
|
4
|
+
* React primitives, the hooks every app's shell needs, and the one API client.
|
|
5
|
+
* Every export is the converged form of a framework that lived as copies inside
|
|
6
|
+
* the nine consumer repos; see the `## Provenance` block at the top of each
|
|
7
|
+
* module for what it replaced and which copy won.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* ## What a consumer must provide
|
|
14
|
+
*
|
|
15
|
+
* - **The CSS variables the class-based components read.** All six Tailwind
|
|
16
|
+
* repos define the same set, so this is usually already present:
|
|
17
|
+
* `--color-accent`, `--color-accent-dim`, `--color-border`,
|
|
18
|
+
* `--color-surface-base`, `--color-surface-1..4`,
|
|
19
|
+
* `--color-text-primary`, `--color-text-secondary`, `--color-text-muted`, and
|
|
20
|
+
* `--color-{success,error,warning,info,neutral}-{bg,text}`.
|
|
21
|
+
* - **`animate-spin`**, for `Spinner` (and therefore `Button`'s busy state).
|
|
22
|
+
* Tailwind ships it; a non-Tailwind app defines the keyframes once.
|
|
23
|
+
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
|
+
* `ServiceError` and the status classes.
|
|
25
|
+
*
|
|
26
|
+
* ## What is deliberately not here
|
|
27
|
+
*
|
|
28
|
+
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
29
|
+
* `?oauth2=` notice seeding, the D1 bookmark header, WebDAV `207` handling, the
|
|
30
|
+
* authed-first public fallback, and every app's `SUPPORTED_LANGUAGES`. Each had
|
|
31
|
+
* exactly one consumer, so each stays with it — see `constants.ts` and the
|
|
32
|
+
* per-module provenance notes for the list.
|
|
33
|
+
*/
|
|
34
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge';
|
|
35
|
+
export type { BadgeProps, BadgeVariant } from './Badge';
|
|
36
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button';
|
|
37
|
+
export type { ButtonProps, ButtonSize, ButtonVariant } from './Button';
|
|
38
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card';
|
|
39
|
+
export type { CardHeaderProps, CardProps, CardTitleProps } from './Card';
|
|
40
|
+
export { FocusInput } from './FocusInput';
|
|
41
|
+
export type { FocusInputProps } from './FocusInput';
|
|
42
|
+
export { Input, Label, Select, Textarea, fieldClass } from './Input';
|
|
43
|
+
export type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input';
|
|
44
|
+
export { LoadingButton } from './LoadingButton';
|
|
45
|
+
export type { LoadingButtonProps } from './LoadingButton';
|
|
46
|
+
export { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';
|
|
47
|
+
export type { PaginationLabels, PaginationProps } from './Pagination';
|
|
48
|
+
export { Spinner } from './Spinner';
|
|
49
|
+
export type { SpinnerProps } from './Spinner';
|
|
50
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, } from './theme';
|
|
51
|
+
export { cn } from './utils';
|
|
52
|
+
export type { ClassDictionary, ClassValue } from './utils';
|
|
53
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants';
|
|
54
|
+
export { useNotice } from './useNotice';
|
|
55
|
+
export type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult } from './useNotice';
|
|
56
|
+
export { canonicalizeLanguageTag, DEFAULT_FALLBACK_LANGUAGE, DEFAULT_LANGUAGE_STORAGE_KEY, DEFAULT_SUPPORTED_LANGUAGES, resolveLanguageTag, useSpaLanguage, } from './useSpaLanguage';
|
|
57
|
+
export type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult } from './useSpaLanguage';
|
|
58
|
+
export { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser';
|
|
59
|
+
export type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult } from './useCurrentUser';
|
|
60
|
+
export { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api';
|
|
61
|
+
export type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue } from './api';
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACrG,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACjG,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UA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AkB,CAAC;AACrE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAC/F,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@rexezuge/web` — the SPA layer of the kit.
|
|
3
|
+
*
|
|
4
|
+
* React primitives, the hooks every app's shell needs, and the one API client.
|
|
5
|
+
* Every export is the converged form of a framework that lived as copies inside
|
|
6
|
+
* the nine consumer repos; see the `## Provenance` block at the top of each
|
|
7
|
+
* module for what it replaced and which copy won.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* ## What a consumer must provide
|
|
14
|
+
*
|
|
15
|
+
* - **The CSS variables the class-based components read.** All six Tailwind
|
|
16
|
+
* repos define the same set, so this is usually already present:
|
|
17
|
+
* `--color-accent`, `--color-accent-dim`, `--color-border`,
|
|
18
|
+
* `--color-surface-base`, `--color-surface-1..4`,
|
|
19
|
+
* `--color-text-primary`, `--color-text-secondary`, `--color-text-muted`, and
|
|
20
|
+
* `--color-{success,error,warning,info,neutral}-{bg,text}`.
|
|
21
|
+
* - **`animate-spin`**, for `Spinner` (and therefore `Button`'s busy state).
|
|
22
|
+
* Tailwind ships it; a non-Tailwind app defines the keyframes once.
|
|
23
|
+
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
|
+
* `ServiceError` and the status classes.
|
|
25
|
+
*
|
|
26
|
+
* ## What is deliberately not here
|
|
27
|
+
*
|
|
28
|
+
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
29
|
+
* `?oauth2=` notice seeding, the D1 bookmark header, WebDAV `207` handling, the
|
|
30
|
+
* authed-first public fallback, and every app's `SUPPORTED_LANGUAGES`. Each had
|
|
31
|
+
* exactly one consumer, so each stays with it — see `constants.ts` and the
|
|
32
|
+
* per-module provenance notes for the list.
|
|
33
|
+
*/
|
|
34
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge';
|
|
35
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button';
|
|
36
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card';
|
|
37
|
+
export { FocusInput } from './FocusInput';
|
|
38
|
+
export { Input, Label, Select, Textarea, fieldClass } from './Input';
|
|
39
|
+
export { LoadingButton } from './LoadingButton';
|
|
40
|
+
export { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';
|
|
41
|
+
export { Spinner } from './Spinner';
|
|
42
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, } from './theme';
|
|
43
|
+
export { cn } from './utils';
|
|
44
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants';
|
|
45
|
+
export { useNotice } from './useNotice';
|
|
46
|
+
export { canonicalizeLanguageTag, DEFAULT_FALLBACK_LANGUAGE, DEFAULT_LANGUAGE_STORAGE_KEY, DEFAULT_SUPPORTED_LANGUAGES, resolveLanguageTag, useSpaLanguage, } from './useSpaLanguage';
|
|
47
|
+
export { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser';
|
|
48
|
+
export { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api';
|
|
49
|
+
//# sourceMappingURL=index.js.map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AAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Design tokens for the inline-styled parts of the SPA.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* Verbatim from `apps/web/src/components/ui/theme.ts` in **AWS-AccessBridge**,
|
|
8
|
+
* which is the only repo of the eight that styled its primitives with inline
|
|
9
|
+
* styles rather than Tailwind classes. It wins by default: nothing else in the
|
|
10
|
+
* family carries a token table, and the six Tailwind repos encode the same
|
|
11
|
+
* decisions as CSS custom properties (`--color-accent`, `--color-surface-1`, …)
|
|
12
|
+
* in their `globals.css` instead of in TypeScript.
|
|
13
|
+
*
|
|
14
|
+
* So this file serves two audiences:
|
|
15
|
+
*
|
|
16
|
+
* - Consumers that render the class-based primitives (`Button`, `Card`, `Input`,
|
|
17
|
+
* `Badge`, `Pagination`) need nothing from here — those components carry
|
|
18
|
+
* Tailwind classes that read the CSS variables their `globals.css` defines.
|
|
19
|
+
* - Consumers with bespoke, non-Tailwind surfaces (AWS-AccessBridge's admin
|
|
20
|
+
* tables and its `LoadingButton` chrome) use these tokens directly.
|
|
21
|
+
*
|
|
22
|
+
* The two are deliberately not unified: collapsing them would either push hex
|
|
23
|
+
* values into the class-based components or force every Tailwind consumer to
|
|
24
|
+
* declare a TypeScript mirror of their theme. Neither repo family does that
|
|
25
|
+
* today, and a token that exists in two places is a token that drifts.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The palette. One flat record so a consumer can spread it into a CSS-in-JS
|
|
29
|
+
* theme or read `theme.accent`-style names without a nested lookup.
|
|
30
|
+
*/
|
|
31
|
+
declare const theme: {
|
|
32
|
+
readonly cardBg: "#1e2433";
|
|
33
|
+
readonly inputBg: "#252d3d";
|
|
34
|
+
readonly border: "#374151";
|
|
35
|
+
readonly blue: "#2563eb";
|
|
36
|
+
readonly blueHover: "#1d4ed8";
|
|
37
|
+
readonly green: "#16a34a";
|
|
38
|
+
readonly greenHover: "#15803d";
|
|
39
|
+
readonly red: "#dc2626";
|
|
40
|
+
readonly redHover: "#b91c1c";
|
|
41
|
+
readonly spinnerBlue: "#60a5fa";
|
|
42
|
+
/** The border colour a focused field paints. */
|
|
43
|
+
readonly focusBorder: "#3b82f6";
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Background/hover pairs for the solid action colours.
|
|
47
|
+
*
|
|
48
|
+
* Keyed by colour name rather than by the kit's `Button` variants because a
|
|
49
|
+
* plain colour table is what a bespoke button needs; `Button` maps its
|
|
50
|
+
* normalized variants onto its own classes.
|
|
51
|
+
*/
|
|
52
|
+
declare const buttonColors: Record<string, {
|
|
53
|
+
bg: string;
|
|
54
|
+
hover: string;
|
|
55
|
+
}>;
|
|
56
|
+
/** The standard content card surface. */
|
|
57
|
+
declare const cardStyle: CSSProperties;
|
|
58
|
+
/** The standard text field surface. */
|
|
59
|
+
declare const inputStyle: CSSProperties;
|
|
60
|
+
/** A card whose content is a table: the table supplies its own padding. */
|
|
61
|
+
declare const tableCardStyle: CSSProperties;
|
|
62
|
+
/** Column header cell. */
|
|
63
|
+
declare const thStyle: CSSProperties;
|
|
64
|
+
/** Body cell. */
|
|
65
|
+
declare const tdStyle: CSSProperties;
|
|
66
|
+
/** A pager control, as used by `Pagination`'s inline-styled consumers. */
|
|
67
|
+
declare const paginationBtnStyle: CSSProperties;
|
|
68
|
+
/**
|
|
69
|
+
* Shared geometry for the solid action buttons: `btnBlueStyle`, `btnGreenStyle`
|
|
70
|
+
* and the small variant each spread it and override only what differs, so a
|
|
71
|
+
* change to the radius or weight lands in all of them at once.
|
|
72
|
+
*/
|
|
73
|
+
declare const btnBase: CSSProperties;
|
|
74
|
+
declare const btnBlueStyle: CSSProperties;
|
|
75
|
+
declare const btnGreenStyle: CSSProperties;
|
|
76
|
+
/** The dense action button used in table rows. */
|
|
77
|
+
declare const btnSmallStyle: CSSProperties;
|
|
78
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, };
|
|
79
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,QAAA,MAAM,KAAK;;;;;;;;;;;IAWT,gDAAgD;;CAExC,CAAC;AAEX;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAI/D,CAAC;AAEF,yCAAyC;AACzC,QAAA,MAAM,SAAS,EAAE,aAIhB,CAAC;AAEF,uCAAuC;AACvC,QAAA,MAAM,UAAU,EAAE,aAUjB,CAAC;AAEF,2EAA2E;AAC3E,QAAA,MAAM,cAAc,EAAE,aAIrB,CAAC;AAEF,0BAA0B;AAC1B,QAAA,MAAM,OAAO,EAAE,aASd,CAAC;AAEF,iBAAiB;AACjB,QAAA,MAAM,OAAO,EAAE,aAGd,CAAC;AAEF,0EAA0E;AAC1E,QAAA,MAAM,kBAAkB,EAAE,aAQzB,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,OAAO,EAAE,aAQd,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,aAAsD,CAAC;AAC3E,QAAA,MAAM,aAAa,EAAE,aAAuD,CAAC;AAE7E,kDAAkD;AAClD,QAAA,MAAM,aAAa,EAAE,aASpB,CAAC;AAEF,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,CAAC"}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design tokens for the inline-styled parts of the SPA.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* Verbatim from `apps/web/src/components/ui/theme.ts` in **AWS-AccessBridge**,
|
|
7
|
+
* which is the only repo of the eight that styled its primitives with inline
|
|
8
|
+
* styles rather than Tailwind classes. It wins by default: nothing else in the
|
|
9
|
+
* family carries a token table, and the six Tailwind repos encode the same
|
|
10
|
+
* decisions as CSS custom properties (`--color-accent`, `--color-surface-1`, …)
|
|
11
|
+
* in their `globals.css` instead of in TypeScript.
|
|
12
|
+
*
|
|
13
|
+
* So this file serves two audiences:
|
|
14
|
+
*
|
|
15
|
+
* - Consumers that render the class-based primitives (`Button`, `Card`, `Input`,
|
|
16
|
+
* `Badge`, `Pagination`) need nothing from here — those components carry
|
|
17
|
+
* Tailwind classes that read the CSS variables their `globals.css` defines.
|
|
18
|
+
* - Consumers with bespoke, non-Tailwind surfaces (AWS-AccessBridge's admin
|
|
19
|
+
* tables and its `LoadingButton` chrome) use these tokens directly.
|
|
20
|
+
*
|
|
21
|
+
* The two are deliberately not unified: collapsing them would either push hex
|
|
22
|
+
* values into the class-based components or force every Tailwind consumer to
|
|
23
|
+
* declare a TypeScript mirror of their theme. Neither repo family does that
|
|
24
|
+
* today, and a token that exists in two places is a token that drifts.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* The palette. One flat record so a consumer can spread it into a CSS-in-JS
|
|
28
|
+
* theme or read `theme.accent`-style names without a nested lookup.
|
|
29
|
+
*/
|
|
30
|
+
const theme = {
|
|
31
|
+
cardBg: '#1e2433',
|
|
32
|
+
inputBg: '#252d3d',
|
|
33
|
+
border: '#374151',
|
|
34
|
+
blue: '#2563eb',
|
|
35
|
+
blueHover: '#1d4ed8',
|
|
36
|
+
green: '#16a34a',
|
|
37
|
+
greenHover: '#15803d',
|
|
38
|
+
red: '#dc2626',
|
|
39
|
+
redHover: '#b91c1c',
|
|
40
|
+
spinnerBlue: '#60a5fa',
|
|
41
|
+
/** The border colour a focused field paints. */
|
|
42
|
+
focusBorder: '#3b82f6',
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Background/hover pairs for the solid action colours.
|
|
46
|
+
*
|
|
47
|
+
* Keyed by colour name rather than by the kit's `Button` variants because a
|
|
48
|
+
* plain colour table is what a bespoke button needs; `Button` maps its
|
|
49
|
+
* normalized variants onto its own classes.
|
|
50
|
+
*/
|
|
51
|
+
const buttonColors = {
|
|
52
|
+
blue: { bg: theme.blue, hover: theme.blueHover },
|
|
53
|
+
green: { bg: theme.green, hover: theme.greenHover },
|
|
54
|
+
red: { bg: theme.red, hover: theme.redHover },
|
|
55
|
+
};
|
|
56
|
+
/** The standard content card surface. */
|
|
57
|
+
const cardStyle = {
|
|
58
|
+
background: theme.cardBg,
|
|
59
|
+
borderRadius: '12px',
|
|
60
|
+
padding: '24px',
|
|
61
|
+
};
|
|
62
|
+
/** The standard text field surface. */
|
|
63
|
+
const inputStyle = {
|
|
64
|
+
width: '100%',
|
|
65
|
+
padding: '12px',
|
|
66
|
+
background: theme.inputBg,
|
|
67
|
+
borderRadius: '8px',
|
|
68
|
+
border: `1px solid ${theme.border}`,
|
|
69
|
+
color: '#ffffff',
|
|
70
|
+
outline: 'none',
|
|
71
|
+
boxSizing: 'border-box',
|
|
72
|
+
transition: 'border-color 0.15s',
|
|
73
|
+
};
|
|
74
|
+
/** A card whose content is a table: the table supplies its own padding. */
|
|
75
|
+
const tableCardStyle = {
|
|
76
|
+
background: theme.cardBg,
|
|
77
|
+
borderRadius: '12px',
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
};
|
|
80
|
+
/** Column header cell. */
|
|
81
|
+
const thStyle = {
|
|
82
|
+
textAlign: 'left',
|
|
83
|
+
padding: '12px',
|
|
84
|
+
background: theme.inputBg,
|
|
85
|
+
color: '#9ca3af',
|
|
86
|
+
textTransform: 'uppercase',
|
|
87
|
+
letterSpacing: '0.05em',
|
|
88
|
+
fontSize: '12px',
|
|
89
|
+
fontWeight: 500,
|
|
90
|
+
};
|
|
91
|
+
/** Body cell. */
|
|
92
|
+
const tdStyle = {
|
|
93
|
+
padding: '12px',
|
|
94
|
+
borderTop: '1px solid rgba(55,65,81,0.3)',
|
|
95
|
+
};
|
|
96
|
+
/** A pager control, as used by `Pagination`'s inline-styled consumers. */
|
|
97
|
+
const paginationBtnStyle = {
|
|
98
|
+
padding: '6px 12px',
|
|
99
|
+
background: theme.inputBg,
|
|
100
|
+
border: 'none',
|
|
101
|
+
borderRadius: '8px',
|
|
102
|
+
color: 'white',
|
|
103
|
+
cursor: 'pointer',
|
|
104
|
+
transition: 'background 0.15s',
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Shared geometry for the solid action buttons: `btnBlueStyle`, `btnGreenStyle`
|
|
108
|
+
* and the small variant each spread it and override only what differs, so a
|
|
109
|
+
* change to the radius or weight lands in all of them at once.
|
|
110
|
+
*/
|
|
111
|
+
const btnBase = {
|
|
112
|
+
padding: '10px 20px',
|
|
113
|
+
borderRadius: '8px',
|
|
114
|
+
color: 'white',
|
|
115
|
+
fontWeight: 500,
|
|
116
|
+
border: 'none',
|
|
117
|
+
cursor: 'pointer',
|
|
118
|
+
transition: 'background 0.15s',
|
|
119
|
+
};
|
|
120
|
+
const btnBlueStyle = { ...btnBase, background: theme.blue };
|
|
121
|
+
const btnGreenStyle = { ...btnBase, background: theme.green };
|
|
122
|
+
/** The dense action button used in table rows. */
|
|
123
|
+
const btnSmallStyle = {
|
|
124
|
+
padding: '6px 12px',
|
|
125
|
+
borderRadius: '6px',
|
|
126
|
+
color: 'white',
|
|
127
|
+
fontWeight: 500,
|
|
128
|
+
fontSize: '13px',
|
|
129
|
+
border: 'none',
|
|
130
|
+
cursor: 'pointer',
|
|
131
|
+
transition: 'background 0.15s',
|
|
132
|
+
};
|
|
133
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, };
|
|
134
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,SAAS;IACrB,GAAG,EAAE,SAAS;IACd,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,SAAS;IACtB,gDAAgD;IAChD,WAAW,EAAE,SAAS;CACd,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,YAAY,GAAkD;IAClE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE;IAChD,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;IACnD,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;CAC9C,CAAC;AAEF,yCAAyC;AACzC,MAAM,SAAS,GAAkB;IAC/B,UAAU,EAAE,KAAK,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d,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AAEF,MAAM,YAAY,GAAkB,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AAC3E,MAAM,aAAa,GAAkB,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;AAE7E,kDAAkD;AAClD,MAAM,aAAa,GAAkB;IACnC,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AAEF,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ServiceError } from '@rexezuge/errors';
|
|
2
|
+
import type { ApiClient } from './api';
|
|
3
|
+
/**
|
|
4
|
+
* The signed-in account, fetched once on mount.
|
|
5
|
+
*
|
|
6
|
+
* ## Provenance
|
|
7
|
+
*
|
|
8
|
+
* `hooks/useCurrentUser.ts` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
9
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
10
|
+
* copies that differ on the three questions this hook exists to answer:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Who fetches.** CalDAV-Bridge, Edge-Git, Edge-Sonic and Mail-Otter call a
|
|
13
|
+
* module-level `loadCurrentUser()` from `services/userService`; Durable-DAV
|
|
14
|
+
* and Durable-DAV-Router call the same helper but keep the client injectable.
|
|
15
|
+
* The kit normalizes to the injectable form: the hook takes the client, so
|
|
16
|
+
* nothing about the request path is baked in and a test hands it a stub.
|
|
17
|
+
* 2. **What a failure means.** Durable-DAV-Router records the bug in a comment:
|
|
18
|
+
* `authorized` was set to `false` for *any* failure, so a 500 or a dropped
|
|
19
|
+
* connection rendered "Sign In With Cloudflare Access" to a caller who was
|
|
20
|
+
* signed in — and the only way back was a hard reload. Its fix is a separate
|
|
21
|
+
* `error` flag meaning "we could not find out", rendered as a retry. That is
|
|
22
|
+
* the shape here: `error` carries the failure, `user` stays `null`, and the
|
|
23
|
+
* caller decides what a retry looks like. A 401 is not special-cased — a 401
|
|
24
|
+
* *is* an error, and a shell that renders a sign-in prompt from it should do
|
|
25
|
+
* so because the app says so.
|
|
26
|
+
* 3. **Effect dependencies.** Durable-DAV documents the other half of the bug:
|
|
27
|
+
* the effect listed `onError` (its only dependency), `SpaApp` passed an
|
|
28
|
+
* inline arrow, so the effect re-ran on every render and issued an
|
|
29
|
+
* unbounded stream of `GET /user/me` from first paint. The kit takes the
|
|
30
|
+
* same cure: the client is read through a ref, and the effect is keyed on
|
|
31
|
+
* `reloadKey` alone. A caller can pass a fresh client every render and the
|
|
32
|
+
* request count is unchanged.
|
|
33
|
+
*
|
|
34
|
+
* ## Normalization
|
|
35
|
+
*
|
|
36
|
+
* `useCurrentUser(client)` returns `{ user, loading, error, reload }`. The
|
|
37
|
+
* `authorized` tri-state (`null`/`true`/`false`) is gone: `loading` already
|
|
38
|
+
* distinguishes "in flight" from "answered", and `error` distinguishes
|
|
39
|
+
* "answered badly" from "not signed in" — a caller that wants `authorized`
|
|
40
|
+
* derives it as `loading ? null : user !== null`. `setUser` is gone too; a
|
|
41
|
+
* change to the account is a refresh (`reload()`), which is what the sources
|
|
42
|
+
* do at every call site anyway.
|
|
43
|
+
*/
|
|
44
|
+
/** The account shape a caller reads. `preferredLanguage` is what `useSpaLanguage` consumes. */
|
|
45
|
+
interface CurrentUser {
|
|
46
|
+
preferredLanguage?: string | null;
|
|
47
|
+
}
|
|
48
|
+
interface UseCurrentUserOptions {
|
|
49
|
+
/** The path to GET. Defaults to `/user/me`, the family's profile route. */
|
|
50
|
+
path?: string;
|
|
51
|
+
}
|
|
52
|
+
interface UseCurrentUserResult<TUser> {
|
|
53
|
+
/** The account, or `null` until it loads (and after a failure). */
|
|
54
|
+
user: TUser | null;
|
|
55
|
+
/** `true` while the request is in flight, including the first one. */
|
|
56
|
+
loading: boolean;
|
|
57
|
+
/** The normalized failure, or `null`. A `ServiceError`, always. */
|
|
58
|
+
error: ServiceError | null;
|
|
59
|
+
/** Re-runs the request. */
|
|
60
|
+
reload: () => void;
|
|
61
|
+
}
|
|
62
|
+
/** The profile route every repo in the family serves. */
|
|
63
|
+
declare const CURRENT_USER_PATH = "/user/me";
|
|
64
|
+
declare function useCurrentUser<TUser = CurrentUser>(client: ApiClient, { path }?: Readonly<UseCurrentUserOptions>): UseCurrentUserResult<TUser>;
|
|
65
|
+
export { CURRENT_USER_PATH, useCurrentUser };
|
|
66
|
+
export type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult };
|
|
67
|
+
//# sourceMappingURL=useCurrentUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentUser.d.ts","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,+FAA+F;AAC/F,UAAU,WAAW;IACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,UAAU,qBAAqB;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,oBAAoB,CAAC,KAAK;IAClC,mEAAmE;IACnE,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,yDAAyD;AACzD,QAAA,MAAM,iBAAiB,aAAa,CAAC;AAErC,iBAAS,cAAc,CAAC,KAAK,GAAG,WAAW,EACzC,MAAM,EAAE,SAAS,EACjB,EAAE,IAAwB,EAAE,GAAE,QAAQ,CAAC,qBAAqB,CAAM,GACjE,oBAAoB,CAAC,KAAK,CAAC,CA8C7B;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { ServiceError } from '@rexezuge/errors';
|
|
3
|
+
/** The profile route every repo in the family serves. */
|
|
4
|
+
const CURRENT_USER_PATH = '/user/me';
|
|
5
|
+
function useCurrentUser(client, { path = CURRENT_USER_PATH } = {}) {
|
|
6
|
+
const [user, setUser] = useState(null);
|
|
7
|
+
const [loading, setLoading] = useState(true);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const [reloadKey, setReloadKey] = useState(0);
|
|
10
|
+
// Read through a ref so a caller's fresh client instance cannot re-run the
|
|
11
|
+
// effect; refreshing is explicit, through `reload`.
|
|
12
|
+
const clientRef = useRef(client);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
clientRef.current = client;
|
|
15
|
+
}, [client]);
|
|
16
|
+
const reload = useCallback(() => {
|
|
17
|
+
setReloadKey((key) => key + 1);
|
|
18
|
+
}, []);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
let cancelled = false;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
clientRef.current
|
|
23
|
+
.get(path)
|
|
24
|
+
.then((me) => {
|
|
25
|
+
if (cancelled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setUser(me);
|
|
29
|
+
setError(null);
|
|
30
|
+
setLoading(false);
|
|
31
|
+
})
|
|
32
|
+
.catch((cause) => {
|
|
33
|
+
if (cancelled) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// Normalized here as well as in the client: a client that is not this
|
|
37
|
+
// package's (`createApiClient`) may throw anything, and a hook that
|
|
38
|
+
// promises a `ServiceError` should deliver one.
|
|
39
|
+
setError(ServiceError.from(cause));
|
|
40
|
+
setLoading(false);
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
cancelled = true;
|
|
44
|
+
};
|
|
45
|
+
}, [path, reloadKey]);
|
|
46
|
+
return { user, loading, error, reload };
|
|
47
|
+
}
|
|
48
|
+
export { CURRENT_USER_PATH, useCurrentUser };
|
|
49
|
+
//# sourceMappingURL=useCurrentUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkEhD,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC,SAAS,cAAc,CACrB,MAAiB,EACjB,EAAE,IAAI,GAAG,iBAAiB,KAAsC,EAAE;IAElE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,IAAI,CAA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,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A transient status message.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `hooks/useNotice.ts` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
7
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
8
|
+
* copies of one hook, with AWS-AccessBridge's `useToast` as the seventh in
|
|
9
|
+
* everything but name. Each contributes one thing:
|
|
10
|
+
*
|
|
11
|
+
* - **Durable-DAV** — the unmount cleanup. Its comment records the bug: the
|
|
12
|
+
* timer was only ever cleared in favour of the *next* notice, so unmounting
|
|
13
|
+
* with a notice showing left it live to call `setState` on a gone component.
|
|
14
|
+
* - **Edge-Sonic** — `clearNotice`, a dismissal that is not just "replace it",
|
|
15
|
+
* and the exported `ShowNotice` type so feature tabs stop re-spelling the
|
|
16
|
+
* setter's signature.
|
|
17
|
+
* - **CalDAV-Bridge / Mail-Otter** — seeding the first notice from the URL's
|
|
18
|
+
* `?oauth2=` result. That is *left local*: the parameter names are
|
|
19
|
+
* product-specific, and a hook that reads a query string is a hook a test
|
|
20
|
+
* has to fake a location for. A consumer seeds its own notice by passing
|
|
21
|
+
* `initial` — see `UseNoticeOptions`.
|
|
22
|
+
* - **All six** — a ref-held timer, so a new notice replaces the old one's
|
|
23
|
+
* dismissal instead of being cut short by it ("the error banner vanished
|
|
24
|
+
* before I read it").
|
|
25
|
+
*
|
|
26
|
+
* ## Normalization
|
|
27
|
+
*
|
|
28
|
+
* The type is `{ kind, message }`. Every copy used `{ type, text }`, and the
|
|
29
|
+
* field names collided with the DOM's `type` on unrelated elements often enough
|
|
30
|
+
* that `kind`/`message` read better at the call sites that build one by hand
|
|
31
|
+
* (`describeProbe` in Edge-Sonic returns a notice-shaped value). The imperative
|
|
32
|
+
* API is `showNotice(kind, message)` — positional, as every copy had it, so a
|
|
33
|
+
* call site reads as the event it reports — plus `dismissNotice()`.
|
|
34
|
+
*/
|
|
35
|
+
type NoticeKind = 'success' | 'error';
|
|
36
|
+
/** One transient message. `kind` is the tone, `message` the sentence. */
|
|
37
|
+
interface Notice {
|
|
38
|
+
kind: NoticeKind;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
/** The setter views and hooks are handed. */
|
|
42
|
+
type ShowNotice = (kind: NoticeKind, message: string) => void;
|
|
43
|
+
interface UseNoticeOptions {
|
|
44
|
+
/** How long a notice stays up. Defaults to `NOTICE_TIMEOUT_MS`. */
|
|
45
|
+
dismissAfterMs?: number;
|
|
46
|
+
/** A notice to start with — the URL-seeded OAuth result, in a consumer. */
|
|
47
|
+
initial?: Notice | null;
|
|
48
|
+
}
|
|
49
|
+
interface UseNoticeResult {
|
|
50
|
+
/** The notice to render, or `null` when there is nothing to say. */
|
|
51
|
+
notice: Notice | null;
|
|
52
|
+
/** Shows a notice, replacing any notice already showing (and its timer). */
|
|
53
|
+
showNotice: ShowNotice;
|
|
54
|
+
/** Hides the notice and cancels its pending dismissal. */
|
|
55
|
+
dismissNotice: () => void;
|
|
56
|
+
}
|
|
57
|
+
declare function useNotice({ dismissAfterMs, initial }?: Readonly<UseNoticeOptions>): UseNoticeResult;
|
|
58
|
+
export { useNotice };
|
|
59
|
+
export type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult };
|
|
60
|
+
//# sourceMappingURL=useNotice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotice.d.ts","sourceRoot":"","sources":["../src/useNotice.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,KAAK,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtC,yEAAyE;AACzE,UAAU,MAAM;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6CAA6C;AAC7C,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE9D,UAAU,gBAAgB;IACxB,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,UAAU,eAAe;IACvB,oEAAoE;IACpE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4EAA4E;IAC5E,UAAU,EAAE,UAAU,CAAC;IACvB,0DAA0D;IAC1D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,iBAAS,SAAS,CAAC,EAAE,cAAkC,EAAE,OAAc,EAAE,GAAE,QAAQ,CAAC,gBAAgB,CAAM,GAAG,eAAe,CAqC3H;AAED,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|