@nosto/search-js 1.4.1 → 1.5.1

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.
Files changed (69) hide show
  1. package/README.md +3 -39
  2. package/dist/core/core.d.ts +2 -2
  3. package/dist/core/src/applyDecorators.d.ts +9 -9
  4. package/dist/core/src/search.d.ts +9 -9
  5. package/dist/core/src/searchWithRetries.d.ts +2 -2
  6. package/dist/core/src/types.d.ts +5 -6
  7. package/dist/currencies/currencies.d.ts +2 -2
  8. package/dist/currencies/src/getCurrencyFormatting.d.ts +2 -3
  9. package/dist/currencies/src/priceDecorator.d.ts +2 -2
  10. package/dist/preact/preact.cjs.js +1 -1
  11. package/dist/preact/preact.d.ts +24 -5
  12. package/dist/preact/preact.es.js +741 -100
  13. package/dist/preact/src/actions/newSearch.d.ts +4 -0
  14. package/dist/preact/src/actions/replaceFilter.d.ts +3 -0
  15. package/dist/preact/src/actions/toggleProductFilter.d.ts +2 -0
  16. package/dist/preact/src/actions/types.d.ts +6 -0
  17. package/dist/preact/src/actions/updateSearch.d.ts +4 -0
  18. package/dist/preact/src/api/types.d.ts +4 -0
  19. package/dist/preact/src/components/SearchInput.d.ts +7 -0
  20. package/dist/preact/src/components/SerpElement.d.ts +18 -0
  21. package/dist/preact/src/config/base/baseConfig.d.ts +41 -0
  22. package/dist/preact/src/config/config.d.ts +4 -0
  23. package/dist/preact/src/config/configContext.d.ts +6 -0
  24. package/dist/preact/src/config/pages/autocomplete/config.d.ts +15 -0
  25. package/dist/preact/src/config/pages/autocomplete/provider.d.ts +10 -0
  26. package/dist/preact/src/config/pages/category/config.d.ts +44 -0
  27. package/dist/preact/src/config/pages/category/provider.d.ts +10 -0
  28. package/dist/preact/src/config/pages/serp/config.d.ts +34 -0
  29. package/dist/preact/src/config/pages/serp/provider.d.ts +10 -0
  30. package/dist/preact/src/dom/renderHeadless.d.ts +18 -0
  31. package/dist/preact/src/dom/utils.d.ts +5 -0
  32. package/dist/preact/src/hooks/useActions.d.ts +32 -0
  33. package/dist/preact/src/hooks/useCheckClientScript.d.ts +1 -0
  34. package/dist/preact/src/hooks/useDecoratedSearchResults.d.ts +27 -0
  35. package/dist/preact/src/hooks/useFacet.d.ts +60 -0
  36. package/dist/preact/src/hooks/useFacets.d.ts +39 -0
  37. package/dist/preact/src/hooks/useNostoAppState.d.ts +1 -1
  38. package/dist/preact/src/hooks/usePersonalization.d.ts +1 -1
  39. package/dist/preact/src/hooks/useProductFilters/useProductFilters.d.ts +59 -0
  40. package/dist/preact/src/hooks/useProductFilters/useProductFiltersUtils.d.ts +48 -0
  41. package/dist/preact/src/hooks/useRange.d.ts +34 -0
  42. package/dist/preact/src/hooks/useRangeSelector.d.ts +98 -0
  43. package/dist/preact/src/hooks/useResponse.d.ts +82 -0
  44. package/dist/preact/src/hooks/useSelectedFiltersCount.d.ts +17 -0
  45. package/dist/preact/src/hooks/useSizeOptions.d.ts +50 -0
  46. package/dist/preact/src/hooks/useSort/useSort.d.ts +47 -0
  47. package/dist/preact/src/hooks/useSort/utils.d.ts +9 -0
  48. package/dist/preact/src/search/defaults.d.ts +45 -0
  49. package/dist/preact/src/search/resultCaching.d.ts +4 -0
  50. package/dist/preact/src/store.d.ts +9 -1387
  51. package/dist/preact/src/storeContext.d.ts +5 -1389
  52. package/dist/preact/src/storeExtensions.d.ts +17 -0
  53. package/dist/thumbnails/src/generateThumbnailUrl.d.ts +1 -1
  54. package/dist/thumbnails/src/nostoThumbnailDecorator.d.ts +2 -2
  55. package/dist/thumbnails/src/shopifyThumbnailDecorator.d.ts +2 -2
  56. package/dist/thumbnails/src/thumbnailDecorator.d.ts +2 -2
  57. package/dist/thumbnails/thumbnails.d.ts +5 -5
  58. package/dist/utils/src/deepFreeze.d.ts +1 -1
  59. package/dist/utils/src/deepMerge.d.ts +5 -3
  60. package/dist/utils/src/mergeArrays.d.ts +2 -1
  61. package/dist/utils/src/parseNumber.d.ts +1 -0
  62. package/dist/utils/src/performance.d.ts +1 -0
  63. package/dist/utils/src/savePageScroll.d.ts +2 -0
  64. package/dist/utils/src/simplify.d.ts +1 -1
  65. package/dist/utils/src/storage.d.ts +6 -0
  66. package/dist/utils/src/types.d.ts +3 -0
  67. package/dist/utils/src/unique.d.ts +1 -0
  68. package/package.json +22 -15
  69. package/dist/preact/test/mocks/mocks.d.ts +0 -1384
