@magicx-eng/ai-autocomplete-vanilla 0.38.0 → 0.38.2

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/dist/index.d.mts CHANGED
@@ -1963,9 +1963,17 @@ declare function scrollCaretIntoView(root: HTMLElement): void;
1963
1963
  * not be loaded. Only an `http(s)` URL is accepted — resolved against the
1964
1964
  * page, so a root-relative path from a same-origin catalog still works —
1965
1965
  * which keeps `javascript:`, `data:` and `blob:` sources out of an `<img>`
1966
- * the server populates.
1966
+ * the server populates. A Shopify-hosted picture is asked for at a thumbnail
1967
+ * width (`shopifyImageSrc`) rather than as the full-size original.
1967
1968
  */
1968
1969
  declare function optionImageSrc(url: string | undefined): string | null;
1970
+ /**
1971
+ * The URLs an option row tries for `image_url`, in order: what
1972
+ * `optionImageSrc` returns, then the original when that was a Shopify
1973
+ * thumbnail, for an `<img>` whose first load fails. Empty when the URL must
1974
+ * not be loaded.
1975
+ */
1976
+ declare function optionImageSources(url: string | undefined): string[];
1969
1977
  /**
1970
1978
  * An option's `item_count` as the built-in rows print it: the number alone,
1971
1979
  * grouped the way the page's locale groups numbers (`"1,200"`). The unit word
@@ -2162,6 +2170,52 @@ interface ScrollArrowArgs {
2162
2170
  }
2163
2171
  declare function attachScrollArrow({ dropdown, grid, button, }: ScrollArrowArgs): ScrollArrowController;
2164
2172
 
2173
+ /**
2174
+ * Small pictures from Shopify's image CDN, for PNG uploads.
2175
+ *
2176
+ * A Shopify catalog's `image_url` is the original upload, drawn here in a
2177
+ * 40px option square or a 116px product card. PNG product photos are the
2178
+ * heavy ones: an 830×1080 PNG is 1–2 MB, and picking "Lehengas" on
2179
+ * gayathrisarees.com loaded 16.5 MB of them. Shopify resizes on request
2180
+ * (`?width=`) and caches every resize at its edge. JPEG uploads are left as
2181
+ * they are (tens to a few hundred KB).
2182
+ *
2183
+ * `format=pjpg` is set too, because some PNG uploads carry megabytes of Adobe
2184
+ * XMP metadata that Shopify copies into every resize: one Gayathri Sarees
2185
+ * photo came back 1.6 MB at `width=200` as PNG and 4.1 MB as AVIF, while
2186
+ * `width=200&format=pjpg` (a progressive JPEG, metadata dropped) was 28 KB.
2187
+ * JPEG has no transparency, which product photos don't use.
2188
+ *
2189
+ * Only Shopify-hosted PNGs are touched — `cdn.shopify.com/s/files/…` and a
2190
+ * store's own `/cdn/shop/…`. Any other URL comes back unchanged. The widths are fixed
2191
+ * (three times the default drawn size, for 3× phone screens) rather than
2192
+ * measured, so every visitor asks for the same URL and hits the same cached
2193
+ * resize.
2194
+ */
2195
+ /** Option thumbnails (40px) and completed-chip pictures (20px). */
2196
+ declare const OPTION_IMAGE_WIDTH = 120;
2197
+ /** Product-strip cards (116px). */
2198
+ declare const PRODUCT_IMAGE_WIDTH = 360;
2199
+ /**
2200
+ * `url` asked for at `width` with `format=pjpg` when it is a Shopify-hosted PNG;
2201
+ * otherwise `url` unchanged. Any `width` or `format` already on the URL is
2202
+ * replaced; other parameters (`v=`, the cache-busting version) are kept. A
2203
+ * root-relative URL (a store's own `/cdn/shop/…`) is read against the page and
2204
+ * stays relative.
2205
+ */
2206
+ declare function shopifyImageSrc(url: string, width: number): string;
2207
+ /**
2208
+ * 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
2210
+ * the original as the fallback. Empty for an absent or blank URL.
2211
+ */
2212
+ declare function productImageSources(url: string | null | undefined): string[];
2213
+ /**
2214
+ * 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.
2216
+ */
2217
+ declare function productImageSrc(url: string | null | undefined): string | undefined;
2218
+
2165
2219
  type Listener<S> = (next: S, prev: S) => void;
