TEMP
This commit is contained in:
parent
d5c4aa250a
commit
2340b1215b
|
@ -4,6 +4,7 @@ modified: 20201018143621963
|
|||
tags: ReleaseNotes
|
||||
title: Release 5.1.23
|
||||
type: text/vnd.tiddlywiki
|
||||
my-field: randomburger
|
||||
|
||||
//[[See GitHub for detailed change history of this release|https://github.com/Jermolene/TiddlyWiki5/compare/v5.1.22...master]]//
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
"tiddlywiki/codemirror",
|
||||
"tiddlywiki/comments",
|
||||
"tiddlywiki/menubar",
|
||||
"tiddlywiki/jszip"
|
||||
"tiddlywiki/jszip",
|
||||
"tiddlywiki/search"
|
||||
],
|
||||
"themes": [
|
||||
"tiddlywiki/vanilla",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
title: $:/plugins/tiddlywiki/search/readme
|
||||
|
||||
TBD
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
FlexSearch v0.6.30
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(w,N,Q){let K;(K=Q.define)&&K.amd?K([],function(){return N}):(K=Q.modules)?K[w.toLowerCase()]=N:"object"===typeof exports?module.exports=N:Q[w]=N})("FlexSearch",function(){function w(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:ja++;this.init(a,b);ca(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});ca(this,"length",function(){return this.index.length})}function N(a){const b=B();for(const c in a)if(a.hasOwnProperty(c)){const d=
|
||||
a[c];F(d)?b[c]=d.slice(0):G(d)?b[c]=N(d):b[c]=d}return b}function Q(a,b){const c=a.length,d=O(b),e=[];for(let g=0,f=0;g<c;g++){const h=a[g];if(d&&b(h)||!d&&!b[h])e[f++]=h}return e}function K(a,b,c,d,e,g,f,h,k,l){c=da(c,f?0:e,h,g,b,k,l);let p;h&&(h=c.page,p=c.next,c=c.result);if(f)b=this.where(f,null,e,c);else{b=c;c=this.i;e=b.length;g=Array(e);for(f=0;f<e;f++)g[f]=c[b[f]];b=g}c=b;d&&(O(d)||(L=d.split(":"),1<L.length?d=ka:(L=L[0],d=la)),c.sort(d));c=R(h,p,c);this.cache&&this.j.set(a,c);return c}function ca(a,
|
||||
b,c){Object.defineProperty(a,b,{get:c})}function r(a){return new RegExp(a,"g")}function P(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function T(a,b,c,d,e,g,f,h){if(b[c])return b[c];e=e?(h-(f||h/1.5))*g+(f||h/1.5)*e:g;b[c]=e;e>=f&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function Y(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const g=c[d],f=a[g];if(f)for(let h=0,k=f.length;h<k;h++)if(f[h]===b){1===k?delete a[g]:f.splice(h,1);break}else G(f[h])&&
|
||||
Y(f[h],b)}}}function Z(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}function ma(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function la(a,b){a=a[L];b=b[L];return a<b?-1:a>b?1:0}function ka(a,b){const c=L.length;for(let d=0;d<c;d++)a=a[L[d]],b=b[L[d]];return a<b?-1:a>b?1:0}function R(a,
|
||||
b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function da(a,b,c,d,e,g,f){let h,k=[];if(!0===c){c="0";var l=""}else l=c&&c.split(":");const p=a.length;if(1<p){const y=B(),t=[];let v,x;var n=0,m;let H;var u=!0;let D,E=0,M,aa,U,ba;l&&(2===l.length?(U=l,l=!1):l=ba=parseInt(l[0],10));if(f){for(v=B();n<p;n++)if("not"===e[n])for(x=a[n],H=x.length,m=0;m<H;m++)v["@"+x[m]]=1;else aa=n+1;if(C(aa))return R(c,h,k);n=0}else M=I(e)&&e;let V;for(;n<p;n++){const na=n===(aa||p)-1;if(!M||!n)if((m=M||e&&e[n])&&
|
||||
"and"!==m)if("or"===m)V=!1;else continue;else V=g=!0;x=a[n];if(H=x.length){if(u)if(D){var q=D.length;for(m=0;m<q;m++){u=D[m];var A="@"+u;f&&v[A]||(y[A]=1,g||(k[E++]=u))}D=null;u=!1}else{D=x;continue}A=!1;for(m=0;m<H;m++){q=x[m];var z="@"+q;const W=g?y[z]||0:n;if(!(!W&&!d||f&&v[z]||!g&&y[z]))if(W===n){if(na){if(!ba||--ba<E)if(k[E++]=q,b&&E===b)return R(c,E+(l||0),k)}else y[z]=n+1;A=!0}else d&&(z=t[W]||(t[W]=[]),z[z.length]=q)}if(V&&!A&&!d)break}else if(V&&!d)return R(c,h,x)}if(D)if(n=D.length,f)for(m=
|
||||
l?parseInt(l,10):0;m<n;m++)a=D[m],v["@"+a]||(k[E++]=a);else k=D;if(d)for(E=k.length,U?(n=parseInt(U[0],10)+1,m=parseInt(U[1],10)+1):(n=t.length,m=0);n--;)if(q=t[n]){for(H=q.length;m<H;m++)if(d=q[m],!f||!v["@"+d])if(k[E++]=d,b&&E===b)return R(c,n+":"+m,k);m=0}}else!p||e&&"not"===e[0]||(k=a[0],l&&(l=parseInt(l[0],10)));b&&(f=k.length,l&&l>f&&(l=0),l=l||0,h=l+b,h<f?k=k.slice(l,h):(h=0,l&&(k=k.slice(l))));return R(c,h,k)}function I(a){return"string"===typeof a}function F(a){return a.constructor===Array}
|
||||
function O(a){return"function"===typeof a}function G(a){return"object"===typeof a}function C(a){return"undefined"===typeof a}function ea(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}const J={encode:"icase",c:"forward",split:/\W+/,cache:!1,async:!1,C:!1,v:!1,a:!1,b:9,threshold:0,depth:0},fa={memory:{encode:"extra",c:"strict",threshold:0,b:1},speed:{encode:"icase",c:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",c:"full",threshold:1,b:3},
|
||||
score:{encode:"extra",c:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",c:"strict",threshold:8,b:9,depth:1}},X=[];let ja=0;const ha={},ia={};w.create=function(a,b){return new w(a,b)};w.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&X.push(r(b),a[b]);return this};w.registerEncoder=function(a,b){S[a]=b.bind(S);return this};w.registerLanguage=function(a,b){ha[a]=b.filter;ia[a]=b.stemmer;return this};w.encode=function(a,
|
||||
b){return S[a](b)};w.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=J),c=a.preset;b={};I(a)?(b=fa[a],a={}):c&&(b=fa[c]);this.c=a.tokenize||b.c||this.c||J.c;this.split=C(c=a.split)?this.split||J.split:I(c)?r(c):c;this.v=a.rtl||this.v||J.v;this.async="undefined"===typeof Promise||C(c=a.async)?this.async||J.async:c;this.threshold=C(c=a.threshold)?b.threshold||this.threshold||J.threshold:c;this.b=C(c=a.resolution)?c=b.b||this.b||J.b:c;c<=this.threshold&&(this.b=this.threshold+
|
||||
1);this.depth="strict"!==this.c||C(c=a.depth)?b.depth||this.depth||J.depth:c;this.o=(c=C(c=a.encode)?b.encode||J.encode:c)&&S[c]&&S[c].bind(S)||(O(c)?c:this.o||!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){I(c)&&(c=ha[c]);if(F(c)){var d=this.o,e=B();for(var g=0;g<c.length;g++){var f=d?d(c[g]):c[g];e[f]=1}c=e}this.filter=c}if(c=b||a.stemmer){var h;b=I(c)?ia[c]:c;d=this.o;e=[];for(h in b)b.hasOwnProperty(h)&&(g=d?d(h):h,e.push(r(g+"($|\\W)"),d?d(b[h]):b[h]));this.stemmer=h=e}this.a=
|
||||
e=(c=a.doc)?N(c):this.a||J.a;this.h=ea(this.b-(this.threshold||0));this.g=B();this.f=B();if(e){this.i=B();a.doc=null;h=e.index={};b=e.keys=[];d=e.field;g=e.tag;f=e.store;F(e.id)||(e.id=e.id.split(":"));if(f){var k=B();if(I(f))k[f]=1;else if(F(f))for(let l=0;l<f.length;l++)k[f[l]]=1;else G(f)&&(k=f);e.store=k}if(g){this.w=B();f=B();if(d)if(I(d))f[d]=a;else if(F(d))for(k=0;k<d.length;k++)f[d[k]]=a;else G(d)&&(f=d);F(g)||(e.tag=g=[g]);for(d=0;d<g.length;d++)this.w[g[d]]=B();this.B=g;d=f}if(d){let l;
|
||||
F(d)||(G(d)?(l=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)g=d[e],F(g)||(l&&(a=l[g]),b[e]=g,d[e]=g.split(":")),h[g]=new w(a)}a.doc=c}this.u=!0;this.j=(this.cache=c=C(c=a.cache)?this.cache||J.cache:c)?new oa(c):!1;return this};w.prototype.encode=function(a){a&&(X.length&&(a=P(a,X)),this.m.length&&(a=P(a,this.m)),this.o&&(a=this.o(a)),this.stemmer&&(a=P(a,this.stemmer)));return a};w.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(r(c),
|
||||
a[c]);return this};w.prototype.add=function(a,b,c,d,e){if(this.a&&G(a))return this.s("add",a,b);if(b&&I(b)&&(a||0===a)){var g="@"+a;if(this.f[g]&&!d)return this.update(a,b);if(!e){if(this.async){let t=this;g=new Promise(function(v){setTimeout(function(){t.add(a,b,null,d,!0);t=null;v()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=O(c)?c(b):b.split(this.split);this.filter&&(e=Q(e,this.filter));const n=
|
||||
B();n._ctx=B();const m=e.length,u=this.threshold,q=this.depth,A=this.b,z=this.h,y=this.v;for(let t=0;t<m;t++){var f=e[t];if(f){var h=f.length,k=(y?t+1:m-t)/m,l="";switch(c){case "reverse":case "both":for(var p=h;--p;)l=f[p]+l,T(z,n,l,a,y?1:(h-p)/h,k,u,A-1);l="";case "forward":for(p=0;p<h;p++)l+=f[p],T(z,n,l,a,y?(p+1)/h:1,k,u,A-1);break;case "full":for(p=0;p<h;p++){const v=(y?p+1:h-p)/h;for(let x=h;x>p;x--)l=f.substring(p,x),T(z,n,l,a,v,k,u,A-1)}break;default:if(h=T(z,n,f,a,1,k,u,A-1),q&&1<m&&h>=u)for(h=
|
||||
n._ctx[f]||(n._ctx[f]=B()),f=this.g[f]||(this.g[f]=ea(A-(u||0))),k=t-q,l=t+q+1,0>k&&(k=0),l>m&&(l=m);k<l;k++)k!==t&&T(f,h,e[k],a,0,A-(k<t?t-k:k-t),u,A-1)}}}this.f[g]=1;this.u=!1}return this};w.prototype.s=function(a,b,c){if(F(b)){var d=b.length;if(d--){for(var e=0;e<d;e++)this.s(a,b[e]);return this.s(a,b[d],c)}}else{var g=this.a.index,f=this.a.keys,h=this.a.tag;e=this.a.store;var k;var l=this.a.id;d=b;for(var p=0;p<l.length;p++)d=d[l[p]];if("remove"===a&&(delete this.i[d],l=f.length,l--)){for(b=0;b<
|
||||
l;b++)g[f[b]].remove(d);return g[f[l]].remove(d,c)}if(h){for(k=0;k<h.length;k++){var n=h[k];var m=b;l=n.split(":");for(p=0;p<l.length;p++)m=m[l[p]];m="@"+m}k=this.w[n];k=k[m]||(k[m]=[])}l=this.a.field;for(let u=0,q=l.length;u<q;u++){n=l[u];h=b;for(m=0;m<n.length;m++)h=h[n[m]];n=g[f[u]];m="add"===a?n.add:n.update;u===q-1?m.call(n,d,h,c):m.call(n,d,h)}if(e){c=Object.keys(e);a=B();for(g=0;g<c.length;g++)if(f=c[g],e[f]){f=f.split(":");let u,q;for(l=0;l<f.length;l++)h=f[l],u=(u||b)[h],q=(q||a)[h]=u}b=
|
||||
a}k&&(k[k.length]=b);this.i[d]=b}return this};w.prototype.update=function(a,b,c){if(this.a&&G(a))return this.s("update",a,b);this.f["@"+a]&&I(b)&&(this.remove(a),this.add(a,b,c,!0));return this};w.prototype.remove=function(a,b,c){if(this.a&&G(a))return this.s("remove",a,b);var d="@"+a;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let e=this;d=new Promise(function(g){setTimeout(function(){e.remove(a,null,!0);e=null;g()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,
|
||||
null,!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)Y(this.h[b],a);this.depth&&Y(this.g,a);delete this.f[d];this.u=!1}return this};let L;w.prototype.search=function(a,b,c,d){if(G(b)){if(F(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&O(b)?(c=b,b=1E3):b||0===b||(b=1E3);let g=[],f=a;let h,k,l;if(G(a)&&!F(a)){c||(c=a.callback)&&(f.callback=null);k=a.sort;h=a.page;b=a.limit;var p=a.threshold;l=a.suggest;a=a.query}if(this.a){p=this.a.index;const y=f.where;var n=f.bool||
|
||||
"or",m=f.field;let t=n;let v,x;if(m)F(m)||(m=[m]);else if(F(f)){var u=f;m=[];t=[];for(var q=0;q<f.length;q++)d=f[q],e=d.bool||n,m[q]=d.field,t[q]=e,"not"===e?v=!0:"and"===e&&(x=!0)}else m=this.a.keys;n=m.length;for(q=0;q<n;q++)u&&(f=u[q]),h&&!I(f)&&(f.page=null,f.limit=0),g[q]=p[m[q]].search(f,0);if(c)return c(K.call(this,a,t,g,k,b,l,y,h,x,v));if(this.async){const H=this;return new Promise(function(D){Promise.all(g).then(function(E){D(K.call(H,a,t,E,k,b,l,y,h,x,v))})})}return K.call(this,a,t,g,k,
|
||||
b,l,y,h,x,v)}p||(p=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){let y=this;p=new Promise(function(t){setTimeout(function(){t(y.search(f,b,null,!0));y=null})});if(c)p.then(c);else return p;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!I(a))return g;f=a;if(this.cache)if(this.u){if(c=this.j.get(a))return c}else this.j.clear(),this.u=!0;f=this.encode(f);if(!f.length)return g;c=this.c;c=O(c)?c(f):f.split(this.split);this.filter&&(c=Q(c,this.filter));u=
|
||||
c.length;d=!0;e=[];const A=B();let z=0;1<u&&(this.depth&&"strict"===this.c?n=!0:c.sort(ma));if(!n||(q=this.g)){const y=this.b;for(;z<u;z++){let t=c[z];if(t){if(n){if(!m)if(q[t])m=t,A[t]=1;else if(!l)return g;if(l&&z===u-1&&!e.length)n=!1,t=m||t,A[t]=0;else if(!m)continue}if(!A[t]){const v=[];let x=!1,H=0;const D=n?q[m]:this.h;if(D){let E;for(let M=0;M<y-p;M++)if(E=D[M]&&D[M][t])v[H++]=E,x=!0}if(x)m=t,e[e.length]=1<H?v.concat.apply([],v):v[0];else if(!l){d=!1;break}A[t]=1}}}}else d=!1;d&&(g=da(e,b,
|
||||
h,l));this.cache&&this.j.set(a,g);return g};w.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};w.prototype.where=function(a,b,c,d){const e=this.i,g=[];let f=0;let h;var k;let l;if(G(a)){c||(c=b);var p=Object.keys(a);var n=p.length;h=!1;if(1===n&&"id"===p[0])return[e[a.id]];if((k=this.B)&&!d)for(var m=0;m<k.length;m++){var u=k[m],q=a[u];if(!C(q)){l=this.w[u]["@"+q];if(0===--n)return l;p.splice(p.indexOf(u),1);delete a[u];break}}k=Array(n);for(m=0;m<n;m++)k[m]=p[m].split(":")}else{if(O(a)){b=
|
||||
d||Object.keys(e);c=b.length;for(p=0;p<c;p++)n=e[b[p]],a(n)&&(g[f++]=n);return g}if(C(b))return[e[a]];if("id"===a)return[e[b]];p=[a];n=1;k=[a.split(":")];h=!0}d=l||d||Object.keys(e);m=d.length;for(u=0;u<m;u++){q=l?d[u]:e[d[u]];let A=!0;for(let z=0;z<n;z++){h||(b=a[p[z]]);const y=k[z],t=y.length;let v=q;if(1<t)for(let x=0;x<t;x++)v=v[y[x]];else v=v[y[0]];if(v!==b){A=!1;break}}if(A&&(g[f++]=q,c&&f===c))break}return g};w.prototype.info=function(){return{id:this.id,items:this.length,cache:this.cache&&
|
||||
this.cache.l?this.cache.l.length:!1,matcher:X.length+(this.m?this.m.length:0),worker:this.C,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.c}};w.prototype.clear=function(){return this.destroy().init()};w.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.h=this.g=this.f=null;if(this.a){const a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.i=null}return this};w.prototype.export=function(a){const b=
|
||||
!a||C(a.serialize)||a.serialize;if(this.a){const d=!a||C(a.doc)||a.doc;var c=!a||C(a.index)||a.index;a=[];let e=0;if(c)for(c=this.a.keys;e<c.length;e++){const g=this.a.index[c[e]];a[e]=[g.h,g.g,Object.keys(g.f)]}d&&(a[e]=this.i)}else a=[this.h,this.g,Object.keys(this.f)];b&&(a=JSON.stringify(a));return a};w.prototype.import=function(a,b){if(!b||C(b.serialize)||b.serialize)a=JSON.parse(a);const c=B();if(this.a){var d=!b||C(b.doc)||b.doc,e=0;if(!b||C(b.index)||b.index){b=this.a.keys;const f=b.length;
|
||||
for(var g=a[0][2];e<g.length;e++)c[g[e]]=1;for(e=0;e<f;e++){g=this.a.index[b[e]];const h=a[e];h&&(g.h=h[0],g.g=h[1],g.f=c)}}d&&(this.i=G(d)?d:a[e])}else{d=a[2];for(e=0;e<d.length;e++)c[d[e]]=1;this.h=a[0];this.g=a[1];this.f=c}};const pa=function(){const a=r("\\s+"),b=r("[^a-z0-9 ]"),c=[r("[-/]")," ",b,"",a," "];return function(d){return Z(P(d.toLowerCase(),c))}}(),S={icase:function(a){return a.toLowerCase()},simple:function(){const a=r("\\s+"),b=r("[^a-z0-9 ]"),c=r("[-/]"),d=r("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),
|
||||
e=r("[\u00e8\u00e9\u00ea\u00eb]"),g=r("[\u00ec\u00ed\u00ee\u00ef]"),f=r("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),h=r("[\u00f9\u00fa\u00fb\u00fc\u0171]"),k=r("[\u00fd\u0177\u00ff]"),l=r("\u00f1"),p=r("[\u00e7c]"),n=r("\u00df"),m=r(" & "),u=[d,"a",e,"e",g,"i",f,"o",h,"u",k,"y",l,"n",p,"k",n,"s",m," and ",c," ",b,"",a," "];return function(q){q=P(q.toLowerCase(),u);return" "===q?"":q}}(),advanced:function(){const a=r("ae"),b=r("ai"),c=r("ay"),d=r("ey"),e=r("oe"),g=r("ue"),f=r("ie"),h=r("sz"),k=r("zs"),
|
||||
l=r("ck"),p=r("cc"),n=r("sh"),m=r("th"),u=r("dt"),q=r("ph"),A=r("pf"),z=r("ou"),y=r("uo"),t=[a,"a",b,"ei",c,"ei",d,"ei",e,"o",g,"u",f,"i",h,"s",k,"s",n,"s",l,"k",p,"k",m,"t",u,"t",q,"f",A,"f",z,"o",y,"u"];return function(v,x){if(!v)return v;v=this.simple(v);2<v.length&&(v=P(v,t));x||1<v.length&&(v=Z(v));return v}}(),extra:function(){const a=r("p"),b=r("z"),c=r("[cgq]"),d=r("n"),e=r("d"),g=r("[vw]"),f=r("[aeiouy]"),h=[a,"b",b,"s",c,"k",d,"m",e,"t",g,"f",f,""];return function(k){if(!k)return k;k=this.advanced(k,
|
||||
!0);if(1<k.length){k=k.split(" ");for(let l=0;l<k.length;l++){const p=k[l];1<p.length&&(k[l]=p[0]+P(p.substring(1),h))}k=k.join(" ");k=Z(k)}return k}}(),balance:pa},oa=function(){function a(b){this.clear();this.A=!0!==b&&b}a.prototype.clear=function(){this.cache=B();this.count=B();this.index=B();this.l=[]};a.prototype.set=function(b,c){if(this.A&&C(this.cache[b])){let d=this.l.length;if(d===this.A){d--;const e=this.l[d];delete this.cache[e];delete this.count[e];delete this.index[e]}this.index[b]=
|
||||
d;this.l[d]=b;this.count[b]=-1;this.cache[b]=c;this.get(b)}else this.cache[b]=c};a.prototype.get=function(b){const c=this.cache[b];if(this.A&&c){var d=++this.count[b];const g=this.index;let f=g[b];if(0<f){const h=this.l;for(var e=f;this.count[h[--f]]<=d&&-1!==f;);f++;if(f!==e){for(d=e;d>f;d--)e=h[d-1],h[d]=e,g[e]=d;h[f]=b;g[b]=f}}}return c};return a}();return w}(!1),this);
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"tiddlers": [
|
||||
{
|
||||
"file": "flexsearch.node.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/search/flexsearch.js",
|
||||
"module-type": "library"
|
||||
},
|
||||
"prefix": "(function() {\n",
|
||||
"suffix": "\n}).call(module);\n"
|
||||
},{
|
||||
"file": "LICENSE",
|
||||
"fields": {
|
||||
"type": "text/plain",
|
||||
"title": "$:/plugins/tiddlywiki/search/flexsearch/license"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/search/startup.js
|
||||
type: application/javascript
|
||||
module-type: startup
|
||||
|
||||
Search background daemon
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
// Export name and synchronous status
|
||||
exports.name = "search-startup";
|
||||
exports.platforms = ["browser"];
|
||||
exports.after = ["render"];
|
||||
exports.synchronous = true;
|
||||
|
||||
exports.startup = function() {
|
||||
var FlexSearch = require("$:/plugins/tiddlywiki/search/flexsearch.js");
|
||||
var index = new FlexSearch("memory");
|
||||
var titleIndex = [];
|
||||
|
||||
index.add(10025, "John Doe");
|
||||
|
||||
var count = 0;
|
||||
|
||||
$tw.wiki.each(function(tiddler,title) {
|
||||
var chunks = [
|
||||
title,
|
||||
tiddler.fields.text || "",
|
||||
$tw.utils.parseStringArray(tiddler.fields.tags || "").join("\n")
|
||||
];
|
||||
$tw.utils.each(Object.keys(tiddler.fields),function(fieldName) {
|
||||
if(["title","tags","text"].indexOf(fieldName) === -1) {
|
||||
chunks.push(tiddler.getFieldString(fieldName));
|
||||
}
|
||||
});
|
||||
index.add(titleIndex.length,chunks.join("\n"));
|
||||
|
||||
count += chunks.join("\n").length;
|
||||
|
||||
titleIndex.push(title);
|
||||
});
|
||||
console.log("Indexed ",count," characters")
|
||||
console.log("Index size",index.export().length)
|
||||
function search(str) {
|
||||
var results = index.search(str);
|
||||
var titles = [];
|
||||
$tw.utils.each(results,function(index) {
|
||||
titles.push(titleIndex[index]);
|
||||
});
|
||||
console.log("Searching for",str,"number of results",titles.length)
|
||||
return titles;
|
||||
}
|
||||
search("jeremy");
|
||||
search({
|
||||
query: "jeremy",
|
||||
suggest: true
|
||||
// limit: 1000,
|
||||
// threshold: 5, // >= threshold
|
||||
// depth: 3 // <= depth
|
||||
});
|
||||
debugger;
|
||||
};
|
||||
|
||||
})();
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/dynannotate",
|
||||
"name": "Dynannotate",
|
||||
"description": "Dynamic content annotation",
|
||||
"author": "JeremyRuston",
|
||||
"core-version": ">=5.0.0",
|
||||
"list": "readme examples",
|
||||
"dependents": ["$:/plugins/tiddlywiki/dynaview"]
|
||||
}
|
Loading…
Reference in New Issue