@magicx-eng/ai-autocomplete-vanilla 0.38.2 → 0.39.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 +1 -0
- package/dist/index.d.mts +25 -13
- package/dist/index.d.ts +25 -13
- 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
|
@@ -80,6 +80,7 @@ const ac = new AIAutocomplete(container, {
|
|
|
80
80
|
maskCompletedText: false, // when true, omits completed params' text from API requests (PII masking)
|
|
81
81
|
commitOnWordEnd: false, // true = a word still being typed never becomes a chip until a space, Enter, or Tab ends it (exact matches and server identified params). Picking an option is unchanged.
|
|
82
82
|
additionalContext: { tier: "gold" }, // optional user context, to personalize suggestions and options
|
|
83
|
+
language: "es", // BCP 47 tag sent with every suggestion request. Default: navigator.language, else "en-US"
|
|
83
84
|
|
|
84
85
|
// Appearance
|
|
85
86
|
mode: "auto", // "light" | "dark" | "auto"
|
package/dist/index.d.mts
CHANGED
|
@@ -931,6 +931,11 @@ interface CoreOptions {
|
|
|
931
931
|
* parameters and options to them.
|
|
932
932
|
*/
|
|
933
933
|
additionalContext?: Record<string, unknown>;
|
|
934
|
+
/**
|
|
935
|
+
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request.
|
|
936
|
+
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
937
|
+
*/
|
|
938
|
+
language?: string;
|
|
934
939
|
/**
|
|
935
940
|
* Stable id for this visitor, kept by the host across page loads (e.g. a
|
|
936
941
|
* first-party cookie). Rides on funnel telemetry so searches can be joined
|
|
@@ -2171,23 +2176,29 @@ interface ScrollArrowArgs {
|
|
|
2171
2176
|
declare function attachScrollArrow({ dropdown, grid, button, }: ScrollArrowArgs): ScrollArrowController;
|
|
2172
2177
|
|
|
2173
2178
|
/**
|
|
2174
|
-
* Small pictures from Shopify's image CDN, for PNG uploads.
|
|
2179
|
+
* Small pictures from Shopify's image CDN, for PNG and WebP uploads.
|
|
2175
2180
|
*
|
|
2176
2181
|
* A Shopify catalog's `image_url` is the original upload, drawn here in a
|
|
2177
2182
|
* 40px option square or a 116px product card. PNG product photos are the
|
|
2178
2183
|
* heavy ones: an 830×1080 PNG is 1–2 MB, and picking "Lehengas" on
|
|
2179
|
-
* gayathrisarees.com loaded 16.5 MB of them.
|
|
2180
|
-
*
|
|
2181
|
-
*
|
|
2184
|
+
* gayathrisarees.com loaded 16.5 MB of them. WebP uploads are lighter but
|
|
2185
|
+
* still far more than a tile needs: opening the search on solene.shop loaded
|
|
2186
|
+
* 992 KB of them for six category tiles, 48 KB at `width=120`. Shopify
|
|
2187
|
+
* resizes on request (`?width=`) and caches every resize at its edge. JPEG
|
|
2188
|
+
* uploads are left as they are (tens to a few hundred KB).
|
|
2182
2189
|
*
|
|
2183
2190
|
* `format=pjpg` is set too, because some PNG uploads carry megabytes of Adobe
|
|
2184
2191
|
* XMP metadata that Shopify copies into every resize: one Gayathri Sarees
|
|
2185
2192
|
* photo came back 1.6 MB at `width=200` as PNG and 4.1 MB as AVIF, while
|
|
2186
2193
|
* `width=200&format=pjpg` (a progressive JPEG, metadata dropped) was 28 KB.
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
*
|
|
2190
|
-
*
|
|
2194
|
+
* Shopify keeps a PNG that has an alpha channel as WebP/AVIF instead, so a
|
|
2195
|
+
* transparent cut-out is never flattened. A WebP upload gets `width` alone:
|
|
2196
|
+
* it has no such bloat, and Shopify's own pick (AVIF or WebP) is smaller than
|
|
2197
|
+
* a JPEG (48 KB against 68 KB for Solene's twelve).
|
|
2198
|
+
*
|
|
2199
|
+
* Only Shopify-hosted PNG and WebP files are touched —
|
|
2200
|
+
* `cdn.shopify.com/s/files/…` and a store's own `/cdn/shop/…`. Any other URL
|
|
2201
|
+
* comes back unchanged. The widths are fixed
|
|
2191
2202
|
* (three times the default drawn size, for 3× phone screens) rather than
|
|
2192
2203
|
* measured, so every visitor asks for the same URL and hits the same cached
|
|
2193
2204
|
* resize.
|
|
@@ -2197,22 +2208,23 @@ declare const OPTION_IMAGE_WIDTH = 120;
|
|
|
2197
2208
|
/** Product-strip cards (116px). */
|
|
2198
2209
|
declare const PRODUCT_IMAGE_WIDTH = 360;
|
|
2199
2210
|
/**
|
|
2200
|
-
* `url` asked for at `width`
|
|
2201
|
-
* otherwise `url` unchanged. Any `width`
|
|
2202
|
-
* replaced; other parameters (`v=`, the
|
|
2211
|
+
* `url` asked for at `width` when it is a Shopify-hosted PNG (with
|
|
2212
|
+
* `format=pjpg`) or WebP; otherwise `url` unchanged. Any `width` already on
|
|
2213
|
+
* the URL is replaced, and a PNG's `format` too; other parameters (`v=`, the
|
|
2214
|
+
* cache-busting version) are kept. A
|
|
2203
2215
|
* root-relative URL (a store's own `/cdn/shop/…`) is read against the page and
|
|
2204
2216
|
* stays relative.
|
|
2205
2217
|
*/
|
|
2206
2218
|
declare function shopifyImageSrc(url: string, width: number): string;
|
|
2207
2219
|
/**
|
|
2208
2220
|
* The URLs a product card tries for `imageUrl`, in order (`imageSources` at
|
|
2209
|
-
* the card width): trimmed, sized down when it is a Shopify-hosted PNG, with
|
|
2221
|
+
* the card width): trimmed, sized down when it is a Shopify-hosted PNG or WebP, with
|
|
2210
2222
|
* the original as the fallback. Empty for an absent or blank URL.
|
|
2211
2223
|
*/
|
|
2212
2224
|
declare function productImageSources(url: string | null | undefined): string[];
|
|
2213
2225
|
/**
|
|
2214
2226
|
* The `src` a product card draws `imageUrl` with first: trimmed, and sized
|
|
2215
|
-
* down when it is a Shopify-hosted PNG. `undefined` for an absent or blank URL.
|
|
2227
|
+
* down when it is a Shopify-hosted PNG or WebP. `undefined` for an absent or blank URL.
|
|
2216
2228
|
*/
|
|
2217
2229
|
declare function productImageSrc(url: string | null | undefined): string | undefined;
|
|
2218
2230
|
|
package/dist/index.d.ts
CHANGED
|
@@ -931,6 +931,11 @@ interface CoreOptions {
|
|
|
931
931
|
* parameters and options to them.
|
|
932
932
|
*/
|
|
933
933
|
additionalContext?: Record<string, unknown>;
|
|
934
|
+
/**
|
|
935
|
+
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request.
|
|
936
|
+
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
937
|
+
*/
|
|
938
|
+
language?: string;
|
|
934
939
|
/**
|
|
935
940
|
* Stable id for this visitor, kept by the host across page loads (e.g. a
|
|
936
941
|
* first-party cookie). Rides on funnel telemetry so searches can be joined
|
|
@@ -2171,23 +2176,29 @@ interface ScrollArrowArgs {
|
|
|
2171
2176
|
declare function attachScrollArrow({ dropdown, grid, button, }: ScrollArrowArgs): ScrollArrowController;
|
|
2172
2177
|
|
|
2173
2178
|
/**
|
|
2174
|
-
* Small pictures from Shopify's image CDN, for PNG uploads.
|
|
2179
|
+
* Small pictures from Shopify's image CDN, for PNG and WebP uploads.
|
|
2175
2180
|
*
|
|
2176
2181
|
* A Shopify catalog's `image_url` is the original upload, drawn here in a
|
|
2177
2182
|
* 40px option square or a 116px product card. PNG product photos are the
|
|
2178
2183
|
* heavy ones: an 830×1080 PNG is 1–2 MB, and picking "Lehengas" on
|
|
2179
|
-
* gayathrisarees.com loaded 16.5 MB of them.
|
|
2180
|
-
*
|
|
2181
|
-
*
|
|
2184
|
+
* gayathrisarees.com loaded 16.5 MB of them. WebP uploads are lighter but
|
|
2185
|
+
* still far more than a tile needs: opening the search on solene.shop loaded
|
|
2186
|
+
* 992 KB of them for six category tiles, 48 KB at `width=120`. Shopify
|
|
2187
|
+
* resizes on request (`?width=`) and caches every resize at its edge. JPEG
|
|
2188
|
+
* uploads are left as they are (tens to a few hundred KB).
|
|
2182
2189
|
*
|
|
2183
2190
|
* `format=pjpg` is set too, because some PNG uploads carry megabytes of Adobe
|
|
2184
2191
|
* XMP metadata that Shopify copies into every resize: one Gayathri Sarees
|
|
2185
2192
|
* photo came back 1.6 MB at `width=200` as PNG and 4.1 MB as AVIF, while
|
|
2186
2193
|
* `width=200&format=pjpg` (a progressive JPEG, metadata dropped) was 28 KB.
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
*
|
|
2190
|
-
*
|
|
2194
|
+
* Shopify keeps a PNG that has an alpha channel as WebP/AVIF instead, so a
|
|
2195
|
+
* transparent cut-out is never flattened. A WebP upload gets `width` alone:
|
|
2196
|
+
* it has no such bloat, and Shopify's own pick (AVIF or WebP) is smaller than
|
|
2197
|
+
* a JPEG (48 KB against 68 KB for Solene's twelve).
|
|
2198
|
+
*
|
|
2199
|
+
* Only Shopify-hosted PNG and WebP files are touched —
|
|
2200
|
+
* `cdn.shopify.com/s/files/…` and a store's own `/cdn/shop/…`. Any other URL
|
|
2201
|
+
* comes back unchanged. The widths are fixed
|
|
2191
2202
|
* (three times the default drawn size, for 3× phone screens) rather than
|
|
2192
2203
|
* measured, so every visitor asks for the same URL and hits the same cached
|
|
2193
2204
|
* resize.
|
|
@@ -2197,22 +2208,23 @@ declare const OPTION_IMAGE_WIDTH = 120;
|
|
|
2197
2208
|
/** Product-strip cards (116px). */
|
|
2198
2209
|
declare const PRODUCT_IMAGE_WIDTH = 360;
|
|
2199
2210
|
/**
|
|
2200
|
-
* `url` asked for at `width`
|
|
2201
|
-
* otherwise `url` unchanged. Any `width`
|
|
2202
|
-
* replaced; other parameters (`v=`, the
|
|
2211
|
+
* `url` asked for at `width` when it is a Shopify-hosted PNG (with
|
|
2212
|
+
* `format=pjpg`) or WebP; otherwise `url` unchanged. Any `width` already on
|
|
2213
|
+
* the URL is replaced, and a PNG's `format` too; other parameters (`v=`, the
|
|
2214
|
+
* cache-busting version) are kept. A
|
|
2203
2215
|
* root-relative URL (a store's own `/cdn/shop/…`) is read against the page and
|
|
2204
2216
|
* stays relative.
|
|
2205
2217
|
*/
|
|
2206
2218
|
declare function shopifyImageSrc(url: string, width: number): string;
|
|
2207
2219
|
/**
|
|
2208
2220
|
* The URLs a product card tries for `imageUrl`, in order (`imageSources` at
|
|
2209
|
-
* the card width): trimmed, sized down when it is a Shopify-hosted PNG, with
|
|
2221
|
+
* the card width): trimmed, sized down when it is a Shopify-hosted PNG or WebP, with
|
|
2210
2222
|
* the original as the fallback. Empty for an absent or blank URL.
|
|
2211
2223
|
*/
|
|
2212
2224
|
declare function productImageSources(url: string | null | undefined): string[];
|
|
2213
2225
|
/**
|
|
2214
2226
|
* The `src` a product card draws `imageUrl` with first: trimmed, and sized
|
|
2215
|
-
* down when it is a Shopify-hosted PNG. `undefined` for an absent or blank URL.
|
|
2227
|
+
* down when it is a Shopify-hosted PNG or WebP. `undefined` for an absent or blank URL.
|
|
2216
2228
|
*/
|
|
2217
2229
|
declare function productImageSrc(url: string | null | undefined): string | undefined;
|
|
2218
2230
|
|