@domicile-desktop/manganese-bar-module-gmail 2.0.2 → 2.1.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/README.md +4 -1
- package/package.json +17 -16
- package/src/addresses.ts +38 -3
- package/src/bar-item.tsx +8 -2
- package/src/consent.ts +9 -3
- package/src/desk-inbox.ts +5 -3
- package/src/gmail-api.ts +87 -3
- package/src/google-token.ts +3 -3
- package/src/held-google.ts +5 -0
- package/src/inbox.ts +9 -2
- package/src/mail-draft.ts +94 -0
- package/src/mail-notices.ts +48 -23
- package/src/open-mail.ts +203 -0
- package/src/read-inbox.ts +35 -12
- package/src/sign-in.ts +5 -1
- package/src/thread-token.ts +31 -0
- package/src/write-mail.ts +94 -0
- package/styled-system/tokens/index.mjs +7 -3
- package/styled-system/tokens/tokens.d.ts +2 -2
- package/styled-system/types/prop-type.d.ts +1 -1
package/README.md
CHANGED
|
@@ -30,12 +30,15 @@ export const Shell = runManganese({
|
|
|
30
30
|
|
|
31
31
|
- `client`: a Google Cloud OAuth client, Desktop app type:
|
|
32
32
|
1. Turn on the Gmail API in a Google Cloud project.
|
|
33
|
-
2. Give the OAuth consent screen the `gmail.metadata
|
|
33
|
+
2. Give the OAuth consent screen the `gmail.metadata`,
|
|
34
|
+
`gmail.settings.basic` and `gmail.compose` scopes, and publish it.
|
|
34
35
|
One in Testing expires sign-ins after 7 days.
|
|
35
36
|
3. Create an OAuth client of the Desktop app type. Google does not treat
|
|
36
37
|
its secret as secret.
|
|
37
38
|
- `email`: the Google account.
|
|
38
39
|
- `nickname`: its name on the bar.
|
|
40
|
+
- `profile`: the browser profile its Gmail window and sign-in open in, such
|
|
41
|
+
as `"work"`. Without one, Gmail's site decides.
|
|
39
42
|
|
|
40
43
|
What it shows, and how it reads the inbox:
|
|
41
44
|
[TOP-BAR.md](../shell-manganese/docs/TOP-BAR.md#gmail).
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@cprussin/option-result": "^2.0.1",
|
|
4
|
-
"@domicile-desktop/component-library": "2.
|
|
5
|
-
"@domicile-desktop/manganese-host": "2.0.
|
|
6
|
-
"@domicile-desktop/react": "0.
|
|
7
|
-
"@domicile-desktop/sdk": "
|
|
8
|
-
"@domicile-desktop/system-apps": "1.
|
|
9
|
-
"@pandacss/dev": "^1.12.
|
|
4
|
+
"@domicile-desktop/component-library": "2.2.0",
|
|
5
|
+
"@domicile-desktop/manganese-host": "2.0.3",
|
|
6
|
+
"@domicile-desktop/react": "0.2.0",
|
|
7
|
+
"@domicile-desktop/sdk": "3.0.0",
|
|
8
|
+
"@domicile-desktop/system-apps": "1.3.0",
|
|
9
|
+
"@pandacss/dev": "^1.12.2",
|
|
10
10
|
"@phosphor-icons/react": "^2.1.10",
|
|
11
|
-
"react": "^19.
|
|
12
|
-
"zod": "^4.
|
|
11
|
+
"react": "^19.3.1",
|
|
12
|
+
"zod": "^4.6.7"
|
|
13
13
|
},
|
|
14
14
|
"description": "A manganese bar item: one Gmail account's inbox count, read with the Gmail API, and notifications for new mail.",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@cprussin/tsconfig": "^5.0.0",
|
|
17
17
|
"@domicile-desktop/test-support": "0.0.2",
|
|
18
|
-
"@pandacss/preset-panda": "^1.12.
|
|
18
|
+
"@pandacss/preset-panda": "^1.12.2",
|
|
19
19
|
"@testing-library/react": "^16.3.3",
|
|
20
|
-
"@testing-library/user-event": "^14.6.
|
|
21
|
-
"@types/bun": "^1.4.
|
|
22
|
-
"@types/react": "^19.
|
|
23
|
-
"@types/react-dom": "^19.
|
|
24
|
-
"postcss": "^8.5.
|
|
20
|
+
"@testing-library/user-event": "^14.6.10",
|
|
21
|
+
"@types/bun": "^1.4.4",
|
|
22
|
+
"@types/react": "^19.3.0",
|
|
23
|
+
"@types/react-dom": "^19.3.0",
|
|
24
|
+
"postcss": "^8.5.32",
|
|
25
25
|
"typescript": "^7.0.2"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"./addresses": "./src/addresses.ts",
|
|
33
33
|
"./consent": "./src/consent.ts",
|
|
34
34
|
"./desk-inbox": "./src/desk-inbox.ts",
|
|
35
|
-
"./inbox": "./src/inbox.ts"
|
|
35
|
+
"./inbox": "./src/inbox.ts",
|
|
36
|
+
"./write-mail": "./src/write-mail.ts"
|
|
36
37
|
},
|
|
37
38
|
"files": [
|
|
38
39
|
"src/**",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"test:unit": "bun test"
|
|
58
59
|
},
|
|
59
60
|
"type": "module",
|
|
60
|
-
"version": "2.0
|
|
61
|
+
"version": "2.1.0"
|
|
61
62
|
}
|
package/src/addresses.ts
CHANGED
|
@@ -7,9 +7,44 @@ export const GMAIL_ORIGIN = "https://mail.google.com";
|
|
|
7
7
|
*/
|
|
8
8
|
export const gmailAppId = (email: string): string => `gmail:${email}`;
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The account's inbox in a browser window. In a browser profile of its own,
|
|
12
|
+
* the profile's Google sign-in is the account's, so the address names no
|
|
13
|
+
* account; otherwise it picks the account by its address.
|
|
14
|
+
*/
|
|
15
|
+
export const inboxAddress = (email: string, profile?: string): string =>
|
|
16
|
+
profile === undefined
|
|
17
|
+
? `${GMAIL_ORIGIN}/mail/?${asUser(email)}`
|
|
18
|
+
: `${GMAIL_ORIGIN}/mail/`;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The account's Gmail with a new message open over the inbox, filled in from
|
|
22
|
+
* the `mailto:` link `link`: its recipients, subject and body. Gmail's own
|
|
23
|
+
* handler for `mailto:` links, as a browser registers it.
|
|
24
|
+
*/
|
|
25
|
+
export const composeAddress = (
|
|
26
|
+
email: string,
|
|
27
|
+
link: string,
|
|
28
|
+
profile?: string,
|
|
29
|
+
): string =>
|
|
30
|
+
`${GMAIL_ORIGIN}/mail/?${new URLSearchParams([
|
|
31
|
+
...(profile === undefined ? [["authuser", email]] : []),
|
|
32
|
+
["extsrc", "mailto"],
|
|
33
|
+
["url", link],
|
|
34
|
+
]).toString()}`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The account's Gmail with draft `message` (its message id) open over the
|
|
38
|
+
* drafts list.
|
|
39
|
+
*/
|
|
40
|
+
export const draftAddress = (
|
|
41
|
+
email: string,
|
|
42
|
+
message: string,
|
|
43
|
+
profile?: string,
|
|
44
|
+
): string =>
|
|
45
|
+
`${inboxAddress(email, profile)}#drafts?${new URLSearchParams({
|
|
46
|
+
compose: message,
|
|
47
|
+
}).toString()}`;
|
|
13
48
|
|
|
14
49
|
/**
|
|
15
50
|
* Picks the signed-in account by its address. Gmail's `/mail/u/<n>/` takes an
|
package/src/bar-item.tsx
CHANGED
|
@@ -12,15 +12,20 @@ type Props = {
|
|
|
12
12
|
nickname: string;
|
|
13
13
|
/** The Google Cloud OAuth client (Desktop app) it signs in with. */
|
|
14
14
|
client: GoogleClient;
|
|
15
|
+
/**
|
|
16
|
+
* The id of the browser profile its Gmail window and sign-in open in, such
|
|
17
|
+
* as `work`. By default, the one Gmail's site opens in.
|
|
18
|
+
*/
|
|
19
|
+
profile?: string;
|
|
15
20
|
};
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* One Gmail account's inbox count, read with the Gmail API. A press opens
|
|
19
24
|
* the account's Gmail window, or brings it up. Not in the default bar.
|
|
20
25
|
*/
|
|
21
|
-
export const Gmail = ({ client, email, nickname }: Props) => {
|
|
26
|
+
export const Gmail = ({ client, email, nickname, profile }: Props) => {
|
|
22
27
|
const domicile = useDomicile();
|
|
23
|
-
const account = deskInbox(domicile)(email, client, nickname);
|
|
28
|
+
const account = deskInbox(domicile)(email, client, nickname, profile);
|
|
24
29
|
return (
|
|
25
30
|
<Account
|
|
26
31
|
email={email}
|
|
@@ -30,6 +35,7 @@ export const Gmail = ({ client, email, nickname }: Props) => {
|
|
|
30
35
|
domicile.browser.openApp(url, {
|
|
31
36
|
id: gmailAppId(email),
|
|
32
37
|
reuse: AppReuse.Focus,
|
|
38
|
+
...(profile === undefined ? {} : { profile }),
|
|
33
39
|
});
|
|
34
40
|
}}
|
|
35
41
|
onSignIn={account.signIn}
|
package/src/consent.ts
CHANGED
|
@@ -16,9 +16,15 @@ export const REDIRECT = "http://127.0.0.1:47823/";
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Read-only access to labels, which carry the inbox's counts, and to message
|
|
19
|
-
* headers, which name a new message's sender and subject. Never bodies.
|
|
19
|
+
* headers, which name a new message's sender and subject. Never bodies. The
|
|
20
|
+
* basic settings, which list the addresses the account sends from. And
|
|
21
|
+
* drafts, so an email link written from an alias starts as a draft from it.
|
|
20
22
|
*/
|
|
21
|
-
export const
|
|
23
|
+
export const SCOPES = [
|
|
24
|
+
"https://www.googleapis.com/auth/gmail.metadata",
|
|
25
|
+
"https://www.googleapis.com/auth/gmail.settings.basic",
|
|
26
|
+
"https://www.googleapis.com/auth/gmail.compose",
|
|
27
|
+
] as const;
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
30
|
* Google's consent page for `email`. It redirects to {@link REDIRECT} with
|
|
@@ -36,7 +42,7 @@ export const consentAddress = (
|
|
|
36
42
|
prompt: "consent",
|
|
37
43
|
redirect_uri: REDIRECT,
|
|
38
44
|
response_type: "code",
|
|
39
|
-
scope:
|
|
45
|
+
scope: SCOPES.join(" "),
|
|
40
46
|
state,
|
|
41
47
|
}).toString()}`;
|
|
42
48
|
|
package/src/desk-inbox.ts
CHANGED
|
@@ -42,11 +42,12 @@ export const deskInbox = perDesktop((domicile) => {
|
|
|
42
42
|
email: string,
|
|
43
43
|
client: GoogleClient,
|
|
44
44
|
nickname: string,
|
|
45
|
+
profile?: string,
|
|
45
46
|
): DeskAccount => {
|
|
46
47
|
const known = accounts.get(email);
|
|
47
48
|
if (known === undefined) {
|
|
48
|
-
const account = watchedAccount(domicile, email, client, (news) =>
|
|
49
|
-
notify({ email, nickname }, news),
|
|
49
|
+
const account = watchedAccount(domicile, email, client, profile, (news) =>
|
|
50
|
+
notify({ email, nickname, profile }, news),
|
|
50
51
|
);
|
|
51
52
|
accounts.set(email, account);
|
|
52
53
|
return account;
|
|
@@ -60,6 +61,7 @@ const watchedAccount = (
|
|
|
60
61
|
domicile: Domicile,
|
|
61
62
|
email: string,
|
|
62
63
|
client: GoogleClient,
|
|
64
|
+
profile: string | undefined,
|
|
63
65
|
onMail: (news: MailNews) => Promise<void>,
|
|
64
66
|
): DeskAccount => {
|
|
65
67
|
const read = inboxReader(domicile, client, email, onMail);
|
|
@@ -84,7 +86,7 @@ const watchedAccount = (
|
|
|
84
86
|
throw new Error(`no bar shows ${email} to sign in from`);
|
|
85
87
|
} else {
|
|
86
88
|
running.watch.answer(
|
|
87
|
-
signIn(domicile, client, email).then(() => read()),
|
|
89
|
+
signIn(domicile, client, email, profile).then(() => read()),
|
|
88
90
|
);
|
|
89
91
|
}
|
|
90
92
|
},
|
package/src/gmail-api.ts
CHANGED
|
@@ -8,6 +8,13 @@ import { jsonText } from "./json-text";
|
|
|
8
8
|
/** The Gmail API's messages for the signed-in account. */
|
|
9
9
|
const MESSAGES = "https://gmail.googleapis.com/gmail/v1/users/me/messages";
|
|
10
10
|
|
|
11
|
+
/** The Gmail API's drafts of the signed-in account. */
|
|
12
|
+
const DRAFTS = "https://gmail.googleapis.com/gmail/v1/users/me/drafts";
|
|
13
|
+
|
|
14
|
+
/** The Gmail API's addresses the account sends from. */
|
|
15
|
+
const SEND_AS =
|
|
16
|
+
"https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs";
|
|
17
|
+
|
|
11
18
|
/** The Gmail API's inbox label, which carries its counts. */
|
|
12
19
|
const INBOX = "https://gmail.googleapis.com/gmail/v1/users/me/labels/INBOX";
|
|
13
20
|
|
|
@@ -60,6 +67,29 @@ export const unreadMail = (
|
|
|
60
67
|
): Promise<Result<Unread[], string>> =>
|
|
61
68
|
ask(domicile, accessToken, UNREAD, unreadSchema);
|
|
62
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Asks the Gmail API for the addresses the account sends from: its own,
|
|
72
|
+
* then the aliases it verified, in Gmail's order.
|
|
73
|
+
*/
|
|
74
|
+
export const sendAsAddresses = (
|
|
75
|
+
domicile: Fetch,
|
|
76
|
+
accessToken: string,
|
|
77
|
+
): Promise<Result<string[], string>> =>
|
|
78
|
+
ask(domicile, accessToken, SEND_AS, sendAsSchema);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Saves the RFC 5322 message `message` as a new draft. Resolves the draft's
|
|
82
|
+
* message id: Gmail's hex number, which its web app opens the draft by.
|
|
83
|
+
*/
|
|
84
|
+
export const createDraft = (
|
|
85
|
+
domicile: Fetch,
|
|
86
|
+
accessToken: string,
|
|
87
|
+
message: string,
|
|
88
|
+
): Promise<Result<string, string>> =>
|
|
89
|
+
ask(domicile, accessToken, DRAFTS, draftSchema, {
|
|
90
|
+
message: { raw: base64Url(new TextEncoder().encode(message)) },
|
|
91
|
+
});
|
|
92
|
+
|
|
63
93
|
/** Asks the Gmail API for message `id`'s sender, subject and arrival. */
|
|
64
94
|
export const mailHeaders = (
|
|
65
95
|
domicile: Fetch,
|
|
@@ -77,15 +107,25 @@ export const mailHeaders = (
|
|
|
77
107
|
headersSchema,
|
|
78
108
|
);
|
|
79
109
|
|
|
80
|
-
|
|
110
|
+
/** GETs `url`, or POSTs `posted` as JSON to it, and reads the answer. */
|
|
111
|
+
const ask = <T extends {}>(
|
|
81
112
|
domicile: Fetch,
|
|
82
113
|
accessToken: string,
|
|
83
114
|
url: string,
|
|
84
115
|
schema: z.ZodType<T, string>,
|
|
116
|
+
posted?: object,
|
|
85
117
|
): Promise<Result<T, string>> =>
|
|
86
118
|
domicile.browser
|
|
87
119
|
.fetch(url, {
|
|
88
|
-
headers: [
|
|
120
|
+
headers: [
|
|
121
|
+
{ name: "Authorization", value: `Bearer ${accessToken}` },
|
|
122
|
+
...(posted === undefined
|
|
123
|
+
? []
|
|
124
|
+
: [{ name: "Content-Type", value: "application/json" }]),
|
|
125
|
+
],
|
|
126
|
+
...(posted === undefined
|
|
127
|
+
? {}
|
|
128
|
+
: { body: JSON.stringify(posted), method: "POST" as const }),
|
|
89
129
|
})
|
|
90
130
|
.then(
|
|
91
131
|
(answer): Result<T, string> => {
|
|
@@ -129,6 +169,50 @@ const unreadSchema = jsonText.pipe(
|
|
|
129
169
|
),
|
|
130
170
|
);
|
|
131
171
|
|
|
172
|
+
const draftSchema = jsonText.pipe(
|
|
173
|
+
z
|
|
174
|
+
.object({ message: z.object({ id: z.string().regex(/^[0-9a-f]+$/) }) })
|
|
175
|
+
.transform(({ message }) => message.id),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
/** `bytes` in base64url, as the Gmail API takes a raw message. */
|
|
179
|
+
const base64Url = (bytes: Uint8Array): string =>
|
|
180
|
+
btoa(Array.from(bytes, (byte) => String.fromCodePoint(byte)).join(""))
|
|
181
|
+
.replaceAll("+", "-")
|
|
182
|
+
.replaceAll("/", "_");
|
|
183
|
+
|
|
184
|
+
// An alias Gmail has not verified cannot send yet. The primary address has
|
|
185
|
+
// no verification status.
|
|
186
|
+
const sendAsSchema = jsonText.pipe(
|
|
187
|
+
z
|
|
188
|
+
.object({
|
|
189
|
+
sendAs: z.array(
|
|
190
|
+
z.object({
|
|
191
|
+
isPrimary: z.boolean().optional(),
|
|
192
|
+
sendAsEmail: z.string(),
|
|
193
|
+
verificationStatus: z.string().optional(),
|
|
194
|
+
}),
|
|
195
|
+
),
|
|
196
|
+
})
|
|
197
|
+
.transform(({ sendAs }) => [
|
|
198
|
+
...sendAs
|
|
199
|
+
.filter(({ isPrimary }) => isPrimary === true)
|
|
200
|
+
.map(({ sendAsEmail }) => sendAsEmail),
|
|
201
|
+
...sendAs
|
|
202
|
+
.filter(
|
|
203
|
+
({ isPrimary, verificationStatus }) =>
|
|
204
|
+
isPrimary !== true && verificationStatus === "accepted",
|
|
205
|
+
)
|
|
206
|
+
.map(({ sendAsEmail }) => sendAsEmail),
|
|
207
|
+
]),
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A thread's id: Gmail's hex number, which a press names the thread's row and
|
|
212
|
+
* link by.
|
|
213
|
+
*/
|
|
214
|
+
const threadIdSchema = z.string().regex(/^[0-9a-f]+$/);
|
|
215
|
+
|
|
132
216
|
const headersSchema = jsonText.pipe(
|
|
133
217
|
z
|
|
134
218
|
.object({
|
|
@@ -138,7 +222,7 @@ const headersSchema = jsonText.pipe(
|
|
|
138
222
|
payload: z.object({
|
|
139
223
|
headers: z.array(z.object({ name: z.string(), value: z.string() })),
|
|
140
224
|
}),
|
|
141
|
-
threadId:
|
|
225
|
+
threadId: threadIdSchema,
|
|
142
226
|
})
|
|
143
227
|
.transform(({ id, internalDate, payload, threadId }) => {
|
|
144
228
|
const header = (name: string) =>
|
package/src/google-token.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
9
|
import type { GoogleClient } from "./consent";
|
|
10
|
-
import { REDIRECT,
|
|
10
|
+
import { REDIRECT, SCOPES } from "./consent";
|
|
11
11
|
import { jsonText } from "./json-text";
|
|
12
12
|
|
|
13
13
|
/** Google's OAuth token endpoint. */
|
|
@@ -50,7 +50,7 @@ export const TokenRefusal = {
|
|
|
50
50
|
}),
|
|
51
51
|
/**
|
|
52
52
|
* Google no longer takes the refresh token, or it was granted without
|
|
53
|
-
* {@link
|
|
53
|
+
* every one of {@link SCOPES}: sign in again.
|
|
54
54
|
*/
|
|
55
55
|
Revoked: () => ({ kind: TokenRefusalKind.Revoked as const }),
|
|
56
56
|
};
|
|
@@ -82,7 +82,7 @@ export const refreshAccess = async (
|
|
|
82
82
|
return parsed(answer, accessSchema)
|
|
83
83
|
.mapErr((why): TokenRefusal => TokenRefusal.Failed(why))
|
|
84
84
|
.andThen((fields) =>
|
|
85
|
-
fields.scope.split(" ").includes(
|
|
85
|
+
SCOPES.every((scope) => fields.scope.split(" ").includes(scope))
|
|
86
86
|
? Ok({
|
|
87
87
|
expiresInMs: fields.expires_in * 1000,
|
|
88
88
|
token: fields.access_token,
|
package/src/held-google.ts
CHANGED
|
@@ -22,6 +22,11 @@ export const INBOX =
|
|
|
22
22
|
export const UNREAD =
|
|
23
23
|
"https://gmail.googleapis.com/gmail/v1/users/me/messages?labelIds=INBOX&labelIds=UNREAD&maxResults=100";
|
|
24
24
|
|
|
25
|
+
export const DRAFTS = "https://gmail.googleapis.com/gmail/v1/users/me/drafts";
|
|
26
|
+
|
|
27
|
+
export const SEND_AS =
|
|
28
|
+
"https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs";
|
|
29
|
+
|
|
25
30
|
/** The address of message `id`'s sender and subject. */
|
|
26
31
|
export const HEADERS = (id: string) =>
|
|
27
32
|
`https://gmail.googleapis.com/gmail/v1/users/me/messages/${id}?format=metadata&metadataHeaders=From&metadataHeaders=Subject`;
|
package/src/inbox.ts
CHANGED
|
@@ -10,9 +10,16 @@ export enum InboxKind {
|
|
|
10
10
|
export const Inbox = {
|
|
11
11
|
/**
|
|
12
12
|
* Every conversation, and the unread ones, with the newest message of each
|
|
13
|
-
* of the newest unread conversations
|
|
13
|
+
* of the newest unread conversations, and the addresses the account sends
|
|
14
|
+
* from: its own, then its aliases.
|
|
14
15
|
*/
|
|
15
|
-
Counted: (
|
|
16
|
+
Counted: (
|
|
17
|
+
total: number,
|
|
18
|
+
unread: number,
|
|
19
|
+
latest: readonly Mail[] = [],
|
|
20
|
+
addresses: readonly string[] = [],
|
|
21
|
+
) => ({
|
|
22
|
+
addresses,
|
|
16
23
|
kind: InboxKind.Counted as const,
|
|
17
24
|
latest,
|
|
18
25
|
total,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** What a `mailto:` link fills a new message in with (RFC 6068). */
|
|
2
|
+
export type MailLink = {
|
|
3
|
+
to: readonly string[];
|
|
4
|
+
cc: readonly string[];
|
|
5
|
+
bcc: readonly string[];
|
|
6
|
+
subject: string;
|
|
7
|
+
body: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The recipients, subject and body of the `mailto:` link `link`. A `+` is
|
|
12
|
+
* itself, not a space, as in a link and unlike a form. Fields other than
|
|
13
|
+
* these, and a second subject or body, are left out.
|
|
14
|
+
*/
|
|
15
|
+
export const mailLink = (link: string): MailLink => {
|
|
16
|
+
const [path = "", query = ""] = link
|
|
17
|
+
.replace(/^mailto:/i, "")
|
|
18
|
+
.split(/\?(.*)/s);
|
|
19
|
+
const fields = query
|
|
20
|
+
.split("&")
|
|
21
|
+
.filter((field) => field !== "")
|
|
22
|
+
.map((field) => {
|
|
23
|
+
const [name = "", value = ""] = field.split(/=(.*)/s);
|
|
24
|
+
return [decode(name).toLowerCase(), decode(value)] as const;
|
|
25
|
+
});
|
|
26
|
+
const all = (name: string) =>
|
|
27
|
+
fields
|
|
28
|
+
.filter(([field]) => field === name)
|
|
29
|
+
.flatMap(([, value]) => addresses(value));
|
|
30
|
+
const first = (name: string) =>
|
|
31
|
+
fields.find(([field]) => field === name)?.[1] ?? "";
|
|
32
|
+
return {
|
|
33
|
+
bcc: all("bcc"),
|
|
34
|
+
body: first("body"),
|
|
35
|
+
cc: all("cc"),
|
|
36
|
+
subject: first("subject"),
|
|
37
|
+
to: [...addresses(decode(path)), ...all("to")],
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An RFC 5322 message from `from`, filled in from `link`: plain text, UTF-8,
|
|
43
|
+
* with lines ending in CRLF.
|
|
44
|
+
*/
|
|
45
|
+
export const draftMessage = (from: string, link: MailLink): string =>
|
|
46
|
+
[
|
|
47
|
+
`From: ${from}`,
|
|
48
|
+
...header("To", link.to.join(", ")),
|
|
49
|
+
...header("Cc", link.cc.join(", ")),
|
|
50
|
+
...header("Bcc", link.bcc.join(", ")),
|
|
51
|
+
...header("Subject", encodedWords(link.subject)),
|
|
52
|
+
"MIME-Version: 1.0",
|
|
53
|
+
'Content-Type: text/plain; charset="UTF-8"',
|
|
54
|
+
"Content-Transfer-Encoding: base64",
|
|
55
|
+
"",
|
|
56
|
+
lines(base64(new TextEncoder().encode(crlf(link.body)))),
|
|
57
|
+
].join("\r\n");
|
|
58
|
+
|
|
59
|
+
/** Header `name`, unless its `value` is empty. */
|
|
60
|
+
const header = (name: string, value: string): string[] =>
|
|
61
|
+
value === "" ? [] : [`${name}: ${value}`];
|
|
62
|
+
|
|
63
|
+
/** A field's addresses, comma-separated. */
|
|
64
|
+
const addresses = (value: string): string[] =>
|
|
65
|
+
value
|
|
66
|
+
.split(",")
|
|
67
|
+
.map((address) => address.trim())
|
|
68
|
+
.filter((address) => address !== "");
|
|
69
|
+
|
|
70
|
+
/** `text` with its percent escapes undone; a broken escape stays as it is. */
|
|
71
|
+
const decode = (text: string): string => {
|
|
72
|
+
try {
|
|
73
|
+
return decodeURIComponent(text);
|
|
74
|
+
} catch {
|
|
75
|
+
return text;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** `text` as an RFC 2047 encoded word when it isn't plain ASCII. */
|
|
80
|
+
const encodedWords = (text: string): string =>
|
|
81
|
+
/^[\x20-\x7e]*$/.test(text)
|
|
82
|
+
? text
|
|
83
|
+
: `=?UTF-8?B?${base64(new TextEncoder().encode(text))}?=`;
|
|
84
|
+
|
|
85
|
+
/** `text` with every line ending as CRLF. */
|
|
86
|
+
const crlf = (text: string): string => text.replace(/\r?\n/g, "\r\n");
|
|
87
|
+
|
|
88
|
+
/** `bytes` in base64. */
|
|
89
|
+
const base64 = (bytes: Uint8Array): string =>
|
|
90
|
+
btoa(Array.from(bytes, (byte) => String.fromCodePoint(byte)).join(""));
|
|
91
|
+
|
|
92
|
+
/** Base64 `text` in lines of 76, as MIME wants. */
|
|
93
|
+
const lines = (text: string): string =>
|
|
94
|
+
text.match(/.{1,76}/g)?.join("\r\n") ?? "";
|
package/src/mail-notices.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// New mail as desktop notifications, sent to the notification server the
|
|
2
2
|
// compositor runs. See docs/architecture/NOTIFICATIONS.md.
|
|
3
3
|
|
|
4
|
-
import type { Browser } from "@domicile-desktop/sdk/desktop/browser";
|
|
5
|
-
import { AppReuse } from "@domicile-desktop/sdk/desktop/browser";
|
|
6
4
|
import type { Dbus } from "@domicile-desktop/sdk/desktop/dbus";
|
|
7
5
|
import type {
|
|
8
6
|
DbusSignal,
|
|
@@ -13,8 +11,10 @@ import { Bus, ListenedKind } from "@domicile-desktop/sdk/system";
|
|
|
13
11
|
import type { Favicons } from "@domicile-desktop/system-apps/favicons";
|
|
14
12
|
import { z } from "zod";
|
|
15
13
|
|
|
16
|
-
import {
|
|
14
|
+
import { inboxAddress } from "./addresses";
|
|
17
15
|
import type { Mail, MailNews } from "./gmail-api";
|
|
16
|
+
import type { MailBrowser } from "./open-mail";
|
|
17
|
+
import { openMail } from "./open-mail";
|
|
18
18
|
|
|
19
19
|
/** The notification server's address on the session bus. */
|
|
20
20
|
const SERVER = {
|
|
@@ -33,11 +33,19 @@ const MOST_NAMED = 3;
|
|
|
33
33
|
/** What notifies: the bus, and the browser a press opens Gmail in. */
|
|
34
34
|
export type NoticeDesk = {
|
|
35
35
|
readonly dbus: Pick<Dbus, "call" | "match">;
|
|
36
|
-
readonly browser:
|
|
36
|
+
readonly browser: MailBrowser;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
/** The account mail arrived for. */
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* An account whose mail is notified, and the browser profile its Gmail
|
|
42
|
+
* window opens in: its site's, as the engine routes it, when `undefined`.
|
|
43
|
+
*/
|
|
44
|
+
export type MailAccount = {
|
|
45
|
+
email: string;
|
|
46
|
+
nickname: string;
|
|
47
|
+
profile?: string | undefined;
|
|
48
|
+
};
|
|
41
49
|
|
|
42
50
|
/**
|
|
43
51
|
* Notifies the desk of mail that arrived, under the account's nickname: a
|
|
@@ -48,7 +56,11 @@ export type MailAccount = { email: string; nickname: string };
|
|
|
48
56
|
* is. A notification closes once all its messages are read. Rejects when the
|
|
49
57
|
* server refuses.
|
|
50
58
|
*/
|
|
51
|
-
export const mailNotices = (
|
|
59
|
+
export const mailNotices = (
|
|
60
|
+
desk: NoticeDesk,
|
|
61
|
+
icons: Favicons,
|
|
62
|
+
open: typeof openMail = openMail,
|
|
63
|
+
) => {
|
|
52
64
|
// Each notification still up, by id.
|
|
53
65
|
const shown = new Map<number, Shown>();
|
|
54
66
|
const presses: { listening: Promise<void> | undefined } = {
|
|
@@ -58,7 +70,7 @@ export const mailNotices = (desk: NoticeDesk, icons: Favicons) => {
|
|
|
58
70
|
account: MailAccount,
|
|
59
71
|
{ arrived, read }: MailNews,
|
|
60
72
|
): Promise<void> => {
|
|
61
|
-
presses.listening ??= listen(desk, shown);
|
|
73
|
+
presses.listening ??= listen(desk, shown, open);
|
|
62
74
|
await presses.listening;
|
|
63
75
|
const site = inboxAddress(account.email);
|
|
64
76
|
if (arrived.length > 0) {
|
|
@@ -66,11 +78,12 @@ export const mailNotices = (desk: NoticeDesk, icons: Favicons) => {
|
|
|
66
78
|
}
|
|
67
79
|
// The theme's Gmail icon until the site's is found.
|
|
68
80
|
const picture = icons.icon(site).unwrapOr("gmail");
|
|
69
|
-
for (const notice of notices(
|
|
81
|
+
for (const notice of notices(arrived)) {
|
|
70
82
|
const id = await notify(desk, account.nickname, picture, notice);
|
|
71
83
|
shown.set(id, {
|
|
72
84
|
email: account.email,
|
|
73
|
-
|
|
85
|
+
profile: account.profile,
|
|
86
|
+
thread: notice.thread,
|
|
74
87
|
unread: notice.messages,
|
|
75
88
|
});
|
|
76
89
|
}
|
|
@@ -87,35 +100,42 @@ export const mailNotices = (desk: NoticeDesk, icons: Favicons) => {
|
|
|
87
100
|
};
|
|
88
101
|
|
|
89
102
|
/**
|
|
90
|
-
* One notification still up: its account,
|
|
91
|
-
* messages.
|
|
103
|
+
* One notification still up: its account, the thread a press opens, and its
|
|
104
|
+
* unread messages.
|
|
92
105
|
*/
|
|
93
|
-
type Shown = {
|
|
106
|
+
type Shown = {
|
|
107
|
+
email: string;
|
|
108
|
+
profile: string | undefined;
|
|
109
|
+
/** The thread a press opens; the inbox for `undefined`. */
|
|
110
|
+
thread: string | undefined;
|
|
111
|
+
unread: readonly string[];
|
|
112
|
+
};
|
|
94
113
|
|
|
95
114
|
type Notice = {
|
|
96
115
|
summary: string;
|
|
97
116
|
body: string;
|
|
98
|
-
opens
|
|
117
|
+
/** The thread a press opens, by its hex id; the inbox for `undefined`. */
|
|
118
|
+
thread: string | undefined;
|
|
99
119
|
/** The ids of the messages it tells of. */
|
|
100
120
|
messages: readonly string[];
|
|
101
121
|
};
|
|
102
122
|
|
|
103
123
|
/** `mail`'s notifications, oldest first, so the newest shows on top. */
|
|
104
|
-
const notices = (
|
|
124
|
+
const notices = (mail: readonly Mail[]): Notice[] =>
|
|
105
125
|
mail.length > MOST_APART
|
|
106
126
|
? [
|
|
107
127
|
{
|
|
108
128
|
body: senders(mail),
|
|
109
129
|
messages: mail.map(({ id }) => id),
|
|
110
|
-
opens: inboxAddress(email),
|
|
111
130
|
summary: `${mail.length.toString()} new emails`,
|
|
131
|
+
thread: undefined,
|
|
112
132
|
},
|
|
113
133
|
]
|
|
114
134
|
: mail.toReversed().map(({ from, id, subject, threadId }) => ({
|
|
115
135
|
body: subject,
|
|
116
136
|
messages: [id],
|
|
117
|
-
opens: `${inboxAddress(email)}#inbox/${threadId}`,
|
|
118
137
|
summary: from,
|
|
138
|
+
thread: threadId,
|
|
119
139
|
}));
|
|
120
140
|
|
|
121
141
|
/** Who sent `mail`, each once, newest first. */
|
|
@@ -181,12 +201,13 @@ const close = async (desk: NoticeDesk, id: number): Promise<void> =>
|
|
|
181
201
|
});
|
|
182
202
|
|
|
183
203
|
/**
|
|
184
|
-
* Opens each press of one of `shown` from now on
|
|
185
|
-
* rejects when the bus refuses.
|
|
204
|
+
* Opens each press of one of `shown` from now on with `open`. Resolves once
|
|
205
|
+
* listening, or rejects when the bus refuses.
|
|
186
206
|
*/
|
|
187
207
|
const listen = async (
|
|
188
208
|
desk: NoticeDesk,
|
|
189
209
|
shown: Map<number, Shown>,
|
|
210
|
+
open: typeof openMail,
|
|
190
211
|
): Promise<void> =>
|
|
191
212
|
(
|
|
192
213
|
await desk.dbus.match({
|
|
@@ -200,7 +221,7 @@ const listen = async (
|
|
|
200
221
|
throw new Error(`could not hear presses of mail: ${error.message}`);
|
|
201
222
|
},
|
|
202
223
|
Ok: (listening) => {
|
|
203
|
-
follow(desk, shown, listening).catch((error: unknown) => {
|
|
224
|
+
follow(desk, shown, listening, open).catch((error: unknown) => {
|
|
204
225
|
// biome-ignore lint/suspicious/noConsole: a broken listener leaves presses unanswered, with nothing else to tell
|
|
205
226
|
console.error("Stopped hearing presses of mail", error);
|
|
206
227
|
});
|
|
@@ -211,7 +232,10 @@ const follow = async (
|
|
|
211
232
|
desk: NoticeDesk,
|
|
212
233
|
shown: Map<number, Shown>,
|
|
213
234
|
listening: Listening<Listened<DbusSignal>>,
|
|
235
|
+
open: typeof openMail,
|
|
214
236
|
): Promise<void> => {
|
|
237
|
+
// Each account's press still waiting for Gmail to start, as its stop.
|
|
238
|
+
const waiting = new Map<string, () => void>();
|
|
215
239
|
const reader = listening.items.getReader();
|
|
216
240
|
for (let next = await reader.read(); !next.done; next = await reader.read()) {
|
|
217
241
|
switch (next.value.kind) {
|
|
@@ -221,10 +245,11 @@ const follow = async (
|
|
|
221
245
|
const pressed = shown.get(id);
|
|
222
246
|
if (pressed !== undefined) {
|
|
223
247
|
shown.delete(id);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
248
|
+
waiting.get(pressed.email)?.();
|
|
249
|
+
waiting.set(
|
|
250
|
+
pressed.email,
|
|
251
|
+
open(desk.browser, pressed.email, pressed.thread, pressed.profile),
|
|
252
|
+
);
|
|
228
253
|
}
|
|
229
254
|
break;
|
|
230
255
|
}
|
package/src/open-mail.ts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { Browser } from "@domicile-desktop/sdk/desktop/browser";
|
|
2
|
+
import { AppReuse } from "@domicile-desktop/sdk/desktop/browser";
|
|
3
|
+
|
|
4
|
+
import { GMAIL_ORIGIN, gmailAppId, inboxAddress } from "./addresses";
|
|
5
|
+
import { threadToken } from "./thread-token";
|
|
6
|
+
|
|
7
|
+
/** The path of an account's mail page. */
|
|
8
|
+
const MAIL_PATH = /^\/mail\/u\/\d+\/$/;
|
|
9
|
+
|
|
10
|
+
/** The hash of Gmail's inbox. */
|
|
11
|
+
const INBOX = "#inbox";
|
|
12
|
+
|
|
13
|
+
/** How often a press looks for its mail's row in the inbox. */
|
|
14
|
+
const LOOK_MS = 500;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* How long a press looks for its mail's row before opening the mail on its
|
|
18
|
+
* own. Gmail shows its offline copy of the list first, and the new mail joins
|
|
19
|
+
* it once Gmail has synced.
|
|
20
|
+
*/
|
|
21
|
+
const WAIT_MS = 20_000;
|
|
22
|
+
|
|
23
|
+
/** The browser {@link openMail} opens Gmail in. */
|
|
24
|
+
export type MailBrowser = Pick<
|
|
25
|
+
Browser,
|
|
26
|
+
"clickMatch" | "on" | "openApp" | "windows"
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Shows the inbox in the account's Gmail window, then, given a `thread` (the
|
|
31
|
+
* Gmail API's hex id), clicks that mail's row in it, as the user would. With
|
|
32
|
+
* Gmail's reading pane on, that shows the mail beside the list: Gmail keeps
|
|
33
|
+
* the address at `#inbox` then, so no address opens that view. It changes
|
|
34
|
+
* only the hash of a running Gmail mail page; loading an address afresh would
|
|
35
|
+
* load all of Gmail again. With no such page open, it loads the inbox first.
|
|
36
|
+
*
|
|
37
|
+
* It looks for the row until it shows, as Gmail brings its list up to date,
|
|
38
|
+
* and stops if the window leaves the inbox or closes. A row that never shows,
|
|
39
|
+
* as for a mail in another tab, opens the mail on its own after
|
|
40
|
+
* {@link WAIT_MS}, saying why with `warn`. Returns a function that stops it.
|
|
41
|
+
* A new window is in browser profile `profile`, or its site's when
|
|
42
|
+
* `undefined`.
|
|
43
|
+
*/
|
|
44
|
+
export const openMail = (
|
|
45
|
+
browser: MailBrowser,
|
|
46
|
+
email: string,
|
|
47
|
+
thread: string | undefined,
|
|
48
|
+
profile?: string,
|
|
49
|
+
// biome-ignore lint/suspicious/noConsole: a fallback the user sees but cannot tell why
|
|
50
|
+
warn: (message: string) => void = console.warn,
|
|
51
|
+
): (() => void) => {
|
|
52
|
+
const id = gmailAppId(email);
|
|
53
|
+
const inProfile = profile === undefined ? {} : { profile };
|
|
54
|
+
const goTo = (started: URL, hash: string) => {
|
|
55
|
+
started.hash = hash;
|
|
56
|
+
browser.openApp(started.href, {
|
|
57
|
+
id,
|
|
58
|
+
reuse: AppReuse.Navigate,
|
|
59
|
+
...inProfile,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const show = (started: URL): (() => void) => {
|
|
63
|
+
if (started.hash !== INBOX) {
|
|
64
|
+
goTo(new URL(started), INBOX);
|
|
65
|
+
}
|
|
66
|
+
return thread === undefined
|
|
67
|
+
? () => undefined
|
|
68
|
+
: clickRow(browser, id, thread, warn, () => {
|
|
69
|
+
goTo(started, `${INBOX}/${threadToken(thread)}`);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const open = listed(browser, id);
|
|
73
|
+
const started = open === undefined ? undefined : startedAt(open.url);
|
|
74
|
+
if (started === undefined) {
|
|
75
|
+
browser.openApp(inboxAddress(email, profile), {
|
|
76
|
+
id,
|
|
77
|
+
reuse: AppReuse.Navigate,
|
|
78
|
+
...inProfile,
|
|
79
|
+
});
|
|
80
|
+
return whenStarted(browser, id, show);
|
|
81
|
+
} else {
|
|
82
|
+
return show(started);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Clicks thread `thread`'s row in window `id`'s inbox once Gmail lists it.
|
|
88
|
+
* Calls `alone` if it never does in {@link WAIT_MS}. Gives up when the window
|
|
89
|
+
* closes, or leaves the inbox after reaching it. Says what went wrong with
|
|
90
|
+
* `warn`. Returns a function that stops it.
|
|
91
|
+
*/
|
|
92
|
+
const clickRow = (
|
|
93
|
+
browser: MailBrowser,
|
|
94
|
+
id: string,
|
|
95
|
+
thread: string,
|
|
96
|
+
warn: (message: string) => void,
|
|
97
|
+
alone: () => void,
|
|
98
|
+
): (() => void) => {
|
|
99
|
+
const row = `tr [data-legacy-thread-id="${thread}"]`;
|
|
100
|
+
const state = { arrived: false, asking: false, warned: false };
|
|
101
|
+
const stop = () => {
|
|
102
|
+
clearInterval(looking);
|
|
103
|
+
clearTimeout(deadline);
|
|
104
|
+
};
|
|
105
|
+
const look = () => {
|
|
106
|
+
const window = listed(browser, id);
|
|
107
|
+
const at = window === undefined ? undefined : URL.parse(window.url)?.hash;
|
|
108
|
+
if (window === undefined || (state.arrived && at !== INBOX)) {
|
|
109
|
+
// Closed, or the user went elsewhere: a click now would take them back.
|
|
110
|
+
stop();
|
|
111
|
+
} else if (at === INBOX && !state.asking) {
|
|
112
|
+
state.arrived = true;
|
|
113
|
+
state.asking = true;
|
|
114
|
+
browser.clickMatch(window.id, row).then(
|
|
115
|
+
(clicked) => {
|
|
116
|
+
state.asking = false;
|
|
117
|
+
if (clicked) {
|
|
118
|
+
stop();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
(error: unknown) => {
|
|
122
|
+
state.asking = false;
|
|
123
|
+
// The page left as it was asked, or the window closed. The next
|
|
124
|
+
// look asks again, or sees where it went and stops. Said once, as
|
|
125
|
+
// each look would say it again.
|
|
126
|
+
if (!state.warned) {
|
|
127
|
+
state.warned = true;
|
|
128
|
+
warn(`Gmail's window gave no answer to a click: ${String(error)}`);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const looking = setInterval(look, LOOK_MS);
|
|
135
|
+
const deadline = setTimeout(() => {
|
|
136
|
+
stop();
|
|
137
|
+
// A closed window has nothing to open the mail in; opening it would open
|
|
138
|
+
// a new one the user closed.
|
|
139
|
+
if (listed(browser, id) !== undefined) {
|
|
140
|
+
warn(
|
|
141
|
+
`Gmail never listed thread ${thread} in its inbox; opening it alone`,
|
|
142
|
+
);
|
|
143
|
+
alone();
|
|
144
|
+
}
|
|
145
|
+
}, WAIT_MS);
|
|
146
|
+
look();
|
|
147
|
+
return stop;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Calls `then` with the address of window `id`'s page once Gmail has started
|
|
152
|
+
* in it. Gives up when the window closes after it was listed. Returns a
|
|
153
|
+
* function that stops the wait, and whatever `then` started.
|
|
154
|
+
*/
|
|
155
|
+
const whenStarted = (
|
|
156
|
+
browser: MailBrowser,
|
|
157
|
+
id: string,
|
|
158
|
+
then: (started: URL) => () => void,
|
|
159
|
+
): (() => void) => {
|
|
160
|
+
const watch: { seen: boolean; stopThen: () => void } = {
|
|
161
|
+
seen: listed(browser, id) !== undefined,
|
|
162
|
+
stopThen: () => undefined,
|
|
163
|
+
};
|
|
164
|
+
const stop = browser.on("change", () => {
|
|
165
|
+
const window = listed(browser, id);
|
|
166
|
+
if (window === undefined) {
|
|
167
|
+
// Closed before Gmail started: nothing is left to show it in.
|
|
168
|
+
if (watch.seen) {
|
|
169
|
+
stop();
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
watch.seen = true;
|
|
173
|
+
const started = startedAt(window.url);
|
|
174
|
+
if (started !== undefined) {
|
|
175
|
+
stop();
|
|
176
|
+
watch.stopThen = then(started);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return () => {
|
|
181
|
+
stop();
|
|
182
|
+
watch.stopThen();
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The Gmail mail page's address once Gmail has started: it sets a hash, such
|
|
188
|
+
* as `#inbox`, when its app is running. `undefined` before then, such as on
|
|
189
|
+
* the sign-in page or the redirect to `/mail/u/<n>/`, and on Gmail's other
|
|
190
|
+
* apps, such as Chat at `/chat/u/<n>/`.
|
|
191
|
+
*/
|
|
192
|
+
const startedAt = (url: string): URL | undefined => {
|
|
193
|
+
const parsed = URL.parse(url);
|
|
194
|
+
return parsed?.origin === GMAIL_ORIGIN &&
|
|
195
|
+
MAIL_PATH.test(parsed.pathname) &&
|
|
196
|
+
parsed.hash !== ""
|
|
197
|
+
? parsed
|
|
198
|
+
: undefined;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** Window `id`, once the browser lists it. */
|
|
202
|
+
const listed = (browser: MailBrowser, id: string) =>
|
|
203
|
+
browser.windows?.find(({ appId }) => appId === id);
|
package/src/read-inbox.ts
CHANGED
|
@@ -2,7 +2,12 @@ import { Result } from "@cprussin/option-result";
|
|
|
2
2
|
|
|
3
3
|
import type { GoogleClient } from "./consent";
|
|
4
4
|
import type { Counts, Mail, MailNews, Unread } from "./gmail-api";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
inboxCounts,
|
|
7
|
+
mailHeaders,
|
|
8
|
+
sendAsAddresses,
|
|
9
|
+
unreadMail,
|
|
10
|
+
} from "./gmail-api";
|
|
6
11
|
import type { Fetch, TokenRefusal } from "./google-token";
|
|
7
12
|
import { refreshAccess, TokenRefusalKind } from "./google-token";
|
|
8
13
|
import { Inbox } from "./inbox";
|
|
@@ -11,7 +16,11 @@ import { forgetToken, storedToken } from "./stored-token";
|
|
|
11
16
|
/** How many of the newest unread conversations a reading names. */
|
|
12
17
|
const LATEST = 8;
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
/**
|
|
20
|
+
* An access token, and the addresses the account sends from, read once per
|
|
21
|
+
* token: they change only in Gmail's settings.
|
|
22
|
+
*/
|
|
23
|
+
type Held = { token: string; expiresAt: number; addresses: readonly string[] };
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* Reads the account's inbox through the Gmail API, each call one read.
|
|
@@ -20,6 +29,8 @@ type Held = { token: string; expiresAt: number };
|
|
|
20
29
|
* (which is then forgotten), it is signed out.
|
|
21
30
|
* - The refresh token gets an access token, kept until it expires or Gmail
|
|
22
31
|
* refuses it.
|
|
32
|
+
* - Each read names the addresses the account sends from, asked for once
|
|
33
|
+
* per access token.
|
|
23
34
|
* - Each read names the newest message of each of the {@link LATEST} newest
|
|
24
35
|
* unread conversations. A message's headers are asked for once.
|
|
25
36
|
* - Each read passes `onMail` the unread messages that arrived since the
|
|
@@ -27,8 +38,8 @@ type Held = { token: string; expiresAt: number };
|
|
|
27
38
|
* first read after signing in passes none, so mail already there is not
|
|
28
39
|
* news.
|
|
29
40
|
*
|
|
30
|
-
* A read rejects when Google gives no access token, or Gmail no counts
|
|
31
|
-
* messages.
|
|
41
|
+
* A read rejects when Google gives no access token, or Gmail no counts,
|
|
42
|
+
* messages or addresses.
|
|
32
43
|
*/
|
|
33
44
|
export const inboxReader = (
|
|
34
45
|
domicile: Fetch,
|
|
@@ -61,7 +72,12 @@ export const inboxReader = (
|
|
|
61
72
|
if (mail.length > 0 || read.length > 0) {
|
|
62
73
|
await onMail({ arrived: mail, read });
|
|
63
74
|
}
|
|
64
|
-
return Inbox.Counted(
|
|
75
|
+
return Inbox.Counted(
|
|
76
|
+
counts.total,
|
|
77
|
+
counts.unread,
|
|
78
|
+
latest,
|
|
79
|
+
access.addresses,
|
|
80
|
+
);
|
|
65
81
|
},
|
|
66
82
|
});
|
|
67
83
|
|
|
@@ -88,13 +104,20 @@ export const inboxReader = (
|
|
|
88
104
|
const askedAt = now();
|
|
89
105
|
return (await refreshAccess(domicile, client, refreshToken)).match({
|
|
90
106
|
Err: (refusal) => Promise.resolve(refused(refusal)),
|
|
91
|
-
Ok: (access) =>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
Ok: async (access) =>
|
|
108
|
+
(await sendAsAddresses(domicile, access.token)).match({
|
|
109
|
+
Err: (why): Promise<Inbox> => {
|
|
110
|
+
throw new Error(why);
|
|
111
|
+
},
|
|
112
|
+
Ok: (addresses) => {
|
|
113
|
+
held.current = {
|
|
114
|
+
addresses,
|
|
115
|
+
expiresAt: askedAt + access.expiresInMs,
|
|
116
|
+
token: access.token,
|
|
117
|
+
};
|
|
118
|
+
return count(held.current);
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
98
121
|
});
|
|
99
122
|
};
|
|
100
123
|
|
package/src/sign-in.ts
CHANGED
|
@@ -25,6 +25,7 @@ export const signIn = async (
|
|
|
25
25
|
domicile: Desk,
|
|
26
26
|
client: GoogleClient,
|
|
27
27
|
email: string,
|
|
28
|
+
profile?: string,
|
|
28
29
|
storage?: Parameters<typeof storeToken>[2],
|
|
29
30
|
state: string = randomState(),
|
|
30
31
|
): Promise<void> => {
|
|
@@ -43,7 +44,10 @@ export const signIn = async (
|
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
const stop = browser.on("change", windowsChanged);
|
|
46
|
-
browser.open(
|
|
47
|
+
browser.open(
|
|
48
|
+
consentAddress(client, email, state),
|
|
49
|
+
profile === undefined ? {} : { profile },
|
|
50
|
+
);
|
|
47
51
|
});
|
|
48
52
|
const refreshToken = await code.match({
|
|
49
53
|
Err: (why) => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The digits of the base64 text a token encodes, in base64's order. */
|
|
2
|
+
const BASE64 =
|
|
3
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4
|
+
|
|
5
|
+
/** The digits of a token, in base 40. */
|
|
6
|
+
const CONSONANTS = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The token Gmail's own links name the thread by, as in `#inbox/FMfcg…`, for
|
|
10
|
+
* the Gmail API's hex `threadId`. Gmail opens a thread named this way as a
|
|
11
|
+
* click on it in the list does: beside the inbox when the reading pane is on.
|
|
12
|
+
* Named by the API's id, it opens the thread on its own.
|
|
13
|
+
*
|
|
14
|
+
* The token is `f:<thread id in decimal>`, base64-encoded with its padding
|
|
15
|
+
* dropped, then read as one number in base 64 and written in base 40.
|
|
16
|
+
*/
|
|
17
|
+
export const threadToken = (threadId: string): string =>
|
|
18
|
+
digits(
|
|
19
|
+
[...btoa(`f:${BigInt(`0x${threadId}`).toString()}`).replace(/=+$/, "")]
|
|
20
|
+
.map((digit) => BigInt(BASE64.indexOf(digit)))
|
|
21
|
+
.reduce((sum, digit) => sum * 64n + digit, 0n),
|
|
22
|
+
CONSONANTS,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/** `value`'s digits in `alphabet`'s base, most significant first. */
|
|
26
|
+
const digits = (value: bigint, alphabet: string): string => {
|
|
27
|
+
const base = BigInt(alphabet.length);
|
|
28
|
+
return value === 0n
|
|
29
|
+
? ""
|
|
30
|
+
: digits(value / base, alphabet) + alphabet[Number(value % base)];
|
|
31
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Browser } from "@domicile-desktop/sdk/desktop/browser";
|
|
2
|
+
import { AppReuse } from "@domicile-desktop/sdk/desktop/browser";
|
|
3
|
+
|
|
4
|
+
import { composeAddress, draftAddress, gmailAppId } from "./addresses";
|
|
5
|
+
import type { GoogleClient } from "./consent";
|
|
6
|
+
import { createDraft } from "./gmail-api";
|
|
7
|
+
import { refreshAccess, TokenRefusalKind } from "./google-token";
|
|
8
|
+
import { draftMessage, mailLink } from "./mail-draft";
|
|
9
|
+
import { storedToken } from "./stored-token";
|
|
10
|
+
|
|
11
|
+
/** The desktop {@link writeMail} asks Gmail through and opens Gmail in. */
|
|
12
|
+
export type WriteDesktop = {
|
|
13
|
+
readonly browser: Pick<Browser, "fetch" | "openApp">;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Opens the account's Gmail window with a new message, filled in from the
|
|
18
|
+
* `mailto:` link `link`, from address `from`.
|
|
19
|
+
*
|
|
20
|
+
* - From the account's own address: Gmail's new message form over the inbox,
|
|
21
|
+
* as Gmail's own handler for the link opens it.
|
|
22
|
+
* - From an alias: Gmail's form has no way to name the sender, so the
|
|
23
|
+
* message starts as a draft from the alias, through the Gmail API, and the
|
|
24
|
+
* window opens that draft. Should that fail, it says why with `warn` and
|
|
25
|
+
* opens the form from the account's own address instead, so the link is
|
|
26
|
+
* never lost.
|
|
27
|
+
*
|
|
28
|
+
* A new window is in browser profile `profile`, or its site's when
|
|
29
|
+
* `undefined`. Resolves once the window is asked to open.
|
|
30
|
+
*/
|
|
31
|
+
export const writeMail = async (
|
|
32
|
+
domicile: WriteDesktop,
|
|
33
|
+
client: GoogleClient,
|
|
34
|
+
email: string,
|
|
35
|
+
link: string,
|
|
36
|
+
from: string,
|
|
37
|
+
profile?: string,
|
|
38
|
+
storage?: Parameters<typeof storedToken>[1],
|
|
39
|
+
// biome-ignore lint/suspicious/noConsole: a fallback the user sees but cannot tell why
|
|
40
|
+
warn: (message: string) => void = console.warn,
|
|
41
|
+
): Promise<void> => {
|
|
42
|
+
const open = (address: string) => {
|
|
43
|
+
domicile.browser.openApp(address, {
|
|
44
|
+
id: gmailAppId(email),
|
|
45
|
+
reuse: AppReuse.Navigate,
|
|
46
|
+
...(profile === undefined ? {} : { profile }),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
if (from === email) {
|
|
50
|
+
open(composeAddress(email, link, profile));
|
|
51
|
+
} else {
|
|
52
|
+
const drafted = await draftFrom(
|
|
53
|
+
domicile,
|
|
54
|
+
client,
|
|
55
|
+
email,
|
|
56
|
+
link,
|
|
57
|
+
from,
|
|
58
|
+
storage,
|
|
59
|
+
);
|
|
60
|
+
drafted.match({
|
|
61
|
+
Err: (why) => {
|
|
62
|
+
warn(`Gmail could not start an email from ${from}: ${why}`);
|
|
63
|
+
open(composeAddress(email, link, profile));
|
|
64
|
+
},
|
|
65
|
+
Ok: (message) => {
|
|
66
|
+
open(draftAddress(email, message, profile));
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Saves `link`'s message from `from` as a draft; resolves its message id. */
|
|
73
|
+
const draftFrom = (
|
|
74
|
+
domicile: WriteDesktop,
|
|
75
|
+
client: GoogleClient,
|
|
76
|
+
email: string,
|
|
77
|
+
link: string,
|
|
78
|
+
from: string,
|
|
79
|
+
storage?: Parameters<typeof storedToken>[1],
|
|
80
|
+
) =>
|
|
81
|
+
storedToken(email, storage)
|
|
82
|
+
.okOr(`${email} is signed out`)
|
|
83
|
+
.andThenAsync(async (refreshToken) =>
|
|
84
|
+
(await refreshAccess(domicile, client, refreshToken)).mapErr((refusal) =>
|
|
85
|
+
refusal.kind === TokenRefusalKind.Revoked
|
|
86
|
+
? `${email} needs to sign in again`
|
|
87
|
+
: refusal.reason,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
.then((access) =>
|
|
91
|
+
access.andThenAsync(({ token }) =>
|
|
92
|
+
createDraft(domicile, token, draftMessage(from, mailLink(link))),
|
|
93
|
+
),
|
|
94
|
+
);
|
|
@@ -33504,15 +33504,15 @@ const tokens = {
|
|
|
33504
33504
|
"variable": "var(--jRjWKm)"
|
|
33505
33505
|
},
|
|
33506
33506
|
"zIndex.lock": {
|
|
33507
|
-
"value": "
|
|
33507
|
+
"value": "2147483647",
|
|
33508
33508
|
"variable": "var(--fkMZTt)"
|
|
33509
33509
|
},
|
|
33510
33510
|
"zIndex.modal": {
|
|
33511
|
-
"value": "
|
|
33511
|
+
"value": "2147483646",
|
|
33512
33512
|
"variable": "var(--dIktSh)"
|
|
33513
33513
|
},
|
|
33514
33514
|
"zIndex.modalBackdrop": {
|
|
33515
|
-
"value": "
|
|
33515
|
+
"value": "2147483645",
|
|
33516
33516
|
"variable": "var(--jXaBXH)"
|
|
33517
33517
|
},
|
|
33518
33518
|
"zIndex.toast": {
|
|
@@ -33595,6 +33595,10 @@ const tokens = {
|
|
|
33595
33595
|
"value": "var(--dIlxIZ)",
|
|
33596
33596
|
"variable": "var(--dIlxIZ)"
|
|
33597
33597
|
},
|
|
33598
|
+
"colors.onDanger": {
|
|
33599
|
+
"value": "white",
|
|
33600
|
+
"variable": "var(--hgeHO)"
|
|
33601
|
+
},
|
|
33598
33602
|
"colors.onPhoto": {
|
|
33599
33603
|
"value": "white",
|
|
33600
33604
|
"variable": "var(--cFzlNp)"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
export type Token = `aspectRatios.${AspectRatioToken}` | `borders.${BorderToken}` | `radii.${RadiusToken}` | `fontWeights.${FontWeightToken}` | `lineHeights.${LineHeightToken}` | `letterSpacings.${LetterSpacingToken}` | `shadows.${ShadowToken}` | `colors.${ColorToken}` | `blurs.${BlurToken}` | `animations.${AnimationToken}` | `borderWidths.${BorderWidthToken}` | `durations.${DurationToken}` | `easings.${EasingToken}` | `fontSizes.${FontSizeToken}` | `fonts.${FontToken}` | `gradients.${GradientToken}` | `opacity.${OpacityToken}` | `sizes.${SizeToken}` | `spacing.${SpacingToken}` | `zIndex.${ZIndexToken}` | `breakpoints.${BreakpointToken}`
|
|
3
3
|
|
|
4
|
-
export type ColorPalette = "current" | "black" | "white" | "transparent" | "rose" | "pink" | "fuchsia" | "purple" | "violet" | "indigo" | "blue" | "sky" | "cyan" | "teal" | "emerald" | "green" | "lime" | "yellow" | "amber" | "orange" | "red" | "neutral" | "stone" | "zinc" | "gray" | "slate" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning"
|
|
4
|
+
export type ColorPalette = "current" | "black" | "white" | "transparent" | "rose" | "pink" | "fuchsia" | "purple" | "violet" | "indigo" | "blue" | "sky" | "cyan" | "teal" | "emerald" | "green" | "lime" | "yellow" | "amber" | "orange" | "red" | "neutral" | "stone" | "zinc" | "gray" | "slate" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onDanger" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning"
|
|
5
5
|
|
|
6
6
|
export type AspectRatioToken = "square" | "landscape" | "portrait" | "wide" | "ultrawide" | "golden"
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ export type LetterSpacingToken = "tighter" | "tight" | "normal" | "wide" | "wide
|
|
|
17
17
|
|
|
18
18
|
export type ShadowToken = "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "inset-2xs" | "inset-xs" | "inset-sm" | "lifted" | "modal" | "textOverPhoto"
|
|
19
19
|
|
|
20
|
-
export type ColorToken = "current" | "black" | "white" | "transparent" | "rose.50" | "rose.100" | "rose.200" | "rose.300" | "rose.400" | "rose.500" | "rose.600" | "rose.700" | "rose.800" | "rose.900" | "rose.950" | "pink.50" | "pink.100" | "pink.200" | "pink.300" | "pink.400" | "pink.500" | "pink.600" | "pink.700" | "pink.800" | "pink.900" | "pink.950" | "fuchsia.50" | "fuchsia.100" | "fuchsia.200" | "fuchsia.300" | "fuchsia.400" | "fuchsia.500" | "fuchsia.600" | "fuchsia.700" | "fuchsia.800" | "fuchsia.900" | "fuchsia.950" | "purple.50" | "purple.100" | "purple.200" | "purple.300" | "purple.400" | "purple.500" | "purple.600" | "purple.700" | "purple.800" | "purple.900" | "purple.950" | "violet.50" | "violet.100" | "violet.200" | "violet.300" | "violet.400" | "violet.500" | "violet.600" | "violet.700" | "violet.800" | "violet.900" | "violet.950" | "indigo.50" | "indigo.100" | "indigo.200" | "indigo.300" | "indigo.400" | "indigo.500" | "indigo.600" | "indigo.700" | "indigo.800" | "indigo.900" | "indigo.950" | "blue.50" | "blue.100" | "blue.200" | "blue.300" | "blue.400" | "blue.500" | "blue.600" | "blue.700" | "blue.800" | "blue.900" | "blue.950" | "sky.50" | "sky.100" | "sky.200" | "sky.300" | "sky.400" | "sky.500" | "sky.600" | "sky.700" | "sky.800" | "sky.900" | "sky.950" | "cyan.50" | "cyan.100" | "cyan.200" | "cyan.300" | "cyan.400" | "cyan.500" | "cyan.600" | "cyan.700" | "cyan.800" | "cyan.900" | "cyan.950" | "teal.50" | "teal.100" | "teal.200" | "teal.300" | "teal.400" | "teal.500" | "teal.600" | "teal.700" | "teal.800" | "teal.900" | "teal.950" | "emerald.50" | "emerald.100" | "emerald.200" | "emerald.300" | "emerald.400" | "emerald.500" | "emerald.600" | "emerald.700" | "emerald.800" | "emerald.900" | "emerald.950" | "green.50" | "green.100" | "green.200" | "green.300" | "green.400" | "green.500" | "green.600" | "green.700" | "green.800" | "green.900" | "green.950" | "lime.50" | "lime.100" | "lime.200" | "lime.300" | "lime.400" | "lime.500" | "lime.600" | "lime.700" | "lime.800" | "lime.900" | "lime.950" | "yellow.50" | "yellow.100" | "yellow.200" | "yellow.300" | "yellow.400" | "yellow.500" | "yellow.600" | "yellow.700" | "yellow.800" | "yellow.900" | "yellow.950" | "amber.50" | "amber.100" | "amber.200" | "amber.300" | "amber.400" | "amber.500" | "amber.600" | "amber.700" | "amber.800" | "amber.900" | "amber.950" | "orange.50" | "orange.100" | "orange.200" | "orange.300" | "orange.400" | "orange.500" | "orange.600" | "orange.700" | "orange.800" | "orange.900" | "orange.950" | "red.50" | "red.100" | "red.200" | "red.300" | "red.400" | "red.500" | "red.600" | "red.700" | "red.800" | "red.900" | "red.950" | "neutral.50" | "neutral.100" | "neutral.200" | "neutral.300" | "neutral.400" | "neutral.500" | "neutral.600" | "neutral.700" | "neutral.800" | "neutral.900" | "neutral.950" | "stone.50" | "stone.100" | "stone.200" | "stone.300" | "stone.400" | "stone.500" | "stone.600" | "stone.700" | "stone.800" | "stone.900" | "stone.950" | "zinc.50" | "zinc.100" | "zinc.200" | "zinc.300" | "zinc.400" | "zinc.500" | "zinc.600" | "zinc.700" | "zinc.800" | "zinc.900" | "zinc.950" | "gray.50" | "gray.100" | "gray.200" | "gray.300" | "gray.400" | "gray.500" | "gray.600" | "gray.700" | "gray.800" | "gray.900" | "gray.950" | "slate.50" | "slate.100" | "slate.200" | "slate.300" | "slate.400" | "slate.500" | "slate.600" | "slate.700" | "slate.800" | "slate.900" | "slate.950" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning" | "colorPalette" | "colorPalette.50" | "colorPalette.100" | "colorPalette.200" | "colorPalette.300" | "colorPalette.400" | "colorPalette.500" | "colorPalette.600" | "colorPalette.700" | "colorPalette.800" | "colorPalette.900" | "colorPalette.950"
|
|
20
|
+
export type ColorToken = "current" | "black" | "white" | "transparent" | "rose.50" | "rose.100" | "rose.200" | "rose.300" | "rose.400" | "rose.500" | "rose.600" | "rose.700" | "rose.800" | "rose.900" | "rose.950" | "pink.50" | "pink.100" | "pink.200" | "pink.300" | "pink.400" | "pink.500" | "pink.600" | "pink.700" | "pink.800" | "pink.900" | "pink.950" | "fuchsia.50" | "fuchsia.100" | "fuchsia.200" | "fuchsia.300" | "fuchsia.400" | "fuchsia.500" | "fuchsia.600" | "fuchsia.700" | "fuchsia.800" | "fuchsia.900" | "fuchsia.950" | "purple.50" | "purple.100" | "purple.200" | "purple.300" | "purple.400" | "purple.500" | "purple.600" | "purple.700" | "purple.800" | "purple.900" | "purple.950" | "violet.50" | "violet.100" | "violet.200" | "violet.300" | "violet.400" | "violet.500" | "violet.600" | "violet.700" | "violet.800" | "violet.900" | "violet.950" | "indigo.50" | "indigo.100" | "indigo.200" | "indigo.300" | "indigo.400" | "indigo.500" | "indigo.600" | "indigo.700" | "indigo.800" | "indigo.900" | "indigo.950" | "blue.50" | "blue.100" | "blue.200" | "blue.300" | "blue.400" | "blue.500" | "blue.600" | "blue.700" | "blue.800" | "blue.900" | "blue.950" | "sky.50" | "sky.100" | "sky.200" | "sky.300" | "sky.400" | "sky.500" | "sky.600" | "sky.700" | "sky.800" | "sky.900" | "sky.950" | "cyan.50" | "cyan.100" | "cyan.200" | "cyan.300" | "cyan.400" | "cyan.500" | "cyan.600" | "cyan.700" | "cyan.800" | "cyan.900" | "cyan.950" | "teal.50" | "teal.100" | "teal.200" | "teal.300" | "teal.400" | "teal.500" | "teal.600" | "teal.700" | "teal.800" | "teal.900" | "teal.950" | "emerald.50" | "emerald.100" | "emerald.200" | "emerald.300" | "emerald.400" | "emerald.500" | "emerald.600" | "emerald.700" | "emerald.800" | "emerald.900" | "emerald.950" | "green.50" | "green.100" | "green.200" | "green.300" | "green.400" | "green.500" | "green.600" | "green.700" | "green.800" | "green.900" | "green.950" | "lime.50" | "lime.100" | "lime.200" | "lime.300" | "lime.400" | "lime.500" | "lime.600" | "lime.700" | "lime.800" | "lime.900" | "lime.950" | "yellow.50" | "yellow.100" | "yellow.200" | "yellow.300" | "yellow.400" | "yellow.500" | "yellow.600" | "yellow.700" | "yellow.800" | "yellow.900" | "yellow.950" | "amber.50" | "amber.100" | "amber.200" | "amber.300" | "amber.400" | "amber.500" | "amber.600" | "amber.700" | "amber.800" | "amber.900" | "amber.950" | "orange.50" | "orange.100" | "orange.200" | "orange.300" | "orange.400" | "orange.500" | "orange.600" | "orange.700" | "orange.800" | "orange.900" | "orange.950" | "red.50" | "red.100" | "red.200" | "red.300" | "red.400" | "red.500" | "red.600" | "red.700" | "red.800" | "red.900" | "red.950" | "neutral.50" | "neutral.100" | "neutral.200" | "neutral.300" | "neutral.400" | "neutral.500" | "neutral.600" | "neutral.700" | "neutral.800" | "neutral.900" | "neutral.950" | "stone.50" | "stone.100" | "stone.200" | "stone.300" | "stone.400" | "stone.500" | "stone.600" | "stone.700" | "stone.800" | "stone.900" | "stone.950" | "zinc.50" | "zinc.100" | "zinc.200" | "zinc.300" | "zinc.400" | "zinc.500" | "zinc.600" | "zinc.700" | "zinc.800" | "zinc.900" | "zinc.950" | "gray.50" | "gray.100" | "gray.200" | "gray.300" | "gray.400" | "gray.500" | "gray.600" | "gray.700" | "gray.800" | "gray.900" | "gray.950" | "slate.50" | "slate.100" | "slate.200" | "slate.300" | "slate.400" | "slate.500" | "slate.600" | "slate.700" | "slate.800" | "slate.900" | "slate.950" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onDanger" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning" | "colorPalette" | "colorPalette.50" | "colorPalette.100" | "colorPalette.200" | "colorPalette.300" | "colorPalette.400" | "colorPalette.500" | "colorPalette.600" | "colorPalette.700" | "colorPalette.800" | "colorPalette.900" | "colorPalette.950"
|
|
21
21
|
|
|
22
22
|
export type BlurToken = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl"
|
|
23
23
|
|
|
@@ -222,7 +222,7 @@ export interface UtilityValues {
|
|
|
222
222
|
srOnly: boolean;
|
|
223
223
|
debug: boolean;
|
|
224
224
|
containerName: CssProperties["containerName"];
|
|
225
|
-
colorPalette: "current" | "black" | "white" | "transparent" | "rose" | "pink" | "fuchsia" | "purple" | "violet" | "indigo" | "blue" | "sky" | "cyan" | "teal" | "emerald" | "green" | "lime" | "yellow" | "amber" | "orange" | "red" | "neutral" | "stone" | "zinc" | "gray" | "slate" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning";
|
|
225
|
+
colorPalette: "current" | "black" | "white" | "transparent" | "rose" | "pink" | "fuchsia" | "purple" | "violet" | "indigo" | "blue" | "sky" | "cyan" | "teal" | "emerald" | "green" | "lime" | "yellow" | "amber" | "orange" | "red" | "neutral" | "stone" | "zinc" | "gray" | "slate" | "accent" | "backdrop" | "background" | "border" | "borderStrong" | "card" | "danger" | "dangerSoft" | "divider" | "fill" | "fillHover" | "fillOverPhoto" | "foreground" | "muted" | "onDanger" | "onPhoto" | "panelOverPhoto" | "private" | "skeleton" | "success" | "textFaint" | "textSoft" | "warning";
|
|
226
226
|
textStyle: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "panelDetail" | "panelLabel" | "panelOverline" | "panelTitle";
|
|
227
227
|
}
|
|
228
228
|
|