Skip to content

Commit 5a95825

Browse files
committed
StorageManager.persist is not available on Web Workers. #519
1 parent bed0044 commit 5a95825

24 files changed

+82
-35
lines changed

dist/db/indexeddb/index.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ IdxDB.prototype.open = function(){
7171
let self = this;
7272

7373
navigator.storage &&
74+
navigator.storage.persist &&
7475
navigator.storage.persist();
7576

7677

dist/flexsearch.bundle.debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Debug)
2+
* FlexSearch.js v0.8.210 (Bundle/Debug)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH
@@ -2644,7 +2644,7 @@ w.open = function() {
26442644
return this.db;
26452645
}
26462646
let a = this;
2647-
navigator.storage && navigator.storage.persist();
2647+
navigator.storage && navigator.storage.persist && navigator.storage.persist();
26482648
Db[a.id] || (Db[a.id] = []);
26492649
Db[a.id].push(a.field);
26502650
const c = Bb.open(a.id, 1);

dist/flexsearch.bundle.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/flexsearch.bundle.module.debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Module/Debug)
2+
* FlexSearch.js v0.8.210 (Bundle/Module/Debug)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH
@@ -2643,7 +2643,7 @@ w.open = function() {
26432643
return this.db;
26442644
}
26452645
let a = this;
2646-
navigator.storage && navigator.storage.persist();
2646+
navigator.storage && navigator.storage.persist && navigator.storage.persist();
26472647
Db[a.id] || (Db[a.id] = []);
26482648
Db[a.id].push(a.field);
26492649
const c = Bb.open(a.id, 1);

dist/flexsearch.bundle.module.debug.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Module/Debug)
2+
* FlexSearch.js v0.8.210 (Bundle/Module/Debug)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH
@@ -2643,7 +2643,7 @@ w.open = function() {
26432643
return this.db;
26442644
}
26452645
let a = this;
2646-
navigator.storage && navigator.storage.persist();
2646+
navigator.storage && navigator.storage.persist && navigator.storage.persist();
26472647
Db[a.id] || (Db[a.id] = []);
26482648
Db[a.id].push(a.field);
26492649
const c = Bb.open(a.id, 1);

