@journeeze/sdk 0.1.0-rc.2 → 0.1.0-rc.3
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/AGENTS.md +16 -3
- package/CHANGELOG.md +12 -1
- package/README.md +298 -119
- package/dist/anchor-cPvFFTOS.js +1 -0
- package/dist/attach-DpioALxW.js +21 -0
- package/dist/chat-BgmB0rnW.js +64 -0
- package/dist/consent-DckCUvYR.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-CtH1a_kQ.js +1 -0
- package/dist/help-w0O5Qu-4.js +105 -0
- package/dist/hook-DGWypoEO.js +1 -0
- package/dist/index-B_nob8S0.js +1 -2091
- package/dist/{index-CfCbJJXa.js → index-CwG2LrhO.js} +3 -3
- package/dist/index.js +3 -3
- package/dist/jobs-CAXbM5-g.js +45 -0
- package/dist/loader-BZiIDD1D.js +96 -0
- package/dist/mask-audit-Du3NPoG_.js +5 -0
- package/dist/react.js +12 -11
- package/dist/resolve-BfWByuTp.js +1 -97
- package/dist/script.js +10 -9
- package/dist/signals-amjMQyOy.js +1 -0
- package/dist/telemetry-CyRJDaVs.js +1 -0
- package/dist/transport-B64CfIcF.js +1 -0
- package/dist/types/chat/capture/attach.d.ts +41 -0
- package/dist/types/chat/capture/draw.d.ts +10 -0
- package/dist/types/chat/capture/geometry.d.ts +30 -0
- package/dist/types/chat/capture/styles.d.ts +1 -0
- package/dist/types/chat/shell/chat.d.ts +27 -0
- package/dist/types/chat/shell/converse.d.ts +95 -0
- package/dist/types/chat/shell/copy.d.ts +8 -0
- package/dist/types/chat/shell/model.d.ts +36 -0
- package/dist/types/chat/shell/session.d.ts +148 -0
- package/dist/types/chat/shell/styles.d.ts +1 -0
- package/dist/types/chat/shell/view.d.ts +18 -0
- package/dist/types/chat/transport.d.ts +5 -0
- package/dist/types/config.d.ts +17 -0
- package/dist/types/help/core/controller.d.ts +12 -3
- package/dist/types/help/core/events.d.ts +24 -0
- package/dist/types/help/core/help.d.ts +1 -0
- package/dist/types/help/core/panel.d.ts +16 -0
- package/dist/types/help/core/routing.d.ts +21 -0
- package/dist/types/help/ui/jobs/jobs.d.ts +24 -0
- package/dist/types/help/ui/jobs/model.d.ts +33 -0
- package/dist/types/help/ui/jobs/styles.d.ts +1 -0
- package/dist/types/loader.d.ts +2 -0
- package/dist/types/mask-detector.d.ts +22 -0
- package/dist/types/preview/flag.d.ts +2 -0
- package/dist/types/preview/mask-audit.d.ts +29 -0
- package/dist/types/schemas/feedback.d.ts +76 -0
- package/dist/types/schemas/finding.d.ts +22 -0
- package/dist/types/schemas/index.d.ts +6 -0
- package/dist/types/schemas/turn.d.ts +26 -0
- package/dist/types/signals/signals.d.ts +7 -3
- package/dist/types/signals/steps.d.ts +33 -0
- package/dist/types/telemetry/telemetry.d.ts +10 -0
- package/dist/types/types.d.ts +72 -1
- package/dist/types/widget/capture.d.ts +12 -1
- package/dist/types/widget/upload.d.ts +14 -0
- package/dist/types/widget.d.ts +1 -21
- package/dist/upload-Fu2qvSJV.js +14 -0
- package/dist/widget-B6mR1J3P.js +118 -0
- package/package.json +4 -2
- package/dist/consent-CoKD33Rm.js +0 -170
- package/dist/feedback-C4CYtS2A.js +0 -196
- package/dist/help-C1x-y2f9.js +0 -878
- package/dist/hook-BdG4UL4k.js +0 -91
- package/dist/loader-Ba4X-WNl.js +0 -95
- package/dist/signals-E3VEdmWH.js +0 -477
- package/dist/telemetry-Cik-cYzw.js +0 -140
- package/dist/transport-B5YJFQEF.js +0 -60
- package/dist/types/signals/signals.conformance.d.ts +0 -2
- package/dist/widget-DQZm8sAC.js +0 -1599
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { FeedbackContext, FeedbackMessage, FeedbackTeam } from "../../schemas/feedback";
|
|
2
|
+
import type { TurnInput } from "../../schemas/turn";
|
|
3
|
+
/** `schema` of every Converse request. */
|
|
4
|
+
export declare const TURN_SCHEMA = "journeeze.turn/v1";
|
|
5
|
+
/** A guide step card on an assistant message. */
|
|
6
|
+
export interface ConverseCard {
|
|
7
|
+
jobId?: string;
|
|
8
|
+
step?: number;
|
|
9
|
+
of?: number;
|
|
10
|
+
title?: string;
|
|
11
|
+
instruction?: string;
|
|
12
|
+
}
|
|
13
|
+
/** An assistant message: rendered copy from the server's copy pack. */
|
|
14
|
+
export interface ConverseMessage {
|
|
15
|
+
copyId: string;
|
|
16
|
+
text: string;
|
|
17
|
+
card?: ConverseCard;
|
|
18
|
+
}
|
|
19
|
+
/** The `plus_menu` items (contract §2). */
|
|
20
|
+
export type PlusItem = "show_us_where" | "point_at_it" | "attach_file";
|
|
21
|
+
/** A "+" menu item with its copy (contract §2 `ConverseMenuItem`), in `items` order. */
|
|
22
|
+
export interface ConverseMenuItem {
|
|
23
|
+
id: PlusItem;
|
|
24
|
+
label: string;
|
|
25
|
+
hint?: string;
|
|
26
|
+
}
|
|
27
|
+
/** What the UI may offer next (contract §2 `actions`). `label` is the server's rendered copy
|
|
28
|
+
* (ADR 0020 §5); a chip's label is its job title. */
|
|
29
|
+
export type ConverseAction = {
|
|
30
|
+
label?: string;
|
|
31
|
+
} & ({
|
|
32
|
+
type: "chip";
|
|
33
|
+
jobId: string;
|
|
34
|
+
title: string;
|
|
35
|
+
badge?: string | null;
|
|
36
|
+
steps?: number;
|
|
37
|
+
} | {
|
|
38
|
+
type: "plus_menu";
|
|
39
|
+
items: PlusItem[];
|
|
40
|
+
menu?: ConverseMenuItem[];
|
|
41
|
+
} | {
|
|
42
|
+
type: "other_need" | "guide_next" | "guide_back" | "didnt_work" | "consent" | "send" | "talk_to_assistant";
|
|
43
|
+
});
|
|
44
|
+
/** Runtime over-masking for one detector rule (contract §2 `overMasked`): a count, never a value. */
|
|
45
|
+
export interface OverMaskCount {
|
|
46
|
+
rule: string;
|
|
47
|
+
count: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ConverseRequest {
|
|
50
|
+
siteKey: string;
|
|
51
|
+
conversationId: string;
|
|
52
|
+
turnId: string;
|
|
53
|
+
consentGiven: boolean;
|
|
54
|
+
context: FeedbackContext;
|
|
55
|
+
schema: typeof TURN_SCHEMA;
|
|
56
|
+
payload: {
|
|
57
|
+
input: TurnInput;
|
|
58
|
+
draft?: FeedbackMessage;
|
|
59
|
+
team?: FeedbackTeam;
|
|
60
|
+
};
|
|
61
|
+
/** A reviewer session (as v1 `SubmitFeedbackRequest.reviewerToken`). */
|
|
62
|
+
reviewerToken?: string;
|
|
63
|
+
/** The host's signed opaque user id (C0a §4), sent with consented turns only. */
|
|
64
|
+
userId?: string;
|
|
65
|
+
userIdExp?: number;
|
|
66
|
+
userIdSig?: string;
|
|
67
|
+
overMasked?: OverMaskCount[];
|
|
68
|
+
}
|
|
69
|
+
export interface ConverseResponse {
|
|
70
|
+
state: string;
|
|
71
|
+
machine: string;
|
|
72
|
+
messages: ConverseMessage[];
|
|
73
|
+
actions: ConverseAction[];
|
|
74
|
+
filed?: {
|
|
75
|
+
feedbackId?: string;
|
|
76
|
+
kind?: string;
|
|
77
|
+
};
|
|
78
|
+
requiresConsent: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Why a turn failed, in the words the shell shows. */
|
|
81
|
+
export type FailureKind = "invalid" | "busy" | "unavailable";
|
|
82
|
+
export declare class ConverseFailure extends Error {
|
|
83
|
+
readonly kind: FailureKind;
|
|
84
|
+
readonly status: number;
|
|
85
|
+
constructor(kind: FailureKind, status: number);
|
|
86
|
+
}
|
|
87
|
+
/** A UUIDv4 (contract §2): `crypto.randomUUID` where it exists, else from random bytes. */
|
|
88
|
+
export declare function uuid4(): string;
|
|
89
|
+
/** The failure a status maps to: 429 busy, 400 invalid, everything else (503, network) unavailable. */
|
|
90
|
+
export declare function failureOf(err: unknown): ConverseFailure;
|
|
91
|
+
export interface ConverseTransport {
|
|
92
|
+
/** POSTs one turn; rejects with a {@link ConverseFailure}. */
|
|
93
|
+
turn(req: ConverseRequest): Promise<ConverseResponse>;
|
|
94
|
+
}
|
|
95
|
+
export declare function converseTransport(endpoint: string, fetchImpl?: typeof fetch): ConverseTransport;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The `widget.ui.*` keys the chat shows (the full key is `widget.ui.<UiKey>`). */
|
|
2
|
+
export type UiKey = "add_to_message" | "allow" | "attachment.image" | "attachment.screenshot" | "attachments" | "cancel" | "card.step" | "card.step_of" | "chip.no_guide" | "chip.one_step" | "chip.steps" | "close" | "consent_line" | "context.build" | "context.page" | "context.persona" | "context.step" | "context.title" | "conversation" | "draw.added.arrow" | "draw.added.box" | "draw.added.circle" | "draw.arrow" | "draw.box" | "draw.circle" | "draw.clear" | "draw.cleared" | "draw.done" | "draw.hint" | "draw.image" | "draw.keys" | "draw.removed_last" | "draw.shape_limit" | "draw.stage" | "draw.title" | "draw.tools" | "draw.undo" | "error.busy" | "error.invalid" | "error.unavailable" | "greeting" | "input.paused" | "input.placeholder" | "input.tap_only" | "launcher" | "message" | "note.attachment_limit" | "note.capture_unavailable" | "note.file_read" | "note.file_type" | "note.masking_failed" | "note.no_name" | "note.signed_out" | "note.unmet" | "note.upload_failed" | "other_need" | "point.hint" | "point.label" | "pointed_at" | "remove" | "report_problem" | "send" | "speaker.assistant" | "speaker.you" | "subtitle" | "suggestions" | "team.severity" | `team.severity.${"low" | "medium" | "high" | "critical"}` | "team.title" | "team.verdict" | `team.verdict.${"unreviewed" | "polished" | "needs_polish" | "broken"}` | "title" | "try_again";
|
|
3
|
+
/** A `widget.ui.*` text with its `{name}` placeholders filled; "" when the site's copy lacks it. */
|
|
4
|
+
export type Copy = (key: UiKey, params?: Record<string, string | number>) => string;
|
|
5
|
+
/** The launcher's accessible name when the site's copy could not be read (the only literal). */
|
|
6
|
+
export declare const LAST_RESORT_LAUNCHER = "Help";
|
|
7
|
+
/** The {@link Copy} over a `GetWidgetConfig` `copy` map (absent: every key is ""). */
|
|
8
|
+
export declare function copyOf(map: Readonly<Record<string, string>> | undefined): Copy;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FeedbackContext, FeedbackDevice, FeedbackRemovedChip } from "../../schemas/feedback";
|
|
2
|
+
import type { ConverseAction } from "./converse";
|
|
3
|
+
import type { Copy } from "./copy";
|
|
4
|
+
export type Chip = Extract<ConverseAction, {
|
|
5
|
+
type: "chip";
|
|
6
|
+
}>;
|
|
7
|
+
/** Job chips whose title holds every typed word (case-insensitive); the query is never sent. */
|
|
8
|
+
export declare function filterChips(chips: readonly Chip[], query: string): Chip[];
|
|
9
|
+
/** A chip's guide length: its structured `steps` (contract #218), never its display `badge`. */
|
|
10
|
+
export declare function chipSteps(chip: Chip): number | undefined;
|
|
11
|
+
/** The browser family (never the full user agent). */
|
|
12
|
+
export declare function browserName(ua: string): string;
|
|
13
|
+
/** A removable chip of "Sent with this report". `removable: false` chips are shown, not sent as context. */
|
|
14
|
+
export interface ContextChip {
|
|
15
|
+
key: "job" | "step" | FeedbackRemovedChip;
|
|
16
|
+
label: string;
|
|
17
|
+
removable: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** What the report carries about the page and the user's place in it. */
|
|
20
|
+
export interface ReportFacts {
|
|
21
|
+
pagePath: string;
|
|
22
|
+
persona?: string | undefined;
|
|
23
|
+
browser?: string | undefined;
|
|
24
|
+
device?: FeedbackDevice | undefined;
|
|
25
|
+
viewport?: {
|
|
26
|
+
w: number;
|
|
27
|
+
h: number;
|
|
28
|
+
} | undefined;
|
|
29
|
+
build?: string | undefined;
|
|
30
|
+
job?: string | undefined;
|
|
31
|
+
step?: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The chips of "Sent with this report", minus what the user removed (labels from the site's copy). */
|
|
34
|
+
export declare function contextChips(f: ReportFacts, removed: ReadonlySet<string>, t: Copy): ContextChip[];
|
|
35
|
+
/** The feedback/v2 `context` of a turn: removed chips' values are absent and listed in `removed`. */
|
|
36
|
+
export declare function turnContext(f: ReportFacts, removed: ReadonlySet<string>): FeedbackContext;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { FeedbackSeverity, FeedbackShape, FeedbackVerdict } from "../../schemas/feedback";
|
|
2
|
+
import { type ConverseAction, type ConverseMenuItem, type ConverseTransport, type FailureKind } from "./converse";
|
|
3
|
+
import type { Copy } from "./copy";
|
|
4
|
+
import { type Chip, type ContextChip, type ReportFacts } from "./model";
|
|
5
|
+
export type Entry = {
|
|
6
|
+
kind: "assistant";
|
|
7
|
+
text: string;
|
|
8
|
+
copyId: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "user";
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "card";
|
|
14
|
+
job: string;
|
|
15
|
+
step: number;
|
|
16
|
+
of?: number | undefined;
|
|
17
|
+
title?: string | undefined;
|
|
18
|
+
instruction?: string | undefined;
|
|
19
|
+
live: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "note";
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
/** A draft screenshot or file ("Show us where", "Attach a file"). */
|
|
25
|
+
export interface Attachment {
|
|
26
|
+
id: string;
|
|
27
|
+
/** An image URL for the thumbnail (a `blob:` URL of the masked capture). */
|
|
28
|
+
thumbnail: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
/** Set once uploaded: only uploaded attachments travel with a turn. */
|
|
31
|
+
screenshotId?: string;
|
|
32
|
+
/** Shapes drawn over the image, normalised (feedback/v2 `attachments[].shapes`). */
|
|
33
|
+
shapes?: FeedbackShape[];
|
|
34
|
+
/** Uploads the masked image; called only after consent. Resolves its `screenshotId`. */
|
|
35
|
+
upload?: () => Promise<string | undefined>;
|
|
36
|
+
/** Frees the thumbnail when the attachment leaves the draft. */
|
|
37
|
+
release?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/** "Point at it": the element's tflo id (feedback/v2 message `anchor`), never its values. */
|
|
40
|
+
export interface DraftAnchor {
|
|
41
|
+
tflowId: string;
|
|
42
|
+
}
|
|
43
|
+
/** Screenshots per message (feedback/v2 `attachments` maxItems). */
|
|
44
|
+
export declare const MAX_ATTACHMENTS = 5;
|
|
45
|
+
export interface TeamDetails {
|
|
46
|
+
verdict?: FeedbackVerdict;
|
|
47
|
+
severity?: FeedbackSeverity;
|
|
48
|
+
}
|
|
49
|
+
export interface SessionDeps {
|
|
50
|
+
siteKey: string;
|
|
51
|
+
/** A reviewer session: Team details travel with each turn as turn/v1 `team`. */
|
|
52
|
+
reviewer?: boolean;
|
|
53
|
+
transport: ConverseTransport;
|
|
54
|
+
/** The site's widget copy (`widget.ui.*`, ADR 0020 §5). */
|
|
55
|
+
t: Copy;
|
|
56
|
+
/** Page facts for the report's context, read at each turn. */
|
|
57
|
+
facts(): ReportFacts;
|
|
58
|
+
hasConsent(): boolean;
|
|
59
|
+
giveConsent(): void;
|
|
60
|
+
}
|
|
61
|
+
export declare class ChatSession {
|
|
62
|
+
private readonly deps;
|
|
63
|
+
/** New when a closed conversation is reopened. */
|
|
64
|
+
conversationId: string;
|
|
65
|
+
entries: Entry[];
|
|
66
|
+
state: string;
|
|
67
|
+
actions: ConverseAction[];
|
|
68
|
+
requiresConsent: boolean;
|
|
69
|
+
pending: boolean;
|
|
70
|
+
error: FailureKind | undefined;
|
|
71
|
+
/** Free text is off: Jev is down (a 503, or the server's tap-only clarify). Chips still work. */
|
|
72
|
+
tapOnly: boolean;
|
|
73
|
+
/** Set when a send was held back for consent: the view moves focus to Allow. */
|
|
74
|
+
consentAsked: boolean;
|
|
75
|
+
filed: string | undefined;
|
|
76
|
+
attachments: Attachment[];
|
|
77
|
+
anchor: DraftAnchor | undefined;
|
|
78
|
+
readonly removed: Set<string>;
|
|
79
|
+
team: TeamDetails;
|
|
80
|
+
private job;
|
|
81
|
+
private step;
|
|
82
|
+
private last;
|
|
83
|
+
/** Closed by the user: the next open starts a new conversation. */
|
|
84
|
+
private ended;
|
|
85
|
+
private opening;
|
|
86
|
+
/** Runtime over-masking since the last consented turn, per detector rule (counts only; the
|
|
87
|
+
* capture chunk adds to it). They travel with the next consented turn as `overMasked`. */
|
|
88
|
+
readonly overMask: Map<string, number>;
|
|
89
|
+
private readonly listeners;
|
|
90
|
+
private consent;
|
|
91
|
+
/** The site's widget copy. */
|
|
92
|
+
readonly t: Copy;
|
|
93
|
+
constructor(deps: SessionDeps);
|
|
94
|
+
subscribe(fn: () => void): () => void;
|
|
95
|
+
private emit;
|
|
96
|
+
/** The opening question with the site's known jobs (no turn is sent to show it). */
|
|
97
|
+
start(chips: Chip[]): void;
|
|
98
|
+
/** The user closed the chat (✕, Esc). A conversation the server knows ends with a `cancel`
|
|
99
|
+
* turn (state `closed`; nothing is filed). Fire and forget: its failure shows nothing. */
|
|
100
|
+
close(): void;
|
|
101
|
+
/** Opening the chat again after a close starts a new conversation (consent is kept). */
|
|
102
|
+
reopen(): void;
|
|
103
|
+
offers(type: ConverseAction["type"]): boolean;
|
|
104
|
+
/** The server's label of an action on offer ("" when it is not offered or has none). */
|
|
105
|
+
label(type: ConverseAction["type"]): string;
|
|
106
|
+
chips(): Chip[];
|
|
107
|
+
/** The "+" menu with the server's labels and hints, in `items` order. */
|
|
108
|
+
plusItems(): ConverseMenuItem[];
|
|
109
|
+
/** The consent line shows: the server offers consent or needs it, and the user has not allowed. */
|
|
110
|
+
needsConsent(): boolean;
|
|
111
|
+
allow(): void;
|
|
112
|
+
contextChips(): ContextChip[];
|
|
113
|
+
removeContext(key: string): void;
|
|
114
|
+
setTeam(team: TeamDetails): void;
|
|
115
|
+
/** Team details without unset fields (turn/v1 `team` is a closed object). */
|
|
116
|
+
private teamOnWire;
|
|
117
|
+
/** Adds (or replaces) a draft attachment; false when the message already has five. */
|
|
118
|
+
addAttachment(a: Attachment): boolean;
|
|
119
|
+
removeAttachment(id: string): void;
|
|
120
|
+
setAnchor(anchor: DraftAnchor | undefined): void;
|
|
121
|
+
/** A calm line in the conversation (never sent). */
|
|
122
|
+
note(text: string): void;
|
|
123
|
+
/** Uploads draft images not yet uploaded, after consent only; a failed one leaves the draft. */
|
|
124
|
+
private uploadPending;
|
|
125
|
+
/** The draft message a turn carries (after consent only): uploaded images with their shapes,
|
|
126
|
+
* and the anchor. */
|
|
127
|
+
private draft;
|
|
128
|
+
pickJob(chip: Chip): void;
|
|
129
|
+
other(): void;
|
|
130
|
+
next(): void;
|
|
131
|
+
back(): void;
|
|
132
|
+
didntWork(): void;
|
|
133
|
+
talk(): void;
|
|
134
|
+
/** `Journeeze.feedback()`: the conversation opens at "Report a problem". */
|
|
135
|
+
reportProblem(): void;
|
|
136
|
+
/** A typed message. Held back (false) while consent is needed, or while typing is off. */
|
|
137
|
+
sendText(text: string): boolean;
|
|
138
|
+
/** "Send report" (the server's `send` action). */
|
|
139
|
+
sendReport(): boolean;
|
|
140
|
+
/** Sends the failed turn again with the same `turnId` (the collector de-duplicates it). */
|
|
141
|
+
retry(): void;
|
|
142
|
+
private askConsent;
|
|
143
|
+
private facts;
|
|
144
|
+
private run;
|
|
145
|
+
private exec;
|
|
146
|
+
private send;
|
|
147
|
+
private apply;
|
|
148
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHAT_CSS = "\n:host{all:initial;--c:#F7F7F5;--s:#FFF;--r:#F0F0EC;--i:#1D2024;--m:#5D636B;--f:#6C727B;--l:rgb(29 32 36/12%);--a:#3D63C9;--ai:#FFF;--as:rgb(61 99 201/10%);--sh:0 1px 3px rgb(0 0 0/12%),0 4px 12px rgb(0 0 0/8%);\nfont:400 13px/1.45 Inter,system-ui,-apple-system,\"Segoe UI\",sans-serif;color:var(--i);-webkit-font-smoothing:antialiased}\n@media (prefers-color-scheme:dark){:host{--c:#111316;--s:#181B1F;--r:#20242A;--i:#E8EAED;--m:#A3A9B2;--f:#8A919B;--l:rgb(232 234 237/12%);--a:#7F9CF0;--ai:#111316;--as:rgb(127 156 240/14%)}}\n*,*::before,*::after{box-sizing:border-box}\nbutton,input,select{font:inherit;color:inherit}\nbutton{cursor:pointer}\nbutton:disabled,input:disabled{cursor:not-allowed;opacity:.55}\n:focus-visible{outline:2px solid var(--a);outline-offset:2px}\n[hidden]{display:none!important}\n.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.launcher{position:fixed;right:24px;bottom:24px;z-index:2147483646;width:56px;height:56px;border-radius:999px;border:0;background:var(--a);color:var(--ai);font-size:24px;font-weight:600;box-shadow:var(--sh)}\n.panel{position:fixed;right:24px;bottom:92px;z-index:2147483646;width:min(360px,calc(100vw - 48px));height:min(600px,calc(100vh - 116px));display:flex;flex-direction:column;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh);overflow:hidden}\n.head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;border-bottom:1px solid var(--l);background:var(--c)}\n.head h2{margin:0;font-size:13px;font-weight:600}\n.head p{margin:0;font-size:12px;color:var(--f)}\n.x{width:44px;height:44px;border:0;border-radius:6px;background:transparent;color:var(--m);font-size:20px}\n.log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}\n.msg{max-width:85%;padding:8px 12px;border:1px solid var(--l);border-radius:12px;white-space:pre-wrap;overflow-wrap:anywhere}\n.as{align-self:flex-start;background:var(--s);border-bottom-left-radius:2px}\n.us{align-self:flex-end;background:var(--as);border-bottom-right-radius:2px}\n.note{align-self:flex-start;margin:0;font-size:12px;color:var(--m)}\n.card{align-self:flex-start;width:90%;padding:12px;border:1px solid var(--l);border-radius:10px;background:var(--c)}\n.card h3{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--a)}\n.card p{margin:0 0 8px;color:var(--m)}\n.row{display:flex;gap:8px;flex-wrap:wrap}\n.btn{min-height:44px;padding:0 16px;border:1px solid var(--l);border-radius:6px;background:var(--s)}\n.pri{background:var(--a);border-color:var(--a);color:var(--ai);font-weight:600}\n.link{min-height:44px;padding:0 4px;border:0;background:none;color:var(--a);text-decoration:underline}\n.foot{border-top:1px solid var(--l);padding:12px;display:flex;flex-direction:column;gap:8px;background:var(--s)}\n.dyn{display:flex;flex-direction:column;gap:8px}.dyn:empty{display:none}\n.chips{display:flex;flex-wrap:wrap;gap:6px}\n.chip{min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:999px;background:var(--s);color:var(--m)}\n.chip.job{border-color:var(--a);color:var(--a)}\n.err{margin:0;padding:8px;border-radius:6px;background:var(--r);color:var(--i)}\n.consent{margin:0;font-size:12px;color:var(--m)}\n.consent.ask{color:var(--i);font-weight:600}\ndetails{font-size:12px;color:var(--m)}\nsummary{cursor:pointer;min-height:24px}\n.ctx{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;padding:0;list-style:none}\n.ctx li{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);color:var(--i)}\n.ctx li.fixed{padding-right:8px;min-height:32px}\n.ctx button,.att button{width:32px;height:32px;border:0;background:none;color:var(--m)}\n.team{display:flex;gap:8px;margin-top:6px}\n.team label{display:flex;flex-direction:column;gap:2px;color:var(--i)}\n.team select{min-height:32px;border:1px solid var(--l);border-radius:6px;background:var(--s)}\n.atts{display:flex;flex-wrap:wrap;gap:8px;margin:0;padding:0;list-style:none}\n.att{position:relative;width:64px;height:48px;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r)}\n.att img{width:100%;height:100%;object-fit:cover}\n.pt{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);font-size:12px;max-width:100%;overflow-wrap:anywhere}\n.pt button{width:32px;height:32px;border:0;background:none;color:var(--m)}\n.att button{position:absolute;top:0;right:0;background:var(--i);color:var(--s);border-radius:0 0 0 6px}\n.comp{position:relative;display:flex;gap:6px;align-items:center}\n.comp input{flex:1;min-width:0;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--c)}\n.ico{width:44px;height:44px;flex:none;border:1px solid var(--l);border-radius:6px;background:var(--s);font-size:18px}\n.send{background:var(--a);border-color:var(--a);color:var(--ai)}\n.menu{position:absolute;left:0;right:0;bottom:52px;z-index:1;padding:4px;margin:0;list-style:none;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh)}\n.menu button{display:block;width:100%;min-height:44px;padding:4px 12px;border:0;border-radius:6px;background:none;text-align:left}\n.menu button:hover,.menu button:focus-visible{background:var(--c)}\n.menu small{display:block;color:var(--f)}\n.dots{align-self:flex-start;color:var(--f)}\n@media (max-width:640px){.panel{inset:0;width:auto;height:auto;border-radius:0;border:0}.launcher[aria-expanded=true]{display:none}}\n@media (prefers-reduced-motion:reduce){*{transition-duration:1ms!important}}\n";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PlusItem } from "./converse";
|
|
2
|
+
import type { ChatSession } from "./session";
|
|
3
|
+
export interface ChatViewOptions {
|
|
4
|
+
/** A reviewer session (the host passed a reviewer token): shows "Team details". */
|
|
5
|
+
reviewer: boolean;
|
|
6
|
+
/** A "+" menu item was chosen (HC8b wires "Show us where" and friends here). */
|
|
7
|
+
onPlusItem(item: PlusItem): void;
|
|
8
|
+
}
|
|
9
|
+
export interface ChatView {
|
|
10
|
+
open(): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
isOpen(): boolean;
|
|
13
|
+
/** Hides the chat while the user captures or points at the page; the returned function brings
|
|
14
|
+
* it back with focus on the composer's "+" (or the input). */
|
|
15
|
+
suspend(): () => void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function chatView(root: ShadowRoot, session: ChatSession, opts: ChatViewOptions): ChatView;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MountOptions } from "../loader";
|
|
2
|
+
import { type ConverseTransport } from "./shell/converse";
|
|
3
|
+
/** {@link converseTransport} with the caller's identity on each turn, read live from the mount
|
|
4
|
+
* options (`setUser` can change the id). */
|
|
5
|
+
export declare function liveTransport(endpoint: string, options: MountOptions, fetchImpl?: typeof fetch): ConverseTransport;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -15,3 +15,20 @@ export declare function checkContext(next: Readonly<JourneezeContext>): Journeez
|
|
|
15
15
|
* B7) drops it entirely, in the feedback channel.
|
|
16
16
|
*/
|
|
17
17
|
export declare function sentPath(href: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* The host's signature over the user id (contract §4, v1.3; the widget's uploads and feedback,
|
|
20
|
+
* the chat's Converse turns), only while it is well formed and
|
|
21
|
+
* unexpired; otherwise the id travels unsigned (sites that require signed identity then treat
|
|
22
|
+
* the request as anonymous). Fixed into the request when it is written, like the id.
|
|
23
|
+
*/
|
|
24
|
+
export declare function signedIdentity(o: {
|
|
25
|
+
userIdSig?: string | undefined;
|
|
26
|
+
userIdExp?: number | undefined;
|
|
27
|
+
signature?: {
|
|
28
|
+
sig: string;
|
|
29
|
+
exp: number;
|
|
30
|
+
} | "" | undefined;
|
|
31
|
+
}): {
|
|
32
|
+
userIdSig?: string;
|
|
33
|
+
userIdExp?: number;
|
|
34
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetGuideResponse, HelpIndexEntry } from "../../types";
|
|
1
|
+
import type { GetGuideResponse, HelpIndexEntry, HelpJobEntry, WireJobRequest } from "../../types";
|
|
2
2
|
import type { AnchorResult, StepTarget } from "./highlight";
|
|
3
3
|
export type CheckinAnswer = "understood" | "confused";
|
|
4
4
|
export type CheckinPhase = "idle" | "asking" | "needs-consent" | "sending";
|
|
@@ -41,6 +41,8 @@ export type HelpState = {
|
|
|
41
41
|
query: string;
|
|
42
42
|
results: HelpIndexEntry[];
|
|
43
43
|
total: number;
|
|
44
|
+
/** The site's jobs ("What are you trying to do?", P4e1), in index order; absent or empty: none. */
|
|
45
|
+
jobs?: HelpJobEntry[] | undefined;
|
|
44
46
|
/** A request in progress (absent: idle). */
|
|
45
47
|
signal?: SignalPhase | undefined;
|
|
46
48
|
/** Result of the last callout/request send. */
|
|
@@ -85,6 +87,7 @@ export type HelpSignal = {
|
|
|
85
87
|
text: string;
|
|
86
88
|
guide?: GuideView | undefined;
|
|
87
89
|
step?: GuideStepView | undefined;
|
|
90
|
+
jobRequest?: WireJobRequest | undefined;
|
|
88
91
|
};
|
|
89
92
|
/** A signal's progress: consent first (nothing leaves the page before), then sending. */
|
|
90
93
|
export type SignalPhase = "idle" | "needs-consent" | "sending";
|
|
@@ -95,6 +98,7 @@ export interface HelpControllerDeps {
|
|
|
95
98
|
endpoint: string;
|
|
96
99
|
loadIndex(): Promise<{
|
|
97
100
|
guides?: HelpIndexEntry[];
|
|
101
|
+
jobs?: HelpJobEntry[];
|
|
98
102
|
}>;
|
|
99
103
|
loadGuide(journeyId: string): Promise<GetGuideResponse>;
|
|
100
104
|
/** Highlights the step's element by its targets (`undefined` or empty: the step names none). */
|
|
@@ -151,10 +155,15 @@ export declare class HelpController {
|
|
|
151
155
|
/** "Not now": nothing is sent (a pending callout/request is dropped; the guide continues). */
|
|
152
156
|
declineConsent(): void;
|
|
153
157
|
canSignal(): boolean;
|
|
158
|
+
/** Whether the site's consent is given (views send nothing about the reader before it). */
|
|
159
|
+
hasConsent(): boolean;
|
|
154
160
|
/** "This is confusing" on step `index`: guide, step and element only. After consent. */
|
|
155
161
|
sendCallout(stepIndex: number): void;
|
|
156
|
-
/**
|
|
157
|
-
|
|
162
|
+
/**
|
|
163
|
+
* "I couldn't find how to …" (or help's "Something else") in the reader's words, after
|
|
164
|
+
* consent; never the raw query. `jobRequest` (index only): the "so you can…" answer and job.
|
|
165
|
+
*/
|
|
166
|
+
sendRequest(text: string, jobRequest?: WireJobRequest): void;
|
|
158
167
|
private signal;
|
|
159
168
|
private patchSignal;
|
|
160
169
|
private sendSignalNow;
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import type { CheckinRequest, HelpController } from "./controller";
|
|
2
|
+
/** The answer to "Got it done?" (engagement.proto `JobAnswer`). */
|
|
3
|
+
export type JobAnswer = "YES" | "PARTLY" | "NO";
|
|
4
|
+
/**
|
|
5
|
+
* A job engagement event (P4e1, ADR 0014 addendum): the job's id and the entry version the reader
|
|
6
|
+
* saw, plus the answer for an outcome. Never text: "Something else" is feedback, not an event.
|
|
7
|
+
* `persona` (engagement.proto field 13, follow-up 21) is the host's `persona` context id, which
|
|
8
|
+
* the jobs view adds when it has the context-id shape (`withPersona`), so answers can be read per
|
|
9
|
+
* job × persona.
|
|
10
|
+
*/
|
|
11
|
+
export type JobEvent = {
|
|
12
|
+
event: "PICKED" | "NOT_POSSIBLE";
|
|
13
|
+
jobId: string;
|
|
14
|
+
jobVersion?: string | undefined;
|
|
15
|
+
persona?: string | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
event: "OUTCOME";
|
|
18
|
+
jobId: string;
|
|
19
|
+
jobVersion?: string | undefined;
|
|
20
|
+
persona?: string | undefined;
|
|
21
|
+
answer: JobAnswer;
|
|
22
|
+
harder?: boolean | undefined;
|
|
23
|
+
};
|
|
2
24
|
export interface TelemetryHook {
|
|
3
25
|
start(): void;
|
|
4
26
|
checkin(req: CheckinRequest): void;
|
|
27
|
+
/** A job event; dropped when telemetry was never started (no consent yet). */
|
|
28
|
+
job(e: JobEvent): void;
|
|
5
29
|
/** `discard` (a logout): drop queued events instead of sending them. */
|
|
6
30
|
stop(discard?: boolean): void;
|
|
7
31
|
}
|
|
@@ -3,6 +3,7 @@ import { type JourneezeContext, type SubmitFeedbackRequest, type WireFeedbackCon
|
|
|
3
3
|
import { type CheckinRequest, type GuideStepView, type GuideView, type HelpSignal } from "./controller";
|
|
4
4
|
import { type HelpView } from "./panel";
|
|
5
5
|
export { HelpController, isHelpDisabled, toView } from "./controller";
|
|
6
|
+
export type { JobAnswer, JobEvent } from "./events";
|
|
6
7
|
export type { CheckinAnswer, CheckinPhase, CheckinRequest, GuideStepView, GuideView, HelpControllerDeps, HelpListener, HelpSignal, HelpState, SendOutcome, SignalPhase } from "./controller";
|
|
7
8
|
export { MAX_REQUEST_CHARS } from "./controller";
|
|
8
9
|
export { HelpClient } from "./client";
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { HelpController } from "./controller";
|
|
2
|
+
import type { JobEvent } from "./events";
|
|
3
|
+
import type { Routed } from "./routing";
|
|
2
4
|
export interface HelpViewOptions {
|
|
3
5
|
/** The consent copy to show before the first check-in is sent (the site's or the default). */
|
|
4
6
|
consentText(): Promise<string>;
|
|
7
|
+
/** The host's `persona` context id, read live (orders "Common for you"). */
|
|
8
|
+
persona?(): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* A job event (P4e1). Help forwards it to telemetry only after consent, with help on and
|
|
11
|
+
* without Global Privacy Control; otherwise it is dropped. Never carries text.
|
|
12
|
+
*/
|
|
13
|
+
jobEvent?(e: JobEvent): void;
|
|
14
|
+
/** Adds a stylesheet to help's shadow root (with the host's CSP nonce): lazily loaded parts. */
|
|
15
|
+
addStyle?(css: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Intent routing (P6d): the reader's "Something else" words → a job and its guide, or
|
|
18
|
+
* `undefined`. Sends only after consent, to a reader allowed to send requests; never rejects.
|
|
19
|
+
*/
|
|
20
|
+
routeIntent?(text: string): Promise<Routed | undefined>;
|
|
5
21
|
}
|
|
6
22
|
/** A view renders the controller's state into the help's closed shadow root. */
|
|
7
23
|
export type HelpView = (root: ShadowRoot, controller: HelpController, options: HelpViewOptions) => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Longest text routed, in characters (the collector's limit). */
|
|
2
|
+
export declare const MAX_ROUTE_CHARS = 500;
|
|
3
|
+
/** How long the reader waits for a route before their request path is offered as is. */
|
|
4
|
+
export declare const ROUTE_TIMEOUT_MS = 6000;
|
|
5
|
+
export interface RouteDeps {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
siteKey: string;
|
|
8
|
+
reviewerToken?: string | undefined;
|
|
9
|
+
/** The site's consent, read on every call. */
|
|
10
|
+
hasConsent(): boolean;
|
|
11
|
+
/** Whether this reader may send requests at all. */
|
|
12
|
+
canSignal(): boolean;
|
|
13
|
+
fetchImpl?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
/** A routed job: its id and its guide for any persona (the view prefers the persona's guide). */
|
|
16
|
+
export interface Routed {
|
|
17
|
+
jobId: string;
|
|
18
|
+
journeyId?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Routes `text` to a job, or resolves `undefined` (never rejects). */
|
|
21
|
+
export declare function routeIntent(deps: RouteDeps, text: string): Promise<Routed | undefined>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HelpController, HelpState } from "../../core/controller";
|
|
2
|
+
import type { HelpViewOptions } from "../../core/panel";
|
|
3
|
+
type Child = Node | string | false | undefined;
|
|
4
|
+
/** What the styled panel lends the jobs view (so the jobs chunk does not repeat it). */
|
|
5
|
+
export interface JobsKit {
|
|
6
|
+
controller: HelpController;
|
|
7
|
+
options: HelpViewOptions;
|
|
8
|
+
el<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Record<string, string>, ...children: Child[]): HTMLElementTagNameMap[K];
|
|
9
|
+
button(label: string, onClick: () => void, attrs?: Record<string, string>): HTMLButtonElement;
|
|
10
|
+
/** The shared consent group ("Allow and send" / "Not now"). */
|
|
11
|
+
consentGroup(): HTMLElement;
|
|
12
|
+
/** Re-renders the panel after a change local to the jobs view. */
|
|
13
|
+
rerender(): void;
|
|
14
|
+
/** The guide view's wording of a check-in send outcome. */
|
|
15
|
+
checkinNotice: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export interface JobsUi {
|
|
18
|
+
/** Whether the jobs view renders this state (the index with jobs, or the end of a job's guide). */
|
|
19
|
+
owns(s: HelpState): boolean;
|
|
20
|
+
content(s: HelpState): Child[];
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function jobsUi(kit: JobsKit): JobsUi;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HelpJobEntry } from "../../../types";
|
|
2
|
+
import type { JobEvent } from "../../core/events";
|
|
3
|
+
/** A job with an id and a title (the controller drops entries without either). */
|
|
4
|
+
export type Job = HelpJobEntry & {
|
|
5
|
+
jobId: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `HelpJobEntry.common_for`: the jobs common for `persona` first ("Common for you"), the rest
|
|
10
|
+
* after ("More"), each in index order. Without a persona every job is under "More".
|
|
11
|
+
*/
|
|
12
|
+
export declare function jobsForPersona(jobs: readonly Job[], persona: string | undefined): {
|
|
13
|
+
common: Job[];
|
|
14
|
+
more: Job[];
|
|
15
|
+
};
|
|
16
|
+
/** The guide that answers `job` for `persona`: its persona guide, else the job's own; none: no guide yet. */
|
|
17
|
+
export declare function guideFor(job: Job, persona: string | undefined): {
|
|
18
|
+
journeyId: string;
|
|
19
|
+
stepCount: number;
|
|
20
|
+
} | undefined;
|
|
21
|
+
/** Local filter on the job titles (every word must appear); the query is never sent. */
|
|
22
|
+
export declare function matchJobs(jobs: readonly Job[], query: string): Job[];
|
|
23
|
+
/** A host `persona` context id the collector accepts on job events (`^[a-z0-9._:-]{1,96}$`). */
|
|
24
|
+
export declare const JOB_PERSONA: RegExp;
|
|
25
|
+
/**
|
|
26
|
+
* The job event with the host's persona (engagement.proto `persona`, follow-up 21), so answers
|
|
27
|
+
* can be read per job × persona. Only a context id is added: anything else is left off, so an
|
|
28
|
+
* out-of-shape persona never refuses the whole batch. The collector keeps it only when it names
|
|
29
|
+
* one of the project's catalog personas; it is never a user, session or device id.
|
|
30
|
+
*/
|
|
31
|
+
export declare function withPersona(e: JobEvent, persona: string | undefined): JobEvent;
|
|
32
|
+
/** "1 step", "3 steps"; nothing without steps. */
|
|
33
|
+
export declare function stepsLabel(n: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const JOBS_CSS = "\n:host { --jz-polish:#9A6412; --jz-broken:#B42318; }\n@media (prefers-color-scheme: dark) { :host { --jz-polish:#E0A54A; --jz-broken:#F07B70; } }\n.head-title { flex:1; display:flex; align-items:baseline; gap:8px; min-width:0; }\n.mono { font:11px/1.4 ui-monospace, \"JetBrains Mono\", monospace; color:var(--jz-faint); white-space:nowrap; }\n.panel h3 { margin:12px 0 4px; padding:0 12px; font-size:11px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--jz-faint); }\n.panel .jobs ul { margin:0; }\n.panel .jobs li { margin:0 0 2px; }\n.panel button.job { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; min-height:48px;\n padding:10px 12px; border:1px solid transparent; border-radius:6px; background:transparent; text-align:left; font-weight:500;\n transition: background 180ms ease-out, border-color 180ms ease-out; }\n.panel button.job:hover { background:var(--jz-raised); border-color:var(--jz-rule); }\n.job .dim { color:var(--jz-faint); }\n.chip { flex:none; padding:2px 6px; border-radius:4px; background:var(--jz-accent-soft); color:var(--jz-accent); font-size:10px; font-weight:600; }\n.chip.none { background:var(--jz-raised); color:var(--jz-muted); }\n.jobs-foot { margin-top:8px; padding-top:8px; border-top:1px solid var(--jz-rule); }\n.row .not-possible { border-color:var(--jz-confused); color:var(--jz-confused); }\n.else label { display:block; margin:12px 0 6px; font-size:11px; font-weight:500; color:var(--jz-faint); }\n.else textarea { display:block; width:100%; min-height:88px; padding:8px 12px; border:1px solid var(--jz-rule); border-radius:6px;\n background:var(--jz-canvas); color:var(--jz-ink); font:inherit; resize:vertical; }\n.note { margin:12px 0; padding:8px 12px; border-radius:6px; background:var(--jz-raised); color:var(--jz-muted); font-size:11px; }\n.panel .wide { width:100%; min-height:44px; padding:0 16px; border:1px solid var(--jz-accent); border-radius:6px;\n background:var(--jz-accent); color:var(--jz-accent-ink); font-weight:500; }\n.route { margin:12px 0; padding:12px; border:1px solid var(--jz-accent); border-radius:6px; background:var(--jz-accent-soft); }\n.route p { margin:0 0 4px; }\n.done .progress-fill { width:100%; background:var(--jz-polished); }\n.answers { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; margin:12px 0 16px; }\n.answers button { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; min-height:64px;\n border:1px solid var(--jz-rule); border-radius:6px; background:var(--jz-surface); font-size:12px; font-weight:500;\n transition: background 180ms ease-out, border-color 180ms ease-out; }\n.answers button:hover { background:var(--jz-raised); }\n.answers button[aria-pressed=\"true\"] { border-color:var(--jz-accent); background:var(--jz-accent-soft); box-shadow:inset 0 0 0 1px var(--jz-accent); }\n.answers svg { width:18px; height:18px; }\n.a-YES svg { color:var(--jz-polished); }\n.a-PARTLY svg { color:var(--jz-polish); }\n.a-NO svg { color:var(--jz-broken); }\n.harder { padding-top:12px; border-top:1px solid var(--jz-rule); }\n.harder label { display:flex; align-items:center; gap:8px; min-height:44px; color:var(--jz-muted); font-weight:500; cursor:pointer; }\n.panel .harder input { width:16px; height:16px; min-height:0; margin:0; padding:0; accent-color:var(--jz-accent); }\n.harder p { margin:0; }\n@media (max-width: 480px) {\n .panel { left:0; right:0; bottom:0; width:100%; max-height:85vh; border-radius:10px 10px 0 0;\n padding-bottom:calc(16px + env(safe-area-inset-bottom, 0px)); }\n}\n";
|
package/dist/types/loader.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface MountedWidget {
|
|
|
14
14
|
unmount(discard?: boolean): void;
|
|
15
15
|
/** Called after the host changed the context (route or journey step changes). */
|
|
16
16
|
contextChanged?(): void;
|
|
17
|
+
/** The chat (SDK 2.x): open at "Report a problem" (`feedback()`). */
|
|
18
|
+
report?(): void;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* What a lazy chunk is mounted with: the host's options. The chunk resolves the collector base
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The detector's rule ids (a closed set: later lanes count and report these, nothing else). */
|
|
2
|
+
export declare const DETECTOR_RULES: readonly ["autocomplete_cc", "autocomplete_otp", "autocomplete_password", "input_password", "label_sensitive", "name_sensitive", "value_key_shaped", "value_card_shaped", "value_email_shaped"];
|
|
3
|
+
export type DetectorRule = (typeof DETECTOR_RULES)[number];
|
|
4
|
+
/** One flagged element: the rule that matched and where it is. Never the value. */
|
|
5
|
+
export interface DetectorHit {
|
|
6
|
+
rule: DetectorRule;
|
|
7
|
+
selector: string;
|
|
8
|
+
}
|
|
9
|
+
/** Hits per rule, for one capture or one scan. */
|
|
10
|
+
export type DetectorCounts = Partial<Record<DetectorRule, number>>;
|
|
11
|
+
/**
|
|
12
|
+
* The first rule this element matches, or `undefined`. Pure and value-free in its result: it
|
|
13
|
+
* reads attributes, labels and the element's own text only to decide, and returns only the rule.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectSensitive(el: Element): DetectorRule | undefined;
|
|
16
|
+
/** A value-free anchor for a hit: the nearest stable hook, else a short structural path. */
|
|
17
|
+
export declare function anchorSelector(el: Element): string;
|
|
18
|
+
/**
|
|
19
|
+
* Every flagged element under `root` that `isAlreadyMasked` does not already cover (subtrees of
|
|
20
|
+
* masked elements are skipped). For integration aids; captures use {@link detectSensitive}.
|
|
21
|
+
*/
|
|
22
|
+
export declare function scanSensitive(root: Element, isAlreadyMasked?: (el: Element) => boolean): DetectorHit[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DetectorHit } from "../mask-detector";
|
|
2
|
+
/** One `journeeze.finding/v1` payload (docs/contract/schemas/finding-v1.schema.json). */
|
|
3
|
+
export interface MaskFindingWire {
|
|
4
|
+
anchor?: string;
|
|
5
|
+
selector?: string;
|
|
6
|
+
pagePath: string;
|
|
7
|
+
rule: string;
|
|
8
|
+
detectedAt: string;
|
|
9
|
+
}
|
|
10
|
+
/** The detector's scan (`scanSensitive` from `../mask-detector`), passed in by the caller: the
|
|
11
|
+
* widget already holds it, so this chunk never imports the widget chunk. */
|
|
12
|
+
export type Scan = (root: Element, isAlreadyMasked: (el: Element) => boolean) => DetectorHit[];
|
|
13
|
+
export interface MaskAuditOptions {
|
|
14
|
+
scan: Scan;
|
|
15
|
+
endpoint: string;
|
|
16
|
+
siteKey: string;
|
|
17
|
+
/** The implementer's widget token (an owner's or triager's). */
|
|
18
|
+
reviewerToken: string;
|
|
19
|
+
/** Host and journey-configuration selectors: elements they cover are already masked. */
|
|
20
|
+
maskSelectors?: readonly string[];
|
|
21
|
+
fetchImpl?: typeof fetch;
|
|
22
|
+
now?: () => Date;
|
|
23
|
+
}
|
|
24
|
+
/** The page's findings, value-free. Pure apart from reading the DOM. */
|
|
25
|
+
export declare function auditPage(scan: Scan, root: Element, href: string, selectors: readonly string[], now: Date): MaskFindingWire[];
|
|
26
|
+
/** Audits the current page and submits what is new for this tab. Never throws into the host. */
|
|
27
|
+
export declare function runMaskAudit(opts: MaskAuditOptions): Promise<number>;
|
|
28
|
+
/** Test helper: forget what this tab sent. */
|
|
29
|
+
export declare function resetMaskAudit(): void;
|