@devaccel-labs/app-comments-toolbar 1.0.0 → 1.3.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 +152 -18
- package/dist/react.js +516 -61
- package/dist/server.js +342 -14
- package/dist/types/capture/api.d.ts +30 -0
- package/dist/types/capture/editor.d.ts +10 -0
- package/dist/types/capture/ignore.d.ts +19 -0
- package/dist/types/capture/index.d.ts +1 -0
- package/dist/types/capture/picker.d.ts +9 -0
- package/dist/types/capture/picture.d.ts +29 -0
- package/dist/types/capture/surface.d.ts +39 -0
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/resolve.d.ts +2 -1
- package/dist/types/core/types.d.ts +11 -0
- package/dist/types/debug-context.d.ts +7 -0
- package/dist/types/dictation.d.ts +9 -0
- package/dist/types/embed/controller.d.ts +61 -0
- package/dist/types/embed/index.d.ts +1 -0
- package/dist/types/embed/options.d.ts +35 -0
- package/dist/types/help/index.d.ts +1 -0
- package/dist/types/help/panel-index.d.ts +1 -0
- package/dist/types/help/panel-styles.d.ts +1 -0
- package/dist/types/help/panel.d.ts +4 -0
- package/dist/types/help/pill-styles.d.ts +11 -0
- package/dist/types/help/pill.d.ts +44 -0
- package/dist/types/help/react.d.ts +12 -0
- package/dist/types/help/requests.d.ts +2 -0
- package/dist/types/help/types.d.ts +119 -0
- package/dist/types/help/wire.d.ts +61 -0
- package/dist/types/native-wire.d.ts +63 -0
- package/dist/types/native.d.ts +43 -0
- package/dist/types/react.d.ts +8 -1
- package/dist/types/replay.d.ts +6 -0
- package/dist/types/runtime/api.d.ts +250 -0
- package/dist/types/runtime/attachment-model.d.ts +16 -0
- package/dist/types/runtime/attachments.d.ts +43 -7
- package/dist/types/runtime/boot.d.ts +39 -0
- package/dist/types/runtime/browser-label.d.ts +5 -0
- package/dist/types/runtime/build-id.d.ts +7 -0
- package/dist/types/runtime/capture-ui.d.ts +45 -21
- package/dist/types/runtime/clarity-model.d.ts +260 -0
- package/dist/types/runtime/clarity-ui.d.ts +62 -0
- package/dist/types/runtime/client.d.ts +6 -197
- package/dist/types/runtime/composer-size.d.ts +30 -0
- package/dist/types/runtime/dashboard.d.ts +17 -2
- package/dist/types/runtime/debug-context-core.d.ts +88 -0
- package/dist/types/runtime/debug-context-host.d.ts +39 -0
- package/dist/types/runtime/debug-context-model.d.ts +352 -0
- package/dist/types/runtime/debug-context-redact.d.ts +48 -0
- package/dist/types/runtime/debug-context.d.ts +36 -0
- package/dist/types/runtime/details-model.d.ts +7 -0
- package/dist/types/runtime/details.d.ts +7 -5
- package/dist/types/runtime/dictation-engine.d.ts +98 -0
- package/dist/types/runtime/dictation-model.d.ts +28 -0
- package/dist/types/runtime/dictation-ui.d.ts +56 -0
- package/dist/types/runtime/dictation.d.ts +66 -0
- package/dist/types/runtime/draft-dock.d.ts +32 -0
- package/dist/types/runtime/draft-model.d.ts +104 -0
- package/dist/types/runtime/draft-store.d.ts +15 -0
- package/dist/types/runtime/edits.d.ts +1 -1
- package/dist/types/runtime/font.d.ts +16 -0
- package/dist/types/runtime/format.d.ts +30 -1
- package/dist/types/runtime/host-watch.d.ts +20 -0
- package/dist/types/runtime/icons.d.ts +16 -2
- package/dist/types/runtime/index.d.ts +3 -1
- package/dist/types/runtime/ink.d.ts +8 -0
- package/dist/types/runtime/kind-model.d.ts +14 -0
- package/dist/types/runtime/live-model.d.ts +25 -0
- package/dist/types/runtime/loader.d.ts +5 -11
- package/dist/types/runtime/markup-editor.d.ts +54 -0
- package/dist/types/runtime/markup-model.d.ts +126 -0
- package/dist/types/runtime/markup.d.ts +69 -0
- package/dist/types/runtime/mention-parse.d.ts +18 -0
- package/dist/types/runtime/mentions.d.ts +4 -4
- package/dist/types/runtime/page-background.d.ts +9 -0
- package/dist/types/runtime/page-image.d.ts +123 -0
- package/dist/types/runtime/placement.d.ts +6 -3
- package/dist/types/runtime/record.d.ts +18 -2
- package/dist/types/runtime/related.d.ts +1 -1
- package/dist/types/runtime/replay-model.d.ts +80 -0
- package/dist/types/runtime/replay.d.ts +5 -38
- package/dist/types/runtime/runtime.d.ts +6 -0
- package/dist/types/runtime/screen.d.ts +47 -0
- package/dist/types/runtime/screenshot.d.ts +60 -6
- package/dist/types/runtime/session-source.d.ts +45 -0
- package/dist/types/runtime/session.d.ts +20 -18
- package/dist/types/runtime/shield.d.ts +9 -0
- package/dist/types/runtime/shot.d.ts +45 -0
- package/dist/types/runtime/sketch.d.ts +26 -0
- package/dist/types/runtime/styles.d.ts +1 -1
- package/dist/types/runtime/sync.d.ts +1 -0
- package/dist/types/runtime/thread-model.d.ts +18 -0
- package/dist/types/runtime/ticket-form-model.d.ts +57 -0
- package/dist/types/runtime/ticket-form.d.ts +9 -0
- package/dist/types/runtime/toolbar.d.ts +37 -1
- package/dist/types/runtime/ui-scale.d.ts +17 -0
- package/dist/types/runtime/update.d.ts +37 -0
- package/dist/types/runtime/use-debug-context.d.ts +27 -0
- package/dist/types/server/index.d.ts +22 -0
- package/dist/types/server/support.d.ts +20 -0
- package/dist/types/server.d.ts +2 -0
- package/dist/types/vite/plugin.d.ts +15 -0
- package/dist/vite.js +121 -41
- package/package.json +26 -13
- package/src/capture/api.ts +128 -0
- package/src/capture/editor.tsx +178 -0
- package/src/capture/ignore.ts +38 -0
- package/src/capture/index.ts +27 -0
- package/src/capture/picker.tsx +171 -0
- package/src/capture/picture.ts +90 -0
- package/src/capture/surface.tsx +185 -0
- package/src/compiler/annotate.ts +202 -0
- package/src/compiler/babel.d.ts +11 -0
- package/src/compiler/enabled.ts +55 -0
- package/src/compiler/index.ts +2 -0
- package/src/core/index.ts +8 -0
- package/src/core/resolve.ts +307 -0
- package/src/core/types.ts +58 -0
- package/src/debug-context.ts +47 -0
- package/src/dictation.ts +17 -0
- package/src/embed/controller.ts +215 -0
- package/src/embed/index.ts +68 -0
- package/src/embed/options.ts +100 -0
- package/src/help/index.ts +38 -0
- package/src/help/panel-index.ts +17 -0
- package/src/help/panel-styles.ts +123 -0
- package/src/help/panel.ts +840 -0
- package/src/help/pill-styles.ts +75 -0
- package/src/help/pill.ts +338 -0
- package/src/help/react.tsx +143 -0
- package/src/help/requests.ts +111 -0
- package/src/help/types.ts +124 -0
- package/src/help/wire.ts +55 -0
- package/src/native-wire.ts +124 -0
- package/src/native.ts +282 -0
- package/src/react.ts +27 -0
- package/src/replay.ts +13 -0
- package/src/runtime/api.ts +531 -0
- package/src/runtime/attachment-model.ts +42 -0
- package/src/runtime/attachments.tsx +1260 -0
- package/src/runtime/boot.ts +95 -0
- package/src/runtime/browser-label.ts +31 -0
- package/src/runtime/build-id.ts +10 -0
- package/src/runtime/capture-ui.tsx +306 -0
- package/src/runtime/capture.ts +508 -0
- package/src/runtime/clarity-model.ts +634 -0
- package/src/runtime/clarity-ui.tsx +454 -0
- package/src/runtime/client.ts +151 -0
- package/src/runtime/composer-size.tsx +146 -0
- package/src/runtime/dashboard.tsx +1130 -0
- package/src/runtime/debug-context-core.ts +681 -0
- package/src/runtime/debug-context-host.ts +56 -0
- package/src/runtime/debug-context-model.ts +1319 -0
- package/src/runtime/debug-context-redact.ts +259 -0
- package/src/runtime/debug-context.ts +613 -0
- package/src/runtime/details-model.ts +30 -0
- package/src/runtime/details.tsx +395 -0
- package/src/runtime/dictation-engine.ts +616 -0
- package/src/runtime/dictation-model.ts +79 -0
- package/src/runtime/dictation-ui.tsx +363 -0
- package/src/runtime/dictation.ts +271 -0
- package/src/runtime/dock.ts +108 -0
- package/src/runtime/draft-dock.tsx +124 -0
- package/src/runtime/draft-model.ts +251 -0
- package/src/runtime/draft-store.ts +149 -0
- package/src/runtime/edits.tsx +165 -0
- package/src/runtime/font.ts +42 -0
- package/src/runtime/format.ts +129 -0
- package/src/runtime/freshness.ts +23 -0
- package/src/runtime/handoff.ts +76 -0
- package/src/runtime/host-watch.ts +64 -0
- package/src/runtime/icons.tsx +295 -0
- package/src/runtime/idle.ts +20 -0
- package/src/runtime/index.ts +11 -0
- package/src/runtime/ink.ts +6 -0
- package/src/runtime/kind-model.ts +20 -0
- package/src/runtime/live-model.ts +32 -0
- package/src/runtime/loader.tsx +87 -0
- package/src/runtime/markup-editor.tsx +1333 -0
- package/src/runtime/markup-model.ts +485 -0
- package/src/runtime/markup.ts +382 -0
- package/src/runtime/members.ts +58 -0
- package/src/runtime/mention-parse.ts +56 -0
- package/src/runtime/mentions.tsx +205 -0
- package/src/runtime/page-background.ts +51 -0
- package/src/runtime/page-image.ts +1592 -0
- package/src/runtime/placement.ts +336 -0
- package/src/runtime/record.ts +402 -0
- package/src/runtime/redact.ts +30 -0
- package/src/runtime/related.ts +34 -0
- package/src/runtime/render-page.ts +2 -0
- package/src/runtime/replay-model.ts +232 -0
- package/src/runtime/replay.ts +173 -0
- package/src/runtime/runtime-version.ts +7 -0
- package/src/runtime/runtime.tsx +51 -0
- package/src/runtime/screen.ts +182 -0
- package/src/runtime/screenshot.ts +260 -0
- package/src/runtime/session-source.ts +112 -0
- package/src/runtime/session.ts +108 -0
- package/src/runtime/shield.ts +34 -0
- package/src/runtime/shot.tsx +422 -0
- package/src/runtime/sketch.ts +139 -0
- package/src/runtime/styles.ts +1541 -0
- package/src/runtime/sync.ts +300 -0
- package/src/runtime/thread-model.ts +71 -0
- package/src/runtime/ticket-form-model.ts +128 -0
- package/src/runtime/ticket-form.tsx +342 -0
- package/src/runtime/toolbar.tsx +4427 -0
- package/src/runtime/ui-scale.ts +75 -0
- package/src/runtime/update.ts +98 -0
- package/src/runtime/use-debug-context.ts +81 -0
- package/src/server/index.ts +133 -0
- package/src/server/support.ts +499 -0
- package/src/server.ts +4 -0
- package/src/vite/plugin.ts +102 -0
- package/src/vite.ts +1 -0
- package/dist/chunks/chunk-CSKXLF33.js +0 -153
- package/dist/chunks/chunk-HUM5FQII.js +0 -160
- package/dist/chunks/render-page-76MLIT6M.js +0 -1421
- package/dist/chunks/runtime-JX75TKER.js +0 -9267
- package/dist/chunks/screenshot-66ARTBGR.js +0 -12
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Need help?": the pill a host shows every signed-in person, and the panel it opens. The person writes what
|
|
3
|
+
* they need, may add pictures of the page, and sends; the host records the request wherever it keeps them
|
|
4
|
+
* (`submit`) and may show the person what they have sent (`list`). Nothing here signs in to the comment
|
|
5
|
+
* toolbar or calls Comment Tool: the two hooks are the host's own.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type HelpTheme = "light" | "dark" | "auto";
|
|
9
|
+
export type HelpPosition = "bottom-right" | "bottom-left";
|
|
10
|
+
|
|
11
|
+
/** A picture as the capture script returns it (`../capture/picture.ts`). */
|
|
12
|
+
export type HelpImage = {
|
|
13
|
+
blob: Blob;
|
|
14
|
+
name: string;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
markedUp: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type HelpRequest = {
|
|
21
|
+
/** Made once per request and sent again unchanged on a retry, so a host can make it safe to repeat. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** 1 to 4,000 characters. */
|
|
24
|
+
message: string;
|
|
25
|
+
/** The page's address, with anything that looks like a credential in its query taken out. */
|
|
26
|
+
pageUrl: string;
|
|
27
|
+
/** The page's path. */
|
|
28
|
+
route: string;
|
|
29
|
+
/** What the person pointed at, when they did. */
|
|
30
|
+
pointed: { label: string } | null;
|
|
31
|
+
/** At most 3 pictures. */
|
|
32
|
+
images: readonly HelpImage[];
|
|
33
|
+
client: { userAgent: string; language: string; viewport: { width: number; height: number } };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type HelpReceipt = {
|
|
37
|
+
/** The request's number in the host's words. Given, the person reads "Request I00042 received." */
|
|
38
|
+
reference?: string;
|
|
39
|
+
/** Where the request opens in the host, when it has such a page. `http:` or `https:` only. */
|
|
40
|
+
url?: string;
|
|
41
|
+
/** One more plain sentence for the person: "1 picture could not be kept." */
|
|
42
|
+
note?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type SubmittedRequestStatus = "received" | "in_progress" | "resolved";
|
|
46
|
+
|
|
47
|
+
export type SubmittedRequest = {
|
|
48
|
+
id: string;
|
|
49
|
+
reference?: string;
|
|
50
|
+
/** The person's own first words. */
|
|
51
|
+
summary: string;
|
|
52
|
+
/** ISO-8601. */
|
|
53
|
+
createdAt: string;
|
|
54
|
+
status: SubmittedRequestStatus;
|
|
55
|
+
/** The host's own word for the status, shown in place of ours when given. */
|
|
56
|
+
statusLabel?: string;
|
|
57
|
+
/**
|
|
58
|
+
* True when the team already tracks this issue in another request and has merged this one into it. The
|
|
59
|
+
* person is told so, and `status` and `statusLabel` are then where that other request stands. Give
|
|
60
|
+
* nothing else of the other request: it may be somebody else's.
|
|
61
|
+
*/
|
|
62
|
+
consolidated?: boolean;
|
|
63
|
+
/** Where the request opens in the host, when it has such a page. `http:` or `https:` only. */
|
|
64
|
+
url?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type HelpOptions = {
|
|
68
|
+
/**
|
|
69
|
+
* Records the request wherever the host keeps them. Rejecting shows the person a failure and keeps their
|
|
70
|
+
* draft. A rejection that is a `HelpError` (or any error named "HelpError") shows its own message; any
|
|
71
|
+
* other shows one fixed sentence, because an exception's text is not written for the person.
|
|
72
|
+
*/
|
|
73
|
+
submit(request: HelpRequest): Promise<HelpReceipt>;
|
|
74
|
+
/** What this person has submitted. Given, the panel has "Your requests". */
|
|
75
|
+
list?(): Promise<readonly SubmittedRequest[]>;
|
|
76
|
+
/** Default "Need help?". */
|
|
77
|
+
label?: string;
|
|
78
|
+
/** Default "bottom-right". */
|
|
79
|
+
position?: HelpPosition;
|
|
80
|
+
/** Default "auto": the system's light or dark setting. */
|
|
81
|
+
theme?: HelpTheme;
|
|
82
|
+
/**
|
|
83
|
+
* Whether pictures are offered right now. A host turns them off on screens that must not be pictured.
|
|
84
|
+
* Default true. A function is asked each time the panel is drawn and again when a picture is asked for.
|
|
85
|
+
*/
|
|
86
|
+
captures?: boolean | (() => boolean);
|
|
87
|
+
/** Where "More options" leads when the host has a fuller form; it is given the text typed so far. */
|
|
88
|
+
moreOptions?: (draft: { message: string }) => void;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type HelpHandle = { open(): void; close(): void; unmount(): void };
|
|
92
|
+
|
|
93
|
+
/** `submit` and `list` over one same-origin route (`./requests.ts`, `../server/support.ts`). */
|
|
94
|
+
export type SupportRequests = {
|
|
95
|
+
submit(request: HelpRequest): Promise<HelpReceipt>;
|
|
96
|
+
list(): Promise<readonly SubmittedRequest[]>;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type CommentToolHelpApi = {
|
|
100
|
+
/** Shows the pill. Calling it again replaces the options; the pill, an open panel and a draft stay. */
|
|
101
|
+
mount(options: HelpOptions): HelpHandle;
|
|
102
|
+
/** The two hooks for a host whose server route is `handleSupportRequest`. */
|
|
103
|
+
supportRequestsAt(url: string): SupportRequests;
|
|
104
|
+
/** A failure whose message is written for the person. */
|
|
105
|
+
HelpError: typeof HelpError;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A failure whose message is one plain sentence for the person who pressed Send. The panel shows it as it
|
|
110
|
+
* is. Recognised by its name, not its class, so one thrown by the package is known to the script and back.
|
|
111
|
+
*/
|
|
112
|
+
export class HelpError extends Error {
|
|
113
|
+
override readonly name = "HelpError";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function isHelpError(error: unknown): error is Error {
|
|
117
|
+
return (
|
|
118
|
+
typeof error === "object" &&
|
|
119
|
+
error !== null &&
|
|
120
|
+
(error as { name?: unknown }).name === "HelpError" &&
|
|
121
|
+
typeof (error as { message?: unknown }).message === "string" &&
|
|
122
|
+
(error as { message: string }).message.trim().length > 0
|
|
123
|
+
);
|
|
124
|
+
}
|
package/src/help/wire.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A help request as it travels from the browser to the host's own route (`./requests.ts` writes it,
|
|
3
|
+
* `../server/support.ts` reads it): JSON, with each picture's bytes as base64. No DOM and no server API
|
|
4
|
+
* here, so both sides import it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const HELP_LIMITS = {
|
|
8
|
+
/** A request's own id: letters, digits, `.`, `_`, `:` and `-`. */
|
|
9
|
+
id: 100,
|
|
10
|
+
message: 4000,
|
|
11
|
+
images: 3,
|
|
12
|
+
/** One picture, before base64. */
|
|
13
|
+
imageBytes: 5 * 1024 * 1024,
|
|
14
|
+
name: 200,
|
|
15
|
+
label: 200,
|
|
16
|
+
url: 1000,
|
|
17
|
+
/** "Your requests" shows at most this many. */
|
|
18
|
+
listed: 50,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
/** The whole body: three pictures as base64, the text, and room for the rest. */
|
|
22
|
+
export const HELP_BODY_BYTES =
|
|
23
|
+
Math.ceil((HELP_LIMITS.images * HELP_LIMITS.imageBytes * 4) / 3) + 256 * 1024;
|
|
24
|
+
|
|
25
|
+
export const HELP_ID = /^[A-Za-z0-9._:-]+$/;
|
|
26
|
+
|
|
27
|
+
/** The picture types a request may carry. Checked on the server against each file's first bytes. */
|
|
28
|
+
export const HELP_IMAGE_TYPES = ["image/png", "image/jpeg", "image/webp"] as const;
|
|
29
|
+
export type HelpImageType = (typeof HELP_IMAGE_TYPES)[number];
|
|
30
|
+
|
|
31
|
+
export type HelpImageWire = {
|
|
32
|
+
name: string;
|
|
33
|
+
contentType: string;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
markedUp: boolean;
|
|
37
|
+
/** The file's bytes, base64. */
|
|
38
|
+
data: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type HelpRequestWire = {
|
|
42
|
+
id: string;
|
|
43
|
+
message: string;
|
|
44
|
+
pageUrl: string;
|
|
45
|
+
route: string;
|
|
46
|
+
pointed: { label: string } | null;
|
|
47
|
+
images: readonly HelpImageWire[];
|
|
48
|
+
client: { userAgent: string; language: string; viewport: { width: number; height: number } };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** What the route answers a `POST` with. */
|
|
52
|
+
export type HelpReceiptWire = { reference?: string; url?: string; note?: string };
|
|
53
|
+
|
|
54
|
+
/** What the route answers when it refuses or fails: one plain sentence. */
|
|
55
|
+
export type HelpFailureWire = { error: string };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire contract between native (iOS / Android) comment clients and the App comments service.
|
|
3
|
+
*
|
|
4
|
+
* One owner for the worker, the host session route, a connection's own workspace and
|
|
5
|
+
* `@devaccel-labs/app-comments-native`. DOM-free and dependency-free.
|
|
6
|
+
*
|
|
7
|
+
* A native app has no web origin. It identifies itself with an app origin, `<scheme>://app`, where `<scheme>`
|
|
8
|
+
* is one of the environment's `appSchemes` (for example `my-app-staging`). It sends that value in the
|
|
9
|
+
* `x-comment-service-origin` header and never sends `Origin`. Browsers always send `Origin` on cross-origin
|
|
10
|
+
* requests, so a web page can never take the app-origin path. Native threads store their screen as an app URL,
|
|
11
|
+
* `<scheme>://app/<route>`, so `url` pathname still equals `route`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Which client wrote a comment. Web clients may omit it; the service treats a missing value as `web`. */
|
|
15
|
+
export type ClientPlatform = "web" | "ios" | "android";
|
|
16
|
+
|
|
17
|
+
/** Device and build facts a native client sends with a new thread (`POST /v1/threads` body `client`). */
|
|
18
|
+
export type ClientInfo = {
|
|
19
|
+
platform: ClientPlatform;
|
|
20
|
+
/** The host app's build variant, e.g. `staging`, `staging2`. */
|
|
21
|
+
appVariant?: string | null;
|
|
22
|
+
/** Marketing version, e.g. `0.6.9`. */
|
|
23
|
+
appVersion?: string | null;
|
|
24
|
+
/** Build number, e.g. `123`. */
|
|
25
|
+
build?: string | null;
|
|
26
|
+
/** OS name and version, e.g. `iOS 26.1`, `Android 16`. */
|
|
27
|
+
os?: string | null;
|
|
28
|
+
/** Device model, e.g. `iPhone 17 Pro`, `Pixel 10`. */
|
|
29
|
+
device?: string | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Header a native client sends instead of `Origin`. */
|
|
33
|
+
export const APP_ORIGIN_HEADER = "x-comment-service-origin";
|
|
34
|
+
|
|
35
|
+
/** The host the app origin uses: `<scheme>://app`. */
|
|
36
|
+
export const APP_ORIGIN_HOST = "app";
|
|
37
|
+
|
|
38
|
+
/** Most schemes an environment may list. */
|
|
39
|
+
export const MAX_APP_SCHEMES = 10;
|
|
40
|
+
|
|
41
|
+
const SCHEME = /^[a-z][a-z0-9+.-]{1,39}$/;
|
|
42
|
+
const RESERVED = new Set([
|
|
43
|
+
"http",
|
|
44
|
+
"https",
|
|
45
|
+
"ws",
|
|
46
|
+
"wss",
|
|
47
|
+
"file",
|
|
48
|
+
"data",
|
|
49
|
+
"blob",
|
|
50
|
+
"javascript",
|
|
51
|
+
"vbscript",
|
|
52
|
+
"about",
|
|
53
|
+
"mailto",
|
|
54
|
+
"tel",
|
|
55
|
+
"sms",
|
|
56
|
+
"intent",
|
|
57
|
+
"content",
|
|
58
|
+
"chrome",
|
|
59
|
+
"chrome-extension",
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
/** Whether `value` is a scheme an environment may list (lowercase, no `:`, not a web or system scheme). */
|
|
63
|
+
export function isAppScheme(value: string): boolean {
|
|
64
|
+
return SCHEME.test(value) && !RESERVED.has(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A list of app schemes as typed (trimmed, lowercased, deduped), or what is wrong with it. */
|
|
68
|
+
export function normalizeAppSchemes(
|
|
69
|
+
value: unknown,
|
|
70
|
+
):
|
|
71
|
+
| { readonly ok: true; readonly schemes: string[] }
|
|
72
|
+
| { readonly ok: false; readonly message: string } {
|
|
73
|
+
if (!Array.isArray(value)) return { ok: false, message: "App schemes must be a list." };
|
|
74
|
+
const schemes: string[] = [];
|
|
75
|
+
for (const item of value) {
|
|
76
|
+
if (typeof item !== "string") return { ok: false, message: "Each app scheme must be text." };
|
|
77
|
+
const scheme = item.trim().toLowerCase();
|
|
78
|
+
if (!isAppScheme(scheme))
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
message: `Not an app scheme: ${item}. Use lowercase letters, numbers and hyphens, like my-app-staging.`,
|
|
82
|
+
};
|
|
83
|
+
if (!schemes.includes(scheme)) schemes.push(scheme);
|
|
84
|
+
}
|
|
85
|
+
if (schemes.length > MAX_APP_SCHEMES)
|
|
86
|
+
return { ok: false, message: `Add up to ${MAX_APP_SCHEMES} app schemes.` };
|
|
87
|
+
return { ok: true, schemes };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** `my-app-staging` → `my-app-staging://app`. */
|
|
91
|
+
export function appOrigin(scheme: string): string {
|
|
92
|
+
return `${scheme}://${APP_ORIGIN_HOST}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The scheme of an app origin (`<scheme>://app`, nothing after it), or null. Does not check the environment's
|
|
97
|
+
* list; callers compare the scheme with `appSchemes`.
|
|
98
|
+
*/
|
|
99
|
+
export function appOriginScheme(value: string): string | null {
|
|
100
|
+
const match = /^([a-z][a-z0-9+.-]{1,39}):\/\/app$/.exec(value);
|
|
101
|
+
const scheme = match?.[1];
|
|
102
|
+
return scheme && isAppScheme(scheme) ? scheme : null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The app URL a native thread stores: `<scheme>://app` + route. `route` starts with `/`. */
|
|
106
|
+
export function appScreenUrl(scheme: string, route: string): string {
|
|
107
|
+
return `${appOrigin(scheme)}${route.startsWith("/") ? route : `/${route}`}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Splits an app URL (`<scheme>://app/<path>?<query>`) into its scheme and pathname, or null when it is not one.
|
|
112
|
+
* `new URL()` gives `origin === "null"` for non-special schemes, so callers use this instead.
|
|
113
|
+
*/
|
|
114
|
+
export function parseAppUrl(value: string): { scheme: string; pathname: string } | null {
|
|
115
|
+
const match = /^([a-z][a-z0-9+.-]{1,39}):\/\/app(\/[^?#]*)?(?:[?#].*)?$/.exec(value);
|
|
116
|
+
const scheme = match?.[1];
|
|
117
|
+
if (!scheme || !isAppScheme(scheme)) return null;
|
|
118
|
+
return { scheme, pathname: match[2] ?? "/" };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Where the sign-in callback returns a native client: `<scheme>://app/app-comments/auth`. */
|
|
122
|
+
export function appAuthReturnUrl(scheme: string): string {
|
|
123
|
+
return `${appOrigin(scheme)}/app-comments/auth`;
|
|
124
|
+
}
|
package/src/native.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolbar's portable (DOM-free) logic, for native clients: `@devaccel-labs/app-comments-toolbar/native`,
|
|
3
|
+
* re-exported by `@devaccel-labs/app-comments-native` (its `src/shared.ts`). It ships as TypeScript source, like
|
|
4
|
+
* `./native-wire`, `./dictation` and `./replay`; React Native's Metro compiles it in the host app.
|
|
5
|
+
*
|
|
6
|
+
* Every module re-exported here must stay DOM-free at import time (no `react-dom`, no DOM components, no
|
|
7
|
+
* top-level `window` / `document`). Where a web module mixes portable helpers with DOM UI, the helpers live in a
|
|
8
|
+
* pure module here and the web file re-exports them, so web imports don't change.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./native-wire.js";
|
|
11
|
+
export type { Anchor, Candidate, Resolution, ResolutionStatus, Sketch } from "./core/index.js";
|
|
12
|
+
export { describeAnchor, validateAnchor } from "./core/index.js";
|
|
13
|
+
|
|
14
|
+
// Request functions and wire types (`api.ts`, the DOM-free half of the web `client.ts`). Member tokens go
|
|
15
|
+
// through `MemberTokenStore`; a session's `clientOrigin` is sent as `x-comment-service-origin` on every call.
|
|
16
|
+
export {
|
|
17
|
+
ApiError,
|
|
18
|
+
base64Url,
|
|
19
|
+
checkClarity,
|
|
20
|
+
createThread,
|
|
21
|
+
editMessage,
|
|
22
|
+
fetchTicketForm,
|
|
23
|
+
finishMsfSignIn,
|
|
24
|
+
getProfile,
|
|
25
|
+
listMembers,
|
|
26
|
+
listThreads,
|
|
27
|
+
memberIsCurrent,
|
|
28
|
+
msfAuthorizeUrl,
|
|
29
|
+
msfHandoffFrom,
|
|
30
|
+
openLive,
|
|
31
|
+
readMemberToken,
|
|
32
|
+
replyToThread,
|
|
33
|
+
saveSettings,
|
|
34
|
+
signInOptions,
|
|
35
|
+
storageKey,
|
|
36
|
+
transcribeAudio,
|
|
37
|
+
updateProfile,
|
|
38
|
+
updateThread,
|
|
39
|
+
uploadAttachment,
|
|
40
|
+
} from "./runtime/api.js";
|
|
41
|
+
export type {
|
|
42
|
+
Access,
|
|
43
|
+
Attachment,
|
|
44
|
+
Capture,
|
|
45
|
+
CommentMessage,
|
|
46
|
+
Delivery,
|
|
47
|
+
Details,
|
|
48
|
+
FieldDef,
|
|
49
|
+
FieldValue,
|
|
50
|
+
Member,
|
|
51
|
+
MemberTokenStore,
|
|
52
|
+
Mentioned,
|
|
53
|
+
MsfHandoff,
|
|
54
|
+
PostExtras,
|
|
55
|
+
Profile,
|
|
56
|
+
Revision,
|
|
57
|
+
Settings,
|
|
58
|
+
SignInOptions,
|
|
59
|
+
Thread,
|
|
60
|
+
TicketBadge,
|
|
61
|
+
} from "./runtime/api.js";
|
|
62
|
+
export { readJwt, sessionFrom, sessionSource } from "./runtime/session-source.js";
|
|
63
|
+
export type { GetSession, Session } from "./runtime/session-source.js";
|
|
64
|
+
|
|
65
|
+
export { fieldIsSensitive, redactText } from "./runtime/redact.js";
|
|
66
|
+
export { relatedTo } from "./runtime/related.js";
|
|
67
|
+
export type { Related } from "./runtime/related.js";
|
|
68
|
+
export { MAX_POLL_MS, nextPoll } from "./runtime/freshness.js";
|
|
69
|
+
export type { PollState } from "./runtime/freshness.js";
|
|
70
|
+
export {
|
|
71
|
+
ago,
|
|
72
|
+
colorFor,
|
|
73
|
+
deliveryText,
|
|
74
|
+
initials,
|
|
75
|
+
paintThreadStatuses,
|
|
76
|
+
statusNote,
|
|
77
|
+
targetName,
|
|
78
|
+
} from "./runtime/format.js";
|
|
79
|
+
|
|
80
|
+
// Replay model (types, buffer, parsing). `watchActivity` is web-only; native activity lives in src/activity.
|
|
81
|
+
export {
|
|
82
|
+
ReplayBuffer,
|
|
83
|
+
consoleText,
|
|
84
|
+
parseReplay,
|
|
85
|
+
redactSecretSearchParams,
|
|
86
|
+
replayLine,
|
|
87
|
+
replayStamp,
|
|
88
|
+
} from "./runtime/replay-model.js";
|
|
89
|
+
export type {
|
|
90
|
+
ReplayBufferOptions,
|
|
91
|
+
ReplayClip,
|
|
92
|
+
ReplayDraft,
|
|
93
|
+
ReplayEvent,
|
|
94
|
+
ReplayFile,
|
|
95
|
+
} from "./runtime/replay-model.js";
|
|
96
|
+
|
|
97
|
+
// Debug context: the file, its redaction and its limits, and the capture core every platform feeds. Native
|
|
98
|
+
// hooks live in src/activity.
|
|
99
|
+
export * from "./debug-context.js";
|
|
100
|
+
export {
|
|
101
|
+
argText,
|
|
102
|
+
createDebugCore,
|
|
103
|
+
errorOf,
|
|
104
|
+
type DebugCaptureStats,
|
|
105
|
+
type DebugCore,
|
|
106
|
+
type RequestReaders,
|
|
107
|
+
} from "./runtime/debug-context-core.js";
|
|
108
|
+
|
|
109
|
+
// Drafts: the store with a native `DraftBackend` (src/drafts).
|
|
110
|
+
export {
|
|
111
|
+
MAX_DRAFT_BYTES,
|
|
112
|
+
MAX_DRAFT_CAPTURES,
|
|
113
|
+
createDraftStore,
|
|
114
|
+
describeDraft,
|
|
115
|
+
readStoredDraft,
|
|
116
|
+
} from "./runtime/draft-model.js";
|
|
117
|
+
export type {
|
|
118
|
+
DraftBackend,
|
|
119
|
+
DraftStore,
|
|
120
|
+
StoredCapture,
|
|
121
|
+
StoredDraft,
|
|
122
|
+
StoredRecording,
|
|
123
|
+
} from "./runtime/draft-model.js";
|
|
124
|
+
|
|
125
|
+
// Markup shape model, hit-testing and history. Drawing is native (react-native-svg); flattening is native.
|
|
126
|
+
export {
|
|
127
|
+
DEFAULT_HIGHLIGHT,
|
|
128
|
+
DEFAULT_INK,
|
|
129
|
+
HIGHLIGHT_ALPHA,
|
|
130
|
+
HISTORY_LIMIT,
|
|
131
|
+
MARKUP_COLORS,
|
|
132
|
+
arrowHead,
|
|
133
|
+
commitHistory,
|
|
134
|
+
contrastText,
|
|
135
|
+
createHistory,
|
|
136
|
+
flattenedName,
|
|
137
|
+
hitTest,
|
|
138
|
+
isMeaningful,
|
|
139
|
+
markupMetrics,
|
|
140
|
+
moveShape,
|
|
141
|
+
normalizeBox,
|
|
142
|
+
redoHistory,
|
|
143
|
+
shapeBounds,
|
|
144
|
+
snapAngle,
|
|
145
|
+
strokeWidth,
|
|
146
|
+
textLayout,
|
|
147
|
+
toRect,
|
|
148
|
+
undoHistory,
|
|
149
|
+
} from "./runtime/markup-model.js";
|
|
150
|
+
export type {
|
|
151
|
+
ArrowShape,
|
|
152
|
+
Box,
|
|
153
|
+
BoxShape,
|
|
154
|
+
MarkupHistory,
|
|
155
|
+
MarkupMetrics,
|
|
156
|
+
MarkupShape,
|
|
157
|
+
MarkupSize,
|
|
158
|
+
MarkupTool,
|
|
159
|
+
MeasureText,
|
|
160
|
+
StrokeShape,
|
|
161
|
+
TextLayout,
|
|
162
|
+
TextShape,
|
|
163
|
+
} from "./runtime/markup-model.js";
|
|
164
|
+
|
|
165
|
+
// Dictation text helpers. Audio capture is native (expo-audio, m4a takes).
|
|
166
|
+
export {
|
|
167
|
+
decibels,
|
|
168
|
+
dictationPrompt,
|
|
169
|
+
insertDictated,
|
|
170
|
+
meterLevel,
|
|
171
|
+
voiceRecordingName,
|
|
172
|
+
} from "./runtime/dictation-model.js";
|
|
173
|
+
|
|
174
|
+
// Who wrote, who is named, and how a thread reads in lists.
|
|
175
|
+
export {
|
|
176
|
+
agoPhrase,
|
|
177
|
+
fromYou,
|
|
178
|
+
involved,
|
|
179
|
+
isMine,
|
|
180
|
+
leadSentence,
|
|
181
|
+
mentionOfYou,
|
|
182
|
+
namesYou,
|
|
183
|
+
versionsOf,
|
|
184
|
+
} from "./runtime/thread-model.js";
|
|
185
|
+
|
|
186
|
+
// Attachment limits, names and sizes.
|
|
187
|
+
export {
|
|
188
|
+
ATTACHMENT_MAX_BYTES,
|
|
189
|
+
ATTACHMENT_MAX_FILES,
|
|
190
|
+
ATTACHMENT_TYPES,
|
|
191
|
+
attachmentStamp,
|
|
192
|
+
formatSize,
|
|
193
|
+
isReplayFile,
|
|
194
|
+
} from "./runtime/attachment-model.js";
|
|
195
|
+
|
|
196
|
+
// Live socket protocol and timing (web `useThreadsSync` and the native live loop).
|
|
197
|
+
export {
|
|
198
|
+
KEEPALIVE_MS,
|
|
199
|
+
MAX_QUICK_RETRIES,
|
|
200
|
+
OPEN_WAIT_MS,
|
|
201
|
+
PUSH_BATCH_MS,
|
|
202
|
+
RETRY_LATER_MS,
|
|
203
|
+
parseLiveMessage,
|
|
204
|
+
} from "./runtime/live-model.js";
|
|
205
|
+
export type { LiveMessage } from "./runtime/live-model.js";
|
|
206
|
+
|
|
207
|
+
// Composer helpers.
|
|
208
|
+
export {
|
|
209
|
+
insertMention,
|
|
210
|
+
mentionMatches,
|
|
211
|
+
mentionParts,
|
|
212
|
+
mentionQueryAt,
|
|
213
|
+
mentionsIn,
|
|
214
|
+
} from "./runtime/mention-parse.js";
|
|
215
|
+
export {
|
|
216
|
+
CHIP_OPTIONS_MAX,
|
|
217
|
+
missingTicketFields,
|
|
218
|
+
ticketDraftPayload,
|
|
219
|
+
ticketFieldOptions,
|
|
220
|
+
ticketFieldVisibility,
|
|
221
|
+
ticketValueFilled,
|
|
222
|
+
} from "./runtime/ticket-form-model.js";
|
|
223
|
+
export type {
|
|
224
|
+
TicketDraft,
|
|
225
|
+
TicketForm,
|
|
226
|
+
TicketFormField,
|
|
227
|
+
TicketValue,
|
|
228
|
+
TicketValues,
|
|
229
|
+
} from "./runtime/ticket-form-model.js";
|
|
230
|
+
export {
|
|
231
|
+
detailsEnabled,
|
|
232
|
+
detailsPayload,
|
|
233
|
+
hasFieldValues,
|
|
234
|
+
noDetails,
|
|
235
|
+
} from "./runtime/details-model.js";
|
|
236
|
+
export { REPORT_KINDS, readReportKind } from "./runtime/kind-model.js";
|
|
237
|
+
export type { ReportKind } from "./runtime/kind-model.js";
|
|
238
|
+
|
|
239
|
+
// The clarity check's decisions before a new comment is sent (docs/adr/0002-clarity-check.md). The panel is native.
|
|
240
|
+
export {
|
|
241
|
+
CLARITY_ANSWER_MAX_LENGTH,
|
|
242
|
+
CLARITY_MAX_ASSUMED,
|
|
243
|
+
CLARITY_MAX_QUESTIONS,
|
|
244
|
+
CLARITY_MAX_ROUNDS,
|
|
245
|
+
CLARITY_WAIT_MS,
|
|
246
|
+
CLARITY_WORDS,
|
|
247
|
+
COMMENT_MESSAGE_MAX_LENGTH,
|
|
248
|
+
answerRoom,
|
|
249
|
+
askClarity,
|
|
250
|
+
canSendAsIs,
|
|
251
|
+
clarityAfterCheck,
|
|
252
|
+
clarityAnnouncement,
|
|
253
|
+
clarityBody,
|
|
254
|
+
clarityChecks,
|
|
255
|
+
clarityGroups,
|
|
256
|
+
clarityReader,
|
|
257
|
+
clarityStep,
|
|
258
|
+
draftMark,
|
|
259
|
+
openQuestions,
|
|
260
|
+
passMark,
|
|
261
|
+
questionAudience,
|
|
262
|
+
readClarityHold,
|
|
263
|
+
readClarityMode,
|
|
264
|
+
readClarityResponse,
|
|
265
|
+
whoWouldAsk,
|
|
266
|
+
withAnswer,
|
|
267
|
+
} from "./runtime/clarity-model.js";
|
|
268
|
+
export type {
|
|
269
|
+
ClarityAnswer,
|
|
270
|
+
ClarityAnswerCheck,
|
|
271
|
+
ClarityAudience,
|
|
272
|
+
ClarityDraft,
|
|
273
|
+
ClarityFacts,
|
|
274
|
+
ClarityGap,
|
|
275
|
+
ClarityHold,
|
|
276
|
+
ClarityMode,
|
|
277
|
+
ClarityOutcome,
|
|
278
|
+
ClarityQuestion,
|
|
279
|
+
ClarityReport,
|
|
280
|
+
ClaritySend,
|
|
281
|
+
ClarityStep,
|
|
282
|
+
} from "./runtime/clarity-model.js";
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { CommentToolbar } from "./runtime/loader.js";
|
|
2
|
+
export type { ToolbarPosition, ToolbarProps, ToolbarTheme } from "./runtime/toolbar.js";
|
|
3
|
+
export { queryCacheSummary, reportToolbarError } from "./runtime/debug-context-host.js";
|
|
4
|
+
export type {
|
|
5
|
+
DebugAudience,
|
|
6
|
+
DebugContextConfig,
|
|
7
|
+
DebugContextOptions,
|
|
8
|
+
DebugSignal,
|
|
9
|
+
HostBuild,
|
|
10
|
+
HostContext,
|
|
11
|
+
QuerySummary,
|
|
12
|
+
} from "./runtime/debug-context-model.js";
|
|
13
|
+
export { HelpPill } from "./help/react.js";
|
|
14
|
+
export type { HelpPillProps } from "./help/react.js";
|
|
15
|
+
export { supportRequestsAt } from "./help/requests.js";
|
|
16
|
+
export { HelpError } from "./help/types.js";
|
|
17
|
+
export type {
|
|
18
|
+
HelpImage,
|
|
19
|
+
HelpOptions,
|
|
20
|
+
HelpPosition,
|
|
21
|
+
HelpReceipt,
|
|
22
|
+
HelpRequest,
|
|
23
|
+
HelpTheme,
|
|
24
|
+
SubmittedRequest,
|
|
25
|
+
SubmittedRequestStatus,
|
|
26
|
+
SupportRequests,
|
|
27
|
+
} from "./help/types.js";
|
package/src/replay.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The replay file a clip carries, for an inbox and for the service: parse it, pair it with its clip, and word
|
|
3
|
+
* each event. These come from the DOM-free half (`runtime/replay-model`), so a Worker can import them.
|
|
4
|
+
* Source only, like `./dictation`: not built into `dist`.
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
parseReplay,
|
|
8
|
+
replayLine,
|
|
9
|
+
replayStamp,
|
|
10
|
+
type ReplayClip,
|
|
11
|
+
type ReplayEvent,
|
|
12
|
+
type ReplayFile,
|
|
13
|
+
} from "./runtime/replay-model.js";
|