@pooflabs/web 0.0.89-ux.2 → 0.0.90

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 (60) hide show
  1. package/dist/{index-BLbguAbm.js → index-BZ_W-sR0.js} +2 -2
  2. package/dist/index-BZ_W-sR0.js.map +1 -0
  3. package/dist/{index-CEr58d1y.esm.js → index-C65AsRIA.esm.js} +364 -14
  4. package/dist/index-C65AsRIA.esm.js.map +1 -0
  5. package/dist/{index-DsyaaxjP.js → index-CqpErQap.js} +363 -13
  6. package/dist/index-CqpErQap.js.map +1 -0
  7. package/dist/{index-D_H81ZZs.esm.js → index-CzVM_hix.esm.js} +142 -7
  8. package/dist/index-CzVM_hix.esm.js.map +1 -0
  9. package/dist/index-D72o3sHT.esm.js +6 -0
  10. package/dist/index-D72o3sHT.esm.js.map +1 -0
  11. package/dist/{index-BhMsVVRC.esm.js → index-DOYZMq5N.esm.js} +363 -13
  12. package/dist/index-DOYZMq5N.esm.js.map +1 -0
  13. package/dist/{index-BsAk0dF_.js → index-Eb2uyla3.js} +147 -6
  14. package/dist/index-Eb2uyla3.js.map +1 -0
  15. package/dist/{index-DV-v3Udi.js → index-lt7AQ69U.js} +364 -14
  16. package/dist/index-lt7AQ69U.js.map +1 -0
  17. package/dist/{index.browser-AsD3ML3C.js → index.browser-BltIkY00.js} +2 -2
  18. package/dist/{index.browser-AsD3ML3C.js.map → index.browser-BltIkY00.js.map} +1 -1
  19. package/dist/{index.browser-CmvrvtVk.js → index.browser-C81ODkjH.js} +2 -2
  20. package/dist/{index.browser-CmvrvtVk.js.map → index.browser-C81ODkjH.js.map} +1 -1
  21. package/dist/{index.browser-Cdrgfw30.esm.js → index.browser-D1uNEi4e.esm.js} +2 -2
  22. package/dist/{index.browser-Cdrgfw30.esm.js.map → index.browser-D1uNEi4e.esm.js.map} +1 -1
  23. package/dist/{index.browser-Ctdjdn7K.esm.js → index.browser-zlnKOqcR.esm.js} +2 -2
  24. package/dist/{index.browser-Ctdjdn7K.esm.js.map → index.browser-zlnKOqcR.esm.js.map} +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/index.js +7 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/{index.native-CujLdGqC.esm.js → index.native-Czk4F68O.esm.js} +142 -7
  29. package/dist/index.native-Czk4F68O.esm.js.map +1 -0
  30. package/dist/{index.native-TmE1_ksX.js → index.native-DYddSSgT.js} +147 -6
  31. package/dist/index.native-DYddSSgT.js.map +1 -0
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +7 -1
  34. package/dist/index.native.js.map +1 -1
  35. package/dist/{phantom-wallet-provider-DsB9i0xD.esm.js → phantom-wallet-provider-0tX0Zs72.esm.js} +4 -4
  36. package/dist/{phantom-wallet-provider-DsB9i0xD.esm.js.map → phantom-wallet-provider-0tX0Zs72.esm.js.map} +1 -1
  37. package/dist/{phantom-wallet-provider-Drxxai7b.js → phantom-wallet-provider-DR5qAGcS.js} +4 -4
  38. package/dist/{phantom-wallet-provider-Drxxai7b.js.map → phantom-wallet-provider-DR5qAGcS.js.map} +1 -1
  39. package/dist/{privy-wallet-provider-_PkLjOQV.js → privy-wallet-provider-BqTsdJPZ.js} +3 -3
  40. package/dist/privy-wallet-provider-BqTsdJPZ.js.map +1 -0
  41. package/dist/{privy-wallet-provider-Bh5qilM2.esm.js → privy-wallet-provider-ChMUFAEp.esm.js} +3 -3
  42. package/dist/privy-wallet-provider-ChMUFAEp.esm.js.map +1 -0
  43. package/dist/{solana-mobile-wallet-provider-xzJFY_GQ.esm.js → solana-mobile-wallet-provider-Cq2H4eoW.esm.js} +4 -4
  44. package/dist/{solana-mobile-wallet-provider-xzJFY_GQ.esm.js.map → solana-mobile-wallet-provider-Cq2H4eoW.esm.js.map} +1 -1
  45. package/dist/{solana-mobile-wallet-provider-wzJ_5N_z.js → solana-mobile-wallet-provider-DiXPSf8n.js} +4 -4
  46. package/dist/{solana-mobile-wallet-provider-wzJ_5N_z.js.map → solana-mobile-wallet-provider-DiXPSf8n.js.map} +1 -1
  47. package/package.json +2 -2
  48. package/dist/index-BLbguAbm.js.map +0 -1
  49. package/dist/index-BhMsVVRC.esm.js.map +0 -1
  50. package/dist/index-BsAk0dF_.js.map +0 -1
  51. package/dist/index-CEr58d1y.esm.js.map +0 -1
  52. package/dist/index-DV-v3Udi.js.map +0 -1
  53. package/dist/index-D_H81ZZs.esm.js.map +0 -1
  54. package/dist/index-DsyaaxjP.js.map +0 -1
  55. package/dist/index-udwtZBLu.esm.js +0 -6
  56. package/dist/index-udwtZBLu.esm.js.map +0 -1
  57. package/dist/index.native-CujLdGqC.esm.js.map +0 -1
  58. package/dist/index.native-TmE1_ksX.js.map +0 -1
  59. package/dist/privy-wallet-provider-Bh5qilM2.esm.js.map +0 -1
  60. package/dist/privy-wallet-provider-_PkLjOQV.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { H as DEFAULT_TEST_ADDRESS, L as InsufficientBalanceError, M as MockAuthProvider, O as OffchainAuthProvider, P as PhantomWalletProvider, K as PrivyExpoProvider, G as PrivyWalletProvider, R as ReactNativeSessionManager, N as ServerSessionManager, S as SolanaMobileWalletProvider, W as WebSessionManager, z as aggregate, Q as buildSetDocumentsTransaction, T as clearCache, U as closeAllSubscriptions, V as convertRemainingAccounts, y as count, X as createSessionWithPrivy, Y as createSessionWithSignature, C as deserializeTransaction, Z as genAuthNonce, _ as genSolanaMessage, k as get, e as getAuthLoading, j as getAuthProvider, $ as getCachedData, h as getConfig, c as getCurrentUser, p as getFiles, D as getIdToken, a0 as getMany, F as getPlatform, i as init, I as isMobileWalletAvailable, l as login, f as logout, d as onAuthLoadingChanged, o as onAuthStateChanged, a1 as reconnectWithNewAuth, a2 as refreshSession, J as registerMobileWalletAdapter, t as runExpression, u as runExpressionMany, r as runQuery, q as runQueryMany, s as set, n as setFile, m as setMany, E as setPlatform, x as signAndSubmitTransaction, v as signMessage, a3 as signSessionCreateMessage, w as signTransaction, A as subscribe, B as useAuth } from './index-D_H81ZZs.esm.js';
