mcard-js 2.1.41 → 2.1.43

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.
Files changed (388) hide show
  1. package/dist/{CardCollection-MXTUJV4J.js → CardCollection-7DKJWKAG.js} +3 -2
  2. package/dist/CardCollection-S4RE3RXP.js +10 -0
  3. package/dist/CardCollection-VPN7AAAX.js +10 -0
  4. package/dist/{IndexedDBEngine-2G5KCISA.js → IndexedDBEngine-7JOGM2MM.js} +3 -2
  5. package/dist/IndexedDBEngine-BGZHJK5L.js +12 -0
  6. package/dist/IndexedDBEngine-ZJ442GI7.js +12 -0
  7. package/dist/{LLMRuntime-GIGDMDEZ.js → LLMRuntime-OZNVAPXJ.js} +4 -3
  8. package/dist/{LLMRuntime-LBWUJ7ON.js → LLMRuntime-UPSEDSIK.js} +2 -2
  9. package/dist/{LambdaRuntime-B6D6IQKZ.js → LambdaRuntime-JZ4Q56TI.js} +6 -5
  10. package/dist/LambdaRuntime-PM3OUFHU.js +19 -0
  11. package/dist/LambdaRuntime-WBEK37AF.js +19 -0
  12. package/dist/LambdaRuntime-YKSBAT65.js +19 -0
  13. package/dist/{Loader-3LSJXJQG.js → Loader-7HQVYDPA.js} +2 -2
  14. package/dist/{Loader-BM56B2TX.js → Loader-NYWTV7CQ.js} +4 -3
  15. package/dist/{Loader-CYLAA4XU.js → Loader-OLKPY6HT.js} +3 -3
  16. package/dist/{MCard-H56VOJLR.js → MCard-OYI73CUI.js} +1 -1
  17. package/dist/{MCard-5LIREV2B.js → MCard-XHG3BZC7.js} +2 -2
  18. package/dist/{NetworkRuntime-IAFHPQSX.js → NetworkRuntime-VYCC5HSY.js} +16 -11
  19. package/dist/{NetworkRuntime-JNGKW3DY.js → NetworkRuntime-XQX3LDDI.js} +61 -33
  20. package/dist/{NetworkRuntime-CXPKIAOQ.js → NetworkRuntime-XZR733M5.js} +17 -12
  21. package/dist/{OllamaProvider-QPX2JXL2.js → OllamaProvider-FBZ5WW72.js} +1 -1
  22. package/dist/OllamaProvider-W6TPZNHD.js +9 -0
  23. package/dist/chunk-2NFGZ6PA.js +170 -0
  24. package/dist/{chunk-VXV35I5J.js → chunk-4TYRTQ4V.js} +48 -17
  25. package/dist/chunk-4VWWTGRW.js +497 -0
  26. package/dist/{chunk-4PDYHPR6.js → chunk-5GHZP7E5.js} +4 -2
  27. package/dist/{chunk-42VF42KH.js → chunk-5HZNWJFT.js} +4 -2
  28. package/dist/{chunk-DEYMHG5A.js → chunk-6MG5ZHAP.js} +58 -22
  29. package/dist/{chunk-7V37AAPK.js → chunk-7B4PABOL.js} +16 -7
  30. package/dist/chunk-A5S2PI37.js +47 -0
  31. package/dist/chunk-BFD4WSWU.js +497 -0
  32. package/dist/chunk-BSEFN25Q.js +32 -0
  33. package/dist/{chunk-3LPY36OG.js → chunk-CBEVE7RG.js} +20 -15
  34. package/dist/{chunk-A5AB4WQN.js → chunk-DPA3ZK4Q.js} +30 -21
  35. package/dist/{chunk-5FA54AMM.js → chunk-EJHX3VZL.js} +54 -21
  36. package/dist/{chunk-QXPHMSPA.js → chunk-GNF4WAPV.js} +22 -9
  37. package/dist/{chunk-XPG6B5IW.js → chunk-JHIA2BQK.js} +26 -13
  38. package/dist/{chunk-4I5IZILN.js → chunk-KGPICAQW.js} +10 -7
  39. package/dist/{chunk-4WBJPHZP.js → chunk-MST5AZXJ.js} +17 -8
  40. package/dist/{chunk-K35KFTEA.js → chunk-N6KDHCBC.js} +58 -33
  41. package/dist/{chunk-2R4ESMZB.js → chunk-NFO5NU6B.js} +5 -3
  42. package/dist/chunk-OKWBHCKC.js +170 -0
  43. package/dist/{chunk-FIE4LAJG.js → chunk-OX3K6UZJ.js} +5 -3
  44. package/dist/{chunk-6SEX42H2.js → chunk-R3K7DG7O.js} +21 -16
  45. package/dist/chunk-RB35Z35T.js +44 -0
  46. package/dist/{chunk-AWGFLRLI.js → chunk-SP4YPKPR.js} +51 -318
  47. package/dist/chunk-U7TSFDKX.js +217 -0
  48. package/dist/chunk-UP3SQX56.js +112 -0
  49. package/dist/{chunk-4EUEU4SM.js → chunk-VGIRC3HX.js} +13 -110
  50. package/dist/chunk-WGG7526Z.js +112 -0
  51. package/dist/{chunk-3JBSRALP.js → chunk-WNKP66IR.js} +10 -7
  52. package/dist/{chunk-DOC55MPG.js → chunk-WR6ISHCS.js} +11 -3
  53. package/dist/{chunk-52UNWVOD.js → chunk-ZVOPQ5BM.js} +54 -21
  54. package/dist/chunk-ZZMOPQER.js +217 -0
  55. package/dist/index.browser.cjs +79 -1454
  56. package/dist/index.browser.d.cts +2 -17
  57. package/dist/index.browser.d.ts +2 -17
  58. package/dist/index.browser.js +7 -6
  59. package/dist/index.cjs +306 -1631
  60. package/dist/index.d.cts +3 -1
  61. package/dist/index.d.ts +3 -1
  62. package/dist/index.js +49 -35
  63. package/dist/storage/SqliteNodeEngine.cjs +59 -1335
  64. package/dist/storage/SqliteNodeEngine.js +4 -3
  65. package/dist/storage/SqliteWasmEngine.cjs +57 -1335
  66. package/dist/storage/SqliteWasmEngine.js +4 -3
  67. package/package.json +12 -8
  68. package/dist/CardCollection-4OFJ6XQJ.js +0 -9
  69. package/dist/CardCollection-7PDWM24F.js +0 -9
  70. package/dist/CardCollection-CEFQ5PA6.js +0 -9
  71. package/dist/CardCollection-GUEYGN2Y.js +0 -9
  72. package/dist/CardCollection-KDO4CQ4B.js +0 -9
  73. package/dist/CardCollection-PB7ZY73E.js +0 -9
  74. package/dist/CardCollection-RK4DVH63.js +0 -9
  75. package/dist/CardCollection-T376E3TS.js +0 -9
  76. package/dist/CardCollection-WGCKKUOD.js +0 -9
  77. package/dist/CardCollection-XON2IWDU.js +0 -9
  78. package/dist/CardCollection-ZEI6FMP3.js +0 -9
  79. package/dist/EventProducer-MW6QF4IO.js +0 -47
  80. package/dist/EventProducer-V7RY2KKR.js +0 -47
  81. package/dist/FileIO.d.ts +0 -44
  82. package/dist/FileIO.d.ts.map +0 -1
  83. package/dist/FileIO.js +0 -203
  84. package/dist/FileIO.js.map +0 -1
  85. package/dist/IndexedDBEngine-7JI2CL32.js +0 -10
  86. package/dist/IndexedDBEngine-7OHQIRTI.js +0 -10
  87. package/dist/IndexedDBEngine-E5YJQG4U.js +0 -10
  88. package/dist/IndexedDBEngine-NV625E7L.js +0 -10
  89. package/dist/IndexedDBEngine-RPQS7ILF.js +0 -10
  90. package/dist/IndexedDBEngine-S3ZWCSI7.js +0 -10
  91. package/dist/IndexedDBEngine-T7OC5GRR.js +0 -10
  92. package/dist/LLMRuntime-BKB3CLXM.js +0 -16
  93. package/dist/LLMRuntime-BQUUFLAB.js +0 -16
  94. package/dist/LLMRuntime-TNBC4JCB.js +0 -16
  95. package/dist/LambdaRuntime-4YILF3G7.js +0 -15
  96. package/dist/LambdaRuntime-53TPVENI.js +0 -16
  97. package/dist/LambdaRuntime-73BSWP2G.js +0 -16
  98. package/dist/LambdaRuntime-AL5SBDCA.js +0 -17
  99. package/dist/LambdaRuntime-BYBUI7H5.js +0 -17
  100. package/dist/LambdaRuntime-JDZP3HIQ.js +0 -17
  101. package/dist/LambdaRuntime-JEI7RVWG.js +0 -16
  102. package/dist/LambdaRuntime-LCTHBYMV.js +0 -17
  103. package/dist/LambdaRuntime-LDA3G7IR.js +0 -16
  104. package/dist/LambdaRuntime-LF4FR6YA.js +0 -16
  105. package/dist/LambdaRuntime-O7JBVHO2.js +0 -16
  106. package/dist/LambdaRuntime-OFOTT464.js +0 -17
  107. package/dist/LambdaRuntime-Q6ISCHAD.js +0 -16
  108. package/dist/LambdaRuntime-TCZ42XCB.js +0 -16
  109. package/dist/LambdaRuntime-UKUOKJIW.js +0 -17
  110. package/dist/LambdaRuntime-VKLON4IB.js +0 -17
  111. package/dist/LambdaRuntime-WNYDBTS6.js +0 -16
  112. package/dist/LambdaRuntime-WPTX76CX.js +0 -17
  113. package/dist/Loader-4P7PEBCL.js +0 -11
  114. package/dist/Loader-HQ3QKMYM.js +0 -11
  115. package/dist/Loader-NCATGB67.js +0 -11
  116. package/dist/Loader-NRHGDQBD.js +0 -11
  117. package/dist/Loader-RT4NI6AT.js +0 -11
  118. package/dist/Loader-SSRY57SS.js +0 -11
  119. package/dist/Loader-W72QZ3T7.js +0 -11
  120. package/dist/Loader-WECRIXQW.js +0 -11
  121. package/dist/Loader-XFBIHCQF.js +0 -11
  122. package/dist/Loader.d.ts +0 -34
  123. package/dist/Loader.d.ts.map +0 -1
  124. package/dist/Loader.js +0 -190
  125. package/dist/Loader.js.map +0 -1
  126. package/dist/MCard-4J6WSBRF.js +0 -8
  127. package/dist/MCard-E3MRPTJF.js +0 -8
  128. package/dist/MCard-FCOIB6BP.js +0 -8
  129. package/dist/MCard-G4HUWHY5.js +0 -8
  130. package/dist/MCard-HFL7AFIH.js +0 -8
  131. package/dist/MCard-JOW6RBSO.js +0 -8
  132. package/dist/MCard-M4LKN4U2.js +0 -8
  133. package/dist/MCard-VB7UDUTN.js +0 -8
  134. package/dist/MCard-WOHE6SX6.js +0 -8
  135. package/dist/NetworkRuntime-2H7AQITA.js +0 -1571
  136. package/dist/NetworkRuntime-3MIUBNOF.js +0 -1571
  137. package/dist/NetworkRuntime-AOE2EJIM.js +0 -1571
  138. package/dist/NetworkRuntime-BQMDBUDO.js +0 -1570
  139. package/dist/NetworkRuntime-GMANLCAB.js +0 -1542
  140. package/dist/NetworkRuntime-L7P4VCGK.js +0 -1542
  141. package/dist/NetworkRuntime-LC7SUAOF.js +0 -1542
  142. package/dist/NetworkRuntime-OJWCWPBI.js +0 -1570
  143. package/dist/NetworkRuntime-ZJ3B4T3A.js +0 -1542
  144. package/dist/OllamaProvider-32RC36HD.js +0 -8
  145. package/dist/OllamaProvider-MQXSXLCA.js +0 -8
  146. package/dist/OllamaProvider-Q45BMOVN.js +0 -8
  147. package/dist/SqliteNodeEngine-WKVFWBNH.js +0 -9
  148. package/dist/StorageAdapter-DdDUiIvH.d.cts +0 -391
  149. package/dist/StorageAdapter-DdDUiIvH.d.ts +0 -391
  150. package/dist/StorageAdapter-Dw1BeOam.d.cts +0 -380
  151. package/dist/StorageAdapter-Dw1BeOam.d.ts +0 -380
  152. package/dist/chunk-23GCCCXB.js +0 -402
  153. package/dist/chunk-2ECISK2I.js +0 -354
  154. package/dist/chunk-2MRBTM72.js +0 -354
  155. package/dist/chunk-2THXO6FH.js +0 -2313
  156. package/dist/chunk-2VNRWIBZ.js +0 -389
  157. package/dist/chunk-2VOQRXWH.js +0 -296
  158. package/dist/chunk-34AYBZRO.js +0 -920
  159. package/dist/chunk-37EEYISR.js +0 -372
  160. package/dist/chunk-3E2TKOCZ.js +0 -354
  161. package/dist/chunk-3MMMJ7NH.js +0 -1068
  162. package/dist/chunk-437JTYVP.js +0 -292
  163. package/dist/chunk-4MQINOOG.js +0 -1218
  164. package/dist/chunk-4UIWXZHY.js +0 -1049
  165. package/dist/chunk-53S2EZCY.js +0 -290
  166. package/dist/chunk-5BIDGXA6.js +0 -987
  167. package/dist/chunk-5HXLTWYN.js +0 -296
  168. package/dist/chunk-5W2FDGUF.js +0 -371
  169. package/dist/chunk-6R4ERZMG.js +0 -1136
  170. package/dist/chunk-74YSNHEM.js +0 -2309
  171. package/dist/chunk-7H2BQZDK.js +0 -270
  172. package/dist/chunk-7KEWCCES.js +0 -1136
  173. package/dist/chunk-7PN2BUYF.js +0 -371
  174. package/dist/chunk-A2ZJA2EV.js +0 -389
  175. package/dist/chunk-ARPIBGRP.js +0 -1236
  176. package/dist/chunk-ATHNEEAG.js +0 -2309
  177. package/dist/chunk-AVXJOPUE.js +0 -354
  178. package/dist/chunk-B7VEU4S2.js +0 -204
  179. package/dist/chunk-C2TKISBR.js +0 -1213
  180. package/dist/chunk-CBH4YKB4.js +0 -2309
  181. package/dist/chunk-DP7HBRDL.js +0 -2309
  182. package/dist/chunk-DV7ZSH4W.js +0 -2309
  183. package/dist/chunk-DWXNZ5AJ.js +0 -642
  184. package/dist/chunk-EFKMZTT2.js +0 -270
  185. package/dist/chunk-FXJYXHG6.js +0 -266
  186. package/dist/chunk-G466I6RT.js +0 -229
  187. package/dist/chunk-GATPBTHL.js +0 -1142
  188. package/dist/chunk-GMQAHPBC.js +0 -292
  189. package/dist/chunk-GMWA2IJJ.js +0 -1105
  190. package/dist/chunk-GVX5LDLH.js +0 -371
  191. package/dist/chunk-HGENNKOJ.js +0 -355
  192. package/dist/chunk-HM2NBYHU.js +0 -292
  193. package/dist/chunk-IZWB5GCG.js +0 -389
  194. package/dist/chunk-J4HOFUKM.js +0 -2309
  195. package/dist/chunk-JIK2G3EH.js +0 -2313
  196. package/dist/chunk-JRXNWGSW.js +0 -1136
  197. package/dist/chunk-KRKK3KP6.js +0 -1081
  198. package/dist/chunk-KYXZHRUG.js +0 -389
  199. package/dist/chunk-L36L2VDL.js +0 -371
  200. package/dist/chunk-L5PZCES6.js +0 -204
  201. package/dist/chunk-L5U77ZEM.js +0 -1142
  202. package/dist/chunk-LQEKGX2T.js +0 -204
  203. package/dist/chunk-LWMUDMMQ.js +0 -1144
  204. package/dist/chunk-MLKGABMK.js +0 -9
  205. package/dist/chunk-NZ6OQ7UT.js +0 -92
  206. package/dist/chunk-O2UMNZGF.js +0 -903
  207. package/dist/chunk-OFHDMLNM.js +0 -355
  208. package/dist/chunk-PDBMNUMB.js +0 -316
  209. package/dist/chunk-PW4XS7M3.js +0 -850
  210. package/dist/chunk-QA2XQMMJ.js +0 -2313
  211. package/dist/chunk-QL2JFNA7.js +0 -389
  212. package/dist/chunk-QPZ2HNSU.js +0 -912
  213. package/dist/chunk-QVGVU6OS.js +0 -296
  214. package/dist/chunk-RCEU7PFH.js +0 -270
  215. package/dist/chunk-RSTKX7WM.js +0 -907
  216. package/dist/chunk-RXL2CW64.js +0 -266
  217. package/dist/chunk-RXUF6Y43.js +0 -2309
  218. package/dist/chunk-SIAA4J6H.js +0 -21
  219. package/dist/chunk-SOJ2UMO2.js +0 -986
  220. package/dist/chunk-T3AG6DXY.js +0 -296
  221. package/dist/chunk-TPCNKMGZ.js +0 -355
  222. package/dist/chunk-TPT3S5AX.js +0 -204
  223. package/dist/chunk-TXWGIEVH.js +0 -2313
  224. package/dist/chunk-TZFI54AU.js +0 -2313
  225. package/dist/chunk-U3FWUPD3.js +0 -717
  226. package/dist/chunk-UFW2VW2D.js +0 -266
  227. package/dist/chunk-UTAOS5Y7.js +0 -2313
  228. package/dist/chunk-V7VX5OJ6.js +0 -389
  229. package/dist/chunk-W2XGNMYB.js +0 -355
  230. package/dist/chunk-W3M4HJ4U.js +0 -2309
  231. package/dist/chunk-WMJGGREP.js +0 -296
  232. package/dist/chunk-WTNVQ5WS.js +0 -732
  233. package/dist/chunk-WVFWNVT2.js +0 -1050
  234. package/dist/chunk-WY7EYSYC.js +0 -1236
  235. package/dist/chunk-X42F7DE3.js +0 -373
  236. package/dist/chunk-XC7Y4I7L.js +0 -290
  237. package/dist/chunk-YFULZTKP.js +0 -270
  238. package/dist/chunk-YSVHXKSZ.js +0 -373
  239. package/dist/chunk-YWGVK5OS.js +0 -292
  240. package/dist/chunk-Z4BRNTO5.js +0 -2313
  241. package/dist/chunk-ZDUXDKPD.js +0 -292
  242. package/dist/chunk-ZXQ2W7LO.js +0 -355
  243. package/dist/chunk-ZXQELXXO.js +0 -378
  244. package/dist/index.browser.d.ts.map +0 -1
  245. package/dist/index.browser.js.map +0 -1
  246. package/dist/index.d.ts.map +0 -1
  247. package/dist/index.js.map +0 -1
  248. package/dist/lib-4XS34IPZ.js +0 -778
  249. package/dist/model/CardCollection.d.ts +0 -147
  250. package/dist/model/CardCollection.d.ts.map +0 -1
  251. package/dist/model/CardCollection.js +0 -272
  252. package/dist/model/CardCollection.js.map +0 -1
  253. package/dist/model/ContentTypeInterpreter.d.ts +0 -28
  254. package/dist/model/ContentTypeInterpreter.d.ts.map +0 -1
  255. package/dist/model/ContentTypeInterpreter.js +0 -147
  256. package/dist/model/ContentTypeInterpreter.js.map +0 -1
  257. package/dist/model/EventProducer.d.ts +0 -10
  258. package/dist/model/EventProducer.d.ts.map +0 -1
  259. package/dist/model/EventProducer.js +0 -46
  260. package/dist/model/EventProducer.js.map +0 -1
  261. package/dist/model/GTime.d.ts +0 -44
  262. package/dist/model/GTime.d.ts.map +0 -1
  263. package/dist/model/GTime.js +0 -91
  264. package/dist/model/GTime.js.map +0 -1
  265. package/dist/model/Handle.d.ts +0 -37
  266. package/dist/model/Handle.d.ts.map +0 -1
  267. package/dist/model/Handle.js +0 -90
  268. package/dist/model/Handle.js.map +0 -1
  269. package/dist/model/MCard.d.ts +0 -145
  270. package/dist/model/MCard.d.ts.map +0 -1
  271. package/dist/model/MCard.js +0 -180
  272. package/dist/model/MCard.js.map +0 -1
  273. package/dist/model/PCard.d.ts +0 -271
  274. package/dist/model/PCard.d.ts.map +0 -1
  275. package/dist/model/PCard.js +0 -558
  276. package/dist/model/PCard.js.map +0 -1
  277. package/dist/model/VCard.d.ts +0 -277
  278. package/dist/model/VCard.d.ts.map +0 -1
  279. package/dist/model/VCard.js +0 -573
  280. package/dist/model/VCard.js.map +0 -1
  281. package/dist/model/constants.d.ts +0 -45
  282. package/dist/model/constants.d.ts.map +0 -1
  283. package/dist/model/constants.js +0 -27
  284. package/dist/model/constants.js.map +0 -1
  285. package/dist/model/vcard_vocabulary.d.ts +0 -174
  286. package/dist/model/vcard_vocabulary.d.ts.map +0 -1
  287. package/dist/model/vcard_vocabulary.js +0 -187
  288. package/dist/model/vcard_vocabulary.js.map +0 -1
  289. package/dist/monads/Either.d.ts +0 -51
  290. package/dist/monads/Either.d.ts.map +0 -1
  291. package/dist/monads/Either.js +0 -82
  292. package/dist/monads/Either.js.map +0 -1
  293. package/dist/monads/IO.d.ts +0 -38
  294. package/dist/monads/IO.d.ts.map +0 -1
  295. package/dist/monads/IO.js +0 -66
  296. package/dist/monads/IO.js.map +0 -1
  297. package/dist/monads/Maybe.d.ts +0 -45
  298. package/dist/monads/Maybe.d.ts.map +0 -1
  299. package/dist/monads/Maybe.js +0 -73
  300. package/dist/monads/Maybe.js.map +0 -1
  301. package/dist/monads/Reader.d.ts +0 -29
  302. package/dist/monads/Reader.d.ts.map +0 -1
  303. package/dist/monads/Reader.js +0 -44
  304. package/dist/monads/Reader.js.map +0 -1
  305. package/dist/monads/State.d.ts +0 -33
  306. package/dist/monads/State.d.ts.map +0 -1
  307. package/dist/monads/State.js +0 -50
  308. package/dist/monads/State.js.map +0 -1
  309. package/dist/monads/Writer.d.ts +0 -29
  310. package/dist/monads/Writer.d.ts.map +0 -1
  311. package/dist/monads/Writer.js +0 -46
  312. package/dist/monads/Writer.js.map +0 -1
  313. package/dist/ptr/Bridgelet.d.ts +0 -180
  314. package/dist/ptr/Bridgelet.d.ts.map +0 -1
  315. package/dist/ptr/Bridgelet.js +0 -296
  316. package/dist/ptr/Bridgelet.js.map +0 -1
  317. package/dist/ptr/CLMIntrospection.d.ts +0 -169
  318. package/dist/ptr/CLMIntrospection.d.ts.map +0 -1
  319. package/dist/ptr/CLMIntrospection.js +0 -329
  320. package/dist/ptr/CLMIntrospection.js.map +0 -1
  321. package/dist/ptr/FaroSidecar.d.ts +0 -56
  322. package/dist/ptr/FaroSidecar.d.ts.map +0 -1
  323. package/dist/ptr/FaroSidecar.js +0 -102
  324. package/dist/ptr/FaroSidecar.js.map +0 -1
  325. package/dist/ptr/LensProtocol.d.ts +0 -84
  326. package/dist/ptr/LensProtocol.d.ts.map +0 -1
  327. package/dist/ptr/LensProtocol.js +0 -98
  328. package/dist/ptr/LensProtocol.js.map +0 -1
  329. package/dist/ptr/OpenTelemetrySidecar.d.ts +0 -144
  330. package/dist/ptr/OpenTelemetrySidecar.d.ts.map +0 -1
  331. package/dist/ptr/OpenTelemetrySidecar.js +0 -232
  332. package/dist/ptr/OpenTelemetrySidecar.js.map +0 -1
  333. package/dist/ptr/SandboxWorker.d.ts +0 -79
  334. package/dist/ptr/SandboxWorker.d.ts.map +0 -1
  335. package/dist/ptr/SandboxWorker.js +0 -298
  336. package/dist/ptr/SandboxWorker.js.map +0 -1
  337. package/dist/ptr/common_types.d.ts +0 -39
  338. package/dist/ptr/common_types.d.ts.map +0 -1
  339. package/dist/ptr/common_types.js +0 -12
  340. package/dist/ptr/common_types.js.map +0 -1
  341. package/dist/rag/GraphRAGEngine.d.ts +0 -26
  342. package/dist/rag/GraphRAGEngine.d.ts.map +0 -1
  343. package/dist/rag/GraphRAGEngine.js +0 -166
  344. package/dist/rag/GraphRAGEngine.js.map +0 -1
  345. package/dist/rag/HandleVectorStore.d.ts +0 -201
  346. package/dist/rag/HandleVectorStore.d.ts.map +0 -1
  347. package/dist/rag/HandleVectorStore.js +0 -527
  348. package/dist/rag/HandleVectorStore.js.map +0 -1
  349. package/dist/rag/PersistentIndexer.d.ts +0 -148
  350. package/dist/rag/PersistentIndexer.d.ts.map +0 -1
  351. package/dist/rag/PersistentIndexer.js +0 -302
  352. package/dist/rag/PersistentIndexer.js.map +0 -1
  353. package/dist/rag/index.d.ts +0 -20
  354. package/dist/rag/index.d.ts.map +0 -1
  355. package/dist/rag/index.js +0 -26
  356. package/dist/rag/index.js.map +0 -1
  357. package/dist/rag/semanticVersioning.d.ts +0 -187
  358. package/dist/rag/semanticVersioning.d.ts.map +0 -1
  359. package/dist/rag/semanticVersioning.js +0 -253
  360. package/dist/rag/semanticVersioning.js.map +0 -1
  361. package/dist/storage/IndexedDBEngine.d.ts +0 -33
  362. package/dist/storage/IndexedDBEngine.d.ts.map +0 -1
  363. package/dist/storage/IndexedDBEngine.js +0 -198
  364. package/dist/storage/IndexedDBEngine.js.map +0 -1
  365. package/dist/storage/SqliteNodeEngine.d.ts.map +0 -1
  366. package/dist/storage/SqliteNodeEngine.js.map +0 -1
  367. package/dist/storage/SqliteWasmEngine.d.ts.map +0 -1
  368. package/dist/storage/SqliteWasmEngine.js.map +0 -1
  369. package/dist/storage/StorageAdapter.d.ts +0 -42
  370. package/dist/storage/StorageAdapter.d.ts.map +0 -1
  371. package/dist/storage/StorageAdapter.js +0 -2
  372. package/dist/storage/StorageAdapter.js.map +0 -1
  373. package/dist/storage/VectorStore.d.ts +0 -202
  374. package/dist/storage/VectorStore.d.ts.map +0 -1
  375. package/dist/storage/VectorStore.js +0 -557
  376. package/dist/storage/VectorStore.js.map +0 -1
  377. package/dist/storage/schema.d.ts +0 -162
  378. package/dist/storage/schema.d.ts.map +0 -1
  379. package/dist/storage/schema.js +0 -335
  380. package/dist/storage/schema.js.map +0 -1
  381. package/dist/storage/schema_constants.d.ts +0 -7
  382. package/dist/storage/schema_constants.d.ts.map +0 -1
  383. package/dist/storage/schema_constants.js +0 -415
  384. package/dist/storage/schema_constants.js.map +0 -1
  385. package/dist/types/dots.d.ts +0 -206
  386. package/dist/types/dots.d.ts.map +0 -1
  387. package/dist/types/dots.js +0 -201
  388. package/dist/types/dots.js.map +0 -1
