@bounded-sh/client 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useQuery.d.ts +58 -0
- package/dist/{index-DyfiK3_X.esm.js → index-30RA_Bdf.esm.js} +268 -18
- package/dist/index-30RA_Bdf.esm.js.map +1 -0
- package/dist/{index-DJg-Dduo.esm.js → index-B9DtkVXb.esm.js} +2 -2
- package/dist/{index-DJg-Dduo.esm.js.map → index-B9DtkVXb.esm.js.map} +1 -1
- package/dist/{index-CYVVTWs4.js → index-CdqFc68L.js} +2 -2
- package/dist/{index-CYVVTWs4.js.map → index-CdqFc68L.js.map} +1 -1
- package/dist/{index-C2JpxGAC.js → index-CplhW55m.js} +2 -2
- package/dist/{index-C2JpxGAC.js.map → index-CplhW55m.js.map} +1 -1
- package/dist/{index-C2yvle9S.esm.js → index-DXdFMfDw.esm.js} +2 -2
- package/dist/{index-C2yvle9S.esm.js.map → index-DXdFMfDw.esm.js.map} +1 -1
- package/dist/{index-2UpSvA7V.js → index-ZYhdEVCA.js} +272 -17
- package/dist/index-ZYhdEVCA.js.map +1 -0
- package/dist/{index.browser-pymH6o1X.esm.js → index.browser-Cictefil.esm.js} +2 -2
- package/dist/{index.browser-pymH6o1X.esm.js.map → index.browser-Cictefil.esm.js.map} +1 -1
- package/dist/{index.browser-BTJZmhY1.js → index.browser-sADlt75X.js} +2 -2
- package/dist/{index.browser-BTJZmhY1.js.map → index.browser-sADlt75X.js.map} +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.native-BTjBgNiE.esm.js → index.native-C8GJTcIy.esm.js} +204 -14
- package/dist/index.native-C8GJTcIy.esm.js.map +1 -0
- package/dist/{index.native-BvsmNFXn.js → index.native-DpYQ8GUh.js} +207 -13
- package/dist/index.native-DpYQ8GUh.js.map +1 -0
- package/dist/index.native.d.ts +1 -1
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +5 -1
- package/dist/index.native.js.map +1 -1
- package/dist/{phantom-wallet-provider-BXMvoOrI.js → phantom-wallet-provider-B8gezRxB.js} +3 -3
- package/dist/{phantom-wallet-provider-BXMvoOrI.js.map → phantom-wallet-provider-B8gezRxB.js.map} +1 -1
- package/dist/{phantom-wallet-provider-CTossIFB.esm.js → phantom-wallet-provider-FOSnYV4t.esm.js} +3 -3
- package/dist/{phantom-wallet-provider-CTossIFB.esm.js.map → phantom-wallet-provider-FOSnYV4t.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-1qE_f-DF.esm.js → privy-wallet-provider-BPOjNW9O.esm.js} +3 -3
- package/dist/{privy-wallet-provider-1qE_f-DF.esm.js.map → privy-wallet-provider-BPOjNW9O.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-D64DJ3u4.js → privy-wallet-provider-DfR-7xpE.js} +3 -3
- package/dist/{privy-wallet-provider-D64DJ3u4.js.map → privy-wallet-provider-DfR-7xpE.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-C1wQ1DRK.js → solana-mobile-wallet-provider-CBAeRxGQ.js} +2 -2
- package/dist/{solana-mobile-wallet-provider-C1wQ1DRK.js.map → solana-mobile-wallet-provider-CBAeRxGQ.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-9M8U6AA7.esm.js → solana-mobile-wallet-provider-CoS-38SL.esm.js} +2 -2
- package/dist/{solana-mobile-wallet-provider-9M8U6AA7.esm.js.map → solana-mobile-wallet-provider-CoS-38SL.esm.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-2UpSvA7V.js.map +0 -1
- package/dist/index-DyfiK3_X.esm.js.map +0 -1
- package/dist/index.native-BTjBgNiE.esm.js.map +0 -1
- package/dist/index.native-BvsmNFXn.js.map +0 -1
|
@@ -10654,6 +10654,87 @@ const pendingRequests = {};
|
|
|
10654
10654
|
const GET_CACHE_TTL = 500; // Adjust this value as needed (in milliseconds)
|
|
10655
10655
|
// Last time we cleaned up the cache
|
|
10656
10656
|
let lastCacheCleanup = Date.now();
|
|
10657
|
+
/**
|
|
10658
|
+
* Return the leaf document key (last path segment) for a document path.
|
|
10659
|
+
*
|
|
10660
|
+
* Bounded rows carry `_id` (and `pathId`) set to the FULL document path
|
|
10661
|
+
* (e.g. `"rooms/r1/prompts/8rd49se3sg"`). Apps that build a child path from a
|
|
10662
|
+
* row naturally want the bare doc key, not the whole path — using the full path
|
|
10663
|
+
* doubles it (`rooms/r1/prompts/rooms/r1/prompts/8rd.../votes/...`) → 403/404.
|
|
10664
|
+
* `docId` extracts that leaf key. Tolerates leading slashes and a trailing `*`.
|
|
10665
|
+
*
|
|
10666
|
+
* @example docId("rooms/r1/prompts/8rd49se3sg") // "8rd49se3sg"
|
|
10667
|
+
*/
|
|
10668
|
+
function docId(path) {
|
|
10669
|
+
if (typeof path !== 'string')
|
|
10670
|
+
return '';
|
|
10671
|
+
let p = path.startsWith('/') ? path.slice(1) : path;
|
|
10672
|
+
if (p.endsWith('*') && p.length > 1)
|
|
10673
|
+
p = p.slice(0, -1);
|
|
10674
|
+
if (p.endsWith('/'))
|
|
10675
|
+
p = p.slice(0, -1);
|
|
10676
|
+
const segments = p.split('/').filter(Boolean);
|
|
10677
|
+
return segments.length ? segments[segments.length - 1] : '';
|
|
10678
|
+
}
|
|
10679
|
+
/**
|
|
10680
|
+
* Additively attach a convenience bare `id` (the leaf doc key) to a returned row.
|
|
10681
|
+
*
|
|
10682
|
+
* Rows already carry `_id`/`pathId` = the full document path; this leaves those
|
|
10683
|
+
* untouched and adds `id` = the last path segment so `row.id` is the doc key apps
|
|
10684
|
+
* expect. No-ops for non-objects, arrays, and rows that already define `id`
|
|
10685
|
+
* (never clobber a user field named `id`). Source for the leaf is `_id` (falling
|
|
10686
|
+
* back to `pathId`/`relativePath`/`absolutePath`).
|
|
10687
|
+
*/
|
|
10688
|
+
function withBareId(row) {
|
|
10689
|
+
var _a, _b, _c;
|
|
10690
|
+
if (!row || typeof row !== 'object' || Array.isArray(row))
|
|
10691
|
+
return row;
|
|
10692
|
+
const r = row;
|
|
10693
|
+
if ('id' in r)
|
|
10694
|
+
return row; // don't clobber an explicit user field
|
|
10695
|
+
const source = (_c = (_b = (_a = r._id) !== null && _a !== void 0 ? _a : r.pathId) !== null && _b !== void 0 ? _b : r.relativePath) !== null && _c !== void 0 ? _c : r.absolutePath;
|
|
10696
|
+
if (typeof source !== 'string' || source.length === 0)
|
|
10697
|
+
return row;
|
|
10698
|
+
const leaf = docId(source);
|
|
10699
|
+
if (!leaf)
|
|
10700
|
+
return row;
|
|
10701
|
+
return Object.assign(Object.assign({}, r), { id: leaf });
|
|
10702
|
+
}
|
|
10703
|
+
/**
|
|
10704
|
+
* Normalize a raw read response from the worker into the SDK's stable shape and
|
|
10705
|
+
* attach the bare `id` to every returned row (Bug 1 + Bug 2).
|
|
10706
|
+
*
|
|
10707
|
+
* - Single-document path: returns EXACTLY ONE shape — the resolved document, or
|
|
10708
|
+
* `null` if missing (Firebase/Mongo convention). Unwraps the ambiguous
|
|
10709
|
+
* `{ data, status }` envelope the worker sometimes emits for a single doc so a
|
|
10710
|
+
* single-doc `get` never sometimes-returns the doc and sometimes the envelope.
|
|
10711
|
+
* - Collection path: preserves the `{ data, nextCursor, ... }` envelope and maps
|
|
10712
|
+
* the bare `id` onto each row in `data`.
|
|
10713
|
+
*/
|
|
10714
|
+
function normalizeReadResult(responseData, pathIsDocument) {
|
|
10715
|
+
if (pathIsDocument) {
|
|
10716
|
+
let doc = responseData;
|
|
10717
|
+
// Unwrap the single-doc envelope `{ data, status }` (Bug 2). A real document
|
|
10718
|
+
// never has the exact shape `{ data, status }` with nothing else meaningful,
|
|
10719
|
+
// so detect the envelope by `data` being present alongside a numeric `status`.
|
|
10720
|
+
if (doc && typeof doc === 'object' && !Array.isArray(doc) &&
|
|
10721
|
+
'data' in doc && 'status' in doc && typeof doc.status === 'number') {
|
|
10722
|
+
doc = doc.data;
|
|
10723
|
+
}
|
|
10724
|
+
if (doc === undefined || doc === null)
|
|
10725
|
+
return null;
|
|
10726
|
+
return withBareId(doc);
|
|
10727
|
+
}
|
|
10728
|
+
// Collection read. The worker body is `{ data: rows[], nextCursor?, status? }`.
|
|
10729
|
+
if (responseData && typeof responseData === 'object' && !Array.isArray(responseData) && Array.isArray(responseData.data)) {
|
|
10730
|
+
return Object.assign(Object.assign({}, responseData), { data: responseData.data.map((row) => withBareId(row)) });
|
|
10731
|
+
}
|
|
10732
|
+
// Some paths return a bare array of rows — map id onto each.
|
|
10733
|
+
if (Array.isArray(responseData)) {
|
|
10734
|
+
return responseData.map((row) => withBareId(row));
|
|
10735
|
+
}
|
|
10736
|
+
return responseData;
|
|
10737
|
+
}
|
|
10657
10738
|
function hashForKey$1(value) {
|
|
10658
10739
|
let h = 5381;
|
|
10659
10740
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -11078,7 +11159,7 @@ async function get(path, opts = {}) {
|
|
|
11078
11159
|
if (hasActiveConnection()) {
|
|
11079
11160
|
if (pathIsDocument) {
|
|
11080
11161
|
const wsResult = await wsGet(normalizedPath);
|
|
11081
|
-
const responseData = wsResult;
|
|
11162
|
+
const responseData = normalizeReadResult(wsResult, true);
|
|
11082
11163
|
if (!opts.bypassCache) {
|
|
11083
11164
|
getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
|
|
11084
11165
|
}
|
|
@@ -11090,7 +11171,7 @@ async function get(path, opts = {}) {
|
|
|
11090
11171
|
sort: undefined,
|
|
11091
11172
|
includeSubPaths: opts.includeSubPaths,
|
|
11092
11173
|
});
|
|
11093
|
-
const responseData = wsResult;
|
|
11174
|
+
const responseData = normalizeReadResult(wsResult, false);
|
|
11094
11175
|
if (!opts.bypassCache) {
|
|
11095
11176
|
getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
|
|
11096
11177
|
}
|
|
@@ -11121,7 +11202,11 @@ async function get(path, opts = {}) {
|
|
|
11121
11202
|
const apiPath = `items?path=${path}${promptQueryParam}${filterParam}${sortParam}${includeSubPathsParam}${shapeParam}${limitParam}${cursorParam}`;
|
|
11122
11203
|
response = await makeApiRequest('GET', apiPath, null, opts._overrides);
|
|
11123
11204
|
}
|
|
11124
|
-
|
|
11205
|
+
// Normalize the worker's raw body into the SDK's stable shape:
|
|
11206
|
+
// - single-doc path → the resolved document or null (Bug 2), and
|
|
11207
|
+
// - collection path → `{ data, nextCursor }` preserved,
|
|
11208
|
+
// with the bare `id` (leaf doc key) attached to every returned row (Bug 1).
|
|
11209
|
+
const responseData = normalizeReadResult(response.data, pathIsDocument);
|
|
11125
11210
|
// Cache the response (unless bypassing cache)
|
|
11126
11211
|
if (!opts.bypassCache) {
|
|
11127
11212
|
getCache[cacheKey] = {
|
|
@@ -11219,11 +11304,16 @@ async function getMany(paths, opts = {}) {
|
|
|
11219
11304
|
const normalizedPath = uncachedPaths[i];
|
|
11220
11305
|
const serverResult = serverResultsMap.get(normalizedPath);
|
|
11221
11306
|
if (serverResult) {
|
|
11222
|
-
|
|
11223
|
-
|
|
11307
|
+
// getMany batches single-doc paths — attach the bare `id` (leaf doc
|
|
11308
|
+
// key) to each returned doc, additive (Bug 1), matching get().
|
|
11309
|
+
const normalizedResult = serverResult.error
|
|
11310
|
+
? serverResult
|
|
11311
|
+
: Object.assign(Object.assign({}, serverResult), { data: withBareId(serverResult.data) });
|
|
11312
|
+
results[originalIndex] = normalizedResult;
|
|
11313
|
+
if (!normalizedResult.error && !opts.bypassCache) {
|
|
11224
11314
|
const cacheKey = `${principalKey}|${normalizedPath}:`;
|
|
11225
11315
|
getCache[cacheKey] = {
|
|
11226
|
-
data:
|
|
11316
|
+
data: normalizedResult.data,
|
|
11227
11317
|
expiresAt: now + GET_CACHE_TTL
|
|
11228
11318
|
};
|
|
11229
11319
|
}
|
|
@@ -11768,6 +11858,7 @@ var operations = /*#__PURE__*/Object.freeze({
|
|
|
11768
11858
|
aggregate: aggregate,
|
|
11769
11859
|
clearReadCacheForAuthChange: clearReadCacheForAuthChange,
|
|
11770
11860
|
count: count,
|
|
11861
|
+
docId: docId,
|
|
11771
11862
|
get: get,
|
|
11772
11863
|
getFiles: getFiles,
|
|
11773
11864
|
getMany: getMany,
|
|
@@ -12355,14 +12446,46 @@ function handleServerMessage(connection, message) {
|
|
|
12355
12446
|
}
|
|
12356
12447
|
}
|
|
12357
12448
|
}
|
|
12449
|
+
/**
|
|
12450
|
+
* Additively attach the bare `id` (leaf doc key) to a subscription row (Bug 1).
|
|
12451
|
+
* Rows carry `_id`/`pathId` = the full document path; this leaves those as-is and
|
|
12452
|
+
* adds `id` = the last path segment so `row.id` is the doc key apps expect. No-ops
|
|
12453
|
+
* for non-objects and rows that already define `id`.
|
|
12454
|
+
*/
|
|
12455
|
+
function withSubscriptionId(row) {
|
|
12456
|
+
var _a, _b, _c;
|
|
12457
|
+
if (!row || typeof row !== 'object' || Array.isArray(row))
|
|
12458
|
+
return row;
|
|
12459
|
+
if ('id' in row)
|
|
12460
|
+
return row;
|
|
12461
|
+
const source = (_c = (_b = (_a = row._id) !== null && _a !== void 0 ? _a : row.pathId) !== null && _b !== void 0 ? _b : row.relativePath) !== null && _c !== void 0 ? _c : row.absolutePath;
|
|
12462
|
+
if (typeof source !== 'string' || source.length === 0)
|
|
12463
|
+
return row;
|
|
12464
|
+
const leaf = docId(source);
|
|
12465
|
+
if (!leaf)
|
|
12466
|
+
return row;
|
|
12467
|
+
return Object.assign(Object.assign({}, row), { id: leaf });
|
|
12468
|
+
}
|
|
12469
|
+
/**
|
|
12470
|
+
* The `onData` payload follows the path: a collection delivers a bare array of
|
|
12471
|
+
* rows, a single-doc path delivers the document (or null). Attach the bare `id`
|
|
12472
|
+
* to each returned row in either case, additive (Bug 1).
|
|
12473
|
+
*/
|
|
12474
|
+
function addIdsToSubscriptionData(data) {
|
|
12475
|
+
if (Array.isArray(data))
|
|
12476
|
+
return data.map(withSubscriptionId);
|
|
12477
|
+
return withSubscriptionId(data);
|
|
12478
|
+
}
|
|
12358
12479
|
function notifyCallbacks(subscription, data) {
|
|
12359
12480
|
var _a;
|
|
12481
|
+
// Attach the bare `id` (leaf doc key) to every delivered row (Bug 1).
|
|
12482
|
+
const decorated = addIdsToSubscriptionData(data);
|
|
12360
12483
|
// Snapshot the callbacks array so that unsubscriptions during
|
|
12361
12484
|
// notification don't cause callbacks to be skipped.
|
|
12362
12485
|
const callbacks = subscription.callbacks.slice();
|
|
12363
12486
|
for (const callback of callbacks) {
|
|
12364
12487
|
try {
|
|
12365
|
-
(_a = callback.onData) === null || _a === void 0 ? void 0 : _a.call(callback,
|
|
12488
|
+
(_a = callback.onData) === null || _a === void 0 ? void 0 : _a.call(callback, decorated);
|
|
12366
12489
|
}
|
|
12367
12490
|
catch (error) {
|
|
12368
12491
|
console.error('[WS v2] Error in subscription callback:', error);
|
|
@@ -12453,7 +12576,7 @@ async function subscribeV2(path, subscriptionOptions, roomRoutePath) {
|
|
|
12453
12576
|
if (cachedEntry && Date.now() - cachedEntry.timestamp < CACHE_TTL && subscriptionOptions.onData) {
|
|
12454
12577
|
setTimeout(() => {
|
|
12455
12578
|
var _a;
|
|
12456
|
-
(_a = subscriptionOptions.onData) === null || _a === void 0 ? void 0 : _a.call(subscriptionOptions, cachedEntry.data);
|
|
12579
|
+
(_a = subscriptionOptions.onData) === null || _a === void 0 ? void 0 : _a.call(subscriptionOptions, addIdsToSubscriptionData(cachedEntry.data));
|
|
12457
12580
|
}, 0);
|
|
12458
12581
|
}
|
|
12459
12582
|
// Get or create connection for this routing target (room-scoped when a
|
|
@@ -12483,7 +12606,7 @@ async function subscribeV2(path, subscriptionOptions, roomRoutePath) {
|
|
|
12483
12606
|
if (existingSubscription.lastData !== undefined && subscriptionOptions.onData) {
|
|
12484
12607
|
setTimeout(() => {
|
|
12485
12608
|
var _a;
|
|
12486
|
-
(_a = subscriptionOptions.onData) === null || _a === void 0 ? void 0 : _a.call(subscriptionOptions, existingSubscription.lastData);
|
|
12609
|
+
(_a = subscriptionOptions.onData) === null || _a === void 0 ? void 0 : _a.call(subscriptionOptions, addIdsToSubscriptionData(existingSubscription.lastData));
|
|
12487
12610
|
}, 0);
|
|
12488
12611
|
}
|
|
12489
12612
|
return async () => {
|
|
@@ -12991,6 +13114,73 @@ function serverTimestamp() {
|
|
|
12991
13114
|
return { operation: 'time', value: 'now' };
|
|
12992
13115
|
}
|
|
12993
13116
|
|
|
13117
|
+
/**
|
|
13118
|
+
* Time units in Bounded — read this once and never get a 1000× timestamp bug.
|
|
13119
|
+
*
|
|
13120
|
+
* **Bounded's policy/proof layer is Unix SECONDS.** `@time.now` in a rule,
|
|
13121
|
+
* `rollingSum` `windowSeconds`, `scheduledAt`, and any timestamp *field your
|
|
13122
|
+
* policy compares against `@time.now`* are all **seconds**. (This is also what
|
|
13123
|
+
* the chain uses — Solana's on-chain clock is `unix_timestamp` in seconds — so a
|
|
13124
|
+
* single seconds unit works for both onchain and offchain rules.)
|
|
13125
|
+
*
|
|
13126
|
+
* **JavaScript is MILLISECONDS.** `Date.now()`, `new Date().getTime()`, and the
|
|
13127
|
+
* auto-stamped system fields `_createdAt` / `_updatedAt` are all **ms**.
|
|
13128
|
+
*
|
|
13129
|
+
* Comparing across the two (e.g. `@time.now - myField` where `myField` was set
|
|
13130
|
+
* from `Date.now()`) is 1000× off, so a freshness / TTL check silently treats
|
|
13131
|
+
* every row as ancient (or far-future) and drops it — which reads as "realtime
|
|
13132
|
+
* isn't delivering" when the data is actually fine.
|
|
13133
|
+
*
|
|
13134
|
+
* **The rules:**
|
|
13135
|
+
* - To **write** a timestamp a policy will read, prefer **`serverTimestamp()`**
|
|
13136
|
+
* (from this package) — the *server* stamps it in seconds, so it matches
|
|
13137
|
+
* `@time.now` AND can't be forged by the client (use it for TTLs, rate windows,
|
|
13138
|
+
* anti-cheat). Use `now()` only when you need the value in client code before
|
|
13139
|
+
* the write.
|
|
13140
|
+
* - To **compare** timestamps in client/render code, use `now()` (seconds), not
|
|
13141
|
+
* `Date.now()` (ms), and `toSeconds()` to convert the ms system fields
|
|
13142
|
+
* (`_createdAt`/`_updatedAt`) or any `Date.now()` value first.
|
|
13143
|
+
*/
|
|
13144
|
+
/**
|
|
13145
|
+
* Current time as a **Unix timestamp in seconds** — the unit Bounded policy rules
|
|
13146
|
+
* use (`@time.now`). Use this (not `Date.now()`) when you need a timestamp in
|
|
13147
|
+
* client code (e.g. a freshness check). For a value you *store* and a policy
|
|
13148
|
+
* reads, prefer the server-authoritative {@link serverTimestamp} instead.
|
|
13149
|
+
*
|
|
13150
|
+
* ```ts
|
|
13151
|
+
* // stale if >15s old — seconds vs seconds ✓
|
|
13152
|
+
* if (now() - doc.lastSeenSeconds > 15) renderStale();
|
|
13153
|
+
* ```
|
|
13154
|
+
*/
|
|
13155
|
+
function now() {
|
|
13156
|
+
return Math.floor(Date.now() / 1000);
|
|
13157
|
+
}
|
|
13158
|
+
/**
|
|
13159
|
+
* Convert a JavaScript millisecond timestamp to Bounded's **seconds**. Accepts a
|
|
13160
|
+
* `Date`, or an ms number such as `Date.now()` or a doc's `_createdAt` /
|
|
13161
|
+
* `_updatedAt` system field.
|
|
13162
|
+
*
|
|
13163
|
+
* ```ts
|
|
13164
|
+
* // doc is >15s old (compare the ms system field in seconds):
|
|
13165
|
+
* if (now() - toSeconds(doc._updatedAt) > 15) renderStale();
|
|
13166
|
+
* ```
|
|
13167
|
+
*/
|
|
13168
|
+
function toSeconds(msOrDate) {
|
|
13169
|
+
const ms = msOrDate instanceof Date ? msOrDate.getTime() : msOrDate;
|
|
13170
|
+
return Math.floor(ms / 1000);
|
|
13171
|
+
}
|
|
13172
|
+
/**
|
|
13173
|
+
* Convert a Bounded **seconds** timestamp back to JavaScript **milliseconds** —
|
|
13174
|
+
* e.g. to build a `Date` or do client-side date math/formatting.
|
|
13175
|
+
*
|
|
13176
|
+
* ```ts
|
|
13177
|
+
* new Date(toMillis(doc.createdAtSeconds)).toLocaleString();
|
|
13178
|
+
* ```
|
|
13179
|
+
*/
|
|
13180
|
+
function toMillis(seconds) {
|
|
13181
|
+
return seconds * 1000;
|
|
13182
|
+
}
|
|
13183
|
+
|
|
12994
13184
|
// ---------------------------------------------------------------------------
|
|
12995
13185
|
// realtime-store.ts — Client-side state manager for realtime apps.
|
|
12996
13186
|
//
|
|
@@ -21559,17 +21749,17 @@ function setAuthProviderInstance(provider) {
|
|
|
21559
21749
|
authProviderInstance = provider;
|
|
21560
21750
|
}
|
|
21561
21751
|
|
|
21562
|
-
var _a;
|
|
21752
|
+
var _a$1;
|
|
21563
21753
|
// Whether we're in a server-side rendering context (no hooks allowed).
|
|
21564
21754
|
// React Native has no `window` but DOES support hooks.
|
|
21565
21755
|
// We detect Node SSR specifically via process.versions.node to avoid
|
|
21566
21756
|
// false positives from Node 21+ which defines `navigator` globally.
|
|
21567
|
-
const isSSR = typeof window === 'undefined'
|
|
21757
|
+
const isSSR$1 = typeof window === 'undefined'
|
|
21568
21758
|
&& typeof process !== 'undefined'
|
|
21569
|
-
&& !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
21759
|
+
&& !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
|
|
21570
21760
|
function useAuth() {
|
|
21571
21761
|
// Provide a fallback so server render doesn't break
|
|
21572
|
-
if (isSSR) {
|
|
21762
|
+
if (isSSR$1) {
|
|
21573
21763
|
return {
|
|
21574
21764
|
login: async () => undefined,
|
|
21575
21765
|
logout: async () => undefined,
|
|
@@ -21629,6 +21819,66 @@ function useAuth() {
|
|
|
21629
21819
|
};
|
|
21630
21820
|
}
|
|
21631
21821
|
|
|
21822
|
+
var _a;
|
|
21823
|
+
// SSR guard (mirrors useAuth): no hooks/subscriptions during Node server render.
|
|
21824
|
+
// React Native has no `window` but DOES support hooks, so detect Node SSR
|
|
21825
|
+
// specifically via process.versions.node.
|
|
21826
|
+
const isSSR = typeof window === 'undefined'
|
|
21827
|
+
&& typeof process !== 'undefined'
|
|
21828
|
+
&& !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
21829
|
+
function useQuery(path, options) {
|
|
21830
|
+
if (isSSR) {
|
|
21831
|
+
return { data: undefined, loading: true, error: null };
|
|
21832
|
+
}
|
|
21833
|
+
const [data, setData] = React__namespace.useState(undefined);
|
|
21834
|
+
const [loading, setLoading] = React__namespace.useState(true);
|
|
21835
|
+
const [error, setError] = React__namespace.useState(null);
|
|
21836
|
+
// Re-subscribe only when the query actually changes (not on every render).
|
|
21837
|
+
const optionsKey = options ? JSON.stringify(options) : '';
|
|
21838
|
+
React__namespace.useEffect(() => {
|
|
21839
|
+
if (!path) {
|
|
21840
|
+
setData(undefined);
|
|
21841
|
+
setLoading(false);
|
|
21842
|
+
setError(null);
|
|
21843
|
+
return;
|
|
21844
|
+
}
|
|
21845
|
+
let active = true;
|
|
21846
|
+
let unsubscribe;
|
|
21847
|
+
setLoading(true);
|
|
21848
|
+
setError(null);
|
|
21849
|
+
subscribe(path, Object.assign(Object.assign({}, options), { onData: (d) => {
|
|
21850
|
+
if (!active)
|
|
21851
|
+
return;
|
|
21852
|
+
setData(d);
|
|
21853
|
+
setLoading(false);
|
|
21854
|
+
}, onError: (e) => {
|
|
21855
|
+
if (!active)
|
|
21856
|
+
return;
|
|
21857
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
21858
|
+
setLoading(false);
|
|
21859
|
+
} }))
|
|
21860
|
+
.then((unsub) => {
|
|
21861
|
+
if (active)
|
|
21862
|
+
unsubscribe = unsub;
|
|
21863
|
+
else
|
|
21864
|
+
void unsub(); // unmounted before subscribe resolved
|
|
21865
|
+
})
|
|
21866
|
+
.catch((e) => {
|
|
21867
|
+
if (!active)
|
|
21868
|
+
return;
|
|
21869
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
21870
|
+
setLoading(false);
|
|
21871
|
+
});
|
|
21872
|
+
return () => {
|
|
21873
|
+
active = false;
|
|
21874
|
+
void (unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
|
|
21875
|
+
};
|
|
21876
|
+
// optionsKey captures the option object's contents; path is the other input.
|
|
21877
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21878
|
+
}, [path, optionsKey]);
|
|
21879
|
+
return { data, loading, error };
|
|
21880
|
+
}
|
|
21881
|
+
|
|
21632
21882
|
async function deserializeTransaction(tx) {
|
|
21633
21883
|
const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
|
|
21634
21884
|
if ((buf[0] & 0x80) !== 0) {
|
|
@@ -21762,7 +22012,7 @@ async function loadDependencies() {
|
|
|
21762
22012
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
21763
22013
|
import('react'),
|
|
21764
22014
|
import('react-dom/client'),
|
|
21765
|
-
Promise.resolve().then(function () { return require('./index-
|
|
22015
|
+
Promise.resolve().then(function () { return require('./index-CdqFc68L.js'); })
|
|
21766
22016
|
]);
|
|
21767
22017
|
// Extract default export from ESM module namespace
|
|
21768
22018
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -23663,7 +23913,7 @@ async function registerMobileWalletAdapter(config) {
|
|
|
23663
23913
|
if (typeof window === 'undefined')
|
|
23664
23914
|
return;
|
|
23665
23915
|
try {
|
|
23666
|
-
const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-
|
|
23916
|
+
const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-sADlt75X.js'); });
|
|
23667
23917
|
const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
|
|
23668
23918
|
if (!registerMwa) {
|
|
23669
23919
|
console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
|
|
@@ -23802,7 +24052,7 @@ class SolanaMobileWalletProvider {
|
|
|
23802
24052
|
async ensureWallet() {
|
|
23803
24053
|
if (this.wallet)
|
|
23804
24054
|
return this.wallet;
|
|
23805
|
-
const mod = await Promise.resolve().then(function () { return require('./index.browser-
|
|
24055
|
+
const mod = await Promise.resolve().then(function () { return require('./index.browser-sADlt75X.js'); });
|
|
23806
24056
|
const chain = mapChainToWalletStandard(this.cluster);
|
|
23807
24057
|
this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
|
|
23808
24058
|
appIdentity: this.appIdentity,
|
|
@@ -25964,6 +26214,7 @@ exports.createSessionWithSignature = createSessionWithSignature;
|
|
|
25964
26214
|
exports.defineLiveModule = defineLiveModule;
|
|
25965
26215
|
exports.deriveUserIdentityFromIdToken = deriveUserIdentityFromIdToken;
|
|
25966
26216
|
exports.deserializeTransaction = deserializeTransaction;
|
|
26217
|
+
exports.docId = docId;
|
|
25967
26218
|
exports.functions = functions;
|
|
25968
26219
|
exports.genAuthNonce = genAuthNonce;
|
|
25969
26220
|
exports.genSolanaMessage = genSolanaMessage;
|
|
@@ -25996,6 +26247,7 @@ exports.loginWithPopup = loginWithPopup;
|
|
|
25996
26247
|
exports.loginWithPrivy = loginWithPrivy;
|
|
25997
26248
|
exports.loginWithRedirect = loginWithRedirect;
|
|
25998
26249
|
exports.logout = logout;
|
|
26250
|
+
exports.now = now;
|
|
25999
26251
|
exports.onAuthLoadingChanged = onAuthLoadingChanged;
|
|
26000
26252
|
exports.onAuthStateChanged = onAuthStateChanged;
|
|
26001
26253
|
exports.queryAggregate = queryAggregate;
|
|
@@ -26023,7 +26275,10 @@ exports.signTransaction = signTransaction;
|
|
|
26023
26275
|
exports.status = status;
|
|
26024
26276
|
exports.subscribe = subscribe;
|
|
26025
26277
|
exports.subscribeView = subscribeView;
|
|
26278
|
+
exports.toMillis = toMillis;
|
|
26279
|
+
exports.toSeconds = toSeconds;
|
|
26026
26280
|
exports.useAuth = useAuth;
|
|
26281
|
+
exports.useQuery = useQuery;
|
|
26027
26282
|
exports.verifyEmailOtp = verifyEmailOtp;
|
|
26028
26283
|
exports.withEffects = withEffects;
|
|
26029
26284
|
exports.wsDelete = wsDelete;
|
|
@@ -26031,4 +26286,4 @@ exports.wsGet = wsGet;
|
|
|
26031
26286
|
exports.wsGetMany = wsGetMany;
|
|
26032
26287
|
exports.wsQuery = wsQuery;
|
|
26033
26288
|
exports.wsSet = wsSet;
|
|
26034
|
-
//# sourceMappingURL=index-
|
|
26289
|
+
//# sourceMappingURL=index-ZYhdEVCA.js.map
|