1
+ export { H as DEFAULT_TEST_ADDRESS, L as InsufficientBalanceError, M as MockAuthProvider, O as OffchainAuthProvider, P as PhantomWalletProvider, K as PrivyExpoProvider, G as PrivyWalletProvider, R as ReactNativeSessionManager, N as ServerSessionManager, S as SolanaMobileWalletProvider, W as WebSessionManager, z as aggregate, Q as buildSetDocumentsTransaction, T as clearCache, U as closeAllSubscriptions, V as convertRemainingAccounts, y as count, X as createSessionWithPrivy, Y as createSessionWithSignature, C as deserializeTransaction, Z as genAuthNonce, _ as genSolanaMessage, k as get, e as getAuthLoading, j as getAuthProvider, $ as getCachedData, h as getConfig, c as getCurrentUser, p as getFiles, D as getIdToken, a0 as getMany, F as getPlatform, a1 as hasActiveConnection, i as init, I as isMobileWalletAvailable, l as login, f as logout, d as onAuthLoadingChanged, o as onAuthStateChanged, a2 as reconnectWithNewAuth, a3 as refreshSession, J as registerMobileWalletAdapter, t as runExpression, u as runExpressionMany, r as runQuery, q as runQueryMany, s as set, n as setFile, m as setMany, E as setPlatform, x as signAndSubmitTransaction, v as signMessage, a4 as signSessionCreateMessage, w as signTransaction, A as subscribe, B as useAuth, a5 as wsDelete, a6 as wsGet, a7 as wsGetMany, a8 as wsQuery, a9 as wsSet } from './index-CzVM_hix.esm.js';
2
2
  import 'axios';
