pinelab-storefront-client
Advanced tools
Comparing version 0.53.0 to 0.53.1
import { CalculatedProduct } from './product.util'; | ||
import { Collection } from '../generated/graphql'; | ||
import Fuse from 'fuse.js'; | ||
import IFuseOptions = Fuse.IFuseOptions; | ||
import type Fuse from 'fuse.js'; | ||
export interface SearchItem { | ||
@@ -31,21 +30,23 @@ name?: string; | ||
} | ||
/** | ||
* Create an pre-compiled index object. Stringify this object | ||
* and save as publicly available JSON file, so that your | ||
* Storefront can fetch this object and init a Fuse | ||
* search engine on the client | ||
*/ | ||
export declare function createSearchIndex( | ||
products: SearchableProduct[], | ||
keys: KeyWeight[] | ||
): SearchIndexObject; | ||
/** | ||
* Create Fuse instance based on the given indexObject | ||
* This instance can be use in your storefront to | ||
* search through products | ||
*/ | ||
export declare function createFuse( | ||
indexObject: SearchIndexObject, | ||
options: IFuseOptions<unknown> | ||
): Fuse<any>; | ||
export declare class SearchUtil { | ||
private fuse; | ||
constructor(fuse: typeof Fuse); | ||
/** | ||
* Create an pre-compiled index object. Stringify this object | ||
* and save as publicly available JSON file, so that your | ||
* Storefront can fetch this object and init a Fuse | ||
* search engine on the client | ||
*/ | ||
createSearchIndex( | ||
products: SearchableProduct[], | ||
keys: KeyWeight[] | ||
): SearchIndexObject; | ||
createSearchItems(products: SearchableProduct[]): SearchItem[]; | ||
/** | ||
* Create Fuse instance based on the given indexObject | ||
* This instance can be use in your storefront to | ||
* search through products | ||
*/ | ||
createFuse(indexObject: SearchIndexObject, options: any): Fuse<any>; | ||
} | ||
export {}; |
@@ -17,65 +17,64 @@ 'use strict'; | ||
}; | ||
var __importDefault = | ||
(this && this.__importDefault) || | ||
function (mod) { | ||
return mod && mod.__esModule ? mod : { default: mod }; | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.createFuse = exports.createSearchIndex = void 0; | ||
var fuse_js_1 = __importDefault(require('fuse.js')); | ||
/** | ||
* Create an pre-compiled index object. Stringify this object | ||
* and save as publicly available JSON file, so that your | ||
* Storefront can fetch this object and init a Fuse | ||
* search engine on the client | ||
*/ | ||
function createSearchIndex(products, keys) { | ||
var searchItems = createSearchItems(products); | ||
var fuseIndex = fuse_js_1.default.createIndex(keys, searchItems); | ||
return { | ||
index: fuseIndex.toJSON(), | ||
items: searchItems, | ||
keys: keys, | ||
exports.SearchUtil = void 0; | ||
var SearchUtil = /** @class */ (function () { | ||
function SearchUtil(fuse) { | ||
this.fuse = fuse; | ||
} | ||
/** | ||
* Create an pre-compiled index object. Stringify this object | ||
* and save as publicly available JSON file, so that your | ||
* Storefront can fetch this object and init a Fuse | ||
* search engine on the client | ||
*/ | ||
SearchUtil.prototype.createSearchIndex = function (products, keys) { | ||
var searchItems = this.createSearchItems(products); | ||
var fuseIndex = this.fuse.createIndex(keys, searchItems); | ||
return { | ||
index: fuseIndex.toJSON(), | ||
items: searchItems, | ||
keys: keys, | ||
}; | ||
}; | ||
} | ||
exports.createSearchIndex = createSearchIndex; | ||
function createSearchItems(products) { | ||
return products.map(function (p) { | ||
var _a, _b, _c; | ||
var keywords = | ||
(_b = | ||
(_a = p.customFields) === null || _a === void 0 | ||
SearchUtil.prototype.createSearchItems = function (products) { | ||
return products.map(function (p) { | ||
var _a, _b, _c; | ||
var keywords = | ||
(_b = | ||
(_a = p.customFields) === null || _a === void 0 | ||
? void 0 | ||
: _a.keywords) === null || _b === void 0 | ||
? void 0 | ||
: _a.keywords) === null || _b === void 0 | ||
? void 0 | ||
: _b.split(','); | ||
var collections = p.collections.map(function (c) { | ||
return c.name; | ||
: _b.split(','); | ||
var collections = p.collections.map(function (c) { | ||
return c.name; | ||
}); | ||
return { | ||
name: p.name, | ||
slug: p.slug, | ||
price: p.lowestPrice, | ||
collections: collections, | ||
keywords: keywords, | ||
thumbnail: | ||
(_c = p.featuredAsset) === null || _c === void 0 | ||
? void 0 | ||
: _c.thumbnail, | ||
}; | ||
}); | ||
return { | ||
name: p.name, | ||
slug: p.slug, | ||
price: p.lowestPrice, | ||
collections: collections, | ||
keywords: keywords, | ||
thumbnail: | ||
(_c = p.featuredAsset) === null || _c === void 0 | ||
? void 0 | ||
: _c.thumbnail, | ||
}; | ||
}); | ||
} | ||
/** | ||
* Create Fuse instance based on the given indexObject | ||
* This instance can be use in your storefront to | ||
* search through products | ||
*/ | ||
function createFuse(indexObject, options) { | ||
var parsedIndex = fuse_js_1.default.parseIndex(indexObject.index); | ||
return new fuse_js_1.default( | ||
indexObject.items, | ||
__assign({ keys: indexObject.keys }, options), | ||
parsedIndex | ||
); | ||
} | ||
exports.createFuse = createFuse; | ||
}; | ||
/** | ||
* Create Fuse instance based on the given indexObject | ||
* This instance can be use in your storefront to | ||
* search through products | ||
*/ | ||
SearchUtil.prototype.createFuse = function (indexObject, options) { | ||
var parsedIndex = this.fuse.parseIndex(indexObject.index); | ||
return new this.fuse( | ||
indexObject.items, | ||
__assign({ keys: indexObject.keys }, options), | ||
parsedIndex | ||
); | ||
}; | ||
return SearchUtil; | ||
})(); | ||
exports.SearchUtil = SearchUtil; |
{ | ||
"name": "pinelab-storefront-client", | ||
"version": "0.53.0", | ||
"version": "0.53.1", | ||
"description": "Generates static html pages with Gridsome and suplied Vue components", | ||
@@ -51,3 +51,3 @@ "author": "Martijn van de Brug <martijn@pinelab.studio>", | ||
}, | ||
"gitHead": "362d20d5e60b55978e343f7b3999b358f8357963" | ||
"gitHead": "a4ebe9e0925bd958e4f52b20dc539e8f57e8e82a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
648959