@@ -1,1136 +0,0 @@
1
- import {
2
- validateHandle
3
- } from "./chunk-U3FWUPD3.js";
4
- import {
5
- MCard
6
- } from "./chunk-PW4XS7M3.js";
7
-
8
- // src/storage/IndexedDBEngine.ts
9
- import { openDB } from "idb";
10
- var IndexedDBEngine = class {
11
- db = null;
12
- dbName;
13
- constructor(dbName = "mcard-db") {
14
- this.dbName = dbName;
15
- }
16
- /**
17
- * Initialize the database connection
18
- */
19
- async init() {
20
- this.db = await openDB(this.dbName, 1, {
21
- upgrade(db) {
22
- if (!db.objectStoreNames.contains("cards")) {
23
- db.createObjectStore("cards", { keyPath: "hash" });
24
- }
25
- if (!db.objectStoreNames.contains("handles")) {
26
- const handleStore = db.createObjectStore("handles", { keyPath: "handle" });
27
- handleStore.createIndex("by-hash", "currentHash");
28
- }
29
- if (!db.objectStoreNames.contains("handleHistory")) {
30
- const historyStore = db.createObjectStore("handleHistory", {
31
- keyPath: "id",
32
- autoIncrement: true
33
- });
34
- historyStore.createIndex("by-handle", "handle");
35
- }
36
- }
37
- });
38
- }
39
- ensureDb() {
40
- if (!this.db) {
41
- throw new Error("Database not initialized. Call init() first.");
42
- }
43
- return this.db;
44
- }
45
- // =========== Card Operations ===========
46
- async add(card) {
47
- const db = this.ensureDb();
48
- await db.put("cards", {
49
- hash: card.hash,
50
- content: card.content,
51
- g_time: card.g_time
52
- });
53
- return card.hash;
54
- }
55
- async get(hash) {
56
- const db = this.ensureDb();
57
- const record = await db.get("cards", hash);
58
- if (!record) return null;
59
- return MCard.fromData(record.content, record.hash, record.g_time);
60
- }
61
- async delete(hash) {
62
- const db = this.ensureDb();
63
- await db.delete("cards", hash);
64
- }
65
- async getPage(pageNumber, pageSize) {
66
- const db = this.ensureDb();
67
- const totalItems = await db.count("cards");
68
- const totalPages = Math.ceil(totalItems / pageSize);
69
- const allCards = await db.getAll("cards");
70
- const start = (pageNumber - 1) * pageSize;
71
- const pageRecords = allCards.slice(start, start + pageSize);
72
- const items = pageRecords.map((r) => MCard.fromData(r.content, r.hash, r.g_time));
73
- return {
74
- items,
75
- totalItems,
76
- pageNumber,
77
- pageSize,
78
- totalPages,
79
- hasNext: pageNumber < totalPages,
80
- hasPrevious: pageNumber > 1
81
- };
82
- }
83
- async count() {
84
- const db = this.ensureDb();
85
- return db.count("cards");
86
- }
87
- async searchByHash(hashPrefix) {
88
- const db = this.ensureDb();
89
- const start = hashPrefix;
90
- const end = hashPrefix + "\uFFFF";
91
- const range = IDBKeyRange.bound(start, end);
92
- const records = await db.getAll("cards", range);
93
- return records.map((r) => MCard.fromData(r.content, r.hash, r.g_time));
94
- }
95
- async search(query, pageNumber, pageSize) {
96
- const db = this.ensureDb();
97
- const records = await db.getAll("cards");
98
- const decoder = new TextDecoder();
99
- const filtered = records.filter((r) => {
100
- try {
101
- const text = decoder.decode(r.content);
102
- return text.includes(query);
103
- } catch {
104
- return false;
105
- }
106
- });
107
- const totalItems = filtered.length;
108
- const totalPages = Math.ceil(totalItems / pageSize);
109
- const start = (pageNumber - 1) * pageSize;
110
- const pageItems = filtered.slice(start, start + pageSize).map((r) => MCard.fromData(r.content, r.hash, r.g_time));
111
- return {
112
- items: pageItems,
113
- totalItems,
114
- pageNumber,
115
- pageSize,
116
- totalPages,
117
- hasNext: pageNumber < totalPages,
118
- hasPrevious: pageNumber > 1
119
- };
120
- }
121
- async getAll() {
122
- const db = this.ensureDb();
123
- const records = await db.getAll("cards");
124
- return records.map((r) => MCard.fromData(r.content, r.hash, r.g_time));
125
- }
126
- async clear() {
127
- const db = this.ensureDb();
128
- await db.clear("cards");
129
- await db.clear("handles");
130
- await db.clear("handleHistory");
131
- }
132
- // =========== Handle Operations ===========
133
- async registerHandle(handle, hash) {
134
- const db = this.ensureDb();
135
- const normalized = validateHandle(handle);
136
- const existing = await db.get("handles", normalized);
137
- if (existing) {
138
- throw new Error(`Handle '${handle}' already exists.`);
139
- }
140
- const now = (/* @__PURE__ */ new Date()).toISOString();
141
- await db.put("handles", {
142
- handle: normalized,
143
- currentHash: hash,
144
- createdAt: now,
145
- updatedAt: now
146
- });
147
- }
148
- async resolveHandle(handle) {
149
- const db = this.ensureDb();
150
- const normalized = validateHandle(handle);
151
- const record = await db.get("handles", normalized);
152
- return record?.currentHash ?? null;
153
- }
154
- async getByHandle(handle) {
155
- const hash = await this.resolveHandle(handle);
156
- if (!hash) return null;
157
- return this.get(hash);
158
- }
159
- async updateHandle(handle, newHash) {
160
- const db = this.ensureDb();
161
- const normalized = validateHandle(handle);
162
- const existing = await db.get("handles", normalized);
163
- if (!existing) {
164
- throw new Error(`Handle '${handle}' not found.`);
165
- }
166
- const previousHash = existing.currentHash;
167
- const now = (/* @__PURE__ */ new Date()).toISOString();
168
- await db.add("handleHistory", {
169
- handle: normalized,
170
- previousHash,
171
- changedAt: now
172
- });
173
- await db.put("handles", {
174
- ...existing,
175
- currentHash: newHash,
176
- updatedAt: now
177
- });
178
- return previousHash;
179
- }
180
- async getHandleHistory(handle) {
181
- const db = this.ensureDb();
182
- const normalized = validateHandle(handle);
183
- const records = await db.getAllFromIndex("handleHistory", "by-handle", normalized);
184
- return records.map((r) => ({ previousHash: r.previousHash, changedAt: r.changedAt })).reverse();
185
- }
186
- };
187
-
188
- // src/model/hash/algorithms/LocalSHA256.ts
189
- async function computeHash(content) {
190
- let contentStr;
191
- if (typeof content === "string") {
192
- contentStr = content;
193
- } else {
194
- contentStr = JSON.stringify(content);
195
- }
196
- const encoder = new TextEncoder();
197
- const data = encoder.encode(contentStr);
198
- const hashBuffer = await crypto.subtle.digest("SHA-256", data);
199
- const hashArray = Array.from(new Uint8Array(hashBuffer));
200
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
201
- return hashHex;
202
- }
203
-
204
- // src/monads/Reader.ts
205
- var Reader = class _Reader {
206
- constructor(run) {
207
- this.run = run;
208
- }
209
- /**
210
- * Lift a pure value into Reader
211
- */
212
- static pure(value) {
213
- return new _Reader((_) => value);
214
- }
215
- /**
216
- * Get the environment
217
- */
218
- static ask() {
219
- return new _Reader((env) => env);
220
- }
221
- /**
222
- * Monadic bind (flatMap)
223
- */
224
- bind(fn) {
225
- return new _Reader((env) => {
226
- const value = this.run(env);
227
- return fn(value).run(env);
228
- });
229
- }
230
- /**
231
- * Map over the result
232
- */
233
- map(fn) {
234
- return this.bind((value) => _Reader.pure(fn(value)));
235
- }
236
- /**
237
- * Execute the Reader logic with an environment
238
- */
239
- evaluate(env) {
240
- return this.run(env);
241
- }
242
- };
243
-
244
- // src/monads/Writer.ts
245
- var Writer = class _Writer {
246
- constructor(run) {
247
- this.run = run;
248
- }
249
- /**
250
- * Lift a pure value into Writer (empty log)
251
- */
252
- static pure(value) {
253
- return new _Writer(() => [value, []]);
254
- }
255
- /**
256
- * Write to log
257
- */
258
- static tell(log) {
259
- return new _Writer(() => [void 0, log]);
260
- }
261
- /**
262
- * Monadic bind
263
- */
264
- bind(fn) {
265
- return new _Writer(() => {
266
- const [val1, log1] = this.run();
267
- const writer2 = fn(val1);
268
- const [val2, log2] = writer2.evaluate();
269
- return [val2, [...log1, ...log2]];
270
- });
271
- }
272
- /**
273
- * Map
274
- */
275
- map(fn) {
276
- return this.bind((val) => _Writer.pure(fn(val)));
277
- }
278
- /**
279
- * Run the writer
280
- */
281
- evaluate() {
282
- return this.run();
283
- }
284
- };
285
-
286
- // src/monads/State.ts
287
- var State = class _State {
288
- constructor(run) {
289
- this.run = run;
290
- }
291
- /**
292
- * Lift pure value
293
- */
294
- static pure(value) {
295
- return new _State((state) => [value, state]);
296
- }
297
- /**
298
- * Get current state
299
- */
300
- static get() {
301
- return new _State((state) => [state, state]);
302
- }
303
- /**
304
- * Set new state
305
- */
306
- static put(newState) {
307
- return new _State((_) => [void 0, newState]);
308
- }
309
- /**
310
- * Monadic bind
311
- */
312
- bind(fn) {
313
- return new _State((state) => {
314
- const [val, newState] = this.run(state);
315
- return fn(val).run(newState);
316
- });
317
- }
318
- /**
319
- * Map
320
- */
321
- map(fn) {
322
- return this.bind((val) => _State.pure(fn(val)));
323
- }
324
- /**
325
- * Execute state transition
326
- */
327
- evaluate(initialState) {
328
- return this.run(initialState);
329
- }
330
- };
331
-
332
- // src/ptr/LensProtocol.ts
333
- var LensProtocol = class {
334
- static idCounter = 0;
335
- /**
336
- * Create an execute request
337
- */
338
- static createExecuteRequest(pcard_hash, target_hash, context) {
339
- return {
340
- jsonrpc: "2.0",
341
- id: ++this.idCounter,
342
- method: "pcard.execute",
343
- params: { pcard_hash, target_hash, context }
344
- };
345
- }
346
- /**
347
- * Create a verify request
348
- */
349
- static createVerifyRequest(pcard_hash, target_hash, context) {
350
- return {
351
- jsonrpc: "2.0",
352
- id: ++this.idCounter,
353
- method: "pcard.verify",
354
- params: { pcard_hash, target_hash, context }
355
- };
356
- }
357
- /**
358
- * Create a reveal request
359
- */
360
- static createRevealRequest(card_hash, aspect) {
361
- return {
362
- jsonrpc: "2.0",
363
- id: ++this.idCounter,
364
- method: "lens.reveal",
365
- params: { card_hash, aspect }
366
- };
367
- }
368
- /**
369
- * Create a system status request
370
- */
371
- static createStatusRequest() {
372
- return {
373
- jsonrpc: "2.0",
374
- id: ++this.idCounter,
375
- method: "system.status"
376
- };
377
- }
378
- /**
379
- * Create a system health request
380
- */
381
- static createHealthRequest() {
382
- return {
383
- jsonrpc: "2.0",
384
- id: ++this.idCounter,
385
- method: "system.health"
386
- };
387
- }
388
- /**
389
- * Create a success response
390
- */
391
- static createSuccessResponse(id, result) {
392
- return { jsonrpc: "2.0", id, result };
393
- }
394
- /**
395
- * Create an error response
396
- */
397
- static createErrorResponse(id, code, message, data) {
398
- return { jsonrpc: "2.0", id, error: { code, message, data } };
399
- }
400
- /**
401
- * Parse a JSON-RPC response
402
- */
403
- static parseResponse(response) {
404
- if (response.error) {
405
- throw new Error(`JSON-RPC Error ${response.error.code}: ${response.error.message}`);
406
- }
407
- return response.result;
408
- }
409
- };
410
- var ErrorCodes = {
411
- PARSE_ERROR: -32700,
412
- INVALID_REQUEST: -32600,
413
- METHOD_NOT_FOUND: -32601,
414
- INVALID_PARAMS: -32602,
415
- INTERNAL_ERROR: -32603,
416
- // Custom PTR errors
417
- EXECUTION_ERROR: -32e3,
418
- VERIFICATION_FAILED: -32001,
419
- TIMEOUT: -32002
420
- };
421
-
422
- // src/ptr/common_types.ts
423
- var VerificationStatus = /* @__PURE__ */ ((VerificationStatus2) => {
424
- VerificationStatus2["PENDING"] = "pending";
425
- VerificationStatus2["VERIFIED"] = "verified";
426
- VerificationStatus2["FAILED"] = "failed";
427
- VerificationStatus2["SKIPPED"] = "skipped";
428
- return VerificationStatus2;
429
- })(VerificationStatus || {});
430
-
431
- // src/ptr/browser/storage/MCardStore.ts
432
- import { openDB as openDB2 } from "idb";
433
- var MCardStore = class {
434
- dbPromise;
435
- constructor(dbName = "mcard-ptr-store") {
436
- this.dbPromise = openDB2(dbName, 8, {
437
- upgrade(db, oldVersion, newVersion, transaction) {
438
- if (db.objectStoreNames.contains("mcards")) db.deleteObjectStore("mcards");
439
- if (db.objectStoreNames.contains("handles")) db.deleteObjectStore("handles");
440
- let cardStore;
441
- if (!db.objectStoreNames.contains("card")) {
442
- cardStore = db.createObjectStore("card", { keyPath: "hash" });
443
- } else {
444
- cardStore = transaction.objectStore("card");
445
- }
446
- if (!cardStore.indexNames.contains("by_g_time")) {
447
- cardStore.createIndex("by_g_time", "g_time");
448
- }
449
- let registryStore;
450
- if (!db.objectStoreNames.contains("handle_registry")) {
451
- registryStore = db.createObjectStore("handle_registry", { keyPath: "handle" });
452
- } else {
453
- registryStore = transaction.objectStore("handle_registry");
454
- }
455
- if (!registryStore.indexNames.contains("by_current_hash")) {
456
- registryStore.createIndex("by_current_hash", "current_hash");
457
- }
458
- if (!registryStore.indexNames.contains("by_updated_at")) {
459
- registryStore.createIndex("by_updated_at", "updated_at");
460
- }
461
- let historyStore;
462
- if (!db.objectStoreNames.contains("handle_history")) {
463
- historyStore = db.createObjectStore("handle_history", { keyPath: "id", autoIncrement: true });
464
- } else {
465
- historyStore = transaction.objectStore("handle_history");
466
- }
467
- if (!historyStore.indexNames.contains("by_handle")) {
468
- historyStore.createIndex("by_handle", "handle");
469
- }
470
- if (!historyStore.indexNames.contains("by_previous_hash")) {
471
- historyStore.createIndex("by_previous_hash", "previous_hash");
472
- }
473
- if (!historyStore.indexNames.contains("by_changed_at")) {
474
- historyStore.createIndex("by_changed_at", "changed_at");
475
- }
476
- if (!db.objectStoreNames.contains("schema_version")) {
477
- const versionStore = db.createObjectStore("schema_version", { keyPath: "version" });
478
- versionStore.add({
479
- version: "3.0.2",
480
- applied_at: (/* @__PURE__ */ new Date()).toISOString(),
481
- description: "Monadic Core Schema (Strict Compliance)"
482
- });
483
- }
484
- }
485
- });
486
- }
487
- // ═══════════════════════════════════════════════════════════════
488
- // CARD OPERATIONS
489
- // ═══════════════════════════════════════════════════════════════
490
- async putCard(hash, content) {
491
- const db = await this.dbPromise;
492
- const g_time = (/* @__PURE__ */ new Date()).toISOString();
493
- await db.put("card", {
494
- hash,
495
- content,
496
- g_time
497
- });
498
- }
499
- async getCard(hash) {
500
- const db = await this.dbPromise;
501
- return db.get("card", hash);
502
- }
503
- // ═══════════════════════════════════════════════════════════════
504
- // HANDLE OPERATIONS (Transaction-safe)
505
- // ═══════════════════════════════════════════════════════════════
506
- async setHandle(handle, newHash) {
507
- const db = await this.dbPromise;
508
- const tx = db.transaction(["handle_registry", "handle_history"], "readwrite");
509
- const registry = tx.objectStore("handle_registry");
510
- const history = tx.objectStore("handle_history");
511
- const now = (/* @__PURE__ */ new Date()).toISOString();
512
- const existing = await registry.get(handle);
513
- if (existing) {
514
- await history.add({
515
- handle,
516
- previous_hash: existing.current_hash,
517
- changed_at: now
518
- });
519
- await registry.put({
520
- handle,
521
- current_hash: newHash,
522
- created_at: existing.created_at,
523
- updated_at: now
524
- });
525
- } else {
526
- await registry.put({
527
- handle,
528
- current_hash: newHash,
529
- created_at: now,
530
- updated_at: now
531
- });
532
- }
533
- await tx.done;
534
- }
535
- async resolveHandle(handle) {
536
- const db = await this.dbPromise;
537
- const tx = db.transaction(["handle_registry", "card"], "readonly");
538
- const registry = tx.objectStore("handle_registry");
539
- const entry = await registry.get(handle);
540
- if (!entry) return void 0;
541
- const cardStore = tx.objectStore("card");
542
- return cardStore.get(entry.current_hash);
543
- }
544
- // ═══════════════════════════════════════════════════════════════
545
- // QUERY HELPERS (using Indices)
546
- // ═══════════════════════════════════════════════════════════════
547
- async getHandleHistory(handle) {
548
- const db = await this.dbPromise;
549
- return db.getAllFromIndex("handle_history", "by_handle", handle);
550
- }
551
- async getHandlesByHash(hash) {
552
- const db = await this.dbPromise;
553
- return db.getAllFromIndex("handle_registry", "by_current_hash", hash);
554
- }
555
- // ═══════════════════════════════════════════════════════════════
556
- // UI HELPERS (For Browser Demo - keeping these for compatibility but implementing via new methods where possible)
557
- // ═══════════════════════════════════════════════════════════════
558
- async getAllCards() {
559
- const db = await this.dbPromise;
560
- return db.getAll("card");
561
- }
562
- async getAllHandles() {
563
- const db = await this.dbPromise;
564
- return db.getAll("handle_registry");
565
- }
566
- async getAllHistory() {
567
- const db = await this.dbPromise;
568
- return db.getAll("handle_history");
569
- }
570
- };
571
-
572
- // src/ptr/browser/network/WebSocketClient.ts
573
- var WebSocketClient = class {
574
- ws = null;
575
- url;
576
- messageHandler = null;
577
- reconnectInterval = 3e3;
578
- constructor(url) {
579
- this.url = url;
580
- }
581
- connect() {
582
- console.log(`[BrowserPTR] Connecting to ${this.url}`);
583
- this.ws = new WebSocket(this.url);
584
- this.ws.onopen = () => {
585
- console.log("[BrowserPTR] WebSocket connected");
586
- };
587
- this.ws.onmessage = (event) => {
588
- try {
589
- const data = JSON.parse(event.data);
590
- if (this.messageHandler) {
591
- this.messageHandler(data);
592
- }
593
- } catch (e) {
594
- console.error("[BrowserPTR] Failed to parse message:", e);
595
- }
596
- };
597
- this.ws.onclose = () => {
598
- console.log("[BrowserPTR] WebSocket closed. Reconnecting...");
599
- this.ws = null;
600
- setTimeout(() => this.connect(), this.reconnectInterval);
601
- };
602
- this.ws.onerror = (error) => {
603
- console.error("[BrowserPTR] WebSocket error:", error);
604
- };
605
- }
606
- setMessageHandler(handler) {
607
- this.messageHandler = handler;
608
- }
609
- send(data) {
610
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
611
- this.ws.send(JSON.stringify(data));
612
- } else {
613
- console.warn("[BrowserPTR] WebSocket not ready. Message dropped:", data);
614
- }
615
- }
616
- };
617
-
618
- // src/ptr/browser/worker/ServiceWorkerPTR.ts
619
- var ServiceWorkerPTR = class {
620
- store;
621
- ws;
622
- constructor(serverUrl, wasmUrl, storeName = "mcard-ptr-store") {
623
- this.store = new MCardStore(storeName);
624
- this.ws = new WebSocketClient(serverUrl);
625
- this.ws.setMessageHandler(this.onMeshMessage.bind(this));
626
- }
627
- start() {
628
- this.ws.connect();
629
- self.addEventListener("message", (event) => {
630
- if (event.data) {
631
- if (event.data.type === "clm_execute") {
632
- this.handleLocalRequest(event);
633
- } else if (event.data.type === "EXECUTE_CLM") {
634
- this.handleDirectExecution(event);
635
- }
636
- }
637
- });
638
- console.log("[ServiceWorkerPTR] Started");
639
- }
640
- getStore() {
641
- return this.store;
642
- }
643
- async onMeshMessage(msg) {
644
- console.log("[ServiceWorkerPTR] Received from mesh:", msg);
645
- if (msg.type === "clm_execute") {
646
- await this.executeCLM(msg.clm_hash, msg.input_hash, msg.request_id);
647
- } else if (msg.type === "clm_result") {
648
- const clients = await self.clients.matchAll();
649
- for (const client of clients) {
650
- client.postMessage(msg);
651
- }
652
- }
653
- }
654
- async handleLocalRequest(event) {
655
- const { clm_hash, input_hash, request_id } = event.data;
656
- console.log("[ServiceWorkerPTR] Local request:", request_id);
657
- this.ws.send({
658
- type: "clm_execute",
659
- clm_hash,
660
- input_hash,
661
- request_id,
662
- origin: "browser"
663
- });
664
- }
665
- async handleDirectExecution(event) {
666
- const { code } = event.data;
667
- const port = event.ports[0];
668
- console.log("[ServiceWorkerPTR] Direct Execution Request");
669
- try {
670
- const input = { content: { count: 0 } };
671
- const result = await this.executeJavaScript(code, input, {});
672
- if (port) {
673
- port.postMessage({
674
- result,
675
- logs: ["[ServiceWorkerPTR] Executed successfully (Client Mode)"]
676
- });
677
- }
678
- } catch (e) {
679
- console.error("[ServiceWorkerPTR] Execution error:", e);
680
- if (port) {
681
- port.postMessage({
682
- logs: [`[ServiceWorkerPTR] Error: ${e.message}`]
683
- });
684
- }
685
- }
686
- }
687
- async executeCLM(clmHash, inputHash, requestId) {
688
- console.log(`[ServiceWorkerPTR] Executing CLM ${clmHash} with input ${inputHash}`);
689
- const input = await this.store.getCard(inputHash);
690
- try {
691
- const code = clmHash.includes("return") ? clmHash : "return input.content.count + 1;";
692
- const result = await this.executeJavaScript(code, input || { content: { count: 0 } }, {});
693
- const resultHash = `sha256:result_${requestId}`;
694
- await this.store.putCard(resultHash, result);
695
- this.ws.send({
696
- type: "clm_result",
697
- request_id: requestId,
698
- output_hash: resultHash,
699
- success: true
700
- });
701
- } catch (e) {
702
- console.error("[ServiceWorkerPTR] Execution error:", e);
703
- this.ws.send({
704
- type: "clm_result",
705
- request_id: requestId,
706
- output_hash: "",
707
- success: false,
708
- error: e.message
709
- });
710
- }
711
- }
712
- // --- Execution Logic Ported from SandboxWorker ---
713
- async executeJavaScript(code, input, context) {
714
- try {
715
- const fn = new Function("input", "context", code);
716
- return fn(input, context || {});
717
- } catch (e) {
718
- throw e;
719
- }
720
- }
721
- // Pyodide support placeholder
722
- // Implementing full Pyodide loading requires handling caching and CDN usage
723
- // similar to SandboxWorker.ts but adapted for ServiceWorker environment.
724
- async executePython(code, input, context) {
725
- throw new Error("Python execution not fully implemented yet in ServiceWorkerPTR");
726
- }
727
- };
728
-
729
- // src/ptr/FaroSidecar.ts
730
- import {
731
- initializeFaro,
732
- getWebInstrumentations
733
- } from "@grafana/faro-web-sdk";
734
- import { TracingInstrumentation } from "@grafana/faro-web-tracing";
735
- var FaroSidecar = class _FaroSidecar {
736
- static instance = null;
737
- faro = null;
738
- constructor() {
739
- }
740
- /**
741
- * Get the singleton instance of FaroSidecar
742
- */
743
- static getInstance() {
744
- if (!_FaroSidecar.instance) {
745
- _FaroSidecar.instance = new _FaroSidecar();
746
- }
747
- return _FaroSidecar.instance;
748
- }
749
- /**
750
- * Initialize the Faro SDK
751
- *
752
- * @param config Configuration options
753
- * @returns The initialized Faro instance or null if not in a browser environment
754
- */
755
- initialize(config) {
756
- if (typeof window === "undefined") {
757
- console.warn("[FaroSidecar] Not initializing Grafana Faro: Non-browser environment detected.");
758
- return null;
759
- }
760
- if (this.faro) {
761
- console.warn("[FaroSidecar] Grafana Faro is already initialized.");
762
- return this.faro;
763
- }
764
- const {
765
- url,
766
- apiKey,
767
- appName,
768
- appVersion,
769
- enableTracing = true,
770
- namespace = "ptr_runtime",
771
- additionalInstrumentations = []
772
- } = config;
773
- const instrumentations = [
774
- ...getWebInstrumentations(),
775
- ...additionalInstrumentations
776
- ];
777
- if (enableTracing) {
778
- instrumentations.push(new TracingInstrumentation());
779
- }
780
- const faroOptions = {
781
- url,
782
- apiKey,
783
- app: {
784
- name: appName,
785
- version: appVersion,
786
- namespace
787
- },
788
- instrumentations
789
- };
790
- try {
791
- this.faro = initializeFaro(faroOptions);
792
- console.log(`[FaroSidecar] Grafana Faro initialized for ${appName}@${appVersion}`);
793
- this.faro.api.pushLog([`PTR Observability Sidecar started for ${appName}`]);
794
- } catch (error) {
795
- console.error("[FaroSidecar] Failed to initialize Grafana Faro:", error);
796
- }
797
- return this.faro;
798
- }
799
- /**
800
- * Get the underlying Faro instance
801
- */
802
- getFaro() {
803
- return this.faro;
804
- }
805
- /**
806
- * Manually push an error to Faro
807
- */
808
- pushError(error, context) {
809
- if (this.faro) {
810
- this.faro.api.pushError(error, { context });
811
- }
812
- }
813
- /**
814
- * Manually push a log message to Faro
815
- */
816
- pushLog(message, context) {
817
- if (this.faro) {
818
- this.faro.api.pushLog([message], { context });
819
- }
820
- }
821
- /**
822
- * Push a custom event
823
- */
824
- pushEvent(name, attributes) {
825
- if (this.faro) {
826
- this.faro.api.pushEvent(name, attributes);
827
- }
828
- }
829
- };
830
-
831
- // src/model/validators/BaseValidator.ts
832
- var ValidationError = class extends Error {
833
- constructor(message) {
834
- super(message);
835
- this.name = "ValidationError";
836
- }
837
- };
838
- var BaseValidator = class {
839
- };
840
-
841
- // src/model/validators/TextValidator.ts
842
- var TextValidator = class _TextValidator extends BaseValidator {
843
- static TEXT_MIME_TYPES = /* @__PURE__ */ new Set([
844
- "text/plain",
845
- "application/json",
846
- "application/xml",
847
- "text/xml",
848
- "image/svg+xml",
849
- "text/html",
850
- "text/markdown"
851
- ]);
852
- canValidate(mimeType) {
853
- return _TextValidator.TEXT_MIME_TYPES.has(mimeType);
854
- }
855
- validate(content, mimeType) {
856
- const textContent = this.ensureString(content);
857
- if (mimeType === "text/plain") {
858
- this.validatePlainText(textContent);
859
- } else if (mimeType === "application/json") {
860
- this.validateJson(textContent);
861
- } else if (["application/xml", "text/xml", "image/svg+xml"].includes(mimeType)) {
862
- this.validateXml(textContent);
863
- }
864
- }
865
- ensureString(content) {
866
- if (typeof content === "string") {
867
- return content;
868
- }
869
- return new TextDecoder().decode(content);
870
- }
871
- validatePlainText(content) {
872
- const trimmed = content.trim();
873
- if (!trimmed) {
874
- throw new ValidationError("Invalid content: empty text");
875
- }
876
- if (trimmed.length < 3) {
877
- throw new ValidationError("Invalid content: too short");
878
- }
879
- if (!/\s/.test(content)) {
880
- if (content.split(/\s+/).length === 1 && content.length > 20) {
881
- throw new ValidationError("Invalid content: likely not plain text");
882
- }
883
- }
884
- }
885
- validateJson(content) {
886
- try {
887
- const lines = content.split("\n");
888
- if (lines.some((line) => line.trim().startsWith("//"))) {
889
- throw new ValidationError("Invalid JSON content: contains comments");
890
- }
891
- JSON.parse(content);
892
- } catch (e) {
893
- if (e instanceof ValidationError) throw e;
894
- throw new ValidationError("Invalid JSON content");
895
- }
896
- }
897
- validateXml(content) {
898
- const trimmed = content.trim();
899
- if (!trimmed.startsWith("<") || !trimmed.endsWith(">")) {
900
- throw new ValidationError("Invalid XML content");
901
- }
902
- }
903
- };
904
-
905
- // src/model/detectors/BinarySignatureDetector.ts
906
- var BinarySignatureDetector = class _BinarySignatureDetector {
907
- // Dictionary of binary signatures mapped to MIME types
908
- // Note: In TS, we use numbers or number arrays for bytes
909
- static SIGNATURES = {
910
- // Images
911
- "89504e470d0a1a0a": "image/png",
912
- // \x89PNG\r\n\x1a\n
913
- "ffd8ff": "image/jpeg",
914
- "474946383761": "image/gif",
915
- // GIF87a
916
- "474946383961": "image/gif",
917
- // GIF89a
918
- "424d": "image/bmp",
919
- // BM
920
- "00000100": "image/x-icon",
921
- "00000200": "image/x-icon",
922
- // MP4
923
- "00000018667479706d703432": "video/mp4",
924
- // ...ftypmp42
925
- "000000186674797069736f6d": "video/mp4",
926
- // ...ftypisom
927
- // ... (simplified for key common ones)
928
- // Documents
929
- "25504446": "application/pdf",
930
- // %PDF
931
- // Archives
932
- "504b0304": "application/zip",
933
- // PK\x03\x04
934
- "1f8b08": "application/gzip",
935
- "526172211a0700": "application/x-rar-compressed",
936
- // Rar!
937
- "377abcaf271c": "application/x-7z-compressed",
938
- // 7z...
939
- // Database
940
- "53514c69746520666f726d6174203300": "application/x-sqlite3"
941
- // SQLite format 3\0
942
- };
943
- static OLE_SIGNATURE = "d0cf11e0a1b11ae1";
944
- /**
945
- * Helper to convert hex string to Uint8Array for easy comparison if needed,
946
- * but we will convert input bytes to hex for lookup.
947
- */
948
- detect(content) {
949
- return this.detectFromBytes(content);
950
- }
951
- detectFromBytes(content) {
952
- if (this.startsWithAscii(content, "RIFF")) {
953
- return this.detectRiffFormat(content);
954
- }
955
- const hexHeader = this.toHex(content.slice(0, 32));
956
- for (const [signature, mimeType] of Object.entries(_BinarySignatureDetector.SIGNATURES)) {
957
- if (hexHeader.startsWith(signature)) {
958
- if (signature === _BinarySignatureDetector.OLE_SIGNATURE) {
959
- return "application/oleobject";
960
- }
961
- if (signature === "504b0304") {
962
- return "application/zip";
963
- }
964
- return mimeType;
965
- }
966
- }
967
- return "application/octet-stream";
968
- }
969
- detectRiffFormat(content) {
970
- if (content.length < 12) return "application/octet-stream";
971
- const formatType = this.toAscii(content.slice(8, 12));
972
- if (formatType === "WAVE") return "audio/wav";
973
- if (formatType === "WEBP") return "image/webp";
974
- return "application/octet-stream";
975
- }
976
- startsWithAscii(content, str) {
977
- if (content.length < str.length) return false;
978
- for (let i = 0; i < str.length; i++) {
979
- if (content[i] !== str.charCodeAt(i)) return false;
980
- }
981
- return true;
982
- }
983
- toAscii(content) {
984
- return Array.from(content).map((b) => String.fromCharCode(b)).join("");
985
- }
986
- toHex(content) {
987
- return Array.from(content).map((b) => b.toString(16).padStart(2, "0")).join("");
988
- }
989
- };
990
-
991
- // src/model/validators/BinaryValidator.ts
992
- var BinaryValidator = class _BinaryValidator extends BaseValidator {
993
- static BINARY_MIME_TYPES = /* @__PURE__ */ new Set([
994
- "image/png",
995
- "image/jpeg",
996
- "image/gif",
997
- "image/bmp",
998
- "application/pdf",
999
- "application/zip",
1000
- "video/mp4",
1001
- "audio/wav",
1002
- "application/octet-stream"
1003
- ]);
1004
- detector = new BinarySignatureDetector();
1005
- canValidate(mimeType) {
1006
- return _BinaryValidator.BINARY_MIME_TYPES.has(mimeType) || mimeType.startsWith("image/") || mimeType.startsWith("audio/") || mimeType.startsWith("video/");
1007
- }
1008
- validate(content, mimeType) {
1009
- const contentBytes = this.ensureBytes(content);
1010
- if (mimeType.startsWith("image/")) {
1011
- this.validateImage(contentBytes, mimeType);
1012
- } else if (mimeType === "application/pdf") {
1013
- this.validatePdf(contentBytes);
1014
- } else if (mimeType === "application/zip") {
1015
- this.validateZip(contentBytes);
1016
- }
1017
- }
1018
- ensureBytes(content) {
1019
- if (content instanceof Uint8Array) {
1020
- return content;
1021
- }
1022
- return new TextEncoder().encode(content);
1023
- }
1024
- validateImage(content, mimeType) {
1025
- if (mimeType === "image/png" && content.length <= 8) {
1026
- throw new ValidationError("Invalid PNG content: truncated file");
1027
- } else if (mimeType === "image/jpeg" && content.length <= 3) {
1028
- throw new ValidationError("Invalid JPEG content: truncated file");
1029
- } else if (mimeType === "image/gif" && content.length <= 6) {
1030
- throw new ValidationError("Invalid GIF content: truncated file");
1031
- }
1032
- const signatures = BinarySignatureDetector.SIGNATURES;
1033
- let expectedSig = null;
1034
- for (const [sig, mime] of Object.entries(signatures)) {
1035
- if (mime === mimeType) {
1036
- expectedSig = sig;
1037
- }
1038
- }
1039
- if (expectedSig) {
1040
- const contentHex = this.toHex(content.slice(0, expectedSig.length / 2));
1041
- if (contentHex !== expectedSig) {
1042
- let hasMatch = false;
1043
- for (const [sig, mime] of Object.entries(signatures)) {
1044
- if (mime === mimeType) {
1045
- const currentHex = this.toHex(content.slice(0, sig.length / 2));
1046
- if (currentHex === sig) {
1047
- hasMatch = true;
1048
- break;
1049
- }
1050
- }
1051
- }
1052
- if (!hasMatch) {
1053
- throw new ValidationError(`Invalid ${mimeType} content: missing proper header`);
1054
- }
1055
- }
1056
- }
1057
- }
1058
- validatePdf(content) {
1059
- if (!this.startsWithAscii(content, "%PDF-")) {
1060
- throw new ValidationError("Invalid PDF content");
1061
- }
1062
- }
1063
- validateZip(content) {
1064
- if (content.length <= 4) {
1065
- throw new ValidationError("Invalid ZIP content");
1066
- }
1067
- }
1068
- // Helpers
1069
- toHex(content) {
1070
- return Array.from(content).map((b) => b.toString(16).padStart(2, "0")).join("");
1071
- }
1072
- startsWithAscii(content, str) {
1073
- if (content.length < str.length) return false;
1074
- for (let i = 0; i < str.length; i++) {
1075
- if (content[i] !== str.charCodeAt(i)) return false;
1076
- }
1077
- return true;
1078
- }
1079
- };
1080
-
1081
- // src/model/validators/ValidationRegistry.ts
1082
- var ValidationRegistry = class {
1083
- validators;
1084
- constructor() {
1085
- this.validators = [
1086
- new TextValidator(),
1087
- new BinaryValidator()
1088
- ];
1089
- }
1090
- /**
1091
- * Validate content using appropriate validator.
1092
- *
1093
- * @param content The content to validate
1094
- * @param mimeType The detected MIME type
1095
- * @throws ValidationError If content is invalid
1096
- */
1097
- validate(content, mimeType) {
1098
- if (!content || content instanceof Uint8Array && content.length === 0) {
1099
- throw new ValidationError("Empty content");
1100
- }
1101
- if (typeof content === "string" && !content) {
1102
- throw new ValidationError("Empty content");
1103
- }
1104
- for (const validator of this.validators) {
1105
- if (validator.canValidate(mimeType)) {
1106
- validator.validate(content, mimeType);
1107
- return;
1108
- }
1109
- }
1110
- this.basicValidation(content);
1111
- }
1112
- basicValidation(content) {
1113
- if (content instanceof Uint8Array) {
1114
- if (content.length === 0) {
1115
- throw new ValidationError("Invalid content: empty byte array");
1116
- }
1117
- }
1118
- }
1119
- };
1120
- var validationRegistry = new ValidationRegistry();
1121
-
1122
- export {
1123
- IndexedDBEngine,
1124
- computeHash,
1125
- Reader,
1126
- Writer,
1127
- State,
1128
- LensProtocol,
1129
- ErrorCodes,
1130
- VerificationStatus,
1131
- MCardStore,
1132
- ServiceWorkerPTR,
1133
- FaroSidecar,
1134
- ValidationRegistry,
1135
- validationRegistry
1136
- };