mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-26 13:28:58 +02:00
fix imports
This commit is contained in:
90
dist/module-debug/worker/handler.js
vendored
90
dist/module-debug/worker/handler.js
vendored
@@ -3,59 +3,53 @@ import { IndexOptions } from "../type.js";
|
||||
|
||||
export default (async function (data) {
|
||||
|
||||
data = data.data;
|
||||
data = data.data;
|
||||
|
||||
/** @type Index */
|
||||
const index = self._index,
|
||||
args = data.args,
|
||||
task = data.task;
|
||||
/** @type Index */
|
||||
const index = self._index,
|
||||
args = data.args,
|
||||
task = data.task;
|
||||
|
||||
|
||||
switch (task) {
|
||||
switch (task) {
|
||||
|
||||
case "init":
|
||||
case "init":
|
||||
|
||||
/** @type IndexOptions */
|
||||
let options = data.options || {},
|
||||
filepath = options.config;
|
||||
/** @type IndexOptions */
|
||||
let options = data.options || {},
|
||||
filepath = options.config;
|
||||
|
||||
if (filepath) {
|
||||
options = filepath;
|
||||
// will be replaced after build with the line below because
|
||||
// there is an issue with closure compiler dynamic import
|
||||
//options = await import(filepath);
|
||||
}
|
||||
|
||||
// deprecated:
|
||||
// const encode = options.encode;
|
||||
// if(encode && (encode.indexOf("function") === 0)){
|
||||
// options.encode = Function("return " + encode)();
|
||||
// }
|
||||
|
||||
const factory = data.factory;
|
||||
|
||||
if (factory) {
|
||||
|
||||
// export the FlexSearch global payload to "self"
|
||||
Function("return " + factory)()(self);
|
||||
|
||||
/** @type Index */
|
||||
self._index = new self.FlexSearch.Index(options);
|
||||
|
||||
// destroy the exported payload
|
||||
delete self.FlexSearch;
|
||||
} else {
|
||||
|
||||
self._index = new Index(options);
|
||||
}
|
||||
|
||||
postMessage({ id: data.id });
|
||||
break;
|
||||
|
||||
default:
|
||||
const id = data.id,
|
||||
message = index[task].apply(index, args);
|
||||
|
||||
postMessage("search" === task ? { id: id, msg: message } : { id: id });
|
||||
if (filepath) {
|
||||
options = filepath;
|
||||
// will be replaced after build with the line below because
|
||||
// there is an issue with closure compiler dynamic import
|
||||
//options = await import(filepath);
|
||||
}
|
||||
|
||||
const factory = data.factory;
|
||||
|
||||
if (factory) {
|
||||
|
||||
// export the FlexSearch global payload to "self"
|
||||
Function("return " + factory)()(self);
|
||||
|
||||
/** @type Index */
|
||||
self._index = new self.FlexSearch.Index(options);
|
||||
|
||||
// destroy the exported payload
|
||||
delete self.FlexSearch;
|
||||
} else {
|
||||
|
||||
self._index = new Index(options);
|
||||
}
|
||||
|
||||
postMessage({ id: data.id });
|
||||
break;
|
||||
|
||||
default:
|
||||
const id = data.id,
|
||||
message = index[task].apply(index, args);
|
||||
|
||||
postMessage("search" === task ? { id: id, msg: message } : { id: id });
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user