2166
2220
  interface Store<S> {
2167
2221
  get: () => S;
@@ -2367,4 +2421,4 @@ interface SubmitResultExtras {
2367
2421
  */
2368
2422
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
2369
2423
 
2370
- 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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, 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, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, 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, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
2424
+ 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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, 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, 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 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, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
package/dist/index.d.ts CHANGED
@@ -1963,9 +1963,17 @@ declare function scrollCaretIntoView(root: HTMLElement): void;
1963
1963
  * not be loaded. Only an `http(s)` URL is accepted — resolved against the
1964
1964
  * page, so a root-relative path from a same-origin catalog still works —
1965
1965
  * which keeps `javascript:`, `data:` and `blob:` sources out of an `<img>`
1966
- * the server populates.
1966
+ * the server populates. A Shopify-hosted picture is asked for at a thumbnail
1967
+ * width (`shopifyImageSrc`) rather than as the full-size original.
1967
1968
  */
1968
1969
  declare function optionImageSrc(url: string | undefined): string | null;
1970
+ /**
1971
+ * The URLs an option row tries for `image_url`, in order: what
1972
+ * `optionImageSrc` returns, then the original when that was a Shopify
1973
+ * thumbnail, for an `<img>` whose first load fails. Empty when the URL must
1974
+ * not be loaded.
1975
+ */
1976
+ declare function optionImageSources(url: string | undefined): string[];
1969
1977
  /**
1970
1978
  * An option's `item_count` as the built-in rows print it: the number alone,
1971
1979
  * grouped the way the page's locale groups numbers (`"1,200"`). The unit word
@@ -2162,6 +2170,52 @@ interface ScrollArrowArgs {
2162
2170
  }
2163
2171
  declare function attachScrollArrow({ dropdown, grid, button, }: ScrollArrowArgs): ScrollArrowController;
2164
2172
 
2173
+ /**
2174
+ * Small pictures from Shopify's image CDN, for PNG uploads.
2175
+ *
2176
+ * A Shopify catalog's `image_url` is the original upload, drawn here in a
2177
+ * 40px option square or a 116px product card. PNG product photos are the
2178
+ * heavy ones: an 830×1080 PNG is 1–2 MB, and picking "Lehengas" on
2179
+ * gayathrisarees.com loaded 16.5 MB of them. Shopify resizes on request
2180
+ * (`?width=`) and caches every resize at its edge. JPEG uploads are left as
2181
+ * they are (tens to a few hundred KB).
2182
+ *
2183
+ * `format=pjpg` is set too, because some PNG uploads carry megabytes of Adobe
2184
+ * XMP metadata that Shopify copies into every resize: one Gayathri Sarees
2185
+ * photo came back 1.6 MB at `width=200` as PNG and 4.1 MB as AVIF, while
2186
+ * `width=200&format=pjpg` (a progressive JPEG, metadata dropped) was 28 KB.
2187
+ * JPEG has no transparency, which product photos don't use.
2188
+ *
2189
+ * Only Shopify-hosted PNGs are touched — `cdn.shopify.com/s/files/…` and a
2190
+ * store's own `/cdn/shop/…`. Any other URL comes back unchanged. The widths are fixed
2191
+ * (three times the default drawn size, for 3× phone screens) rather than
2192
+ * measured, so every visitor asks for the same URL and hits the same cached
2193
+ * resize.
2194
+ */
2195
+ /** Option thumbnails (40px) and completed-chip pictures (20px). */
2196
+ declare const OPTION_IMAGE_WIDTH = 120;
2197
+ /** Product-strip cards (116px). */
2198
+ declare const PRODUCT_IMAGE_WIDTH = 360;
2199
+ /**
2200
+ * `url` asked for at `width` with `format=pjpg` when it is a Shopify-hosted PNG;
2201
+ * otherwise `url` unchanged. Any `width` or `format` already on the URL is
2202
+ * replaced; other parameters (`v=`, the cache-busting version) are kept. A
2203
+ * root-relative URL (a store's own `/cdn/shop/…`) is read against the page and
2204
+ * stays relative.
2205
+ */
2206
+ declare function shopifyImageSrc(url: string, width: number): string;
2207
+ /**
2208
+ * 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
2210
+ * the original as the fallback. Empty for an absent or blank URL.
2211
+ */
2212
+ declare function productImageSources(url: string | null | undefined): string[];
2213
+ /**
2214
+ * 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.
2216
+ */
2217
+ declare function productImageSrc(url: string | null | undefined): string | undefined;
2218
+
2165
2219
  type Listener<S> = (next: S, prev: S) => void;
2166
2220
  interface Store<S> {
2167
2221
  get: () => S;
@@ -2367,4 +2421,4 @@ interface SubmitResultExtras {
2367
2421
  */
2368
2422
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
2369
2423
 
2370
- 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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, 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, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, 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, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
2424
+ 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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, 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, 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 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, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, visibleDateRange, withSkippedParams };