dist/flexsearch.bundle.module.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/flexsearch.bundle.module.min.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Module)
2+
* FlexSearch.js v0.8.210 (Bundle/Module)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH
@@ -93,8 +93,8 @@ w.cleanup=function(){if(!this.fastupdate)return this;tb(this.map);this.depth&&tb
9393
w.import=function(a,c){if(c)switch(typeof c==="string"&&(c=JSON.parse(c)),a=a.split("."),a[a.length-1]==="json"&&a.pop(),a.length===3&&a.shift(),a=a.length>1?a[1]:a[0],a){case "reg":this.fastupdate=!1;this.reg=qb(c,this.reg);break;case "map":this.map=mb(c,this.map);break;case "ctx":this.ctx=ob(c,this.ctx)}};
9494
w.serialize=function(a=!0){let c="",b="",e="";if(this.reg.size){let f;for(var d of this.reg.keys())f||(f=typeof d),c+=(c?",":"")+(f==="string"?'"'+d+'"':d);c="index.reg=new Set(["+c+"]);";b=sb(this.map,f);b="index.map=new Map(["+b+"]);";for(const g of this.ctx.entries()){d=g[0];let h=sb(g[1],f);h="new Map(["+h+"])";h='["'+d+'",'+h+"]";e+=(e?",":"")+h}e="index.ctx=new Map(["+e+"]);"}return a?"function inject(index){"+c+b+e+"}":c+b+e};Fa(T.prototype);const Bb=typeof window!=="undefined"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Cb=["map","ctx","tag","reg","cfg"],Db=I();
9595
function Eb(a,c={}){if(!this||this.constructor!==Eb)return new Eb(a,c);typeof a==="object"&&(c=a,a=a.name);a||console.info("Default storage space was used, because a name was not passed.");this.id="flexsearch"+(a?":"+a.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"");this.field=c.field?c.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"";this.type=c.type;this.fastupdate=this.support_tag_search=!1;this.db=null;this.h={}}w=Eb.prototype;w.mount=function(a){if(a.index)return a.mount(this);a.db=this;return this.open()};
96-
w.open=function(){if(this.db)return this.db;let a=this;navigator.storage&&navigator.storage.persist();Db[a.id]||(Db[a.id]=[]);Db[a.id].push(a.field);const c=Bb.open(a.id,1);c.onupgradeneeded=function(){const b=a.db=this.result;for(let e=0,d;e<Cb.length;e++){d=Cb[e];for(let f=0,g;f<Db[a.id].length;f++)g=Db[a.id][f],b.objectStoreNames.contains(d+(d!=="reg"?g?":"+g:"":""))||b.createObjectStore(d+(d!=="reg"?g?":"+g:"":""))}};return a.db=Z(c,function(b){a.db=b;a.db.onversionchange=function(){a.close()}})};
97-
w.close=function(){this.db&&this.db.close();this.db=null};w.destroy=function(){const a=Bb.deleteDatabase(this.id);return Z(a)};w.clear=function(){const a=[];for(let b=0,e;b<Cb.length;b++){e=Cb[b];for(let d=0,f;d<Db[this.id].length;d++)f=Db[this.id][d],a.push(e+(e!=="reg"?f?":"+f:"":""))}const c=this.db.transaction(a,"readwrite");for(let b=0;b<a.length;b++)c.objectStore(a[b]).clear();return Z(c)};
96+
w.open=function(){if(this.db)return this.db;let a=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist();Db[a.id]||(Db[a.id]=[]);Db[a.id].push(a.field);const c=Bb.open(a.id,1);c.onupgradeneeded=function(){const b=a.db=this.result;for(let e=0,d;e<Cb.length;e++){d=Cb[e];for(let f=0,g;f<Db[a.id].length;f++)g=Db[a.id][f],b.objectStoreNames.contains(d+(d!=="reg"?g?":"+g:"":""))||b.createObjectStore(d+(d!=="reg"?g?":"+g:"":""))}};return a.db=Z(c,function(b){a.db=b;a.db.onversionchange=
97+
function(){a.close()}})};w.close=function(){this.db&&this.db.close();this.db=null};w.destroy=function(){const a=Bb.deleteDatabase(this.id);return Z(a)};w.clear=function(){const a=[];for(let b=0,e;b<Cb.length;b++){e=Cb[b];for(let d=0,f;d<Db[this.id].length;d++)f=Db[this.id][d],a.push(e+(e!=="reg"?f?":"+f:"":""))}const c=this.db.transaction(a,"readwrite");for(let b=0;b<a.length;b++)c.objectStore(a[b]).clear();return Z(c)};
9898
w.get=function(a,c,b=0,e=0,d=!0,f=!1){a=this.db.transaction((c?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((c?"ctx":"map")+(this.field?":"+this.field:"")).get(c?c+":"+a:a);const g=this;return Z(a).then(function(h){let k=[];if(!h||!h.length)return k;if(d){if(!b&&!e&&h.length===1)return h[0];for(let l=0,m;l<h.length;l++)if((m=h[l])&&m.length){if(e>=m.length){e-=m.length;continue}const p=b?e+Math.min(m.length-e,b):m.length;for(let u=e;u<p;u++)k.push(m[u]);e=0;if(k.length===b)break}return f?
9999
g.enrich(k):k}return h})};w.tag=function(a,c=0,b=0,e=!1){a=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(a);const d=this;return Z(a).then(function(f){if(!f||!f.length||b>=f.length)return[];if(!c&&!b)return f;f=f.slice(b,b+c);return e?d.enrich(f):f})};
100100
w.enrich=function(a){typeof a!=="object"&&(a=[a]);const c=this.db.transaction("reg","readonly").objectStore("reg"),b=[];for(let e=0;e<a.length;e++)b[e]=Z(c.get(a[e]));return Promise.all(b).then(function(e){for(let d=0;d<e.length;d++)e[d]={id:a[d],doc:e[d]?JSON.parse(e[d]):null};return e})};w.has=function(a){a=this.db.transaction("reg","readonly").objectStore("reg").getKey(a);return Z(a).then(function(c){return!!c})};w.search=null;w.info=function(){};

dist/flexsearch.compact.debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Debug)
2+
* FlexSearch.js v0.8.210 (Bundle/Debug)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH

dist/flexsearch.compact.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/flexsearch.compact.module.debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* FlexSearch.js v0.8.209 (Bundle/Debug)
2+
* FlexSearch.js v0.8.210 (Bundle/Debug)
33
* Author and Copyright: Thomas Wilkerling
44
* Licence: Apache-2.0
55
* Hosted by Nextapps GmbH

0 commit comments

Comments
 (0)