3
3
  import '@solana/web3.js';
4
4
  import '@coral-xyz/anchor';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BsAk0dF_.js');
3
+ var index = require('./index-Eb2uyla3.js');
4
4
  require('axios');
5
5
  require('@solana/web3.js');
6
6
  require('@coral-xyz/anchor');
@@ -40,6 +40,7 @@ exports.getFiles = index.getFiles;
40
40
  exports.getIdToken = index.getIdToken;
41
41
  exports.getMany = index.getMany;
42
42
  exports.getPlatform = index.getPlatform;
43
+ exports.hasActiveConnection = index.hasActiveConnection;
43
44
  exports.init = index.init;
44
45
  exports.isMobileWalletAvailable = index.isMobileWalletAvailable;
45
46
  exports.login = index.login;
@@ -63,4 +64,9 @@ exports.signSessionCreateMessage = index.signSessionCreateMessage;
63
64
  exports.signTransaction = index.signTransaction;
64
65
  exports.subscribe = index.subscribe;
65
66
  exports.useAuth = index.useAuth;
67
+ exports.wsDelete = index.wsDelete;
68
+ exports.wsGet = index.wsGet;
69
+ exports.wsGetMany = index.wsGetMany;
70
+ exports.wsQuery = index.wsQuery;
71
+ exports.wsSet = index.wsSet;
66
72
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -11117,6 +11117,7 @@ async function getOrCreateConnection(appId, isServer) {
11117
11117
  subscriptions: new Map(),
11118
11118
  pendingSubscriptions: new Map(),
11119
11119
  pendingUnsubscriptions: new Map(),
11120
+ pendingRequests: new Map(),
11120
11121
  isConnecting: false,
11121
11122
  isConnected: false,
11122
11123
  appId,
@@ -11215,11 +11216,17 @@ async function getOrCreateConnection(appId, isServer) {
11215
11216
  clearInterval(connection.tokenRefreshTimer);
11216
11217
  connection.tokenRefreshTimer = null;
11217
11218
  }
11219
+ // Reject all pending WS CRUD requests on disconnect (fail fast)
11220
+ for (const [id, pending] of connection.pendingRequests) {
11221
+ clearTimeout(pending.timer);
11222
+ pending.reject(new Error('WebSocket disconnected'));
11223
+ }
11224
+ connection.pendingRequests.clear();
11218
11225
  });
11219
11226
  return connection;
11220
11227
  }
