@oobe-protocol-labs/synapse-client-sdk 1.0.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (659) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/dist/cjs/ai/gateway/index.d.ts +5 -5
  3. package/dist/cjs/ai/gateway/index.d.ts.map +1 -1
  4. package/dist/cjs/ai/gateway/index.js +2 -2
  5. package/dist/cjs/ai/gateway/index.js.map +1 -1
  6. package/dist/cjs/ai/index.d.ts +1 -1
  7. package/dist/cjs/ai/index.d.ts.map +1 -1
  8. package/dist/cjs/ai/index.js +5 -2
  9. package/dist/cjs/ai/index.js.map +1 -1
  10. package/dist/cjs/ai/tools/index.d.ts +4 -4
  11. package/dist/cjs/ai/tools/index.d.ts.map +1 -1
  12. package/dist/cjs/ai/tools/index.js +5 -2
  13. package/dist/cjs/ai/tools/index.js.map +1 -1
  14. package/dist/cjs/ai/tools/protocols/index.d.ts +9 -3
  15. package/dist/cjs/ai/tools/protocols/index.d.ts.map +1 -1
  16. package/dist/cjs/ai/tools/protocols/index.js +16 -2
  17. package/dist/cjs/ai/tools/protocols/index.js.map +1 -1
  18. package/dist/cjs/ai/tools/protocols/jupiter/schemas.d.ts +1 -1
  19. package/dist/cjs/ai/tools/protocols/jupiter/schemas.d.ts.map +1 -1
  20. package/dist/cjs/ai/tools/protocols/jupiter/schemas.js +126 -28
  21. package/dist/cjs/ai/tools/protocols/jupiter/schemas.js.map +1 -1
  22. package/dist/cjs/ai/tools/protocols/jupiter/tools.d.ts +4 -3
  23. package/dist/cjs/ai/tools/protocols/jupiter/tools.d.ts.map +1 -1
  24. package/dist/cjs/ai/tools/protocols/jupiter/tools.js +91 -9
  25. package/dist/cjs/ai/tools/protocols/jupiter/tools.js.map +1 -1
  26. package/dist/cjs/ai/tools/protocols/jupiter-onchain/tools.d.ts +4 -4
  27. package/dist/cjs/ai/tools/protocols/jupiter-onchain/tools.d.ts.map +1 -1
  28. package/dist/cjs/ai/tools/protocols/jupiter-onchain/tools.js +1 -1
  29. package/dist/cjs/ai/tools/protocols/jupiter-onchain/tools.js.map +1 -1
  30. package/dist/cjs/ai/tools/protocols/metaplex/tools.d.ts +7 -4
  31. package/dist/cjs/ai/tools/protocols/metaplex/tools.d.ts.map +1 -1
  32. package/dist/cjs/ai/tools/protocols/metaplex/tools.js +4 -1
  33. package/dist/cjs/ai/tools/protocols/metaplex/tools.js.map +1 -1
  34. package/dist/cjs/ai/tools/protocols/raydium-onchain/tools.d.ts +4 -4
  35. package/dist/cjs/ai/tools/protocols/raydium-onchain/tools.d.ts.map +1 -1
  36. package/dist/cjs/ai/tools/protocols/raydium-onchain/tools.js +1 -1
  37. package/dist/cjs/ai/tools/protocols/raydium-onchain/tools.js.map +1 -1
  38. package/dist/cjs/ai/tools/protocols/solana-programs/index.d.ts +7 -0
  39. package/dist/cjs/ai/tools/protocols/solana-programs/index.d.ts.map +1 -0
  40. package/dist/cjs/ai/tools/protocols/solana-programs/index.js +13 -0
  41. package/dist/cjs/ai/tools/protocols/solana-programs/index.js.map +1 -0
  42. package/dist/cjs/ai/tools/protocols/solana-programs/schemas.d.ts +11 -0
  43. package/dist/cjs/ai/tools/protocols/solana-programs/schemas.d.ts.map +1 -0
  44. package/dist/cjs/ai/tools/protocols/solana-programs/schemas.js +160 -0
  45. package/dist/cjs/ai/tools/protocols/solana-programs/schemas.js.map +1 -0
  46. package/dist/cjs/ai/tools/protocols/solana-programs/tools.d.ts +57 -0
  47. package/dist/cjs/ai/tools/protocols/solana-programs/tools.d.ts.map +1 -0
  48. package/dist/cjs/ai/tools/protocols/solana-programs/tools.js +226 -0
  49. package/dist/cjs/ai/tools/protocols/solana-programs/tools.js.map +1 -0
  50. package/dist/cjs/context/container.d.ts +341 -0
  51. package/dist/cjs/context/container.d.ts.map +1 -0
  52. package/dist/cjs/context/container.js +670 -0
  53. package/dist/cjs/context/container.js.map +1 -0
  54. package/dist/cjs/context/hooks.d.ts +357 -0
  55. package/dist/cjs/context/hooks.d.ts.map +1 -0
  56. package/dist/cjs/context/hooks.js +451 -0
  57. package/dist/cjs/context/hooks.js.map +1 -0
  58. package/dist/cjs/context/index.d.ts +81 -0
  59. package/dist/cjs/context/index.d.ts.map +1 -0
  60. package/dist/cjs/context/index.js +125 -0
  61. package/dist/cjs/context/index.js.map +1 -0
  62. package/dist/cjs/context/providers.d.ts +176 -0
  63. package/dist/cjs/context/providers.d.ts.map +1 -0
  64. package/dist/cjs/context/providers.js +184 -0
  65. package/dist/cjs/context/providers.js.map +1 -0
  66. package/dist/cjs/context/refs.d.ts +491 -0
  67. package/dist/cjs/context/refs.d.ts.map +1 -0
  68. package/dist/cjs/context/refs.js +673 -0
  69. package/dist/cjs/context/refs.js.map +1 -0
  70. package/dist/cjs/context/types.d.ts +251 -0
  71. package/dist/cjs/context/types.d.ts.map +1 -0
  72. package/dist/cjs/context/types.js +87 -0
  73. package/dist/cjs/context/types.js.map +1 -0
  74. package/dist/cjs/core/client.d.ts +31 -1
  75. package/dist/cjs/core/client.d.ts.map +1 -1
  76. package/dist/cjs/core/client.js.map +1 -1
  77. package/dist/cjs/index.d.ts +4 -1
  78. package/dist/cjs/index.d.ts.map +1 -1
  79. package/dist/cjs/index.js +6 -1
  80. package/dist/cjs/index.js.map +1 -1
  81. package/dist/cjs/programs/associated-token.d.ts +97 -0
  82. package/dist/cjs/programs/associated-token.d.ts.map +1 -0
  83. package/dist/cjs/programs/associated-token.js +113 -0
  84. package/dist/cjs/programs/associated-token.js.map +1 -0
  85. package/dist/cjs/programs/compute-budget.d.ts +105 -0
  86. package/dist/cjs/programs/compute-budget.d.ts.map +1 -0
  87. package/dist/cjs/programs/compute-budget.js +99 -0
  88. package/dist/cjs/programs/compute-budget.js.map +1 -0
  89. package/dist/cjs/programs/index.d.ts +74 -0
  90. package/dist/cjs/programs/index.d.ts.map +1 -0
  91. package/dist/cjs/programs/index.js +112 -0
  92. package/dist/cjs/programs/index.js.map +1 -0
  93. package/dist/cjs/programs/memo.d.ts +70 -0
  94. package/dist/cjs/programs/memo.d.ts.map +1 -0
  95. package/dist/cjs/programs/memo.js +74 -0
  96. package/dist/cjs/programs/memo.js.map +1 -0
  97. package/dist/cjs/programs/spl-token.d.ts +373 -0
  98. package/dist/cjs/programs/spl-token.d.ts.map +1 -0
  99. package/dist/cjs/programs/spl-token.js +358 -0
  100. package/dist/cjs/programs/spl-token.js.map +1 -0
  101. package/dist/cjs/programs/system.d.ts +231 -0
  102. package/dist/cjs/programs/system.d.ts.map +1 -0
  103. package/dist/cjs/programs/system.js +231 -0
  104. package/dist/cjs/programs/system.js.map +1 -0
  105. package/dist/cjs/programs/types.d.ts +111 -0
  106. package/dist/cjs/programs/types.d.ts.map +1 -0
  107. package/dist/cjs/programs/types.js +166 -0
  108. package/dist/cjs/programs/types.js.map +1 -0
  109. package/dist/docs/assets/navigation.js +1 -1
  110. package/dist/docs/assets/search.js +1 -1
  111. package/dist/docs/classes/AccountReader.html +18 -18
  112. package/dist/docs/classes/AccountsClient.html +10 -10
  113. package/dist/docs/classes/AsyncProviderError.html +39 -0
  114. package/dist/docs/classes/CircularDependencyError.html +39 -0
  115. package/dist/docs/classes/DasClient.html +13 -13
  116. package/dist/docs/classes/GeyserParser.html +17 -17
  117. package/dist/docs/classes/GrpcTransport.html +6 -6
  118. package/dist/docs/classes/HttpTransport.html +4 -4
  119. package/dist/docs/classes/InstructionWriter.html +37 -0
  120. package/dist/docs/classes/MemoryGuard.html +27 -0
  121. package/dist/docs/classes/NetworkError.html +5 -5
  122. package/dist/docs/classes/RefRegistry.html +40 -0
  123. package/dist/docs/classes/RefReleasedError.html +39 -0
  124. package/dist/docs/classes/RpcMethodNotFoundError.html +4 -4
  125. package/dist/docs/classes/ServiceNotFoundError.html +39 -0
  126. package/dist/docs/classes/ServiceRef.html +60 -0
  127. package/dist/docs/classes/SolanaRpc.html +55 -55
  128. package/dist/docs/classes/SynapseClient.html +39 -27
  129. package/dist/docs/classes/SynapseContext.html +151 -0
  130. package/dist/docs/classes/SynapseError.html +4 -4
  131. package/dist/docs/classes/TimeoutError.html +4 -4
  132. package/dist/docs/classes/UpstreamError.html +6 -6
  133. package/dist/docs/classes/WeakServiceRef.html +17 -0
  134. package/dist/docs/classes/WsClient.html +10 -10
  135. package/dist/docs/enums/SynapseNetwork.html +2 -2
  136. package/dist/docs/enums/SynapseRegion.html +2 -2
  137. package/dist/docs/enums/TokenExtensionType.html +2 -2
  138. package/dist/docs/functions/Epoch-1.html +1 -1
  139. package/dist/docs/functions/Lamports-2.html +1 -1
  140. package/dist/docs/functions/Pubkey-1.html +1 -1
  141. package/dist/docs/functions/Sig.html +1 -1
  142. package/dist/docs/functions/Slot-1.html +1 -1
  143. package/dist/docs/functions/UnixTs.html +1 -1
  144. package/dist/docs/functions/autoSelectRegion.html +1 -1
  145. package/dist/docs/functions/autoWire.html +11 -0
  146. package/dist/docs/functions/base58Encode.html +1 -1
  147. package/dist/docs/functions/base64ToBytes.html +1 -1
  148. package/dist/docs/functions/chunk.html +1 -1
  149. package/dist/docs/functions/computeBalanceChanges.html +1 -1
  150. package/dist/docs/functions/computeTokenBalanceChanges.html +1 -1
  151. package/dist/docs/functions/createBareContext.html +6 -0
  152. package/dist/docs/functions/createBinding.html +11 -0
  153. package/dist/docs/functions/createBoundHook.html +8 -0
  154. package/dist/docs/functions/createReactAdapter.html +11 -0
  155. package/dist/docs/functions/createRefHook.html +10 -0
  156. package/dist/docs/functions/createServerMiddleware.html +11 -0
  157. package/dist/docs/functions/createServiceHook.html +10 -0
  158. package/dist/docs/functions/createSynapse.html +1 -1
  159. package/dist/docs/functions/createSynapseContext.html +12 -0
  160. package/dist/docs/functions/createToken.html +9 -0
  161. package/dist/docs/functions/decodeBase58.html +2 -0
  162. package/dist/docs/functions/decodeLookupTable.html +1 -1
  163. package/dist/docs/functions/decodeMint.html +1 -1
  164. package/dist/docs/functions/decodeMultisig.html +1 -1
  165. package/dist/docs/functions/decodeNonceAccount.html +1 -1
  166. package/dist/docs/functions/decodeStakeAccount.html +1 -1
  167. package/dist/docs/functions/decodeToken2022Account.html +1 -1
  168. package/dist/docs/functions/decodeToken2022Mint.html +1 -1
  169. package/dist/docs/functions/decodeTokenAccount.html +1 -1
  170. package/dist/docs/functions/encodeBase58.html +1 -1
  171. package/dist/docs/functions/fetchLookupTable.html +1 -1
  172. package/dist/docs/functions/fetchMint.html +1 -1
  173. package/dist/docs/functions/fetchNonceAccount.html +1 -1
  174. package/dist/docs/functions/fetchStakeAccount.html +1 -1
  175. package/dist/docs/functions/fetchTokenAccount.html +1 -1
  176. package/dist/docs/functions/fetchTokenAccountsByOwner.html +1 -1
  177. package/dist/docs/functions/fromKitAddress.html +1 -1
  178. package/dist/docs/functions/getAccountInfo.html +1 -1
  179. package/dist/docs/functions/getAsset.html +1 -1
  180. package/dist/docs/functions/getAssetBatch.html +1 -1
  181. package/dist/docs/functions/getAssetProof.html +1 -1
  182. package/dist/docs/functions/getAssetProofBatch.html +1 -1
  183. package/dist/docs/functions/getAssetsByAuthority.html +1 -1
  184. package/dist/docs/functions/getAssetsByCreator.html +1 -1
  185. package/dist/docs/functions/getAssetsByGroup.html +1 -1
  186. package/dist/docs/functions/getAssetsByOwner.html +1 -1
  187. package/dist/docs/functions/getBalance.html +1 -1
  188. package/dist/docs/functions/getBlock.html +1 -1
  189. package/dist/docs/functions/getBlockCommitment.html +1 -1
  190. package/dist/docs/functions/getBlockHeight.html +1 -1
  191. package/dist/docs/functions/getBlockProduction.html +1 -1
  192. package/dist/docs/functions/getBlockTime.html +1 -1
  193. package/dist/docs/functions/getBlocks.html +1 -1
  194. package/dist/docs/functions/getBlocksWithLimit.html +1 -1
  195. package/dist/docs/functions/getClusterNodes.html +1 -1
  196. package/dist/docs/functions/getContext.html +4 -0
  197. package/dist/docs/functions/getDecodedAccount.html +1 -1
  198. package/dist/docs/functions/getDecodedAccounts.html +1 -1
  199. package/dist/docs/functions/getEnvironment.html +1 -1
  200. package/dist/docs/functions/getEpochInfo.html +1 -1
  201. package/dist/docs/functions/getEpochSchedule.html +1 -1
  202. package/dist/docs/functions/getFeeForMessage.html +1 -1
  203. package/dist/docs/functions/getFirstAvailableBlock.html +1 -1
  204. package/dist/docs/functions/getGenesisHash.html +1 -1
  205. package/dist/docs/functions/getHealth.html +1 -1
  206. package/dist/docs/functions/getHighestSnapshotSlot.html +1 -1
  207. package/dist/docs/functions/getIdentity.html +1 -1
  208. package/dist/docs/functions/getInflationGovernor.html +1 -1
  209. package/dist/docs/functions/getInflationRate.html +1 -1
  210. package/dist/docs/functions/getInflationReward.html +1 -1
  211. package/dist/docs/functions/getLargestAccounts.html +1 -1
  212. package/dist/docs/functions/getLatestBlockhash.html +1 -1
  213. package/dist/docs/functions/getLeaderSchedule.html +1 -1
  214. package/dist/docs/functions/getMaxRetransmitSlot.html +1 -1
  215. package/dist/docs/functions/getMaxShredInsertSlot.html +1 -1
  216. package/dist/docs/functions/getMinimumBalanceForRentExemption.html +1 -1
  217. package/dist/docs/functions/getMultipleAccounts.html +1 -1
  218. package/dist/docs/functions/getProgramAccounts.html +1 -1
  219. package/dist/docs/functions/getProgramCategory.html +1 -1
  220. package/dist/docs/functions/getRecentPerformanceSamples.html +1 -1
  221. package/dist/docs/functions/getRecentPrioritizationFees.html +1 -1
  222. package/dist/docs/functions/getSignatureStatuses.html +1 -1
  223. package/dist/docs/functions/getSignaturesForAddress.html +1 -1
  224. package/dist/docs/functions/getSignaturesForAsset.html +1 -1
  225. package/dist/docs/functions/getSlot.html +1 -1
  226. package/dist/docs/functions/getSlotLeader.html +1 -1
  227. package/dist/docs/functions/getSlotLeaders.html +1 -1
  228. package/dist/docs/functions/getStakeActivation.html +1 -1
  229. package/dist/docs/functions/getStakeMinimumDelegation.html +1 -1
  230. package/dist/docs/functions/getSupply.html +1 -1
  231. package/dist/docs/functions/getTokenAccountBalance.html +1 -1
  232. package/dist/docs/functions/getTokenAccounts.html +1 -1
  233. package/dist/docs/functions/getTokenAccountsByDelegate.html +1 -1
  234. package/dist/docs/functions/getTokenAccountsByOwner.html +1 -1
  235. package/dist/docs/functions/getTokenLargestAccounts.html +1 -1
  236. package/dist/docs/functions/getTokenSupply.html +1 -1
  237. package/dist/docs/functions/getTransaction.html +1 -1
  238. package/dist/docs/functions/getTransactionCount.html +1 -1
  239. package/dist/docs/functions/getVersion.html +1 -1
  240. package/dist/docs/functions/getVoteAccounts.html +1 -1
  241. package/dist/docs/functions/isBlockhashValid.html +1 -1
  242. package/dist/docs/functions/isBrowser.html +1 -1
  243. package/dist/docs/functions/isDisposable.html +3 -0
  244. package/dist/docs/functions/isProgramInCategory.html +1 -1
  245. package/dist/docs/functions/isServer.html +1 -1
  246. package/dist/docs/functions/isValidPubkey.html +1 -1
  247. package/dist/docs/functions/isValidSignature.html +1 -1
  248. package/dist/docs/functions/lamportsToSol.html +1 -1
  249. package/dist/docs/functions/listEndpoints.html +1 -1
  250. package/dist/docs/functions/listNetworks.html +1 -1
  251. package/dist/docs/functions/listRegions.html +1 -1
  252. package/dist/docs/functions/minimumLedgerSlot.html +1 -1
  253. package/dist/docs/functions/parseAccountUpdate.html +1 -1
  254. package/dist/docs/functions/parseBlockMeta.html +1 -1
  255. package/dist/docs/functions/parseEntry.html +1 -1
  256. package/dist/docs/functions/parseGeyserUpdate.html +1 -1
  257. package/dist/docs/functions/parseSlotUpdate.html +1 -1
  258. package/dist/docs/functions/parseTimestamp.html +1 -1
  259. package/dist/docs/functions/parseTransaction.html +1 -1
  260. package/dist/docs/functions/probeLatency.html +1 -1
  261. package/dist/docs/functions/rawBufferToBase58.html +1 -1
  262. package/dist/docs/functions/rawBufferToBase64.html +1 -1
  263. package/dist/docs/functions/rawBufferToBytes.html +1 -1
  264. package/dist/docs/functions/rawBufferToHex.html +1 -1
  265. package/dist/docs/functions/readonly.html +3 -0
  266. package/dist/docs/functions/readonlySigner.html +3 -0
  267. package/dist/docs/functions/requestAirdrop.html +1 -1
  268. package/dist/docs/functions/resolveEndpoint.html +1 -1
  269. package/dist/docs/functions/resolveProgram.html +1 -1
  270. package/dist/docs/functions/resolveProgramBatch.html +1 -1
  271. package/dist/docs/functions/retry.html +1 -1
  272. package/dist/docs/functions/searchAssets.html +1 -1
  273. package/dist/docs/functions/sendTransaction.html +1 -1
  274. package/dist/docs/functions/setGlobalContext.html +9 -0
  275. package/dist/docs/functions/simulateTransaction.html +1 -1
  276. package/dist/docs/functions/sleep.html +1 -1
  277. package/dist/docs/functions/solToLamports.html +1 -1
  278. package/dist/docs/functions/toClientConfig.html +1 -1
  279. package/dist/docs/functions/toKitAddress.html +1 -1
  280. package/dist/docs/functions/toKitInstruction.html +9 -0
  281. package/dist/docs/functions/toKitLamports.html +1 -1
  282. package/dist/docs/functions/toKitSignatureString.html +1 -1
  283. package/dist/docs/functions/tryGetContext.html +3 -0
  284. package/dist/docs/functions/tryUseService.html +4 -0
  285. package/dist/docs/functions/useBoundServices.html +10 -0
  286. package/dist/docs/functions/useService.html +13 -0
  287. package/dist/docs/functions/useSharedRef.html +14 -0
  288. package/dist/docs/functions/withRef.html +14 -0
  289. package/dist/docs/functions/withRefAsync.html +12 -0
  290. package/dist/docs/functions/writable.html +3 -0
  291. package/dist/docs/functions/writableSigner.html +3 -0
  292. package/dist/docs/hierarchy.html +1 -1
  293. package/dist/docs/interfaces/AccountInfo.html +7 -7
  294. package/dist/docs/interfaces/AccountMeta.html +9 -0
  295. package/dist/docs/interfaces/AccountNotification.html +2 -2
  296. package/dist/docs/interfaces/AccountSubParams.html +2 -2
  297. package/dist/docs/interfaces/AddMemoParams.html +11 -0
  298. package/dist/docs/interfaces/AdvanceNonceParams.html +7 -0
  299. package/dist/docs/interfaces/AliasProvider.html +6 -0
  300. package/dist/docs/interfaces/AllocateParams.html +7 -0
  301. package/dist/docs/interfaces/ApproveCheckedParams.html +19 -0
  302. package/dist/docs/interfaces/ApproveParams.html +15 -0
  303. package/dist/docs/interfaces/AssetSignatureInfo.html +2 -2
  304. package/dist/docs/interfaces/AssetSignaturesPage.html +2 -2
  305. package/dist/docs/interfaces/AssignParams.html +7 -0
  306. package/dist/docs/interfaces/AsyncFactoryProvider.html +7 -0
  307. package/dist/docs/interfaces/AuthorizeNonceParams.html +9 -0
  308. package/dist/docs/interfaces/BalanceChange.html +6 -6
  309. package/dist/docs/interfaces/BlockProduction.html +3 -3
  310. package/dist/docs/interfaces/BlockResult.html +2 -2
  311. package/dist/docs/interfaces/BlockReward.html +2 -2
  312. package/dist/docs/interfaces/BlockhashResult.html +2 -2
  313. package/dist/docs/interfaces/BurnCheckedParams.html +17 -0
  314. package/dist/docs/interfaces/BurnParams.html +15 -0
  315. package/dist/docs/interfaces/CallOptions.html +6 -6
  316. package/dist/docs/interfaces/ClassProvider.html +6 -0
  317. package/dist/docs/interfaces/CloseAccountParams.html +13 -0
  318. package/dist/docs/interfaces/ConfirmedTransaction.html +6 -6
  319. package/dist/docs/interfaces/ContactInfo.html +2 -2
  320. package/dist/docs/interfaces/ContextAdapter.html +15 -0
  321. package/dist/docs/interfaces/ContextEvents.html +13 -0
  322. package/dist/docs/interfaces/ContextModule.html +12 -0
  323. package/dist/docs/interfaces/CreateATAParams.html +13 -0
  324. package/dist/docs/interfaces/CreateAccountParams.html +13 -0
  325. package/dist/docs/interfaces/CreateAccountWithSeedParams.html +17 -0
  326. package/dist/docs/interfaces/CreateSynapseContextOpts.html +18 -0
  327. package/dist/docs/interfaces/DasAsset.html +2 -2
  328. package/dist/docs/interfaces/DasAssetProof.html +2 -2
  329. package/dist/docs/interfaces/DasAuthority.html +2 -2
  330. package/dist/docs/interfaces/DasCompression.html +2 -2
  331. package/dist/docs/interfaces/DasContent.html +2 -2
  332. package/dist/docs/interfaces/DasCreator.html +2 -2
  333. package/dist/docs/interfaces/DasFile.html +2 -2
  334. package/dist/docs/interfaces/DasGrouping.html +2 -2
  335. package/dist/docs/interfaces/DasOpts.html +2 -2
  336. package/dist/docs/interfaces/DasOwnership.html +2 -2
  337. package/dist/docs/interfaces/DasPage.html +2 -2
  338. package/dist/docs/interfaces/DasRoyalty.html +2 -2
  339. package/dist/docs/interfaces/DasSearchParams.html +2 -2
  340. package/dist/docs/interfaces/DasSupply.html +2 -2
  341. package/dist/docs/interfaces/DataSlice.html +3 -3
  342. package/dist/docs/interfaces/DecodedAccountResult.html +4 -4
  343. package/dist/docs/interfaces/DecodedLookupTable.html +8 -8
  344. package/dist/docs/interfaces/DecodedMint.html +6 -6
  345. package/dist/docs/interfaces/DecodedMultisig.html +5 -5
  346. package/dist/docs/interfaces/DecodedNonceAccount.html +6 -6
  347. package/dist/docs/interfaces/DecodedStakeAccount.html +2 -2
  348. package/dist/docs/interfaces/DecodedToken2022Account.html +9 -9
  349. package/dist/docs/interfaces/DecodedToken2022Mint.html +6 -6
  350. package/dist/docs/interfaces/DecodedTokenAccount.html +9 -9
  351. package/dist/docs/interfaces/DefaultAccountStateExt.html +2 -2
  352. package/dist/docs/interfaces/Disposable.html +5 -0
  353. package/dist/docs/interfaces/EndpointConnectConfig.html +5 -5
  354. package/dist/docs/interfaces/EpochInfo.html +7 -7
  355. package/dist/docs/interfaces/EpochSchedule.html +2 -2
  356. package/dist/docs/interfaces/FactoryProvider.html +7 -0
  357. package/dist/docs/interfaces/FetchedMint.html +6 -6
  358. package/dist/docs/interfaces/FetchedTokenAccount.html +6 -6
  359. package/dist/docs/interfaces/FreezeThawParams.html +13 -0
  360. package/dist/docs/interfaces/GetAccountInfoOpts.html +6 -6
  361. package/dist/docs/interfaces/GetAssetsByAuthorityParams.html +2 -2
  362. package/dist/docs/interfaces/GetAssetsByCreatorParams.html +2 -2
  363. package/dist/docs/interfaces/GetAssetsByGroupParams.html +2 -2
  364. package/dist/docs/interfaces/GetAssetsByOwnerParams.html +2 -2
  365. package/dist/docs/interfaces/GetBlockOpts.html +6 -6
  366. package/dist/docs/interfaces/GetBlockProductionOpts.html +6 -6
  367. package/dist/docs/interfaces/GetMultipleAccountsOpts.html +6 -6
  368. package/dist/docs/interfaces/GetProgramAccountsOpts.html +6 -6
  369. package/dist/docs/interfaces/GetSignatureStatusesOpts.html +6 -6
  370. package/dist/docs/interfaces/GetSignaturesOpts.html +7 -7
  371. package/dist/docs/interfaces/GetTokenAccountsParams.html +2 -2
  372. package/dist/docs/interfaces/GetTransactionOpts.html +6 -6
  373. package/dist/docs/interfaces/GeyserParserConfig.html +6 -6
  374. package/dist/docs/interfaces/GeyserParserEvents.html +9 -9
  375. package/dist/docs/interfaces/GeyserParserStats.html +2 -2
  376. package/dist/docs/interfaces/GrpcCallOptions.html +2 -2
  377. package/dist/docs/interfaces/GrpcTransportConfig.html +6 -6
  378. package/dist/docs/interfaces/ImmutableOwnerExt.html +2 -2
  379. package/dist/docs/interfaces/InflationGovernor.html +2 -2
  380. package/dist/docs/interfaces/InflationRate.html +2 -2
  381. package/dist/docs/interfaces/InflationReward.html +2 -2
  382. package/dist/docs/interfaces/InitializeAccountParams.html +11 -0
  383. package/dist/docs/interfaces/InitializeMintParams.html +13 -0
  384. package/dist/docs/interfaces/InitializeNonceParams.html +7 -0
  385. package/dist/docs/interfaces/InterestBearingConfigExt.html +2 -2
  386. package/dist/docs/interfaces/LatencyProbeResult.html +2 -2
  387. package/dist/docs/interfaces/LeakReport.html +12 -0
  388. package/dist/docs/interfaces/LogsNotification.html +2 -2
  389. package/dist/docs/interfaces/LogsSubParams.html +2 -2
  390. package/dist/docs/interfaces/MemoTransferExt.html +2 -2
  391. package/dist/docs/interfaces/MemoryGuardConfig.html +20 -0
  392. package/dist/docs/interfaces/MetadataPointerExt.html +2 -2
  393. package/dist/docs/interfaces/MintCloseAuthorityExt.html +2 -2
  394. package/dist/docs/interfaces/MintToCheckedParams.html +17 -0
  395. package/dist/docs/interfaces/MintToParams.html +15 -0
  396. package/dist/docs/interfaces/NonTransferableExt.html +2 -2
  397. package/dist/docs/interfaces/PaginationOpts.html +2 -2
  398. package/dist/docs/interfaces/ParsedAccountUpdate.html +16 -16
  399. package/dist/docs/interfaces/ParsedBlockMeta.html +2 -2
  400. package/dist/docs/interfaces/ParsedEntry.html +2 -2
  401. package/dist/docs/interfaces/ParsedInstruction.html +9 -9
  402. package/dist/docs/interfaces/ParsedSlotUpdate.html +3 -3
  403. package/dist/docs/interfaces/ParsedTransaction.html +19 -19
  404. package/dist/docs/interfaces/PerfSample.html +2 -2
  405. package/dist/docs/interfaces/PermanentDelegateExt.html +2 -2
  406. package/dist/docs/interfaces/ProgramAccount.html +2 -2
  407. package/dist/docs/interfaces/ProgramNotification.html +2 -2
  408. package/dist/docs/interfaces/ProgramSubParams.html +2 -2
  409. package/dist/docs/interfaces/ProgramsBundle.html +108 -0
  410. package/dist/docs/interfaces/RawAccountInfo.html +2 -2
  411. package/dist/docs/interfaces/RawBlockMeta.html +2 -2
  412. package/dist/docs/interfaces/RawBuffer.html +2 -2
  413. package/dist/docs/interfaces/RawCompiledInstruction.html +2 -2
  414. package/dist/docs/interfaces/RawEntry.html +2 -2
  415. package/dist/docs/interfaces/RawGeyserUpdate.html +2 -2
  416. package/dist/docs/interfaces/RawInnerInstruction.html +2 -2
  417. package/dist/docs/interfaces/RawSlotInfo.html +2 -2
  418. package/dist/docs/interfaces/RawTimestamp.html +2 -2
  419. package/dist/docs/interfaces/RawTokenBalance.html +2 -2
  420. package/dist/docs/interfaces/RawTransactionInfo.html +2 -2
  421. package/dist/docs/interfaces/ReactAdapterConfig.html +8 -0
  422. package/dist/docs/interfaces/RecoverNestedParams.html +15 -0
  423. package/dist/docs/interfaces/RefRegistryConfig.html +9 -0
  424. package/dist/docs/interfaces/RefStats.html +15 -0
  425. package/dist/docs/interfaces/RequestHeapFrameParams.html +5 -0
  426. package/dist/docs/interfaces/ResolveMiddleware.html +8 -0
  427. package/dist/docs/interfaces/RevokeParams.html +11 -0
  428. package/dist/docs/interfaces/RootNotification.html +2 -2
  429. package/dist/docs/interfaces/RootSubParams.html +1 -1
  430. package/dist/docs/interfaces/RpcContext.html +2 -2
  431. package/dist/docs/interfaces/RpcError.html +4 -4
  432. package/dist/docs/interfaces/RpcRequest.html +2 -2
  433. package/dist/docs/interfaces/RpcResponse.html +2 -2
  434. package/dist/docs/interfaces/SendTransactionOpts.html +6 -6
  435. package/dist/docs/interfaces/ServerAdapterConfig.html +13 -0
  436. package/dist/docs/interfaces/ServiceBinding.html +17 -0
  437. package/dist/docs/interfaces/ServiceRegistration.html +7 -0
  438. package/dist/docs/interfaces/ServiceResolver.html +16 -0
  439. package/dist/docs/interfaces/ServiceToken.html +13 -0
  440. package/dist/docs/interfaces/SetComputeUnitLimitParams.html +5 -0
  441. package/dist/docs/interfaces/SetComputeUnitPriceParams.html +5 -0
  442. package/dist/docs/interfaces/SetLoadedAccountsDataSizeLimitParams.html +5 -0
  443. package/dist/docs/interfaces/SignatureInfo.html +7 -7
  444. package/dist/docs/interfaces/SignatureNotification.html +2 -2
  445. package/dist/docs/interfaces/SignatureStatus.html +5 -5
  446. package/dist/docs/interfaces/SignatureSubParams.html +2 -2
  447. package/dist/docs/interfaces/SignaturesForAssetParams.html +2 -2
  448. package/dist/docs/interfaces/SimulateResult.html +2 -2
  449. package/dist/docs/interfaces/SimulateTransactionOpts.html +7 -7
  450. package/dist/docs/interfaces/SlotNotification.html +2 -2
  451. package/dist/docs/interfaces/SlotSubParams.html +1 -1
  452. package/dist/docs/interfaces/SortOpts.html +2 -2
  453. package/dist/docs/interfaces/StakeAuthorized.html +2 -2
  454. package/dist/docs/interfaces/StakeDelegation.html +3 -3
  455. package/dist/docs/interfaces/StakeLockup.html +4 -4
  456. package/dist/docs/interfaces/StakeMeta.html +2 -2
  457. package/dist/docs/interfaces/Supply.html +5 -5
  458. package/dist/docs/interfaces/SynapseClientConfig.html +9 -9
  459. package/dist/docs/interfaces/SynapseClientLike.html +14 -0
  460. package/dist/docs/interfaces/SynapseEndpoint.html +7 -7
  461. package/dist/docs/interfaces/SyncNativeParams.html +7 -0
  462. package/dist/docs/interfaces/SystemTransferParams.html +9 -0
  463. package/dist/docs/interfaces/TokenAccount.html +3 -3
  464. package/dist/docs/interfaces/TokenAccountsByOwnerResult.html +2 -2
  465. package/dist/docs/interfaces/TokenAmount.html +5 -5
  466. package/dist/docs/interfaces/TokenBalanceChange.html +2 -2
  467. package/dist/docs/interfaces/TokenTransferParams.html +15 -0
  468. package/dist/docs/interfaces/TransactionInstruction.html +11 -0
  469. package/dist/docs/interfaces/TransactionMeta.html +11 -11
  470. package/dist/docs/interfaces/TransferCheckedParams.html +19 -0
  471. package/dist/docs/interfaces/TransferFeeAmount.html +2 -2
  472. package/dist/docs/interfaces/TransferFeeConfig.html +2 -2
  473. package/dist/docs/interfaces/TransportConfig.html +7 -7
  474. package/dist/docs/interfaces/UnknownExtension.html +2 -2
  475. package/dist/docs/interfaces/ValueProvider.html +4 -0
  476. package/dist/docs/interfaces/VoteAccount.html +9 -9
  477. package/dist/docs/interfaces/VoteAccountsResult.html +3 -3
  478. package/dist/docs/interfaces/WithdrawNonceParams.html +11 -0
  479. package/dist/docs/interfaces/WsConfig.html +6 -6
  480. package/dist/docs/media/CHANGELOG.md +114 -0
  481. package/dist/docs/modules.html +107 -1
  482. package/dist/docs/types/AccountFetchOpts.html +1 -1
  483. package/dist/docs/types/AccountFilter.html +1 -1
  484. package/dist/docs/types/Base58.html +1 -1
  485. package/dist/docs/types/Brand.html +1 -1
  486. package/dist/docs/types/Commitment.html +1 -1
  487. package/dist/docs/types/DasSortBy.html +1 -1
  488. package/dist/docs/types/DasSortDirection.html +1 -1
  489. package/dist/docs/types/DataSizeFilter.html +1 -1
  490. package/dist/docs/types/DecodedExtension.html +1 -1
  491. package/dist/docs/types/Encoding.html +1 -1
  492. package/dist/docs/types/Epoch.html +1 -1
  493. package/dist/docs/types/Lamports.html +1 -1
  494. package/dist/docs/types/LogsFilter.html +1 -1
  495. package/dist/docs/types/MemcmpFilter.html +1 -1
  496. package/dist/docs/types/NonceState.html +1 -1
  497. package/dist/docs/types/ParsedGeyserUpdate.html +1 -1
  498. package/dist/docs/types/Pubkey.html +1 -1
  499. package/dist/docs/types/RuntimeEnv.html +1 -1
  500. package/dist/docs/types/ServiceLifecycle.html +25 -0
  501. package/dist/docs/types/ServiceProvider.html +3 -0
  502. package/dist/docs/types/Signature.html +1 -1
  503. package/dist/docs/types/Slot.html +1 -1
  504. package/dist/docs/types/StakeAccountType.html +1 -1
  505. package/dist/docs/types/SubscriptionId.html +1 -1
  506. package/dist/docs/types/TokenAccountState.html +1 -1
  507. package/dist/docs/types/TransactionDetail.html +1 -1
  508. package/dist/docs/types/UnaryMethod.html +1 -1
  509. package/dist/docs/types/UnixTimestamp.html +1 -1
  510. package/dist/docs/types/WsNotification.html +1 -1
  511. package/dist/docs/variables/ASSOCIATED_TOKEN_PROGRAM.html +3 -0
  512. package/dist/docs/variables/AssociatedToken.html +13 -0
  513. package/dist/docs/variables/COMPUTE_BUDGET_PROGRAM.html +3 -0
  514. package/dist/docs/variables/ComputeBudget.html +19 -0
  515. package/dist/docs/variables/JUPITER_PROGRAMS.html +1 -1
  516. package/dist/docs/variables/KNOWN_PROGRAMS.html +1 -1
  517. package/dist/docs/variables/KNOWN_PROGRAMS_COUNT.html +1 -1
  518. package/dist/docs/variables/LOOKUP_TABLE_HEADER_SIZE.html +1 -1
  519. package/dist/docs/variables/LOOKUP_TABLE_PROGRAM_ID.html +1 -1
  520. package/dist/docs/variables/MARINADE_PROGRAMS.html +1 -1
  521. package/dist/docs/variables/MAX_MULTISIG_SIGNERS.html +1 -1
  522. package/dist/docs/variables/MEMO_PROGRAM_V1.html +3 -0
  523. package/dist/docs/variables/MEMO_PROGRAM_V2.html +3 -0
  524. package/dist/docs/variables/METAPLEX_PROGRAMS.html +1 -1
  525. package/dist/docs/variables/METEORA_PROGRAMS.html +1 -1
  526. package/dist/docs/variables/MINT_SIZE.html +1 -1
  527. package/dist/docs/variables/MULTISIG_SIZE.html +1 -1
  528. package/dist/docs/variables/Memo.html +9 -0
  529. package/dist/docs/variables/NONCE_ACCOUNT_SIZE.html +1 -1
  530. package/dist/docs/variables/ORCA_PROGRAMS.html +1 -1
  531. package/dist/docs/variables/OTHER_PROGRAMS.html +1 -1
  532. package/dist/docs/variables/RAYDIUM_PROGRAMS.html +1 -1
  533. package/dist/docs/variables/SDK_USER_AGENT.html +1 -1
  534. package/dist/docs/variables/SPL_PROGRAMS.html +1 -1
  535. package/dist/docs/variables/STAKE_PROGRAM_ID.html +1 -1
  536. package/dist/docs/variables/SYNAPSE_DEVNET_EU.html +1 -1
  537. package/dist/docs/variables/SYNAPSE_DEVNET_US.html +1 -1
  538. package/dist/docs/variables/SYNAPSE_ENDPOINTS.html +1 -1
  539. package/dist/docs/variables/SYNAPSE_MAINNET_EU.html +1 -1
  540. package/dist/docs/variables/SYNAPSE_MAINNET_US.html +1 -1
  541. package/dist/docs/variables/SYSTEM_PROGRAM.html +3 -0
  542. package/dist/docs/variables/SYSTEM_PROGRAMS.html +1 -1
  543. package/dist/docs/variables/SYSTEM_PROGRAM_ID.html +1 -1
  544. package/dist/docs/variables/SplToken.html +38 -0
  545. package/dist/docs/variables/SystemProgram.html +42 -0
  546. package/dist/docs/variables/TOKEN_2022_PROGRAM.html +3 -0
  547. package/dist/docs/variables/TOKEN_2022_PROGRAM_ID.html +1 -1
  548. package/dist/docs/variables/TOKEN_ACCOUNT_SIZE.html +1 -1
  549. package/dist/docs/variables/TOKEN_PROGRAM.html +3 -0
  550. package/dist/docs/variables/TOKEN_PROGRAM_ID.html +1 -1
  551. package/dist/docs/variables/Tokens.html +16 -0
  552. package/dist/esm/ai/gateway/index.d.ts +5 -5
  553. package/dist/esm/ai/gateway/index.d.ts.map +1 -1
  554. package/dist/esm/ai/gateway/index.js +2 -2
  555. package/dist/esm/ai/gateway/index.js.map +1 -1
  556. package/dist/esm/ai/index.d.ts +1 -1
  557. package/dist/esm/ai/index.d.ts.map +1 -1
  558. package/dist/esm/ai/index.js +2 -2
  559. package/dist/esm/ai/index.js.map +1 -1
  560. package/dist/esm/ai/tools/index.d.ts +4 -4
  561. package/dist/esm/ai/tools/index.d.ts.map +1 -1
  562. package/dist/esm/ai/tools/index.js +3 -3
  563. package/dist/esm/ai/tools/index.js.map +1 -1
  564. package/dist/esm/ai/tools/protocols/index.d.ts +9 -3
  565. package/dist/esm/ai/tools/protocols/index.d.ts.map +1 -1
  566. package/dist/esm/ai/tools/protocols/index.js +12 -1
  567. package/dist/esm/ai/tools/protocols/index.js.map +1 -1
  568. package/dist/esm/ai/tools/protocols/jupiter/schemas.d.ts +1 -1
  569. package/dist/esm/ai/tools/protocols/jupiter/schemas.d.ts.map +1 -1
  570. package/dist/esm/ai/tools/protocols/jupiter/schemas.js +126 -28
  571. package/dist/esm/ai/tools/protocols/jupiter/schemas.js.map +1 -1
  572. package/dist/esm/ai/tools/protocols/jupiter/tools.d.ts +4 -3
  573. package/dist/esm/ai/tools/protocols/jupiter/tools.d.ts.map +1 -1
  574. package/dist/esm/ai/tools/protocols/jupiter/tools.js +91 -9
  575. package/dist/esm/ai/tools/protocols/jupiter/tools.js.map +1 -1
  576. package/dist/esm/ai/tools/protocols/jupiter-onchain/tools.d.ts +4 -4
  577. package/dist/esm/ai/tools/protocols/jupiter-onchain/tools.d.ts.map +1 -1
  578. package/dist/esm/ai/tools/protocols/jupiter-onchain/tools.js +1 -1
  579. package/dist/esm/ai/tools/protocols/jupiter-onchain/tools.js.map +1 -1
  580. package/dist/esm/ai/tools/protocols/metaplex/tools.d.ts +7 -4
  581. package/dist/esm/ai/tools/protocols/metaplex/tools.d.ts.map +1 -1
  582. package/dist/esm/ai/tools/protocols/metaplex/tools.js +4 -1
  583. package/dist/esm/ai/tools/protocols/metaplex/tools.js.map +1 -1
  584. package/dist/esm/ai/tools/protocols/raydium-onchain/tools.d.ts +4 -4
  585. package/dist/esm/ai/tools/protocols/raydium-onchain/tools.d.ts.map +1 -1
  586. package/dist/esm/ai/tools/protocols/raydium-onchain/tools.js +1 -1
  587. package/dist/esm/ai/tools/protocols/raydium-onchain/tools.js.map +1 -1
  588. package/dist/esm/ai/tools/protocols/solana-programs/index.d.ts +7 -0
  589. package/dist/esm/ai/tools/protocols/solana-programs/index.d.ts.map +1 -0
  590. package/dist/esm/ai/tools/protocols/solana-programs/index.js +7 -0
  591. package/dist/esm/ai/tools/protocols/solana-programs/index.js.map +1 -0
  592. package/dist/esm/ai/tools/protocols/solana-programs/schemas.d.ts +11 -0
  593. package/dist/esm/ai/tools/protocols/solana-programs/schemas.d.ts.map +1 -0
  594. package/dist/esm/ai/tools/protocols/solana-programs/schemas.js +157 -0
  595. package/dist/esm/ai/tools/protocols/solana-programs/schemas.js.map +1 -0
  596. package/dist/esm/ai/tools/protocols/solana-programs/tools.d.ts +57 -0
  597. package/dist/esm/ai/tools/protocols/solana-programs/tools.d.ts.map +1 -0
  598. package/dist/esm/ai/tools/protocols/solana-programs/tools.js +220 -0
  599. package/dist/esm/ai/tools/protocols/solana-programs/tools.js.map +1 -0
  600. package/dist/esm/context/container.d.ts +341 -0
  601. package/dist/esm/context/container.d.ts.map +1 -0
  602. package/dist/esm/context/container.js +666 -0
  603. package/dist/esm/context/container.js.map +1 -0
  604. package/dist/esm/context/hooks.d.ts +357 -0
  605. package/dist/esm/context/hooks.d.ts.map +1 -0
  606. package/dist/esm/context/hooks.js +434 -0
  607. package/dist/esm/context/hooks.js.map +1 -0
  608. package/dist/esm/context/index.d.ts +81 -0
  609. package/dist/esm/context/index.d.ts.map +1 -0
  610. package/dist/esm/context/index.js +98 -0
  611. package/dist/esm/context/index.js.map +1 -0
  612. package/dist/esm/context/providers.d.ts +176 -0
  613. package/dist/esm/context/providers.d.ts.map +1 -0
  614. package/dist/esm/context/providers.js +179 -0
  615. package/dist/esm/context/providers.js.map +1 -0
  616. package/dist/esm/context/refs.d.ts +491 -0
  617. package/dist/esm/context/refs.d.ts.map +1 -0
  618. package/dist/esm/context/refs.js +664 -0
  619. package/dist/esm/context/refs.js.map +1 -0
  620. package/dist/esm/context/types.d.ts +251 -0
  621. package/dist/esm/context/types.d.ts.map +1 -0
  622. package/dist/esm/context/types.js +79 -0
  623. package/dist/esm/context/types.js.map +1 -0
  624. package/dist/esm/core/client.d.ts +31 -1
  625. package/dist/esm/core/client.d.ts.map +1 -1
  626. package/dist/esm/core/client.js.map +1 -1
  627. package/dist/esm/index.d.ts +4 -1
  628. package/dist/esm/index.d.ts.map +1 -1
  629. package/dist/esm/index.js +6 -1
  630. package/dist/esm/index.js.map +1 -1
  631. package/dist/esm/programs/associated-token.d.ts +97 -0
  632. package/dist/esm/programs/associated-token.d.ts.map +1 -0
  633. package/dist/esm/programs/associated-token.js +110 -0
  634. package/dist/esm/programs/associated-token.js.map +1 -0
  635. package/dist/esm/programs/compute-budget.d.ts +105 -0
  636. package/dist/esm/programs/compute-budget.d.ts.map +1 -0
  637. package/dist/esm/programs/compute-budget.js +96 -0
  638. package/dist/esm/programs/compute-budget.js.map +1 -0
  639. package/dist/esm/programs/index.d.ts +74 -0
  640. package/dist/esm/programs/index.d.ts.map +1 -0
  641. package/dist/esm/programs/index.js +90 -0
  642. package/dist/esm/programs/index.js.map +1 -0
  643. package/dist/esm/programs/memo.d.ts +70 -0
  644. package/dist/esm/programs/memo.d.ts.map +1 -0
  645. package/dist/esm/programs/memo.js +71 -0
  646. package/dist/esm/programs/memo.js.map +1 -0
  647. package/dist/esm/programs/spl-token.d.ts +373 -0
  648. package/dist/esm/programs/spl-token.d.ts.map +1 -0
  649. package/dist/esm/programs/spl-token.js +355 -0
  650. package/dist/esm/programs/spl-token.js.map +1 -0
  651. package/dist/esm/programs/system.d.ts +231 -0
  652. package/dist/esm/programs/system.d.ts.map +1 -0
  653. package/dist/esm/programs/system.js +228 -0
  654. package/dist/esm/programs/system.js.map +1 -0
  655. package/dist/esm/programs/types.d.ts +111 -0
  656. package/dist/esm/programs/types.d.ts.map +1 -0
  657. package/dist/esm/programs/types.js +157 -0
  658. package/dist/esm/programs/types.js.map +1 -0
  659. package/package.json +41 -1
