@unnoodle/browser 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -0
- package/dist/index.cjs +2639 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +517 -0
- package/dist/index.d.ts +517 -0
- package/dist/index.js +2639 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggestions, AI generation, and generic action types.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* An action button shown in legacy AI response panels and deprecated plugin hooks.
|
|
6
|
+
*/
|
|
7
|
+
interface UnnoodleAction {
|
|
8
|
+
type: "link" | "copy" | "custom";
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A single stage entry as returned by the backend.
|
|
15
|
+
*/
|
|
16
|
+
interface ProductMemoryEntryResponse {
|
|
17
|
+
id: number;
|
|
18
|
+
productMemoryId: number;
|
|
19
|
+
snapshotHtml: string;
|
|
20
|
+
explanation: string;
|
|
21
|
+
url: string;
|
|
22
|
+
pageTitle: string;
|
|
23
|
+
capturedByName: string;
|
|
24
|
+
capturedByRole: string;
|
|
25
|
+
capturedAt: string;
|
|
26
|
+
sortOrder: number;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
sanitizerVersion?: string;
|
|
29
|
+
targetingMetadata?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
dataTestId?: string;
|
|
32
|
+
tag: string;
|
|
33
|
+
role: string | null;
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Full detail response — memory + all entries.
|
|
39
|
+
* Returned by create, addEntry, updateEntry, updateTitle, getById.
|
|
40
|
+
*/
|
|
41
|
+
interface ProductMemoryDetailResponse {
|
|
42
|
+
id: number;
|
|
43
|
+
userId: number;
|
|
44
|
+
title: string;
|
|
45
|
+
entries: ProductMemoryEntryResponse[];
|
|
46
|
+
createdAt: string;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
watchForChanges: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* List-view response — title and entry count only.
|
|
52
|
+
* Returned by GET /api/product-memories (paginated list).
|
|
53
|
+
*/
|
|
54
|
+
interface ProductMemoryResponse {
|
|
55
|
+
id: number;
|
|
56
|
+
userId: number;
|
|
57
|
+
title: string;
|
|
58
|
+
entryCount: number;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
watchForChanges: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Glossary, term, and discussion types.
|
|
66
|
+
*/
|
|
67
|
+
/** A resolved cross-reference to another term within the same context. */
|
|
68
|
+
interface TermRef {
|
|
69
|
+
id: number;
|
|
70
|
+
term: string;
|
|
71
|
+
slug: string;
|
|
72
|
+
}
|
|
73
|
+
/** A single glossary term as returned by the backend. */
|
|
74
|
+
interface GlossaryTerm {
|
|
75
|
+
id: number;
|
|
76
|
+
term: string;
|
|
77
|
+
definition: string;
|
|
78
|
+
/** Optional short alias or abbreviation */
|
|
79
|
+
abbreviation?: string;
|
|
80
|
+
/** Resolved @slug cross-references within this context. */
|
|
81
|
+
relations?: TermRef[];
|
|
82
|
+
status: "ACTIVE" | "DEPRECATED" | "PENDING";
|
|
83
|
+
contextId: number;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedAt: string;
|
|
86
|
+
}
|
|
87
|
+
/** Minimal context metadata returned alongside the glossary. */
|
|
88
|
+
interface ContextMetadata {
|
|
89
|
+
id: number;
|
|
90
|
+
name: string;
|
|
91
|
+
slug: string;
|
|
92
|
+
/** Display name of the context owner. Absent for SDK auto-created contexts. */
|
|
93
|
+
ownerName?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Response from POST /api/init (SdkInitResponse on the backend). */
|
|
96
|
+
interface WidgetInitResponse {
|
|
97
|
+
context: ContextMetadata;
|
|
98
|
+
glossary: GlossaryTerm[];
|
|
99
|
+
/** Optional clarifications included in init response for better performance */
|
|
100
|
+
clarifications?: ContextDiscussion[];
|
|
101
|
+
/** Optional product memories included in init response for better performance */
|
|
102
|
+
productMemories?: ProductMemoryResponse[];
|
|
103
|
+
tenantName: string;
|
|
104
|
+
subdomain: string;
|
|
105
|
+
}
|
|
106
|
+
/** A context-level clarification post (question or reply). */
|
|
107
|
+
interface ContextDiscussion {
|
|
108
|
+
id: number;
|
|
109
|
+
contextId: number;
|
|
110
|
+
parentId: number | null;
|
|
111
|
+
body: string;
|
|
112
|
+
authorName: string | null;
|
|
113
|
+
aiGenerated: boolean;
|
|
114
|
+
aiModel?: string | null;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
replies: ContextDiscussion[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Only kept for backwards-compat with old plugin hooks.
|
|
120
|
+
* New code should use WidgetInitResponse.
|
|
121
|
+
*/
|
|
122
|
+
interface UnnoodleApiResponse {
|
|
123
|
+
message?: string;
|
|
124
|
+
actions?: UnnoodleAction[];
|
|
125
|
+
prUrl?: string;
|
|
126
|
+
error?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Configuration for the Unnoodle widget SDK.
|
|
131
|
+
* Designed to be extensible across major versions without breaking changes.
|
|
132
|
+
*/
|
|
133
|
+
interface UnnoodleConfig {
|
|
134
|
+
/**
|
|
135
|
+
* Your workspace API key. Starts with `pk_live_` (production) or `pk_test_` (development).
|
|
136
|
+
* Identifies the tenant and authorizes SDK requests.
|
|
137
|
+
* Required.
|
|
138
|
+
*/
|
|
139
|
+
apiKey: string;
|
|
140
|
+
/**
|
|
141
|
+
* The knowledge context name to load (e.g. "engineering", "sales").
|
|
142
|
+
* Must match a context configured in your Unnoodle workspace.
|
|
143
|
+
* Required.
|
|
144
|
+
*/
|
|
145
|
+
context: string;
|
|
146
|
+
/**
|
|
147
|
+
* Target environment. Defaults to "prod".
|
|
148
|
+
*/
|
|
149
|
+
environment?: "dev" | "staging" | "prod";
|
|
150
|
+
/**
|
|
151
|
+
* Override the API base URL. Defaults to https://api.unnoodle.com
|
|
152
|
+
* Useful for local development or self-hosted deployments.
|
|
153
|
+
*/
|
|
154
|
+
baseUrl?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Provide a function that returns the current user's auth token.
|
|
157
|
+
* Called at the time of each request — never stored.
|
|
158
|
+
* When provided and returns a non-null value the login screen is skipped.
|
|
159
|
+
*/
|
|
160
|
+
getAuthToken?: () => string | null;
|
|
161
|
+
/**
|
|
162
|
+
* Visual theme overrides.
|
|
163
|
+
*/
|
|
164
|
+
theme?: {
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated Has no effect. Pass design tokens via `shadowTokens` instead.
|
|
167
|
+
* Will be removed in a future major version.
|
|
168
|
+
*/
|
|
169
|
+
primaryColor?: string;
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Has no effect. Pass design tokens via `shadowTokens` instead.
|
|
172
|
+
* Will be removed in a future major version.
|
|
173
|
+
*/
|
|
174
|
+
borderRadius?: string;
|
|
175
|
+
/**
|
|
176
|
+
* CSS `:host { }` block containing `--unn-*` design tokens for injection
|
|
177
|
+
* into the widget's Shadow DOM. Generate with `getShadowDomTokens()` from
|
|
178
|
+
* `@unnoodle/design-system` in your host app.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* import { getShadowDomTokens } from "@unnoodle/design-system";
|
|
182
|
+
* initUnnoodle({ theme: { shadowTokens: getShadowDomTokens() } });
|
|
183
|
+
*/
|
|
184
|
+
shadowTokens?: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Enable automatic PR suggestions in the response panel.
|
|
188
|
+
*/
|
|
189
|
+
enableAutoPR?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Returns additional metadata to include in context payloads.
|
|
192
|
+
* Called at request time — should be cheap and synchronous.
|
|
193
|
+
*/
|
|
194
|
+
customMetadata?: () => Record<string, unknown>;
|
|
195
|
+
/**
|
|
196
|
+
* URL of the Unnoodle workspace app — used for "View details" links.
|
|
197
|
+
* Defaults to https://app.unnoodle.com
|
|
198
|
+
*/
|
|
199
|
+
workspaceUrl?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Plugin hooks — reserved for future plugin system.
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
_plugins?: UnnoodlePlugin[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Plugin interface — reserved for future extensibility.
|
|
208
|
+
* Plugins can hook into lifecycle events without modifying core.
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
interface UnnoodlePlugin {
|
|
212
|
+
name: string;
|
|
213
|
+
onInit?: (config: UnnoodleConfig) => void;
|
|
214
|
+
onContextCollected?: (ctx: Record<string, unknown>) => Record<string, unknown>;
|
|
215
|
+
onResponse?: (response: WidgetInitResponse) => void;
|
|
216
|
+
onError?: (error: Error) => void;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The context payload sent to the Unnoodle API.
|
|
220
|
+
*/
|
|
221
|
+
interface UnnoodleContext {
|
|
222
|
+
apiKey: string;
|
|
223
|
+
context: string;
|
|
224
|
+
environment: string;
|
|
225
|
+
route: string;
|
|
226
|
+
title: string;
|
|
227
|
+
timestamp: string;
|
|
228
|
+
metadata?: Record<string, unknown>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* StateWatcher
|
|
233
|
+
*
|
|
234
|
+
* Single responsibility:
|
|
235
|
+
* Observe a captured DOM element for meaningful state changes and report
|
|
236
|
+
* them via a callback — enabling automatic new-state detection in the UI
|
|
237
|
+
* memory timeline.
|
|
238
|
+
*
|
|
239
|
+
* Behaviour:
|
|
240
|
+
* - watch(el, onStateChange): attaches a MutationObserver that listens for
|
|
241
|
+
* text, attribute, and structural changes on the element and its subtree.
|
|
242
|
+
* - Changes are debounced for 500ms so rapid successive mutations (e.g.
|
|
243
|
+
* CSS class toggling during an animation) produce a single diff.
|
|
244
|
+
* - Noise filter: style attribute mutations are ignored (too noisy).
|
|
245
|
+
* - unwatch(): disconnects the observer and cancels pending callbacks.
|
|
246
|
+
*
|
|
247
|
+
* Change classification (StateDiff.type):
|
|
248
|
+
* - "text" — visible text content changed (textContent assignment
|
|
249
|
+
* fires a childList mutation with only text nodes, or a
|
|
250
|
+
* characterData mutation on a text node directly).
|
|
251
|
+
* - "attribute" — a non-style attribute changed (class, disabled,
|
|
252
|
+
* aria-*, data-*, etc.).
|
|
253
|
+
* - "structure" — child elements were added or removed.
|
|
254
|
+
*
|
|
255
|
+
* Design principles:
|
|
256
|
+
* - No DOM mutation — observer only.
|
|
257
|
+
* - No coupling to panel, API, or captureOrchestrator.
|
|
258
|
+
* - before/after are always strings (attribute values, textContent, or
|
|
259
|
+
* serialised child counts for structural diffs).
|
|
260
|
+
*/
|
|
261
|
+
interface StateDiff {
|
|
262
|
+
/** Category of the detected change. */
|
|
263
|
+
type: "text" | "attribute" | "structure";
|
|
264
|
+
/** Name of the changed attribute — only set when type === "attribute". */
|
|
265
|
+
attribute?: string;
|
|
266
|
+
/** State before the change. */
|
|
267
|
+
before: string;
|
|
268
|
+
/** State after the change. */
|
|
269
|
+
after: string;
|
|
270
|
+
}
|
|
271
|
+
interface IStateWatcher {
|
|
272
|
+
/**
|
|
273
|
+
* Begin watching `el` for meaningful mutations.
|
|
274
|
+
* Calls `onStateChange` (debounced 500ms) when a diff is detected.
|
|
275
|
+
* Replaces any previous watch.
|
|
276
|
+
*/
|
|
277
|
+
watch(el: Element, onStateChange: (diff: StateDiff) => void): void;
|
|
278
|
+
/**
|
|
279
|
+
* Stop watching. Cancels any pending debounced callback.
|
|
280
|
+
* Safe to call when no watch is active.
|
|
281
|
+
*/
|
|
282
|
+
unwatch(): void;
|
|
283
|
+
}
|
|
284
|
+
declare class StateWatcher implements IStateWatcher {
|
|
285
|
+
private observer;
|
|
286
|
+
private timerId;
|
|
287
|
+
private pendingMutations;
|
|
288
|
+
private watchedEl;
|
|
289
|
+
private callback;
|
|
290
|
+
/** Snapshot of watched element state at the start of the current quiet window. */
|
|
291
|
+
private preBatchState;
|
|
292
|
+
watch(el: Element, onStateChange: (diff: StateDiff) => void): void;
|
|
293
|
+
unwatch(): void;
|
|
294
|
+
private scheduleFlush;
|
|
295
|
+
private flush;
|
|
296
|
+
private computeDiff;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* meaningInference
|
|
301
|
+
*
|
|
302
|
+
* Single responsibility:
|
|
303
|
+
* Given a StateDiff and the current live element, produce a concise
|
|
304
|
+
* human-readable string suggesting what UI state the change represents.
|
|
305
|
+
* Returns null when no confident semantic meaning can be inferred.
|
|
306
|
+
*
|
|
307
|
+
* Rule-based approach (no ML, fully deterministic):
|
|
308
|
+
*
|
|
309
|
+
* Text changes — keyword scan of diff.after:
|
|
310
|
+
* loading/spinner/submitting/saving → "Loading state"
|
|
311
|
+
* error/failed/invalid/try again → "Error state"
|
|
312
|
+
* success/saved/complete/done → "Success state"
|
|
313
|
+
*
|
|
314
|
+
* Attribute changes on "class":
|
|
315
|
+
* Newly added class keyword scan (diff.after classes minus diff.before classes):
|
|
316
|
+
* loading/spinner/pending → "Loading state"
|
|
317
|
+
* disabled/inactive → "Disabled state"
|
|
318
|
+
* error/invalid/danger → "Error state"
|
|
319
|
+
* success/valid/done → "Success state"
|
|
320
|
+
* active/selected/open → "Active state"
|
|
321
|
+
* collapsed/closed/hidden → "Collapsed state"
|
|
322
|
+
*
|
|
323
|
+
* The "disabled" attribute:
|
|
324
|
+
* Attribute present after change → "Disabled state"
|
|
325
|
+
* Attribute absent after change → "Enabled state"
|
|
326
|
+
*
|
|
327
|
+
* ARIA attributes:
|
|
328
|
+
* aria-expanded = "true" → "Expanded state"
|
|
329
|
+
* aria-expanded = "false" → "Collapsed state"
|
|
330
|
+
* aria-selected = "true" → "Selected state"
|
|
331
|
+
* aria-busy = "true" → "Loading state"
|
|
332
|
+
* aria-label changed → "Label changed to: <value>"
|
|
333
|
+
*
|
|
334
|
+
* Structure changes → null (caller decides context).
|
|
335
|
+
*
|
|
336
|
+
* Design principles:
|
|
337
|
+
* - Pure function — no side effects, no DOM mutation.
|
|
338
|
+
* - Returns null rather than guessing.
|
|
339
|
+
* - Deterministic output for testability.
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Infer a human-readable state meaning from a StateDiff.
|
|
344
|
+
*
|
|
345
|
+
* @param diff The state change detected by StateWatcher.
|
|
346
|
+
* @param el The live element after the change (used for attribute reads).
|
|
347
|
+
* @returns A short description, or null if no meaning can be inferred.
|
|
348
|
+
*/
|
|
349
|
+
declare function inferMeaning(diff: StateDiff, el: Element): string | null;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* LiveRenderer
|
|
353
|
+
*
|
|
354
|
+
* Single responsibility:
|
|
355
|
+
* Highlight the DOM element that corresponds to a captured ProductMemory
|
|
356
|
+
* entry — giving the viewer a live "this is the element" pointer.
|
|
357
|
+
*
|
|
358
|
+
* Behaviour:
|
|
359
|
+
* - show(el): scrolls the element into view then draws a read-only highlight
|
|
360
|
+
* ring (position:fixed) over the element's bounding rect.
|
|
361
|
+
* - hide(): removes the ring from the DOM.
|
|
362
|
+
* - Calling hide() before show() is safe (no-op).
|
|
363
|
+
* - Calling show() a second time replaces the previous ring.
|
|
364
|
+
*
|
|
365
|
+
* Design principles:
|
|
366
|
+
* - No click handlers — read-only visual indicator only.
|
|
367
|
+
* - No coupling to panel, API, or state machine.
|
|
368
|
+
* - Reuses the same visual language as ElementPicker (dashed Unnoodle violet
|
|
369
|
+
* ring) but with a solid fill to distinguish "live" from "pick" mode.
|
|
370
|
+
*/
|
|
371
|
+
interface ILiveRenderer {
|
|
372
|
+
/** Scroll the element into view and draw the live highlight ring. */
|
|
373
|
+
show(el: Element): void;
|
|
374
|
+
/** Remove the highlight ring. Safe to call when ring is not shown. */
|
|
375
|
+
hide(): void;
|
|
376
|
+
}
|
|
377
|
+
declare class LiveRenderer implements ILiveRenderer {
|
|
378
|
+
private ring;
|
|
379
|
+
show(el: Element): void;
|
|
380
|
+
hide(): void;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* targetingEngine
|
|
385
|
+
*
|
|
386
|
+
* Single responsibility:
|
|
387
|
+
* Given a StoredTarget (element-identification metadata harvested at capture
|
|
388
|
+
* time), find the corresponding live element in the current host page.
|
|
389
|
+
*
|
|
390
|
+
* Resolution strategy — tiered, highest-confidence first:
|
|
391
|
+
*
|
|
392
|
+
* Tier 1a — id attribute (O(1), most stable):
|
|
393
|
+
* document.getElementById(id) → verify same tag → return if found.
|
|
394
|
+
*
|
|
395
|
+
* Tier 1b — data-testid attribute (O(1), second most stable):
|
|
396
|
+
* querySelector('[data-testid="..."]') → verify tag + unique → return.
|
|
397
|
+
*
|
|
398
|
+
* Tier 2 — text match (O(n) over elements of the given tag):
|
|
399
|
+
* querySelectorAll(tag) → filter by exact trimmed textContent → return
|
|
400
|
+
* if exactly one match. Falls through when text is empty or not unique.
|
|
401
|
+
*
|
|
402
|
+
* Design principles:
|
|
403
|
+
* - Never mutates the DOM
|
|
404
|
+
* - Returns null on any ambiguity rather than guessing wrong
|
|
405
|
+
* - All DOM traversal is synchronous and lightweight
|
|
406
|
+
*/
|
|
407
|
+
/**
|
|
408
|
+
* Element-identification data persisted per captured entry.
|
|
409
|
+
* Mirrors the backend TargetingMetadata DTO.
|
|
410
|
+
*/
|
|
411
|
+
interface StoredTarget {
|
|
412
|
+
/** element.id attribute — most stable identifier, set by developers. */
|
|
413
|
+
id?: string;
|
|
414
|
+
/** data-testid attribute — second most stable. */
|
|
415
|
+
dataTestId?: string;
|
|
416
|
+
/** Lower-case tag name. Never undefined. */
|
|
417
|
+
tag: string;
|
|
418
|
+
/** ARIA role at capture time. May be null. */
|
|
419
|
+
role: string | null;
|
|
420
|
+
/** Trimmed visible text content at capture time. */
|
|
421
|
+
text: string;
|
|
422
|
+
/** Page URL at capture time — used by callers for page-match checks. */
|
|
423
|
+
url: string;
|
|
424
|
+
}
|
|
425
|
+
/** Implemented by TargetingEngine; injectable for testing. */
|
|
426
|
+
interface ITargetingEngine {
|
|
427
|
+
resolve(target: StoredTarget): Element | null;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* MemoryDetailController
|
|
432
|
+
*
|
|
433
|
+
* Single responsibility:
|
|
434
|
+
* After a ProductMemory is loaded, optionally start a StateWatcher on the
|
|
435
|
+
* originally captured DOM element and surface its diffs via an onDiff
|
|
436
|
+
* callback — enabling automatic new-state detection.
|
|
437
|
+
*
|
|
438
|
+
* Behaviour:
|
|
439
|
+
* load(memory, onDiff):
|
|
440
|
+
* 1. Unloads any prior watch.
|
|
441
|
+
* 2. If memory.watchForChanges is false, does nothing more.
|
|
442
|
+
* 3. Checks that the first entry's URL matches the current page URL
|
|
443
|
+
* (origin + pathname only, ignoring query / hash).
|
|
444
|
+
* 4. Uses TargetingEngine.resolve() to find the captured element.
|
|
445
|
+
* 5. Starts StateWatcher.watch(el, onDiff).
|
|
446
|
+
*
|
|
447
|
+
* unload():
|
|
448
|
+
* Stops any active StateWatcher. Safe to call when nothing is watching.
|
|
449
|
+
*
|
|
450
|
+
* Design principles:
|
|
451
|
+
* - No DOM mutation.
|
|
452
|
+
* - All dependencies are injected via interfaces for full testability.
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
interface IMemoryDetailController {
|
|
456
|
+
load(memory: ProductMemoryDetailResponse, onDiff: (diff: StateDiff) => void): void;
|
|
457
|
+
unload(): void;
|
|
458
|
+
}
|
|
459
|
+
declare class MemoryDetailController implements IMemoryDetailController {
|
|
460
|
+
private readonly stateWatcher;
|
|
461
|
+
private readonly targetingEngine;
|
|
462
|
+
constructor(stateWatcher: IStateWatcher, targetingEngine: ITargetingEngine);
|
|
463
|
+
load(memory: ProductMemoryDetailResponse, onDiff: (diff: StateDiff) => void): void;
|
|
464
|
+
unload(): void;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Initializes the Unnoodle widget SDK.
|
|
469
|
+
*
|
|
470
|
+
* Call once when your application boots. Safe to call in SSR environments —
|
|
471
|
+
* it will no-op if `document` is not available.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* import { initUnnoodle } from "@unnoodle/browser";
|
|
476
|
+
*
|
|
477
|
+
* initUnnoodle({ apiKey: "pk_live_abc123", context: "engineering" });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
declare function initUnnoodle(config: UnnoodleConfig): void;
|
|
481
|
+
/**
|
|
482
|
+
* Programmatically open the Unnoodle panel.
|
|
483
|
+
* No-op if the SDK has not been initialized.
|
|
484
|
+
*/
|
|
485
|
+
declare function openUnnoodle(): void;
|
|
486
|
+
/**
|
|
487
|
+
* Programmatically close the Unnoodle panel.
|
|
488
|
+
* No-op if the SDK has not been initialized.
|
|
489
|
+
*/
|
|
490
|
+
declare function closeUnnoodle(): void;
|
|
491
|
+
/**
|
|
492
|
+
* Tear down the Unnoodle widget and remove all DOM elements and listeners.
|
|
493
|
+
* Useful for single-page apps that need to clean up on route change.
|
|
494
|
+
*/
|
|
495
|
+
declare function destroyUnnoodle(): void;
|
|
496
|
+
/**
|
|
497
|
+
* Namespace-style API — preferred for script-tag / CDN usage.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```ts
|
|
501
|
+
* import { Unnoodle } from "@unnoodle/browser";
|
|
502
|
+
*
|
|
503
|
+
* Unnoodle.init({ apiKey: "pk_live_abc123", context: "engineering" });
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare const Unnoodle: {
|
|
507
|
+
/** Initialize the Unnoodle widget SDK. Equivalent to `initUnnoodle()`. */
|
|
508
|
+
readonly init: typeof initUnnoodle;
|
|
509
|
+
/** Programmatically open the panel. */
|
|
510
|
+
readonly open: typeof openUnnoodle;
|
|
511
|
+
/** Programmatically close the panel. */
|
|
512
|
+
readonly close: typeof closeUnnoodle;
|
|
513
|
+
/** Tear down the widget and remove all DOM elements. */
|
|
514
|
+
readonly destroy: typeof destroyUnnoodle;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export { type ILiveRenderer, type IMemoryDetailController, type IStateWatcher, LiveRenderer, MemoryDetailController, type StateDiff, StateWatcher, Unnoodle, type UnnoodleAction, type UnnoodleApiResponse, type UnnoodleConfig, type UnnoodleContext, type UnnoodlePlugin, closeUnnoodle, destroyUnnoodle, inferMeaning, initUnnoodle, openUnnoodle };
|