11221
11228
  function handleServerMessage(connection, message) {
11222
- var _a;
11229
+ var _a, _b;
11223
11230
  switch (message.type) {
11224
11231
  case 'subscribed': {
11225
11232
  const subscription = connection.subscriptions.get(message.subscriptionId);
@@ -11264,8 +11271,45 @@ function handleServerMessage(connection, message) {
11264
11271
  }
11265
11272
  break;
11266
11273
  }
11274
+ case 'response': {
11275
+ const pendingReq = connection.pendingRequests.get(message.requestId);
11276
+ if (pendingReq) {
11277
+ connection.pendingRequests.delete(message.requestId);
11278
+ clearTimeout(pendingReq.timer);
11279
+ if (message.status >= 400) {
11280
+ pendingReq.reject(new Error(`Request failed with status ${message.status}`));
11281
+ }
11282
+ else {
11283
+ pendingReq.resolve(message.data);
11284
+ }
11285
+ }
11286
+ break;
11287
+ }
11288
+ case 'setResponse': {
11289
+ const pendingSet = connection.pendingRequests.get(message.requestId);
11290
+ if (pendingSet) {
11291
+ connection.pendingRequests.delete(message.requestId);
11292
+ clearTimeout(pendingSet.timer);
11293
+ if (message.statusCode >= 400) {
11294
+ pendingSet.reject(new Error(((_a = message.body) === null || _a === void 0 ? void 0 : _a.message) || `Set failed with status ${message.statusCode}`));
11295
+ }
11296
+ else {
11297
+ pendingSet.resolve(message.body);
11298
+ }
11299
+ }
11300
+ break;
11301
+ }
11267
11302
  case 'error': {
11268
11303
  console.error('[WS v2] Server error:', message.code, message.message);
11304
+ // Handle CRUD request errors (requestId present)
11305
+ if (message.requestId) {
11306
+ const pendingReq = connection.pendingRequests.get(message.requestId);
11307
+ if (pendingReq) {
11308
+ connection.pendingRequests.delete(message.requestId);
11309
+ clearTimeout(pendingReq.timer);
11310
+ pendingReq.reject(new Error(`${message.code}: ${message.message}`));
11311
+ }
11312
+ }
11269
11313
  if (message.subscriptionId) {
11270
11314
  // Reject pending subscription if this is a subscription error
11271
11315
  const pending = connection.pendingSubscriptions.get(message.subscriptionId);
@@ -11277,7 +11321,7 @@ function handleServerMessage(connection, message) {
11277
11321
  const subscription = connection.subscriptions.get(message.subscriptionId);
11278
11322
  if (subscription) {
11279
11323
  for (const callback of subscription.callbacks) {
11280
- (_a = callback.onError) === null || _a === void 0 ? void 0 : _a.call(callback, new Error(`${message.code}: ${message.message}`));
11324
+ (_b = callback.onError) === null || _b === void 0 ? void 0 : _b.call(callback, new Error(`${message.code}: ${message.message}`));
11281
11325
  }
11282
11326
  }
11283
11327
  }
@@ -11566,6 +11610,97 @@ async function doReconnectWithNewAuth() {
11566
11610
  }
11567
11611
  }
11568
11612
  }
11613
+ // ============ CRUD over WebSocket ============
11614
+ const WS_REQUEST_TIMEOUT_MS = 30000;
11615
+ function generateRequestId() {
11616
+ return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
11617
+ }
11618
+ /**
11619
+ * Returns true if there is an active v2 WebSocket connection open.
11620
+ */
11621
+ function hasActiveConnection() {
11622
+ for (const connection of connections.values()) {
11623
+ if (connection.ws && connection.isConnected) {
11624
+ return true;
11625
+ }
11626
+ }
11627
+ return false;
11628
+ }
11629
+ async function sendRequest(msgBuilder) {
11630
+ const config = await getConfig();
11631
+ const appId = config.appId;
11632
+ const connection = await getOrCreateConnection(appId, config.isServer);
11633
+ // Wait for the connection to be open (getOrCreateConnection may return
11634
+ // while still connecting).
11635
+ if (!connection.isConnected && connection.ws) {
11636
+ await new Promise((resolve, reject) => {
11637
+ const timeout = setTimeout(() => {
11638
+ var _a;
11639
+ (_a = connection.ws) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', onOpen);
11640
+ reject(new Error('WebSocket connection timeout'));
11641
+ }, 10000);
11642
+ const onOpen = () => { clearTimeout(timeout); resolve(); };
11643
+ if (connection.isConnected) {
11644
+ clearTimeout(timeout);
11645
+ resolve();
11646
+ return;
11647
+ }
11648
+ connection.ws.addEventListener('open', onOpen);
11649
+ });
11650
+ }
11651
+ if (!connection.ws || !connection.isConnected) {
11652
+ throw new Error('WebSocket connection not available');
11653
+ }
11654
+ const requestId = generateRequestId();
11655
+ const message = msgBuilder(requestId);
11656
+ return new Promise((resolve, reject) => {
11657
+ const timer = setTimeout(() => {
11658
+ connection.pendingRequests.delete(requestId);
11659
+ reject(new Error(`WebSocket request timed out after ${WS_REQUEST_TIMEOUT_MS}ms`));
11660
+ }, WS_REQUEST_TIMEOUT_MS);
11661
+ connection.pendingRequests.set(requestId, { resolve, reject, timer });
11662
+ try {
11663
+ connection.ws.send(JSON.stringify(message));
11664
+ }
11665
+ catch (error) {
11666
+ connection.pendingRequests.delete(requestId);
11667
+ clearTimeout(timer);
11668
+ reject(error);
11669
+ }
11670
+ });
11671
+ }
11672
+ async function wsGet(path) {
11673
+ return sendRequest((requestId) => ({
11674
+ type: 'get',
11675
+ requestId,
11676
+ path,
11677
+ }));
11678
+ }
11679
+ async function wsSet(documents) {
11680
+ return sendRequest((requestId) => ({
11681
+ type: 'set',
11682
+ requestId,
11683
+ documents,
11684
+ }));
11685
+ }
11686
+ async function wsQuery(path, opts) {
11687
+ return sendRequest((requestId) => (Object.assign(Object.assign(Object.assign(Object.assign({ type: 'query', requestId,
11688
+ path }, ((opts === null || opts === void 0 ? void 0 : opts.filter) ? { filter: opts.filter } : {})), ((opts === null || opts === void 0 ? void 0 : opts.sort) ? { sort: opts.sort } : {})), ((opts === null || opts === void 0 ? void 0 : opts.limit) !== undefined ? { limit: opts.limit } : {})), ((opts === null || opts === void 0 ? void 0 : opts.includeSubPaths) ? { includeSubPaths: opts.includeSubPaths } : {}))));
11689
+ }
11690
+ async function wsDelete(path) {
11691
+ return sendRequest((requestId) => ({
11692
+ type: 'delete',
11693
+ requestId,
11694
+ path,
11695
+ }));
11696
+ }
11697
+ async function wsGetMany(paths) {
11698
+ return sendRequest((requestId) => ({
11699
+ type: 'getMany',
11700
+ requestId,
11701
+ paths,
11702
+ }));
11703
+ }
11569
11704
 
11570
11705
  /**
11571
11706
  * WebSocket Subscription Module
@@ -12865,15 +13000,15 @@ function clearIncompatibleSession() {
12865
13000
  // Lazy loaders for web-only providers.
12866
13001
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
12867
13002
  async function loadPrivyWalletProvider() {
12868
- const mod = await import('./privy-wallet-provider-Bh5qilM2.esm.js');
13003
+ const mod = await import('./privy-wallet-provider-ChMUFAEp.esm.js');
12869
13004
  return mod.PrivyWalletProvider;
12870
13005
  }
12871
13006
  async function loadPhantomWalletProvider() {
12872
- const mod = await import('./phantom-wallet-provider-DsB9i0xD.esm.js');
13007
+ const mod = await import('./phantom-wallet-provider-0tX0Zs72.esm.js');
12873
13008
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
12874
13009
  }
12875
13010
  async function loadSolanaMobileWalletProvider() {
12876
- const mod = await import('./solana-mobile-wallet-provider-xzJFY_GQ.esm.js');
13011
+ const mod = await import('./solana-mobile-wallet-provider-Cq2H4eoW.esm.js');
12877
13012
  return mod.SolanaMobileWalletProvider;
12878
13013
  }
12879
13014
  async function hotSwapToPrivyProvider(config) {
@@ -16234,5 +16369,5 @@ class PrivyExpoProvider {
16234
16369
  }
16235
16370
  }
16236
16371
 
16237
- export { ServerSessionManager as $, get as A, set as B, setMany as C, setFile as D, getFiles as E, runQuery as F, runQueryMany as G, runExpression as H, runExpressionMany as I, signMessage as J, signTransaction as K, signAndSubmitTransaction as L, count as M, aggregate as N, subscribe as O, useAuth as P, deserializeTransaction as Q, getIdToken as R, SOLANA_MAINNET_RPC_URL as S, setPlatform as T, MockAuthProvider as U, DEFAULT_TEST_ADDRESS as V, WebSessionManager as W, OffchainAuthProvider as X, PrivyExpoProvider as Y, InsufficientBalanceError as Z, ReactNativeSessionManager as _, SOLANA_DEVNET_RPC_URL as a, clearCache as a0, closeAllSubscriptions as a1, getCachedData as a2, getMany as a3, reconnectWithNewAuth as a4, refreshSession as a5, signSessionCreateMessage as a6, index as a7, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, base58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, SURFNET_RPC_URL$1 as h, detectMobile as i, detectAndroid as j, setAuthLoading as k, genAuthNonce as l, genSolanaMessage as m, createSessionWithSignature as n, getDefaultExportFromCjs$1 as o, init as p, getCurrentUser as q, requireBuffer as r, setCurrentUser as s, onAuthStateChanged as t, onAuthLoadingChanged as u, getAuthLoading as v, login as w, logout as x, getConfig as y, getAuthProvider as z };
16238
- //# sourceMappingURL=index.native-CujLdGqC.esm.js.map
16372
+ export { ServerSessionManager as $, get as A, set as B, setMany as C, setFile as D, getFiles as E, runQuery as F, runQueryMany as G, runExpression as H, runExpressionMany as I, signMessage as J, signTransaction as K, signAndSubmitTransaction as L, count as M, aggregate as N, subscribe as O, useAuth as P, deserializeTransaction as Q, getIdToken as R, SOLANA_MAINNET_RPC_URL as S, setPlatform as T, MockAuthProvider as U, DEFAULT_TEST_ADDRESS as V, WebSessionManager as W, OffchainAuthProvider as X, PrivyExpoProvider as Y, InsufficientBalanceError as Z, ReactNativeSessionManager as _, SOLANA_DEVNET_RPC_URL as a, clearCache as a0, closeAllSubscriptions as a1, getCachedData as a2, getMany as a3, hasActiveConnection as a4, reconnectWithNewAuth as a5, refreshSession as a6, signSessionCreateMessage as a7, wsDelete as a8, wsGet as a9, wsGetMany as aa, wsQuery as ab, wsSet as ac, index as ad, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, base58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, SURFNET_RPC_URL$1 as h, detectMobile as i, detectAndroid as j, setAuthLoading as k, genAuthNonce as l, genSolanaMessage as m, createSessionWithSignature as n, getDefaultExportFromCjs$1 as o, init as p, getCurrentUser as q, requireBuffer as r, setCurrentUser as s, onAuthStateChanged as t, onAuthLoadingChanged as u, getAuthLoading as v, login as w, logout as x, getConfig as y, getAuthProvider as z };
16373
+ //# sourceMappingURL=index.native-Czk4F68O.esm.js.map