@redscope-ai/redscope 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +224 -0
- package/dist/chunk-090920rk.js +288 -0
- package/dist/chunk-0afb2r78.js +141 -0
- package/dist/chunk-0d4ekx1g.js +73 -0
- package/dist/chunk-0g6nwbhq.js +15 -0
- package/dist/chunk-0qj905nt.js +18 -0
- package/dist/chunk-0s5btnn1.js +186 -0
- package/dist/chunk-0s8fars0.js +91 -0
- package/dist/chunk-10ev3dvh.js +312 -0
- package/dist/chunk-10k5jfc5.js +1295 -0
- package/dist/chunk-12tspwqa.js +240 -0
- package/dist/chunk-13qesvnw.js +17 -0
- package/dist/chunk-143eh1e0.js +121 -0
- package/dist/chunk-14p6wvsq.js +39 -0
- package/dist/chunk-19f3zb1m.js +342 -0
- package/dist/chunk-1a5cep8h.js +145 -0
- package/dist/chunk-1abw9kkn.js +34 -0
- package/dist/chunk-1aer7c78.js +118 -0
- package/dist/chunk-1dazz4g6.js +154 -0
- package/dist/chunk-1fcf4ty1.js +142 -0
- package/dist/chunk-1gnxhyf8.js +62 -0
- package/dist/chunk-1he3944e.js +8124 -0
- package/dist/chunk-1jpayz7y.js +952 -0
- package/dist/chunk-1qd6f6vk.js +269 -0
- package/dist/chunk-1v0kpe62.js +2547 -0
- package/dist/chunk-1w20m7gw.js +445 -0
- package/dist/chunk-1y7kp51j.js +72 -0
- package/dist/chunk-1ycb5sxt.js +247 -0
- package/dist/chunk-1zbwhcbt.js +1124 -0
- package/dist/chunk-20psem54.js +116 -0
- package/dist/chunk-23h69r5b.js +30 -0
- package/dist/chunk-23x86ptv.js +473 -0
- package/dist/chunk-24fyv3jz.js +378 -0
- package/dist/chunk-24kv69g3.js +97 -0
- package/dist/chunk-2azx8zsc.js +125 -0
- package/dist/chunk-2d1gwzz9.js +524 -0
- package/dist/chunk-2g0ytd9d.js +29058 -0
- package/dist/chunk-2hfp9kat.js +21 -0
- package/dist/chunk-2j875eq6.js +37 -0
- package/dist/chunk-2kcgxnvp.js +39 -0
- package/dist/chunk-2kz09j2s.js +23 -0
- package/dist/chunk-2mwnwp0n.js +17 -0
- package/dist/chunk-2p1cqhcn.js +921 -0
- package/dist/chunk-2p369q9z.js +61 -0
- package/dist/chunk-2rf6asgf.js +151 -0
- package/dist/chunk-2vr7mqx1.js +384 -0
- package/dist/chunk-2xcg933e.js +205 -0
- package/dist/chunk-2ypwckbz.js +40310 -0
- package/dist/chunk-30wnahyg.js +626 -0
- package/dist/chunk-326zehp8.js +204 -0
- package/dist/chunk-32s6jzgw.js +183 -0
- package/dist/chunk-35yzt1a7.js +202 -0
- package/dist/chunk-38frkej6.js +62 -0
- package/dist/chunk-3abaq08g.js +34 -0
- package/dist/chunk-3h59ttr5.js +32 -0
- package/dist/chunk-3nk9q8dr.js +154 -0
- package/dist/chunk-3prrxevm.js +224 -0
- package/dist/chunk-3tv8p9xw.js +127 -0
- package/dist/chunk-3txyekes.js +19 -0
- package/dist/chunk-3vfxjn7g.js +19 -0
- package/dist/chunk-3w9sye8h.js +81 -0
- package/dist/chunk-3y69j7y8.js +24 -0
- package/dist/chunk-3zwjpkjh.js +1603 -0
- package/dist/chunk-40t1d75v.js +3442 -0
- package/dist/chunk-470kmby4.js +318 -0
- package/dist/chunk-47jc141z.js +335 -0
- package/dist/chunk-48rz50ct.js +868 -0
- package/dist/chunk-49wv03ts.js +232 -0
- package/dist/chunk-4a189mn2.js +103 -0
- package/dist/chunk-4c4fmh7a.js +15 -0
- package/dist/chunk-4ct8dsj5.js +49 -0
- package/dist/chunk-4kqt1pm1.js +100 -0
- package/dist/chunk-4ng0xy0e.js +802 -0
- package/dist/chunk-4spgkgr3.js +43 -0
- package/dist/chunk-4tjdwtyy.js +19 -0
- package/dist/chunk-4tr60273.js +370 -0
- package/dist/chunk-4vnaeng5.js +29 -0
- package/dist/chunk-4wbqpeaw.js +871 -0
- package/dist/chunk-4wgkv3fv.js +1140 -0
- package/dist/chunk-4yjskjb6.js +40 -0
- package/dist/chunk-50m3a23z.js +35 -0
- package/dist/chunk-511f79az.js +182 -0
- package/dist/chunk-51sgztvv.js +161 -0
- package/dist/chunk-563fcpv1.js +290 -0
- package/dist/chunk-564cnq6v.js +735 -0
- package/dist/chunk-569r8cxc.js +31 -0
- package/dist/chunk-570x55d4.js +12 -0
- package/dist/chunk-571556cm.js +80 -0
- package/dist/chunk-59t4c56e.js +63 -0
- package/dist/chunk-5axjhkma.js +36 -0
- package/dist/chunk-5b188q5e.js +157 -0
- package/dist/chunk-5dmn1865.js +439 -0
- package/dist/chunk-5ks4829r.js +267 -0
- package/dist/chunk-5mmhfbxb.js +1078 -0
- package/dist/chunk-5rdt14hy.js +742 -0
- package/dist/chunk-5ssryexj.js +121 -0
- package/dist/chunk-5v95pnq4.js +15 -0
- package/dist/chunk-5xvjt2t9.js +68 -0
- package/dist/chunk-5zyq6t1q.js +118 -0
- package/dist/chunk-60fkafk2.js +15 -0
- package/dist/chunk-62fjkf5q.js +46 -0
- package/dist/chunk-64gazrrb.js +8067 -0
- package/dist/chunk-65tq2yjx.js +126 -0
- package/dist/chunk-65zbgg1n.js +14 -0
- package/dist/chunk-66v8mty3.js +264 -0
- package/dist/chunk-6acx5heq.js +292 -0
- package/dist/chunk-6hr7742d.js +61 -0
- package/dist/chunk-6hygvrhn.js +143 -0
- package/dist/chunk-6kjh280m.js +128 -0
- package/dist/chunk-6s0q1s5r.js +66 -0
- package/dist/chunk-6x35ffpx.js +690 -0
- package/dist/chunk-71jfy1hh.js +570 -0
- package/dist/chunk-71sdcaq6.js +15 -0
- package/dist/chunk-754qdxs5.js +92 -0
- package/dist/chunk-79v5bkj4.js +1176 -0
- package/dist/chunk-7br0w7j5.js +151 -0
- package/dist/chunk-7cjgrzz1.js +298 -0
- package/dist/chunk-7d41ks0y.js +133 -0
- package/dist/chunk-7f40pmtr.js +71 -0
- package/dist/chunk-7g15x8hm.js +131 -0
- package/dist/chunk-7gtnzdet.js +120 -0
- package/dist/chunk-7h0z4aqx.js +702 -0
- package/dist/chunk-7h7e5a7d.js +25 -0
- package/dist/chunk-7m2cznwr.js +40 -0
- package/dist/chunk-7nvday0n.js +252 -0
- package/dist/chunk-7qey87th.js +145 -0
- package/dist/chunk-7qx3xhv3.js +9076 -0
- package/dist/chunk-7tfdhkpy.js +61 -0
- package/dist/chunk-80m511j6.js +121 -0
- package/dist/chunk-80ysxfe9.js +784 -0
- package/dist/chunk-8375zk8t.js +17200 -0
- package/dist/chunk-85bpkyy9.js +412 -0
- package/dist/chunk-85tcn547.js +876 -0
- package/dist/chunk-85vqgbc8.js +13 -0
- package/dist/chunk-86626jb4.js +49 -0
- package/dist/chunk-87ms17f6.js +444 -0
- package/dist/chunk-87mz239c.js +118 -0
- package/dist/chunk-89vdzt4e.js +254 -0
- package/dist/chunk-89z3e99z.js +159 -0
- package/dist/chunk-8cwrz1dd.js +1806 -0
- package/dist/chunk-8gv2pjby.js +21 -0
- package/dist/chunk-8hdevr3s.js +140 -0
- package/dist/chunk-8hdsk6qc.js +710 -0
- package/dist/chunk-8kct9arg.js +724 -0
- package/dist/chunk-8kf8h7xf.js +23 -0
- package/dist/chunk-8qed8ymj.js +605 -0
- package/dist/chunk-8sdgr592.js +101 -0
- package/dist/chunk-8we9w8pw.js +111 -0
- package/dist/chunk-8xnm5637.js +72 -0
- package/dist/chunk-8y3q0eqy.js +67 -0
- package/dist/chunk-8yvsnrkr.js +3449 -0
- package/dist/chunk-8zz4z1q3.js +42 -0
- package/dist/chunk-90eyff3k.js +119 -0
- package/dist/chunk-92bjkrf2.js +121 -0
- package/dist/chunk-92zrc7c6.js +327 -0
- package/dist/chunk-935nrvdb.js +13 -0
- package/dist/chunk-94pfyv6a.js +48 -0
- package/dist/chunk-9568p8se.js +115 -0
- package/dist/chunk-96km1ywr.js +37 -0
- package/dist/chunk-980bg4w4.js +163 -0
- package/dist/chunk-9a9g5hbj.js +205 -0
- package/dist/chunk-9cm4725d.js +4395 -0
- package/dist/chunk-9ds3vzq8.js +847 -0
- package/dist/chunk-9ffc9n60.js +618 -0
- package/dist/chunk-9fstrwv2.js +184 -0
- package/dist/chunk-9gt0g0qe.js +153 -0
- package/dist/chunk-9h9k5vz3.js +2761 -0
- package/dist/chunk-9he8bmhy.js +17 -0
- package/dist/chunk-9hn8e6h1.js +12 -0
- package/dist/chunk-9j0n3g8e.js +179 -0
- package/dist/chunk-9j6pa3ft.js +251 -0
- package/dist/chunk-9jpg9dn7.js +122 -0
- package/dist/chunk-9mycnwj5.js +46 -0
- package/dist/chunk-9npy2c17.js +517 -0
- package/dist/chunk-9p6sec8n.js +34 -0
- package/dist/chunk-9pnym83h.js +4584 -0
- package/dist/chunk-9skwrnd2.js +25 -0
- package/dist/chunk-9tsfaqr8.js +459 -0
- package/dist/chunk-9tsw3cqv.js +5924 -0
- package/dist/chunk-9w6ckyk4.js +49 -0
- package/dist/chunk-a15bwzv6.js +147 -0
- package/dist/chunk-a9t6cp69.js +28 -0
- package/dist/chunk-ad2yk19p.js +102 -0
- package/dist/chunk-ad4cw4nw.js +336 -0
- package/dist/chunk-ad69fbsk.js +347 -0
- package/dist/chunk-ae76ded0.js +30 -0
- package/dist/chunk-aeysytks.js +216 -0
- package/dist/chunk-ag81m9bq.js +61 -0
- package/dist/chunk-ahx7gp6r.js +4448 -0
- package/dist/chunk-aj4tk4tk.js +23 -0
- package/dist/chunk-an82t9jc.js +104 -0
- package/dist/chunk-apg95qd7.js +1393 -0
- package/dist/chunk-aq5n2adz.js +27 -0
- package/dist/chunk-aw4s3a99.js +208 -0
- package/dist/chunk-awgdfggg.js +14 -0
- package/dist/chunk-ayymxgn1.js +164 -0
- package/dist/chunk-azbab59e.js +637 -0
- package/dist/chunk-azdxq2a3.js +293 -0
- package/dist/chunk-b0tjx3k1.js +523 -0
- package/dist/chunk-b5pp4g2g.js +371 -0
- package/dist/chunk-b5zm8dt6.js +26 -0
- package/dist/chunk-bcnye5a0.js +109 -0
- package/dist/chunk-beqz3k49.js +190 -0
- package/dist/chunk-bf906wpw.js +147 -0
- package/dist/chunk-bgan4cpf.js +13 -0
- package/dist/chunk-bhzp13h7.js +1178 -0
- package/dist/chunk-bk403kpw.js +142 -0
- package/dist/chunk-bmq4c135.js +489 -0
- package/dist/chunk-bprbeda7.js +35 -0
- package/dist/chunk-bst7czdd.js +888 -0
- package/dist/chunk-bths4xgn.js +111 -0
- package/dist/chunk-btjn3qby.js +13 -0
- package/dist/chunk-bwb1vxnt.js +120 -0
- package/dist/chunk-bxa6tw4m.js +643 -0
- package/dist/chunk-bxfjr8qb.js +27 -0
- package/dist/chunk-bxpzhrej.js +73 -0
- package/dist/chunk-bzyzrq0k.js +51 -0
- package/dist/chunk-c0k7b0jw.js +4265 -0
- package/dist/chunk-c17f0h2s.js +16 -0
- package/dist/chunk-c1yc761e.js +6748 -0
- package/dist/chunk-c5g9shkw.js +298 -0
- package/dist/chunk-c696122m.js +69 -0
- package/dist/chunk-c92b3yxx.js +109 -0
- package/dist/chunk-c9aqz56y.js +143 -0
- package/dist/chunk-cba7c5w3.js +345 -0
- package/dist/chunk-cbcxbbe6.js +6543 -0
- package/dist/chunk-cdfjb87h.js +11 -0
- package/dist/chunk-ce8zjt1y.js +136 -0
- package/dist/chunk-cep7e37k.js +22740 -0
- package/dist/chunk-chs5qm8d.js +258 -0
- package/dist/chunk-ckydq33g.js +144 -0
- package/dist/chunk-cnge6wpj.js +514 -0
- package/dist/chunk-cpnsvqf1.js +13 -0
- package/dist/chunk-cqqebkv4.js +32 -0
- package/dist/chunk-cvqpp7dk.js +627 -0
- package/dist/chunk-cwc33j40.js +65 -0
- package/dist/chunk-cypvrq2a.js +155 -0
- package/dist/chunk-d1ha0swn.js +475 -0
- package/dist/chunk-d2an0138.js +35 -0
- package/dist/chunk-d2tt72ck.js +343 -0
- package/dist/chunk-d6wvcqrw.js +9507 -0
- package/dist/chunk-d7ys2kka.js +991 -0
- package/dist/chunk-dbts5q5p.js +122 -0
- package/dist/chunk-dct29ggs.js +295 -0
- package/dist/chunk-de0qnnf7.js +1059 -0
- package/dist/chunk-dep72ce4.js +513 -0
- package/dist/chunk-dgpvgy8x.js +47 -0
- package/dist/chunk-dhhd7dtc.js +20 -0
- package/dist/chunk-dhzpmxv6.js +594 -0
- package/dist/chunk-djes4da7.js +413 -0
- package/dist/chunk-dnhv3vx7.js +166 -0
- package/dist/chunk-dqtvafan.js +2365 -0
- package/dist/chunk-dr4a3tcp.js +60 -0
- package/dist/chunk-dz2xk9kb.js +100 -0
- package/dist/chunk-dz7nc6rf.js +15 -0
- package/dist/chunk-e3abfxpy.js +1486 -0
- package/dist/chunk-e3cq9z89.js +85 -0
- package/dist/chunk-e3j7m7k2.js +642 -0
- package/dist/chunk-e4dsy4g1.js +9951 -0
- package/dist/chunk-e5592pnn.js +197 -0
- package/dist/chunk-e55hdegh.js +129 -0
- package/dist/chunk-e5r5r04e.js +1030 -0
- package/dist/chunk-e60zztbt.js +442 -0
- package/dist/chunk-e7qq6vn0.js +372 -0
- package/dist/chunk-e9aat7xw.js +80 -0
- package/dist/chunk-e9d5v3zs.js +143 -0
- package/dist/chunk-eax32zk4.js +87 -0
- package/dist/chunk-ebfwmbx1.js +117 -0
- package/dist/chunk-ec71pb8t.js +971 -0
- package/dist/chunk-eemjb825.js +17252 -0
- package/dist/chunk-ees8xdhd.js +256 -0
- package/dist/chunk-eewg66y1.js +112 -0
- package/dist/chunk-eg22v12d.js +266 -0
- package/dist/chunk-enzzk67f.js +313 -0
- package/dist/chunk-eskhp70f.js +117 -0
- package/dist/chunk-ewx6z4g8.js +55 -0
- package/dist/chunk-eyvx461k.js +76 -0
- package/dist/chunk-eztq2b5f.js +94 -0
- package/dist/chunk-f0ffwzdd.js +321 -0
- package/dist/chunk-f80n68mf.js +119 -0
- package/dist/chunk-fae2hjxp.js +99 -0
- package/dist/chunk-fbtfp370.js +60 -0
- package/dist/chunk-fc6ndtgf.js +94 -0
- package/dist/chunk-fdwabr8p.js +13870 -0
- package/dist/chunk-fejeqe61.js +785 -0
- package/dist/chunk-fh0d6mvk.js +168 -0
- package/dist/chunk-fh19zcaf.js +304 -0
- package/dist/chunk-fh8bd39r.js +186 -0
- package/dist/chunk-fj2ebbpn.js +33 -0
- package/dist/chunk-fjn632v7.js +194 -0
- package/dist/chunk-fncpkzs5.js +1389 -0
- package/dist/chunk-fpd1gpt8.js +332 -0
- package/dist/chunk-fq9snrnh.js +295 -0
- package/dist/chunk-fqcfzg3j.js +207 -0
- package/dist/chunk-ftt3vqj2.js +1919 -0
- package/dist/chunk-g06pm4n9.js +395 -0
- package/dist/chunk-g4m5pf4g.js +8 -0
- package/dist/chunk-g72h52y6.js +36 -0
- package/dist/chunk-g79ej71s.js +1627 -0
- package/dist/chunk-g7fwk59d.js +19 -0
- package/dist/chunk-g9jnkrtm.js +663 -0
- package/dist/chunk-g9vg5d7t.js +38 -0
- package/dist/chunk-ga1jkyqy.js +1636 -0
- package/dist/chunk-gaaap2nk.js +676 -0
- package/dist/chunk-gc6erq5q.js +483 -0
- package/dist/chunk-gjrcmf0a.js +752 -0
- package/dist/chunk-gmdy2w3z.js +238999 -0
- package/dist/chunk-gsz4yrrk.js +81 -0
- package/dist/chunk-gy47rjy8.js +3830 -0
- package/dist/chunk-h12a4f4x.js +11 -0
- package/dist/chunk-h1yratmg.js +725 -0
- package/dist/chunk-h9y0jnsy.js +155 -0
- package/dist/chunk-hbhs3mwy.js +133 -0
- package/dist/chunk-hbs8cmb4.js +8 -0
- package/dist/chunk-hdk0t1ht.js +940 -0
- package/dist/chunk-hef8dx4s.js +178 -0
- package/dist/chunk-hgsca8mt.js +381 -0
- package/dist/chunk-hhsxm2yr.js +67 -0
- package/dist/chunk-hj5tzzpd.js +39 -0
- package/dist/chunk-hjxqmtg5.js +94 -0
- package/dist/chunk-hn4w9pkj.js +68 -0
- package/dist/chunk-hnprkjgp.js +25 -0
- package/dist/chunk-hq3n5ex7.js +183 -0
- package/dist/chunk-hqjspfma.js +158 -0
- package/dist/chunk-hqxp6b72.js +1198 -0
- package/dist/chunk-hs6nrmq6.js +94 -0
- package/dist/chunk-hwba5xdc.js +267 -0
- package/dist/chunk-hy566ev3.js +430 -0
- package/dist/chunk-hzmzwte2.js +153 -0
- package/dist/chunk-hzxzvzw8.js +274 -0
- package/dist/chunk-j139fzgs.js +114 -0
- package/dist/chunk-j1mep9ck.js +62 -0
- package/dist/chunk-j3xveeg4.js +273 -0
- package/dist/chunk-j5y1s11j.js +100 -0
- package/dist/chunk-j9475b46.js +26 -0
- package/dist/chunk-j9rgqs8m.js +1192 -0
- package/dist/chunk-jccjaddz.js +74 -0
- package/dist/chunk-jdkwfy9e.js +35 -0
- package/dist/chunk-jdqp0r4h.js +6157 -0
- package/dist/chunk-jdzk4zwn.js +587 -0
- package/dist/chunk-jfafmkte.js +49 -0
- package/dist/chunk-jg3r989b.js +16 -0
- package/dist/chunk-jhtccjc9.js +54 -0
- package/dist/chunk-jj2ff1pr.js +688 -0
- package/dist/chunk-jmv7k0jn.js +37 -0
- package/dist/chunk-jmxzmwpw.js +65 -0
- package/dist/chunk-jnjxdqyr.js +353 -0
- package/dist/chunk-jsbbez9j.js +138 -0
- package/dist/chunk-jvpt2dc0.js +424 -0
- package/dist/chunk-jwd7cka0.js +34 -0
- package/dist/chunk-jy5er3st.js +15 -0
- package/dist/chunk-jyby79z5.js +121 -0
- package/dist/chunk-jzyr6j5n.js +332 -0
- package/dist/chunk-k49xc781.js +63 -0
- package/dist/chunk-k7dt2g4a.js +41 -0
- package/dist/chunk-k7hexw3v.js +969 -0
- package/dist/chunk-k7wwkraa.js +117 -0
- package/dist/chunk-kb3758f7.js +51 -0
- package/dist/chunk-kc67kt75.js +3119 -0
- package/dist/chunk-kdhmfxmh.js +3149 -0
- package/dist/chunk-kejdd6zc.js +51 -0
- package/dist/chunk-kekrjeem.js +402 -0
- package/dist/chunk-kez5r0zz.js +280 -0
- package/dist/chunk-kfsvcs5t.js +75 -0
- package/dist/chunk-khtvffc4.js +285 -0
- package/dist/chunk-kkz4w1tv.js +64 -0
- package/dist/chunk-kmywng0j.js +272 -0
- package/dist/chunk-kq6vcpdr.js +224 -0
- package/dist/chunk-kqzdszcc.js +37 -0
- package/dist/chunk-ktxpp02w.js +435 -0
- package/dist/chunk-kwcvhbtz.js +26 -0
- package/dist/chunk-kx0cm9qr.js +128 -0
- package/dist/chunk-kxcmqz10.js +120 -0
- package/dist/chunk-kxwava1g.js +14 -0
- package/dist/chunk-kywtr3jg.js +825 -0
- package/dist/chunk-kzwg923p.js +8 -0
- package/dist/chunk-m1eq3sgv.js +255 -0
- package/dist/chunk-m21h5zb4.js +119 -0
- package/dist/chunk-m2c3bjv1.js +111 -0
- package/dist/chunk-m41e19ms.js +42 -0
- package/dist/chunk-m7ka36ex.js +97 -0
- package/dist/chunk-m81w8tbm.js +259 -0
- package/dist/chunk-m95ggkax.js +281 -0
- package/dist/chunk-manx26xa.js +145 -0
- package/dist/chunk-mdxh3pk2.js +298 -0
- package/dist/chunk-mhbfkcja.js +311 -0
- package/dist/chunk-mjnr5erm.js +173 -0
- package/dist/chunk-mngvnmwp.js +135 -0
- package/dist/chunk-mvfqanv5.js +63 -0
- package/dist/chunk-mw1nesq1.js +140 -0
- package/dist/chunk-mx168925.js +661 -0
- package/dist/chunk-mxwvj18g.js +795 -0
- package/dist/chunk-my7r5mba.js +257 -0
- package/dist/chunk-myaa1kkf.js +17 -0
- package/dist/chunk-myypc3tn.js +46 -0
- package/dist/chunk-mzcnmnpq.js +3379 -0
- package/dist/chunk-mznav6d1.js +194 -0
- package/dist/chunk-n0qxskpr.js +24 -0
- package/dist/chunk-n6a6hgtp.js +394 -0
- package/dist/chunk-n6d5fgx0.js +254 -0
- package/dist/chunk-n6ym3n03.js +120 -0
- package/dist/chunk-n9g24mwe.js +104 -0
- package/dist/chunk-naamqdf9.js +185 -0
- package/dist/chunk-nb2jk7zj.js +15 -0
- package/dist/chunk-nbkbq9en.js +67 -0
- package/dist/chunk-ndttd6es.js +38 -0
- package/dist/chunk-nfygaaxg.js +133 -0
- package/dist/chunk-ngdzpszd.js +454 -0
- package/dist/chunk-nmfwksa4.js +1297 -0
- package/dist/chunk-nt837qt9.js +21 -0
- package/dist/chunk-nwc3v0vp.js +691 -0
- package/dist/chunk-nz8ha95p.js +3610 -0
- package/dist/chunk-nzxfj0gq.js +2007 -0
- package/dist/chunk-p0r8887g.js +6932 -0
- package/dist/chunk-p1seyqdm.js +120 -0
- package/dist/chunk-p425zbgw.js +726 -0
- package/dist/chunk-p7hamd2c.js +146 -0
- package/dist/chunk-pdvg91cg.js +32 -0
- package/dist/chunk-pecy49yr.js +14649 -0
- package/dist/chunk-pfxrg89f.js +547 -0
- package/dist/chunk-pfyw3155.js +2750 -0
- package/dist/chunk-pr8m11pm.js +1192 -0
- package/dist/chunk-ptxteaeh.js +1591 -0
- package/dist/chunk-pv164mac.js +394 -0
- package/dist/chunk-pxxhtxf5.js +10154 -0
- package/dist/chunk-q0e485mg.js +61 -0
- package/dist/chunk-q1vrhh0q.js +458 -0
- package/dist/chunk-q2h79ncs.js +370 -0
- package/dist/chunk-q3b4n194.js +56 -0
- package/dist/chunk-q44zc68f.js +4301 -0
- package/dist/chunk-q8gknbdx.js +352 -0
- package/dist/chunk-q8xk3kdj.js +11 -0
- package/dist/chunk-qak46xtp.js +119 -0
- package/dist/chunk-qfq7absv.js +95 -0
- package/dist/chunk-qfsn720k.js +151 -0
- package/dist/chunk-qg4811f6.js +228 -0
- package/dist/chunk-qgzn3qps.js +90 -0
- package/dist/chunk-qhaggqkt.js +113 -0
- package/dist/chunk-qjjp27z8.js +195 -0
- package/dist/chunk-qxp0nye6.js +34 -0
- package/dist/chunk-qy3nagaq.js +4957 -0
- package/dist/chunk-qz2meav1.js +1452 -0
- package/dist/chunk-r50hne7m.js +63 -0
- package/dist/chunk-r6m0vgnv.js +80 -0
- package/dist/chunk-r7yw38vf.js +22864 -0
- package/dist/chunk-r8xc618w.js +42 -0
- package/dist/chunk-r961r5kj.js +87 -0
- package/dist/chunk-r9b5xrh0.js +66 -0
- package/dist/chunk-rcn2pd6q.js +477 -0
- package/dist/chunk-rdeh8p3y.js +148 -0
- package/dist/chunk-rg9x1742.js +542 -0
- package/dist/chunk-rgyzsbs3.js +39 -0
- package/dist/chunk-rk2fsxtz.js +16 -0
- package/dist/chunk-rkchkwv9.js +40 -0
- package/dist/chunk-rp8whpb3.js +478 -0
- package/dist/chunk-rpkxdtgr.js +68 -0
- package/dist/chunk-rpmntgyh.js +394 -0
- package/dist/chunk-rpshz4dy.js +614 -0
- package/dist/chunk-rqd60ay5.js +133 -0
- package/dist/chunk-rrsjf2ea.js +229 -0
- package/dist/chunk-rtjk8c8e.js +173 -0
- package/dist/chunk-rw0y2wdf.js +1017 -0
- package/dist/chunk-rx5w7ess.js +663 -0
- package/dist/chunk-rx8t9d35.js +1947 -0
- package/dist/chunk-rxcazxgf.js +195 -0
- package/dist/chunk-rxg6q3bp.js +1413 -0
- package/dist/chunk-rxrb7xnd.js +71 -0
- package/dist/chunk-rxrzxff3.js +118 -0
- package/dist/chunk-ryqjc943.js +71 -0
- package/dist/chunk-rzk9k2rf.js +81 -0
- package/dist/chunk-s2qv0nht.js +119 -0
- package/dist/chunk-s3hafnk3.js +2285 -0
- package/dist/chunk-s4a496tt.js +226 -0
- package/dist/chunk-s4d1h3ka.js +35 -0
- package/dist/chunk-sm3k3ze4.js +16525 -0
- package/dist/chunk-sn0bja82.js +385 -0
- package/dist/chunk-sngjggw1.js +4227 -0
- package/dist/chunk-sq047n34.js +364 -0
- package/dist/chunk-sttwe2tw.js +8584 -0
- package/dist/chunk-sw8qx1r0.js +86 -0
- package/dist/chunk-swstah6a.js +240 -0
- package/dist/chunk-syrkr0mf.js +63 -0
- package/dist/chunk-sz206bd9.js +26 -0
- package/dist/chunk-t09669cj.js +333 -0
- package/dist/chunk-t5f8e30k.js +602 -0
- package/dist/chunk-t5m78mc8.js +432 -0
- package/dist/chunk-t5x1dqwn.js +143 -0
- package/dist/chunk-t877ea0w.js +168 -0
- package/dist/chunk-t91hb71c.js +17 -0
- package/dist/chunk-tb636bcf.js +942 -0
- package/dist/chunk-tb8sykbr.js +426 -0
- package/dist/chunk-tbdkekz3.js +125 -0
- package/dist/chunk-td2gsz7s.js +225 -0
- package/dist/chunk-tenvxbyh.js +20 -0
- package/dist/chunk-texg4qqt.js +317 -0
- package/dist/chunk-teymzz80.js +266 -0
- package/dist/chunk-tj26qpf7.js +153 -0
- package/dist/chunk-tk85ec4p.js +395 -0
- package/dist/chunk-tq205h01.js +164 -0
- package/dist/chunk-tqzddjzg.js +61 -0
- package/dist/chunk-trqrj23e.js +134 -0
- package/dist/chunk-tw1hfsxv.js +2477 -0
- package/dist/chunk-txxdfq83.js +122 -0
- package/dist/chunk-v0yhe582.js +31 -0
- package/dist/chunk-v14184xm.js +15 -0
- package/dist/chunk-v1h9z4hw.js +138 -0
- package/dist/chunk-v3ey5j7f.js +329 -0
- package/dist/chunk-v3nh1sfn.js +208 -0
- package/dist/chunk-v3x8tcc0.js +45 -0
- package/dist/chunk-v4nqnvqq.js +3984 -0
- package/dist/chunk-v4ypszbb.js +15 -0
- package/dist/chunk-v7wbqcx9.js +63 -0
- package/dist/chunk-v8r5fev3.js +341 -0
- package/dist/chunk-v9zg5kzx.js +2810 -0
- package/dist/chunk-va1wh5ss.js +24 -0
- package/dist/chunk-vbfswhht.js +42 -0
- package/dist/chunk-ve7x2tfq.js +124 -0
- package/dist/chunk-vfz8k89y.js +485 -0
- package/dist/chunk-vgm5k14x.js +35678 -0
- package/dist/chunk-vh9pej3c.js +247 -0
- package/dist/chunk-vjxqyt6f.js +3820 -0
- package/dist/chunk-vpb1xstn.js +178 -0
- package/dist/chunk-vqt79tj8.js +110 -0
- package/dist/chunk-vr0n9pv9.js +152 -0
- package/dist/chunk-vrejmja5.js +90 -0
- package/dist/chunk-vrxasmdw.js +449 -0
- package/dist/chunk-vrxb946v.js +125 -0
- package/dist/chunk-vv4kj0q8.js +98 -0
- package/dist/chunk-vvpfng7w.js +8 -0
- package/dist/chunk-vw6ybyew.js +2007 -0
- package/dist/chunk-vwenx8ke.js +17 -0
- package/dist/chunk-vwfa0s5a.js +155 -0
- package/dist/chunk-vx71j8xe.js +63 -0
- package/dist/chunk-vxbjzggp.js +43 -0
- package/dist/chunk-vxjxtz8w.js +440 -0
- package/dist/chunk-vy0c1bwp.js +9 -0
- package/dist/chunk-w3zczyse.js +14 -0
- package/dist/chunk-w4p5t920.js +655 -0
- package/dist/chunk-w68wc625.js +287 -0
- package/dist/chunk-w9ddp3yf.js +96 -0
- package/dist/chunk-wcggm5ja.js +125 -0
- package/dist/chunk-wgnyph3q.js +1306 -0
- package/dist/chunk-wjm5pc1e.js +134 -0
- package/dist/chunk-wnve0drm.js +131 -0
- package/dist/chunk-wp27ev2k.js +135 -0
- package/dist/chunk-wyvy8a4x.js +131 -0
- package/dist/chunk-x671y4dk.js +129 -0
- package/dist/chunk-xbj5keyy.js +22 -0
- package/dist/chunk-xf4fzms8.js +39 -0
- package/dist/chunk-xf59k3zg.js +65 -0
- package/dist/chunk-xgzc4w49.js +204 -0
- package/dist/chunk-xhj7g13b.js +2149 -0
- package/dist/chunk-xjp0cd00.js +56 -0
- package/dist/chunk-xkhnmhqs.js +74 -0
- package/dist/chunk-xkrkqx61.js +55 -0
- package/dist/chunk-xmpgmeb8.js +114 -0
- package/dist/chunk-xrw80zgd.js +4249 -0
- package/dist/chunk-xrzc96g0.js +202 -0
- package/dist/chunk-xt76sm44.js +318 -0
- package/dist/chunk-xwet3awb.js +20 -0
- package/dist/chunk-xyg1sk2w.js +78 -0
- package/dist/chunk-y0jpkqb0.js +180 -0
- package/dist/chunk-y1q7rt9n.js +102 -0
- package/dist/chunk-y67ntyek.js +258 -0
- package/dist/chunk-ybk37qp9.js +37 -0
- package/dist/chunk-yc1stfve.js +5386 -0
- package/dist/chunk-ychjpjef.js +62 -0
- package/dist/chunk-yez8fa9g.js +276 -0
- package/dist/chunk-ygm7xszr.js +90 -0
- package/dist/chunk-ym11azkj.js +37 -0
- package/dist/chunk-ympz2h15.js +578 -0
- package/dist/chunk-yqx3az3n.js +129 -0
- package/dist/chunk-yt3nfhcc.js +152 -0
- package/dist/chunk-yy8q0n8s.js +120 -0
- package/dist/chunk-yzb92zxv.js +8 -0
- package/dist/chunk-yzet6xyr.js +119 -0
- package/dist/chunk-yzm97qp1.js +226 -0
- package/dist/chunk-z0jgeax8.js +35 -0
- package/dist/chunk-z1r3z6w6.js +29 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z79355gz.js +308 -0
- package/dist/chunk-z7e94hxz.js +251 -0
- package/dist/chunk-z8cqdcec.js +173 -0
- package/dist/chunk-z99tbg45.js +148 -0
- package/dist/chunk-z9nsjcht.js +37 -0
- package/dist/chunk-za3k6h2h.js +470 -0
- package/dist/chunk-zacynq5p.js +265 -0
- package/dist/chunk-zb0x40az.js +1785 -0
- package/dist/chunk-zbxtzycc.js +274 -0
- package/dist/chunk-zga50181.js +342 -0
- package/dist/chunk-zhb2pns1.js +44 -0
- package/dist/chunk-zkch6trx.js +231 -0
- package/dist/chunk-znf3z4qt.js +954 -0
- package/dist/chunk-zp8zwdgq.js +72 -0
- package/dist/chunk-ztjd8pyf.js +120 -0
- package/dist/chunk-ztmb7geg.js +173 -0
- package/dist/chunk-zvr4snzv.js +887 -0
- package/dist/chunk-zw62m6n3.js +34858 -0
- package/dist/chunk-zwwdebd0.js +65 -0
- package/dist/chunk-zxc6x9w8.js +340 -0
- package/dist/chunk-zy2e7sz0.js +8 -0
- package/dist/chunk-zzf074w3.js +196 -0
- package/dist/chunk-zzz0nwb5.js +310 -0
- package/dist/cli-bun.js +2 -0
- package/dist/cli-node.js +2 -0
- package/dist/cli.js +218 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +243 -0
- package/scripts/chrome-mcp-bridge-resolver.mjs +43 -0
- package/scripts/chrome-mcp-env.mjs +19 -0
- package/scripts/postinstall.cjs +339 -0
- package/scripts/run-parallel.mjs +10 -0
- package/scripts/setup-chrome-mcp.mjs +69 -0
|
@@ -0,0 +1,1919 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
__esm
|
|
4
|
+
} from "./chunk-hhsxm2yr.js";
|
|
5
|
+
|
|
6
|
+
// node_modules/.bun/fuse.js@7.3.0/node_modules/fuse.js/dist/fuse.mjs
|
|
7
|
+
function isArray(value) {
|
|
8
|
+
return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function baseToString(value) {
|
|
11
|
+
if (typeof value == "string") {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === "bigint") {
|
|
15
|
+
return value.toString();
|
|
16
|
+
}
|
|
17
|
+
const result = value + "";
|
|
18
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
19
|
+
}
|
|
20
|
+
function toString(value) {
|
|
21
|
+
return value == null ? "" : baseToString(value);
|
|
22
|
+
}
|
|
23
|
+
function isString(value) {
|
|
24
|
+
return typeof value === "string";
|
|
25
|
+
}
|
|
26
|
+
function isNumber(value) {
|
|
27
|
+
return typeof value === "number";
|
|
28
|
+
}
|
|
29
|
+
function isBoolean(value) {
|
|
30
|
+
return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]";
|
|
31
|
+
}
|
|
32
|
+
function isObject(value) {
|
|
33
|
+
return typeof value === "object";
|
|
34
|
+
}
|
|
35
|
+
function isObjectLike(value) {
|
|
36
|
+
return isObject(value) && value !== null;
|
|
37
|
+
}
|
|
38
|
+
function isDefined(value) {
|
|
39
|
+
return value !== undefined && value !== null;
|
|
40
|
+
}
|
|
41
|
+
function isBlank(value) {
|
|
42
|
+
return !value.trim().length;
|
|
43
|
+
}
|
|
44
|
+
function getTag(value) {
|
|
45
|
+
return value == null ? value === undefined ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class KeyStore {
|
|
49
|
+
constructor(keys) {
|
|
50
|
+
this._keys = [];
|
|
51
|
+
this._keyMap = {};
|
|
52
|
+
let totalWeight = 0;
|
|
53
|
+
keys.forEach((key) => {
|
|
54
|
+
const obj = createKey(key);
|
|
55
|
+
this._keys.push(obj);
|
|
56
|
+
this._keyMap[obj.id] = obj;
|
|
57
|
+
totalWeight += obj.weight;
|
|
58
|
+
});
|
|
59
|
+
this._keys.forEach((key) => {
|
|
60
|
+
key.weight /= totalWeight;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
get(keyId) {
|
|
64
|
+
return this._keyMap[keyId];
|
|
65
|
+
}
|
|
66
|
+
keys() {
|
|
67
|
+
return this._keys;
|
|
68
|
+
}
|
|
69
|
+
toJSON() {
|
|
70
|
+
return JSON.stringify(this._keys);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function createKey(key) {
|
|
74
|
+
let path = null;
|
|
75
|
+
let id = null;
|
|
76
|
+
let src = null;
|
|
77
|
+
let weight = 1;
|
|
78
|
+
let getFn = null;
|
|
79
|
+
if (isString(key) || isArray(key)) {
|
|
80
|
+
src = key;
|
|
81
|
+
path = createKeyPath(key);
|
|
82
|
+
id = createKeyId(key);
|
|
83
|
+
} else {
|
|
84
|
+
if (!hasOwn.call(key, "name")) {
|
|
85
|
+
throw new Error(MISSING_KEY_PROPERTY("name"));
|
|
86
|
+
}
|
|
87
|
+
const name = key.name;
|
|
88
|
+
src = name;
|
|
89
|
+
if (hasOwn.call(key, "weight")) {
|
|
90
|
+
weight = key.weight;
|
|
91
|
+
if (weight <= 0) {
|
|
92
|
+
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
path = createKeyPath(name);
|
|
96
|
+
id = createKeyId(name);
|
|
97
|
+
getFn = key.getFn;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
path,
|
|
101
|
+
id,
|
|
102
|
+
weight,
|
|
103
|
+
src,
|
|
104
|
+
getFn
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function createKeyPath(key) {
|
|
108
|
+
return isArray(key) ? key : key.split(".");
|
|
109
|
+
}
|
|
110
|
+
function createKeyId(key) {
|
|
111
|
+
return isArray(key) ? key.join(".") : key;
|
|
112
|
+
}
|
|
113
|
+
function get(obj, path) {
|
|
114
|
+
const list = [];
|
|
115
|
+
let arr = false;
|
|
116
|
+
const deepGet = (obj2, path2, index, arrayIndex) => {
|
|
117
|
+
if (!isDefined(obj2)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!path2[index]) {
|
|
121
|
+
list.push(arrayIndex !== undefined ? {
|
|
122
|
+
v: obj2,
|
|
123
|
+
i: arrayIndex
|
|
124
|
+
} : obj2);
|
|
125
|
+
} else {
|
|
126
|
+
const key = path2[index];
|
|
127
|
+
const value = obj2[key];
|
|
128
|
+
if (!isDefined(value)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (index === path2.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === "bigint")) {
|
|
132
|
+
list.push(arrayIndex !== undefined ? {
|
|
133
|
+
v: toString(value),
|
|
134
|
+
i: arrayIndex
|
|
135
|
+
} : toString(value));
|
|
136
|
+
} else if (isArray(value)) {
|
|
137
|
+
arr = true;
|
|
138
|
+
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
139
|
+
deepGet(value[i], path2, index + 1, i);
|
|
140
|
+
}
|
|
141
|
+
} else if (path2.length) {
|
|
142
|
+
deepGet(value, path2, index + 1, arrayIndex);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
deepGet(obj, isString(path) ? path.split(".") : path, 0);
|
|
147
|
+
return arr ? list : list[0];
|
|
148
|
+
}
|
|
149
|
+
function norm(weight = 1, mantissa = 3) {
|
|
150
|
+
const cache = new Map;
|
|
151
|
+
const m = Math.pow(10, mantissa);
|
|
152
|
+
return {
|
|
153
|
+
get(value) {
|
|
154
|
+
const numTokens = value.match(SPACE).length;
|
|
155
|
+
if (cache.has(numTokens)) {
|
|
156
|
+
return cache.get(numTokens);
|
|
157
|
+
}
|
|
158
|
+
const norm2 = 1 / Math.pow(numTokens, 0.5 * weight);
|
|
159
|
+
const n = parseFloat(Math.round(norm2 * m) / m);
|
|
160
|
+
cache.set(numTokens, n);
|
|
161
|
+
return n;
|
|
162
|
+
},
|
|
163
|
+
clear() {
|
|
164
|
+
cache.clear();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
class FuseIndex {
|
|
170
|
+
constructor({
|
|
171
|
+
getFn = Config.getFn,
|
|
172
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
173
|
+
} = {}) {
|
|
174
|
+
this.norm = norm(fieldNormWeight, 3);
|
|
175
|
+
this.getFn = getFn;
|
|
176
|
+
this.isCreated = false;
|
|
177
|
+
this.docs = [];
|
|
178
|
+
this.keys = [];
|
|
179
|
+
this._keysMap = {};
|
|
180
|
+
this.setIndexRecords();
|
|
181
|
+
}
|
|
182
|
+
setSources(docs = []) {
|
|
183
|
+
this.docs = docs;
|
|
184
|
+
}
|
|
185
|
+
setIndexRecords(records = []) {
|
|
186
|
+
this.records = records;
|
|
187
|
+
}
|
|
188
|
+
setKeys(keys = []) {
|
|
189
|
+
this.keys = keys;
|
|
190
|
+
this._keysMap = {};
|
|
191
|
+
keys.forEach((key, idx) => {
|
|
192
|
+
this._keysMap[key.id] = idx;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
create() {
|
|
196
|
+
if (this.isCreated || !this.docs.length) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.isCreated = true;
|
|
200
|
+
if (isString(this.docs[0])) {
|
|
201
|
+
this.docs.forEach((doc, docIndex) => {
|
|
202
|
+
this._addString(doc, docIndex);
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
this.docs.forEach((doc, docIndex) => {
|
|
206
|
+
this._addObject(doc, docIndex);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
this.norm.clear();
|
|
210
|
+
}
|
|
211
|
+
add(doc) {
|
|
212
|
+
const idx = this.size();
|
|
213
|
+
if (isString(doc)) {
|
|
214
|
+
this._addString(doc, idx);
|
|
215
|
+
} else {
|
|
216
|
+
this._addObject(doc, idx);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
removeAt(idx) {
|
|
220
|
+
this.records.splice(idx, 1);
|
|
221
|
+
for (let i = idx, len = this.size();i < len; i += 1) {
|
|
222
|
+
this.records[i].i -= 1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
removeAll(indices) {
|
|
226
|
+
for (let i = indices.length - 1;i >= 0; i -= 1) {
|
|
227
|
+
this.records.splice(indices[i], 1);
|
|
228
|
+
}
|
|
229
|
+
for (let i = 0, len = this.records.length;i < len; i += 1) {
|
|
230
|
+
this.records[i].i = i;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
getValueForItemAtKeyId(item, keyId) {
|
|
234
|
+
return item[this._keysMap[keyId]];
|
|
235
|
+
}
|
|
236
|
+
size() {
|
|
237
|
+
return this.records.length;
|
|
238
|
+
}
|
|
239
|
+
_addString(doc, docIndex) {
|
|
240
|
+
if (!isDefined(doc) || isBlank(doc)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const record = {
|
|
244
|
+
v: doc,
|
|
245
|
+
i: docIndex,
|
|
246
|
+
n: this.norm.get(doc)
|
|
247
|
+
};
|
|
248
|
+
this.records.push(record);
|
|
249
|
+
}
|
|
250
|
+
_addObject(doc, docIndex) {
|
|
251
|
+
const record = {
|
|
252
|
+
i: docIndex,
|
|
253
|
+
$: {}
|
|
254
|
+
};
|
|
255
|
+
this.keys.forEach((key, keyIndex) => {
|
|
256
|
+
const value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
|
|
257
|
+
if (!isDefined(value)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (isArray(value)) {
|
|
261
|
+
const subRecords = [];
|
|
262
|
+
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
263
|
+
const item = value[i];
|
|
264
|
+
if (!isDefined(item)) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (isString(item)) {
|
|
268
|
+
if (!isBlank(item)) {
|
|
269
|
+
const subRecord = {
|
|
270
|
+
v: item,
|
|
271
|
+
i,
|
|
272
|
+
n: this.norm.get(item)
|
|
273
|
+
};
|
|
274
|
+
subRecords.push(subRecord);
|
|
275
|
+
}
|
|
276
|
+
} else if (isDefined(item.v)) {
|
|
277
|
+
const text = isString(item.v) ? item.v : toString(item.v);
|
|
278
|
+
if (!isBlank(text)) {
|
|
279
|
+
const subRecord = {
|
|
280
|
+
v: text,
|
|
281
|
+
i: item.i,
|
|
282
|
+
n: this.norm.get(text)
|
|
283
|
+
};
|
|
284
|
+
subRecords.push(subRecord);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
record.$[keyIndex] = subRecords;
|
|
289
|
+
} else if (isString(value) && !isBlank(value)) {
|
|
290
|
+
const subRecord = {
|
|
291
|
+
v: value,
|
|
292
|
+
n: this.norm.get(value)
|
|
293
|
+
};
|
|
294
|
+
record.$[keyIndex] = subRecord;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
this.records.push(record);
|
|
298
|
+
}
|
|
299
|
+
toJSON() {
|
|
300
|
+
return {
|
|
301
|
+
keys: this.keys.map(({
|
|
302
|
+
getFn,
|
|
303
|
+
...key
|
|
304
|
+
}) => key),
|
|
305
|
+
records: this.records
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function createIndex(keys, docs, {
|
|
310
|
+
getFn = Config.getFn,
|
|
311
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
312
|
+
} = {}) {
|
|
313
|
+
const myIndex = new FuseIndex({
|
|
314
|
+
getFn,
|
|
315
|
+
fieldNormWeight
|
|
316
|
+
});
|
|
317
|
+
myIndex.setKeys(keys.map(createKey));
|
|
318
|
+
myIndex.setSources(docs);
|
|
319
|
+
myIndex.create();
|
|
320
|
+
return myIndex;
|
|
321
|
+
}
|
|
322
|
+
function parseIndex(data, {
|
|
323
|
+
getFn = Config.getFn,
|
|
324
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
325
|
+
} = {}) {
|
|
326
|
+
const {
|
|
327
|
+
keys,
|
|
328
|
+
records
|
|
329
|
+
} = data;
|
|
330
|
+
const myIndex = new FuseIndex({
|
|
331
|
+
getFn,
|
|
332
|
+
fieldNormWeight
|
|
333
|
+
});
|
|
334
|
+
myIndex.setKeys(keys);
|
|
335
|
+
myIndex.setIndexRecords(records);
|
|
336
|
+
return myIndex;
|
|
337
|
+
}
|
|
338
|
+
function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
|
|
339
|
+
const indices = [];
|
|
340
|
+
let start = -1;
|
|
341
|
+
let end = -1;
|
|
342
|
+
let i = 0;
|
|
343
|
+
for (let len = matchmask.length;i < len; i += 1) {
|
|
344
|
+
const match = matchmask[i];
|
|
345
|
+
if (match && start === -1) {
|
|
346
|
+
start = i;
|
|
347
|
+
} else if (!match && start !== -1) {
|
|
348
|
+
end = i - 1;
|
|
349
|
+
if (end - start + 1 >= minMatchCharLength) {
|
|
350
|
+
indices.push([start, end]);
|
|
351
|
+
}
|
|
352
|
+
start = -1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (matchmask[i - 1] && i - start >= minMatchCharLength) {
|
|
356
|
+
indices.push([start, i - 1]);
|
|
357
|
+
}
|
|
358
|
+
return indices;
|
|
359
|
+
}
|
|
360
|
+
function search(text, pattern, patternAlphabet, {
|
|
361
|
+
location = Config.location,
|
|
362
|
+
distance = Config.distance,
|
|
363
|
+
threshold = Config.threshold,
|
|
364
|
+
findAllMatches = Config.findAllMatches,
|
|
365
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
366
|
+
includeMatches = Config.includeMatches,
|
|
367
|
+
ignoreLocation = Config.ignoreLocation
|
|
368
|
+
} = {}) {
|
|
369
|
+
if (pattern.length > MAX_BITS) {
|
|
370
|
+
throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
|
|
371
|
+
}
|
|
372
|
+
const patternLen = pattern.length;
|
|
373
|
+
const textLen = text.length;
|
|
374
|
+
const expectedLocation = Math.max(0, Math.min(location, textLen));
|
|
375
|
+
let currentThreshold = threshold;
|
|
376
|
+
let bestLocation = expectedLocation;
|
|
377
|
+
const calcScore = (errors, currentLocation) => {
|
|
378
|
+
const accuracy = errors / patternLen;
|
|
379
|
+
if (ignoreLocation)
|
|
380
|
+
return accuracy;
|
|
381
|
+
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
382
|
+
if (!distance)
|
|
383
|
+
return proximity ? 1 : accuracy;
|
|
384
|
+
return accuracy + proximity / distance;
|
|
385
|
+
};
|
|
386
|
+
const computeMatches = minMatchCharLength > 1 || includeMatches;
|
|
387
|
+
const matchMask = computeMatches ? Array(textLen) : [];
|
|
388
|
+
let index;
|
|
389
|
+
while ((index = text.indexOf(pattern, bestLocation)) > -1) {
|
|
390
|
+
const score = calcScore(0, index);
|
|
391
|
+
currentThreshold = Math.min(score, currentThreshold);
|
|
392
|
+
bestLocation = index + patternLen;
|
|
393
|
+
if (computeMatches) {
|
|
394
|
+
let i = 0;
|
|
395
|
+
while (i < patternLen) {
|
|
396
|
+
matchMask[index + i] = 1;
|
|
397
|
+
i += 1;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
bestLocation = -1;
|
|
402
|
+
let lastBitArr = [];
|
|
403
|
+
let finalScore = 1;
|
|
404
|
+
let binMax = patternLen + textLen;
|
|
405
|
+
const mask = 1 << patternLen - 1;
|
|
406
|
+
for (let i = 0;i < patternLen; i += 1) {
|
|
407
|
+
let binMin = 0;
|
|
408
|
+
let binMid = binMax;
|
|
409
|
+
while (binMin < binMid) {
|
|
410
|
+
const score2 = calcScore(i, expectedLocation + binMid);
|
|
411
|
+
if (score2 <= currentThreshold) {
|
|
412
|
+
binMin = binMid;
|
|
413
|
+
} else {
|
|
414
|
+
binMax = binMid;
|
|
415
|
+
}
|
|
416
|
+
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
417
|
+
}
|
|
418
|
+
binMax = binMid;
|
|
419
|
+
let start = Math.max(1, expectedLocation - binMid + 1);
|
|
420
|
+
const finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
|
|
421
|
+
const bitArr = Array(finish + 2);
|
|
422
|
+
bitArr[finish + 1] = (1 << i) - 1;
|
|
423
|
+
for (let j = finish;j >= start; j -= 1) {
|
|
424
|
+
const currentLocation = j - 1;
|
|
425
|
+
const charMatch = patternAlphabet[text[currentLocation]];
|
|
426
|
+
if (computeMatches) {
|
|
427
|
+
matchMask[currentLocation] = +!!charMatch;
|
|
428
|
+
}
|
|
429
|
+
bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
|
|
430
|
+
if (i) {
|
|
431
|
+
bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
|
|
432
|
+
}
|
|
433
|
+
if (bitArr[j] & mask) {
|
|
434
|
+
finalScore = calcScore(i, currentLocation);
|
|
435
|
+
if (finalScore <= currentThreshold) {
|
|
436
|
+
currentThreshold = finalScore;
|
|
437
|
+
bestLocation = currentLocation;
|
|
438
|
+
if (bestLocation <= expectedLocation) {
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
start = Math.max(1, 2 * expectedLocation - bestLocation);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const score = calcScore(i + 1, expectedLocation);
|
|
446
|
+
if (score > currentThreshold) {
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
lastBitArr = bitArr;
|
|
450
|
+
}
|
|
451
|
+
const result = {
|
|
452
|
+
isMatch: bestLocation >= 0,
|
|
453
|
+
score: Math.max(0.001, finalScore)
|
|
454
|
+
};
|
|
455
|
+
if (computeMatches) {
|
|
456
|
+
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
457
|
+
if (!indices.length) {
|
|
458
|
+
result.isMatch = false;
|
|
459
|
+
} else if (includeMatches) {
|
|
460
|
+
result.indices = indices;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
function createPatternAlphabet(pattern) {
|
|
466
|
+
const mask = {};
|
|
467
|
+
for (let i = 0, len = pattern.length;i < len; i += 1) {
|
|
468
|
+
const char = pattern.charAt(i);
|
|
469
|
+
mask[char] = (mask[char] || 0) | 1 << len - i - 1;
|
|
470
|
+
}
|
|
471
|
+
return mask;
|
|
472
|
+
}
|
|
473
|
+
function mergeIndices(indices) {
|
|
474
|
+
if (indices.length <= 1)
|
|
475
|
+
return indices;
|
|
476
|
+
indices.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
477
|
+
const merged = [indices[0]];
|
|
478
|
+
for (let i = 1, len = indices.length;i < len; i += 1) {
|
|
479
|
+
const last = merged[merged.length - 1];
|
|
480
|
+
const curr = indices[i];
|
|
481
|
+
if (curr[0] <= last[1] + 1) {
|
|
482
|
+
last[1] = Math.max(last[1], curr[1]);
|
|
483
|
+
} else {
|
|
484
|
+
merged.push(curr);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return merged;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
class BitapSearch {
|
|
491
|
+
constructor(pattern, {
|
|
492
|
+
location = Config.location,
|
|
493
|
+
threshold = Config.threshold,
|
|
494
|
+
distance = Config.distance,
|
|
495
|
+
includeMatches = Config.includeMatches,
|
|
496
|
+
findAllMatches = Config.findAllMatches,
|
|
497
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
498
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
499
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
500
|
+
ignoreLocation = Config.ignoreLocation
|
|
501
|
+
} = {}) {
|
|
502
|
+
this.options = {
|
|
503
|
+
location,
|
|
504
|
+
threshold,
|
|
505
|
+
distance,
|
|
506
|
+
includeMatches,
|
|
507
|
+
findAllMatches,
|
|
508
|
+
minMatchCharLength,
|
|
509
|
+
isCaseSensitive,
|
|
510
|
+
ignoreDiacritics,
|
|
511
|
+
ignoreLocation
|
|
512
|
+
};
|
|
513
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
514
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
515
|
+
this.pattern = pattern;
|
|
516
|
+
this.chunks = [];
|
|
517
|
+
if (!this.pattern.length) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const addChunk = (pattern2, startIndex) => {
|
|
521
|
+
this.chunks.push({
|
|
522
|
+
pattern: pattern2,
|
|
523
|
+
alphabet: createPatternAlphabet(pattern2),
|
|
524
|
+
startIndex
|
|
525
|
+
});
|
|
526
|
+
};
|
|
527
|
+
const len = this.pattern.length;
|
|
528
|
+
if (len > MAX_BITS) {
|
|
529
|
+
let i = 0;
|
|
530
|
+
const remainder = len % MAX_BITS;
|
|
531
|
+
const end = len - remainder;
|
|
532
|
+
while (i < end) {
|
|
533
|
+
addChunk(this.pattern.substr(i, MAX_BITS), i);
|
|
534
|
+
i += MAX_BITS;
|
|
535
|
+
}
|
|
536
|
+
if (remainder) {
|
|
537
|
+
const startIndex = len - MAX_BITS;
|
|
538
|
+
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
addChunk(this.pattern, 0);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
searchIn(text) {
|
|
545
|
+
const {
|
|
546
|
+
isCaseSensitive,
|
|
547
|
+
ignoreDiacritics,
|
|
548
|
+
includeMatches
|
|
549
|
+
} = this.options;
|
|
550
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
551
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
552
|
+
if (this.pattern === text) {
|
|
553
|
+
const result2 = {
|
|
554
|
+
isMatch: true,
|
|
555
|
+
score: 0
|
|
556
|
+
};
|
|
557
|
+
if (includeMatches) {
|
|
558
|
+
result2.indices = [[0, text.length - 1]];
|
|
559
|
+
}
|
|
560
|
+
return result2;
|
|
561
|
+
}
|
|
562
|
+
const {
|
|
563
|
+
location,
|
|
564
|
+
distance,
|
|
565
|
+
threshold,
|
|
566
|
+
findAllMatches,
|
|
567
|
+
minMatchCharLength,
|
|
568
|
+
ignoreLocation
|
|
569
|
+
} = this.options;
|
|
570
|
+
const allIndices = [];
|
|
571
|
+
let totalScore = 0;
|
|
572
|
+
let hasMatches = false;
|
|
573
|
+
this.chunks.forEach(({
|
|
574
|
+
pattern,
|
|
575
|
+
alphabet,
|
|
576
|
+
startIndex
|
|
577
|
+
}) => {
|
|
578
|
+
const {
|
|
579
|
+
isMatch,
|
|
580
|
+
score,
|
|
581
|
+
indices
|
|
582
|
+
} = search(text, pattern, alphabet, {
|
|
583
|
+
location: location + startIndex,
|
|
584
|
+
distance,
|
|
585
|
+
threshold,
|
|
586
|
+
findAllMatches,
|
|
587
|
+
minMatchCharLength,
|
|
588
|
+
includeMatches,
|
|
589
|
+
ignoreLocation
|
|
590
|
+
});
|
|
591
|
+
if (isMatch) {
|
|
592
|
+
hasMatches = true;
|
|
593
|
+
}
|
|
594
|
+
totalScore += score;
|
|
595
|
+
if (isMatch && indices) {
|
|
596
|
+
allIndices.push(...indices);
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
const result = {
|
|
600
|
+
isMatch: hasMatches,
|
|
601
|
+
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
602
|
+
};
|
|
603
|
+
if (hasMatches && includeMatches) {
|
|
604
|
+
result.indices = mergeIndices(allIndices);
|
|
605
|
+
}
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
class BaseMatch {
|
|
611
|
+
constructor(pattern) {
|
|
612
|
+
this.pattern = pattern;
|
|
613
|
+
}
|
|
614
|
+
static isMultiMatch(pattern) {
|
|
615
|
+
return getMatch(pattern, this.multiRegex);
|
|
616
|
+
}
|
|
617
|
+
static isSingleMatch(pattern) {
|
|
618
|
+
return getMatch(pattern, this.singleRegex);
|
|
619
|
+
}
|
|
620
|
+
search(_text) {
|
|
621
|
+
return {
|
|
622
|
+
isMatch: false,
|
|
623
|
+
score: 1
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function getMatch(pattern, exp) {
|
|
628
|
+
const matches = pattern.match(exp);
|
|
629
|
+
return matches ? matches[1] : null;
|
|
630
|
+
}
|
|
631
|
+
function tokenize(pattern) {
|
|
632
|
+
const tokens = [];
|
|
633
|
+
const len = pattern.length;
|
|
634
|
+
let i = 0;
|
|
635
|
+
while (i < len) {
|
|
636
|
+
while (i < len && pattern[i] === " ")
|
|
637
|
+
i++;
|
|
638
|
+
if (i >= len)
|
|
639
|
+
break;
|
|
640
|
+
let j = i;
|
|
641
|
+
while (j < len && pattern[j] !== " " && pattern[j] !== '"')
|
|
642
|
+
j++;
|
|
643
|
+
if (j < len && pattern[j] === '"') {
|
|
644
|
+
j++;
|
|
645
|
+
while (j < len) {
|
|
646
|
+
if (pattern[j] === '"') {
|
|
647
|
+
const next = j + 1;
|
|
648
|
+
if (next >= len || pattern[next] === " ") {
|
|
649
|
+
j++;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
if (pattern[next] === "$" && (next + 1 >= len || pattern[next + 1] === " ")) {
|
|
653
|
+
j += 2;
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
j++;
|
|
658
|
+
}
|
|
659
|
+
tokens.push(pattern.substring(i, j));
|
|
660
|
+
i = j;
|
|
661
|
+
} else {
|
|
662
|
+
while (j < len && pattern[j] !== " ")
|
|
663
|
+
j++;
|
|
664
|
+
tokens.push(pattern.substring(i, j));
|
|
665
|
+
i = j;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return tokens;
|
|
669
|
+
}
|
|
670
|
+
function parseQuery(pattern, options = {}) {
|
|
671
|
+
const escaped = pattern.replace(/\\\|/g, ESCAPED_PIPE);
|
|
672
|
+
return escaped.split(OR_TOKEN).map((item) => {
|
|
673
|
+
const restored = item.replace(/\u0000/g, "|");
|
|
674
|
+
const query = tokenize(restored.trim()).filter((item2) => item2 && !!item2.trim());
|
|
675
|
+
const results = [];
|
|
676
|
+
for (let i = 0, len = query.length;i < len; i += 1) {
|
|
677
|
+
const queryItem = query[i];
|
|
678
|
+
let found = false;
|
|
679
|
+
let idx = -1;
|
|
680
|
+
while (!found && ++idx < searchersLen) {
|
|
681
|
+
const searcher = searchers[idx];
|
|
682
|
+
const token = searcher.isMultiMatch(queryItem);
|
|
683
|
+
if (token) {
|
|
684
|
+
results.push(new searcher(token, options));
|
|
685
|
+
found = true;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (found) {
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
idx = -1;
|
|
692
|
+
while (++idx < searchersLen) {
|
|
693
|
+
const searcher = searchers[idx];
|
|
694
|
+
const token = searcher.isSingleMatch(queryItem);
|
|
695
|
+
if (token) {
|
|
696
|
+
results.push(new searcher(token, options));
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return results;
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
class ExtendedSearch {
|
|
706
|
+
constructor(pattern, {
|
|
707
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
708
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
709
|
+
includeMatches = Config.includeMatches,
|
|
710
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
711
|
+
ignoreLocation = Config.ignoreLocation,
|
|
712
|
+
findAllMatches = Config.findAllMatches,
|
|
713
|
+
location = Config.location,
|
|
714
|
+
threshold = Config.threshold,
|
|
715
|
+
distance = Config.distance
|
|
716
|
+
} = {}) {
|
|
717
|
+
this.query = null;
|
|
718
|
+
this.options = {
|
|
719
|
+
isCaseSensitive,
|
|
720
|
+
ignoreDiacritics,
|
|
721
|
+
includeMatches,
|
|
722
|
+
minMatchCharLength,
|
|
723
|
+
findAllMatches,
|
|
724
|
+
ignoreLocation,
|
|
725
|
+
location,
|
|
726
|
+
threshold,
|
|
727
|
+
distance
|
|
728
|
+
};
|
|
729
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
730
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
731
|
+
this.pattern = pattern;
|
|
732
|
+
this.query = parseQuery(this.pattern, this.options);
|
|
733
|
+
}
|
|
734
|
+
static condition(_, options) {
|
|
735
|
+
return options.useExtendedSearch;
|
|
736
|
+
}
|
|
737
|
+
searchIn(text) {
|
|
738
|
+
const query = this.query;
|
|
739
|
+
if (!query) {
|
|
740
|
+
return {
|
|
741
|
+
isMatch: false,
|
|
742
|
+
score: 1
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
const {
|
|
746
|
+
includeMatches,
|
|
747
|
+
isCaseSensitive,
|
|
748
|
+
ignoreDiacritics
|
|
749
|
+
} = this.options;
|
|
750
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
751
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
752
|
+
let numMatches = 0;
|
|
753
|
+
const allIndices = [];
|
|
754
|
+
let totalScore = 0;
|
|
755
|
+
let hasInverse = false;
|
|
756
|
+
for (let i = 0, qLen = query.length;i < qLen; i += 1) {
|
|
757
|
+
const searchers2 = query[i];
|
|
758
|
+
allIndices.length = 0;
|
|
759
|
+
numMatches = 0;
|
|
760
|
+
hasInverse = false;
|
|
761
|
+
for (let j = 0, pLen = searchers2.length;j < pLen; j += 1) {
|
|
762
|
+
const searcher = searchers2[j];
|
|
763
|
+
const {
|
|
764
|
+
isMatch,
|
|
765
|
+
indices,
|
|
766
|
+
score
|
|
767
|
+
} = searcher.search(text);
|
|
768
|
+
if (isMatch) {
|
|
769
|
+
numMatches += 1;
|
|
770
|
+
totalScore += score;
|
|
771
|
+
const type = searcher.constructor.type;
|
|
772
|
+
if (type.startsWith("inverse")) {
|
|
773
|
+
hasInverse = true;
|
|
774
|
+
}
|
|
775
|
+
if (includeMatches) {
|
|
776
|
+
if (MultiMatchSet.has(type)) {
|
|
777
|
+
allIndices.push(...indices);
|
|
778
|
+
} else {
|
|
779
|
+
allIndices.push(indices);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
} else {
|
|
783
|
+
totalScore = 0;
|
|
784
|
+
numMatches = 0;
|
|
785
|
+
allIndices.length = 0;
|
|
786
|
+
hasInverse = false;
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (numMatches) {
|
|
791
|
+
const result = {
|
|
792
|
+
isMatch: true,
|
|
793
|
+
score: totalScore / numMatches
|
|
794
|
+
};
|
|
795
|
+
if (hasInverse) {
|
|
796
|
+
result.hasInverse = true;
|
|
797
|
+
}
|
|
798
|
+
if (includeMatches) {
|
|
799
|
+
result.indices = mergeIndices(allIndices);
|
|
800
|
+
}
|
|
801
|
+
return result;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return {
|
|
805
|
+
isMatch: false,
|
|
806
|
+
score: 1
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function register(...args) {
|
|
811
|
+
registeredSearchers.push(...args);
|
|
812
|
+
}
|
|
813
|
+
function createSearcher(pattern, options) {
|
|
814
|
+
for (let i = 0, len = registeredSearchers.length;i < len; i += 1) {
|
|
815
|
+
const searcherClass = registeredSearchers[i];
|
|
816
|
+
if (searcherClass.condition(pattern, options)) {
|
|
817
|
+
return new searcherClass(pattern, options);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return new BitapSearch(pattern, options);
|
|
821
|
+
}
|
|
822
|
+
function parse(query, options, {
|
|
823
|
+
auto = true
|
|
824
|
+
} = {}) {
|
|
825
|
+
const next = (query2) => {
|
|
826
|
+
if (isString(query2)) {
|
|
827
|
+
const obj = {
|
|
828
|
+
keyId: null,
|
|
829
|
+
pattern: query2
|
|
830
|
+
};
|
|
831
|
+
if (auto) {
|
|
832
|
+
obj.searcher = createSearcher(query2, options);
|
|
833
|
+
}
|
|
834
|
+
return obj;
|
|
835
|
+
}
|
|
836
|
+
const keys = Object.keys(query2);
|
|
837
|
+
const isQueryPath = isPath(query2);
|
|
838
|
+
if (!isQueryPath && keys.length > 1 && !isExpression(query2)) {
|
|
839
|
+
return next(convertToExplicit(query2));
|
|
840
|
+
}
|
|
841
|
+
if (isLeaf(query2)) {
|
|
842
|
+
const key = isQueryPath ? query2[KeyType.PATH] : keys[0];
|
|
843
|
+
const pattern = isQueryPath ? query2[KeyType.PATTERN] : query2[key];
|
|
844
|
+
if (!isString(pattern)) {
|
|
845
|
+
throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
|
|
846
|
+
}
|
|
847
|
+
const obj = {
|
|
848
|
+
keyId: createKeyId(key),
|
|
849
|
+
pattern
|
|
850
|
+
};
|
|
851
|
+
if (auto) {
|
|
852
|
+
obj.searcher = createSearcher(pattern, options);
|
|
853
|
+
}
|
|
854
|
+
return obj;
|
|
855
|
+
}
|
|
856
|
+
const node = {
|
|
857
|
+
children: [],
|
|
858
|
+
operator: keys[0]
|
|
859
|
+
};
|
|
860
|
+
keys.forEach((key) => {
|
|
861
|
+
const value = query2[key];
|
|
862
|
+
if (isArray(value)) {
|
|
863
|
+
value.forEach((item) => {
|
|
864
|
+
node.children.push(next(item));
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
return node;
|
|
869
|
+
};
|
|
870
|
+
if (!isExpression(query)) {
|
|
871
|
+
query = convertToExplicit(query);
|
|
872
|
+
}
|
|
873
|
+
return next(query);
|
|
874
|
+
}
|
|
875
|
+
function computeScoreSingle(matches, {
|
|
876
|
+
ignoreFieldNorm = Config.ignoreFieldNorm
|
|
877
|
+
}) {
|
|
878
|
+
let totalScore = 1;
|
|
879
|
+
matches.forEach(({
|
|
880
|
+
key,
|
|
881
|
+
norm: norm2,
|
|
882
|
+
score
|
|
883
|
+
}) => {
|
|
884
|
+
const weight = key ? key.weight : null;
|
|
885
|
+
totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm2));
|
|
886
|
+
});
|
|
887
|
+
return totalScore;
|
|
888
|
+
}
|
|
889
|
+
function computeScore(results, {
|
|
890
|
+
ignoreFieldNorm = Config.ignoreFieldNorm
|
|
891
|
+
}) {
|
|
892
|
+
results.forEach((result) => {
|
|
893
|
+
result.score = computeScoreSingle(result.matches, {
|
|
894
|
+
ignoreFieldNorm
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
class MaxHeap {
|
|
900
|
+
constructor(limit) {
|
|
901
|
+
this.limit = limit;
|
|
902
|
+
this.heap = [];
|
|
903
|
+
}
|
|
904
|
+
get size() {
|
|
905
|
+
return this.heap.length;
|
|
906
|
+
}
|
|
907
|
+
shouldInsert(score) {
|
|
908
|
+
return this.size < this.limit || score < this.heap[0].score;
|
|
909
|
+
}
|
|
910
|
+
insert(item) {
|
|
911
|
+
if (this.size < this.limit) {
|
|
912
|
+
this.heap.push(item);
|
|
913
|
+
this._bubbleUp(this.size - 1);
|
|
914
|
+
} else if (item.score < this.heap[0].score) {
|
|
915
|
+
this.heap[0] = item;
|
|
916
|
+
this._sinkDown(0);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
extractSorted(sortFn) {
|
|
920
|
+
return this.heap.sort(sortFn);
|
|
921
|
+
}
|
|
922
|
+
_bubbleUp(i) {
|
|
923
|
+
const heap = this.heap;
|
|
924
|
+
while (i > 0) {
|
|
925
|
+
const parent = i - 1 >> 1;
|
|
926
|
+
if (heap[i].score <= heap[parent].score)
|
|
927
|
+
break;
|
|
928
|
+
const tmp = heap[i];
|
|
929
|
+
heap[i] = heap[parent];
|
|
930
|
+
heap[parent] = tmp;
|
|
931
|
+
i = parent;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
_sinkDown(i) {
|
|
935
|
+
const heap = this.heap;
|
|
936
|
+
const len = heap.length;
|
|
937
|
+
let largest = i;
|
|
938
|
+
do {
|
|
939
|
+
i = largest;
|
|
940
|
+
const left = 2 * i + 1;
|
|
941
|
+
const right = 2 * i + 2;
|
|
942
|
+
if (left < len && heap[left].score > heap[largest].score) {
|
|
943
|
+
largest = left;
|
|
944
|
+
}
|
|
945
|
+
if (right < len && heap[right].score > heap[largest].score) {
|
|
946
|
+
largest = right;
|
|
947
|
+
}
|
|
948
|
+
if (largest !== i) {
|
|
949
|
+
const tmp = heap[i];
|
|
950
|
+
heap[i] = heap[largest];
|
|
951
|
+
heap[largest] = tmp;
|
|
952
|
+
}
|
|
953
|
+
} while (largest !== i);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
function transformMatches(result, data) {
|
|
957
|
+
const matches = result.matches;
|
|
958
|
+
data.matches = [];
|
|
959
|
+
if (!isDefined(matches)) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
matches.forEach((match) => {
|
|
963
|
+
if (!isDefined(match.indices) || !match.indices.length) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const {
|
|
967
|
+
indices,
|
|
968
|
+
value
|
|
969
|
+
} = match;
|
|
970
|
+
const obj = {
|
|
971
|
+
indices,
|
|
972
|
+
value
|
|
973
|
+
};
|
|
974
|
+
if (match.key) {
|
|
975
|
+
obj.key = match.key.src;
|
|
976
|
+
}
|
|
977
|
+
if (match.idx > -1) {
|
|
978
|
+
obj.refIndex = match.idx;
|
|
979
|
+
}
|
|
980
|
+
data.matches.push(obj);
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
function transformScore(result, data) {
|
|
984
|
+
data.score = result.score;
|
|
985
|
+
}
|
|
986
|
+
function format(results, docs, {
|
|
987
|
+
includeMatches = Config.includeMatches,
|
|
988
|
+
includeScore = Config.includeScore
|
|
989
|
+
} = {}) {
|
|
990
|
+
const transformers = [];
|
|
991
|
+
if (includeMatches)
|
|
992
|
+
transformers.push(transformMatches);
|
|
993
|
+
if (includeScore)
|
|
994
|
+
transformers.push(transformScore);
|
|
995
|
+
return results.map((result) => {
|
|
996
|
+
const {
|
|
997
|
+
idx
|
|
998
|
+
} = result;
|
|
999
|
+
const data = {
|
|
1000
|
+
item: docs[idx],
|
|
1001
|
+
refIndex: idx
|
|
1002
|
+
};
|
|
1003
|
+
if (transformers.length) {
|
|
1004
|
+
transformers.forEach((transformer) => {
|
|
1005
|
+
transformer(result, data);
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
return data;
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
function createAnalyzer({
|
|
1012
|
+
isCaseSensitive = false,
|
|
1013
|
+
ignoreDiacritics = false
|
|
1014
|
+
} = {}) {
|
|
1015
|
+
return {
|
|
1016
|
+
tokenize(text) {
|
|
1017
|
+
if (!isCaseSensitive) {
|
|
1018
|
+
text = text.toLowerCase();
|
|
1019
|
+
}
|
|
1020
|
+
if (ignoreDiacritics) {
|
|
1021
|
+
text = stripDiacritics(text);
|
|
1022
|
+
}
|
|
1023
|
+
return text.match(WORD) || [];
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function buildInvertedIndex(records, keyCount, analyzer) {
|
|
1028
|
+
const terms = new Map;
|
|
1029
|
+
const df = new Map;
|
|
1030
|
+
let fieldCount = 0;
|
|
1031
|
+
function addField(text, docIdx, keyIdx, subIdx) {
|
|
1032
|
+
const tokens = analyzer.tokenize(text);
|
|
1033
|
+
if (!tokens.length)
|
|
1034
|
+
return;
|
|
1035
|
+
fieldCount++;
|
|
1036
|
+
const termFreqs = new Map;
|
|
1037
|
+
for (const token of tokens) {
|
|
1038
|
+
termFreqs.set(token, (termFreqs.get(token) || 0) + 1);
|
|
1039
|
+
}
|
|
1040
|
+
for (const [term, tf] of termFreqs) {
|
|
1041
|
+
const posting = {
|
|
1042
|
+
docIdx,
|
|
1043
|
+
keyIdx,
|
|
1044
|
+
subIdx,
|
|
1045
|
+
tf
|
|
1046
|
+
};
|
|
1047
|
+
let postings = terms.get(term);
|
|
1048
|
+
if (!postings) {
|
|
1049
|
+
postings = [];
|
|
1050
|
+
terms.set(term, postings);
|
|
1051
|
+
}
|
|
1052
|
+
postings.push(posting);
|
|
1053
|
+
df.set(term, (df.get(term) || 0) + 1);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
for (const record of records) {
|
|
1057
|
+
const {
|
|
1058
|
+
i: docIdx,
|
|
1059
|
+
v,
|
|
1060
|
+
$: fields
|
|
1061
|
+
} = record;
|
|
1062
|
+
if (v !== undefined) {
|
|
1063
|
+
addField(v, docIdx, -1, -1);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
if (fields) {
|
|
1067
|
+
for (let keyIdx = 0;keyIdx < keyCount; keyIdx++) {
|
|
1068
|
+
const value = fields[keyIdx];
|
|
1069
|
+
if (!value)
|
|
1070
|
+
continue;
|
|
1071
|
+
if (Array.isArray(value)) {
|
|
1072
|
+
for (const sub of value) {
|
|
1073
|
+
addField(sub.v, docIdx, keyIdx, sub.i ?? -1);
|
|
1074
|
+
}
|
|
1075
|
+
} else {
|
|
1076
|
+
addField(value.v, docIdx, keyIdx, -1);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
terms,
|
|
1083
|
+
fieldCount,
|
|
1084
|
+
df
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function addToInvertedIndex(index, record, keyCount, analyzer) {
|
|
1088
|
+
const {
|
|
1089
|
+
i: docIdx,
|
|
1090
|
+
v,
|
|
1091
|
+
$: fields
|
|
1092
|
+
} = record;
|
|
1093
|
+
function addField(text, keyIdx, subIdx) {
|
|
1094
|
+
const tokens = analyzer.tokenize(text);
|
|
1095
|
+
if (!tokens.length)
|
|
1096
|
+
return;
|
|
1097
|
+
index.fieldCount++;
|
|
1098
|
+
const termFreqs = new Map;
|
|
1099
|
+
for (const token of tokens) {
|
|
1100
|
+
termFreqs.set(token, (termFreqs.get(token) || 0) + 1);
|
|
1101
|
+
}
|
|
1102
|
+
for (const [term, tf] of termFreqs) {
|
|
1103
|
+
const posting = {
|
|
1104
|
+
docIdx,
|
|
1105
|
+
keyIdx,
|
|
1106
|
+
subIdx,
|
|
1107
|
+
tf
|
|
1108
|
+
};
|
|
1109
|
+
let postings = index.terms.get(term);
|
|
1110
|
+
if (!postings) {
|
|
1111
|
+
postings = [];
|
|
1112
|
+
index.terms.set(term, postings);
|
|
1113
|
+
}
|
|
1114
|
+
postings.push(posting);
|
|
1115
|
+
index.df.set(term, (index.df.get(term) || 0) + 1);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
if (v !== undefined) {
|
|
1119
|
+
addField(v, -1, -1);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (fields) {
|
|
1123
|
+
for (let keyIdx = 0;keyIdx < keyCount; keyIdx++) {
|
|
1124
|
+
const value = fields[keyIdx];
|
|
1125
|
+
if (!value)
|
|
1126
|
+
continue;
|
|
1127
|
+
if (Array.isArray(value)) {
|
|
1128
|
+
for (const sub of value) {
|
|
1129
|
+
addField(sub.v, keyIdx, sub.i ?? -1);
|
|
1130
|
+
}
|
|
1131
|
+
} else {
|
|
1132
|
+
addField(value.v, keyIdx, -1);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function removeFromInvertedIndex(index, docIdx) {
|
|
1138
|
+
for (const [term, postings] of index.terms) {
|
|
1139
|
+
const filtered = postings.filter((p) => p.docIdx !== docIdx);
|
|
1140
|
+
const removed = postings.length - filtered.length;
|
|
1141
|
+
if (removed > 0) {
|
|
1142
|
+
index.fieldCount -= removed;
|
|
1143
|
+
index.df.set(term, (index.df.get(term) || 0) - removed);
|
|
1144
|
+
if (filtered.length === 0) {
|
|
1145
|
+
index.terms.delete(term);
|
|
1146
|
+
index.df.delete(term);
|
|
1147
|
+
} else {
|
|
1148
|
+
index.terms.set(term, filtered);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
class Fuse {
|
|
1155
|
+
constructor(docs, options, index) {
|
|
1156
|
+
this.options = {
|
|
1157
|
+
...Config,
|
|
1158
|
+
...options
|
|
1159
|
+
};
|
|
1160
|
+
if (this.options.useExtendedSearch && false)
|
|
1161
|
+
;
|
|
1162
|
+
if (this.options.useTokenSearch && false)
|
|
1163
|
+
;
|
|
1164
|
+
this._keyStore = new KeyStore(this.options.keys);
|
|
1165
|
+
this._docs = docs;
|
|
1166
|
+
this._myIndex = null;
|
|
1167
|
+
this._invertedIndex = null;
|
|
1168
|
+
this.setCollection(docs, index);
|
|
1169
|
+
this._lastQuery = null;
|
|
1170
|
+
this._lastSearcher = null;
|
|
1171
|
+
}
|
|
1172
|
+
_getSearcher(query) {
|
|
1173
|
+
if (this._lastQuery === query) {
|
|
1174
|
+
return this._lastSearcher;
|
|
1175
|
+
}
|
|
1176
|
+
const opts = this._invertedIndex ? {
|
|
1177
|
+
...this.options,
|
|
1178
|
+
_invertedIndex: this._invertedIndex
|
|
1179
|
+
} : this.options;
|
|
1180
|
+
const searcher = createSearcher(query, opts);
|
|
1181
|
+
this._lastQuery = query;
|
|
1182
|
+
this._lastSearcher = searcher;
|
|
1183
|
+
return searcher;
|
|
1184
|
+
}
|
|
1185
|
+
setCollection(docs, index) {
|
|
1186
|
+
this._docs = docs;
|
|
1187
|
+
if (index && !(index instanceof FuseIndex)) {
|
|
1188
|
+
throw new Error(INCORRECT_INDEX_TYPE);
|
|
1189
|
+
}
|
|
1190
|
+
this._myIndex = index || createIndex(this.options.keys, this._docs, {
|
|
1191
|
+
getFn: this.options.getFn,
|
|
1192
|
+
fieldNormWeight: this.options.fieldNormWeight
|
|
1193
|
+
});
|
|
1194
|
+
if (this.options.useTokenSearch) {
|
|
1195
|
+
const analyzer = createAnalyzer({
|
|
1196
|
+
isCaseSensitive: this.options.isCaseSensitive,
|
|
1197
|
+
ignoreDiacritics: this.options.ignoreDiacritics
|
|
1198
|
+
});
|
|
1199
|
+
this._invertedIndex = buildInvertedIndex(this._myIndex.records, this._myIndex.keys.length, analyzer);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
add(doc) {
|
|
1203
|
+
if (!isDefined(doc)) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
this._docs.push(doc);
|
|
1207
|
+
this._myIndex.add(doc);
|
|
1208
|
+
if (this._invertedIndex) {
|
|
1209
|
+
const record = this._myIndex.records[this._myIndex.records.length - 1];
|
|
1210
|
+
const analyzer = createAnalyzer({
|
|
1211
|
+
isCaseSensitive: this.options.isCaseSensitive,
|
|
1212
|
+
ignoreDiacritics: this.options.ignoreDiacritics
|
|
1213
|
+
});
|
|
1214
|
+
addToInvertedIndex(this._invertedIndex, record, this._myIndex.keys.length, analyzer);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
remove(predicate = () => false) {
|
|
1218
|
+
const results = [];
|
|
1219
|
+
const indicesToRemove = [];
|
|
1220
|
+
for (let i = 0, len = this._docs.length;i < len; i += 1) {
|
|
1221
|
+
if (predicate(this._docs[i], i)) {
|
|
1222
|
+
results.push(this._docs[i]);
|
|
1223
|
+
indicesToRemove.push(i);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
if (indicesToRemove.length) {
|
|
1227
|
+
if (this._invertedIndex) {
|
|
1228
|
+
for (const idx of indicesToRemove) {
|
|
1229
|
+
removeFromInvertedIndex(this._invertedIndex, idx);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
for (let i = indicesToRemove.length - 1;i >= 0; i -= 1) {
|
|
1233
|
+
this._docs.splice(indicesToRemove[i], 1);
|
|
1234
|
+
}
|
|
1235
|
+
this._myIndex.removeAll(indicesToRemove);
|
|
1236
|
+
}
|
|
1237
|
+
return results;
|
|
1238
|
+
}
|
|
1239
|
+
removeAt(idx) {
|
|
1240
|
+
if (this._invertedIndex) {
|
|
1241
|
+
removeFromInvertedIndex(this._invertedIndex, idx);
|
|
1242
|
+
}
|
|
1243
|
+
const doc = this._docs.splice(idx, 1)[0];
|
|
1244
|
+
this._myIndex.removeAt(idx);
|
|
1245
|
+
return doc;
|
|
1246
|
+
}
|
|
1247
|
+
getIndex() {
|
|
1248
|
+
return this._myIndex;
|
|
1249
|
+
}
|
|
1250
|
+
search(query, options) {
|
|
1251
|
+
const {
|
|
1252
|
+
limit = -1
|
|
1253
|
+
} = options || {};
|
|
1254
|
+
const {
|
|
1255
|
+
includeMatches,
|
|
1256
|
+
includeScore,
|
|
1257
|
+
shouldSort,
|
|
1258
|
+
sortFn,
|
|
1259
|
+
ignoreFieldNorm
|
|
1260
|
+
} = this.options;
|
|
1261
|
+
if (isString(query) && !query.trim()) {
|
|
1262
|
+
let docs = this._docs.map((item, idx) => ({
|
|
1263
|
+
item,
|
|
1264
|
+
refIndex: idx
|
|
1265
|
+
}));
|
|
1266
|
+
if (isNumber(limit) && limit > -1) {
|
|
1267
|
+
docs = docs.slice(0, limit);
|
|
1268
|
+
}
|
|
1269
|
+
return docs;
|
|
1270
|
+
}
|
|
1271
|
+
const useHeap = isNumber(limit) && limit > 0 && isString(query);
|
|
1272
|
+
let results;
|
|
1273
|
+
if (useHeap) {
|
|
1274
|
+
const heap = new MaxHeap(limit);
|
|
1275
|
+
if (isString(this._docs[0])) {
|
|
1276
|
+
this._searchStringList(query, {
|
|
1277
|
+
heap,
|
|
1278
|
+
ignoreFieldNorm
|
|
1279
|
+
});
|
|
1280
|
+
} else {
|
|
1281
|
+
this._searchObjectList(query, {
|
|
1282
|
+
heap,
|
|
1283
|
+
ignoreFieldNorm
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
results = heap.extractSorted(sortFn);
|
|
1287
|
+
} else {
|
|
1288
|
+
results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
|
|
1289
|
+
computeScore(results, {
|
|
1290
|
+
ignoreFieldNorm
|
|
1291
|
+
});
|
|
1292
|
+
if (shouldSort) {
|
|
1293
|
+
results.sort(sortFn);
|
|
1294
|
+
}
|
|
1295
|
+
if (isNumber(limit) && limit > -1) {
|
|
1296
|
+
results = results.slice(0, limit);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
return format(results, this._docs, {
|
|
1300
|
+
includeMatches,
|
|
1301
|
+
includeScore
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
_searchStringList(query, {
|
|
1305
|
+
heap,
|
|
1306
|
+
ignoreFieldNorm
|
|
1307
|
+
} = {}) {
|
|
1308
|
+
const searcher = this._getSearcher(query);
|
|
1309
|
+
const {
|
|
1310
|
+
records
|
|
1311
|
+
} = this._myIndex;
|
|
1312
|
+
const results = heap ? null : [];
|
|
1313
|
+
records.forEach(({
|
|
1314
|
+
v: text,
|
|
1315
|
+
i: idx,
|
|
1316
|
+
n: norm2
|
|
1317
|
+
}) => {
|
|
1318
|
+
if (!isDefined(text)) {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
const {
|
|
1322
|
+
isMatch,
|
|
1323
|
+
score,
|
|
1324
|
+
indices
|
|
1325
|
+
} = searcher.searchIn(text);
|
|
1326
|
+
if (isMatch) {
|
|
1327
|
+
const result = {
|
|
1328
|
+
item: text,
|
|
1329
|
+
idx,
|
|
1330
|
+
matches: [{
|
|
1331
|
+
score,
|
|
1332
|
+
value: text,
|
|
1333
|
+
norm: norm2,
|
|
1334
|
+
indices
|
|
1335
|
+
}]
|
|
1336
|
+
};
|
|
1337
|
+
if (heap) {
|
|
1338
|
+
result.score = computeScoreSingle(result.matches, {
|
|
1339
|
+
ignoreFieldNorm
|
|
1340
|
+
});
|
|
1341
|
+
if (heap.shouldInsert(result.score)) {
|
|
1342
|
+
heap.insert(result);
|
|
1343
|
+
}
|
|
1344
|
+
} else {
|
|
1345
|
+
results.push(result);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1349
|
+
return results;
|
|
1350
|
+
}
|
|
1351
|
+
_searchLogical(query) {
|
|
1352
|
+
const expression = parse(query, this.options);
|
|
1353
|
+
const evaluate = (node, item, idx) => {
|
|
1354
|
+
if (!("children" in node)) {
|
|
1355
|
+
const {
|
|
1356
|
+
keyId,
|
|
1357
|
+
searcher
|
|
1358
|
+
} = node;
|
|
1359
|
+
let matches;
|
|
1360
|
+
if (keyId === null) {
|
|
1361
|
+
matches = [];
|
|
1362
|
+
this._myIndex.keys.forEach((key, keyIndex) => {
|
|
1363
|
+
matches.push(...this._findMatches({
|
|
1364
|
+
key,
|
|
1365
|
+
value: item[keyIndex],
|
|
1366
|
+
searcher
|
|
1367
|
+
}));
|
|
1368
|
+
});
|
|
1369
|
+
} else {
|
|
1370
|
+
matches = this._findMatches({
|
|
1371
|
+
key: this._keyStore.get(keyId),
|
|
1372
|
+
value: this._myIndex.getValueForItemAtKeyId(item, keyId),
|
|
1373
|
+
searcher
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
if (matches && matches.length) {
|
|
1377
|
+
return [{
|
|
1378
|
+
idx,
|
|
1379
|
+
item,
|
|
1380
|
+
matches
|
|
1381
|
+
}];
|
|
1382
|
+
}
|
|
1383
|
+
return [];
|
|
1384
|
+
}
|
|
1385
|
+
const {
|
|
1386
|
+
children,
|
|
1387
|
+
operator
|
|
1388
|
+
} = node;
|
|
1389
|
+
const res = [];
|
|
1390
|
+
for (let i = 0, len = children.length;i < len; i += 1) {
|
|
1391
|
+
const child = children[i];
|
|
1392
|
+
const result = evaluate(child, item, idx);
|
|
1393
|
+
if (result.length) {
|
|
1394
|
+
res.push(...result);
|
|
1395
|
+
} else if (operator === LogicalOperator.AND) {
|
|
1396
|
+
return [];
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return res;
|
|
1400
|
+
};
|
|
1401
|
+
const records = this._myIndex.records;
|
|
1402
|
+
const resultMap = new Map;
|
|
1403
|
+
const results = [];
|
|
1404
|
+
records.forEach(({
|
|
1405
|
+
$: item,
|
|
1406
|
+
i: idx
|
|
1407
|
+
}) => {
|
|
1408
|
+
if (isDefined(item)) {
|
|
1409
|
+
const expResults = evaluate(expression, item, idx);
|
|
1410
|
+
if (expResults.length) {
|
|
1411
|
+
if (!resultMap.has(idx)) {
|
|
1412
|
+
resultMap.set(idx, {
|
|
1413
|
+
idx,
|
|
1414
|
+
item,
|
|
1415
|
+
matches: []
|
|
1416
|
+
});
|
|
1417
|
+
results.push(resultMap.get(idx));
|
|
1418
|
+
}
|
|
1419
|
+
expResults.forEach(({
|
|
1420
|
+
matches
|
|
1421
|
+
}) => {
|
|
1422
|
+
resultMap.get(idx).matches.push(...matches);
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
return results;
|
|
1428
|
+
}
|
|
1429
|
+
_searchObjectList(query, {
|
|
1430
|
+
heap,
|
|
1431
|
+
ignoreFieldNorm
|
|
1432
|
+
} = {}) {
|
|
1433
|
+
const searcher = this._getSearcher(query);
|
|
1434
|
+
const {
|
|
1435
|
+
keys,
|
|
1436
|
+
records
|
|
1437
|
+
} = this._myIndex;
|
|
1438
|
+
const results = heap ? null : [];
|
|
1439
|
+
records.forEach(({
|
|
1440
|
+
$: item,
|
|
1441
|
+
i: idx
|
|
1442
|
+
}) => {
|
|
1443
|
+
if (!isDefined(item)) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
const matches = [];
|
|
1447
|
+
let anyKeyFailed = false;
|
|
1448
|
+
let hasInverse = false;
|
|
1449
|
+
keys.forEach((key, keyIndex) => {
|
|
1450
|
+
const keyMatches = this._findMatches({
|
|
1451
|
+
key,
|
|
1452
|
+
value: item[keyIndex],
|
|
1453
|
+
searcher
|
|
1454
|
+
});
|
|
1455
|
+
if (keyMatches.length) {
|
|
1456
|
+
matches.push(...keyMatches);
|
|
1457
|
+
if (keyMatches[0].hasInverse) {
|
|
1458
|
+
hasInverse = true;
|
|
1459
|
+
}
|
|
1460
|
+
} else {
|
|
1461
|
+
anyKeyFailed = true;
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
if (hasInverse && anyKeyFailed) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
if (matches.length) {
|
|
1468
|
+
const result = {
|
|
1469
|
+
idx,
|
|
1470
|
+
item,
|
|
1471
|
+
matches
|
|
1472
|
+
};
|
|
1473
|
+
if (heap) {
|
|
1474
|
+
result.score = computeScoreSingle(result.matches, {
|
|
1475
|
+
ignoreFieldNorm
|
|
1476
|
+
});
|
|
1477
|
+
if (heap.shouldInsert(result.score)) {
|
|
1478
|
+
heap.insert(result);
|
|
1479
|
+
}
|
|
1480
|
+
} else {
|
|
1481
|
+
results.push(result);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
return results;
|
|
1486
|
+
}
|
|
1487
|
+
_findMatches({
|
|
1488
|
+
key,
|
|
1489
|
+
value,
|
|
1490
|
+
searcher
|
|
1491
|
+
}) {
|
|
1492
|
+
if (!isDefined(value)) {
|
|
1493
|
+
return [];
|
|
1494
|
+
}
|
|
1495
|
+
const matches = [];
|
|
1496
|
+
if (isArray(value)) {
|
|
1497
|
+
value.forEach(({
|
|
1498
|
+
v: text,
|
|
1499
|
+
i: idx,
|
|
1500
|
+
n: norm2
|
|
1501
|
+
}) => {
|
|
1502
|
+
if (!isDefined(text)) {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
const {
|
|
1506
|
+
isMatch,
|
|
1507
|
+
score,
|
|
1508
|
+
indices,
|
|
1509
|
+
hasInverse
|
|
1510
|
+
} = searcher.searchIn(text);
|
|
1511
|
+
if (isMatch) {
|
|
1512
|
+
matches.push({
|
|
1513
|
+
score,
|
|
1514
|
+
key,
|
|
1515
|
+
value: text,
|
|
1516
|
+
idx,
|
|
1517
|
+
norm: norm2,
|
|
1518
|
+
indices,
|
|
1519
|
+
hasInverse
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1523
|
+
} else {
|
|
1524
|
+
const {
|
|
1525
|
+
v: text,
|
|
1526
|
+
n: norm2
|
|
1527
|
+
} = value;
|
|
1528
|
+
const {
|
|
1529
|
+
isMatch,
|
|
1530
|
+
score,
|
|
1531
|
+
indices,
|
|
1532
|
+
hasInverse
|
|
1533
|
+
} = searcher.searchIn(text);
|
|
1534
|
+
if (isMatch) {
|
|
1535
|
+
matches.push({
|
|
1536
|
+
score,
|
|
1537
|
+
key,
|
|
1538
|
+
value: text,
|
|
1539
|
+
norm: norm2,
|
|
1540
|
+
indices,
|
|
1541
|
+
hasInverse
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return matches;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
class TokenSearch {
|
|
1550
|
+
static condition(_, options) {
|
|
1551
|
+
return options.useTokenSearch;
|
|
1552
|
+
}
|
|
1553
|
+
constructor(pattern, options) {
|
|
1554
|
+
this.options = options;
|
|
1555
|
+
this.analyzer = createAnalyzer({
|
|
1556
|
+
isCaseSensitive: options.isCaseSensitive,
|
|
1557
|
+
ignoreDiacritics: options.ignoreDiacritics
|
|
1558
|
+
});
|
|
1559
|
+
const queryTerms = this.analyzer.tokenize(pattern);
|
|
1560
|
+
const invertedIndex = options._invertedIndex;
|
|
1561
|
+
const {
|
|
1562
|
+
df,
|
|
1563
|
+
fieldCount
|
|
1564
|
+
} = invertedIndex;
|
|
1565
|
+
this.termSearchers = [];
|
|
1566
|
+
this.idfWeights = [];
|
|
1567
|
+
for (const term of queryTerms) {
|
|
1568
|
+
this.termSearchers.push(new BitapSearch(term, {
|
|
1569
|
+
location: options.location,
|
|
1570
|
+
threshold: options.threshold,
|
|
1571
|
+
distance: options.distance,
|
|
1572
|
+
includeMatches: options.includeMatches,
|
|
1573
|
+
findAllMatches: options.findAllMatches,
|
|
1574
|
+
minMatchCharLength: options.minMatchCharLength,
|
|
1575
|
+
isCaseSensitive: options.isCaseSensitive,
|
|
1576
|
+
ignoreDiacritics: options.ignoreDiacritics,
|
|
1577
|
+
ignoreLocation: true
|
|
1578
|
+
}));
|
|
1579
|
+
const docFreq = df.get(term) || 0;
|
|
1580
|
+
const idf = Math.log(1 + (fieldCount - docFreq + 0.5) / (docFreq + 0.5));
|
|
1581
|
+
this.idfWeights.push(idf);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
searchIn(text) {
|
|
1585
|
+
if (!this.termSearchers.length) {
|
|
1586
|
+
return {
|
|
1587
|
+
isMatch: false,
|
|
1588
|
+
score: 1
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
const allIndices = [];
|
|
1592
|
+
let weightedScore = 0;
|
|
1593
|
+
let maxPossibleScore = 0;
|
|
1594
|
+
let matchedCount = 0;
|
|
1595
|
+
for (let i = 0;i < this.termSearchers.length; i++) {
|
|
1596
|
+
const result = this.termSearchers[i].searchIn(text);
|
|
1597
|
+
const idf = this.idfWeights[i];
|
|
1598
|
+
maxPossibleScore += idf;
|
|
1599
|
+
if (result.isMatch) {
|
|
1600
|
+
matchedCount++;
|
|
1601
|
+
weightedScore += idf * (1 - result.score);
|
|
1602
|
+
if (result.indices) {
|
|
1603
|
+
allIndices.push(...result.indices);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (matchedCount === 0) {
|
|
1608
|
+
return {
|
|
1609
|
+
isMatch: false,
|
|
1610
|
+
score: 1
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
const normalized = maxPossibleScore > 0 ? 1 - weightedScore / maxPossibleScore : 0;
|
|
1614
|
+
const searchResult = {
|
|
1615
|
+
isMatch: true,
|
|
1616
|
+
score: Math.max(0.001, normalized)
|
|
1617
|
+
};
|
|
1618
|
+
if (this.options.includeMatches && allIndices.length) {
|
|
1619
|
+
searchResult.indices = mergeIndices(allIndices);
|
|
1620
|
+
}
|
|
1621
|
+
return searchResult;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
var INCORRECT_INDEX_TYPE = "Incorrect 'index' type", LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`, PATTERN_LENGTH_TOO_LARGE = (max) => `Pattern length exceeds max of ${max}.`, MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`, INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`, hasOwn, MatchOptions, BasicOptions, FuzzyOptions, AdvancedOptions, Config, SPACE, MAX_BITS = 32, NON_DECOMPOSABLE_MAP, NON_DECOMPOSABLE_RE, stripDiacritics, ExactMatch, InverseExactMatch, PrefixExactMatch, InversePrefixExactMatch, SuffixExactMatch, InverseSuffixExactMatch, FuzzyMatch, IncludeMatch, searchers, searchersLen, ESCAPED_PIPE = "\x00", OR_TOKEN = "|", MultiMatchSet, registeredSearchers, LogicalOperator, KeyType, isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]), isPath = (query) => !!query[KeyType.PATH], isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query), convertToExplicit = (query) => ({
|
|
1625
|
+
[LogicalOperator.AND]: Object.keys(query).map((key) => ({
|
|
1626
|
+
[key]: query[key]
|
|
1627
|
+
}))
|
|
1628
|
+
}), WORD;
|
|
1629
|
+
var init_fuse = __esm(() => {
|
|
1630
|
+
hasOwn = Object.prototype.hasOwnProperty;
|
|
1631
|
+
MatchOptions = {
|
|
1632
|
+
includeMatches: false,
|
|
1633
|
+
findAllMatches: false,
|
|
1634
|
+
minMatchCharLength: 1
|
|
1635
|
+
};
|
|
1636
|
+
BasicOptions = {
|
|
1637
|
+
isCaseSensitive: false,
|
|
1638
|
+
ignoreDiacritics: false,
|
|
1639
|
+
includeScore: false,
|
|
1640
|
+
keys: [],
|
|
1641
|
+
shouldSort: true,
|
|
1642
|
+
sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
|
|
1643
|
+
};
|
|
1644
|
+
FuzzyOptions = {
|
|
1645
|
+
location: 0,
|
|
1646
|
+
threshold: 0.6,
|
|
1647
|
+
distance: 100
|
|
1648
|
+
};
|
|
1649
|
+
AdvancedOptions = {
|
|
1650
|
+
useExtendedSearch: false,
|
|
1651
|
+
useTokenSearch: false,
|
|
1652
|
+
getFn: get,
|
|
1653
|
+
ignoreLocation: false,
|
|
1654
|
+
ignoreFieldNorm: false,
|
|
1655
|
+
fieldNormWeight: 1
|
|
1656
|
+
};
|
|
1657
|
+
Config = Object.freeze({
|
|
1658
|
+
...BasicOptions,
|
|
1659
|
+
...MatchOptions,
|
|
1660
|
+
...FuzzyOptions,
|
|
1661
|
+
...AdvancedOptions
|
|
1662
|
+
});
|
|
1663
|
+
SPACE = /[^ ]+/g;
|
|
1664
|
+
NON_DECOMPOSABLE_MAP = {
|
|
1665
|
+
"\u0142": "l",
|
|
1666
|
+
"\u0141": "L",
|
|
1667
|
+
"\u0111": "d",
|
|
1668
|
+
"\u0110": "D",
|
|
1669
|
+
"\xF8": "o",
|
|
1670
|
+
"\xD8": "O",
|
|
1671
|
+
"\u0127": "h",
|
|
1672
|
+
"\u0126": "H",
|
|
1673
|
+
"\u0167": "t",
|
|
1674
|
+
"\u0166": "T",
|
|
1675
|
+
"\u0131": "i",
|
|
1676
|
+
"\xDF": "ss"
|
|
1677
|
+
};
|
|
1678
|
+
NON_DECOMPOSABLE_RE = new RegExp("[" + Object.keys(NON_DECOMPOSABLE_MAP).join("") + "]", "g");
|
|
1679
|
+
stripDiacritics = String.prototype.normalize ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "").replace(NON_DECOMPOSABLE_RE, (ch) => NON_DECOMPOSABLE_MAP[ch]) : (str) => str;
|
|
1680
|
+
ExactMatch = class ExactMatch extends BaseMatch {
|
|
1681
|
+
constructor(pattern) {
|
|
1682
|
+
super(pattern);
|
|
1683
|
+
}
|
|
1684
|
+
static get type() {
|
|
1685
|
+
return "exact";
|
|
1686
|
+
}
|
|
1687
|
+
static get multiRegex() {
|
|
1688
|
+
return /^="(.*)"$/;
|
|
1689
|
+
}
|
|
1690
|
+
static get singleRegex() {
|
|
1691
|
+
return /^=(.*)$/;
|
|
1692
|
+
}
|
|
1693
|
+
search(text) {
|
|
1694
|
+
const isMatch = text === this.pattern;
|
|
1695
|
+
return {
|
|
1696
|
+
isMatch,
|
|
1697
|
+
score: isMatch ? 0 : 1,
|
|
1698
|
+
indices: [0, this.pattern.length - 1]
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
InverseExactMatch = class InverseExactMatch extends BaseMatch {
|
|
1703
|
+
constructor(pattern) {
|
|
1704
|
+
super(pattern);
|
|
1705
|
+
}
|
|
1706
|
+
static get type() {
|
|
1707
|
+
return "inverse-exact";
|
|
1708
|
+
}
|
|
1709
|
+
static get multiRegex() {
|
|
1710
|
+
return /^!"(.*)"$/;
|
|
1711
|
+
}
|
|
1712
|
+
static get singleRegex() {
|
|
1713
|
+
return /^!(.*)$/;
|
|
1714
|
+
}
|
|
1715
|
+
search(text) {
|
|
1716
|
+
const index = text.indexOf(this.pattern);
|
|
1717
|
+
const isMatch = index === -1;
|
|
1718
|
+
return {
|
|
1719
|
+
isMatch,
|
|
1720
|
+
score: isMatch ? 0 : 1,
|
|
1721
|
+
indices: [0, text.length - 1]
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
PrefixExactMatch = class PrefixExactMatch extends BaseMatch {
|
|
1726
|
+
constructor(pattern) {
|
|
1727
|
+
super(pattern);
|
|
1728
|
+
}
|
|
1729
|
+
static get type() {
|
|
1730
|
+
return "prefix-exact";
|
|
1731
|
+
}
|
|
1732
|
+
static get multiRegex() {
|
|
1733
|
+
return /^\^"(.*)"$/;
|
|
1734
|
+
}
|
|
1735
|
+
static get singleRegex() {
|
|
1736
|
+
return /^\^(.*)$/;
|
|
1737
|
+
}
|
|
1738
|
+
search(text) {
|
|
1739
|
+
const isMatch = text.startsWith(this.pattern);
|
|
1740
|
+
return {
|
|
1741
|
+
isMatch,
|
|
1742
|
+
score: isMatch ? 0 : 1,
|
|
1743
|
+
indices: [0, this.pattern.length - 1]
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
InversePrefixExactMatch = class InversePrefixExactMatch extends BaseMatch {
|
|
1748
|
+
constructor(pattern) {
|
|
1749
|
+
super(pattern);
|
|
1750
|
+
}
|
|
1751
|
+
static get type() {
|
|
1752
|
+
return "inverse-prefix-exact";
|
|
1753
|
+
}
|
|
1754
|
+
static get multiRegex() {
|
|
1755
|
+
return /^!\^"(.*)"$/;
|
|
1756
|
+
}
|
|
1757
|
+
static get singleRegex() {
|
|
1758
|
+
return /^!\^(.*)$/;
|
|
1759
|
+
}
|
|
1760
|
+
search(text) {
|
|
1761
|
+
const isMatch = !text.startsWith(this.pattern);
|
|
1762
|
+
return {
|
|
1763
|
+
isMatch,
|
|
1764
|
+
score: isMatch ? 0 : 1,
|
|
1765
|
+
indices: [0, text.length - 1]
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
SuffixExactMatch = class SuffixExactMatch extends BaseMatch {
|
|
1770
|
+
constructor(pattern) {
|
|
1771
|
+
super(pattern);
|
|
1772
|
+
}
|
|
1773
|
+
static get type() {
|
|
1774
|
+
return "suffix-exact";
|
|
1775
|
+
}
|
|
1776
|
+
static get multiRegex() {
|
|
1777
|
+
return /^"(.*)"\$$/;
|
|
1778
|
+
}
|
|
1779
|
+
static get singleRegex() {
|
|
1780
|
+
return /^(.*)\$$/;
|
|
1781
|
+
}
|
|
1782
|
+
search(text) {
|
|
1783
|
+
const isMatch = text.endsWith(this.pattern);
|
|
1784
|
+
return {
|
|
1785
|
+
isMatch,
|
|
1786
|
+
score: isMatch ? 0 : 1,
|
|
1787
|
+
indices: [text.length - this.pattern.length, text.length - 1]
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
InverseSuffixExactMatch = class InverseSuffixExactMatch extends BaseMatch {
|
|
1792
|
+
constructor(pattern) {
|
|
1793
|
+
super(pattern);
|
|
1794
|
+
}
|
|
1795
|
+
static get type() {
|
|
1796
|
+
return "inverse-suffix-exact";
|
|
1797
|
+
}
|
|
1798
|
+
static get multiRegex() {
|
|
1799
|
+
return /^!"(.*)"\$$/;
|
|
1800
|
+
}
|
|
1801
|
+
static get singleRegex() {
|
|
1802
|
+
return /^!(.*)\$$/;
|
|
1803
|
+
}
|
|
1804
|
+
search(text) {
|
|
1805
|
+
const isMatch = !text.endsWith(this.pattern);
|
|
1806
|
+
return {
|
|
1807
|
+
isMatch,
|
|
1808
|
+
score: isMatch ? 0 : 1,
|
|
1809
|
+
indices: [0, text.length - 1]
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
FuzzyMatch = class FuzzyMatch extends BaseMatch {
|
|
1814
|
+
constructor(pattern, {
|
|
1815
|
+
location = Config.location,
|
|
1816
|
+
threshold = Config.threshold,
|
|
1817
|
+
distance = Config.distance,
|
|
1818
|
+
includeMatches = Config.includeMatches,
|
|
1819
|
+
findAllMatches = Config.findAllMatches,
|
|
1820
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1821
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1822
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
1823
|
+
ignoreLocation = Config.ignoreLocation
|
|
1824
|
+
} = {}) {
|
|
1825
|
+
super(pattern);
|
|
1826
|
+
this._bitapSearch = new BitapSearch(pattern, {
|
|
1827
|
+
location,
|
|
1828
|
+
threshold,
|
|
1829
|
+
distance,
|
|
1830
|
+
includeMatches,
|
|
1831
|
+
findAllMatches,
|
|
1832
|
+
minMatchCharLength,
|
|
1833
|
+
isCaseSensitive,
|
|
1834
|
+
ignoreDiacritics,
|
|
1835
|
+
ignoreLocation
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
static get type() {
|
|
1839
|
+
return "fuzzy";
|
|
1840
|
+
}
|
|
1841
|
+
static get multiRegex() {
|
|
1842
|
+
return /^"(.*)"$/;
|
|
1843
|
+
}
|
|
1844
|
+
static get singleRegex() {
|
|
1845
|
+
return /^(.*)$/;
|
|
1846
|
+
}
|
|
1847
|
+
search(text) {
|
|
1848
|
+
return this._bitapSearch.searchIn(text);
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
IncludeMatch = class IncludeMatch extends BaseMatch {
|
|
1852
|
+
constructor(pattern) {
|
|
1853
|
+
super(pattern);
|
|
1854
|
+
}
|
|
1855
|
+
static get type() {
|
|
1856
|
+
return "include";
|
|
1857
|
+
}
|
|
1858
|
+
static get multiRegex() {
|
|
1859
|
+
return /^'"(.*)"$/;
|
|
1860
|
+
}
|
|
1861
|
+
static get singleRegex() {
|
|
1862
|
+
return /^'(.*)$/;
|
|
1863
|
+
}
|
|
1864
|
+
search(text) {
|
|
1865
|
+
let location = 0;
|
|
1866
|
+
let index;
|
|
1867
|
+
const indices = [];
|
|
1868
|
+
const patternLen = this.pattern.length;
|
|
1869
|
+
while ((index = text.indexOf(this.pattern, location)) > -1) {
|
|
1870
|
+
location = index + patternLen;
|
|
1871
|
+
indices.push([index, location - 1]);
|
|
1872
|
+
}
|
|
1873
|
+
const isMatch = !!indices.length;
|
|
1874
|
+
return {
|
|
1875
|
+
isMatch,
|
|
1876
|
+
score: isMatch ? 0 : 1,
|
|
1877
|
+
indices
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
searchers = [ExactMatch, IncludeMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch];
|
|
1882
|
+
searchersLen = searchers.length;
|
|
1883
|
+
MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
|
|
1884
|
+
registeredSearchers = [];
|
|
1885
|
+
LogicalOperator = {
|
|
1886
|
+
AND: "$and",
|
|
1887
|
+
OR: "$or"
|
|
1888
|
+
};
|
|
1889
|
+
KeyType = {
|
|
1890
|
+
PATH: "$path",
|
|
1891
|
+
PATTERN: "$val"
|
|
1892
|
+
};
|
|
1893
|
+
WORD = /\b\w+\b/g;
|
|
1894
|
+
Fuse.version = "7.3.0";
|
|
1895
|
+
Fuse.createIndex = createIndex;
|
|
1896
|
+
Fuse.parseIndex = parseIndex;
|
|
1897
|
+
Fuse.config = Config;
|
|
1898
|
+
Fuse.match = function(pattern, text, options) {
|
|
1899
|
+
const searcher = createSearcher(pattern, {
|
|
1900
|
+
...Config,
|
|
1901
|
+
...options
|
|
1902
|
+
});
|
|
1903
|
+
return searcher.searchIn(text);
|
|
1904
|
+
};
|
|
1905
|
+
{
|
|
1906
|
+
Fuse.parseQuery = parse;
|
|
1907
|
+
}
|
|
1908
|
+
{
|
|
1909
|
+
register(ExtendedSearch);
|
|
1910
|
+
}
|
|
1911
|
+
{
|
|
1912
|
+
register(TokenSearch);
|
|
1913
|
+
}
|
|
1914
|
+
Fuse.use = function(...plugins) {
|
|
1915
|
+
plugins.forEach((plugin) => register(plugin));
|
|
1916
|
+
};
|
|
1917
|
+
});
|
|
1918
|
+
|
|
1919
|
+
export { Fuse, init_fuse };
|