@delali/narsil 0.3.1-next.153 → 0.3.1-next.154
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 +2 -1
- package/dist/adapters/filesystem.mjs +2 -2
- package/dist/adapters/gcs.mjs +2 -2
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/s3.mjs +2 -2
- package/dist/{analysis-change-2OYM7ARW.mjs → analysis-change-4GCRVRBW.mjs} +27 -18
- package/dist/{react-native/chunks/analysis-change-entry-CXNRW324.mjs → analysis-change-entry-KYGSXW4K.mjs} +1 -1
- package/dist/browser/{analysis-change-2V2HZ2NY.mjs → analysis-change-IXWPXXJJ.mjs} +17 -7
- package/dist/{analysis-change-entry-QD7YNDEE.mjs → browser/analysis-change-entry-FCSHFQSS.mjs} +1 -1
- package/dist/browser/{chunk-TQ5UMFG5.mjs → chunk-2FX6ROWR.mjs} +15 -6
- package/dist/browser/{chunk-KWYQ6KX4.mjs → chunk-2SHAKW2Z.mjs} +119 -1922
- package/dist/browser/{chunk-55WYRLDZ.mjs → chunk-3U3QR5YP.mjs} +2 -2
- package/dist/browser/chunk-4PD752F6.mjs +85 -0
- package/dist/browser/chunk-5W3MMTLG.mjs +19 -0
- package/dist/browser/{chunk-IAXZAVYL.mjs → chunk-7MEYN7V6.mjs} +1 -151
- package/dist/browser/chunk-7TTWXUH6.mjs +1828 -0
- package/dist/browser/{chunk-CSCKZBVJ.mjs → chunk-AJ4HHOVT.mjs} +4 -4
- package/dist/{react-native/chunks/chunk-DFQJ4IJB.mjs → browser/chunk-AYY6PIKL.mjs} +2 -2
- package/dist/browser/{chunk-VD7JEUIR.mjs → chunk-C4KS2QNF.mjs} +9 -8
- package/dist/browser/chunk-DSXIBE6N.mjs +78 -0
- package/dist/browser/chunk-ELV4OZOI.mjs +29 -0
- package/dist/browser/{chunk-PM4MUM5N.mjs → chunk-EUNBNLKM.mjs} +6 -5
- package/dist/browser/{chunk-GJKXW3SF.mjs → chunk-G7LUMBSG.mjs} +137 -253
- package/dist/browser/{chunk-B3JM6Z74.mjs → chunk-H6QFBMVE.mjs} +3 -2
- package/dist/browser/chunk-J433A7P3.mjs +241 -0
- package/dist/browser/chunk-ML6HY7T7.mjs +96 -0
- package/dist/browser/chunk-ML7THVLJ.mjs +38 -0
- package/dist/{chunk-MDF6PDIA.mjs → browser/chunk-MYITLCHT.mjs} +7 -1
- package/dist/browser/{chunk-QJCO3TJU.mjs → chunk-QXTPSX2H.mjs} +9 -150
- package/dist/browser/{chunk-MPK76GVS.mjs → chunk-RA6LSBCM.mjs} +1 -21
- package/dist/browser/{chunk-7ZJTRUVW.mjs → chunk-SIR3LMTV.mjs} +2 -2
- package/dist/browser/{chunk-LURXVCHG.mjs → chunk-SJB6VIZG.mjs} +1 -1
- package/dist/browser/chunk-TTD27VXX.mjs +298 -0
- package/dist/browser/chunk-U2E3HMYW.mjs +151 -0
- package/dist/browser/{chunk-2A2IPRC3.mjs → chunk-VCOYGVP7.mjs} +5 -31
- package/dist/browser/chunk-VI7BQR4U.mjs +21 -0
- package/dist/browser/chunk-W5X2UFWQ.mjs +102 -0
- package/dist/browser/{chunk-HT7J73QL.mjs → chunk-XRV72TJD.mjs} +2 -2
- package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
- package/dist/browser/chunk-ZI2V4VD7.mjs +21 -0
- package/dist/{react-native/chunks/chunk-QC4ZRBSX.mjs → browser/chunk-ZPTA75ZC.mjs} +2 -79
- package/dist/browser/{cold-module-YECAK4MN.mjs → cold-module-VTUGDYNY.mjs} +20 -14
- package/dist/browser/{durability-wiring-LM7WFL6X.mjs → durability-wiring-GL4A7KDV.mjs} +1886 -1364
- package/dist/browser/import-YI5GNB4H.mjs +17 -0
- package/dist/browser/methods-LMUTS7OI.mjs +30 -0
- package/dist/browser/{module-XQLEOYNM.mjs → module-EC3FYW7N.mjs} +9 -8
- package/dist/browser/{module-KAMRAJLE.mjs → module-M4JNBV6V.mjs} +16 -10
- package/dist/browser/operations-WVYLF72Q.mjs +5 -0
- package/dist/browser/{phrase-module-CNKMUY4U.mjs → phrase-module-NPYUVX75.mjs} +1 -1
- package/dist/browser/{pool-DTYSPBMQ.mjs → pool-WCGDZHJP.mjs} +3 -2
- package/dist/{restore-queue-AOF5OTQV.mjs → browser/restore-queue-TYIGDL5L.mjs} +2 -2
- package/dist/browser/retention-6QMRS5VK.mjs +207 -0
- package/dist/browser/{runtime-D2ULZGCN.mjs → runtime-3EW2AGB6.mjs} +1 -1
- package/dist/browser/{snapshot-UGZVMP4H.mjs → snapshot-DN3CRVUQ.mjs} +38 -307
- package/dist/browser/sync-state-P5XG6LTQ.mjs +15 -0
- package/dist/browser/{write-I5P5MW4O.mjs → write-WAWAFGKQ.mjs} +16 -11
- package/dist/{capabilities-BT-HLDC8.d.ts → capabilities-B3Brs1Rc.d.ts} +62 -7
- package/dist/{chunk-DGRM4EZZ.mjs → chunk-37IVJLP6.mjs} +1 -1
- package/dist/{chunk-KYVRZAYP.mjs → chunk-3A5KI24C.mjs} +2 -69
- package/dist/{chunk-POUYICOU.mjs → chunk-3OFU3NJT.mjs} +1 -1
- package/dist/{chunk-3TVDTACC.mjs → chunk-3Y3J4V2R.mjs} +1 -1
- package/dist/{chunk-FNBNZCGP.mjs → chunk-466PYR4P.mjs} +2 -2
- package/dist/{chunk-SEAJS664.mjs → chunk-4HWZV5MK.mjs} +5 -5
- package/dist/{chunk-UGVUW27S.mjs → chunk-5FUOVJKG.mjs} +13 -9
- package/dist/{chunk-ZHAXP7SD.mjs → chunk-5KGYQT6W.mjs} +6 -235
- package/dist/{chunk-NPXVQS33.mjs → chunk-62G63NMH.mjs} +4 -3
- package/dist/chunk-6MSZ543Y.mjs +32 -0
- package/dist/chunk-7GXJUJ24.mjs +49 -0
- package/dist/{chunk-3E4RRF5J.mjs → chunk-7HCZWC7B.mjs} +58 -8
- package/dist/{chunk-6RKSY3BX.mjs → chunk-7NTMUDC5.mjs} +5 -5
- package/dist/chunk-7QUGDVFC.mjs +101 -0
- package/dist/{chunk-G5KHSM6E.mjs → chunk-AO2FAYIZ.mjs} +1 -1
- package/dist/chunk-B7S6YEBP.mjs +102 -0
- package/dist/{chunk-AWNHDBKV.mjs → chunk-BPSKLCS7.mjs} +15 -7
- package/dist/chunk-BUMREPLU.mjs +15 -0
- package/dist/{chunk-T4CJDBBE.mjs → chunk-C6ASEFZI.mjs} +1 -1
- package/dist/{chunk-NITCPDFL.mjs → chunk-C73JLU4E.mjs} +2 -2
- package/dist/{chunk-NYSONUB7.mjs → chunk-CP5RRPJR.mjs} +1 -1
- package/dist/{chunk-TTCKT2RT.mjs → chunk-DMQPFLGI.mjs} +134 -11
- package/dist/{chunk-3SBJVQLL.mjs → chunk-DVWYODEB.mjs} +2 -2
- package/dist/chunk-ECX4SGX6.mjs +167 -0
- package/dist/chunk-GES7U2PM.mjs +68 -0
- package/dist/{chunk-NVTFQFUL.mjs → chunk-HVKXNBFL.mjs} +1 -1
- package/dist/chunk-HVYICDY3.mjs +214 -0
- package/dist/{chunk-3HV7M5OJ.mjs → chunk-HWEDFLB7.mjs} +9 -133
- package/dist/{chunk-52QQWEBS.mjs → chunk-IBNLW3AV.mjs} +21 -6
- package/dist/chunk-IJU7LL7D.mjs +242 -0
- package/dist/chunk-IPN7S4KX.mjs +130 -0
- package/dist/{chunk-5QMHMELB.mjs → chunk-IQ4R2I6N.mjs} +4 -1
- package/dist/chunk-JCLTESFN.mjs +96 -0
- package/dist/{chunk-J4BDAH2W.mjs → chunk-JFNKIBDT.mjs} +2 -2
- package/dist/{chunk-LDGGR7YT.mjs → chunk-K4B7OH65.mjs} +2 -2
- package/dist/{chunk-7TE2AJIH.mjs → chunk-K7KLL263.mjs} +13 -10
- package/dist/{chunk-CSHHU7PA.mjs → chunk-KCUIFVVW.mjs} +11 -30
- package/dist/{react-native/chunks/chunk-YH7W556M.mjs → chunk-KUZKUONM.mjs} +11 -2
- package/dist/chunk-KYYABCSW.mjs +72 -0
- package/dist/{chunk-B2FTZNNF.mjs → chunk-LKUE5GXS.mjs} +34 -14
- package/dist/{chunk-2PNYKG2D.mjs → chunk-LSM2YTKM.mjs} +100 -335
- package/dist/{chunk-DMNPYF54.mjs → chunk-LTUGDMV4.mjs} +2 -2
- package/dist/{chunk-FDG4KXX5.mjs → chunk-MLHNSAPK.mjs} +5 -3
- package/dist/{chunk-VP6XRMWR.mjs → chunk-MMBEANB2.mjs} +6 -32
- package/dist/{chunk-LJ4ENXOD.mjs → chunk-MMEMEUOO.mjs} +2 -2
- package/dist/{chunk-2HJWQPR6.mjs → chunk-NTZOXVUZ.mjs} +6 -122
- package/dist/{chunk-5WB2A3XU.mjs → chunk-NZMAXR2S.mjs} +397 -24
- package/dist/{chunk-IZT3G24Q.mjs → chunk-O43Z4MS6.mjs} +2 -2
- package/dist/{chunk-U46IZNCW.mjs → chunk-OKX2BBNW.mjs} +3 -2
- package/dist/{chunk-RBEHLIKX.mjs → chunk-PFKM7VNZ.mjs} +14 -8
- package/dist/chunk-PGVPE7GJ.mjs +96 -0
- package/dist/chunk-Q3TCTQCC.mjs +85 -0
- package/dist/chunk-Q7MS6P2J.mjs +74 -0
- package/dist/chunk-QDZJM7NI.mjs +23 -0
- package/dist/{chunk-ZS6CMXAE.mjs → chunk-QKZHLADX.mjs} +89 -250
- package/dist/{chunk-IJSFWGVW.mjs → chunk-REL7LFLR.mjs} +3 -3
- package/dist/chunk-RVKFI3A2.mjs +237 -0
- package/dist/chunk-S2N75OTN.mjs +83 -0
- package/dist/chunk-TRISKD4Q.mjs +50 -0
- package/dist/{chunk-6F6USYII.mjs → chunk-TV2L3BN7.mjs} +13 -11
- package/dist/{chunk-6BWLDLS3.mjs → chunk-URPCYQVJ.mjs} +1 -1
- package/dist/chunk-USR7FQRZ.mjs +34 -0
- package/dist/chunk-V6EUBAIT.mjs +19 -0
- package/dist/{chunk-SOUZMPME.mjs → chunk-VMXSVVXG.mjs} +7 -194
- package/dist/{chunk-4QCSHLNM.mjs → chunk-VREK3MYG.mjs} +3 -3
- package/dist/{chunk-YGQOPB2Z.mjs → chunk-WCBA2LVZ.mjs} +1 -1
- package/dist/{chunk-KQJVNPRM.mjs → chunk-X6NSJYQ3.mjs} +19 -16
- package/dist/chunk-Y4WPNHMC.mjs +50 -0
- package/dist/{chunk-IRWP524D.mjs → chunk-YBJDOA2T.mjs} +1 -1
- package/dist/{chunk-IJPK5PGM.mjs → chunk-YPUEV6ZC.mjs} +1 -1
- package/dist/{chunk-J7M73VY7.mjs → chunk-YROWNOMH.mjs} +1 -1
- package/dist/chunk-Z3TNWCI5.mjs +196 -0
- package/dist/{chunk-65WCV5JO.mjs → chunk-ZIFJXCKA.mjs} +1 -1
- package/dist/chunk-ZYAY26KG.mjs +29 -0
- package/dist/{client-Cn3gNxUU.d.ts → client-Df76GNKm.d.ts} +76 -6
- package/dist/client.d.ts +8 -7
- package/dist/client.mjs +56 -5
- package/dist/{cold-module-PYSSBIL7.mjs → cold-module-YLWMTTZG.mjs} +38 -28
- package/dist/{config-CfhH1IWQ.d.ts → config-05G_hy-1.d.ts} +3 -3
- package/dist/config-B8DP2VwR.d.ts +463 -0
- package/dist/{direct-executor-WYALQSMD.mjs → direct-executor-FI5GJHWX.mjs} +14 -9
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +4 -4
- package/dist/distribution/transport/in-memory.mjs +2 -2
- package/dist/distribution/transport/tcp.mjs +3 -3
- package/dist/distribution.d.ts +41 -9
- package/dist/distribution.mjs +1296 -117
- package/dist/{durability-wiring-7VBZEJLG.mjs → durability-wiring-RHLXDIVF.mjs} +1751 -1226
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-CJRUHXgf.d.ts → engine-DYu-e0oR.d.ts} +50 -40
- package/dist/{import-GJOMB2HC.mjs → import-SRBNC6TE.mjs} +27 -19
- package/dist/{index-MsF7e5hL.d.ts → index-nRqDM6uS.d.ts} +1 -1
- package/dist/index.browser.mjs +8 -4
- package/dist/index.d.ts +7 -6
- package/dist/index.mjs +24 -16
- package/dist/index.react-native.mjs +17 -11
- package/dist/{long-query-thread-SCUE62TO.mjs → long-query-thread-EMYTGSJP.mjs} +28 -15
- package/dist/methods-ABM5ELBR.mjs +30 -0
- package/dist/{module-AVQEIB7O.mjs → module-3OMJZUFT.mjs} +12 -12
- package/dist/{module-6RLIKSZQ.mjs → module-MG7JMV2U.mjs} +33 -23
- package/dist/operations-PGOAY2KS.mjs +5 -0
- package/dist/{paged-partition-archive-KGRW366Y.mjs → paged-partition-archive-UOLHOEZJ.mjs} +37 -26
- package/dist/partial-words.mjs +6 -4
- package/dist/pattern.mjs +4 -3
- package/dist/persistence/durability/checkpoint-worker.d.ts +9 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +34 -23
- package/dist/{phrase-module-OUQIRUQU.mjs → phrase-module-O3MDRQXP.mjs} +1 -1
- package/dist/{pool-UPV5PVPY.mjs → pool-CQXYPFLG.mjs} +2 -2
- package/dist/react-native/chunks/{analysis-change-DXPZRGWF.mjs → analysis-change-EAYO3Y6Q.mjs} +27 -15
- package/dist/{browser/analysis-change-entry-JL5U2N3Q.mjs → react-native/chunks/analysis-change-entry-TNLUC6IZ.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-D7LFYPYI.mjs → chunk-2CGSQM4O.mjs} +12 -10
- package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +1 -0
- package/dist/react-native/chunks/{chunk-R4OPUZQ5.mjs → chunk-3O57C2ZO.mjs} +2 -2
- package/dist/react-native/chunks/chunk-3XKMRNRE.mjs +298 -0
- package/dist/react-native/chunks/{chunk-IDFMNRIC.mjs → chunk-63YSZOXB.mjs} +97 -333
- package/dist/react-native/chunks/{chunk-UFNCLEQM.mjs → chunk-75VWIY35.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-2J2727V4.mjs → chunk-7GWPJDOA.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-PU55IOG4.mjs → chunk-AUT7PMA4.mjs} +6 -190
- package/dist/react-native/chunks/chunk-C2H2QQFW.mjs +288 -0
- package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +43 -0
- package/dist/{browser/chunk-PIS7ZAP7.mjs → react-native/chunks/chunk-CUNGPR5R.mjs} +11 -2
- package/dist/{browser/chunk-NVEJJP4R.mjs → react-native/chunks/chunk-DCKMICOB.mjs} +2 -79
- package/dist/react-native/chunks/chunk-DH3TVWWK.mjs +102 -0
- package/dist/react-native/chunks/{chunk-ZCKNBPQ4.mjs → chunk-EH5CFV6Z.mjs} +2 -2
- package/dist/react-native/chunks/chunk-F753DA54.mjs +23 -0
- package/dist/{browser/chunk-VBX2TI5V.mjs → react-native/chunks/chunk-GFYFQLJD.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-7IQR3SZO.mjs → chunk-I5PGWQJF.mjs} +142 -257
- package/dist/react-native/chunks/{chunk-NFGBOI46.mjs → chunk-IOY2SM2P.mjs} +1 -1
- package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +38 -0
- package/dist/react-native/chunks/{chunk-TLYD7IJ2.mjs → chunk-JPAJWO6D.mjs} +1 -1
- package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +15 -0
- package/dist/react-native/chunks/{chunk-KLZGAOLT.mjs → chunk-JX2RIAXH.mjs} +4 -4
- package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +68 -0
- package/dist/react-native/chunks/{chunk-LQAKO5QV.mjs → chunk-NCJS3WIY.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-BRNAVOKP.mjs → chunk-NKIZX26F.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-CLE3LZ77.mjs → chunk-NP7DD4G5.mjs} +5 -4
- package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +78 -0
- package/dist/react-native/chunks/chunk-O32RB3BL.mjs +191 -0
- package/dist/react-native/chunks/{chunk-DKJTZ625.mjs → chunk-OQQVRWZ2.mjs} +2 -69
- package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +29 -0
- package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
- package/dist/react-native/chunks/{chunk-LRGWK367.mjs → chunk-RVAEBN74.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-KOCTCUXW.mjs → chunk-RYMDHGL4.mjs} +16 -8
- package/dist/react-native/chunks/chunk-SJWDBRNP.mjs +85 -0
- package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +68 -0
- package/dist/react-native/chunks/chunk-UWDNZDWK.mjs +242 -0
- package/dist/react-native/chunks/{chunk-FS7BYE23.mjs → chunk-VQSKZ3EZ.mjs} +9 -152
- package/dist/react-native/chunks/{chunk-UCJU6WNH.mjs → chunk-VVFYOADG.mjs} +7 -6
- package/dist/react-native/chunks/{chunk-VGUWIZFQ.mjs → chunk-YBEW6YTR.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-JYL35A4A.mjs → chunk-YHKZSLOC.mjs} +7 -33
- package/dist/react-native/chunks/{chunk-3CTWSQRW.mjs → chunk-ZBSWRSBG.mjs} +4 -30
- package/dist/react-native/chunks/chunk-ZYDKJXQJ.mjs +96 -0
- package/dist/react-native/chunks/{cold-module-KFGEWYEL.mjs → cold-module-TJL6AFAD.mjs} +29 -21
- package/dist/react-native/chunks/{durability-wiring-QKJB2QBT.mjs → durability-wiring-RRDYJLLM.mjs} +1882 -1358
- package/dist/react-native/chunks/gzip.react-native-DNB5YNFA.mjs +3 -0
- package/dist/react-native/chunks/import-JYBMEJPQ.mjs +29 -0
- package/dist/react-native/chunks/methods-X6F36SJE.mjs +30 -0
- package/dist/react-native/chunks/module-QT5HZAY4.mjs +33 -0
- package/dist/react-native/chunks/{module-UJ5VUARS.mjs → module-S4DKSWMF.mjs} +10 -9
- package/dist/react-native/chunks/operations-RYKTSZQA.mjs +5 -0
- package/dist/react-native/chunks/{phrase-module-76UAPPSG.mjs → phrase-module-JZ37TB7N.mjs} +1 -1
- package/dist/react-native/chunks/{pool-CD4ANYUI.mjs → pool-RTGXJXPU.mjs} +3 -2
- package/dist/{browser/restore-queue-UQ6AAUVX.mjs → react-native/chunks/restore-queue-ZBVIKJWI.mjs} +2 -2
- package/dist/react-native/chunks/retention-PPCTP2VY.mjs +219 -0
- package/dist/react-native/chunks/{runtime-3MCDLJAF.mjs → runtime-KUATOLYB.mjs} +1 -1
- package/dist/react-native/chunks/{snapshot-KVBD4LRC.mjs → snapshot-ZBIEOZTZ.mjs} +47 -314
- package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +15 -0
- package/dist/react-native/chunks/{write-ES5A3WUA.mjs → write-2W4FTX7J.mjs} +25 -18
- package/dist/react-native/partial-words.mjs +6 -4
- package/dist/react-native/pattern.mjs +4 -3
- package/dist/react-native/sync.mjs +2236 -0
- package/dist/react-native/synonyms.mjs +7 -4
- package/dist/react.d.ts +10 -9
- package/dist/react.mjs +7 -1
- package/dist/{rerank-3W54N6P2.mjs → rerank-IZOB6NII.mjs} +4 -4
- package/dist/rerankers/http.mjs +2 -2
- package/dist/{react-native/chunks/restore-queue-H5VCN453.mjs → restore-queue-COI2GSSK.mjs} +2 -2
- package/dist/retention-55WA7GPU.mjs +58 -0
- package/dist/{runtime-L2DZYY6N.mjs → runtime-UZOC3NPY.mjs} +5 -5
- package/dist/{schema-D33CyXCy.d.ts → schema-DDauvDOv.d.ts} +1 -1
- package/dist/server.d.ts +22 -19
- package/dist/server.mjs +868 -50
- package/dist/{snapshot-WMX6JCLP.mjs → snapshot-NFX2EYN2.mjs} +62 -36
- package/dist/sync/filesystem.d.ts +30 -0
- package/dist/sync/filesystem.mjs +271 -0
- package/dist/sync/indexeddb.d.ts +30 -0
- package/dist/sync/indexeddb.mjs +237 -0
- package/dist/sync-state-ZWHLAFLE.mjs +15 -0
- package/dist/{config-aIsy7mcL.d.ts → sync-uXR7MmM7.d.ts} +53 -444
- package/dist/sync.browser.mjs +2231 -0
- package/dist/sync.d.ts +23 -0
- package/dist/sync.mjs +2206 -0
- package/dist/synonyms.mjs +5 -3
- package/dist/{tasks-C4ElXr4P.d.ts → tasks-BShx8pdK.d.ts} +4 -4
- package/dist/thread-P2G2FWM2.mjs +44 -0
- package/dist/types-SnO7_tAI.d.ts +228 -0
- package/dist/vector/search-worker.d.ts +1 -1
- package/dist/vector/search-worker.mjs +6 -6
- package/dist/workers/entry.mjs +7 -7
- package/dist/{write-SKJ6HW7O.mjs → write-FGB62BHQ.mjs} +31 -23
- package/openapi.json +119 -3
- package/package.json +28 -8
- package/dist/browser/import-QOY6ZH6X.mjs +0 -12
- package/dist/chunk-7LDMWKP6.mjs +0 -209
- package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +0 -110
- package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +0 -3
- package/dist/react-native/chunks/import-XFBCCENV.mjs +0 -22
- package/dist/react-native/chunks/module-FHJ2GOBI.mjs +0 -25
- package/dist/thread-I7DVHHW7.mjs +0 -31
|
@@ -1,60 +1,76 @@
|
|
|
1
|
-
import { documentsOfPayloadV2 } from './chunk-
|
|
2
|
-
import { buildArchiveFromMemory, archiveStream, memoryCheckpointStore,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { indexMetadataOf, unpackIndexSnapshotEnvelope, loadSegmentedCheckpoint, writeMetadataEnvelope, deserializePayloadV1, SINGLE_NODE_PRIMARY_TERM } from './chunk-ZS6CMXAE.mjs';
|
|
6
|
-
import { readVectorFile, readGraphParts } from './chunk-6RKSY3BX.mjs';
|
|
7
|
-
import { restoredConfigFields, restoredEmbedding, rejectSnapshot } from './chunk-IRWP524D.mjs';
|
|
1
|
+
import { documentsOfPayloadV2 } from './chunk-466PYR4P.mjs';
|
|
2
|
+
import { buildArchiveFromMemory, archiveStream, memoryCheckpointStore, writeArchiveFile } from './chunk-RVKFI3A2.mjs';
|
|
3
|
+
import { indexMetadataOf, unpackIndexSnapshotEnvelope, loadSegmentedCheckpoint, writeMetadataEnvelope, deserializePayloadV1, SINGLE_NODE_PRIMARY_TERM } from './chunk-QKZHLADX.mjs';
|
|
4
|
+
import { readVectorFile, readGraphParts } from './chunk-7NTMUDC5.mjs';
|
|
8
5
|
import './chunk-ZXNNR73R.mjs';
|
|
9
|
-
import './chunk-
|
|
10
|
-
import './chunk-IJSFWGVW.mjs';
|
|
6
|
+
import './chunk-REL7LFLR.mjs';
|
|
11
7
|
import './chunk-MATMVH65.mjs';
|
|
12
8
|
import './chunk-VD7J552I.mjs';
|
|
13
|
-
import {
|
|
14
|
-
import './chunk-
|
|
15
|
-
import './chunk-
|
|
9
|
+
import { requireRestoreMemory, earlierSnapshotFootprint, storedBytesOfSegments, archiveFootprint } from './chunk-MMBEANB2.mjs';
|
|
10
|
+
import { restoredConfigFields, restoredEmbedding, rejectSnapshot } from './chunk-YBJDOA2T.mjs';
|
|
11
|
+
import { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
|
|
12
|
+
import { MAX_SNAPSHOT_ANALYSIS_ATTEMPTS } from './chunk-ZYAY26KG.mjs';
|
|
13
|
+
import { createByteReader } from './chunk-CZQ33DLW.mjs';
|
|
14
|
+
import { readSnapshotArchive } from './chunk-5KGYQT6W.mjs';
|
|
15
|
+
import './chunk-IJU7LL7D.mjs';
|
|
16
|
+
import { newSyncEpoch } from './chunk-BUMREPLU.mjs';
|
|
17
|
+
import './chunk-LTUGDMV4.mjs';
|
|
18
|
+
import { decodeVectorIndexParts, bytesToVectors } from './chunk-AO2FAYIZ.mjs';
|
|
19
|
+
import './chunk-BPSKLCS7.mjs';
|
|
16
20
|
import './chunk-DJHHF2L5.mjs';
|
|
17
|
-
import './chunk-
|
|
21
|
+
import './chunk-37CD3OKS.mjs';
|
|
22
|
+
import './chunk-X6NSJYQ3.mjs';
|
|
23
|
+
import { encodeSegmentManifest } from './chunk-TRISKD4Q.mjs';
|
|
18
24
|
import './chunk-JDDXV6UF.mjs';
|
|
19
|
-
import { readSegmentFile } from './chunk-
|
|
20
|
-
import './chunk-
|
|
21
|
-
import
|
|
22
|
-
import './chunk-
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import './chunk-KAKQ74LS.mjs';
|
|
25
|
+
import { readSegmentFile } from './chunk-KCUIFVVW.mjs';
|
|
26
|
+
import './chunk-62G63NMH.mjs';
|
|
27
|
+
import './chunk-S2N75OTN.mjs';
|
|
28
|
+
import { manifestKey, manifestFileRefs } from './chunk-Q3TCTQCC.mjs';
|
|
29
|
+
import './chunk-QDZJM7NI.mjs';
|
|
30
|
+
import './chunk-IQ4R2I6N.mjs';
|
|
31
|
+
import { encodeIndexConfiguration, validateRequiredFieldsInSchema, validateEmbeddingConfig, storedArrayPositionGap, prepareStoredSynonyms, arrayPositionsAreStale, insertDocumentVectors } from './chunk-LSM2YTKM.mjs';
|
|
32
|
+
import { validatePatternValueLimit, requireSurfaceFormsForPartialFields } from './chunk-TV2L3BN7.mjs';
|
|
28
33
|
import './chunk-HJSN7UYG.mjs';
|
|
29
|
-
import './chunk-
|
|
34
|
+
import './chunk-URPCYQVJ.mjs';
|
|
30
35
|
import './chunk-XIHUI4KB.mjs';
|
|
31
|
-
import './chunk-Q2UL2TPC.mjs';
|
|
32
36
|
import './chunk-3MXV3VHR.mjs';
|
|
33
37
|
import './chunk-EEBCDP36.mjs';
|
|
34
|
-
import {
|
|
38
|
+
import { decodeEveryStoredDocument } from './chunk-5FUOVJKG.mjs';
|
|
39
|
+
import { ARRAY_POSITION_GAP, isCompositePartition } from './chunk-HWEDFLB7.mjs';
|
|
40
|
+
import { decodeIndexConfiguration } from './chunk-USR7FQRZ.mjs';
|
|
41
|
+
import { hasNrslMagic, HEADER_SIZE, readHeader } from './chunk-HVYICDY3.mjs';
|
|
42
|
+
import './chunk-IPN7S4KX.mjs';
|
|
43
|
+
import './chunk-KAKQ74LS.mjs';
|
|
44
|
+
import './chunk-7GXJUJ24.mjs';
|
|
45
|
+
import './chunk-Q2UL2TPC.mjs';
|
|
46
|
+
import './chunk-NTZOXVUZ.mjs';
|
|
35
47
|
import './chunk-X5CV2E2B.mjs';
|
|
48
|
+
import { emitSyncChange } from './chunk-Y4WPNHMC.mjs';
|
|
49
|
+
import { getLanguage, resolveIndexAnalysis } from './chunk-JCLTESFN.mjs';
|
|
36
50
|
import './chunk-TGP5M5R7.mjs';
|
|
37
51
|
import './chunk-U2BKYEC7.mjs';
|
|
38
|
-
import { loadVectorCodeFor } from './chunk-DGRM4EZZ.mjs';
|
|
39
52
|
import './chunk-QHPYS427.mjs';
|
|
40
53
|
import './chunk-QYRNLLLI.mjs';
|
|
54
|
+
import { loadVectorCodeFor } from './chunk-37IVJLP6.mjs';
|
|
41
55
|
import './chunk-ZXNQEW43.mjs';
|
|
42
56
|
import './chunk-KOKM4PQN.mjs';
|
|
43
|
-
import './chunk-
|
|
44
|
-
import './chunk-LQG5G2LY.mjs';
|
|
57
|
+
import './chunk-HVKXNBFL.mjs';
|
|
45
58
|
import './chunk-BTPGQC6Z.mjs';
|
|
59
|
+
import './chunk-LQG5G2LY.mjs';
|
|
46
60
|
import './chunk-RFBLQLLZ.mjs';
|
|
47
|
-
import './chunk-
|
|
61
|
+
import './chunk-OKX2BBNW.mjs';
|
|
48
62
|
import './chunk-JUKYYXSP.mjs';
|
|
49
|
-
import { raiseEarlierReleaseGraphSetting,
|
|
63
|
+
import { raiseEarlierReleaseGraphSetting, validateVectorPromotion, validateVectorStorage, validateTextStorage, parseVectorDimension } from './chunk-VMXSVVXG.mjs';
|
|
64
|
+
import { validateSchema, flattenSchema } from './chunk-Z3TNWCI5.mjs';
|
|
50
65
|
import './chunk-FQBFZAWG.mjs';
|
|
51
|
-
import './chunk-
|
|
66
|
+
import './chunk-ZIFJXCKA.mjs';
|
|
52
67
|
import './chunk-4UMZ7KQL.mjs';
|
|
53
68
|
import './chunk-ZXX5GZEX.mjs';
|
|
54
|
-
import './chunk-
|
|
69
|
+
import './chunk-GES7U2PM.mjs';
|
|
70
|
+
import './chunk-3A5KI24C.mjs';
|
|
55
71
|
import './chunk-L5ORED7V.mjs';
|
|
56
72
|
import { MAX_FILE_BYTES } from './chunk-U476IXKQ.mjs';
|
|
57
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
73
|
+
import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
|
|
58
74
|
import './chunk-R6A773WK.mjs';
|
|
59
75
|
import './chunk-YTJCGKM4.mjs';
|
|
60
76
|
import { decode } from '@msgpack/msgpack';
|
|
@@ -84,7 +100,7 @@ async function validateStagedCheckpoint(store, manifest) {
|
|
|
84
100
|
for (const ref of partition.segments) {
|
|
85
101
|
const { directory } = store;
|
|
86
102
|
if (directory !== void 0) {
|
|
87
|
-
const { checkPagedSegmentFully, isPagedSegmentFile } = await import('./module-
|
|
103
|
+
const { checkPagedSegmentFully, isPagedSegmentFile } = await import('./module-MG7JMV2U.mjs');
|
|
88
104
|
if (await isPagedSegmentFile(directory, ref.key)) {
|
|
89
105
|
requireSchemaOfManifest(ref.key, await checkPagedSegmentFully(directory, ref), manifest);
|
|
90
106
|
continue;
|
|
@@ -217,7 +233,8 @@ function restoredRegistryEntry(prepared, manager, deps) {
|
|
|
217
233
|
synonyms: prepared.synonyms?.encoded ?? null,
|
|
218
234
|
analysisGeneration: prepared.analysisGeneration,
|
|
219
235
|
pendingAnalysis: null,
|
|
220
|
-
durableAnalysis: null
|
|
236
|
+
durableAnalysis: null,
|
|
237
|
+
sync: null
|
|
221
238
|
};
|
|
222
239
|
}
|
|
223
240
|
|
|
@@ -358,6 +375,8 @@ async function stageMetadata(indexName, staging, entry) {
|
|
|
358
375
|
}
|
|
359
376
|
async function installRestoredIndex(indexName, restored, deps) {
|
|
360
377
|
const entry = restoredRegistryEntry(restored.prepared, restored.detached.manager, deps);
|
|
378
|
+
const previousSync = deps.indexRegistry.get(indexName)?.sync ?? null;
|
|
379
|
+
if (previousSync !== null) entry.sync = { ...previousSync, active: false, epoch: newSyncEpoch() };
|
|
361
380
|
let replaced;
|
|
362
381
|
try {
|
|
363
382
|
if (restored.staging !== null) await stageMetadata(indexName, restored.staging, entry);
|
|
@@ -375,9 +394,16 @@ async function installRestoredIndex(indexName, restored, deps) {
|
|
|
375
394
|
await durable.persistMetadata(indexName);
|
|
376
395
|
await durable.checkpoint(indexName);
|
|
377
396
|
}
|
|
397
|
+
if (previousSync !== null) {
|
|
398
|
+
const storage = durable?.syncStorage?.();
|
|
399
|
+
if (storage !== void 0)
|
|
400
|
+
await oneSyncChangeAtATime(deps.indexRegistry, indexName, () => storage.release(indexName));
|
|
401
|
+
emitSyncChange(deps.indexRegistry, { kind: "epoch", indexName });
|
|
402
|
+
}
|
|
378
403
|
if (replaced !== void 0) await deps.announceIndexDropped(indexName, replaced.config);
|
|
379
404
|
await deps.announceIndexCreated(indexName, restored.prepared.config);
|
|
380
405
|
for (const vectorIndex of restored.detached.manager.getVectorIndexes().values()) {
|
|
406
|
+
vectorIndex.scheduleBuild();
|
|
381
407
|
vectorIndex.startShuffledRebuildWhenDue();
|
|
382
408
|
}
|
|
383
409
|
}
|
|
@@ -452,7 +478,7 @@ async function stageArchive(indexName, reader, staging, deps) {
|
|
|
452
478
|
if (manifest === null) missingPart("manifest");
|
|
453
479
|
const { directory } = staging;
|
|
454
480
|
if (keepsTextOnDisk(prepared, staging) && directory !== void 0) {
|
|
455
|
-
const { bytesThatSegmentsHoldInMemory } = await import('./module-
|
|
481
|
+
const { bytesThatSegmentsHoldInMemory } = await import('./module-MG7JMV2U.mjs');
|
|
456
482
|
const replacesIndex = deps.indexRegistry.has(indexName);
|
|
457
483
|
const segmentBytes = await bytesThatSegmentsHoldInMemory(directory, manifest);
|
|
458
484
|
requireRestoreMemory(indexName, archiveFootprint(prepared, manifest, replacesIndex, segmentBytes), replacesIndex);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as DeviceSyncStore } from '../types-SnO7_tAI.js';
|
|
2
|
+
import '../sync-uXR7MmM7.js';
|
|
3
|
+
import '../schema-DDauvDOv.js';
|
|
4
|
+
import '../adapters-pljAqmrC.js';
|
|
5
|
+
import '../synonyms-CpOAHPa-.js';
|
|
6
|
+
import '../engine-DYu-e0oR.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,271 @@
|
|
|
1
|
+
import { replayQueue, decodeKeptEntries, encodeKeptEntries, encodeQueueRecord, encodePosition, decodePosition, decodeDownloadTag, downloadOutOfOrder, encodeDownloadTag } from '../chunk-7QUGDVFC.mjs';
|
|
2
|
+
import { createSerial, QUEUE_COMPACTION_BYTES, DOWNLOAD_FRAME_BYTES, STORE_FRAME_LIMIT_BYTES } from '../chunk-6MSZ543Y.mjs';
|
|
3
|
+
import '../chunk-BUMREPLU.mjs';
|
|
4
|
+
import { createDurableDirectory } from '../chunk-MLHNSAPK.mjs';
|
|
5
|
+
import '../chunk-BEZH7VEH.mjs';
|
|
6
|
+
import '../chunk-HLPRHOSO.mjs';
|
|
7
|
+
import '../chunk-QDZJM7NI.mjs';
|
|
8
|
+
import { crc32 } from '../chunk-7GXJUJ24.mjs';
|
|
9
|
+
import '../chunk-Q2UL2TPC.mjs';
|
|
10
|
+
import '../chunk-ZXNQEW43.mjs';
|
|
11
|
+
import '../chunk-U476IXKQ.mjs';
|
|
12
|
+
import { NarsilError, ErrorCodes } from '../chunk-KUZKUONM.mjs';
|
|
13
|
+
import '../chunk-R6A773WK.mjs';
|
|
14
|
+
import '../chunk-YTJCGKM4.mjs';
|
|
15
|
+
|
|
16
|
+
// src/sync/device/stores/frames.ts
|
|
17
|
+
var FRAME_HEADER_BYTES = 8;
|
|
18
|
+
function frameOf(payload) {
|
|
19
|
+
const frame = new Uint8Array(FRAME_HEADER_BYTES + payload.byteLength);
|
|
20
|
+
const view = new DataView(frame.buffer);
|
|
21
|
+
view.setUint32(0, payload.byteLength, false);
|
|
22
|
+
view.setUint32(4, crc32(payload), false);
|
|
23
|
+
frame.set(payload, FRAME_HEADER_BYTES);
|
|
24
|
+
return frame;
|
|
25
|
+
}
|
|
26
|
+
function readFrames(bytes) {
|
|
27
|
+
const payloads = [];
|
|
28
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
29
|
+
let at = 0;
|
|
30
|
+
while (at + FRAME_HEADER_BYTES <= bytes.byteLength) {
|
|
31
|
+
const length = view.getUint32(at, false);
|
|
32
|
+
const checksum = view.getUint32(at + 4, false);
|
|
33
|
+
const end = at + FRAME_HEADER_BYTES + length;
|
|
34
|
+
if (length > STORE_FRAME_LIMIT_BYTES || end > bytes.byteLength) break;
|
|
35
|
+
const payload = bytes.subarray(at + FRAME_HEADER_BYTES, end);
|
|
36
|
+
if (crc32(payload) !== checksum) break;
|
|
37
|
+
payloads.push(payload);
|
|
38
|
+
at = end;
|
|
39
|
+
}
|
|
40
|
+
return { payloads, cleanLength: at };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/sync/device/stores/filesystem-download.ts
|
|
44
|
+
var DOWNLOAD_TAG_KEY = "download.tag";
|
|
45
|
+
var DOWNLOAD_BYTES_KEY = "download.bin";
|
|
46
|
+
var FRAME_HEADER_BYTES2 = 8;
|
|
47
|
+
async function readHeader(readRange, at) {
|
|
48
|
+
const header = await readRange(DOWNLOAD_BYTES_KEY, at, FRAME_HEADER_BYTES2);
|
|
49
|
+
const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
50
|
+
return { length: view.getUint32(0, false), checksum: view.getUint32(4, false) };
|
|
51
|
+
}
|
|
52
|
+
async function scanFrames(readRange, onDisk) {
|
|
53
|
+
let savedLength = 0;
|
|
54
|
+
let fileLength = 0;
|
|
55
|
+
while (fileLength + FRAME_HEADER_BYTES2 <= onDisk) {
|
|
56
|
+
const header = await readHeader(readRange, fileLength);
|
|
57
|
+
const end = fileLength + FRAME_HEADER_BYTES2 + header.length;
|
|
58
|
+
if (header.length === 0 || header.length > DOWNLOAD_FRAME_BYTES || end > onDisk) break;
|
|
59
|
+
const payload = await readRange(DOWNLOAD_BYTES_KEY, fileLength + FRAME_HEADER_BYTES2, header.length);
|
|
60
|
+
if (crc32(payload) !== header.checksum) break;
|
|
61
|
+
savedLength += header.length;
|
|
62
|
+
fileLength = end;
|
|
63
|
+
}
|
|
64
|
+
return { savedLength, fileLength };
|
|
65
|
+
}
|
|
66
|
+
async function openFilesystemDownload(directory) {
|
|
67
|
+
const directoryReadRange = directory.readRange;
|
|
68
|
+
if (directoryReadRange === void 0) {
|
|
69
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store needs a directory that reads by position");
|
|
70
|
+
}
|
|
71
|
+
const readRange = (key, offset, length) => directoryReadRange.call(directory, key, offset, length);
|
|
72
|
+
let entityTag = null;
|
|
73
|
+
let savedLength = 0;
|
|
74
|
+
let fileLength = 0;
|
|
75
|
+
const tagBytes = await directory.read(DOWNLOAD_TAG_KEY);
|
|
76
|
+
if (tagBytes !== null) entityTag = decodeDownloadTag(tagBytes);
|
|
77
|
+
if (entityTag === null) {
|
|
78
|
+
await directory.remove(DOWNLOAD_BYTES_KEY);
|
|
79
|
+
} else {
|
|
80
|
+
const scanned = await scanFrames(readRange, await directory.byteLength?.(DOWNLOAD_BYTES_KEY) ?? 0);
|
|
81
|
+
savedLength = scanned.savedLength;
|
|
82
|
+
fileLength = scanned.fileLength;
|
|
83
|
+
}
|
|
84
|
+
let handle = await directory.appendHandle(DOWNLOAD_BYTES_KEY);
|
|
85
|
+
if (await handle.size() !== fileLength) await handle.truncate(fileLength);
|
|
86
|
+
async function reset(nextTag) {
|
|
87
|
+
await handle.close();
|
|
88
|
+
await directory.remove(DOWNLOAD_BYTES_KEY);
|
|
89
|
+
if (nextTag === null) {
|
|
90
|
+
await directory.remove(DOWNLOAD_TAG_KEY);
|
|
91
|
+
} else {
|
|
92
|
+
await directory.atomicWrite(DOWNLOAD_TAG_KEY, encodeDownloadTag(nextTag));
|
|
93
|
+
}
|
|
94
|
+
entityTag = nextTag;
|
|
95
|
+
savedLength = 0;
|
|
96
|
+
fileLength = 0;
|
|
97
|
+
handle = await directory.appendHandle(DOWNLOAD_BYTES_KEY);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
async append(tag, offset, chunk) {
|
|
101
|
+
if (offset === 0) {
|
|
102
|
+
await reset(tag);
|
|
103
|
+
} else if (tag !== entityTag || offset !== savedLength) {
|
|
104
|
+
throw downloadOutOfOrder(tag, offset, tag === entityTag ? savedLength : 0);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
for (let at = 0; at < chunk.byteLength; at += DOWNLOAD_FRAME_BYTES) {
|
|
108
|
+
await handle.append(frameOf(chunk.subarray(at, at + DOWNLOAD_FRAME_BYTES)));
|
|
109
|
+
}
|
|
110
|
+
await handle.sync();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
await handle.truncate(fileLength).catch(() => void 0);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
savedLength += chunk.byteLength;
|
|
116
|
+
fileLength = await handle.size();
|
|
117
|
+
},
|
|
118
|
+
read() {
|
|
119
|
+
const tag = entityTag;
|
|
120
|
+
if (tag === null || savedLength === 0) return null;
|
|
121
|
+
const framesEnd = fileLength;
|
|
122
|
+
return {
|
|
123
|
+
entityTag: tag,
|
|
124
|
+
byteLength: savedLength,
|
|
125
|
+
async *chunks() {
|
|
126
|
+
let at = 0;
|
|
127
|
+
while (at < framesEnd) {
|
|
128
|
+
const header = await readHeader(readRange, at);
|
|
129
|
+
yield await readRange(DOWNLOAD_BYTES_KEY, at + FRAME_HEADER_BYTES2, header.length);
|
|
130
|
+
at += FRAME_HEADER_BYTES2 + header.length;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
async clear() {
|
|
136
|
+
await reset(null);
|
|
137
|
+
},
|
|
138
|
+
async close() {
|
|
139
|
+
await handle.close();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/sync/device/stores/filesystem.ts
|
|
145
|
+
var POSITION_KEY = "position";
|
|
146
|
+
var QUEUE_KEY = "queue.log";
|
|
147
|
+
var KEPT_KEY = "kept.log";
|
|
148
|
+
async function openFramedLog(directory, key) {
|
|
149
|
+
const bytes = await directory.read(key) ?? new Uint8Array(0);
|
|
150
|
+
const { payloads, cleanLength } = readFrames(bytes);
|
|
151
|
+
const handle = await directory.appendHandle(key);
|
|
152
|
+
if (cleanLength !== bytes.byteLength) await handle.truncate(cleanLength);
|
|
153
|
+
return { handle, payloads };
|
|
154
|
+
}
|
|
155
|
+
async function appendDurably(handle, frames) {
|
|
156
|
+
const before = await handle.size();
|
|
157
|
+
try {
|
|
158
|
+
for (const frame of frames) await handle.append(frame);
|
|
159
|
+
await handle.sync();
|
|
160
|
+
} catch (error) {
|
|
161
|
+
await handle.truncate(before).catch(() => void 0);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function createFilesystemDeviceStore(config) {
|
|
166
|
+
if (typeof config.directory !== "string" || config.directory.trim().length === 0) {
|
|
167
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store needs a directory");
|
|
168
|
+
}
|
|
169
|
+
const directory = createDurableDirectory(config.directory);
|
|
170
|
+
const lock = await directory.lock?.() ?? null;
|
|
171
|
+
try {
|
|
172
|
+
return await openStore(directory, lock);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
await lock?.release().catch(() => void 0);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function openStore(directory, lock) {
|
|
179
|
+
const serial = createSerial();
|
|
180
|
+
const queueLog = await openFramedLog(directory, QUEUE_KEY);
|
|
181
|
+
const queue = replayQueue(queueLog.payloads);
|
|
182
|
+
let queueHandle = queueLog.handle;
|
|
183
|
+
let queueFileBytes = await queueHandle.size();
|
|
184
|
+
const keptLog = await openFramedLog(directory, KEPT_KEY);
|
|
185
|
+
let keptHandle = keptLog.handle;
|
|
186
|
+
const download = await openFilesystemDownload(directory);
|
|
187
|
+
let closed = false;
|
|
188
|
+
function liveQueueBytes() {
|
|
189
|
+
let total = 0;
|
|
190
|
+
for (const bytes of queue.recordBytes.values()) total += bytes;
|
|
191
|
+
return total;
|
|
192
|
+
}
|
|
193
|
+
async function compactQueue() {
|
|
194
|
+
const frames = [frameOf(encodeQueueRecord({ type: "next", sequence: queue.nextSequence }))];
|
|
195
|
+
for (const write of [...queue.writes.values()].sort((a, b) => a.sequence - b.sequence)) {
|
|
196
|
+
frames.push(frameOf(encodeQueueRecord({ type: "write", write })));
|
|
197
|
+
}
|
|
198
|
+
await queueHandle.close();
|
|
199
|
+
await directory.atomicWrite(QUEUE_KEY, frames);
|
|
200
|
+
queueHandle = await directory.appendHandle(QUEUE_KEY);
|
|
201
|
+
queueFileBytes = await queueHandle.size();
|
|
202
|
+
}
|
|
203
|
+
function guarded(task) {
|
|
204
|
+
return serial.run(async () => {
|
|
205
|
+
if (closed) throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The device sync store is closed");
|
|
206
|
+
return task();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
readPosition: () => guarded(async () => {
|
|
211
|
+
const bytes = await directory.read(POSITION_KEY);
|
|
212
|
+
return bytes === null ? null : decodePosition(bytes);
|
|
213
|
+
}),
|
|
214
|
+
writePosition: (position) => guarded(async () => {
|
|
215
|
+
if (position === null) {
|
|
216
|
+
await directory.remove(POSITION_KEY);
|
|
217
|
+
} else {
|
|
218
|
+
await directory.atomicWrite(POSITION_KEY, encodePosition(position));
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
appendWrite: (write) => guarded(async () => {
|
|
222
|
+
const queued = { sequence: queue.nextSequence, documentId: write.documentId, document: write.document };
|
|
223
|
+
const frame = frameOf(encodeQueueRecord({ type: "write", write: queued }));
|
|
224
|
+
await appendDurably(queueHandle, [frame]);
|
|
225
|
+
queue.nextSequence += 1;
|
|
226
|
+
queue.writes.set(queued.sequence, queued);
|
|
227
|
+
queue.recordBytes.set(queued.sequence, frame.byteLength);
|
|
228
|
+
queueFileBytes += frame.byteLength;
|
|
229
|
+
return queued;
|
|
230
|
+
}),
|
|
231
|
+
queuedWrites: () => guarded(async () => [...queue.writes.values()].sort((a, b) => a.sequence - b.sequence)),
|
|
232
|
+
removeWrites: (sequences) => guarded(async () => {
|
|
233
|
+
const present = sequences.filter((sequence) => queue.writes.has(sequence));
|
|
234
|
+
if (present.length === 0) return;
|
|
235
|
+
const frame = frameOf(encodeQueueRecord({ type: "removed", sequences: present }));
|
|
236
|
+
await appendDurably(queueHandle, [frame]);
|
|
237
|
+
queueFileBytes += frame.byteLength;
|
|
238
|
+
for (const sequence of present) {
|
|
239
|
+
queue.writes.delete(sequence);
|
|
240
|
+
queue.recordBytes.delete(sequence);
|
|
241
|
+
}
|
|
242
|
+
if (queueFileBytes > QUEUE_COMPACTION_BYTES && liveQueueBytes() * 2 < queueFileBytes) await compactQueue();
|
|
243
|
+
}),
|
|
244
|
+
keepEntries: (entries) => guarded(async () => {
|
|
245
|
+
if (entries.length === 0) return;
|
|
246
|
+
await appendDurably(keptHandle, [frameOf(encodeKeptEntries(entries))]);
|
|
247
|
+
}),
|
|
248
|
+
keptEntries: () => guarded(async () => {
|
|
249
|
+
const bytes = await directory.read(KEPT_KEY) ?? new Uint8Array(0);
|
|
250
|
+
const kept = [];
|
|
251
|
+
for (const payload of readFrames(bytes).payloads) kept.push(...decodeKeptEntries(payload));
|
|
252
|
+
return kept;
|
|
253
|
+
}),
|
|
254
|
+
clearKeptEntries: () => guarded(async () => {
|
|
255
|
+
await keptHandle.close();
|
|
256
|
+
await directory.remove(KEPT_KEY);
|
|
257
|
+
keptHandle = await directory.appendHandle(KEPT_KEY);
|
|
258
|
+
}),
|
|
259
|
+
appendDownload: (entityTag, offset, chunk) => guarded(() => download.append(entityTag, offset, chunk)),
|
|
260
|
+
readDownload: () => guarded(async () => download.read()),
|
|
261
|
+
clearDownload: () => guarded(() => download.clear()),
|
|
262
|
+
close: () => serial.run(async () => {
|
|
263
|
+
if (closed) return;
|
|
264
|
+
closed = true;
|
|
265
|
+
await Promise.allSettled([queueHandle.close(), keptHandle.close(), download.close()]);
|
|
266
|
+
await lock?.release();
|
|
267
|
+
})
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export { createFilesystemDeviceStore };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as DeviceSyncStore } from '../types-SnO7_tAI.js';
|
|
2
|
+
import '../sync-uXR7MmM7.js';
|
|
3
|
+
import '../schema-DDauvDOv.js';
|
|
4
|
+
import '../adapters-pljAqmrC.js';
|
|
5
|
+
import '../synonyms-CpOAHPa-.js';
|
|
6
|
+
import '../engine-DYu-e0oR.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The settings of {@link createIndexedDBDeviceStore}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
interface IndexedDBDeviceStoreConfig {
|
|
14
|
+
/** The store keeps its records in the IndexedDB database with this name, `narsil-device-sync` by default. */
|
|
15
|
+
databaseName?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Opens a store that keeps a synced device's queue, kept feed entries, position, and snapshot download in IndexedDB,
|
|
19
|
+
* for an app in a browser.
|
|
20
|
+
*
|
|
21
|
+
* The store commits every write in a strict-durability transaction before its promise resolves.
|
|
22
|
+
*
|
|
23
|
+
* @param config - The database to use. Omit it to accept the default name.
|
|
24
|
+
* @returns The open store, which {@link DeviceSyncStore.close} releases.
|
|
25
|
+
* @throws A `NarsilError` with `CONFIG_INVALID` in a runtime without IndexedDB.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
declare function createIndexedDBDeviceStore(config?: IndexedDBDeviceStoreConfig): Promise<DeviceSyncStore>;
|
|
29
|
+
|
|
30
|
+
export { type IndexedDBDeviceStoreConfig, createIndexedDBDeviceStore };
|