@magicx-eng/ai-autocomplete-vanilla 0.77.0 → 0.79.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 +2 -0
- package/REFERENCE.md +37 -0
- package/dist/index.d.mts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -713,6 +713,8 @@ const ac = new AIAutocomplete(container, {
|
|
|
713
713
|
|
|
714
714
|
Pass `visitorId` to tie searches to what the same visitor does later: a UUID v4 you keep across page loads (for example a first-party cookie), or a function that returns one. A function is called only when the id is needed, so it is safe to create the id lazily inside it.
|
|
715
715
|
|
|
716
|
+
Or pass `analyticsConsent` and let the SDK keep one: see [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-vanilla/REFERENCE.md).
|
|
717
|
+
|
|
716
718
|
Submits from Enter and from the built-in submit button are recorded for you. If you render your own submit button (Tier 2 or 3), call `recordSubmit(result)` from it, once per submit, with the result you pass to your own submit handler.
|
|
717
719
|
|
|
718
720
|
## Option Overrides
|
package/REFERENCE.md
CHANGED
|
@@ -9,6 +9,8 @@ Longer guides that do not fit in the [README](https://unpkg.com/@magicx-eng/ai-a
|
|
|
9
9
|
- [Multiple selections](#multiple-selections)
|
|
10
10
|
- [Location search](#location-search)
|
|
11
11
|
- [CSS variables](#css-variables)
|
|
12
|
+
- [Visitor id kept by the SDK](#visitor-id-kept-by-the-sdk)
|
|
13
|
+
- [Search id](#search-id)
|
|
12
14
|
|
|
13
15
|
## Product strip
|
|
14
16
|
|
|
@@ -724,3 +726,38 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
724
726
|
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color of the option and chip image tiles while their picture loads (unless `--aia-option-image-bg` / `--aia-chip-image-bg` are set). |
|
|
725
727
|
| `--aia-chip-remove-opacity` | `0.32` | `0.32` | Opacity of a chip's remove × (`showChipRemove`). The × is for a mouse or a tap and is hidden from assistive technology; from the keyboard, Backspace at the end of a chip removes it. |
|
|
726
728
|
| `--aia-chip-remove-opacity-hover` | `0.7` | `0.7` | Opacity of that × under a hovering pointer (never on touch). |
|
|
729
|
+
|
|
730
|
+
## Visitor id kept by the SDK
|
|
731
|
+
|
|
732
|
+
Without `visitorId`, the SDK can keep the id for you. Pass `analyticsConsent` so it knows the visitor's choice: `true` (allowed), `false` (declined), or `undefined` (not answered yet). Once allowed, it keeps a UUID v4 in the first-party cookie `aia_vid` for a year, renewed on use; declined, it removes that cookie. This needs the feature to be enabled for your account, and nothing is stored without `analyticsConsent`.
|
|
733
|
+
|
|
734
|
+
```ts
|
|
735
|
+
const ac = new AIAutocomplete(el, {
|
|
736
|
+
// Cookiebot, as an example. Return undefined until the visitor answers.
|
|
737
|
+
analyticsConsent: () => {
|
|
738
|
+
const cookiebot = window.Cookiebot;
|
|
739
|
+
return cookiebot?.hasResponse ? cookiebot.consent.statistics : undefined;
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
// Apply a changed choice at once, rather than at the next event.
|
|
744
|
+
window.addEventListener("CookiebotOnAccept", () => ac.refreshAnalyticsConsent());
|
|
745
|
+
window.addEventListener("CookiebotOnDecline", () => ac.refreshAnalyticsConsent());
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
`getVisitorId()` returns the id the instance's events carry, so you can send it with your own events. It is `undefined` before the first response and whenever there is no id.
|
|
749
|
+
|
|
750
|
+
## Search id
|
|
751
|
+
|
|
752
|
+
Each search gets its own id, so what happens after it (a results page, a cart, an order) can be tied to the exact search. The SDK makes it: a new one starts with the widget, on `reset()`, and with the shopper's next input after a submit or a product pick. It rides on the SDK's own requests and events once the feature is enabled for your account; until then `getSearchId()` returns `undefined`.
|
|
753
|
+
|
|
754
|
+
Read it where the search is handed off, before the shopper types again:
|
|
755
|
+
|
|
756
|
+
```ts
|
|
757
|
+
onSubmit: (result) => {
|
|
758
|
+
const searchId = ac.getSearchId();
|
|
759
|
+
// Carry it to your results page, and send it with the events that follow.
|
|
760
|
+
},
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
The id of the last search the current tab handed off (a submit or a product pick) is also kept in `sessionStorage` under `aia:last-search`, as `{ id, at }`, where `at` is when it was handed off, in milliseconds since the epoch.
|
package/dist/index.d.mts
CHANGED
|
@@ -264,6 +264,16 @@ interface AutocompleteResponse {
|
|
|
264
264
|
* shows. Absent means one for every response that changes it.
|
|
265
265
|
*/
|
|
266
266
|
visible_impression?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Set when the SDK may keep its own visitor id for a site that passes no
|
|
269
|
+
* `visitorId` and reports analytics consent. Absent means off.
|
|
270
|
+
*/
|
|
271
|
+
sdk_visitor_id?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Set when the SDK should send a `search_id`: the search each request and
|
|
274
|
+
* event belongs to. Absent means off.
|
|
275
|
+
*/
|
|
276
|
+
search_ids?: boolean;
|
|
267
277
|
/** The request's `schema_version`, echoed back. */
|
|
268
278
|
schema_version?: string;
|
|
269
279
|
};
|
|
@@ -1408,6 +1418,15 @@ interface CoreOptions {
|
|
|
1408
1418
|
* while it is off.
|
|
1409
1419
|
*/
|
|
1410
1420
|
visitorId?: string | (() => string | undefined);
|
|
1421
|
+
/**
|
|
1422
|
+
* Whether the visitor allowed analytics: `true`, `false`, or a function
|
|
1423
|
+
* returning either, or `undefined` while they have not answered. Once
|
|
1424
|
+
* allowed, and while the server has it on, a site that passes no `visitorId`
|
|
1425
|
+
* gets one kept for it in the first-party cookie `aia_vid` (a UUID v4, one
|
|
1426
|
+
* year, renewed on use). Declined, that cookie is removed. Omit it and the
|
|
1427
|
+
* SDK never touches the cookie. Ignored when `visitorId` is passed.
|
|
1428
|
+
*/
|
|
1429
|
+
analyticsConsent?: boolean | (() => boolean | undefined);
|
|
1411
1430
|
columns?: number;
|
|
1412
1431
|
/** Where pills render in "full" mode. Default: "dropdown". Ignored in "dropdown" mode (always in dropdown). */
|
|
1413
1432
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -1686,6 +1705,12 @@ type AIAutocompleteEvents = {
|
|
|
1686
1705
|
productSelect: [product: Product];
|
|
1687
1706
|
};
|
|
1688
1707
|
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1708
|
+
/**
|
|
1709
|
+
* Where the last search this tab handed off (a submit or a product pick) is
|
|
1710
|
+
* kept, for the storefront's own events (the Shopify Web Pixel reads it):
|
|
1711
|
+
* `{ id, at }`, `at` the handoff's time in epoch ms.
|
|
1712
|
+
*/
|
|
1713
|
+
declare const LAST_SEARCH_KEY = "aia:last-search";
|
|
1689
1714
|
declare class AIAutocomplete {
|
|
1690
1715
|
private inputStore;
|
|
1691
1716
|
private store;
|
|
@@ -1711,6 +1736,16 @@ declare class AIAutocomplete {
|
|
|
1711
1736
|
private subscriberCount;
|
|
1712
1737
|
private emitter;
|
|
1713
1738
|
private sessionId;
|
|
1739
|
+
/**
|
|
1740
|
+
* The search in progress. A new one starts with the instance, on reset(),
|
|
1741
|
+
* and with the shopper's next input after a submit or a product pick: what
|
|
1742
|
+
* they do after handing a search off is the next search.
|
|
1743
|
+
*/
|
|
1744
|
+
private searchId;
|
|
1745
|
+
/** A submit or product pick ended the search; the next input starts another. */
|
|
1746
|
+
private searchHandedOff;
|
|
1747
|
+
/** The server's `search_ids`: send the search with requests and events. */
|
|
1748
|
+
private searchIds;
|
|
1714
1749
|
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1715
1750
|
private lastRequestId;
|
|
1716
1751
|
/** Session that already sent `search_started`, so it fires once per session. */
|
|
@@ -1736,6 +1771,8 @@ declare class AIAutocomplete {
|
|
|
1736
1771
|
private lastImpressionKey;
|
|
1737
1772
|
/** The server's `visible_impression`: send an impression only while the dropdown is visible. */
|
|
1738
1773
|
private visibleImpression;
|
|
1774
|
+
/** The server's `sdk_visitor_id`: keep a visitor id for a host that passes none. */
|
|
1775
|
+
private sdkVisitorId;
|
|
1739
1776
|
private destroyed;
|
|
1740
1777
|
/** The location search in flight, so a newer phrase or destroy() can cancel it. */
|
|
1741
1778
|
private locationAbort;
|
|
@@ -1911,6 +1948,25 @@ declare class AIAutocomplete {
|
|
|
1911
1948
|
* own — a button you render — so each submit is counted once.
|
|
1912
1949
|
*/
|
|
1913
1950
|
recordSubmit(result: AutocompleteResult): void;
|
|
1951
|
+
/**
|
|
1952
|
+
* The search in progress, to send with your own events from it (a results
|
|
1953
|
+
* page, a cart). Undefined until the feature is enabled for your account
|
|
1954
|
+
* and the first response has said so. Read it in `onSubmit` or
|
|
1955
|
+
* `onProductSelect`: the shopper's next input starts another search.
|
|
1956
|
+
*/
|
|
1957
|
+
getSearchId(): string | undefined;
|
|
1958
|
+
/**
|
|
1959
|
+
* The visitor id this instance's events carry right now, to send with your
|
|
1960
|
+
* own events. Undefined while there is none: before the first response, or
|
|
1961
|
+
* without `visitorId` and without consent.
|
|
1962
|
+
*/
|
|
1963
|
+
getVisitorId(): string | undefined;
|
|
1964
|
+
/**
|
|
1965
|
+
* Reads `analyticsConsent` again now. Call it when the shopper changes their
|
|
1966
|
+
* choice, so a declined one removes the stored visitor id at once rather
|
|
1967
|
+
* than at the next event.
|
|
1968
|
+
*/
|
|
1969
|
+
refreshAnalyticsConsent(): void;
|
|
1914
1970
|
/**
|
|
1915
1971
|
* Ends whatever is in progress, a submit or a product selection, at once:
|
|
1916
1972
|
* call it when the work your handler started is done and the shopper is
|
|
@@ -2115,6 +2171,11 @@ declare class AIAutocomplete {
|
|
|
2115
2171
|
private applyOption;
|
|
2116
2172
|
private startSelectionAnimationTimer;
|
|
2117
2173
|
private resolveVisitorId;
|
|
2174
|
+
private resolveOwnVisitorId;
|
|
2175
|
+
/** The shopper's input after a search was handed off starts the next one. */
|
|
2176
|
+
private continueSearch;
|
|
2177
|
+
/** Remembers the search this tab ran last, for the storefront's own events. */
|
|
2178
|
+
private rememberSearch;
|
|
2118
2179
|
private resolveSource;
|
|
2119
2180
|
/**
|
|
2120
2181
|
* With `visible_impression`, the dropdown opening is itself an impression of
|
|
@@ -3710,4 +3771,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3710
3771
|
/** True when some pill is a question the shopper can decline. */
|
|
3711
3772
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3712
3773
|
|
|
3713
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3774
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LAST_SEARCH_KEY, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -264,6 +264,16 @@ interface AutocompleteResponse {
|
|
|
264
264
|
* shows. Absent means one for every response that changes it.
|
|
265
265
|
*/
|
|
266
266
|
visible_impression?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Set when the SDK may keep its own visitor id for a site that passes no
|
|
269
|
+
* `visitorId` and reports analytics consent. Absent means off.
|
|
270
|
+
*/
|
|
271
|
+
sdk_visitor_id?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Set when the SDK should send a `search_id`: the search each request and
|
|
274
|
+
* event belongs to. Absent means off.
|
|
275
|
+
*/
|
|
276
|
+
search_ids?: boolean;
|
|
267
277
|
/** The request's `schema_version`, echoed back. */
|
|
268
278
|
schema_version?: string;
|
|
269
279
|
};
|
|
@@ -1408,6 +1418,15 @@ interface CoreOptions {
|
|
|
1408
1418
|
* while it is off.
|
|
1409
1419
|
*/
|
|
1410
1420
|
visitorId?: string | (() => string | undefined);
|
|
1421
|
+
/**
|
|
1422
|
+
* Whether the visitor allowed analytics: `true`, `false`, or a function
|
|
1423
|
+
* returning either, or `undefined` while they have not answered. Once
|
|
1424
|
+
* allowed, and while the server has it on, a site that passes no `visitorId`
|
|
1425
|
+
* gets one kept for it in the first-party cookie `aia_vid` (a UUID v4, one
|
|
1426
|
+
* year, renewed on use). Declined, that cookie is removed. Omit it and the
|
|
1427
|
+
* SDK never touches the cookie. Ignored when `visitorId` is passed.
|
|
1428
|
+
*/
|
|
1429
|
+
analyticsConsent?: boolean | (() => boolean | undefined);
|
|
1411
1430
|
columns?: number;
|
|
1412
1431
|
/** Where pills render in "full" mode. Default: "dropdown". Ignored in "dropdown" mode (always in dropdown). */
|
|
1413
1432
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -1686,6 +1705,12 @@ type AIAutocompleteEvents = {
|
|
|
1686
1705
|
productSelect: [product: Product];
|
|
1687
1706
|
};
|
|
1688
1707
|
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1708
|
+
/**
|
|
1709
|
+
* Where the last search this tab handed off (a submit or a product pick) is
|
|
1710
|
+
* kept, for the storefront's own events (the Shopify Web Pixel reads it):
|
|
1711
|
+
* `{ id, at }`, `at` the handoff's time in epoch ms.
|
|
1712
|
+
*/
|
|
1713
|
+
declare const LAST_SEARCH_KEY = "aia:last-search";
|
|
1689
1714
|
declare class AIAutocomplete {
|
|
1690
1715
|
private inputStore;
|
|
1691
1716
|
private store;
|
|
@@ -1711,6 +1736,16 @@ declare class AIAutocomplete {
|
|
|
1711
1736
|
private subscriberCount;
|
|
1712
1737
|
private emitter;
|
|
1713
1738
|
private sessionId;
|
|
1739
|
+
/**
|
|
1740
|
+
* The search in progress. A new one starts with the instance, on reset(),
|
|
1741
|
+
* and with the shopper's next input after a submit or a product pick: what
|
|
1742
|
+
* they do after handing a search off is the next search.
|
|
1743
|
+
*/
|
|
1744
|
+
private searchId;
|
|
1745
|
+
/** A submit or product pick ended the search; the next input starts another. */
|
|
1746
|
+
private searchHandedOff;
|
|
1747
|
+
/** The server's `search_ids`: send the search with requests and events. */
|
|
1748
|
+
private searchIds;
|
|
1714
1749
|
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1715
1750
|
private lastRequestId;
|
|
1716
1751
|
/** Session that already sent `search_started`, so it fires once per session. */
|
|
@@ -1736,6 +1771,8 @@ declare class AIAutocomplete {
|
|
|
1736
1771
|
private lastImpressionKey;
|
|
1737
1772
|
/** The server's `visible_impression`: send an impression only while the dropdown is visible. */
|
|
1738
1773
|
private visibleImpression;
|
|
1774
|
+
/** The server's `sdk_visitor_id`: keep a visitor id for a host that passes none. */
|
|
1775
|
+
private sdkVisitorId;
|
|
1739
1776
|
private destroyed;
|
|
1740
1777
|
/** The location search in flight, so a newer phrase or destroy() can cancel it. */
|
|
1741
1778
|
private locationAbort;
|
|
@@ -1911,6 +1948,25 @@ declare class AIAutocomplete {
|
|
|
1911
1948
|
* own — a button you render — so each submit is counted once.
|
|
1912
1949
|
*/
|
|
1913
1950
|
recordSubmit(result: AutocompleteResult): void;
|
|
1951
|
+
/**
|
|
1952
|
+
* The search in progress, to send with your own events from it (a results
|
|
1953
|
+
* page, a cart). Undefined until the feature is enabled for your account
|
|
1954
|
+
* and the first response has said so. Read it in `onSubmit` or
|
|
1955
|
+
* `onProductSelect`: the shopper's next input starts another search.
|
|
1956
|
+
*/
|
|
1957
|
+
getSearchId(): string | undefined;
|
|
1958
|
+
/**
|
|
1959
|
+
* The visitor id this instance's events carry right now, to send with your
|
|
1960
|
+
* own events. Undefined while there is none: before the first response, or
|
|
1961
|
+
* without `visitorId` and without consent.
|
|
1962
|
+
*/
|
|
1963
|
+
getVisitorId(): string | undefined;
|
|
1964
|
+
/**
|
|
1965
|
+
* Reads `analyticsConsent` again now. Call it when the shopper changes their
|
|
1966
|
+
* choice, so a declined one removes the stored visitor id at once rather
|
|
1967
|
+
* than at the next event.
|
|
1968
|
+
*/
|
|
1969
|
+
refreshAnalyticsConsent(): void;
|
|
1914
1970
|
/**
|
|
1915
1971
|
* Ends whatever is in progress, a submit or a product selection, at once:
|
|
1916
1972
|
* call it when the work your handler started is done and the shopper is
|
|
@@ -2115,6 +2171,11 @@ declare class AIAutocomplete {
|
|
|
2115
2171
|
private applyOption;
|
|
2116
2172
|
private startSelectionAnimationTimer;
|
|
2117
2173
|
private resolveVisitorId;
|
|
2174
|
+
private resolveOwnVisitorId;
|
|
2175
|
+
/** The shopper's input after a search was handed off starts the next one. */
|
|
2176
|
+
private continueSearch;
|
|
2177
|
+
/** Remembers the search this tab ran last, for the storefront's own events. */
|
|
2178
|
+
private rememberSearch;
|
|
2118
2179
|
private resolveSource;
|
|
2119
2180
|
/**
|
|
2120
2181
|
* With `visible_impression`, the dropdown opening is itself an impression of
|
|
@@ -3710,4 +3771,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3710
3771
|
/** True when some pill is a question the shopper can decline. */
|
|
3711
3772
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3712
3773
|
|
|
3713
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3774
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LAST_SEARCH_KEY, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|