@knock-ai/sdk 0.1.2 → 0.1.4
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 +27 -5
- package/dist/contract.cjs +1 -1
- package/dist/contract.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/knockai.iife.js +2 -2
- package/dist/knockai.iife.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/snippet.js +1 -1
- package/dist/snippet.js.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/types/core/bridge.d.cts +3 -2
- package/dist/types/core/bridge.d.ts +3 -2
- package/dist/types/core/bridge.d.ts.map +1 -1
- package/dist/types/core/chat-types.d.cts +78 -0
- package/dist/types/core/chat-types.d.ts +79 -0
- package/dist/types/core/chat-types.d.ts.map +1 -0
- package/dist/types/core/contract.d.cts +1 -1
- package/dist/types/core/contract.d.ts +1 -1
- package/dist/types/core/contract.d.ts.map +1 -1
- package/dist/types/core/emitter.d.cts +0 -1
- package/dist/types/core/emitter.d.ts +0 -1
- package/dist/types/core/emitter.d.ts.map +1 -1
- package/dist/types/core/index.d.cts +2 -1
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/loader.d.cts +4 -3
- package/dist/types/core/loader.d.ts +4 -3
- package/dist/types/core/loader.d.ts.map +1 -1
- package/dist/types/core/queue.d.cts +2 -2
- package/dist/types/core/queue.d.ts +2 -2
- package/dist/types/core/queue.d.ts.map +1 -1
- package/dist/types/core/types.d.cts +214 -0
- package/dist/types/core/types.d.ts +214 -0
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/version.d.cts +1 -1
- package/dist/types/core/version.d.ts +1 -1
- package/dist/types/frameworks/react/KnockLink.d.cts +15 -0
- package/dist/types/frameworks/react/KnockLink.d.ts +16 -0
- package/dist/types/frameworks/react/KnockLink.d.ts.map +1 -0
- package/dist/types/frameworks/react/index.d.cts +2 -0
- package/dist/types/frameworks/react/index.d.ts +2 -0
- package/dist/types/frameworks/react/index.d.ts.map +1 -1
- package/dist/types/testing/index.d.cts +19 -1
- package/dist/types/testing/index.d.ts +19 -1
- package/dist/types/testing/index.d.ts.map +1 -1
- package/package.json +12 -7
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Keep this file dependency-free and DOM-agnostic: it is shared by the core and
|
|
5
5
|
* every framework binding.
|
|
6
6
|
*/
|
|
7
|
+
import type { KnockChatClient } from './chat-types.js';
|
|
7
8
|
export type KnockEnvironment = 'production' | 'staging' | 'development';
|
|
8
9
|
/** Which of the vendor's two Knock tags is loaded: the website tag or the product tag. */
|
|
9
10
|
export type KnockTagSurface = 'website' | 'product';
|
|
@@ -18,6 +19,8 @@ export interface KnockInitOptions {
|
|
|
18
19
|
debug?: boolean;
|
|
19
20
|
/** Load the Knock tag from this URL instead of Knock's default location. */
|
|
20
21
|
scriptUrl?: string;
|
|
22
|
+
/** Sets up the Knock chat before it shows. The same as calling `knock.chat.configure()` first. */
|
|
23
|
+
chat?: KnockChatOptions;
|
|
21
24
|
}
|
|
22
25
|
export interface KnockIdentifyTraits {
|
|
23
26
|
email: string;
|
|
@@ -63,6 +66,182 @@ export interface KnockSchedulingHandle {
|
|
|
63
66
|
close(): void;
|
|
64
67
|
readonly status: KnockSchedulingStatus;
|
|
65
68
|
}
|
|
69
|
+
/** A scripted conversation for the chat's test mode. */
|
|
70
|
+
export type KnockChatTestScenario = 'default' | 'returning' | 'rep' | 'booking' | 'media' | 'edited' | 'send-fails' | 'rate-limited' | 'session-expired' | 'offline' | 'no-stream' | 'disabled' | 'origin-blocked' | 'captcha';
|
|
71
|
+
export interface KnockChatOpenOptions {
|
|
72
|
+
/** Opens this screen of the chat. */
|
|
73
|
+
screen?: string;
|
|
74
|
+
/** Pre-fills the message box. */
|
|
75
|
+
message?: string;
|
|
76
|
+
/** Sends this message for the visitor. Sent once per conversation. */
|
|
77
|
+
send?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Moves the chat to this magic link: it stays there for later `open()` calls until another link is
|
|
80
|
+
* set. Each link has its own conversation. In test mode it only names the scripted conversation.
|
|
81
|
+
*/
|
|
82
|
+
magicLinkId?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A click event from the DOM or a framework, so `onClick={knock.chat.open}` and `@click="knock.chat.open"`
|
|
86
|
+
* work as they are. The chat ignores it and opens as `open()` does.
|
|
87
|
+
*/
|
|
88
|
+
export interface KnockChatOpenEvent {
|
|
89
|
+
readonly type: string;
|
|
90
|
+
preventDefault(): void;
|
|
91
|
+
}
|
|
92
|
+
/** Names of the chat's built-in looks. Other names are passed through to the chat as they are. */
|
|
93
|
+
export type KnockChatPreset = 'harbor' | 'nightshift' | 'fieldbook' | 'signal' | 'terminal' | 'pixel';
|
|
94
|
+
type KnockChatSkinGroup = {
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The chat's colours, each a hex colour like `'#2346D8'`. A key you set replaces the look's value;
|
|
99
|
+
* a key you leave out keeps the look's.
|
|
100
|
+
*/
|
|
101
|
+
export interface KnockChatColors {
|
|
102
|
+
/** Your main colour: buttons and, in most looks, the visitor's bubble and the launcher. */
|
|
103
|
+
brand?: string;
|
|
104
|
+
/** Text and icons on `brand`. */
|
|
105
|
+
onBrand?: string;
|
|
106
|
+
/** Links and brand-coloured text on the chat's surfaces. */
|
|
107
|
+
brandInk?: string;
|
|
108
|
+
/** The chat's background. */
|
|
109
|
+
bg?: string;
|
|
110
|
+
/** Menus, cards, chips and code blocks. */
|
|
111
|
+
surface?: string;
|
|
112
|
+
/** Hovered items, table headers and day stamps. */
|
|
113
|
+
surfaceRaised?: string;
|
|
114
|
+
/** The main text. */
|
|
115
|
+
text?: string;
|
|
116
|
+
/** Secondary text: times, hints and placeholders. */
|
|
117
|
+
textMuted?: string;
|
|
118
|
+
/** Borders and dividers. Their width is `shape.borderWidth`. */
|
|
119
|
+
border?: string;
|
|
120
|
+
/** The visitor's bubble. */
|
|
121
|
+
userBubble?: string;
|
|
122
|
+
/** Text in the visitor's bubble. */
|
|
123
|
+
userBubbleText?: string;
|
|
124
|
+
/** The agent's bubble. */
|
|
125
|
+
agentBubble?: string;
|
|
126
|
+
/** Text in the agent's bubble. */
|
|
127
|
+
agentBubbleText?: string;
|
|
128
|
+
/** Unread badges and dots. */
|
|
129
|
+
accent?: string;
|
|
130
|
+
/** Text and icons on `accent`. */
|
|
131
|
+
onAccent?: string;
|
|
132
|
+
/** Success marks, such as a check or the live dot. */
|
|
133
|
+
positive?: string;
|
|
134
|
+
/** The keyboard focus outline. */
|
|
135
|
+
focusRing?: string;
|
|
136
|
+
/** The launcher bubble. */
|
|
137
|
+
launcherBg?: string;
|
|
138
|
+
/** The icon and label on the launcher bubble. */
|
|
139
|
+
launcherFg?: string;
|
|
140
|
+
/** The header's background. */
|
|
141
|
+
headerBg?: string;
|
|
142
|
+
/** Text and buttons in the header. */
|
|
143
|
+
headerFg?: string;
|
|
144
|
+
}
|
|
145
|
+
/** How the chat looks. Each key you set replaces that part of the look; the chat fills in the rest. */
|
|
146
|
+
export interface KnockChatSkin {
|
|
147
|
+
/** A built-in look to start from. A skin that names a preset drops the look set in your Knock tag. */
|
|
148
|
+
preset?: KnockChatPreset | (string & {});
|
|
149
|
+
mode?: 'light' | 'dark' | 'auto';
|
|
150
|
+
colors?: KnockChatColors;
|
|
151
|
+
/** The dark palette. `null` makes the chat derive one from `colors.brand`. */
|
|
152
|
+
colorsDark?: KnockChatColors | null;
|
|
153
|
+
/** The light palette of a dark look (`nightshift`), shown in light mode. */
|
|
154
|
+
colorsLight?: KnockChatColors | null;
|
|
155
|
+
typography?: KnockChatSkinGroup;
|
|
156
|
+
shape?: KnockChatSkinGroup;
|
|
157
|
+
layout?: KnockChatSkinGroup;
|
|
158
|
+
bubble?: KnockChatSkinGroup;
|
|
159
|
+
motion?: KnockChatSkinGroup;
|
|
160
|
+
direction?: 'ltr' | 'rtl';
|
|
161
|
+
responsive?: KnockChatSkinGroup;
|
|
162
|
+
/**
|
|
163
|
+
* Pictures by URL, one per place: each an `https://` or `http://` URL, or a path on your site.
|
|
164
|
+
* Anything else is ignored. Without one, or when it fails to load, the place shows what it shows
|
|
165
|
+
* with no picture. `null` clears it.
|
|
166
|
+
* - `bubble`: the bubble's picture, in place of its icon.
|
|
167
|
+
* - `wall`: the conversation's background, drawn as a soft pattern from the picture's shape. A
|
|
168
|
+
* picture from another origin needs CORS.
|
|
169
|
+
* - `header`: your logo, in the header in place of the agent's picture.
|
|
170
|
+
*/
|
|
171
|
+
assets?: {
|
|
172
|
+
bubble?: string | null;
|
|
173
|
+
wall?: string | null;
|
|
174
|
+
header?: string | null;
|
|
175
|
+
};
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
/** The chat's screens: which one it starts on, how the visitor moves between them, and what each shows. */
|
|
179
|
+
export interface KnockChatScreens {
|
|
180
|
+
start?: string;
|
|
181
|
+
nav?: 'none' | 'menu' | 'tabs';
|
|
182
|
+
items?: Array<{
|
|
183
|
+
id: string;
|
|
184
|
+
[key: string]: unknown;
|
|
185
|
+
}>;
|
|
186
|
+
}
|
|
187
|
+
/** Each key you pass replaces that key; `skin: null` clears the look set from code. Keys you leave out stay as they are. */
|
|
188
|
+
export interface KnockChatOptions {
|
|
189
|
+
/** The look: colours, type, shape, layout, bubble, motion, direction and your pictures. */
|
|
190
|
+
skin?: KnockChatSkin | null;
|
|
191
|
+
/** What opens the chat: its bubble, your page's buttons, or both. Default `'both'`. */
|
|
192
|
+
launcher?: 'bubble' | 'buttons' | 'both';
|
|
193
|
+
screens?: KnockChatScreens;
|
|
194
|
+
/** Up to 4 suggested first messages. */
|
|
195
|
+
starters?: string[];
|
|
196
|
+
brandName?: string;
|
|
197
|
+
agentName?: string;
|
|
198
|
+
/**
|
|
199
|
+
* The AI agent's picture, in the header and beside its messages: an `https://` or `http://` URL, or
|
|
200
|
+
* a path on your site. Anything else is ignored. Without it, or when it fails to load, the agent
|
|
201
|
+
* shows the first letter of `brandName`, else the spark icon. `null` clears it.
|
|
202
|
+
*/
|
|
203
|
+
agentImageUrl?: string | null;
|
|
204
|
+
/**
|
|
205
|
+
* The magic link the chat runs on, instead of the one set in your Knock tag. Setting it moves the
|
|
206
|
+
* chat to that link, even after `open()` moved it to another one; `null` goes back to the tag's
|
|
207
|
+
* link. Each link has its own conversation. The link must belong to your workspace.
|
|
208
|
+
*/
|
|
209
|
+
magicLinkId?: string | null;
|
|
210
|
+
/**
|
|
211
|
+
* Test mode: the chat runs a scripted conversation instead of your live chat. `true` runs the
|
|
212
|
+
* `'default'` scenario. Once on, it stays on for the page; `false` doesn't turn it off.
|
|
213
|
+
*/
|
|
214
|
+
test?: boolean | KnockChatTestScenario;
|
|
215
|
+
/**
|
|
216
|
+
* Shows the chat inside this element of your page instead of floating over it. The chat fills the
|
|
217
|
+
* element and is always shown: no bubble and no close button, styled by your skin. Give the
|
|
218
|
+
* element a height. A string is a CSS selector. It is looked up when you set it and when the chat
|
|
219
|
+
* loads. Set `container` again to move the chat (after a route change, for example): the
|
|
220
|
+
* conversation stays. `null` goes back to the floating chat.
|
|
221
|
+
*/
|
|
222
|
+
container?: Element | string | null;
|
|
223
|
+
/**
|
|
224
|
+
* Your own chat UI. Knock renders nothing and downloads no UI (no React, no styles): only the
|
|
225
|
+
* conversation. Your function is called with the chat client when the chat has loaded. Set it
|
|
226
|
+
* before the chat loads, in `init({ chat })`; once on, it stays on for the page. `null` clears
|
|
227
|
+
* it before the chat loads.
|
|
228
|
+
*/
|
|
229
|
+
headless?: ((chat: KnockChatClient) => void) | null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The Knock chat. When your Knock tag has the chat, the SDK uses it. When it has none, the SDK loads and runs the chat
|
|
233
|
+
* itself. A page never shows two chats.
|
|
234
|
+
*/
|
|
235
|
+
export interface KnockChat {
|
|
236
|
+
/** Opens the chat. Also takes a click event, so you can pass it straight to `onClick`. */
|
|
237
|
+
open(options?: KnockChatOpenOptions | KnockChatOpenEvent): void;
|
|
238
|
+
close(): void;
|
|
239
|
+
/** Replaces the look you set from code. */
|
|
240
|
+
setSkin(skin: KnockChatSkin): void;
|
|
241
|
+
/** Drops the look you set from code, back to your Knock tag's. */
|
|
242
|
+
resetSkin(): void;
|
|
243
|
+
configure(options: KnockChatOptions): void;
|
|
244
|
+
}
|
|
66
245
|
export interface KnockEventMap {
|
|
67
246
|
/** Fires once. A handler added after that still runs, once. */
|
|
68
247
|
ready: void;
|
|
@@ -75,6 +254,13 @@ export interface KnockEventMap {
|
|
|
75
254
|
};
|
|
76
255
|
'widget:open': void;
|
|
77
256
|
'widget:close': void;
|
|
257
|
+
/** `test` is true while the chat runs in test mode. */
|
|
258
|
+
'chat:open': {
|
|
259
|
+
test: boolean;
|
|
260
|
+
};
|
|
261
|
+
'chat:close': {
|
|
262
|
+
test: boolean;
|
|
263
|
+
};
|
|
78
264
|
error: {
|
|
79
265
|
message: string;
|
|
80
266
|
cause?: unknown;
|
|
@@ -98,7 +284,23 @@ export interface KnockSDK {
|
|
|
98
284
|
open(): void;
|
|
99
285
|
close(): void;
|
|
100
286
|
};
|
|
287
|
+
chat: KnockChat;
|
|
101
288
|
on<E extends KnockEventName>(event: E, handler: (payload: KnockEventMap[E]) => void): () => void;
|
|
289
|
+
/**
|
|
290
|
+
* Returns `url` with the visitor's Knock identity added, so a Knock chat opened from it knows who
|
|
291
|
+
* they are. Call it when the visitor opens the link (on click and middle-click), not when you
|
|
292
|
+
* render it, and put the plain URL back right after, so a copied link stays clean. Before your
|
|
293
|
+
* Knock tag is ready, on the server, or on a tag that predates it, it returns `url` unchanged.
|
|
294
|
+
* Synchronous; never throws, never queued. In React, `<KnockLink href={url}>` does all of this.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* link.onclick = () => {
|
|
298
|
+
* link.href = knock.wrapLink(url);
|
|
299
|
+
* setTimeout(() => (link.href = url));
|
|
300
|
+
* };
|
|
301
|
+
* window.open(knock.wrapLink(url));
|
|
302
|
+
*/
|
|
303
|
+
wrapLink(url: string): string;
|
|
102
304
|
/** True once the runtime has loaded and drained the queue. */
|
|
103
305
|
readonly ready: boolean;
|
|
104
306
|
readonly version: string;
|
|
@@ -124,7 +326,15 @@ export interface KnockRuntime {
|
|
|
124
326
|
open(): void;
|
|
125
327
|
close(): void;
|
|
126
328
|
};
|
|
329
|
+
/** On a tag whose config turns the chat on, and on any tag after `loadChat()`. */
|
|
330
|
+
chat?: KnockChat;
|
|
331
|
+
/** Loads the tag's chat on a tag whose config has none: `chat` is there once it resolves. Absent on tags that predate it (0.10.0 and earlier). */
|
|
332
|
+
loadChat?(): Promise<KnockChat | undefined>;
|
|
127
333
|
on?<E extends KnockEventName>(event: E, handler: (payload: KnockEventMap[E]) => void): () => void;
|
|
334
|
+
/** `url` with the visitor's identity added. Absent on tags that predate it. */
|
|
335
|
+
wrapLink?(url: string): string;
|
|
336
|
+
/** The visitor's id. */
|
|
337
|
+
getUID?(): string;
|
|
128
338
|
}
|
|
129
339
|
/** What the SDK writes to `window.__KNOCK_SDK__` on `init()`. Informational; the current Knock tag doesn't read it. */
|
|
130
340
|
export interface KnockSdkBootConfig {
|
|
@@ -145,5 +355,9 @@ declare global {
|
|
|
145
355
|
initialized?: boolean;
|
|
146
356
|
}>;
|
|
147
357
|
}
|
|
358
|
+
/** The DOM's own `Element`. Named here so these types also compile without the DOM lib. */
|
|
359
|
+
interface Element {
|
|
360
|
+
}
|
|
148
361
|
}
|
|
362
|
+
export {};
|
|
149
363
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;AAExE,0FAA0F;AAC1F,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;AAEjF,MAAM,WAAW,gBAAgB;IAC/B,yGAAyG;IACzG,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,wGAAwG;IACxG,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;AAExE,0FAA0F;AAC1F,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;AAEjF,MAAM,WAAW,gBAAgB;IAC/B,yGAAyG;IACzG,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,wGAAwG;IACxG,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,IAAI,CAAC,E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WAAW,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KAC/F;IACD,2FAA2F;IAC3F,UAAU,OAAO;KAAG;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.4";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes } from 'react';
|
|
2
|
+
export interface KnockLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
3
|
+
/** The link, as is. The rendered `<a>` keeps it; the visitor's identity is added only while they open it. */
|
|
4
|
+
href: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A plain `<a>` for links to Knock chat that keeps the visitor's identity when they open it. It
|
|
8
|
+
* renders `href` as is, so server rendering stays the same and nothing re-renders when Knock loads.
|
|
9
|
+
* It swaps in `knock.wrapLink(href)` only while the link is opened (a click with any modifier, a
|
|
10
|
+
* middle-click, Enter, or a mouse press, so a drag to a new tab keeps it too), then puts `href`
|
|
11
|
+
* back. A right-click, a long-press or a Ctrl-click on a Mac always shows `href` as is, so a copied
|
|
12
|
+
* link stays clean. Your own handlers run first and see `href` as is; if your `onClick` calls
|
|
13
|
+
* `preventDefault()`, the link stays as it is.
|
|
14
|
+
*/
|
|
15
|
+
export declare const KnockLink: import("react").ForwardRefExoticComponent<KnockLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes } from 'react';
|
|
2
|
+
export interface KnockLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
3
|
+
/** The link, as is. The rendered `<a>` keeps it; the visitor's identity is added only while they open it. */
|
|
4
|
+
href: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A plain `<a>` for links to Knock chat that keeps the visitor's identity when they open it. It
|
|
8
|
+
* renders `href` as is, so server rendering stays the same and nothing re-renders when Knock loads.
|
|
9
|
+
* It swaps in `knock.wrapLink(href)` only while the link is opened (a click with any modifier, a
|
|
10
|
+
* middle-click, Enter, or a mouse press, so a drag to a new tab keeps it too), then puts `href`
|
|
11
|
+
* back. A right-click, a long-press or a Ctrl-click on a Mac always shows `href` as is, so a copied
|
|
12
|
+
* link stays clean. Your own handlers run first and see `href` as is; if your `onClick` calls
|
|
13
|
+
* `preventDefault()`, the link stays as it is.
|
|
14
|
+
*/
|
|
15
|
+
export declare const KnockLink: import("react").ForwardRefExoticComponent<KnockLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
16
|
+
//# sourceMappingURL=KnockLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnockLink.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/react/KnockLink.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,oBAAoB,EAAuB,MAAM,OAAO,CAAC;AAGnF,MAAM,WAAW,cAAe,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC7E,6GAA6G;IAC7G,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,8GAmCpB,CAAC"}
|
|
@@ -5,3 +5,5 @@ export { useKnockIdentify } from './useKnockIdentify.cjs';
|
|
|
5
5
|
export { useKnockEvent } from './useKnockEvent.cjs';
|
|
6
6
|
export { KnockButton } from './KnockButton.cjs';
|
|
7
7
|
export type { KnockButtonProps } from './KnockButton.cjs';
|
|
8
|
+
export { KnockLink } from './KnockLink.cjs';
|
|
9
|
+
export type { KnockLinkProps } from './KnockLink.cjs';
|
|
@@ -5,4 +5,6 @@ export { useKnockIdentify } from './useKnockIdentify.js';
|
|
|
5
5
|
export { useKnockEvent } from './useKnockEvent.js';
|
|
6
6
|
export { KnockButton } from './KnockButton.js';
|
|
7
7
|
export type { KnockButtonProps } from './KnockButton.js';
|
|
8
|
+
export { KnockLink } from './KnockLink.js';
|
|
9
|
+
export type { KnockLinkProps } from './KnockLink.js';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KnockEventMap, KnockEventName, KnockFieldValue, KnockIdentifyTraits, KnockInitOptions, KnockModalOpenOptions, KnockSDK, KnockSchedulingLoadOptions } from '../core/types.cjs';
|
|
1
|
+
import type { KnockChatOpenEvent, KnockChatOpenOptions, KnockChatOptions, KnockChatSkin, KnockEventMap, KnockEventName, KnockFieldValue, KnockIdentifyTraits, KnockInitOptions, KnockModalOpenOptions, KnockSDK, KnockSchedulingLoadOptions } from '../core/types.cjs';
|
|
2
2
|
export type KnockMockCall = {
|
|
3
3
|
method: 'init';
|
|
4
4
|
args: [KnockInitOptions];
|
|
@@ -35,9 +35,27 @@ export type KnockMockCall = {
|
|
|
35
35
|
} | {
|
|
36
36
|
method: 'widget.close';
|
|
37
37
|
args: [];
|
|
38
|
+
} | {
|
|
39
|
+
method: 'chat.open';
|
|
40
|
+
args: [KnockChatOpenOptions | KnockChatOpenEvent | undefined];
|
|
41
|
+
} | {
|
|
42
|
+
method: 'chat.close';
|
|
43
|
+
args: [];
|
|
44
|
+
} | {
|
|
45
|
+
method: 'chat.setSkin';
|
|
46
|
+
args: [KnockChatSkin];
|
|
47
|
+
} | {
|
|
48
|
+
method: 'chat.resetSkin';
|
|
49
|
+
args: [];
|
|
50
|
+
} | {
|
|
51
|
+
method: 'chat.configure';
|
|
52
|
+
args: [KnockChatOptions];
|
|
38
53
|
} | {
|
|
39
54
|
method: 'on';
|
|
40
55
|
args: [KnockEventName];
|
|
56
|
+
} | {
|
|
57
|
+
method: 'wrapLink';
|
|
58
|
+
args: [string];
|
|
41
59
|
};
|
|
42
60
|
export interface KnockMock extends KnockSDK {
|
|
43
61
|
/** Every call made against this mock, oldest first. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KnockEventMap, KnockEventName, KnockFieldValue, KnockIdentifyTraits, KnockInitOptions, KnockModalOpenOptions, KnockSDK, KnockSchedulingLoadOptions } from '../core/types.js';
|
|
1
|
+
import type { KnockChatOpenEvent, KnockChatOpenOptions, KnockChatOptions, KnockChatSkin, KnockEventMap, KnockEventName, KnockFieldValue, KnockIdentifyTraits, KnockInitOptions, KnockModalOpenOptions, KnockSDK, KnockSchedulingLoadOptions } from '../core/types.js';
|
|
2
2
|
export type KnockMockCall = {
|
|
3
3
|
method: 'init';
|
|
4
4
|
args: [KnockInitOptions];
|
|
@@ -35,9 +35,27 @@ export type KnockMockCall = {
|
|
|
35
35
|
} | {
|
|
36
36
|
method: 'widget.close';
|
|
37
37
|
args: [];
|
|
38
|
+
} | {
|
|
39
|
+
method: 'chat.open';
|
|
40
|
+
args: [KnockChatOpenOptions | KnockChatOpenEvent | undefined];
|
|
41
|
+
} | {
|
|
42
|
+
method: 'chat.close';
|
|
43
|
+
args: [];
|
|
44
|
+
} | {
|
|
45
|
+
method: 'chat.setSkin';
|
|
46
|
+
args: [KnockChatSkin];
|
|
47
|
+
} | {
|
|
48
|
+
method: 'chat.resetSkin';
|
|
49
|
+
args: [];
|
|
50
|
+
} | {
|
|
51
|
+
method: 'chat.configure';
|
|
52
|
+
args: [KnockChatOptions];
|
|
38
53
|
} | {
|
|
39
54
|
method: 'on';
|
|
40
55
|
args: [KnockEventName];
|
|
56
|
+
} | {
|
|
57
|
+
method: 'wrapLink';
|
|
58
|
+
args: [string];
|
|
41
59
|
};
|
|
42
60
|
export interface KnockMock extends KnockSDK {
|
|
43
61
|
/** Every call made against this mock, oldest first. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EAER,0BAA0B,EAE3B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,gBAAgB,CAA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{
|
|
2
2
|
"name": "@knock-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Knock AI SDK \u2014 identify people, send events and open the Knock widget from your website or your logged-in app. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://knock-ai.com",
|
|
@@ -133,9 +133,12 @@
|
|
|
133
133
|
"test": "vitest run",
|
|
134
134
|
"test:watch": "vitest",
|
|
135
135
|
"size": "size-limit",
|
|
136
|
-
"check": "npm run typecheck && npm run test && npm run build && npm run
|
|
136
|
+
"check": "npm run typecheck && npm run test && npm run build && npm run types:check && npm run api:check && npm run snippet:check && npm run size",
|
|
137
137
|
"snippet:sync": "node scripts/sync-snippet.mjs",
|
|
138
|
-
"snippet:check": "node scripts/sync-snippet.mjs --check"
|
|
138
|
+
"snippet:check": "node scripts/sync-snippet.mjs --check",
|
|
139
|
+
"types:check": "tsc -p type-tests/tsconfig.json",
|
|
140
|
+
"api:sync": "node scripts/sync-api.mjs",
|
|
141
|
+
"api:check": "node scripts/sync-api.mjs --check"
|
|
139
142
|
},
|
|
140
143
|
"peerDependencies": {
|
|
141
144
|
"@angular/core": ">=17",
|
|
@@ -159,7 +162,9 @@
|
|
|
159
162
|
"@testing-library/dom": "^10.4.2",
|
|
160
163
|
"@testing-library/react": "^16.0.0",
|
|
161
164
|
"@types/react": "^19.0.0",
|
|
165
|
+
"@types/react-dom": "^19.3.0",
|
|
162
166
|
"@vitest/coverage-v8": "^3.0.0",
|
|
167
|
+
"acorn": "^8.18.0",
|
|
163
168
|
"jsdom": "^26.0.0",
|
|
164
169
|
"react": "^19.0.0",
|
|
165
170
|
"react-dom": "^19.0.0",
|
|
@@ -175,13 +180,13 @@
|
|
|
175
180
|
{
|
|
176
181
|
"name": "core (@knock-ai/sdk)",
|
|
177
182
|
"path": "dist/index.js",
|
|
178
|
-
"limit": "
|
|
183
|
+
"limit": "2.2 kB",
|
|
179
184
|
"gzip": true
|
|
180
185
|
},
|
|
181
186
|
{
|
|
182
187
|
"name": "react",
|
|
183
188
|
"path": "dist/react.js",
|
|
184
|
-
"limit": "
|
|
189
|
+
"limit": "950 B",
|
|
185
190
|
"gzip": true,
|
|
186
191
|
"ignore": [
|
|
187
192
|
"@knock-ai/sdk",
|
|
@@ -218,13 +223,13 @@
|
|
|
218
223
|
{
|
|
219
224
|
"name": "snippet (CDN stub)",
|
|
220
225
|
"path": "dist/snippet.js",
|
|
221
|
-
"limit": "
|
|
226
|
+
"limit": "640 B",
|
|
222
227
|
"gzip": true
|
|
223
228
|
},
|
|
224
229
|
{
|
|
225
230
|
"name": "knockai.iife (CDN)",
|
|
226
231
|
"path": "dist/knockai.iife.js",
|
|
227
|
-
"limit": "
|
|
232
|
+
"limit": "2.32 kB",
|
|
228
233
|
"gzip": true
|
|
229
234
|
}
|
|
230
235
|
]
|