@delali/narsil 0.3.1-next.98 → 0.4.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/NOTICE +45 -0
- package/README.md +27 -8
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +101 -13
- package/dist/adapters/gcs.d.ts +49 -0
- package/dist/adapters/gcs.mjs +213 -0
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +2 -7
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/adapters/memory.mjs +5 -0
- package/dist/adapters/s3.d.ts +53 -0
- package/dist/adapters/s3.mjs +263 -0
- package/dist/{adapters-BQFQ4PRz.d.ts → adapters-pljAqmrC.d.ts} +33 -0
- package/dist/browser/chunk-4E5APHTM.mjs +1459 -0
- package/dist/browser/chunk-NDYADQ4Y.mjs +23426 -0
- package/dist/browser/chunk-QAOVAYAG.mjs +564 -0
- package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
- package/dist/browser/chunk-YINZFPLT.mjs +1239 -0
- package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
- package/dist/browser/{chunk-Z7QH2XHB.mjs → core-leaf-HWAXCEWX.mjs} +3987 -2103
- package/dist/browser/custom-token-results-R5BIX7SL.mjs +59 -0
- package/dist/browser/digest-leaf-64IPRPZD.mjs +151 -0
- package/dist/browser/durability-config-75NSFCQN.mjs +97 -0
- package/dist/browser/embed-GG6PS3EA.mjs +264 -0
- package/dist/browser/geo-index-GNHY4PUB.mjs +1484 -0
- package/dist/browser/gzip-JF3S6PPT.mjs +31 -0
- package/dist/browser/module-ZZTNG5JZ.mjs +5762 -0
- package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
- package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
- package/dist/browser/optional-writes-76DWMRQH.mjs +3603 -0
- package/dist/browser/phrase-module-6UGFVW5J.mjs +617 -0
- package/dist/browser/resolve-vector-text-XRR2OVHE.mjs +85 -0
- package/dist/browser/restore-queue-SG5O735W.mjs +196 -0
- package/dist/browser/{runtime-NYE5TB6O.mjs → runtime-OMKE7DF4.mjs} +83 -25
- package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
- package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
- package/dist/browser/storage-leaf-5UTR5K7J.mjs +19829 -0
- package/dist/browser/store-leaf-3L33V35P.mjs +2070 -0
- package/dist/browser/suggestions-leaf-UBNDVKBD.mjs +1430 -0
- package/dist/browser/worker-copies-JXSGYR5X.mjs +2951 -0
- package/dist/{capabilities-BTTIs96E.d.ts → capabilities-DMte5K9_.d.ts} +162 -18
- package/dist/chunk-2AFZE7Y3.mjs +72 -0
- package/dist/chunk-2CKDCC65.mjs +47 -0
- package/dist/chunk-3ECIRFS5.mjs +61 -0
- package/dist/chunk-44W3CBNG.mjs +7 -0
- package/dist/chunk-4H4RG2FR.mjs +13 -0
- package/dist/chunk-4PY4JYMY.mjs +11 -0
- package/dist/chunk-4ZPVAHWF.mjs +1289 -0
- package/dist/chunk-5EI5CXO6.mjs +197 -0
- package/dist/chunk-5F5MXWS5.mjs +283 -0
- package/dist/{chunk-OHP7QR33.mjs → chunk-5FLRXF73.mjs} +25 -4
- package/dist/chunk-6FOENO4E.mjs +273 -0
- package/dist/chunk-6GHX35ZM.mjs +108 -0
- package/dist/chunk-6MSZ543Y.mjs +32 -0
- package/dist/chunk-6N6HHBCQ.mjs +4596 -0
- package/dist/{chunk-LXPIXDUJ.mjs → chunk-7P5YWDRQ.mjs} +403 -169
- package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
- package/dist/{chunk-GGSH6KBQ.mjs → chunk-ASZLNVWW.mjs} +23 -3
- package/dist/chunk-AVBPB3MI.mjs +602 -0
- package/dist/{chunk-UCDF35PU.mjs → chunk-AVGUEEQ3.mjs} +494 -245
- package/dist/chunk-BUMREPLU.mjs +15 -0
- package/dist/chunk-BY6NALRK.mjs +31921 -0
- package/dist/chunk-C4ZMXXTL.mjs +92 -0
- package/dist/{chunk-2WYMG3OZ.mjs → chunk-C74KPRR7.mjs} +274 -19
- package/dist/{chunk-RSRVGAIQ.mjs → chunk-D456ZFPQ.mjs} +3 -2
- package/dist/chunk-DXZ6JDWG.mjs +797 -0
- package/dist/chunk-FJXJZUWF.mjs +209 -0
- package/dist/chunk-FS3HPPSC.mjs +212 -0
- package/dist/chunk-FT4KLZXW.mjs +1164 -0
- package/dist/chunk-GR5GMFJJ.mjs +104 -0
- package/dist/chunk-GXCDWLQI.mjs +193 -0
- package/dist/chunk-GXED6R3Q.mjs +271 -0
- package/dist/chunk-HLPRHOSO.mjs +17 -0
- package/dist/chunk-IL5DRCNU.mjs +3041 -0
- package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
- package/dist/chunk-K5HSUPYS.mjs +11 -0
- package/dist/chunk-KYIRXTCA.mjs +100 -0
- package/dist/chunk-LFXS6OF7.mjs +289 -0
- package/dist/chunk-LNGE7SLY.mjs +151 -0
- package/dist/chunk-M2Z5WVWW.mjs +194 -0
- package/dist/{chunk-45AVKHMJ.mjs → chunk-M3B7SGJB.mjs} +63 -50
- package/dist/chunk-M3OW2XSP.mjs +40 -0
- package/dist/chunk-MFPSQZ6P.mjs +127 -0
- package/dist/chunk-MRCJBWJZ.mjs +1292 -0
- package/dist/chunk-MSIN4NM3.mjs +25 -0
- package/dist/chunk-MW3CJVGP.mjs +219 -0
- package/dist/chunk-MYM6CAVK.mjs +76 -0
- package/dist/chunk-NJJN4FMM.mjs +84 -0
- package/dist/chunk-NM7I3BM7.mjs +59 -0
- package/dist/chunk-OIJ64LGT.mjs +19 -0
- package/dist/{chunk-K7D4ZTSW.mjs → chunk-P4F4UWLC.mjs} +1 -1
- package/dist/chunk-Q2AP2FSN.mjs +15 -0
- package/dist/chunk-R2PJKSNL.mjs +54 -0
- package/dist/{chunk-HXJBSHXF.mjs → chunk-R724DJSG.mjs} +5056 -2619
- package/dist/chunk-S2POFTLN.mjs +10 -0
- package/dist/chunk-S5QMWECL.mjs +7 -0
- package/dist/chunk-SLAC5PAB.mjs +5008 -0
- package/dist/chunk-T4HMSZCX.mjs +5 -0
- package/dist/chunk-TACP6VK6.mjs +111 -0
- package/dist/chunk-TGPKS2UM.mjs +125 -0
- package/dist/chunk-TKKXPKEO.mjs +979 -0
- package/dist/chunk-V6EUBAIT.mjs +19 -0
- package/dist/chunk-XL56L4IR.mjs +228 -0
- package/dist/chunk-XQIAMDAG.mjs +3076 -0
- package/dist/chunk-YTUZ4R22.mjs +1063 -0
- package/dist/{chunk-KV3AZFT3.mjs → chunk-ZKOQR7EA.mjs} +45 -1
- package/dist/chunk-ZPJFGGGI.mjs +638 -0
- package/dist/chunk-ZXX5GZEX.mjs +17 -0
- package/dist/{client-i9eLJrw5.d.ts → client-BKqtl0_V.d.ts} +442 -22
- package/dist/client.d.ts +11 -10
- package/dist/client.mjs +8 -898
- package/dist/config-Bnl7L-0H.d.ts +608 -0
- package/dist/{config-P__Diiy4.d.ts → config-CJ-jfI0a.d.ts} +119 -9
- package/dist/core-leaf-6JVHEVFB.mjs +8 -0
- package/dist/custom-token-results-NXHBVY7U.mjs +59 -0
- package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
- package/dist/direct-executor-V3WOYU2Y.mjs +17 -0
- package/dist/distribution/coordinator/etcd.d.ts +63 -7
- package/dist/distribution/coordinator/etcd.mjs +725 -81
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/coordinator/in-memory.mjs +65 -10
- package/dist/distribution/transport/grpc.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +39 -10
- package/dist/distribution/transport/in-memory.d.ts +2 -2
- package/dist/distribution/transport/in-memory.mjs +9 -6
- package/dist/distribution/transport/tcp.d.ts +2 -2
- package/dist/distribution/transport/tcp.mjs +20 -15
- package/dist/distribution.d.ts +267 -56
- package/dist/distribution.mjs +23156 -11362
- package/dist/durability-config-VWS2K24E.mjs +96 -0
- package/dist/embed-4PHHKGBK.mjs +263 -0
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{memory-CUEDwr-F.d.ts → engine-qjAxJSKk.d.ts} +2254 -1123
- package/dist/geo-index-2ZMMWWSK.mjs +1484 -0
- package/dist/gzip-2UCZW2MM.mjs +31 -0
- package/dist/{index-lcdGLyJH.d.ts → index-B_vmxpgW.d.ts} +260 -102
- package/dist/index.browser.mjs +4 -4
- package/dist/index.d.ts +2133 -57
- package/dist/index.mjs +16 -32
- package/dist/index.react-native.mjs +12 -0
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +1 -2
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/languages/albanian.mjs +1 -1
- package/dist/languages/amharic.mjs +1 -1
- package/dist/languages/arabic.mjs +1 -1
- package/dist/languages/armenian.mjs +1 -1
- package/dist/languages/azerbaijani.mjs +1 -1
- package/dist/languages/bambara.mjs +1 -1
- package/dist/languages/basque.mjs +1 -1
- package/dist/languages/belarusian.mjs +1 -1
- package/dist/languages/bengali.mjs +1 -1
- package/dist/languages/bosnian.mjs +1 -1
- package/dist/languages/breton.mjs +1 -1
- package/dist/languages/bulgarian.mjs +1 -1
- package/dist/languages/burmese.mjs +1 -1
- package/dist/languages/catalan.mjs +1 -1
- package/dist/languages/chinese.mjs +1 -1
- package/dist/languages/croatian.mjs +1 -1
- package/dist/languages/czech.mjs +1 -1
- package/dist/languages/dagbani.mjs +1 -1
- package/dist/languages/danish.mjs +1 -1
- package/dist/languages/dutch.mjs +1 -1
- package/dist/languages/english.mjs +1 -1
- package/dist/languages/esperanto.mjs +1 -1
- package/dist/languages/estonian.mjs +1 -1
- package/dist/languages/ewe.mjs +1 -1
- package/dist/languages/faroese.mjs +1 -1
- package/dist/languages/fijian.mjs +1 -1
- package/dist/languages/finnish.mjs +1 -1
- package/dist/languages/french.mjs +1 -1
- package/dist/languages/ga.mjs +1 -1
- package/dist/languages/galician.mjs +1 -1
- package/dist/languages/georgian.mjs +1 -1
- package/dist/languages/german.mjs +1 -1
- package/dist/languages/greek.mjs +1 -1
- package/dist/languages/guarani.mjs +1 -1
- package/dist/languages/gujarati.mjs +1 -1
- package/dist/languages/haitian-creole.mjs +1 -1
- package/dist/languages/hausa.mjs +1 -1
- package/dist/languages/hawaiian.mjs +1 -1
- package/dist/languages/hebrew.mjs +1 -1
- package/dist/languages/hindi.mjs +1 -1
- package/dist/languages/hungarian.mjs +1 -1
- package/dist/languages/icelandic.mjs +1 -1
- package/dist/languages/igbo.mjs +1 -1
- package/dist/languages/indonesian.mjs +1 -1
- package/dist/languages/irish.mjs +1 -1
- package/dist/languages/italian.mjs +1 -1
- package/dist/languages/japanese.mjs +1 -1
- package/dist/languages/kannada.mjs +1 -1
- package/dist/languages/kazakh.mjs +1 -1
- package/dist/languages/khmer.mjs +1 -1
- package/dist/languages/kinyarwanda.mjs +1 -1
- package/dist/languages/kirundi.mjs +1 -1
- package/dist/languages/korean.mjs +1 -1
- package/dist/languages/kurmanji.mjs +1 -1
- package/dist/languages/kyrgyz.mjs +1 -1
- package/dist/languages/lao.mjs +1 -1
- package/dist/languages/latin.mjs +1 -1
- package/dist/languages/latvian.mjs +1 -1
- package/dist/languages/lingala.mjs +1 -1
- package/dist/languages/lithuanian.mjs +1 -1
- package/dist/languages/luxembourgish.mjs +1 -1
- package/dist/languages/macedonian.mjs +1 -1
- package/dist/languages/malagasy.mjs +1 -1
- package/dist/languages/malay.mjs +1 -1
- package/dist/languages/malayalam.mjs +1 -1
- package/dist/languages/maltese.mjs +1 -1
- package/dist/languages/maori.mjs +1 -1
- package/dist/languages/marathi.mjs +1 -1
- package/dist/languages/nepali.mjs +1 -1
- package/dist/languages/norwegian.mjs +1 -1
- package/dist/languages/oromo.mjs +1 -1
- package/dist/languages/persian.mjs +1 -1
- package/dist/languages/polish.mjs +1 -1
- package/dist/languages/portuguese.mjs +1 -1
- package/dist/languages/punjabi.mjs +1 -1
- package/dist/languages/romanian.mjs +1 -1
- package/dist/languages/russian.mjs +1 -1
- package/dist/languages/samoan.mjs +1 -1
- package/dist/languages/sanskrit.mjs +1 -1
- package/dist/languages/scottish-gaelic.mjs +1 -1
- package/dist/languages/serbian.mjs +1 -1
- package/dist/languages/shona.mjs +1 -1
- package/dist/languages/sinhala.mjs +1 -1
- package/dist/languages/slovak.mjs +1 -1
- package/dist/languages/slovenian.mjs +1 -1
- package/dist/languages/sorani.mjs +1 -1
- package/dist/languages/spanish.mjs +1 -1
- package/dist/languages/swahili.mjs +1 -1
- package/dist/languages/swedish.mjs +1 -1
- package/dist/languages/tagalog.mjs +1 -1
- package/dist/languages/tamil.mjs +1 -1
- package/dist/languages/tatar.mjs +1 -1
- package/dist/languages/telugu.mjs +1 -1
- package/dist/languages/thai.mjs +1 -1
- package/dist/languages/tibetan.mjs +1 -1
- package/dist/languages/tigrinya.mjs +1 -1
- package/dist/languages/tongan.mjs +1 -1
- package/dist/languages/turkish.mjs +1 -1
- package/dist/languages/twi.mjs +1 -1
- package/dist/languages/ukrainian.mjs +1 -1
- package/dist/languages/urdu.mjs +1 -1
- package/dist/languages/vietnamese.mjs +1 -1
- package/dist/languages/welsh.mjs +1 -1
- package/dist/languages/wolof.mjs +1 -1
- package/dist/languages/xhosa.mjs +1 -1
- package/dist/languages/yoruba.mjs +1 -1
- package/dist/languages/zulu.mjs +1 -1
- package/dist/long-query-thread-UCRK7MSI.mjs +154 -0
- package/dist/module-5ZSLUQII.mjs +3729 -0
- package/dist/msgpack-leaf-H5ZYW7S7.mjs +9 -0
- package/dist/optional-reads-5HFMF2QZ.mjs +3373 -0
- package/dist/optional-writes-4UOQKETU.mjs +247 -0
- package/dist/paged-partition-archive-BBRLZCIF.mjs +253 -0
- package/dist/partial-words.browser.mjs +1650 -0
- package/dist/partial-words.mjs +17 -11
- package/dist/{chunk-ASY5PHYI.mjs → pattern.browser.mjs} +253 -311
- package/dist/pattern.mjs +6 -7
- package/dist/persistence/durability/checkpoint-worker.d.ts +93 -25
- package/dist/persistence/durability/checkpoint-worker.mjs +51 -41
- package/dist/phrase-module-EFESWOCR.mjs +635 -0
- package/dist/query-actions-HMJUVWGT.mjs +119 -0
- package/dist/query-suggestions/merge-worker.d.ts +55 -0
- package/dist/query-suggestions/merge-worker.mjs +53 -0
- package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
- package/dist/query-suggestions.browser.mjs +47 -0
- package/dist/query-suggestions.d.ts +20 -0
- package/dist/query-suggestions.mjs +19 -0
- package/dist/react-native/chunks/chunk-3OEFSHVV.mjs +970 -0
- package/dist/{browser/chunk-RELZRJNR.mjs → react-native/chunks/chunk-43R4GCM7.mjs} +49 -50
- package/dist/react-native/chunks/chunk-AKRYHAVG.mjs +6729 -0
- package/dist/react-native/chunks/chunk-CW2ZFXSE.mjs +14 -0
- package/dist/react-native/chunks/chunk-G3WCDTOF.mjs +29640 -0
- package/dist/react-native/chunks/chunk-GXXHHA2T.mjs +212 -0
- package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
- package/dist/react-native/chunks/chunk-HQEVQEDJ.mjs +52 -0
- package/dist/react-native/chunks/chunk-HRDMIQ63.mjs +131 -0
- package/dist/react-native/chunks/chunk-HTBY4GON.mjs +565 -0
- package/dist/react-native/chunks/chunk-LX62Y4B5.mjs +61 -0
- package/dist/react-native/chunks/chunk-MRH36RN3.mjs +902 -0
- package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
- package/dist/react-native/chunks/chunk-UE4ANHSX.mjs +127 -0
- package/dist/react-native/chunks/chunk-UNZPWLVL.mjs +1063 -0
- package/dist/react-native/chunks/chunk-UO44MA5M.mjs +232 -0
- package/dist/react-native/chunks/chunk-UYKIV2KT.mjs +42 -0
- package/dist/react-native/chunks/chunk-VUJCSQG5.mjs +11 -0
- package/dist/react-native/chunks/chunk-WVHF4ZAK.mjs +802 -0
- package/dist/react-native/chunks/chunk-ZUJCUPVS.mjs +54 -0
- package/dist/react-native/chunks/core-leaf-S2KNBWDY.mjs +7 -0
- package/dist/react-native/chunks/custom-token-results-3OZEMRE7.mjs +59 -0
- package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
- package/dist/react-native/chunks/durability-config-FCSD4MXY.mjs +96 -0
- package/dist/react-native/chunks/embed-HA2I7RCF.mjs +263 -0
- package/dist/react-native/chunks/geo-index-QEYKEVPH.mjs +1484 -0
- package/dist/react-native/chunks/gzip.react-native-CVM4NQG2.mjs +12 -0
- package/dist/react-native/chunks/module-FMBX75GP.mjs +5209 -0
- package/dist/react-native/chunks/msgpack-leaf-JMNGSTRW.mjs +7 -0
- package/dist/react-native/chunks/optional-reads-AFPO2FEB.mjs +3364 -0
- package/dist/react-native/chunks/optional-writes-XOH25XZI.mjs +296 -0
- package/dist/react-native/chunks/phrase-module-IGYBK7XH.mjs +636 -0
- package/dist/react-native/chunks/replace-IMZUVUOE.mjs +57 -0
- package/dist/react-native/chunks/resolve-vector-text-GE2CRJKI.mjs +84 -0
- package/dist/react-native/chunks/restore-queue-LLNMYB4Z.mjs +187 -0
- package/dist/react-native/chunks/runtime-UOHD2XUJ.mjs +615 -0
- package/dist/react-native/chunks/segment-codec-leaf-VR6O5GLC.mjs +13 -0
- package/dist/react-native/chunks/segment-merge-leaf-LLMWU4EW.mjs +14 -0
- package/dist/react-native/chunks/storage-leaf-JD7PIDO4.mjs +19633 -0
- package/dist/react-native/chunks/store-leaf-4UVCMYGN.mjs +15 -0
- package/dist/react-native/chunks/suggestions-leaf-J5VT5RHY.mjs +1321 -0
- package/dist/react-native/chunks/worker-copies-ZYHY7FKJ.mjs +2831 -0
- package/dist/react-native/partial-words.mjs +1658 -0
- package/dist/react-native/pattern.mjs +2570 -0
- package/dist/react-native/query-suggestions.mjs +55 -0
- package/dist/react-native/sync.mjs +2759 -0
- package/dist/react-native/synonyms.mjs +676 -0
- package/dist/react.d.ts +12 -8
- package/dist/react.mjs +45 -1
- package/dist/{rerank-NWTKK636.mjs → rerank-RI2PMNOD.mjs} +22 -12
- package/dist/rerankers/http.d.ts +1 -1
- package/dist/rerankers/http.mjs +2 -2
- package/dist/resolve-vector-text-OD4J3WHF.mjs +3 -0
- package/dist/restore-queue-PCKWDAKQ.mjs +192 -0
- package/dist/runtime-USQYKN3I.mjs +615 -0
- package/dist/{schema-4W_7tk1f.d.ts → schema-CzG9OUw5.d.ts} +70 -30
- package/dist/segment-codec-leaf-QJM7I6QG.mjs +18 -0
- package/dist/segment-merge-leaf-4BJGIJHY.mjs +18 -0
- package/dist/server.d.ts +348 -22
- package/dist/server.mjs +2211 -327
- package/dist/storage-leaf-GRRRI7UV.mjs +5962 -0
- package/dist/store-leaf-6VMMSVBE.mjs +20 -0
- package/dist/stored-values-BWIMpiT_.d.ts +25 -0
- package/dist/suggestions-leaf-4KPTMPTL.mjs +54 -0
- package/dist/sync/filesystem.d.ts +30 -0
- package/dist/sync/filesystem.mjs +288 -0
- package/dist/sync/indexeddb.browser.mjs +287 -0
- package/dist/sync/indexeddb.d.ts +30 -0
- package/dist/sync/indexeddb.mjs +242 -0
- package/dist/sync.browser.mjs +1271 -0
- package/dist/sync.d.ts +23 -0
- package/dist/sync.mjs +2712 -0
- package/dist/synonyms.browser.mjs +658 -0
- package/dist/synonyms.mjs +17 -7
- package/dist/tasks-65b6t6lk.d.ts +782 -0
- package/dist/thread-UJ3W5LVI.mjs +31 -0
- package/dist/{types-B3b68nfF.d.ts → types-Ck97nB3D.d.ts} +1 -1
- package/dist/types-CpCg-Gq-.d.ts +227 -0
- package/dist/{types-Cb9kiY5P.d.ts → types-DvncmvuQ.d.ts} +12 -1
- package/dist/vector/search-worker.d.ts +10 -2
- package/dist/vector/search-worker.mjs +11 -11
- package/dist/worker-copies-YSXZXIGC.mjs +2232 -0
- package/dist/workers/entry.mjs +75 -15
- package/openapi.json +6840 -0
- package/package.json +406 -19
- package/dist/browser/chunk-CN4I4FZU.mjs +0 -602
- package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
- package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
- package/dist/browser/chunk-LD55ZGU3.mjs +0 -347
- package/dist/browser/chunk-NAFT3K6X.mjs +0 -24546
- package/dist/browser/chunk-NNG3EEB6.mjs +0 -2728
- package/dist/browser/chunk-QWES44AW.mjs +0 -473
- package/dist/browser/durability-wiring-PY3L7DES.mjs +0 -3679
- package/dist/browser/module-PDXYHT75.mjs +0 -2822
- package/dist/browser/release-76MXRPGV.mjs +0 -33
- package/dist/browser/restore-queue-DVIYJ7RU.mjs +0 -35
- package/dist/browser/snapshot-J57MZK6L.mjs +0 -1207
- package/dist/browser/write-L7FAQA47.mjs +0 -208
- package/dist/chunk-37CD3OKS.mjs +0 -87
- package/dist/chunk-5XNIRLFC.mjs +0 -96
- package/dist/chunk-7X5JST5L.mjs +0 -114
- package/dist/chunk-AV4IJKD2.mjs +0 -35
- package/dist/chunk-AY3AQ3UH.mjs +0 -73
- package/dist/chunk-BKB3XTMI.mjs +0 -707
- package/dist/chunk-C7SLA6CM.mjs +0 -19
- package/dist/chunk-COVCQ73F.mjs +0 -587
- package/dist/chunk-DJHHF2L5.mjs +0 -17
- package/dist/chunk-E74YLAIG.mjs +0 -24
- package/dist/chunk-FMWRCP2C.mjs +0 -57
- package/dist/chunk-GES7U2PM.mjs +0 -68
- package/dist/chunk-HJSN7UYG.mjs +0 -10
- package/dist/chunk-JFRNNBOM.mjs +0 -35
- package/dist/chunk-K25LZA54.mjs +0 -8484
- package/dist/chunk-KEHK2O6P.mjs +0 -13
- package/dist/chunk-KOKM4PQN.mjs +0 -52
- package/dist/chunk-KZ3NX2P7.mjs +0 -21
- package/dist/chunk-L3L5YFXC.mjs +0 -614
- package/dist/chunk-L5ORED7V.mjs +0 -25
- package/dist/chunk-LH4NZNJJ.mjs +0 -1731
- package/dist/chunk-LU2CE5AE.mjs +0 -507
- package/dist/chunk-LXWDQLTW.mjs +0 -30
- package/dist/chunk-MHOSCQCQ.mjs +0 -948
- package/dist/chunk-NKRBEGJZ.mjs +0 -1705
- package/dist/chunk-NTRMFARG.mjs +0 -462
- package/dist/chunk-NW4XDSP2.mjs +0 -212
- package/dist/chunk-OOEXLUGR.mjs +0 -117
- package/dist/chunk-ORBLD3EL.mjs +0 -6
- package/dist/chunk-OWNZYMRE.mjs +0 -3591
- package/dist/chunk-PPY2GSIB.mjs +0 -44
- package/dist/chunk-QY7GC2MW.mjs +0 -33
- package/dist/chunk-R6A773WK.mjs +0 -226
- package/dist/chunk-R6PR4WYZ.mjs +0 -68
- package/dist/chunk-R7EEKAJE.mjs +0 -593
- package/dist/chunk-RONEOEON.mjs +0 -426
- package/dist/chunk-VWULPWRJ.mjs +0 -7469
- package/dist/chunk-WCJKUGHB.mjs +0 -262
- package/dist/chunk-WQBCBKY3.mjs +0 -8
- package/dist/chunk-X5CV2E2B.mjs +0 -1
- package/dist/chunk-YA7XLE2R.mjs +0 -1256
- package/dist/chunk-YTJCGKM4.mjs +0 -56
- package/dist/chunk-ZG477IPV.mjs +0 -526
- package/dist/chunk-ZYNAMIYX.mjs +0 -113
- package/dist/config-BGB_fDtq.d.ts +0 -237
- package/dist/direct-executor-CXZ66ACP.mjs +0 -22
- package/dist/durability-wiring-QTHOGFMZ.mjs +0 -3229
- package/dist/engine-BGCEm9E_.d.ts +0 -577
- package/dist/module-3NONKBZX.mjs +0 -1860
- package/dist/release-BH3DKW3T.mjs +0 -33
- package/dist/restore-queue-JPRBUYII.mjs +0 -35
- package/dist/runtime-ZKYZFJJC.mjs +0 -177
- package/dist/snapshot-HOGXNO5W.mjs +0 -793
- package/dist/tasks-HG3rlxx6.d.ts +0 -302
- package/dist/thread-B657LQXK.mjs +0 -692
- package/dist/write-XLIGTXBU.mjs +0 -238
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { DayStore, RestoredHistory, clearLeftoversOfName, dayOf, installSuggestionHooks, openCountsFile, sameBytes, startQuerySuggestions } from './chunk-YTUZ4R22.mjs';
|
|
2
|
+
export { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
|
|
3
|
+
export { BUILD_LIST_PAGE, BUILD_WRITE_BATCH, BYTES_PER_MIB, DAY_MS, DEFAULT_PREVIEW_LIMIT, HEADER_SIZE, HISTORY_SWEEP_INTERVAL_MS, KEY_FINGERPRINT_BYTES, KEY_FINGERPRINT_LABEL, MAX_HISTORY_FILE_BYTES, MAX_MANUAL_SUGGESTION_COUNT, MAX_PREVIEW_LIMIT, MAX_SOURCE_INDEX_NAME_LENGTH, MAX_TIMER_DELAY_MS, MIN_KEY_BYTES, MS_PER_SECOND, QUERY_HISTORY_ARCHIVE_PREFIX, QUERY_HISTORY_FOLDER, SCHEDULE_OFF, SCRAMBLED_ID_BYTES, acceptedPhrase, attachRuntime, attachedRuntimeOf, banListFromInput, bindSuggestionStoreHost, buildRecordKey, checksumOfChunks, crc32, crc32Final, crc32Init, crc32Update, engineVersionParts, hasNrslMagic, historyFileOf, historyFilesOf, invalidSetting, isGroup, isPerson, latestMatchAtOrBefore, listHistoryFolder, nextMatchAfter, normaliseBan, openChecksummedEnvelope, packChecksummedEnvelope, packEnvelopeWithChecksum, parseSchedule, readHeader, removeHistoryFolder, removeRestoreLeftovers, requireFieldsInSchema, requireWithinFileLimit, resolveSetting, storedStateFromWire, storedStateOf, storedStateToWire, unionOfBans, validateSetting, withState, writeHeader } from './chunk-TKKXPKEO.mjs';
|
|
4
|
+
import './chunk-BY6NALRK.mjs';
|
|
5
|
+
import './chunk-2CKDCC65.mjs';
|
|
6
|
+
import './chunk-2AFZE7Y3.mjs';
|
|
7
|
+
import './chunk-GXCDWLQI.mjs';
|
|
8
|
+
import './chunk-BUMREPLU.mjs';
|
|
9
|
+
import './chunk-7T4LAYT4.mjs';
|
|
10
|
+
import './chunk-IL5DRCNU.mjs';
|
|
11
|
+
import './chunk-7P5YWDRQ.mjs';
|
|
12
|
+
import './chunk-U2BKYEC7.mjs';
|
|
13
|
+
import './chunk-FJXJZUWF.mjs';
|
|
14
|
+
import './chunk-5EI5CXO6.mjs';
|
|
15
|
+
import './chunk-3ECIRFS5.mjs';
|
|
16
|
+
import './chunk-ASZLNVWW.mjs';
|
|
17
|
+
import './chunk-ZXX5GZEX.mjs';
|
|
18
|
+
import './chunk-4PY4JYMY.mjs';
|
|
19
|
+
import './chunk-ZKOQR7EA.mjs';
|
|
20
|
+
import './chunk-TGPKS2UM.mjs';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed regions of one stored field in a shared ordinal space.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
interface NativeStoredValues {
|
|
7
|
+
/** Records 0 for an absent field, 1 for a scalar, and 2 for an array at each ordinal. */
|
|
8
|
+
shapes: Uint8Array;
|
|
9
|
+
/** Gives each ordinal's first value, followed by the terminal value offset. */
|
|
10
|
+
starts: Uint32Array;
|
|
11
|
+
/** Records 0 for null, 1 for false, 2 for true, 3 for a number, 4 for a string, and 5 for encoded data. */
|
|
12
|
+
kinds: Uint8Array;
|
|
13
|
+
/** Holds each numeric value at its value position. */
|
|
14
|
+
numbers: Float64Array;
|
|
15
|
+
/** Gives each string's first code unit or each encoded value's first byte. */
|
|
16
|
+
textStart: Uint32Array;
|
|
17
|
+
/** Gives each string's code unit count or each encoded value's byte count. */
|
|
18
|
+
textLength: Uint32Array;
|
|
19
|
+
/** Holds the UTF-16 code units of the strings. */
|
|
20
|
+
units: Uint16Array;
|
|
21
|
+
/** Holds the MessagePack bytes of objects and nested arrays. */
|
|
22
|
+
bytes: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type { NativeStoredValues as N };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { querySuggestionsOf, keyBytesOf, createQuerySuggestionsRuntime, createLocalHost } from './chunk-4ZPVAHWF.mjs';
|
|
2
|
+
export { bindSuggestionsHost } from './chunk-MYM6CAVK.mjs';
|
|
3
|
+
import { installSuggestionHooks } from './chunk-YTUZ4R22.mjs';
|
|
4
|
+
import './chunk-V6EUBAIT.mjs';
|
|
5
|
+
import { attachedRuntimeOf, attachRuntime } from './chunk-TKKXPKEO.mjs';
|
|
6
|
+
import './chunk-BY6NALRK.mjs';
|
|
7
|
+
import './chunk-2CKDCC65.mjs';
|
|
8
|
+
import './chunk-2AFZE7Y3.mjs';
|
|
9
|
+
import './chunk-GXCDWLQI.mjs';
|
|
10
|
+
import './chunk-BUMREPLU.mjs';
|
|
11
|
+
import './chunk-7T4LAYT4.mjs';
|
|
12
|
+
import './chunk-IL5DRCNU.mjs';
|
|
13
|
+
import './chunk-7P5YWDRQ.mjs';
|
|
14
|
+
import './chunk-U2BKYEC7.mjs';
|
|
15
|
+
import './chunk-FJXJZUWF.mjs';
|
|
16
|
+
import './chunk-5EI5CXO6.mjs';
|
|
17
|
+
import './chunk-3ECIRFS5.mjs';
|
|
18
|
+
import './chunk-ASZLNVWW.mjs';
|
|
19
|
+
import './chunk-ZXX5GZEX.mjs';
|
|
20
|
+
import './chunk-4PY4JYMY.mjs';
|
|
21
|
+
import './chunk-ZKOQR7EA.mjs';
|
|
22
|
+
import './chunk-TGPKS2UM.mjs';
|
|
23
|
+
|
|
24
|
+
// src/query-suggestions/start.ts
|
|
25
|
+
var starting = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
async function startRuntime(core, engine, config) {
|
|
27
|
+
const keySetting = config?.querySuggestions?.key;
|
|
28
|
+
const key = keySetting === void 0 ? null : keyBytesOf(keySetting);
|
|
29
|
+
const runtime = await createQuerySuggestionsRuntime(createLocalHost(core, engine, config), key);
|
|
30
|
+
attachRuntime(core, runtime);
|
|
31
|
+
installSuggestionHooks(core);
|
|
32
|
+
await runtime.start();
|
|
33
|
+
return runtime;
|
|
34
|
+
}
|
|
35
|
+
function localRuntimeOf(core, engine, config) {
|
|
36
|
+
const attached = attachedRuntimeOf(core);
|
|
37
|
+
if (attached !== void 0) return Promise.resolve(attached);
|
|
38
|
+
const pending = starting.get(core);
|
|
39
|
+
if (pending !== void 0) return pending;
|
|
40
|
+
const started = startRuntime(core, engine, config);
|
|
41
|
+
starting.set(core, started);
|
|
42
|
+
void started.then(
|
|
43
|
+
() => starting.delete(core),
|
|
44
|
+
() => starting.delete(core)
|
|
45
|
+
);
|
|
46
|
+
return started;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/query-suggestions/suggestions-leaf.ts
|
|
50
|
+
function localQuerySuggestionsOf(core, engine) {
|
|
51
|
+
return querySuggestionsOf(() => localRuntimeOf(core, engine, void 0));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { localQuerySuggestionsOf, localRuntimeOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as DeviceSyncStore } from '../types-CpCg-Gq-.js';
|
|
2
|
+
import '../engine-qjAxJSKk.js';
|
|
3
|
+
import '../adapters-pljAqmrC.js';
|
|
4
|
+
import '../schema-CzG9OUw5.js';
|
|
5
|
+
import '../synonyms-CpOAHPa-.js';
|
|
6
|
+
import '../query-suggestions-CBYkrQ5T.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The settings of {@link createFilesystemDeviceStore}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
interface FilesystemDeviceStoreConfig {
|
|
14
|
+
/** The store keeps its files in this directory, which it creates where it is missing and locks while it is open. */
|
|
15
|
+
directory: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Opens a store that keeps a synced device's queue, kept feed entries, position, and snapshot download in files, for
|
|
19
|
+
* an app on Node.js, Electron, or another runtime with `node:fs`.
|
|
20
|
+
*
|
|
21
|
+
* Each write reaches the disk through `fsync` before its promise resolves, and the store drops a record that a crash
|
|
22
|
+
* cut short when it next opens. Only one store may hold the directory open at a time.
|
|
23
|
+
*
|
|
24
|
+
* @param config - The directory that holds the files.
|
|
25
|
+
* @returns The open store, which {@link DeviceSyncStore.close} releases.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
declare function createFilesystemDeviceStore(config: FilesystemDeviceStoreConfig): Promise<DeviceSyncStore>;
|
|
29
|
+
|
|
30
|
+
export { type FilesystemDeviceStoreConfig, createFilesystemDeviceStore };
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { replayQueue, decodeKeptEntries, encodeKeptEntries, encodeQueueRecord, encodePosition, decodePosition, decodeDownloadTag, downloadOutOfOrder, encodeDownloadTag } from '../chunk-6GHX35ZM.mjs';
|
|
2
|
+
import { createSerial, QUEUE_COMPACTION_BYTES, DOWNLOAD_FRAME_BYTES, STORE_FRAME_LIMIT_BYTES } from '../chunk-6MSZ543Y.mjs';
|
|
3
|
+
import { createDurableDirectory } from '../chunk-M3B7SGJB.mjs';
|
|
4
|
+
import '../chunk-HLPRHOSO.mjs';
|
|
5
|
+
import '../chunk-MSIN4NM3.mjs';
|
|
6
|
+
import '../chunk-S5QMWECL.mjs';
|
|
7
|
+
import '../chunk-LNGE7SLY.mjs';
|
|
8
|
+
import '../chunk-R2PJKSNL.mjs';
|
|
9
|
+
import '../chunk-MFPSQZ6P.mjs';
|
|
10
|
+
import '../chunk-FS3HPPSC.mjs';
|
|
11
|
+
import '../chunk-R724DJSG.mjs';
|
|
12
|
+
import '../chunk-V6EUBAIT.mjs';
|
|
13
|
+
import { crc32 } from '../chunk-TKKXPKEO.mjs';
|
|
14
|
+
import '../chunk-BY6NALRK.mjs';
|
|
15
|
+
import '../chunk-2CKDCC65.mjs';
|
|
16
|
+
import '../chunk-2AFZE7Y3.mjs';
|
|
17
|
+
import '../chunk-GXCDWLQI.mjs';
|
|
18
|
+
import '../chunk-BUMREPLU.mjs';
|
|
19
|
+
import '../chunk-7T4LAYT4.mjs';
|
|
20
|
+
import '../chunk-IL5DRCNU.mjs';
|
|
21
|
+
import { loadMessagePack } from '../chunk-7P5YWDRQ.mjs';
|
|
22
|
+
import '../chunk-U2BKYEC7.mjs';
|
|
23
|
+
import '../chunk-FJXJZUWF.mjs';
|
|
24
|
+
import '../chunk-5EI5CXO6.mjs';
|
|
25
|
+
import '../chunk-3ECIRFS5.mjs';
|
|
26
|
+
import '../chunk-ASZLNVWW.mjs';
|
|
27
|
+
import '../chunk-ZXX5GZEX.mjs';
|
|
28
|
+
import '../chunk-4PY4JYMY.mjs';
|
|
29
|
+
import { NarsilError, ErrorCodes } from '../chunk-ZKOQR7EA.mjs';
|
|
30
|
+
import '../chunk-TGPKS2UM.mjs';
|
|
31
|
+
|
|
32
|
+
// src/sync/device/stores/frames.ts
|
|
33
|
+
var FRAME_HEADER_BYTES = 8;
|
|
34
|
+
function frameOf(payload) {
|
|
35
|
+
const frame = new Uint8Array(FRAME_HEADER_BYTES + payload.byteLength);
|
|
36
|
+
const view = new DataView(frame.buffer);
|
|
37
|
+
view.setUint32(0, payload.byteLength, false);
|
|
38
|
+
view.setUint32(4, crc32(payload), false);
|
|
39
|
+
frame.set(payload, FRAME_HEADER_BYTES);
|
|
40
|
+
return frame;
|
|
41
|
+
}
|
|
42
|
+
function readFrames(bytes) {
|
|
43
|
+
const payloads = [];
|
|
44
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
45
|
+
let at = 0;
|
|
46
|
+
while (at + FRAME_HEADER_BYTES <= bytes.byteLength) {
|
|
47
|
+
const length = view.getUint32(at, false);
|
|
48
|
+
const checksum = view.getUint32(at + 4, false);
|
|
49
|
+
const end = at + FRAME_HEADER_BYTES + length;
|
|
50
|
+
if (length > STORE_FRAME_LIMIT_BYTES || end > bytes.byteLength) break;
|
|
51
|
+
const payload = bytes.subarray(at + FRAME_HEADER_BYTES, end);
|
|
52
|
+
if (crc32(payload) !== checksum) break;
|
|
53
|
+
payloads.push(payload);
|
|
54
|
+
at = end;
|
|
55
|
+
}
|
|
56
|
+
return { payloads, cleanLength: at };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/sync/device/stores/filesystem-download.ts
|
|
60
|
+
var DOWNLOAD_TAG_KEY = "download.tag";
|
|
61
|
+
var DOWNLOAD_BYTES_KEY = "download.bin";
|
|
62
|
+
var FRAME_HEADER_BYTES2 = 8;
|
|
63
|
+
async function readHeader(readRange, at) {
|
|
64
|
+
const header = await readRange(DOWNLOAD_BYTES_KEY, at, FRAME_HEADER_BYTES2);
|
|
65
|
+
const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
66
|
+
return { length: view.getUint32(0, false), checksum: view.getUint32(4, false) };
|
|
67
|
+
}
|
|
68
|
+
async function scanFrames(readRange, onDisk) {
|
|
69
|
+
let savedLength = 0;
|
|
70
|
+
let fileLength = 0;
|
|
71
|
+
while (fileLength + FRAME_HEADER_BYTES2 <= onDisk) {
|
|
72
|
+
const header = await readHeader(readRange, fileLength);
|
|
73
|
+
const end = fileLength + FRAME_HEADER_BYTES2 + header.length;
|
|
74
|
+
if (header.length === 0 || header.length > DOWNLOAD_FRAME_BYTES || end > onDisk) break;
|
|
75
|
+
const payload = await readRange(DOWNLOAD_BYTES_KEY, fileLength + FRAME_HEADER_BYTES2, header.length);
|
|
76
|
+
if (crc32(payload) !== header.checksum) break;
|
|
77
|
+
savedLength += header.length;
|
|
78
|
+
fileLength = end;
|
|
79
|
+
}
|
|
80
|
+
return { savedLength, fileLength };
|
|
81
|
+
}
|
|
82
|
+
async function openFilesystemDownload(directory) {
|
|
83
|
+
const directoryReadRange = directory.readRange;
|
|
84
|
+
if (directoryReadRange === void 0) {
|
|
85
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store needs a directory that reads by position");
|
|
86
|
+
}
|
|
87
|
+
const readRange = (key, offset, length) => directoryReadRange.call(directory, key, offset, length);
|
|
88
|
+
let entityTag = null;
|
|
89
|
+
let savedLength = 0;
|
|
90
|
+
let fileLength = 0;
|
|
91
|
+
const tagBytes = await directory.read(DOWNLOAD_TAG_KEY);
|
|
92
|
+
if (tagBytes !== null) entityTag = decodeDownloadTag(tagBytes);
|
|
93
|
+
if (entityTag === null) {
|
|
94
|
+
await directory.remove(DOWNLOAD_BYTES_KEY);
|
|
95
|
+
} else {
|
|
96
|
+
const scanned = await scanFrames(readRange, await directory.byteLength?.(DOWNLOAD_BYTES_KEY) ?? 0);
|
|
97
|
+
savedLength = scanned.savedLength;
|
|
98
|
+
fileLength = scanned.fileLength;
|
|
99
|
+
}
|
|
100
|
+
let handle = await directory.appendHandle(DOWNLOAD_BYTES_KEY);
|
|
101
|
+
if (await handle.size() !== fileLength) await handle.truncate(fileLength);
|
|
102
|
+
async function reset(nextTag) {
|
|
103
|
+
await handle.close();
|
|
104
|
+
await directory.remove(DOWNLOAD_BYTES_KEY);
|
|
105
|
+
if (nextTag === null) {
|
|
106
|
+
await directory.remove(DOWNLOAD_TAG_KEY);
|
|
107
|
+
} else {
|
|
108
|
+
await directory.atomicWrite(DOWNLOAD_TAG_KEY, encodeDownloadTag(nextTag));
|
|
109
|
+
}
|
|
110
|
+
entityTag = nextTag;
|
|
111
|
+
savedLength = 0;
|
|
112
|
+
fileLength = 0;
|
|
113
|
+
handle = await directory.appendHandle(DOWNLOAD_BYTES_KEY);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
async append(tag, offset, chunk) {
|
|
117
|
+
if (offset === 0) {
|
|
118
|
+
await reset(tag);
|
|
119
|
+
} else if (tag !== entityTag || offset !== savedLength) {
|
|
120
|
+
throw downloadOutOfOrder(tag, offset, tag === entityTag ? savedLength : 0);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
for (let at = 0; at < chunk.byteLength; at += DOWNLOAD_FRAME_BYTES) {
|
|
124
|
+
await handle.append(frameOf(chunk.subarray(at, at + DOWNLOAD_FRAME_BYTES)));
|
|
125
|
+
}
|
|
126
|
+
await handle.sync();
|
|
127
|
+
} catch (error) {
|
|
128
|
+
await handle.truncate(fileLength).catch(() => void 0);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
savedLength += chunk.byteLength;
|
|
132
|
+
fileLength = await handle.size();
|
|
133
|
+
},
|
|
134
|
+
read() {
|
|
135
|
+
const tag = entityTag;
|
|
136
|
+
if (tag === null || savedLength === 0) return null;
|
|
137
|
+
const framesEnd = fileLength;
|
|
138
|
+
return {
|
|
139
|
+
entityTag: tag,
|
|
140
|
+
byteLength: savedLength,
|
|
141
|
+
async *chunks() {
|
|
142
|
+
let at = 0;
|
|
143
|
+
while (at < framesEnd) {
|
|
144
|
+
const header = await readHeader(readRange, at);
|
|
145
|
+
yield await readRange(DOWNLOAD_BYTES_KEY, at + FRAME_HEADER_BYTES2, header.length);
|
|
146
|
+
at += FRAME_HEADER_BYTES2 + header.length;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
async clear() {
|
|
152
|
+
await reset(null);
|
|
153
|
+
},
|
|
154
|
+
async close() {
|
|
155
|
+
await handle.close();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/sync/device/stores/filesystem.ts
|
|
161
|
+
var POSITION_KEY = "position";
|
|
162
|
+
var QUEUE_KEY = "queue.log";
|
|
163
|
+
var KEPT_KEY = "kept.log";
|
|
164
|
+
async function openFramedLog(directory, key) {
|
|
165
|
+
const bytes = await directory.read(key) ?? new Uint8Array(0);
|
|
166
|
+
const { payloads, cleanLength } = readFrames(bytes);
|
|
167
|
+
const handle = await directory.appendHandle(key);
|
|
168
|
+
if (cleanLength !== bytes.byteLength) await handle.truncate(cleanLength);
|
|
169
|
+
return { handle, payloads };
|
|
170
|
+
}
|
|
171
|
+
async function appendDurably(handle, frames) {
|
|
172
|
+
const before = await handle.size();
|
|
173
|
+
try {
|
|
174
|
+
for (const frame of frames) await handle.append(frame);
|
|
175
|
+
await handle.sync();
|
|
176
|
+
} catch (error) {
|
|
177
|
+
await handle.truncate(before).catch(() => void 0);
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function createFilesystemDeviceStore(config) {
|
|
182
|
+
if (typeof config.directory !== "string" || config.directory.trim().length === 0) {
|
|
183
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store needs a directory");
|
|
184
|
+
}
|
|
185
|
+
await loadMessagePack();
|
|
186
|
+
const directory = createDurableDirectory(config.directory);
|
|
187
|
+
const lock = await directory.lock?.() ?? null;
|
|
188
|
+
try {
|
|
189
|
+
return await openStore(directory, lock);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
await lock?.release().catch(() => void 0);
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function openStore(directory, lock) {
|
|
196
|
+
const serial = createSerial();
|
|
197
|
+
const queueLog = await openFramedLog(directory, QUEUE_KEY);
|
|
198
|
+
const queue = replayQueue(queueLog.payloads);
|
|
199
|
+
let queueHandle = queueLog.handle;
|
|
200
|
+
let queueFileBytes = await queueHandle.size();
|
|
201
|
+
const keptLog = await openFramedLog(directory, KEPT_KEY);
|
|
202
|
+
let keptHandle = keptLog.handle;
|
|
203
|
+
const download = await openFilesystemDownload(directory);
|
|
204
|
+
let closed = false;
|
|
205
|
+
function liveQueueBytes() {
|
|
206
|
+
let total = 0;
|
|
207
|
+
for (const bytes of queue.recordBytes.values()) total += bytes;
|
|
208
|
+
return total;
|
|
209
|
+
}
|
|
210
|
+
async function compactQueue() {
|
|
211
|
+
const frames = [frameOf(encodeQueueRecord({ type: "next", sequence: queue.nextSequence }))];
|
|
212
|
+
for (const write of [...queue.writes.values()].sort((a, b) => a.sequence - b.sequence)) {
|
|
213
|
+
frames.push(frameOf(encodeQueueRecord({ type: "write", write })));
|
|
214
|
+
}
|
|
215
|
+
await queueHandle.close();
|
|
216
|
+
await directory.atomicWrite(QUEUE_KEY, frames);
|
|
217
|
+
queueHandle = await directory.appendHandle(QUEUE_KEY);
|
|
218
|
+
queueFileBytes = await queueHandle.size();
|
|
219
|
+
}
|
|
220
|
+
function guarded(task) {
|
|
221
|
+
return serial.run(async () => {
|
|
222
|
+
if (closed) throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store is closed");
|
|
223
|
+
return task();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
readPosition: () => guarded(async () => {
|
|
228
|
+
const bytes = await directory.read(POSITION_KEY);
|
|
229
|
+
return bytes === null ? null : decodePosition(bytes);
|
|
230
|
+
}),
|
|
231
|
+
writePosition: (position) => guarded(async () => {
|
|
232
|
+
if (position === null) {
|
|
233
|
+
await directory.remove(POSITION_KEY);
|
|
234
|
+
} else {
|
|
235
|
+
await directory.atomicWrite(POSITION_KEY, encodePosition(position));
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
appendWrite: (write) => guarded(async () => {
|
|
239
|
+
const queued = { sequence: queue.nextSequence, documentId: write.documentId, document: write.document };
|
|
240
|
+
const frame = frameOf(encodeQueueRecord({ type: "write", write: queued }));
|
|
241
|
+
await appendDurably(queueHandle, [frame]);
|
|
242
|
+
queue.nextSequence += 1;
|
|
243
|
+
queue.writes.set(queued.sequence, queued);
|
|
244
|
+
queue.recordBytes.set(queued.sequence, frame.byteLength);
|
|
245
|
+
queueFileBytes += frame.byteLength;
|
|
246
|
+
return queued;
|
|
247
|
+
}),
|
|
248
|
+
queuedWrites: () => guarded(async () => [...queue.writes.values()].sort((a, b) => a.sequence - b.sequence)),
|
|
249
|
+
removeWrites: (sequences) => guarded(async () => {
|
|
250
|
+
const present = sequences.filter((sequence) => queue.writes.has(sequence));
|
|
251
|
+
if (present.length === 0) return;
|
|
252
|
+
const frame = frameOf(encodeQueueRecord({ type: "removed", sequences: present }));
|
|
253
|
+
await appendDurably(queueHandle, [frame]);
|
|
254
|
+
queueFileBytes += frame.byteLength;
|
|
255
|
+
for (const sequence of present) {
|
|
256
|
+
queue.writes.delete(sequence);
|
|
257
|
+
queue.recordBytes.delete(sequence);
|
|
258
|
+
}
|
|
259
|
+
if (queueFileBytes > QUEUE_COMPACTION_BYTES && liveQueueBytes() * 2 < queueFileBytes) await compactQueue();
|
|
260
|
+
}),
|
|
261
|
+
keepEntries: (entries) => guarded(async () => {
|
|
262
|
+
if (entries.length === 0) return;
|
|
263
|
+
await appendDurably(keptHandle, [frameOf(encodeKeptEntries(entries))]);
|
|
264
|
+
}),
|
|
265
|
+
keptEntries: () => guarded(async () => {
|
|
266
|
+
const bytes = await directory.read(KEPT_KEY) ?? new Uint8Array(0);
|
|
267
|
+
const kept = [];
|
|
268
|
+
for (const payload of readFrames(bytes).payloads) kept.push(...decodeKeptEntries(payload));
|
|
269
|
+
return kept;
|
|
270
|
+
}),
|
|
271
|
+
clearKeptEntries: () => guarded(async () => {
|
|
272
|
+
await keptHandle.close();
|
|
273
|
+
await directory.remove(KEPT_KEY);
|
|
274
|
+
keptHandle = await directory.appendHandle(KEPT_KEY);
|
|
275
|
+
}),
|
|
276
|
+
appendDownload: (entityTag, offset, chunk) => guarded(() => download.append(entityTag, offset, chunk)),
|
|
277
|
+
readDownload: () => guarded(async () => download.read()),
|
|
278
|
+
clearDownload: () => guarded(() => download.clear()),
|
|
279
|
+
close: () => serial.run(async () => {
|
|
280
|
+
if (closed) return;
|
|
281
|
+
closed = true;
|
|
282
|
+
await Promise.allSettled([queueHandle.close(), keptHandle.close(), download.close()]);
|
|
283
|
+
await lock?.release();
|
|
284
|
+
})
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { createFilesystemDeviceStore };
|