@@ -0,0 +1,451 @@
1
+ "use strict";
2
+ /**
3
+ * Framework-agnostic hooks and adapters for the Synapse context provider.
4
+ *
5
+ * Provides utilities to integrate the IoC container with any UI framework
6
+ * (React, Vue, Svelte, etc.) or backend framework (Express, Fastify,
7
+ * NestJS, etc.) via a simple adapter interface.
8
+ *
9
+ * ## Architecture
10
+ *
11
+ * ```
12
+ * ┌──────────────────────────────────────────────────┐
13
+ * │ ContextAdapter<Framework> │
14
+ * │ ┌────────────────────┐ ┌─────────────────────┐ │
15
+ * │ │ React: useService │ │ Express: middleware │ │
16
+ * │ │ Vue: inject │ │ Fastify: decorator │ │
17
+ * │ └────────────────────┘ └─────────────────────┘ │
18
+ * │ │ │ │
19
+ * │ ▼ ▼ │
20
+ * │ ┌──────────────────────────────────────────────┐ │
21
+ * │ │ SynapseContext (IoC core) │ │
22
+ * │ └──────────────────────────────────────────────┘ │
23
+ * └──────────────────────────────────────────────────┘
24
+ * ```
25
+ *
26
+ * @module context/hooks
27
+ * @since 1.2.0
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.setGlobalContext = setGlobalContext;
31
+ exports.getContext = getContext;
32
+ exports.tryGetContext = tryGetContext;
33
+ exports.useService = useService;
34
+ exports.tryUseService = tryUseService;
35
+ exports.createReactAdapter = createReactAdapter;
36
+ exports.createServerMiddleware = createServerMiddleware;
37
+ exports.createServiceHook = createServiceHook;
38
+ exports.createBoundHook = createBoundHook;
39
+ exports.autoWire = autoWire;
40
+ exports.useSharedRef = useSharedRef;
41
+ exports.useBoundServices = useBoundServices;
42
+ exports.withRef = withRef;
43
+ exports.withRefAsync = withRefAsync;
44
+ exports.createRefHook = createRefHook;
45
+ // ── Global context holder ──────────────────────────────────────
46
+ /**
47
+ * Module-level reference to the "current" context.
48
+ *
49
+ * Framework adapters can set this to make `getContext()` and
50
+ * `useService()` work without passing the context explicitly.
51
+ *
52
+ * @since 1.2.0
53
+ */
54
+ let _globalContext;
55
+ /**
56
+ * Set the global context reference.
57
+ *
58
+ * Call this once during application bootstrap. Framework adapters
59
+ * call this automatically.
60
+ *
61
+ * @param ctx - The context to make globally available.
62
+ * @since 1.2.0
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const ctx = createSynapseContext(config);
67
+ * setGlobalContext(ctx);
68
+ * ```
69
+ */
70
+ function setGlobalContext(ctx) {
71
+ _globalContext = ctx;
72
+ }
73
+ /**
74
+ * Get the current global context.
75
+ *
76
+ * @throws {Error} If no context has been set.
77
+ * @since 1.2.0
78
+ */
79
+ function getContext() {
80
+ if (!_globalContext) {
81
+ throw new Error('No Synapse context set. Call setGlobalContext(ctx) or use a framework adapter ' +
82
+ '(e.g. SynapseProvider for React) before calling getContext().');
83
+ }
84
+ return _globalContext;
85
+ }
86
+ /**
87
+ * Try to get the global context; returns `undefined` if not set.
88
+ * @since 1.2.0
89
+ */
90
+ function tryGetContext() {
91
+ return _globalContext;
92
+ }
93
+ // ── Framework-agnostic service accessor ────────────────────────
94
+ /**
95
+ * Resolve a service from the global context.
96
+ *
97
+ * This is the simplest way to access services without dependency on
98
+ * any specific framework. Works in Node.js, Deno, Bun, and browsers.
99
+ *
100
+ * @typeParam T - The service type.
101
+ * @param token - The service token to resolve.
102
+ * @returns The resolved service instance.
103
+ * @throws {Error} If no context is set.
104
+ * @throws {ServiceNotFoundError} If the token is not registered.
105
+ * @since 1.2.0
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * import { useService, Tokens } from '@oobe-protocol-labs/synapse-client-sdk/context';
110
+ *
111
+ * const rpc = useService(Tokens.RPC);
112
+ * const balance = await rpc.getBalance(pubkey);
113
+ * ```
114
+ */
115
+ function useService(token) {
116
+ return getContext().resolve(token);
117
+ }
118
+ /**
119
+ * Try to resolve a service from the global context.
120
+ * Returns `undefined` if no context is set or the token is not registered.
121
+ *
122
+ * @since 1.2.0
123
+ */
124
+ function tryUseService(token) {
125
+ const ctx = tryGetContext();
126
+ if (!ctx)
127
+ return undefined;
128
+ return ctx.tryResolve(token);
129
+ }
130
+ /**
131
+ * Creates a React adapter blueprint.
132
+ *
133
+ * This does NOT depend on React — it returns plain functions and
134
+ * descriptors that a React wrapper can use. This keeps React as
135
+ * an optional peer dependency.
136
+ *
137
+ * @param ctx - The Synapse context to wrap.
138
+ * @returns Adapter blueprint with `Provider` props and hook factories.
139
+ * @since 1.2.0
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * // In your React app:
144
+ * import React, { createContext, useContext } from 'react';
145
+ * import { createReactAdapter, Tokens } from '@oobe-protocol-labs/synapse-client-sdk/context';
146
+ *
147
+ * const adapter = createReactAdapter(ctx);
148
+ * const SynapseReactContext = createContext(adapter.context);
149
+ *
150
+ * function SynapseProvider({ children }) {
151
+ * adapter.init({ setGlobal: true });
152
+ * return <SynapseReactContext.Provider value={adapter.context}>{children}</SynapseReactContext.Provider>;
153
+ * }
154
+ *
155
+ * function useRpc() {
156
+ * const ctx = useContext(SynapseReactContext);
157
+ * return ctx.resolve(Tokens.RPC);
158
+ * }
159
+ * ```
160
+ */
161
+ function createReactAdapter(ctx) {
162
+ return {
163
+ name: 'react',
164
+ context: ctx,
165
+ init(opts) {
166
+ if (opts?.setGlobal !== false) {
167
+ setGlobalContext(ctx);
168
+ }
169
+ },
170
+ destroy() {
171
+ if (_globalContext === ctx) {
172
+ setGlobalContext(undefined);
173
+ }
174
+ },
175
+ };
176
+ }
177
+ /**
178
+ * Create request-scoped middleware for Express/Fastify-style servers.
179
+ *
180
+ * Returns a middleware function that creates a child scope per
181
+ * request and attaches it to `req[contextKey]`.
182
+ *
183
+ * @param ctx - The root Synapse context.
184
+ * @param opts - Server adapter options.
185
+ * @returns A middleware function `(req, res, next) => void`.
186
+ * @since 1.2.0
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * import express from 'express';
191
+ * import { createSynapseContext, createServerMiddleware, Tokens } from '@oobe-protocol-labs/synapse-client-sdk/context';
192
+ *
193
+ * const ctx = createSynapseContext(config);
194
+ * const app = express();
195
+ *
196
+ * app.use(createServerMiddleware(ctx));
197
+ *
198
+ * app.get('/balance/:address', async (req, res) => {
199
+ * const scope = req.synapseCtx;
200
+ * const rpc = scope.resolve(Tokens.RPC);
201
+ * const balance = await rpc.getBalance(Pubkey(req.params.address));
202
+ * res.json({ balance });
203
+ * });
204
+ * ```
205
+ */
206
+ function createServerMiddleware(ctx, opts = {}) {
207
+ const key = opts.contextKey ?? 'synapseCtx';
208
+ const scoped = opts.scopePerRequest !== false;
209
+ return (req, _res, next) => {
210
+ if (scoped) {
211
+ const requestId = req['id']
212
+ ?? `req-${Math.random().toString(36).slice(2, 9)}`;
213
+ const scope = ctx.createScope(requestId);
214
+ req[key] = scope;
215
+ // Auto-dispose the scope when the response finishes
216
+ const res = _res;
217
+ if (res && typeof res.on === 'function') {
218
+ res.on('finish', () => { scope.dispose().catch(() => { }); });
219
+ }
220
+ }
221
+ else {
222
+ req[key] = ctx;
223
+ }
224
+ next();
225
+ };
226
+ }
227
+ // ── Composable service "hooks" (framework-agnostic) ────────────
228
+ /**
229
+ * Create a typed accessor function bound to a specific token.
230
+ *
231
+ * Returns a zero-argument function that resolves the service from
232
+ * the global context. Perfect for composable patterns.
233
+ *
234
+ * @param token - The service token.
235
+ * @returns A function `() => T` that resolves on each call.
236
+ * @since 1.2.0
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * // Define once:
241
+ * const useRpc = createServiceHook(Tokens.RPC);
242
+ * const useDas = createServiceHook(Tokens.DAS);
243
+ *
244
+ * // Use anywhere:
245
+ * const rpc = useRpc();
246
+ * ```
247
+ */
248
+ function createServiceHook(token) {
249
+ return () => useService(token);
250
+ }
251
+ /**
252
+ * Create a typed accessor bound to a specific context instance.
253
+ *
254
+ * Unlike `createServiceHook`, this does not use the global context —
255
+ * it's bound directly to the provided context.
256
+ *
257
+ * @param ctx - The context to bind to.
258
+ * @param token - The service token.
259
+ * @returns A function `() => T`.
260
+ * @since 1.2.0
261
+ */
262
+ function createBoundHook(ctx, token) {
263
+ return () => ctx.resolve(token);
264
+ }
265
+ // ── Utility: auto-wire ─────────────────────────────────────────
266
+ /**
267
+ * Wire a plain object's methods to use services from the context.
268
+ *
269
+ * Creates a Proxy that resolves services lazily on property access.
270
+ * Useful for creating "service bags" that group multiple services.
271
+ *
272
+ * @param ctx - The context to resolve from.
273
+ * @param tokens - A record of property names → service tokens.
274
+ * @returns A proxy object with lazy-resolved properties.
275
+ * @since 1.2.0
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * const services = autoWire(ctx, {
280
+ * rpc: Tokens.RPC,
281
+ * das: Tokens.DAS,
282
+ * programs: Tokens.PROGRAMS,
283
+ * });
284
+ *
285
+ * // Each property is resolved lazily:
286
+ * const balance = await services.rpc.getBalance(pubkey);
287
+ * const asset = await services.das.getAsset(assetId);
288
+ * ```
289
+ */
290
+ function autoWire(ctx, tokens) {
291
+ const cache = new Map();
292
+ return new Proxy({}, {
293
+ get(_target, prop) {
294
+ if (typeof prop === 'symbol')
295
+ return undefined;
296
+ if (cache.has(prop))
297
+ return cache.get(prop);
298
+ const token = tokens[prop];
299
+ if (!token)
300
+ return undefined;
301
+ const instance = ctx.resolve(token);
302
+ cache.set(prop, instance);
303
+ return instance;
304
+ },
305
+ has(_target, prop) {
306
+ return typeof prop === 'string' && prop in tokens;
307
+ },
308
+ ownKeys() {
309
+ return Object.keys(tokens);
310
+ },
311
+ getOwnPropertyDescriptor(_target, prop) {
312
+ if (typeof prop === 'string' && prop in tokens) {
313
+ return { configurable: true, enumerable: true, writable: false };
314
+ }
315
+ return undefined;
316
+ },
317
+ });
318
+ }
319
+ // ── Memory-safe ref hooks ──────────────────────────────────────
320
+ /**
321
+ * Acquire a tracked, ref-counted reference from the global context.
322
+ *
323
+ * The returned {@link ServiceRef} **must** be `.release()`'d when the
324
+ * component/module is done with the service. This ensures the SDK can
325
+ * track how many consumers hold a service and detect leaks.
326
+ *
327
+ * @typeParam T - The service type.
328
+ * @param token - The service token.
329
+ * @returns A new `ServiceRef<T>`.
330
+ * @throws {Error} If no global context is set.
331
+ * @throws {ServiceNotFoundError} If the token is not registered.
332
+ * @since 1.2.0
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * // In a React component:
337
+ * useEffect(() => {
338
+ * const rpcRef = useSharedRef(Tokens.RPC);
339
+ * rpcRef.current.getBalance(pubkey).then(setBalance);
340
+ * return () => rpcRef.release(); // cleanup on unmount
341
+ * }, []);
342
+ * ```
343
+ */
344
+ function useSharedRef(token) {
345
+ return getContext().acquireRef(token);
346
+ }
347
+ /**
348
+ * Acquire tracked refs for multiple tokens from the global context.
349
+ *
350
+ * Returns a {@link ServiceBinding} whose `.services` proxy lazily
351
+ * resolves each token. A single `.release()` frees all refs at once.
352
+ *
353
+ * @param tokens - Record mapping property names to service tokens.
354
+ * @returns A binding with lazy services and batch release.
355
+ * @since 1.2.0
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * const binding = useBoundServices({
360
+ * rpc: Tokens.RPC,
361
+ * das: Tokens.DAS,
362
+ * });
363
+ *
364
+ * await binding.services.rpc.getBalance(pubkey);
365
+ * binding.release(); // releases all
366
+ * ```
367
+ */
368
+ function useBoundServices(tokens) {
369
+ return getContext().bind(tokens);
370
+ }
371
+ /**
372
+ * RAII pattern: acquire a ref, run `fn`, auto-release.
373
+ *
374
+ * The ref is released in a `finally` block so cleanup is guaranteed
375
+ * even if `fn` throws. Zero chance of leaking.
376
+ *
377
+ * @typeParam T - The service type.
378
+ * @typeParam R - The return type of `fn`.
379
+ * @param ctx - The context to acquire from.
380
+ * @param token - The service token.
381
+ * @param fn - Receives the unwrapped service value.
382
+ * @returns The return value of `fn`.
383
+ * @since 1.2.0
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * const balance = withRef(ctx, Tokens.RPC, rpc => rpc.getBalance(pubkey));
388
+ * // ref is auto-released — no leak
389
+ * ```
390
+ */
391
+ function withRef(ctx, token, fn) {
392
+ const ref = ctx.acquireRef(token);
393
+ try {
394
+ return fn(ref.current);
395
+ }
396
+ finally {
397
+ ref.release();
398
+ }
399
+ }
400
+ /**
401
+ * Async RAII pattern: acquire a ref, await `fn`, auto-release.
402
+ *
403
+ * @typeParam T - The service type.
404
+ * @typeParam R - The return type of `fn`.
405
+ * @param ctx - The context to acquire from.
406
+ * @param token - The service token.
407
+ * @param fn - Async function that receives the unwrapped service.
408
+ * @returns The return value of `fn`.
409
+ * @since 1.2.0
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * const balance = await withRefAsync(ctx, Tokens.RPC, async rpc => {
414
+ * return rpc.getBalance(pubkey);
415
+ * });
416
+ * // ref is auto-released after await
417
+ * ```
418
+ */
419
+ async function withRefAsync(ctx, token, fn) {
420
+ const ref = ctx.acquireRef(token);
421
+ try {
422
+ return await fn(ref.current);
423
+ }
424
+ finally {
425
+ ref.release();
426
+ }
427
+ }
428
+ /**
429
+ * Create a reusable hook that acquires a tracked ref on each call.
430
+ *
431
+ * Unlike `createServiceHook` (which returns the raw service),
432
+ * this returns a `ServiceRef<T>` that must be released.
433
+ *
434
+ * @param token - The service token.
435
+ * @returns A function `() => ServiceRef<T>`.
436
+ * @since 1.2.0
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * const useRpcRef = createRefHook(Tokens.RPC);
441
+ *
442
+ * // In a component:
443
+ * const rpcRef = useRpcRef();
444
+ * await rpcRef.current.getBalance(pubkey);
445
+ * rpcRef.release();
446
+ * ```
447
+ */
448
+ function createRefHook(token) {
449
+ return () => useSharedRef(token);
450
+ }
451
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/context/hooks.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Synapse Context Provider — IoC service container with DI, scoping, and
3
+ * framework-agnostic hooks.
4
+ *
5
+ * Provides a type-safe dependency injection system for the Synapse SDK,
6
+ * enabling components, modules, and frameworks to access SDK services
7
+ * (RPC, DAS, WebSocket, Programs, AI Tools, etc.) through a unified
8
+ * context without tight coupling.
9
+ *
10
+ * ## Key exports
11
+ *
12
+ * | Export | Description |
13
+ * |--------|-------------|
14
+ * | {@link SynapseContext} | Core IoC container with register/resolve/scope |
15
+ * | {@link createSynapseContext} | Factory that wires all SDK services |
16
+ * | {@link Tokens} | Pre-defined tokens for every SDK module |
17
+ * | {@link useService} | Framework-agnostic service accessor |
18
+ * | {@link createServiceHook} | Composable typed accessor factory |
19
+ * | {@link autoWire} | Proxy-based lazy service bag |
20
+ * | {@link createReactAdapter} | React integration blueprint |
21
+ * | {@link createServerMiddleware} | Express/Fastify request-scoped DI |
22
+ *
23
+ * @module context
24
+ * @since 1.2.0
25
+ *
26
+ * @example Quick start
27
+ * ```ts
28
+ * import {
29
+ * createSynapseContext,
30
+ * Tokens,
31
+ * useService,
32
+ * setGlobalContext,
33
+ * } from '@oobe-protocol-labs/synapse-client-sdk/context';
34
+ *
35
+ * // 1. Create context
36
+ * const ctx = createSynapseContext({
37
+ * endpoint: 'https://rpc.synapse.com',
38
+ * apiKey: 'sk-...',
39
+ * });
40
+ *
41
+ * // 2. Set as global (optional — enables useService())
42
+ * setGlobalContext(ctx);
43
+ *
44
+ * // 3. Resolve services anywhere
45
+ * const rpc = useService(Tokens.RPC);
46
+ * const programs = useService(Tokens.PROGRAMS);
47
+ *
48
+ * // 4. Create scoped contexts
49
+ * const scope = ctx.createScope('user-session');
50
+ * scope.register(USER_TOKEN, { useValue: currentUser });
51
+ *
52
+ * // 5. Cleanup
53
+ * await ctx.dispose();
54
+ * ```
55
+ *
56
+ * @example Custom module
57
+ * ```ts
58
+ * import { createSynapseContext, createToken, type ContextModule } from '...';
59
+ *
60
+ * interface Analytics { track(event: string): void; }
61
+ * const ANALYTICS = createToken<Analytics>('Analytics');
62
+ *
63
+ * const analyticsModule: ContextModule = {
64
+ * name: 'analytics',
65
+ * register(ctx) {
66
+ * ctx.register(ANALYTICS, {
67
+ * useFactory: () => new MixpanelAnalytics(),
68
+ * lifecycle: 'singleton',
69
+ * });
70
+ * },
71
+ * };
72
+ *
73
+ * const ctx = createSynapseContext(config, { modules: [analyticsModule] });
74
+ * ```
75
+ */
76
+ export { createToken, isDisposable, ServiceNotFoundError, CircularDependencyError, AsyncProviderError, type ServiceToken, type ServiceLifecycle, type ServiceProvider, type ValueProvider, type FactoryProvider, type ClassProvider, type AliasProvider, type AsyncFactoryProvider, type ServiceRegistration, type ServiceResolver, type ResolveMiddleware, type Disposable, type ContextEvents, } from './types';
77
+ export { SynapseContext } from './container';
78
+ export { ServiceRef, WeakServiceRef, RefRegistry, MemoryGuard, RefReleasedError, createBinding, type LeakReport, type RefStats, type RefRegistryConfig, type MemoryGuardConfig, type ServiceBinding, } from './refs';
79
+ export { Tokens, createSynapseContext, createBareContext, type ProgramsBundle, type ContextModule, type CreateSynapseContextOpts, } from './providers';
80
+ export { setGlobalContext, getContext, tryGetContext, useService, tryUseService, createServiceHook, createBoundHook, useSharedRef, useBoundServices, withRef, withRefAsync, createRefHook, createReactAdapter, createServerMiddleware, autoWire, type ContextAdapter, type ReactAdapterConfig, type ServerAdapterConfig, } from './hooks';
81
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAGH,OAAO,EAEL,WAAW,EACX,YAAY,EAEZ,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAElB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,wBAAwB,GAC9B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAEL,gBAAgB,EAChB,UAAU,EACV,aAAa,EAEb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EAEf,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,aAAa,EAEb,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EAER,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /**
3
+ * Synapse Context Provider — IoC service container with DI, scoping, and
4
+ * framework-agnostic hooks.
5
+ *
6
+ * Provides a type-safe dependency injection system for the Synapse SDK,
7
+ * enabling components, modules, and frameworks to access SDK services
8
+ * (RPC, DAS, WebSocket, Programs, AI Tools, etc.) through a unified
9
+ * context without tight coupling.
10
+ *
11
+ * ## Key exports
12
+ *
13
+ * | Export | Description |
14
+ * |--------|-------------|
15
+ * | {@link SynapseContext} | Core IoC container with register/resolve/scope |
16
+ * | {@link createSynapseContext} | Factory that wires all SDK services |
17
+ * | {@link Tokens} | Pre-defined tokens for every SDK module |
18
+ * | {@link useService} | Framework-agnostic service accessor |
19
+ * | {@link createServiceHook} | Composable typed accessor factory |
20
+ * | {@link autoWire} | Proxy-based lazy service bag |
21
+ * | {@link createReactAdapter} | React integration blueprint |
22
+ * | {@link createServerMiddleware} | Express/Fastify request-scoped DI |
23
+ *
24
+ * @module context
25
+ * @since 1.2.0
26
+ *
27
+ * @example Quick start
28
+ * ```ts
29
+ * import {
30
+ * createSynapseContext,
31
+ * Tokens,
32
+ * useService,
33
+ * setGlobalContext,
34
+ * } from '@oobe-protocol-labs/synapse-client-sdk/context';
35
+ *
36
+ * // 1. Create context
37
+ * const ctx = createSynapseContext({
38
+ * endpoint: 'https://rpc.synapse.com',
39
+ * apiKey: 'sk-...',
40
+ * });
41
+ *
42
+ * // 2. Set as global (optional — enables useService())
43
+ * setGlobalContext(ctx);
44
+ *
45
+ * // 3. Resolve services anywhere
46
+ * const rpc = useService(Tokens.RPC);
47
+ * const programs = useService(Tokens.PROGRAMS);
48
+ *
49
+ * // 4. Create scoped contexts
50
+ * const scope = ctx.createScope('user-session');
51
+ * scope.register(USER_TOKEN, { useValue: currentUser });
52
+ *
53
+ * // 5. Cleanup
54
+ * await ctx.dispose();
55
+ * ```
56
+ *
57
+ * @example Custom module
58
+ * ```ts
59
+ * import { createSynapseContext, createToken, type ContextModule } from '...';
60
+ *
61
+ * interface Analytics { track(event: string): void; }
62
+ * const ANALYTICS = createToken<Analytics>('Analytics');
63
+ *
64
+ * const analyticsModule: ContextModule = {
65
+ * name: 'analytics',
66
+ * register(ctx) {
67
+ * ctx.register(ANALYTICS, {
68
+ * useFactory: () => new MixpanelAnalytics(),
69
+ * lifecycle: 'singleton',
70
+ * });
71
+ * },
72
+ * };
73
+ *
74
+ * const ctx = createSynapseContext(config, { modules: [analyticsModule] });
75
+ * ```
76
+ */
77
+ Object.defineProperty(exports, "__esModule", { value: true });
78
+ exports.autoWire = exports.createServerMiddleware = exports.createReactAdapter = exports.createRefHook = exports.withRefAsync = exports.withRef = exports.useBoundServices = exports.useSharedRef = exports.createBoundHook = exports.createServiceHook = exports.tryUseService = exports.useService = exports.tryGetContext = exports.getContext = exports.setGlobalContext = exports.createBareContext = exports.createSynapseContext = exports.Tokens = exports.createBinding = exports.RefReleasedError = exports.MemoryGuard = exports.RefRegistry = exports.WeakServiceRef = exports.ServiceRef = exports.SynapseContext = exports.AsyncProviderError = exports.CircularDependencyError = exports.ServiceNotFoundError = exports.isDisposable = exports.createToken = void 0;
79
+ // ── Types & tokens ─────────────────────────────────────────────
80
+ var types_1 = require("./types");
81
+ // Token creation
82
+ Object.defineProperty(exports, "createToken", { enumerable: true, get: function () { return types_1.createToken; } });
83
+ Object.defineProperty(exports, "isDisposable", { enumerable: true, get: function () { return types_1.isDisposable; } });
84
+ // Error classes
85
+ Object.defineProperty(exports, "ServiceNotFoundError", { enumerable: true, get: function () { return types_1.ServiceNotFoundError; } });
86
+ Object.defineProperty(exports, "CircularDependencyError", { enumerable: true, get: function () { return types_1.CircularDependencyError; } });
87
+ Object.defineProperty(exports, "AsyncProviderError", { enumerable: true, get: function () { return types_1.AsyncProviderError; } });
88
+ // ── Container ──────────────────────────────────────────────────
89
+ var container_1 = require("./container");
90
+ Object.defineProperty(exports, "SynapseContext", { enumerable: true, get: function () { return container_1.SynapseContext; } });
91
+ // ── Memory-safe references ─────────────────────────────────────
92
+ var refs_1 = require("./refs");
93
+ Object.defineProperty(exports, "ServiceRef", { enumerable: true, get: function () { return refs_1.ServiceRef; } });
94
+ Object.defineProperty(exports, "WeakServiceRef", { enumerable: true, get: function () { return refs_1.WeakServiceRef; } });
95
+ Object.defineProperty(exports, "RefRegistry", { enumerable: true, get: function () { return refs_1.RefRegistry; } });
96
+ Object.defineProperty(exports, "MemoryGuard", { enumerable: true, get: function () { return refs_1.MemoryGuard; } });
97
+ Object.defineProperty(exports, "RefReleasedError", { enumerable: true, get: function () { return refs_1.RefReleasedError; } });
98
+ Object.defineProperty(exports, "createBinding", { enumerable: true, get: function () { return refs_1.createBinding; } });
99
+ // ── Built-in providers & tokens ────────────────────────────────
100
+ var providers_1 = require("./providers");
101
+ Object.defineProperty(exports, "Tokens", { enumerable: true, get: function () { return providers_1.Tokens; } });
102
+ Object.defineProperty(exports, "createSynapseContext", { enumerable: true, get: function () { return providers_1.createSynapseContext; } });
103
+ Object.defineProperty(exports, "createBareContext", { enumerable: true, get: function () { return providers_1.createBareContext; } });
104
+ // ── Hooks & adapters ───────────────────────────────────────────
105
+ var hooks_1 = require("./hooks");
106
+ // Global context
107
+ Object.defineProperty(exports, "setGlobalContext", { enumerable: true, get: function () { return hooks_1.setGlobalContext; } });
108
+ Object.defineProperty(exports, "getContext", { enumerable: true, get: function () { return hooks_1.getContext; } });
109
+ Object.defineProperty(exports, "tryGetContext", { enumerable: true, get: function () { return hooks_1.tryGetContext; } });
110
+ // Service accessors
111
+ Object.defineProperty(exports, "useService", { enumerable: true, get: function () { return hooks_1.useService; } });
112
+ Object.defineProperty(exports, "tryUseService", { enumerable: true, get: function () { return hooks_1.tryUseService; } });
113
+ Object.defineProperty(exports, "createServiceHook", { enumerable: true, get: function () { return hooks_1.createServiceHook; } });
114
+ Object.defineProperty(exports, "createBoundHook", { enumerable: true, get: function () { return hooks_1.createBoundHook; } });
115
+ // Memory-safe ref hooks
116
+ Object.defineProperty(exports, "useSharedRef", { enumerable: true, get: function () { return hooks_1.useSharedRef; } });
117
+ Object.defineProperty(exports, "useBoundServices", { enumerable: true, get: function () { return hooks_1.useBoundServices; } });
118
+ Object.defineProperty(exports, "withRef", { enumerable: true, get: function () { return hooks_1.withRef; } });
119
+ Object.defineProperty(exports, "withRefAsync", { enumerable: true, get: function () { return hooks_1.withRefAsync; } });
120
+ Object.defineProperty(exports, "createRefHook", { enumerable: true, get: function () { return hooks_1.createRefHook; } });
121
+ // Framework adapters
122
+ Object.defineProperty(exports, "createReactAdapter", { enumerable: true, get: function () { return hooks_1.createReactAdapter; } });
123
+ Object.defineProperty(exports, "createServerMiddleware", { enumerable: true, get: function () { return hooks_1.createServerMiddleware; } });
124
+ Object.defineProperty(exports, "autoWire", { enumerable: true, get: function () { return hooks_1.autoWire; } });
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;;;AAEH,kEAAkE;AAClE,iCAsBiB;AArBf,iBAAiB;AACjB,oGAAA,WAAW,OAAA;AACX,qGAAA,YAAY,OAAA;AACZ,gBAAgB;AAChB,6GAAA,oBAAoB,OAAA;AACpB,gHAAA,uBAAuB,OAAA;AACvB,2GAAA,kBAAkB,OAAA;AAiBpB,kEAAkE;AAClE,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AAEvB,kEAAkE;AAClE,+BAYgB;AAXd,kGAAA,UAAU,OAAA;AACV,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,mGAAA,WAAW,OAAA;AACX,wGAAA,gBAAgB,OAAA;AAChB,qGAAA,aAAa,OAAA;AAQf,kEAAkE;AAClE,yCAOqB;AANnB,mGAAA,MAAM,OAAA;AACN,iHAAA,oBAAoB,OAAA;AACpB,8GAAA,iBAAiB,OAAA;AAMnB,kEAAkE;AAClE,iCAwBiB;AAvBf,iBAAiB;AACjB,yGAAA,gBAAgB,OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,sGAAA,aAAa,OAAA;AACb,oBAAoB;AACpB,mGAAA,UAAU,OAAA;AACV,sGAAA,aAAa,OAAA;AACb,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AACf,wBAAwB;AACxB,qGAAA,YAAY,OAAA;AACZ,yGAAA,gBAAgB,OAAA;AAChB,gGAAA,OAAO,OAAA;AACP,qGAAA,YAAY,OAAA;AACZ,sGAAA,aAAa,OAAA;AACb,qBAAqB;AACrB,2GAAA,kBAAkB,OAAA;AAClB,+GAAA,sBAAsB,OAAA;AACtB,iGAAA,QAAQ,OAAA"}