mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-24 20:41:28 +02:00
proper light/compact bundle
This commit is contained in:
3
dist/module-debug/async.js
vendored
3
dist/module-debug/async.js
vendored
@@ -1,5 +1,6 @@
|
||||
import Document from "./document.js";
|
||||
import Index from "./index.js";
|
||||
import WorkerIndex from "./worker.js";
|
||||
|
||||
export default function (prototype) {
|
||||
register.call(prototype, "add");
|
||||
@@ -21,7 +22,7 @@ function tick(key) {
|
||||
|
||||
/**
|
||||
* @param {!string} key
|
||||
* @this {Index|Document}
|
||||
* @this {Index|Document|WorkerIndex}
|
||||
*/
|
||||
|
||||
function register(key) {
|
||||
|
4
dist/module-debug/bundle.js
vendored
4
dist/module-debug/bundle.js
vendored
@@ -138,6 +138,8 @@ import Charset from "./charset.js";
|
||||
/** @export */IndexOptions.worker; // worker url
|
||||
/** @export */IndexOptions.config; // config url
|
||||
/** @export */IndexOptions.priority;
|
||||
/** @export */IndexOptions.export;
|
||||
/** @export */IndexOptions.import;
|
||||
|
||||
/** @export */FieldOptions.preset;
|
||||
/** @export */FieldOptions.context;
|
||||
@@ -173,6 +175,8 @@ import Charset from "./charset.js";
|
||||
/** @export */DocumentOptions.document;
|
||||
/** @export */DocumentOptions.worker;
|
||||
/** @export */DocumentOptions.priority;
|
||||
/** @export */DocumentOptions.export;
|
||||
/** @export */DocumentOptions.import;
|
||||
|
||||
/** @export */ContextOptions.depth;
|
||||
/** @export */ContextOptions.bidirectional;
|
||||
|
16
dist/module-debug/document.js
vendored
16
dist/module-debug/document.js
vendored
@@ -42,8 +42,7 @@ export default function Document(options) {
|
||||
keystore = options.keystore || 0;
|
||||
keystore && (this.keystore = keystore);
|
||||
this.fastupdate = !!options.fastupdate;
|
||||
this.reg = this.fastupdate ? keystore && /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */
|
||||
/* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/ ? new KeystoreMap(keystore) : new Map() : keystore && !0 ? new KeystoreSet(keystore) : new Set();
|
||||
this.reg = this.fastupdate && !options.worker && !options.db ? keystore && /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/ ? new KeystoreMap(keystore) : new Map() : keystore && !0 ? new KeystoreSet(keystore) : new Set();
|
||||
|
||||
// todo support custom filter function
|
||||
this.storetree = (tmp = document.store || null) && tmp && !0 !== tmp && [];
|
||||
@@ -52,8 +51,7 @@ export default function Document(options) {
|
||||
this.cache = (tmp = options.cache || null) && new Cache(tmp);
|
||||
// do not apply cache again for the indexes since .searchCache()
|
||||
// is just a wrapper over .search()
|
||||
options.cache = /* suggest */ /* append: */
|
||||
/* enrich */!1;
|
||||
options.cache = /* suggest */ /* append: */ /* enrich */!1;
|
||||
|
||||
this.worker = options.worker;
|
||||
|
||||
@@ -105,6 +103,7 @@ export default function Document(options) {
|
||||
|
||||
// resolve worker promises and swap instances
|
||||
if (this.worker) {
|
||||
this.fastupdate = !1;
|
||||
const promises = [];
|
||||
for (const index of this.index.values()) {
|
||||
index.then && promises.push(index);
|
||||
@@ -123,7 +122,10 @@ export default function Document(options) {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
options.db && this.mount(options.db);
|
||||
if (options.db) {
|
||||
this.fastupdate = !1;
|
||||
this.mount(options.db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +134,10 @@ export default function Document(options) {
|
||||
* @return {Promise<Array<?>>}
|
||||
*/
|
||||
Document.prototype.mount = function (db) {
|
||||
if (this.worker) {
|
||||
throw new Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave).");
|
||||
}
|
||||
|
||||
|
||||
let fields = this.field;
|
||||
|
||||
|
2
dist/module-debug/index.js
vendored
2
dist/module-debug/index.js
vendored
@@ -47,7 +47,7 @@ export default function Index(options, _register) {
|
||||
|
||||
|
||||
this.resolution = options.resolution || 9;
|
||||
this.tokenize = tmp = options.tokenize || "strict";
|
||||
this.tokenize = (tmp = options.tokenize) && "default" !== tmp || "strict";
|
||||
this.depth = "strict" === tmp && context.depth || 0;
|
||||
this.bidirectional = !1 !== context.bidirectional;
|
||||
this.fastupdate = !!options.fastupdate;
|
||||
|
2
dist/module-debug/index/search.js
vendored
2
dist/module-debug/index/search.js
vendored
@@ -350,8 +350,6 @@ function single_term_query(term, keyword, limit, offset, resolve, enrich, tag) {
|
||||
|
||||
const result = this.get_array(term, keyword, limit, offset, resolve, enrich, tag);
|
||||
|
||||
resolve = resolve;
|
||||
|
||||
if (this.db) {
|
||||
return result.then(function (result) {
|
||||
return resolve ? result || [] : new Resolver(result);
|
||||
|
8
dist/module-debug/type.js
vendored
8
dist/module-debug/type.js
vendored
@@ -21,7 +21,9 @@ import StorageInterface from "./db/interface.js";
|
||||
* commit: (boolean|undefined),
|
||||
* worker: (string|undefined),
|
||||
* config: (string|undefined),
|
||||
* priority: (number|undefined)
|
||||
* priority: (number|undefined),
|
||||
* export: (Function|undefined),
|
||||
* import: (Function|undefined)
|
||||
* }}
|
||||
*/
|
||||
export let IndexOptions = {};
|
||||
@@ -65,7 +67,9 @@ export let FieldOptions = {};
|
||||
* doc: (DocumentDescriptor|Array<DocumentDescriptor>|undefined),
|
||||
* document: (DocumentDescriptor|Array<DocumentDescriptor>|undefined),
|
||||
* worker: (boolean|string|undefined),
|
||||
* priority: (number|undefined)
|
||||
* priority: (number|undefined),
|
||||
* export: (Function|undefined),
|
||||
* import: (Function|undefined)
|
||||
* }}
|
||||
*/
|
||||
export let DocumentOptions = {};
|
||||
|
2
dist/module-debug/worker.js
vendored
2
dist/module-debug/worker.js
vendored
@@ -1,3 +1,4 @@
|
||||
|
||||
import { IndexOptions } from "./type.js";
|
||||
import { create_object, is_function, is_object, is_string } from "./common.js";
|
||||
import handler from "./worker/handler.js";
|
||||
@@ -97,6 +98,7 @@ register("import");
|
||||
|
||||
apply_async(WorkerIndex.prototype);
|
||||
|
||||
|
||||
function register(key) {
|
||||
|
||||
WorkerIndex.prototype[key] =
|
||||
|
13
dist/module-debug/worker/handler.js
vendored
13
dist/module-debug/worker/handler.js
vendored
@@ -1,3 +1,4 @@
|
||||
|
||||
import Index from "../index.js";
|
||||
import { IndexOptions } from "../type.js";
|
||||
|
||||
@@ -21,6 +22,7 @@ export default (async function (data) {
|
||||
options = data.options || {};
|
||||
let filepath = options.config;
|
||||
if (filepath) {
|
||||
// compiler fix
|
||||
options = options;
|
||||
// will be replaced after build with the line below because
|
||||
// there is an issue with closure compiler dynamic import
|
||||
@@ -33,9 +35,7 @@ export default (async function (data) {
|
||||
|
||||
// export the FlexSearch global payload to "self"
|
||||
Function("return " + factory)()(self);
|
||||
|
||||
index = new self.FlexSearch.Index(options);
|
||||
|
||||
// destroy the exported payload
|
||||
delete self.FlexSearch;
|
||||
} else {
|
||||
@@ -51,11 +51,18 @@ export default (async function (data) {
|
||||
let message;
|
||||
|
||||
if ("export" === task) {
|
||||
if (!options.export || "function" != typeof options.export) {
|
||||
throw new Error("Either no extern configuration provided for the Worker-Index or no method was defined on the config property \"export\".");
|
||||
}
|
||||
|
||||
args = [options.export];
|
||||
}
|
||||
if ("import" === task) {
|
||||
if (!options.import || "function" != typeof options.import) {
|
||||
throw new Error("Either no extern configuration provided for the Worker-Index or no method was defined on the config property \"import\".");
|
||||
}
|
||||
|
||||
await options.import.call(index, index);
|
||||
//args = [options.import];
|
||||
} else {
|
||||
message = index[task].apply(index, args);
|
||||
}
|
||||
|
11
dist/module-debug/worker/node.js
vendored
11
dist/module-debug/worker/node.js
vendored
@@ -29,8 +29,8 @@ parentPort.on("message", async function (data) {
|
||||
|
||||
index = new Index(options);
|
||||
//index.db && await index.db;
|
||||
parentPort.postMessage({ id: id });
|
||||
|
||||
parentPort.postMessage({ id: id });
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -38,11 +38,18 @@ parentPort.on("message", async function (data) {
|
||||
let message;
|
||||
|
||||
if ("export" === task) {
|
||||
if (!options.export || "function" != typeof options.export) {
|
||||
throw new Error("Either no extern configuration provided for the Worker-Index or no method was defined on the config property \"export\".");
|
||||
}
|
||||
|
||||
args = [options.export];
|
||||
}
|
||||
if ("import" === task) {
|
||||
if (!options.import || "function" != typeof options.import) {
|
||||
throw new Error("Either no extern configuration provided for the Worker-Index or no method was defined on the config property \"import\".");
|
||||
}
|
||||
|
||||
await options.import.call(index, index);
|
||||
//args = [options.import];
|
||||
} else {
|
||||
message = index[task].apply(index, args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user