@@ -0,0 +1,17 @@
1
+ import { State as BaseState } from './store';
2
+ /**
3
+ * Create an extendable Nosto store with any state object.
4
+ * @param defaultState Default state object.
5
+ * @param overrides Initial state overrides.
6
+ *
7
+ * While not as powerful as established store management libraries, Nosto store is a viable way to manage state in your app.
8
+ * This store may be useful for smaller deployments or when you want to avoid the complexity of a larger library.
9
+ */
10
+ export declare function createExtendableStore<State extends BaseState>(defaultState: State, overrides?: Partial<State>): {
11
+ updateState: (newState: Partial<State>) => void;
12
+ getState: () => State;
13
+ getInitialState: () => State;
14
+ onChange: <T>(selector: (state: State) => T, callback: (piece: T) => void) => void;
15
+ clearOnChange: <T>(callback: (piece: T) => void) => void;
16
+ };
17
+ export type ExtendedStore<T extends BaseState> = ReturnType<typeof createExtendableStore<T>>;
@@ -1,4 +1,4 @@
1
- import { NostoSize } from "./types";
1
+ import { NostoSize } from './types';
2
2
  export type Config = {
3
3
  size: NostoSize;
4
4
  productId: string;
@@ -1,5 +1,5 @@
1
- import { SearchProduct } from "@nosto/nosto-js/client";
2
- import { NostoSize } from "./types";
1
+ import { SearchProduct } from '@nosto/nosto-js/client';
2
+ import { NostoSize } from './types';
3
3
  export type Config = {
4
4
  size: NostoSize;
5
5
  };
@@ -1,5 +1,5 @@
1
- import { SearchProduct } from "@nosto/nosto-js/client";
2
- import { NostoShopifySize, ShopifySize } from "./types";
1
+ import { SearchProduct } from '@nosto/nosto-js/client';
2
+ import { NostoShopifySize, ShopifySize } from './types';
3
3
  export type Config = {
4
4
  size: ShopifySize | NostoShopifySize | "orig";
5
5
  fallback?: (hit: SearchProduct) => SearchProduct;
@@ -1,4 +1,4 @@
1
- import { NostoSize } from "./types";
1
+ import { NostoSize } from './types';
2
2
  export type Config = {
3
3
  size: NostoSize;
4
4
  };
@@ -6,4 +6,4 @@ export type Config = {
6
6
  * Replaces full size images with thumbnail sized versions.
7
7
  * Uses `shopifyThumbnailDecorator` and `nostoThumbnailDecorator` based on the platform.
8
8
  */
9
- export declare function thumbnailDecorator({ size }: Config): (hit: import("@nosto/nosto-js/client").SearchProduct) => import("@nosto/nosto-js/client").SearchProduct;
9
+ export declare function thumbnailDecorator({ size }: Config): (hit: import('@nosto/nosto-js/client').SearchProduct) => import('@nosto/nosto-js/client').SearchProduct;
@@ -1,6 +1,6 @@
1
1
  /** @module thumbnails */
2
- export { generateThumbnailUrl, type Config as GenerateThumbnailUrlConfig } from "./src/generateThumbnailUrl";
3
- export { nostoThumbnailDecorator, type Config as NostoThumbnailDecoratorConfig } from "./src/nostoThumbnailDecorator";
4
- export { shopifyThumbnailDecorator, type Config as ShopifyThumbnailDecoratorConfig } from "./src/shopifyThumbnailDecorator";
5
- export { thumbnailDecorator, type Config as ThumbnailDecoratorConfig } from "./src/thumbnailDecorator";
6
- export type { NostoShopifySize, NostoSize, ShopifySize } from "./src/types";
2
+ export { generateThumbnailUrl, type Config as GenerateThumbnailUrlConfig } from './src/generateThumbnailUrl';
3
+ export { nostoThumbnailDecorator, type Config as NostoThumbnailDecoratorConfig } from './src/nostoThumbnailDecorator';
4
+ export { shopifyThumbnailDecorator, type Config as ShopifyThumbnailDecoratorConfig } from './src/shopifyThumbnailDecorator';
5
+ export { thumbnailDecorator, type Config as ThumbnailDecoratorConfig } from './src/thumbnailDecorator';
6
+ export type { NostoShopifySize, NostoSize, ShopifySize } from './src/types';
@@ -1,4 +1,4 @@
1
- import { Equals, Expect } from "./types";
1
+ import { Equals, Expect } from './types';
2
2
  export declare const deepFreeze: <T extends object>(obj: T) => Readonly<Freeze<T>>;
3
3
  type Freeze<T> = T extends object ? Readonly<{
4
4
  [K in keyof T]: Freeze<T[K]>;
@@ -1,7 +1,9 @@
1
- import type { Simplify } from "./simplify";
2
- import type { Equals, Expect } from "./types";
1
+ import { Simplify } from './simplify';
2
+ import { Equals, Expect } from './types';
3
3
  export declare function deepMerge<T extends unknown[]>(...objects: T): Merge<T>;
4
+ export declare function deepMergePlain<T extends unknown[]>(...objects: T): PlainMerge<T>;
4
5
  type Merge<T, U = unknown> = T extends [infer First, ...infer Rest] ? Merge<Rest, U & First> : Simplify<U>;
6
+ type PlainMerge<T, U = unknown> = T extends [infer First, ...infer Rest] ? PlainMerge<Rest, U & First> : U;
5
7
  export type MergeTests = [
6
8
  Expect<Equals<Merge<[{
7
9
  a: string;
@@ -16,7 +18,7 @@ export type MergeTests = [
16
18
  }, {
17
19
  a: number;
18
20
  }]>, {
19
- a: string & number;
21
+ a: never;
20
22
  }>>,
21
23
  Expect<Equals<Merge<[{
22
24
  a: string | undefined;
@@ -1 +1,2 @@
1
- export declare function mergeArrays<T extends (unknown[] | undefined | null)[]>(...objects: T): T[number];
1
+ import { Unfreeze } from './types';
2
+ export declare function mergeArrays<T extends (unknown[] | readonly unknown[] | undefined | null)[]>(...objects: T): Unfreeze<T>[number];
@@ -0,0 +1 @@
1
+ export declare function parseNumber(value: unknown): number | undefined;
@@ -0,0 +1 @@
1
+ export declare function measure(name: string): () => void;
@@ -0,0 +1,2 @@
1
+ export declare function savePageScroll(): void;
2
+ export declare function restoreSavedScroll(): void;
@@ -1,4 +1,4 @@
1
- import { Equals, Expect } from "./types";
1
+ import { Equals, Expect } from './types';
2
2
  export type Simplify<T> = T extends infer O ? {
3
3
  [K in keyof O]: O[K];
4
4
  } : never;
@@ -0,0 +1,6 @@
1
+ export declare function setLocalStorageItem(name: string, value: unknown): void;
2
+ export declare function setSessionStorageItem(name: string, value: unknown): void;
3
+ export declare function getLocalStorageItem<T>(name: string): T | undefined;
4
+ export declare function getSessionStorageItem<T>(name: string): T | undefined;
5
+ export declare function removeLocalStorageItem(name: string): void;
6
+ export declare function removeSessionStorageItem(name: string): void;
@@ -1,3 +1,6 @@
1
1
  export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
2
2
  export type Expect<T extends true> = T;
3
3
  export type MaybeArray<T> = T | T[];
4
+ export type Unfreeze<T> = T extends object ? {
5
+ -readonly [K in keyof T]: Unfreeze<T[K]>;
6
+ } : T;
@@ -0,0 +1 @@
1
+ export declare function unique<T>(arr: T[]): T[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -41,33 +41,40 @@
41
41
  "keywords": [],
42
42
  "author": "Nosto",
43
43
  "scripts": {
44
- "build": "tsc && vite build && npm run build-dts && npm run typedoc",
45
- "build-dts": "tsc --project tsconfig.build.json",
46
- "typedoc": "typedoc",
47
- "test": "vitest --run",
44
+ "build": "tsc && vite build && npm run typedoc",
45
+ "dev": "concurrently \"npm run dev:library\" \"npm run dev:preact\"",
46
+ "dev:library": "vite build --watch",
47
+ "dev:preact": "cd dev/preact && npm run dev",
48
+ "typedoc": "typedoc --treatWarningsAsErrors",
49
+ "test": "vitest --run && (cd dev/preact && npm run test)",
48
50
  "test:watch": "vitest",
49
51
  "lint": "eslint",
50
- "lint-fix": "eslint --fix"
52
+ "lint-fix": "eslint --fix",
53
+ "install:dev": "(cd dev/preact && npm i --ignore-scripts)"
51
54
  },
52
55
  "devDependencies": {
53
56
  "@nosto/nosto-js": "^1.5.0",
54
57
  "@testing-library/dom": "^10.4.0",
55
58
  "@types/eslint-config-prettier": "^6.11.3",
56
- "@types/node": "^22.13.5",
59
+ "@types/node": "^22.13.10",
60
+ "concurrently": "^9.1.2",
57
61
  "copyfiles": "^2.4.1",
58
- "eslint": "^9.21.0",
59
- "eslint-config-prettier": "^10.0.1",
62
+ "eslint": "^9.22.0",
63
+ "eslint-config-prettier": "^10.1.1",
60
64
  "eslint-plugin-barrel-files": "^3.0.1",
61
65
  "eslint-plugin-prettier": "^5.2.3",
62
66
  "eslint-plugin-simple-import-sort": "^12.1.1",
63
67
  "eslint-plugin-unused-imports": "^4.1.4",
68
+ "eslint-plugin-react": "^7.37.4",
69
+ "eslint-plugin-react-hooks": "^5.2.0",
64
70
  "jsdom": "^26.0.0",
65
- "prettier": "^3.5.2",
66
- "typedoc": "^0.27.8",
67
- "typescript": "^5.7.3",
68
- "typescript-eslint": "^8.25.0",
69
- "vite": "^6.2.0",
70
- "vitest": "^3.0.7"
71
+ "prettier": "^3.5.3",
72
+ "typedoc": "^0.27.9",
73
+ "typescript": "^5.8.2",
74
+ "typescript-eslint": "^8.26.0",
75
+ "vite": "^6.2.1",
76
+ "vite-plugin-dts": "^4.5.3",
77
+ "vitest": "^3.0.8"
71
78
  },
72
79
  "publishConfig": {
73
80
  "access": "public"